comparison test/unit/project_test.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
131 def test_identifier_should_not_be_frozen_for_a_new_project 131 def test_identifier_should_not_be_frozen_for_a_new_project
132 assert_equal false, Project.new.identifier_frozen? 132 assert_equal false, Project.new.identifier_frozen?
133 end 133 end
134 134
135 def test_identifier_should_not_be_frozen_for_a_saved_project_with_blank_identifier 135 def test_identifier_should_not_be_frozen_for_a_saved_project_with_blank_identifier
136 Project.update_all(["identifier = ''"], "id = 1") 136 Project.where(:id => 1).update_all(["identifier = ''"])
137
138 assert_equal false, Project.find(1).identifier_frozen? 137 assert_equal false, Project.find(1).identifier_frozen?
139 end 138 end
140 139
141 def test_identifier_should_be_frozen_for_a_saved_project_with_valid_identifier 140 def test_identifier_should_be_frozen_for_a_saved_project_with_valid_identifier
142 assert_equal true, Project.find(1).identifier_frozen? 141 assert_equal true, Project.find(1).identifier_frozen?
201 200
202 def test_destroy 201 def test_destroy
203 # 2 active members 202 # 2 active members
204 assert_equal 2, @ecookbook.members.size 203 assert_equal 2, @ecookbook.members.size
205 # and 1 is locked 204 # and 1 is locked
206 assert_equal 3, Member.where('project_id = ?', @ecookbook.id).all.size 205 assert_equal 3, Member.where(:project_id => @ecookbook.id).count
207 # some boards 206 # some boards
208 assert @ecookbook.boards.any? 207 assert @ecookbook.boards.any?
209 208
210 @ecookbook.destroy 209 @ecookbook.destroy
211 # make sure that the project non longer exists 210 # make sure that the project non longer exists
223 assert_equal 2, issues[1].children.count 222 assert_equal 2, issues[1].children.count
224 223
225 assert_nothing_raised do 224 assert_nothing_raised do
226 Project.find(1).destroy 225 Project.find(1).destroy
227 end 226 end
228 assert Issue.find_all_by_id(issues.map(&:id)).empty? 227 assert_equal 0, Issue.where(:id => issues.map(&:id)).count
229 end 228 end
230 229
231 def test_destroying_root_projects_should_clear_data 230 def test_destroying_root_projects_should_clear_data
232 Project.roots.each do |root| 231 Project.roots.each do |root|
233 root.destroy 232 root.destroy
256 assert_equal 0, Watcher.count 255 assert_equal 0, Watcher.count
257 assert_equal 0, Wiki.count 256 assert_equal 0, Wiki.count
258 assert_equal 0, WikiPage.count 257 assert_equal 0, WikiPage.count
259 assert_equal 0, WikiContent.count 258 assert_equal 0, WikiContent.count
260 assert_equal 0, WikiContent::Version.count 259 assert_equal 0, WikiContent::Version.count
261 assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size 260 assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").count
262 assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size 261 assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").count
263 assert_equal 0, CustomValue.where(:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']).count 262 assert_equal 0, CustomValue.where(:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']).count
263 end
264
265 def test_destroy_should_delete_time_entries_custom_values
266 project = Project.generate!
267 time_entry = TimeEntry.generate!(:project => project, :custom_field_values => {10 => '1'})
268
269 assert_difference 'CustomValue.where(:customized_type => "TimeEntry").count', -1 do
270 assert project.destroy
271 end
264 end 272 end
265 273
266 def test_move_an_orphan_project_to_a_root_project 274 def test_move_an_orphan_project_to_a_root_project
267 sub = Project.find(2) 275 sub = Project.find(2)
268 sub.set_parent! @ecookbook 276 sub.set_parent! @ecookbook
574 private_child = parent.children.find(5) 582 private_child = parent.children.find(5)
575 583
576 assert_equal [1,2,3], parent.version_ids.sort 584 assert_equal [1,2,3], parent.version_ids.sort
577 assert_equal [4], child.version_ids 585 assert_equal [4], child.version_ids
578 assert_equal [6], private_child.version_ids 586 assert_equal [6], private_child.version_ids
579 assert_equal [7], Version.find_all_by_sharing('system').collect(&:id) 587 assert_equal [7], Version.where(:sharing => 'system').collect(&:id)
580 588
581 assert_equal 6, parent.shared_versions.size 589 assert_equal 6, parent.shared_versions.size
582 parent.shared_versions.each do |version| 590 parent.shared_versions.each do |version|
583 assert_kind_of Version, version 591 assert_kind_of Version, version
584 end 592 end
720 end 728 end
721 729
722 def test_activities_should_use_the_system_activities 730 def test_activities_should_use_the_system_activities
723 project = Project.find(1) 731 project = Project.find(1)
724 assert_equal project.activities, TimeEntryActivity.where(:active => true).all 732 assert_equal project.activities, TimeEntryActivity.where(:active => true).all
733 assert_kind_of ActiveRecord::Relation, project.activities
725 end 734 end
726 735
727 736
728 def test_activities_should_use_the_project_specific_activities 737 def test_activities_should_use_the_project_specific_activities
729 project = Project.find(1) 738 project = Project.find(1)
730 overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project}) 739 overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project})
731 assert overridden_activity.save! 740 assert overridden_activity.save!
732 741
733 assert project.activities.include?(overridden_activity), "Project specific Activity not found" 742 assert project.activities.include?(overridden_activity), "Project specific Activity not found"
743 assert_kind_of ActiveRecord::Relation, project.activities
734 end 744 end
735 745
736 def test_activities_should_not_include_the_inactive_project_specific_activities 746 def test_activities_should_not_include_the_inactive_project_specific_activities
737 project = Project.find(1) 747 project = Project.find(1)
738 overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.first, :active => false}) 748 overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.first, :active => false})