diff options
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/document_category_test.rb | 4 | ||||
-rw-r--r-- | test/unit/enumeration_test.rb | 2 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 11 | ||||
-rw-r--r-- | test/unit/journal_observer_test.rb | 36 | ||||
-rw-r--r-- | test/unit/journal_test.rb | 4 | ||||
-rw-r--r-- | test/unit/mailer_test.rb | 6 | ||||
-rw-r--r-- | test/unit/news_test.rb | 2 | ||||
-rw-r--r-- | test/unit/project_test.rb | 8 | ||||
-rw-r--r-- | test/unit/repository_cvs_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 2 | ||||
-rw-r--r-- | test/unit/version_test.rb | 12 | ||||
-rw-r--r-- | test/unit/wiki_redirect_test.rb | 2 |
12 files changed, 45 insertions, 46 deletions
diff --git a/test/unit/document_category_test.rb b/test/unit/document_category_test.rb index 03fa1b947..8a474a098 100644 --- a/test/unit/document_category_test.rb +++ b/test/unit/document_category_test.rb @@ -34,14 +34,14 @@ class DocumentCategoryTest < ActiveSupport::TestCase end def test_default - assert_nil DocumentCategory.find(:first, :conditions => { :is_default => true }) + assert_nil DocumentCategory.where(:is_default => true).first e = Enumeration.find_by_name('Technical documentation') e.update_attributes(:is_default => true) assert_equal 3, DocumentCategory.default.id end def test_force_default - assert_nil DocumentCategory.find(:first, :conditions => { :is_default => true }) + assert_nil DocumentCategory.where(:is_default => true).first assert_equal 1, DocumentCategory.default.id end end diff --git a/test/unit/enumeration_test.rb b/test/unit/enumeration_test.rb index bd098a13b..48cd02893 100644 --- a/test/unit/enumeration_test.rb +++ b/test/unit/enumeration_test.rb @@ -86,7 +86,7 @@ class EnumerationTest < ActiveSupport::TestCase def test_destroy_with_reassign Enumeration.find(4).destroy(Enumeration.find(6)) - assert_nil Issue.find(:first, :conditions => {:priority_id => 4}) + assert_nil Issue.where(:priority_id => 4).first assert_equal 6, Enumeration.find(6).objects_count end diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 655edb53c..2bf748682 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -876,7 +876,7 @@ class IssueTest < ActiveSupport::TestCase assert issue1.reload.duplicates.include?(issue2) # Closing issue 1 - issue1.init_journal(User.find(:first), "Closing issue1") + issue1.init_journal(User.first, "Closing issue1") issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true} assert issue1.save # 2 and 3 should be also closed @@ -895,7 +895,7 @@ class IssueTest < ActiveSupport::TestCase assert !issue2.reload.duplicates.include?(issue1) # Closing issue 2 - issue2.init_journal(User.find(:first), "Closing issue2") + issue2.init_journal(User.first, "Closing issue2") issue2.status = IssueStatus.find :first, :conditions => {:is_closed => true} assert issue2.save # 1 should not be also closed @@ -1431,8 +1431,7 @@ class IssueTest < ActiveSupport::TestCase assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue? assert !Issue.new(:due_date => nil).overdue? assert !Issue.new(:due_date => 1.day.ago.to_date, - :status => IssueStatus.find(:first, - :conditions => {:is_closed => true}) + :status => IssueStatus.where(:is_closed => true).first ).overdue? end @@ -1630,7 +1629,7 @@ class IssueTest < ActiveSupport::TestCase end def test_saving_twice_should_not_duplicate_journal_details - i = Issue.find(:first) + i = Issue.first i.init_journal(User.find(2), 'Some notes') # initial changes i.subject = 'New subject' @@ -1639,7 +1638,7 @@ class IssueTest < ActiveSupport::TestCase assert i.save end # 1 more change - i.priority = IssuePriority.find(:first, :conditions => ["id <> ?", i.priority_id]) + i.priority = IssuePriority.where("id <> ?", i.priority_id).first assert_no_difference 'Journal.count' do assert_difference 'JournalDetail.count', 1 do i.save diff --git a/test/unit/journal_observer_test.rb b/test/unit/journal_observer_test.rb index e9049ac8e..d54228210 100644 --- a/test/unit/journal_observer_test.rb +++ b/test/unit/journal_observer_test.rb @@ -29,8 +29,8 @@ class JournalObserverTest < ActiveSupport::TestCase # context: issue_updated notified_events def test_create_should_send_email_notification_with_issue_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) with_settings :notified_events => %w(issue_updated) do @@ -40,8 +40,8 @@ class JournalObserverTest < ActiveSupport::TestCase end def test_create_should_not_send_email_notification_with_notify_set_to_false - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) journal.notify = false @@ -52,8 +52,8 @@ class JournalObserverTest < ActiveSupport::TestCase end def test_create_should_not_send_email_notification_without_issue_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) with_settings :notified_events => [] do @@ -64,8 +64,8 @@ class JournalObserverTest < ActiveSupport::TestCase # context: issue_note_added notified_events def test_create_should_send_email_notification_with_issue_note_added - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) journal.notes = 'This update has a note' @@ -76,8 +76,8 @@ class JournalObserverTest < ActiveSupport::TestCase end def test_create_should_not_send_email_notification_without_issue_note_added - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) journal.notes = 'This update has a note' @@ -89,8 +89,8 @@ class JournalObserverTest < ActiveSupport::TestCase # context: issue_status_updated notified_events def test_create_should_send_email_notification_with_issue_status_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first issue.init_journal(user, issue) issue.status = IssueStatus.last @@ -101,8 +101,8 @@ class JournalObserverTest < ActiveSupport::TestCase end def test_create_should_not_send_email_notification_without_issue_status_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first issue.init_journal(user, issue) issue.status = IssueStatus.last @@ -114,8 +114,8 @@ class JournalObserverTest < ActiveSupport::TestCase # context: issue_priority_updated notified_events def test_create_should_send_email_notification_with_issue_priority_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first issue.init_journal(user, issue) issue.priority = IssuePriority.last @@ -126,8 +126,8 @@ class JournalObserverTest < ActiveSupport::TestCase end def test_create_should_not_send_email_notification_without_issue_priority_updated - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first issue.init_journal(user, issue) issue.priority = IssuePriority.last diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb index 315ea51cf..bec497f46 100644 --- a/test/unit/journal_test.rb +++ b/test/unit/journal_test.rb @@ -41,8 +41,8 @@ class JournalTest < ActiveSupport::TestCase def test_create_should_send_email_notification ActionMailer::Base.deliveries.clear - issue = Issue.find(:first) - user = User.find(:first) + issue = Issue.first + user = User.first journal = issue.init_journal(user, issue) assert journal.save diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index a92f738a7..d6c9b7e0f 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -210,7 +210,7 @@ class MailerTest < ActiveSupport::TestCase end def test_should_not_send_email_without_recipient - news = News.find(:first) + news = News.first user = news.author # Remove members except news author news.project.memberships.each {|m| m.destroy unless m.user == user} @@ -402,7 +402,7 @@ class MailerTest < ActiveSupport::TestCase end def test_news_added - news = News.find(:first) + news = News.first valid_languages.each do |lang| Setting.default_language = lang.to_s assert Mailer.news_added(news).deliver @@ -418,7 +418,7 @@ class MailerTest < ActiveSupport::TestCase end def test_message_posted - message = Message.find(:first) + message = Message.first recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author} recipients = recipients.compact.uniq valid_languages.each do |lang| diff --git a/test/unit/news_test.rb b/test/unit/news_test.rb index 94054e5a7..2ad90ce40 100644 --- a/test/unit/news_test.rb +++ b/test/unit/news_test.rb @@ -21,7 +21,7 @@ class NewsTest < ActiveSupport::TestCase fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :news def valid_news - { :title => 'Test news', :description => 'Lorem ipsum etc', :author => User.find(:first) } + { :title => 'Test news', :description => 'Lorem ipsum etc', :author => User.first } end def setup diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 28a478e60..4c1441747 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -707,7 +707,7 @@ class ProjectTest < ActiveSupport::TestCase 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}) + overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.first, :active => false}) assert overridden_activity.save! assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity found" @@ -722,7 +722,7 @@ class ProjectTest < ActiveSupport::TestCase end def test_activities_should_handle_nils - overridden_activity = TimeEntryActivity.new({:name => "Project", :project => Project.find(1), :parent => TimeEntryActivity.find(:first)}) + overridden_activity = TimeEntryActivity.new({:name => "Project", :project => Project.find(1), :parent => TimeEntryActivity.first}) TimeEntryActivity.delete_all # No activities @@ -737,7 +737,7 @@ class ProjectTest < ActiveSupport::TestCase def test_activities_should_override_system_activities_with_project_activities project = Project.find(1) - parent_activity = TimeEntryActivity.find(:first) + parent_activity = TimeEntryActivity.first overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => parent_activity}) assert overridden_activity.save! @@ -747,7 +747,7 @@ class ProjectTest < ActiveSupport::TestCase def test_activities_should_include_inactive_activities_if_specified project = Project.find(1) - overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.find(:first), :active => false}) + overridden_activity = TimeEntryActivity.new({:name => "Project", :project => project, :parent => TimeEntryActivity.first, :active => false}) assert overridden_activity.save! assert project.activities(true).include?(overridden_activity), "Inactive Project specific Activity not found" diff --git a/test/unit/repository_cvs_test.rb b/test/unit/repository_cvs_test.rb index 05f59d8a6..ff34d017e 100644 --- a/test/unit/repository_cvs_test.rb +++ b/test/unit/repository_cvs_test.rb @@ -121,7 +121,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase assert_equal 3, @repository.changesets.count assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision) - rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') + rev3_commit = @repository.changesets.reorder('committed_on DESC').first assert_equal '3', rev3_commit.revision # 2007-12-14 01:27:22 +0900 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22) diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index 56663c165..d6e00d2b5 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -209,7 +209,7 @@ class RepositoryTest < ActiveSupport::TestCase assert_equal [101], fixed_issue.changeset_ids # issue change - journal = fixed_issue.journals.find(:first, :order => 'created_on desc') + journal = fixed_issue.journals.reorder('created_on desc').first assert_equal User.find_by_login('dlopper'), journal.user assert_equal 'Applied in changeset r2.', journal.notes diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb index 807ff32b7..ad4c0e0ca 100644 --- a/test/unit/version_test.rb +++ b/test/unit/version_test.rb @@ -61,7 +61,7 @@ class VersionTest < ActiveSupport::TestCase def test_progress_should_be_100_with_closed_assigned_issues project = Project.find(1) - status = IssueStatus.find(:first, :conditions => {:is_closed => true}) + status = IssueStatus.where(:is_closed => true).first v = Version.create!(:project => project, :name => 'Progress') add_issue(v, :status => status) add_issue(v, :status => status, :done_ratio => 20) @@ -86,7 +86,7 @@ class VersionTest < ActiveSupport::TestCase v = Version.create!(:project => project, :name => 'Progress') add_issue(v) add_issue(v, :done_ratio => 20) - add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) + add_issue(v, :status => IssueStatus.where(:is_closed => true).first) assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_pourcent assert_progress_equal (100.0)/3, v.closed_pourcent end @@ -97,7 +97,7 @@ class VersionTest < ActiveSupport::TestCase add_issue(v, :estimated_hours => 10) add_issue(v, :estimated_hours => 20, :done_ratio => 30) add_issue(v, :estimated_hours => 40, :done_ratio => 10) - add_issue(v, :estimated_hours => 25, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) + add_issue(v, :estimated_hours => 25, :status => IssueStatus.where(:is_closed => true).first) assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_pourcent assert_progress_equal 25.0/95.0*100, v.closed_pourcent end @@ -106,7 +106,7 @@ class VersionTest < ActiveSupport::TestCase project = Project.find(1) v = Version.create!(:project => project, :name => 'Progress') add_issue(v, :done_ratio => 20) - add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) + add_issue(v, :status => IssueStatus.where(:is_closed => true).first) add_issue(v, :estimated_hours => 10, :done_ratio => 30) add_issue(v, :estimated_hours => 40, :done_ratio => 10) assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent @@ -242,8 +242,8 @@ class VersionTest < ActiveSupport::TestCase Issue.create!({:project => version.project, :fixed_version => version, :subject => 'Test', - :author => User.find(:first), - :tracker => version.project.trackers.find(:first)}.merge(attributes)) + :author => User.first, + :tracker => version.project.trackers.first}.merge(attributes)) end def assert_progress_equal(expected_float, actual_float, message="") diff --git a/test/unit/wiki_redirect_test.rb b/test/unit/wiki_redirect_test.rb index 5e09ac701..3e256e35d 100644 --- a/test/unit/wiki_redirect_test.rb +++ b/test/unit/wiki_redirect_test.rb @@ -69,6 +69,6 @@ class WikiRedirectTest < ActiveSupport::TestCase assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title') @original.destroy - assert !@wiki.redirects.find(:first) + assert_nil @wiki.redirects.first end end |