summaryrefslogtreecommitdiffstats
path: root/test/unit/project_test.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-10-21 22:34:39 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-10-21 22:34:39 +0000
commite615266e9a036811c7f73a471ba48b5bbe27adfe (patch)
tree83458d985c737f3cd898278d1066015eac395547 /test/unit/project_test.rb
parent29301c8a381aa5995a0ce2e10ad91f210dc6464f (diff)
downloadredmine-e615266e9a036811c7f73a471ba48b5bbe27adfe.tar.gz
redmine-e615266e9a036811c7f73a471ba48b5bbe27adfe.zip
Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities
* Added Project#activities to return all the Systemwide and Project specific activities, excluding Systemwide ones that are overridden. * Added some tests for TimelogHelper. #4077 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2948 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/project_test.rb')
-rw-r--r--test/unit/project_test.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index fa163cfad..7ac9bf382 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -313,6 +313,53 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal 1, copied_project.status
end
+ def test_activities_should_use_the_system_activities
+ project = Project.find(1)
+ assert_equal project.activities, TimeEntryActivity.find(:all, :conditions => {:active => true} )
+ end
+
+
+ def test_activities_should_use_the_project_specific_activities
+ project = Project.find(1)
+ overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project})
+ assert overridden_activity.save!
+
+ assert project.activities.include?(overridden_activity), "Project specific Activity not found"
+ end
+
+ def test_activities_should_not_include_the_inactive_project_specific_activities
+ project = Project.find(1)
+ overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.find(:first), :active => false})
+ assert overridden_activity.save!
+
+ assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity found"
+ end
+
+ def test_activities_should_not_include_project_specific_activities_from_other_projects
+ project = Project.find(1)
+ overridden_activity = TimeEntryActivity.new({:name => "Project", :project => Project.find(2)})
+ assert overridden_activity.save!
+
+ assert !project.activities.include?(overridden_activity), "Project specific Activity found on a different project"
+ end
+
+ def test_activities_should_handle_nils
+ TimeEntryActivity.delete_all
+
+ project = Project.find(1)
+ assert project.activities.empty?
+ end
+
+ def test_activities_should_override_system_activities_with_project_activities
+ project = Project.find(1)
+ parent_activity = TimeEntryActivity.find(:first)
+ overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => parent_activity})
+ assert overridden_activity.save!
+
+ assert project.activities.include?(overridden_activity), "Project specific Activity not found"
+ assert !project.activities.include?(parent_activity), "System Activity found when it should have been overridden"
+ end
+
context "Project#copy" do
setup do
ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests