diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/custom_fields_controller_test.rb | 2 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 4 | ||||
-rw-r--r-- | test/functional/projects_controller_test.rb | 2 | ||||
-rw-r--r-- | test/functional/repositories_controller_test.rb | 2 | ||||
-rw-r--r-- | test/functional/workflows_controller_test.rb | 8 | ||||
-rw-r--r-- | test/integration/api_test/issue_categories_test.rb | 4 | ||||
-rw-r--r-- | test/integration/api_test/issues_test.rb | 14 | ||||
-rw-r--r-- | test/test_helper.rb | 2 | ||||
-rw-r--r-- | test/unit/board_test.rb | 2 | ||||
-rw-r--r-- | test/unit/changeset_test.rb | 6 | ||||
-rw-r--r-- | test/unit/issue_status_test.rb | 8 | ||||
-rw-r--r-- | test/unit/project_copy_test.rb | 10 | ||||
-rw-r--r-- | test/unit/project_test.rb | 12 | ||||
-rw-r--r-- | test/unit/query_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 6 | ||||
-rw-r--r-- | test/unit/search_test.rb | 2 | ||||
-rw-r--r-- | test/unit/user_test.rb | 2 | ||||
-rw-r--r-- | test/unit/workflow_test.rb | 6 |
18 files changed, 45 insertions, 49 deletions
diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb index c8193c5d4..c7efcfeb6 100644 --- a/test/functional/custom_fields_controller_test.rb +++ b/test/functional/custom_fields_controller_test.rb @@ -153,7 +153,7 @@ class CustomFieldsControllerTest < ActionController::TestCase end def test_destroy - custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1}) + custom_values_count = CustomValue.where(:custom_field_id => 1).count assert custom_values_count > 0 assert_difference 'CustomField.count', -1 do diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index e9afa9b0f..707b57438 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -3701,7 +3701,7 @@ class IssuesControllerTest < ActionController::TestCase def test_bulk_copy_should_allow_changing_the_issue_attributes # Fixes random test failure with Mysql - # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) + # where Issue.where(:project_id => 2).limit(2).order('id desc') # doesn't return the expected results Issue.delete_all("project_id=2") @@ -3716,7 +3716,7 @@ class IssuesControllerTest < ActionController::TestCase end end - copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) + copied_issues = Issue.where(:project_id => 2).limit(2).order('id desc').to_a assert_equal 2, copied_issues.size copied_issues.each do |issue| assert_equal 2, issue.project_id, "Project is incorrect" diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 29de3df3c..37010cc71 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -51,7 +51,7 @@ class ProjectsControllerTest < ActionController::TestCase assert_response :success assert_template 'common/feed' assert_select 'feed>title', :text => 'Redmine: Latest projects' - assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current)) + assert_select 'feed>entry', :count => Project.visible(User.current).count end test "#index by non-admin user with view_time_entries permission should show overall spent time link" do diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 2231e3134..ec1847fcd 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -280,7 +280,7 @@ class RepositoriesControllerTest < ActionController::TestCase :revision => 100, :comments => 'Committed by foo.' ) - assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do + assert_no_difference "Changeset.where(:user_id => 3).count" do post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} assert_response 302 assert_equal User.find(2), c.reload.user diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb index d04c3ec0a..f5bf3910b 100644 --- a/test/functional/workflows_controller_test.rb +++ b/test/functional/workflows_controller_test.rb @@ -30,7 +30,7 @@ class WorkflowsControllerTest < ActionController::TestCase assert_response :success assert_template 'index' - count = WorkflowTransition.count(:all, :conditions => 'role_id = 1 AND tracker_id = 2') + count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count assert_tag :tag => 'a', :content => count.to_s, :attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' } end @@ -125,10 +125,10 @@ class WorkflowsControllerTest < ActionController::TestCase end def test_clear_workflow - assert WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0 + assert WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count > 0 - post :edit, :role_id => 2, :tracker_id => 1 - assert_equal 0, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2}) + post :edit, :role_id => 1, :tracker_id => 2 + assert_equal 0, WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count end def test_get_permissions diff --git a/test/integration/api_test/issue_categories_test.rb b/test/integration/api_test/issue_categories_test.rb index dc970a65a..a8a2abda3 100644 --- a/test/integration/api_test/issue_categories_test.rb +++ b/test/integration/api_test/issue_categories_test.rb @@ -95,11 +95,11 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base end test "DELETE /issue_categories/:id.xml should reassign issues with :reassign_to_id param" do - issue_count = Issue.count(:conditions => {:category_id => 1}) + issue_count = Issue.where(:category_id => 1).count assert issue_count > 0 assert_difference 'IssueCategory.count', -1 do - assert_difference 'Issue.count(:conditions => {:category_id => 2})', 3 do + assert_difference 'Issue.where(:category_id => 2).count', 3 do delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith') end end diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 176c18105..d8f1dad48 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -138,9 +138,9 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base get '/issues.xml', {:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, :v => {:cf_1 => ['MySQL']}} - expected_ids = Issue.visible.all( - :include => :custom_values, - :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id) + expected_ids = Issue.visible. + joins(:custom_values). + where(:custom_values => {:custom_field_id => 1, :value => 'MySQL'}).map(&:id) assert_select 'issues > issue > id', :count => expected_ids.count do |ids| ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } end @@ -151,9 +151,9 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base should "show only issues with the custom field value" do get '/issues.xml', { :cf_1 => 'MySQL' } - expected_ids = Issue.visible.all( - :include => :custom_values, - :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id) + expected_ids = Issue.visible. + joins(:custom_values). + where(:custom_values => {:custom_field_id => 1, :value => 'MySQL'}).map(&:id) assert_select 'issues > issue > id', :count => expected_ids.count do |ids| ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } @@ -170,7 +170,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base should "show only issues with the status_id" do get '/issues.xml?status_id=5' - expected_ids = Issue.visible.all(:conditions => {:status_id => 5}).map(&:id) + expected_ids = Issue.visible.where(:status_id => 5).map(&:id) assert_select 'issues > issue > id', :count => expected_ids.count do |ids| ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } diff --git a/test/test_helper.rb b/test/test_helper.rb index 368a4d41b..39826bc2d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -112,7 +112,7 @@ class ActiveSupport::TestCase end def change_user_password(login, new_password) - user = User.first(:conditions => {:login => login}) + user = User.where(:login => login).first user.password, user.password_confirmation = new_password, new_password user.save! end diff --git a/test/unit/board_test.rb b/test/unit/board_test.rb index ff4779081..bebb14b02 100644 --- a/test/unit/board_test.rb +++ b/test/unit/board_test.rb @@ -100,7 +100,7 @@ class BoardTest < ActiveSupport::TestCase end end end - assert_equal 0, Message.count(:conditions => {:board_id => 1}) + assert_equal 0, Message.where(:board_id => 1).count end def test_destroy_should_nullify_children diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index a652c9810..a97dc37d2 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -30,8 +30,7 @@ class ChangesetTest < ActiveSupport::TestCase def test_ref_keywords_any ActionMailer::Base.deliveries.clear - Setting.commit_fix_status_id = IssueStatus.find( - :first, :conditions => ["is_closed = ?", true]).id + Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id Setting.commit_fix_done_ratio = '90' Setting.commit_ref_keywords = '*' Setting.commit_fix_keywords = 'fixes , closes' @@ -113,8 +112,7 @@ class ChangesetTest < ActiveSupport::TestCase end def test_ref_keywords_closing_with_timelog - Setting.commit_fix_status_id = IssueStatus.find( - :first, :conditions => ["is_closed = ?", true]).id + Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id Setting.commit_ref_keywords = '*' Setting.commit_fix_keywords = 'fixes , closes' Setting.commit_logtime_enabled = '1' diff --git a/test/unit/issue_status_test.rb b/test/unit/issue_status_test.rb index 9c4593244..4ab94c14a 100644 --- a/test/unit/issue_status_test.rb +++ b/test/unit/issue_status_test.rb @@ -36,8 +36,8 @@ class IssueStatusTest < ActiveSupport::TestCase assert_difference 'IssueStatus.count', -1 do assert status.destroy end - assert_nil WorkflowTransition.first(:conditions => {:old_status_id => status.id}) - assert_nil WorkflowTransition.first(:conditions => {:new_status_id => status.id}) + assert_nil WorkflowTransition.where(:old_status_id => status.id).first + assert_nil WorkflowTransition.where(:new_status_id => status.id).first end def test_destroy_status_in_use @@ -98,7 +98,7 @@ class IssueStatusTest < ActiveSupport::TestCase with_settings :issue_done_ratio => 'issue_field' do IssueStatus.update_issue_done_ratios - assert_equal 0, Issue.count(:conditions => {:done_ratio => 50}) + assert_equal 0, Issue.where(:done_ratio => 50).count end end @@ -107,7 +107,7 @@ class IssueStatusTest < ActiveSupport::TestCase with_settings :issue_done_ratio => 'issue_status' do IssueStatus.update_issue_done_ratios - issues = Issue.all(:conditions => {:status_id => 1}) + issues = Issue.where(:status_id => 1).all assert_equal [50], issues.map {|issue| issue.read_attribute(:done_ratio)}.uniq end end diff --git a/test/unit/project_copy_test.rb b/test/unit/project_copy_test.rb index 893e6653f..7499c07dc 100644 --- a/test/unit/project_copy_test.rb +++ b/test/unit/project_copy_test.rb @@ -63,7 +63,7 @@ class ProjectCopyTest < ActiveSupport::TestCase assert_equal @project, issue.project end - copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"}) + copied_issue = @project.issues.where(:subject => "copy issue status").first assert copied_issue assert copied_issue.status assert_equal "Closed", copied_issue.status.name @@ -93,7 +93,7 @@ class ProjectCopyTest < ActiveSupport::TestCase assert @project.copy(@source_project) @project.reload - copied_issue = @project.issues.first(:conditions => {:subject => "copy issues assigned to a locked version"}) + copied_issue = @project.issues.where(:subject => "copy issues assigned to a locked version").first assert copied_issue assert copied_issue.fixed_version @@ -112,7 +112,7 @@ class ProjectCopyTest < ActiveSupport::TestCase assert @project.copy(@source_project) @project.reload - copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"}) + copied_issue = @project.issues.where(:subject => "change the new issues to use the copied version").first assert copied_issue assert copied_issue.fixed_version @@ -128,7 +128,7 @@ class ProjectCopyTest < ActiveSupport::TestCase assert @project.copy(@source_project) @project.reload - copied_issue = @project.issues.first(:conditions => {:subject => "keep target shared versions"}) + copied_issue = @project.issues.where(:subject => "keep target shared versions").first assert copied_issue assert_equal assigned_version, copied_issue.fixed_version @@ -175,7 +175,7 @@ class ProjectCopyTest < ActiveSupport::TestCase @source_project.issues << issue assert @project.copy(@source_project) - copied_issue = @project.issues.first(:conditions => {:subject => "copy with attachment"}) + copied_issue = @project.issues.where(:subject => "copy with attachment").first assert_not_nil copied_issue assert_equal 1, copied_issue.attachments.count, "Attachment not copied" assert_equal "testfile.txt", copied_issue.attachments.first.filename diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index c6ba4cd72..88e99c439 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -175,7 +175,7 @@ class ProjectTest < ActiveSupport::TestCase # Assign an issue of a project to a version of a child project Issue.find(4).update_attribute :fixed_version_id, 4 - assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do + assert_no_difference "Project.where(:status => Project::STATUS_ARCHIVED).count" do assert_equal false, @ecookbook.archive end @ecookbook.reload @@ -211,9 +211,9 @@ class ProjectTest < ActiveSupport::TestCase # make sure that the project non longer exists assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) } # make sure related data was removed - assert_nil Member.first(:conditions => {:project_id => @ecookbook.id}) - assert_nil Board.first(:conditions => {:project_id => @ecookbook.id}) - assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) + assert_nil Member.where(:project_id => @ecookbook.id).first + assert_nil Board.where(:project_id => @ecookbook.id).first + assert_nil Issue.where(:project_id => @ecookbook.id).first end def test_destroy_should_destroy_subtasks @@ -246,7 +246,7 @@ class ProjectTest < ActiveSupport::TestCase assert_equal 0, Board.count assert_equal 0, Message.count assert_equal 0, News.count - assert_equal 0, Query.count(:conditions => "project_id IS NOT NULL") + assert_equal 0, Query.where("project_id IS NOT NULL").count assert_equal 0, Repository.count assert_equal 0, Changeset.count assert_equal 0, Change.count @@ -260,7 +260,7 @@ class ProjectTest < ActiveSupport::TestCase assert_equal 0, WikiContent::Version.count assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size - assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']}) + assert_equal 0, CustomValue.where(:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']).count end def test_move_an_orphan_project_to_a_root_project diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index f3402ce17..59639384f 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -586,7 +586,7 @@ class QueryTest < ActiveSupport::TestCase query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}}) result = query.issues - assert_equal Issue.visible.all(:conditions => {:assigned_to_id => ([2] + user.reload.group_ids)}).sort_by(&:id), result.sort_by(&:id) + assert_equal Issue.visible.where(:assigned_to_id => ([2] + user.reload.group_ids)).sort_by(&:id), result.sort_by(&:id) assert result.include?(i1) assert result.include?(i2) diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index 2bd430a4d..390a5334e 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -183,9 +183,7 @@ class RepositoryTest < ActiveSupport::TestCase Setting.default_language = 'en' # choosing a status to apply to fix issues - Setting.commit_fix_status_id = IssueStatus.find( - :first, - :conditions => ["is_closed = ?", true]).id + Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id Setting.commit_fix_done_ratio = "90" Setting.commit_ref_keywords = 'refs , references, IssueID' Setting.commit_fix_keywords = 'fixes , closes' @@ -278,7 +276,7 @@ class RepositoryTest < ActiveSupport::TestCase end def test_manual_user_mapping - assert_no_difference "Changeset.count(:conditions => 'user_id <> 2')" do + assert_no_difference "Changeset.where('user_id <> 2').count" do c = Changeset.create!( :repository => @repository, :committer => 'foo', diff --git a/test/unit/search_test.rb b/test/unit/search_test.rb index 7b124c1f9..fda9ea56f 100644 --- a/test/unit/search_test.rb +++ b/test/unit/search_test.rb @@ -128,7 +128,7 @@ class SearchTest < ActiveSupport::TestCase def test_search_issue_with_multiple_hits_in_journals i = Issue.find(1) - assert_equal 2, i.journals.count(:all, :conditions => "notes LIKE '%notes%'") + assert_equal 2, i.journals.where("notes LIKE '%notes%'").count r = Issue.search('%notes%').first assert_equal 1, r.size diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index c5b642970..4594d8e1a 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -40,7 +40,7 @@ class UserTest < ActiveSupport::TestCase def test_generate User.generate!(:firstname => 'Testing connection') User.generate!(:firstname => 'Testing connection') - assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'}) + assert_equal 2, User.where(:firstname => 'Testing connection').count end def test_truth diff --git a/test/unit/workflow_test.rb b/test/unit/workflow_test.rb index e1a517e72..0e4b5ce96 100644 --- a/test/unit/workflow_test.rb +++ b/test/unit/workflow_test.rb @@ -30,9 +30,9 @@ class WorkflowTest < ActiveSupport::TestCase WorkflowTransition.copy(Tracker.find(2), Role.find(1), Tracker.find(3), Role.find(2)) end - assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false}) - assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true}) - assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false}) + assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false).first + assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true).first + assert WorkflowTransition.where(:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false).first end def test_workflow_permission_should_validate_rule |