diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-15 13:33:09 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-15 13:33:09 +0000 |
commit | 4601ed2f3aebc545024287e318494ce32bc5803f (patch) | |
tree | 40f4bda265bbc92f9ddaed1bca6deb7769f2ccae /test | |
parent | 13e2c727cfa7b3a9e3e9bd0563cda0a15ee3892d (diff) | |
download | redmine-4601ed2f3aebc545024287e318494ce32bc5803f.tar.gz redmine-4601ed2f3aebc545024287e318494ce32bc5803f.zip |
Replaces Enumeration.get_values and Enumeration.default with named scopes.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2472 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/issues_controller_test.rb | 4 | ||||
-rw-r--r-- | test/unit/enumeration_test.rb | 16 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 10 |
3 files changed, 15 insertions, 15 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index cc1c77408..25100f9a0 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -640,7 +640,7 @@ class IssuesControllerTest < Test::Unit::TestCase :id => 1, :issue => { :status_id => 2, :assigned_to_id => 3 }, :notes => 'Assigned to dlopper', - :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } + :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.activities.first } end assert_redirected_to :action => 'show', :id => '1' issue.reload @@ -676,7 +676,7 @@ class IssuesControllerTest < Test::Unit::TestCase post :edit, :id => 1, :notes => '2.5 hours added', - :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first } + :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.activities.first } end assert_redirected_to :action => 'show', :id => '1' diff --git a/test/unit/enumeration_test.rb b/test/unit/enumeration_test.rb index 4da3f094b..c192cee8f 100644 --- a/test/unit/enumeration_test.rb +++ b/test/unit/enumeration_test.rb @@ -38,7 +38,7 @@ class EnumerationTest < Test::Unit::TestCase end def test_default - e = Enumeration.default('IPRI') + e = Enumeration.priorities.default assert e.is_a?(Enumeration) assert e.is_default? assert_equal 'Normal', e.name @@ -47,31 +47,31 @@ class EnumerationTest < Test::Unit::TestCase def test_create e = Enumeration.new(:opt => 'IPRI', :name => 'Very urgent', :is_default => false) assert e.save - assert_equal 'Normal', Enumeration.default('IPRI').name + assert_equal 'Normal', Enumeration.priorities.default.name end def test_create_as_default e = Enumeration.new(:opt => 'IPRI', :name => 'Very urgent', :is_default => true) assert e.save - assert_equal e, Enumeration.default('IPRI') + assert_equal e, Enumeration.priorities.default end def test_update_default - e = Enumeration.default('IPRI') + e = Enumeration.priorities.default e.update_attributes(:name => 'Changed', :is_default => true) - assert_equal e, Enumeration.default('IPRI') + assert_equal e, Enumeration.priorities.default end def test_update_default_to_non_default - e = Enumeration.default('IPRI') + e = Enumeration.priorities.default e.update_attributes(:name => 'Changed', :is_default => false) - assert_nil Enumeration.default('IPRI') + assert_nil Enumeration.priorities.default end def test_change_default e = Enumeration.find_by_name('Urgent') e.update_attributes(:name => 'Urgent', :is_default => true) - assert_equal e, Enumeration.default('IPRI') + assert_equal e, Enumeration.priorities.default end def test_destroy_with_reassign diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 89ec3c6da..bfe29f552 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -27,14 +27,14 @@ class IssueTest < Test::Unit::TestCase :time_entries def test_create - issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'test_create', :description => 'IssueTest#test_create', :estimated_hours => '1:30') + issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'test_create', :description => 'IssueTest#test_create', :estimated_hours => '1:30') assert issue.save issue.reload assert_equal 1.5, issue.estimated_hours end def test_create_minimal - issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'test_create') + issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'test_create') assert issue.save assert issue.description.nil? end @@ -110,7 +110,7 @@ class IssueTest < Test::Unit::TestCase end def test_category_based_assignment - issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) + issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to end @@ -126,7 +126,7 @@ class IssueTest < Test::Unit::TestCase def test_should_close_duplicates # Create 3 issues - issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Duplicates test', :description => 'Duplicates test') + issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Duplicates test', :description => 'Duplicates test') assert issue1.save issue2 = issue1.clone assert issue2.save @@ -153,7 +153,7 @@ class IssueTest < Test::Unit::TestCase def test_should_not_close_duplicated_issue # Create 3 issues - issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Duplicates test', :description => 'Duplicates test') + issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Duplicates test', :description => 'Duplicates test') assert issue1.save issue2 = issue1.clone assert issue2.save |