From 157986c77891572079e755d1b93cebe5acab85c7 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 5 Nov 2025 07:41:46 +0000 Subject: [PATCH] Fix RuboCop Rails/OrderArguments (#43438). git-svn-id: https://svn.redmine.org/redmine/trunk@24125 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/changeset.rb | 4 +- app/models/group_builtin.rb | 2 +- app/models/news.rb | 2 +- app/models/project.rb | 2 +- app/models/repository/cvs.rb | 2 +- test/functional/account_controller_test.rb | 4 +- .../functional/attachments_controller_test.rb | 2 +- .../auth_sources_controller_test.rb | 2 +- test/functional/boards_controller_test.rb | 6 +- .../custom_fields_controller_test.rb | 4 +- test/functional/documents_controller_test.rb | 2 +- .../email_addresses_controller_test.rb | 2 +- test/functional/files_controller_test.rb | 4 +- test/functional/groups_controller_test.rb | 4 +- .../issue_categories_controller_test.rb | 2 +- .../issue_relations_controller_test.rb | 8 +- .../issue_statuses_controller_test.rb | 2 +- test/functional/issues_controller_test.rb | 86 +++++++++---------- .../issues_controller_transaction_test.rb | 6 +- test/functional/messages_controller_test.rb | 2 +- test/functional/news_controller_test.rb | 6 +- .../principal_memberships_controller_test.rb | 8 +- test/functional/projects_controller_test.rb | 2 +- test/functional/queries_controller_test.rb | 4 +- .../repositories_controller_test.rb | 2 +- .../repositories_git_controller_test.rb | 2 +- test/functional/timelog_controller_test.rb | 6 +- test/functional/trackers_controller_test.rb | 4 +- test/functional/users_controller_test.rb | 6 +- test/functional/wiki_controller_test.rb | 2 +- test/functional/workflows_controller_test.rb | 2 +- test/integration/account_test.rb | 4 +- test/integration/api_test/attachments_test.rb | 6 +- .../api_test/custom_fields_attribute_test.rb | 10 +-- test/integration/api_test/groups_test.rb | 2 +- .../api_test/issue_categories_test.rb | 2 +- .../api_test/issue_relations_test.rb | 4 +- test/integration/api_test/issues_test.rb | 16 ++-- test/integration/api_test/projects_test.rb | 6 +- .../integration/api_test/time_entries_test.rb | 6 +- test/integration/api_test/users_test.rb | 12 +-- test/integration/api_test/versions_test.rb | 8 +- test/integration/api_test/wiki_pages_test.rb | 6 +- test/integration/attachments_test.rb | 8 +- test/system/issues_test.rb | 12 +-- test/unit/attachment_test.rb | 4 +- test/unit/board_test.rb | 2 +- test/unit/changeset_test.rb | 10 +-- test/unit/custom_field_test.rb | 4 +- test/unit/issue_category_test.rb | 4 +- test/unit/issue_nested_set_test.rb | 2 +- test/unit/issue_test.rb | 8 +- test/unit/journal_test.rb | 2 +- test/unit/lib/redmine/ciphering_test.rb | 8 +- .../redmine/field_format/list_format_test.rb | 2 +- .../field_format/user_field_format_test.rb | 2 +- .../field_format/version_field_format_test.rb | 2 +- test/unit/mail_handler_test.rb | 10 +-- test/unit/project_copy_test.rb | 2 +- test/unit/project_members_inheritance_test.rb | 12 +-- test/unit/user_test.rb | 4 +- test/unit/wiki_content_test.rb | 8 +- 62 files changed, 190 insertions(+), 190 deletions(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index a9838fd11..b14b46bc4 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -191,12 +191,12 @@ class Changeset < ApplicationRecord # Returns the previous changeset def previous - @previous ||= Changeset.where(["id < ? AND repository_id = ?", id, repository_id]).order('id DESC').first + @previous ||= Changeset.where(["id < ? AND repository_id = ?", id, repository_id]).order(id: :desc).first end # Returns the next changeset def next - @next ||= Changeset.where(["id > ? AND repository_id = ?", id, repository_id]).order('id ASC').first + @next ||= Changeset.where(["id > ? AND repository_id = ?", id, repository_id]).order(:id).first end # Creates a new Change from it's common parameters diff --git a/app/models/group_builtin.rb b/app/models/group_builtin.rb index 6ad384033..ced61a139 100644 --- a/app/models/group_builtin.rb +++ b/app/models/group_builtin.rb @@ -40,7 +40,7 @@ class GroupBuiltin < Group def load_instance return nil if self == GroupBuiltin - instance = unscoped.order('id').first || create_instance + instance = unscoped.order(:id).first || create_instance end def create_instance diff --git a/app/models/news.rb b/app/models/news.rb index 174e4c5ac..12c70d5a8 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -23,7 +23,7 @@ class News < ApplicationRecord belongs_to :project belongs_to :author, :class_name => 'User' - has_many :comments, lambda {order("created_on")}, :as => :commented, :dependent => :delete_all + has_many :comments, lambda {order(:created_on)}, :as => :commented, :dependent => :delete_all validates_presence_of :title, :description validates_length_of :title, :maximum => 60 diff --git a/app/models/project.rb b/app/models/project.rb index e13f55a55..b92d10a2d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -911,7 +911,7 @@ class Project < ApplicationRecord # Returns an auto-generated project identifier based on the last identifier used def self.next_identifier - p = Project.order('id DESC').first + p = Project.order(id: :desc).first p.nil? ? nil : p.identifier.to_s.succ end diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb index d055428a5..74099fc8e 100644 --- a/app/models/repository/cvs.rb +++ b/app/models/repository/cvs.rb @@ -190,7 +190,7 @@ class Repository::Cvs < Repository # Renumber new changesets in chronological order Changeset. - order('committed_on ASC, id ASC'). + order(:committed_on, :id). where("repository_id = ? AND revision LIKE 'tmp%'", id). each do |changeset| changeset.update_attribute :revision, next_revision_number diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 911888cbf..0fcaa1a2e 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -346,7 +346,7 @@ class AccountControllerTest < Redmine::ControllerTest ) assert_redirected_to '/my/account' end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'register', user.login assert_equal 'John', user.firstname assert_equal 'Doe', user.lastname @@ -442,7 +442,7 @@ class AccountControllerTest < Redmine::ControllerTest assert_redirected_to '/login' end end - token = Token.order('id DESC').first + token = Token.order(id: :desc).first assert_equal User.find(2), token.user assert_equal 'recovery', token.action diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index c2e7e2f7b..7d856b11d 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -683,7 +683,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest end end assert_nil Attachment.find_by_id(1) - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal issue, j.journalized assert_equal 'attachment', j.details.first.property assert_equal '1', j.details.first.prop_key diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index 638b0de30..fdc1c7d9a 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -67,7 +67,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest assert_redirected_to '/auth_sources' end - source = AuthSourceLdap.order('id DESC').first + source = AuthSourceLdap.order(id: :desc).first assert_equal 'Test', source.name assert_equal '127.0.0.1', source.host assert_equal 389, source.port diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb index 078b324e4..f06d7b999 100644 --- a/test/functional/boards_controller_test.rb +++ b/test/functional/boards_controller_test.rb @@ -100,7 +100,7 @@ class BoardsControllerTest < Redmine::ControllerTest Message.update_all(:sticky => 0) # Reply to an old topic - old_topic = Message.where(:board_id => 1, :parent_id => nil).order('created_on ASC').first + old_topic = Message.where(:board_id => 1, :parent_id => nil).order(:created_on).first reply = Message.new(:board_id => 1, :subject => 'New reply', :content => 'New reply', :author_id => 2) old_topic.children << reply @@ -206,7 +206,7 @@ class BoardsControllerTest < Redmine::ControllerTest ) end assert_redirected_to '/projects/ecookbook/settings/boards' - board = Board.order('id DESC').first + board = Board.order(id: :desc).first assert_equal 'Testing', board.name assert_equal 'Testing board creation', board.description end @@ -227,7 +227,7 @@ class BoardsControllerTest < Redmine::ControllerTest ) end assert_redirected_to '/projects/ecookbook/settings/boards' - board = Board.order('id DESC').first + board = Board.order(id: :desc).first assert_equal Board.find(2), board.parent end diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb index fdd2a4148..9ed072d45 100644 --- a/test/functional/custom_fields_controller_test.rb +++ b/test/functional/custom_fields_controller_test.rb @@ -451,7 +451,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest ) assert_response :found end - field = IssueCustomField.order("id desc").first + field = IssueCustomField.order(id: :desc).first assert_equal [1, 3], field.projects.map(&:id).sort end @@ -520,7 +520,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest ) assert_response :found end - field = IssueCustomField.order('id desc').first + field = IssueCustomField.order(id: :desc).first assert_equal 'Copy', field.name assert_equal ['enumeration1', 'enumeration2'], field.enumerations.pluck(:name).sort assert_equal [1, 2], field.enumerations.pluck(:position).sort diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index 944f0b30f..cf5c3d62c 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -282,7 +282,7 @@ class DocumentsControllerTest < Redmine::ControllerTest } ) end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal Document.find(1), attachment.container end end diff --git a/test/functional/email_addresses_controller_test.rb b/test/functional/email_addresses_controller_test.rb index 89788ea47..dd83244bb 100644 --- a/test/functional/email_addresses_controller_test.rb +++ b/test/functional/email_addresses_controller_test.rb @@ -75,7 +75,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest assert_response :found assert_redirected_to '/users/2/email_addresses' end - email = EmailAddress.order('id DESC').first + email = EmailAddress.order(id: :desc).first assert_equal 2, email.user_id assert_equal 'another@somenet.foo', email.address end diff --git a/test/functional/files_controller_test.rb b/test/functional/files_controller_test.rb index 57db1579b..8bb62b96c 100644 --- a/test/functional/files_controller_test.rb +++ b/test/functional/files_controller_test.rb @@ -88,7 +88,7 @@ class FilesControllerTest < Redmine::ControllerTest end end assert_redirected_to '/projects/ecookbook/files' - a = Attachment.order('created_on DESC').first + a = Attachment.order(created_on: :desc).first assert_equal 'testfile.txt', a.filename assert_equal Project.find(1), a.container @@ -117,7 +117,7 @@ class FilesControllerTest < Redmine::ControllerTest assert_response :redirect end assert_redirected_to '/projects/ecookbook/files' - a = Attachment.order('created_on DESC').first + a = Attachment.order(created_on: :desc).first assert_equal 'testfile.txt', a.filename assert_equal Version.find(2), a.container end diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index e9156c88c..77b730227 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -112,7 +112,7 @@ class GroupsControllerTest < Redmine::ControllerTest ) end assert_redirected_to '/groups' - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal 'New group', group.name assert_equal [], group.users end @@ -130,7 +130,7 @@ class GroupsControllerTest < Redmine::ControllerTest ) end assert_redirected_to '/groups/new' - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal 'New group', group.name end diff --git a/test/functional/issue_categories_controller_test.rb b/test/functional/issue_categories_controller_test.rb index 9b3448216..8884d2516 100644 --- a/test/functional/issue_categories_controller_test.rb +++ b/test/functional/issue_categories_controller_test.rb @@ -93,7 +93,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest :xhr => true ) end - category = IssueCategory.order('id DESC').first + category = IssueCategory.order(id: :desc).first assert_equal 'New category', category.name assert_response :success diff --git a/test/functional/issue_relations_controller_test.rb b/test/functional/issue_relations_controller_test.rb index b01263c87..35a02a1df 100644 --- a/test/functional/issue_relations_controller_test.rb +++ b/test/functional/issue_relations_controller_test.rb @@ -39,7 +39,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest } ) end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 1, relation.issue_from_id assert_equal 2, relation.issue_to_id assert_equal 'relates', relation.relation_type @@ -79,7 +79,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest assert_response :success assert_equal 'text/javascript', response.media_type end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 1, relation.issue_from_id assert_equal 3, relation.issue_to_id @@ -100,7 +100,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest } ) end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 2, relation.issue_to_id end @@ -118,7 +118,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest } ) end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 2, relation.issue_to_id end diff --git a/test/functional/issue_statuses_controller_test.rb b/test/functional/issue_statuses_controller_test.rb index b3129d1d9..7d015fec2 100644 --- a/test/functional/issue_statuses_controller_test.rb +++ b/test/functional/issue_statuses_controller_test.rb @@ -78,7 +78,7 @@ class IssueStatusesControllerTest < Redmine::ControllerTest ) end assert_redirected_to :action => 'index' - status = IssueStatus.order('id DESC').first + status = IssueStatus.order(id: :desc).first assert_equal 'New status', status.name assert_equal 'New status description', status.description end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index e120697ae..10bb9906e 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -4344,7 +4344,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3} @@ -4395,7 +4395,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end assert_response :found - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort end @@ -4421,7 +4421,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end assert_response :found - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal [''], issue.custom_field_value(1).sort end @@ -4449,7 +4449,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end assert_response :found - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal ['2', '3'], issue.custom_field_value(field).sort end @@ -4582,7 +4582,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal Date.parse('2012-07-14'), issue.start_date assert_nil issue.due_date assert_equal 'value1', issue.custom_field_value(cf1) @@ -4665,7 +4665,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal Issue.find(2), issue.parent end @@ -4685,7 +4685,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal Issue.find(2), issue.parent end @@ -4744,7 +4744,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert issue.is_private? end @@ -4766,7 +4766,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert issue.is_private? end @@ -4785,7 +4785,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 3, issue.project_id assert_equal 2, issue.tracker_id end @@ -4981,8 +4981,8 @@ class IssuesControllerTest < Redmine::ControllerTest end end - issue = Issue.order('id DESC').first - attachment = Attachment.order('id DESC').first + issue = Issue.order(id: :desc).first + attachment = Attachment.order(id: :desc).first assert_equal issue, attachment.container assert_equal 2, attachment.author_id @@ -5052,7 +5052,7 @@ class IssuesControllerTest < Redmine::ControllerTest end end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal 'testfile.txt', attachment.filename assert File.exist?(attachment.diskfile) assert_nil attachment.container @@ -5121,7 +5121,7 @@ class IssuesControllerTest < Redmine::ControllerTest end end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.attachments.count attachment.reload @@ -5160,7 +5160,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id').last + issue = Issue.order(:id).last assert_not_nil issue.default_status assert_equal issue.default_status, issue.status end @@ -5180,7 +5180,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id').last + issue = Issue.order(:id).last assert_not_nil issue.default_status assert_equal issue.default_status, issue.status end @@ -5461,7 +5461,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_redirected_to "/issues/#{issue.id}" assert_equal 2, issue.project_id @@ -5489,7 +5489,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.status_id end @@ -5540,7 +5540,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end end - copy = Issue.order('id DESC').first + copy = Issue.order(id: :desc).first assert_equal count, copy.attachments.count assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort end @@ -5567,7 +5567,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end end - copy = Issue.order('id DESC').first + copy = Issue.order(id: :desc).first assert_equal 0, copy.attachments.count end @@ -5601,7 +5601,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end end - copy = Issue.order('id DESC').first + copy = Issue.order(id: :desc).first assert_equal count + 1, copy.attachments.count end @@ -5625,7 +5625,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end end - copy = Issue.order('id DESC').first + copy = Issue.order(id: :desc).first assert_equal 1, copy.relations.size end @@ -5749,7 +5749,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - copy = Issue.where(:parent_id => nil).order('id DESC').first + copy = Issue.where(:parent_id => nil).order(id: :desc).first assert_equal count, copy.descendants.count assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort end @@ -5802,7 +5802,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - copy = Issue.where(:parent_id => nil).order('id DESC').first + copy = Issue.where(:parent_id => nil).order(id: :desc).first assert_equal 0, copy.descendants.count end @@ -5851,7 +5851,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.project_id end @@ -5873,7 +5873,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal [3, 10], issue.watcher_user_ids.sort end @@ -5895,7 +5895,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal [], issue.watcher_user_ids end @@ -6442,7 +6442,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_redirected_to :action => 'show', :id => '1' issue.reload assert_equal 2, issue.status_id - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal 'Assigned to dlopper', j.notes assert_equal 2, j.details.size @@ -6519,7 +6519,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) end assert_redirected_to :action => 'show', :id => '1' - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal notes, j.notes assert_equal 0, j.details.size assert_equal User.anonymous, j.user @@ -6546,7 +6546,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_redirected_to :action => 'show', :id => '1' end - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal notes, j.notes assert_equal true, j.private_notes end @@ -6570,12 +6570,12 @@ class IssuesControllerTest < Redmine::ControllerTest assert_redirected_to :action => 'show', :id => '1' end - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal notes, j.notes assert_equal true, j.private_notes assert_equal 0, j.details.count - j = Journal.order('id DESC').offset(1).first + j = Journal.order(id: :desc).offset(1).first assert_nil j.notes assert_equal false, j.private_notes assert_equal 1, j.details.count @@ -6604,7 +6604,7 @@ class IssuesControllerTest < Redmine::ControllerTest issue = Issue.find(1) - j = Journal.order('id DESC').first + j = Journal.order(id: :desc).first assert_equal '2.5 hours added', j.notes assert_equal 0, j.details.size @@ -6691,7 +6691,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_equal 'testfile.txt', j.details.first.value assert_equal User.anonymous, j.user - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal Issue.find(1), attachment.container assert_equal User.anonymous, attachment.author assert_equal 'testfile.txt', attachment.filename @@ -6730,7 +6730,7 @@ class IssuesControllerTest < Redmine::ControllerTest end end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal 'testfile.txt', attachment.filename assert File.exist?(attachment.diskfile) assert_nil attachment.container @@ -6798,7 +6798,7 @@ class IssuesControllerTest < Redmine::ControllerTest attachment.reload assert_equal Issue.find(1), attachment.container - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal 1, journal.details.size assert_equal 'testfile.txt', journal.details.first.value end @@ -8064,7 +8064,7 @@ class IssuesControllerTest < Redmine::ControllerTest end assert_redirected_to '/projects/ecookbook/issues' - copies = Issue.order('id DESC').limit(issue_ids.size) + copies = Issue.order(id: :desc).limit(issue_ids.size) copies.each do |copy| assert_equal 2, copy.project_id end @@ -8147,7 +8147,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - copies = Issue.order('id DESC').limit(issues.size) + copies = Issue.order(id: :desc).limit(issues.size) issues.each do |orig| copy = copies.detect {|c| c.subject == orig.subject} assert_not_nil copy @@ -8190,7 +8190,7 @@ class IssuesControllerTest < Redmine::ControllerTest end end - copied_issues = Issue.where(:project_id => 2).limit(2).order('id desc').to_a + 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" @@ -8220,7 +8220,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.journals.size journal = issue.journals.first assert_equal 'Copying one issue', journal.notes @@ -8363,7 +8363,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - copy = Issue.where(:parent_id => nil).order("id DESC").first + copy = Issue.where(:parent_id => nil).order(id: :desc).first assert_equal count, copy.descendants.count end @@ -8408,7 +8408,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) end - copy = Issue.where(:parent_id => nil).order("id DESC").first + copy = Issue.where(:parent_id => nil).order(id: :desc).first assert_equal count, copy.descendants.count end @@ -8425,7 +8425,7 @@ class IssuesControllerTest < Redmine::ControllerTest :follow => '1' } ) - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_redirected_to :controller => 'issues', :action => 'show', :id => issue end diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb index 3677ebf86..893712549 100644 --- a/test/functional/issues_controller_transaction_test.rb +++ b/test/functional/issues_controller_transaction_test.rb @@ -99,7 +99,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest assert_response :success - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt' end @@ -225,7 +225,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest assert_response :found issue = Issue.find(1) assert_equal 4, issue.fixed_version_id - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal 'overwrite_conflict_resolution', journal.notes assert journal.details.any? end @@ -251,7 +251,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest assert_response :found issue = Issue.find(1) assert_nil issue.fixed_version_id - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal 'add_notes_conflict_resolution', journal.notes assert_equal false, journal.private_notes assert journal.details.empty? diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index cec58ff5f..f87e46f30 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -278,7 +278,7 @@ class MessagesControllerTest < Redmine::ControllerTest } } ) - reply = Message.order('id DESC').first + reply = Message.order(id: :desc).first assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" assert_equal I18n.t(:notice_successful_update), flash[:notice] assert Message.find_by_subject('Test reply') diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 686fada25..ca5e6a983 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -229,8 +229,8 @@ class NewsControllerTest < Redmine::ControllerTest end end end - attachment = Attachment.order('id DESC').first - news = News.order('id DESC').first + attachment = Attachment.order(id: :desc).first + news = News.order(id: :desc).first assert_equal news, attachment.container assert_select_email do # link to the attachments download @@ -303,7 +303,7 @@ class NewsControllerTest < Redmine::ControllerTest ) end end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal News.find(1), attachment.container end diff --git a/test/functional/principal_memberships_controller_test.rb b/test/functional/principal_memberships_controller_test.rb index fe6c1bf1c..d8d793d09 100644 --- a/test/functional/principal_memberships_controller_test.rb +++ b/test/functional/principal_memberships_controller_test.rb @@ -62,7 +62,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest ) end assert_redirected_to '/users/7/edit?tab=memberships' - member = Member.order('id DESC').first + member = Member.order(id: :desc).first assert_equal User.find(7), member.principal assert_equal [2], member.role_ids assert_equal 3, member.project_id @@ -81,7 +81,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest } ) end - member = Member.order('id DESC').first + member = Member.order(id: :desc).first assert_equal User.find(7), member.principal assert_equal [2, 3], member.role_ids.sort assert_equal 3, member.project_id @@ -100,7 +100,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest } ) end - members = Member.order('id DESC').limit(2).sort_by(&:project_id) + members = Member.order(id: :desc).limit(2).sort_by(&:project_id) assert_equal 1, members[0].project_id assert_equal 3, members[1].project_id members.each do |member| @@ -126,7 +126,7 @@ class PrincipalMembershipsControllerTest < Redmine::ControllerTest assert_response :success assert_equal 'text/javascript', response.media_type end - member = Member.order('id DESC').first + member = Member.order(id: :desc).first assert_equal User.find(7), member.principal assert_equal [2], member.role_ids assert_equal 3, member.project_id diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 88851262d..6680811f7 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -750,7 +750,7 @@ class ProjectsControllerTest < Redmine::ControllerTest ) assert_response :found end - project = Project.order('id desc').first + project = Project.order(id: :desc).first assert_equal 'inherited', project.name assert_equal parent, project.parent assert project.memberships.count > 0 diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 4f0827da8..297bfa232 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -407,7 +407,7 @@ class QueriesControllerTest < Redmine::ControllerTest ) assert_response :found end - query = IssueQuery.order('id DESC').first + query = IssueQuery.order(id: :desc).first assert_redirected_to "/issues/gantt?query_id=#{query.id}" assert_equal true, query.draw_relations assert_equal true, query.draw_progress_line @@ -438,7 +438,7 @@ class QueriesControllerTest < Redmine::ControllerTest ) assert_response :found end - query = IssueQuery.order('id DESC').first + query = IssueQuery.order(id: :desc).first assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}" assert_equal false, query.draw_relations assert_equal false, query.draw_progress_line diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index c7d36cda6..8f32d1a28 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -92,7 +92,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest ) end assert_response :found - repository = Repository.order('id DESC').first + repository = Repository.order(id: :desc).first assert_kind_of Repository::Subversion, repository assert_equal 'file:///test', repository.url end diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index cb8788a03..ae9c501ac 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -62,7 +62,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest ) end assert_response :found - repository = Repository.order('id DESC').first + repository = Repository.order(id: :desc).first assert_kind_of Repository::Git, repository assert_equal '/test', repository.url assert_equal true, repository.report_last_commit diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index bc0dfebb9..8fda4610a 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -256,7 +256,7 @@ class TimelogControllerTest < Redmine::ControllerTest assert_redirected_to '/projects/ecookbook/time_entries' end - t = TimeEntry.order('id DESC').first + t = TimeEntry.order(id: :desc).first assert_not_nil t assert_equal 'Some work on TimelogControllerTest', t.comments assert_equal 1, t.project_id @@ -283,7 +283,7 @@ class TimelogControllerTest < Redmine::ControllerTest assert_redirected_to '/projects/ecookbook/time_entries' end - t = TimeEntry.order('id DESC').first + t = TimeEntry.order(id: :desc).first assert_not_nil t assert_equal 'Some work on TimelogControllerTest', t.comments assert_equal 1, t.project_id @@ -537,7 +537,7 @@ class TimelogControllerTest < Redmine::ControllerTest end assert_redirected_to '/projects/ecookbook/time_entries' - time_entry = TimeEntry.order('id DESC').first + time_entry = TimeEntry.order(id: :desc).first assert_equal 1, time_entry.project_id end diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb index 3534289d4..a4a741791 100644 --- a/test/functional/trackers_controller_test.rb +++ b/test/functional/trackers_controller_test.rb @@ -127,7 +127,7 @@ class TrackersControllerTest < Redmine::ControllerTest } end assert_redirected_to :action => 'index' - tracker = Tracker.order('id DESC').first + tracker = Tracker.order(id: :desc).first assert_equal 'New tracker', tracker.name assert_equal [1], tracker.project_ids.sort assert_equal Tracker::CORE_FIELDS, tracker.core_fields @@ -146,7 +146,7 @@ class TrackersControllerTest < Redmine::ControllerTest } end assert_redirected_to :action => 'index' - tracker = Tracker.order('id DESC').first + tracker = Tracker.order(id: :desc).first assert_equal 'New tracker', tracker.name assert_equal %w(assigned_to_id fixed_version_id), tracker.core_fields end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 02ad3d7b3..c519dd5df 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -462,7 +462,7 @@ class UsersControllerTest < Redmine::ControllerTest end end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_redirected_to :controller => 'users', :action => 'edit', :id => user.id assert_equal 'John', user.firstname @@ -500,7 +500,7 @@ class UsersControllerTest < Redmine::ControllerTest } } end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'jdoe', user.login assert_equal true, user.pref.hide_mail assert_equal 'Paris', user.pref.time_zone @@ -526,7 +526,7 @@ class UsersControllerTest < Redmine::ControllerTest :send_information => 1 } end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'randompass', user.login mail = ActionMailer::Base.deliveries.last diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 04b687531..b40771a70 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -1284,7 +1284,7 @@ class WikiControllerTest < Redmine::ControllerTest } } end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal Wiki.find(1).find_page('CookBook_documentation'), attachment.container end diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb index dcdc8d5bb..8c2d7b315 100644 --- a/test/functional/workflows_controller_test.rb +++ b/test/functional/workflows_controller_test.rb @@ -505,7 +505,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest def status_transitions(conditions) WorkflowTransition. where(conditions). - order('tracker_id, role_id, old_status_id, new_status_id'). + order(:tracker_id, :role_id, :old_status_id, :new_status_id). collect {|w| [w.old_status, w.new_status_id]} end end diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb index efdc8238f..08e82215b 100644 --- a/test/integration/account_test.rb +++ b/test/integration/account_test.rb @@ -427,7 +427,7 @@ class AccountTest < Redmine::IntegrationTest ) end end - user = User.order('id desc').first + user = User.order(id: :desc).first assert_equal User::STATUS_REGISTERED, user.status reset! @@ -451,7 +451,7 @@ class AccountTest < Redmine::IntegrationTest get '/account/activation_email' end assert_redirected_to '/login' - token = Token.order('id desc').first + token = Token.order(id: :desc).first activation_path = "/account/activate?token=#{token.value}" assert_include activation_path, mail_body(ActionMailer::Base.deliveries.last) diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb index 524399bdc..5b0e8315b 100644 --- a/test/integration/api_test/attachments_test.rb +++ b/test/integration/api_test/attachments_test.rb @@ -136,7 +136,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base attachment_id = xml['upload']['id'] assert_not_nil attachment_id - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal token, attachment.token assert_equal attachment_id, attachment.id.to_s assert_nil attachment.container @@ -168,7 +168,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base token = json['upload']['token'] assert_not_nil token - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal token, attachment.token end @@ -185,7 +185,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base assert_response :created end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal 'test.txt', attachment.filename assert_match /_test\.txt$/, attachment.diskfile end diff --git a/test/integration/api_test/custom_fields_attribute_test.rb b/test/integration/api_test/custom_fields_attribute_test.rb index 0abd643bb..9344dfb84 100644 --- a/test/integration/api_test/custom_fields_attribute_test.rb +++ b/test/integration/api_test/custom_fields_attribute_test.rb @@ -29,7 +29,7 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base 'CONTENT_TYPE' => 'application/json' }.merge(credentials('admin'))) assert_response :created - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal "52", group.custom_field_value(field) end @@ -42,7 +42,7 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base 'CONTENT_TYPE' => 'application/json' }.merge(credentials('admin'))) assert_response :created - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal "52", group.custom_field_value(field) end @@ -55,7 +55,7 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base 'CONTENT_TYPE' => 'application/json' }.merge(credentials('admin'))) assert_response :created - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal "1", group.custom_field_value(field) end @@ -68,7 +68,7 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base 'CONTENT_TYPE' => 'application/json' }.merge(credentials('admin'))) assert_response :created - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal "1", group.custom_field_value(field) end @@ -92,7 +92,7 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base 'CONTENT_TYPE' => 'application/json' }.merge(credentials('admin'))) assert_response :created - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal ["V1", "V3"], group.custom_field_value(field).sort end end diff --git a/test/integration/api_test/groups_test.rb b/test/integration/api_test/groups_test.rb index 5c39364b1..110c59051 100644 --- a/test/integration/api_test/groups_test.rb +++ b/test/integration/api_test/groups_test.rb @@ -131,7 +131,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base assert_equal 'application/xml', response.media_type end - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal 'Test', group.name assert_equal [2, 3], group.users.map(&:id).sort diff --git a/test/integration/api_test/issue_categories_test.rb b/test/integration/api_test/issue_categories_test.rb index cd9c43a44..7096e5ce0 100644 --- a/test/integration/api_test/issue_categories_test.rb +++ b/test/integration/api_test/issue_categories_test.rb @@ -44,7 +44,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base assert_response :created assert_equal 'application/xml', @response.media_type - category = IssueCategory.order('id DESC').first + category = IssueCategory.order(id: :desc).first assert_equal 'API', category.name assert_equal 1, category.project_id end diff --git a/test/integration/api_test/issue_relations_test.rb b/test/integration/api_test/issue_relations_test.rb index 9885c3939..9797cc34b 100644 --- a/test/integration/api_test/issue_relations_test.rb +++ b/test/integration/api_test/issue_relations_test.rb @@ -38,7 +38,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base ) end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 2, relation.issue_from_id assert_equal 7, relation.issue_to_id assert_equal 'relates', relation.relation_type @@ -58,7 +58,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base ) end - relation = IssueRelation.order('id DESC').first + relation = IssueRelation.order(id: :desc).first assert_equal 2, relation.issue_from_id assert_equal 7, relation.issue_to_id assert_equal 'relates', relation.relation_type diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index df558d797..b8f676a43 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -545,7 +545,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :params => payload, :headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.project_id assert_equal 2, issue.tracker_id assert_equal 3, issue.status_id @@ -570,7 +570,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => credentials('jsmith')) assert_response :created end - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_equal 2, issue.watchers.size assert_equal [1, 3], issue.watcher_user_ids.sort end @@ -605,7 +605,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))) end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.project_id assert_equal 2, issue.tracker_id assert_equal 3, issue.status_id @@ -648,7 +648,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))) end assert_response :created - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal ["V1", "V3"], issue.custom_field_value(field).sort end @@ -926,7 +926,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base assert_response :no_content assert_equal '', response.body end - watcher = Watcher.order('id desc').first + watcher = Watcher.order(id: :desc).first assert_equal Issue.find(1), watcher.watchable assert_equal User.find(3), watcher.user end @@ -960,7 +960,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => credentials('jsmith')) assert_response :created end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 1, issue.attachments.count assert_equal attachment, issue.attachments.first @@ -1014,7 +1014,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))) assert_response :created end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 2, issue.attachments.count end @@ -1041,7 +1041,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base :headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))) assert_response :created end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 2, issue.attachments.count end diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb index f5263690a..11e1be848 100644 --- a/test/integration/api_test/projects_test.rb +++ b/test/integration/api_test/projects_test.rb @@ -241,7 +241,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base end end - project = Project.order('id DESC').first + project = Project.order(id: :desc).first assert_equal 'API test', project.name assert_equal 'api-test', project.identifier assert_equal ['issue_tracking', 'repository'], project.enabled_module_names.sort @@ -267,7 +267,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base ) end - project = Project.order('id DESC').first + project = Project.order(id: :desc).first assert_equal ['issue_tracking', 'news', 'time_tracking'], project.enabled_module_names.sort end @@ -286,7 +286,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base ) end - project = Project.order('id DESC').first + project = Project.order(id: :desc).first assert_equal [1, 3], project.trackers.map(&:id).sort end diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb index abd634506..e44da3a14 100644 --- a/test/integration/api_test/time_entries_test.rb +++ b/test/integration/api_test/time_entries_test.rb @@ -73,7 +73,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base assert_response :created assert_equal 'application/xml', @response.media_type - entry = TimeEntry.order('id DESC').first + entry = TimeEntry.order(id: :desc).first assert_equal 'jsmith', entry.user.login assert_equal Issue.find(1), entry.issue assert_equal Project.find(1), entry.project @@ -102,7 +102,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base assert_response :created assert_equal 'application/xml', @response.media_type - entry = TimeEntry.order('id DESC').first + entry = TimeEntry.order(id: :desc).first assert_equal 'accepted', entry.custom_field_value(field) end @@ -119,7 +119,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base assert_response :created assert_equal 'application/xml', @response.media_type - entry = TimeEntry.order('id DESC').first + entry = TimeEntry.order(id: :desc).first assert_equal 'jsmith', entry.user.login assert_nil entry.issue assert_equal Project.find(1), entry.project diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 94ecb52cf..50c8533e6 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -21,7 +21,7 @@ require_relative '../../test_helper' class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base test "GET /users.xml should return users" do - users = User.active.order('login') + users = User.active.order(:login) users.last.update(twofa_scheme: 'totp') Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do with_settings :gravatar_enabled => '1', :gravatar_default => 'mm' do @@ -53,7 +53,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base end test "GET /users.json should return users" do - users = User.active.order('login') + users = User.active.order(:login) users.last.update(twofa_scheme: 'totp') get '/users.json', :headers => credentials('admin') @@ -62,7 +62,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base json = ActiveSupport::JSON.decode(response.body) assert json.key?('users') - users = User.active.order('login') + users = User.active.order(:login) assert_equal users.size, json['users'].size json['users'].zip(users) do |user_json, user| @@ -343,7 +343,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base :headers => credentials('admin')) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'foo', user.login assert_equal 'Firstname', user.firstname assert_equal 'Lastname', user.lastname @@ -370,7 +370,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base :headers => credentials('admin')) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert user.hashed_password.present? end @@ -388,7 +388,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base :headers => credentials('admin')) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'foo', user.login assert_equal 'Firstname', user.firstname assert_equal 'Lastname', user.lastname diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb index 012739928..c430a672c 100644 --- a/test/integration/api_test/versions_test.rb +++ b/test/integration/api_test/versions_test.rb @@ -38,7 +38,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base :params => {:version => {:name => 'API test'}}, :headers => credentials('jsmith')) end - version = Version.order('id DESC').first + version = Version.order(id: :desc).first assert_equal 'API test', version.name assert_response :created @@ -53,7 +53,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base :params => {:version => {:name => 'API test', :due_date => '2012-01-24'}}, :headers => credentials('jsmith')) end - version = Version.order('id DESC').first + version = Version.order(id: :desc).first assert_equal 'API test', version.name assert_equal Date.parse('2012-01-24'), version.due_date @@ -69,7 +69,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base :params => {:version => {:name => 'API test', :wiki_page_title => WikiPage.first.title}}, :headers => credentials('jsmith')) end - version = Version.order('id DESC').first + version = Version.order(id: :desc).first assert_equal 'API test', version.name assert_equal WikiPage.first, version.wiki_page @@ -93,7 +93,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base }, :headers => credentials('jsmith')) end - version = Version.order('id DESC').first + version = Version.order(id: :desc).first assert_equal 'API test', version.name assert_equal 'Some value', version.custom_field_value(field) diff --git a/test/integration/api_test/wiki_pages_test.rb b/test/integration/api_test/wiki_pages_test.rb index f57db5880..0a57b6b9f 100644 --- a/test/integration/api_test/wiki_pages_test.rb +++ b/test/integration/api_test/wiki_pages_test.rb @@ -194,7 +194,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base end end - page = WikiPage.order('id DESC').first + page = WikiPage.order(id: :desc).first assert_equal 'New_page_from_API', page.title assert_equal 'New content from API', page.content.text assert_equal 1, page.content.version @@ -227,7 +227,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base end end - page = WikiPage.order('id DESC').first + page = WikiPage.order(id: :desc).first assert_equal 'New_page_from_API', page.title assert_include attachment, page.attachments assert_equal attachment.filename, page.attachments.first.filename @@ -251,7 +251,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base end end - page = WikiPage.order('id DESC').first + page = WikiPage.order(id: :desc).first assert_equal 'New_subpage_from_API', page.title assert_equal WikiPage.find(1), page.parent end diff --git a/test/integration/attachments_test.rb b/test/integration/attachments_test.rb index 80d2040a1..30162cb12 100644 --- a/test/integration/attachments_test.rb +++ b/test/integration/attachments_test.rb @@ -69,7 +69,7 @@ class AttachmentsTest < Redmine::IntegrationTest assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 'Issue with upload', issue.subject assert_equal 1, issue.attachments.count @@ -153,7 +153,7 @@ class AttachmentsTest < Redmine::IntegrationTest assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 'Issue with upload', issue.subject assert_equal 1, issue.attachments.count @@ -178,7 +178,7 @@ class AttachmentsTest < Redmine::IntegrationTest ) assert_response :found end - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_equal 'Issue with upload', issue.subject assert_equal 1, issue.attachments.count @@ -193,7 +193,7 @@ class AttachmentsTest < Redmine::IntegrationTest token = ajax_upload('myupload.txt', 'File content') - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first attachment_path = "/attachments/#{attachment.id}.js?attachment_id=1" assert_include( "href: '#{attachment_path}'", diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index c161538e7..2fd5cb7d4 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -91,7 +91,7 @@ class IssuesSystemTest < ApplicationSystemTestCase assert_text /Issue #\d+ created./ end - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_equal 'New test issue', issue.subject assert_equal 'New test issue description', issue.description assert_equal 'Low', issue.priority.name @@ -131,7 +131,7 @@ class IssuesSystemTest < ApplicationSystemTestCase assert_text /Issue #\d+ created./ end - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort end @@ -191,7 +191,7 @@ class IssuesSystemTest < ApplicationSystemTestCase end end - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_not_nil issue.fixed_version assert_equal '4.0', issue.fixed_version.name end @@ -210,7 +210,7 @@ class IssuesSystemTest < ApplicationSystemTestCase assert_text /Issue #\d+ created./ end - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_equal 'new issue description', issue.description end @@ -491,7 +491,7 @@ class IssuesSystemTest < ApplicationSystemTestCase assert_current_path '/issues', :ignore_query => true end - copies = Issue.order('id DESC').limit(2) + copies = Issue.order(id: :desc).limit(2) assert_equal 4, copies[0].priority.id assert_equal 4, copies[1].priority.id @@ -525,7 +525,7 @@ class IssuesSystemTest < ApplicationSystemTestCase assert_current_path '/projects/onlinestore/issues', :ignore_query => true end - copies = Issue.order('id DESC').limit(2) + copies = Issue.order(id: :desc).limit(2) assert_equal 2, copies[0].project.id assert_equal 6, copies[0].priority.id assert_equal 2, copies[1].project.id diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 3200e46cd..7bfa9311f 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -84,7 +84,7 @@ class AttachmentTest < ActiveSupport::TestCase copy = a.copy assert_save copy - copy = Attachment.order('id DESC').first + copy = Attachment.order(id: :desc).first %w(filename filesize content_type author_id created_on description digest disk_filename disk_directory diskfile).each do |attribute| assert_equal a.send(attribute), copy.send(attribute), "#{attribute} was different" end @@ -377,7 +377,7 @@ class AttachmentTest < ActiveSupport::TestCase 'description' => 'test' }) end - attachment = Attachment.order('id DESC').first + attachment = Attachment.order(id: :desc).first assert_equal issue, attachment.container assert_equal 'testfile.txt', attachment.filename assert_equal 59, attachment.filesize diff --git a/test/unit/board_test.rb b/test/unit/board_test.rb index 9f9b6e38b..e36ba17bd 100644 --- a/test/unit/board_test.rb +++ b/test/unit/board_test.rb @@ -120,6 +120,6 @@ class BoardTest < ActiveSupport::TestCase board = Board.find(1) assert_equal board.topics.count, board.topics_count assert_equal board.messages.count, board.messages_count - assert_equal board.messages.order("id DESC").first.id, board.last_message_id + assert_equal board.messages.order(id: :desc).first.id, board.last_message_id end end diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index 3ad8b1cbf..8a753046e 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -87,7 +87,7 @@ class ChangesetTest < ActiveSupport::TestCase c.scan_comment_for_issue_ids end - time = TimeEntry.order('id desc').first + time = TimeEntry.order(id: :desc).first assert_equal project_specific_activity, time.activity end @@ -121,7 +121,7 @@ class ChangesetTest < ActiveSupport::TestCase end assert_equal [1], c.issue_ids.sort - time = TimeEntry.order('id desc').first + time = TimeEntry.order(id: :desc).first assert_equal 1, time.issue_id assert_equal 1, time.project_id assert_equal 2, time.user_id @@ -156,7 +156,7 @@ class ChangesetTest < ActiveSupport::TestCase assert Issue.find(1).closed? assert Issue.find(2).closed? - times = TimeEntry.order('id desc').limit(2) + times = TimeEntry.order(id: :desc).limit(2) assert_equal [1, 2], times.collect(&:issue_id).sort end @@ -213,7 +213,7 @@ class ChangesetTest < ActiveSupport::TestCase :comments => "Fixes ##{issue.id}" ) assert_include c.id, issue.reload.changeset_ids - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal 1, journal.details.count end end @@ -312,7 +312,7 @@ class ChangesetTest < ActiveSupport::TestCase assert c.save end assert issue.reload.closed? - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal issue, journal.issue assert_include "Applied in changeset ecookbook:r12345.", journal.notes end diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb index 608176559..a6c8d35d3 100644 --- a/test/unit/custom_field_test.rb +++ b/test/unit/custom_field_test.rb @@ -316,7 +316,7 @@ class CustomFieldTest < ActiveSupport::TestCase user = User.generate! User.add_to_project(user, Project.first, Role.find(3)) - assert_equal [fields[0], fields[2]], CustomField.visible(user).order("id").to_a + assert_equal [fields[0], fields[2]], CustomField.visible(user).order(:id).to_a end def test_visibile_scope_with_anonymous_user_should_return_visible_custom_fields @@ -328,7 +328,7 @@ class CustomFieldTest < ActiveSupport::TestCase CustomField.generate!(:visible => false, :role_ids => [1, 2]), ] - assert_equal [fields[0]], CustomField.visible(User.anonymous).order("id").to_a + assert_equal [fields[0]], CustomField.visible(User.anonymous).order(:id).to_a end def test_float_cast_blank_value_should_return_nil diff --git a/test/unit/issue_category_test.rb b/test/unit/issue_category_test.rb index 60107232c..7a304c531 100644 --- a/test/unit/issue_category_test.rb +++ b/test/unit/issue_category_test.rb @@ -27,13 +27,13 @@ class IssueCategoryTest < ActiveSupport::TestCase def test_create assert IssueCategory.new(:project_id => 2, :name => 'New category').save - category = IssueCategory.order('id DESC').first + category = IssueCategory.order(id: :desc).first assert_equal 'New category', category.name end def test_create_with_group_assignment assert IssueCategory.new(:project_id => 2, :name => 'Group assignment', :assigned_to_id => 11).save - category = IssueCategory.order('id DESC').first + category = IssueCategory.order(id: :desc).first assert_kind_of Group, category.assigned_to assert_equal Group.find(11), category.assigned_to end diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb index 43d0f7110..9e52c031f 100644 --- a/test/unit/issue_nested_set_test.rb +++ b/test/unit/issue_nested_set_test.rb @@ -331,7 +331,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase c.reload assert_equal 5, c.issues.count - ic1, ic2, ic3, ic4, ic5 = c.issues.order('subject').to_a + ic1, ic2, ic3, ic4, ic5 = c.issues.order(:subject).to_a assert ic1.root? assert_equal ic1, ic2.parent assert_equal ic1, ic3.parent diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 5b286f264..df38b8062 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -178,7 +178,7 @@ class IssueTest < ActiveSupport::TestCase assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1, :subject => 'Group assignment', :assigned_to_id => 11).save - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_kind_of Group, issue.assigned_to assert_equal Group.find(11), issue.assigned_to end @@ -748,7 +748,7 @@ class IssueTest < ActiveSupport::TestCase issue.save! assert_nil issue.due_date end - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first details = journal.details.select {|d| d.prop_key == 'due_date'} assert_equal 1, details.count end @@ -758,7 +758,7 @@ class IssueTest < ActiveSupport::TestCase issue.custom_field_values = {'2' => 'Foo'} issue.save! - issue = Issue.order('id desc').first + issue = Issue.order(id: :desc).first assert_equal 'Foo', issue.custom_field_value(2) issue.custom_field_values = {'2' => 'Bar'} @@ -2834,7 +2834,7 @@ class IssueTest < ActiveSupport::TestCase end end - detail = JournalDetail.order('id DESC').first + detail = JournalDetail.order(id: :desc).first assert_equal i, detail.journal.journalized assert_equal 'attr', detail.property assert_equal 'description', detail.prop_key diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb index b8571858a..78edc1a4a 100644 --- a/test/unit/journal_test.rb +++ b/test/unit/journal_test.rb @@ -94,7 +94,7 @@ class JournalTest < ActiveSupport::TestCase assert_equal 'Notes', journal.notes assert_equal 0, journal.details.size - journal_with_changes = Journal.order('id DESC').offset(1).first + journal_with_changes = Journal.order(id: :desc).offset(1).first assert_equal false, journal_with_changes.private_notes assert_nil journal_with_changes.notes assert_equal 1, journal_with_changes.details.size diff --git a/test/unit/lib/redmine/ciphering_test.rb b/test/unit/lib/redmine/ciphering_test.rb index 261b2004a..e0f53ccf1 100644 --- a/test/unit/lib/redmine/ciphering_test.rb +++ b/test/unit/lib/redmine/ciphering_test.rb @@ -59,7 +59,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase end Redmine::Configuration.with 'database_cipher_key' => 'secret' do - r = Repository.order('id DESC').first + r = Repository.order(id: :desc).first assert_equal 'clear', r.password end end @@ -70,7 +70,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase end Redmine::Configuration.with 'database_cipher_key' => '' do - r = Repository.order('id DESC').first + r = Repository.order(id: :desc).first # password can not be deciphered assert_nothing_raised do assert r.password.match(/\Aaes-256-cbc:.+\Z/) @@ -87,7 +87,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase Redmine::Configuration.with 'database_cipher_key' => 'secret' do assert Repository.encrypt_all(:password) - r = Repository.order('id DESC').first + r = Repository.order(id: :desc).first assert_equal 'bar', r.password assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/) end @@ -100,7 +100,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase Repository::Subversion.create!(:password => 'bar', :url => 'file:///tmp', :identifier => 'bar') assert Repository.decrypt_all(:password) - r = Repository.order('id DESC').first + r = Repository.order(id: :desc).first assert_equal 'bar', r.password assert_equal 'bar', r.read_attribute(:password) end diff --git a/test/unit/lib/redmine/field_format/list_format_test.rb b/test/unit/lib/redmine/field_format/list_format_test.rb index 4d373f229..50e870c98 100644 --- a/test/unit/lib/redmine/field_format/list_format_test.rb +++ b/test/unit/lib/redmine/field_format/list_format_test.rb @@ -34,7 +34,7 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase group.custom_field_values = {field.id => 'Baz'} assert group.save(:validate => false) - group = Group.order('id DESC').first + group = Group.order(id: :desc).first assert_equal ['Foo', 'Bar', 'Baz'], field.possible_custom_value_options(group.custom_value_for(field)) assert group.valid? end diff --git a/test/unit/lib/redmine/field_format/user_field_format_test.rb b/test/unit/lib/redmine/field_format/user_field_format_test.rb index 2d095a207..9f34d47bb 100644 --- a/test/unit/lib/redmine/field_format/user_field_format_test.rb +++ b/test/unit/lib/redmine/field_format/user_field_format_test.rb @@ -41,7 +41,7 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase field.user_role = [Role.find_by_name('Developer').id] field.save! - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_include [user.name, user.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field)) assert issue.valid? end diff --git a/test/unit/lib/redmine/field_format/version_field_format_test.rb b/test/unit/lib/redmine/field_format/version_field_format_test.rb index cd3921845..b441fe008 100644 --- a/test/unit/lib/redmine/field_format/version_field_format_test.rb +++ b/test/unit/lib/redmine/field_format/version_field_format_test.rb @@ -44,7 +44,7 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase field.version_status = ["open"] field.save! - issue = Issue.order('id DESC').first + issue = Issue.order(id: :desc).first assert_include( [version.name, version.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field)) diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 8556d1e6c..373819be9 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -475,7 +475,7 @@ class MailHandlerTest < ActiveSupport::TestCase :default_group => "#{group1.name},#{group2.name}" ) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal [group1, group2].sort, user.groups.sort end @@ -505,7 +505,7 @@ class MailHandlerTest < ActiveSupport::TestCase :no_notification => '1' ) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal 'none', user.mail_notification end @@ -984,7 +984,7 @@ class MailHandlerTest < ActiveSupport::TestCase end end end - journal = Journal.order('id DESC').first + journal = Journal.order(id: :desc).first assert_equal Issue.find(2), journal.journalized assert_equal 1, journal.details.size @@ -1390,7 +1390,7 @@ class MailHandlerTest < ActiveSupport::TestCase :unknown_user => 'create' ) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal "foo@example.org", user.mail assert_equal 'Ää', user.firstname assert_equal 'Öö', user.lastname @@ -1405,7 +1405,7 @@ class MailHandlerTest < ActiveSupport::TestCase :unknown_user => 'create' ) end - user = User.order('id DESC').first + user = User.order(id: :desc).first assert_equal "jdoe@example.net", user.mail assert_equal 'John', user.firstname assert_equal 'Doe', user.lastname diff --git a/test/unit/project_copy_test.rb b/test/unit/project_copy_test.rb index 1bfb65cb5..8cad4f020 100644 --- a/test/unit/project_copy_test.rb +++ b/test/unit/project_copy_test.rb @@ -421,7 +421,7 @@ class ProjectCopyTest < ActiveSupport::TestCase assert project.copy(source.reload) end end - copy = Issue.where(:parent_id => nil).order("id DESC").first + copy = Issue.where(:parent_id => nil).order(id: :desc).first assert_equal project, copy.project assert_equal issue.descendants.count, copy.descendants.count child_copy = copy.children.detect {|c| c.subject == 'Child1'} diff --git a/test/unit/project_members_inheritance_test.rb b/test/unit/project_members_inheritance_test.rb index a5f7b3d93..da1a81fd2 100644 --- a/test/unit/project_members_inheritance_test.rb +++ b/test/unit/project_members_inheritance_test.rb @@ -51,7 +51,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase Project.generate_with_parent!(@parent, :inherit_members => false) assert_difference 'Member.count', 1 do - project = Project.order('id desc').first + project = Project.order(id: :desc).first project.inherit_members = true project.save! project.reload @@ -67,7 +67,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase Project.generate_with_parent!(@parent, :inherit_members => true) assert_difference 'Member.count', -1 do - project = Project.order('id desc').first + project = Project.order(id: :desc).first project.inherit_members = false project.save! project.reload @@ -78,7 +78,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase def test_moving_a_root_project_under_a_parent_should_inherit_members Project.generate!(:inherit_members => true) - project = Project.order('id desc').first + project = Project.order(id: :desc).first assert_difference 'Member.count', 1 do project.set_parent!(@parent) @@ -93,7 +93,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase def test_moving_a_subproject_as_root_should_loose_inherited_members Project.generate_with_parent!(@parent, :inherit_members => true) - project = Project.order('id desc').first + project = Project.order(id: :desc).first assert_difference 'Member.count', -1 do project.set_parent!(nil) @@ -109,7 +109,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase other_member.reload Project.generate_with_parent!(@parent, :inherit_members => true) - project = Project.order('id desc').first + project = Project.order(id: :desc).first project.set_parent!(other_parent.reload) project.reload @@ -161,7 +161,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase member = Member.create!(:principal => User.find(4), :project => @parent, :role_ids => [1, 3]) member.reload - inherited_member = project.memberships.order('id desc').first + inherited_member = project.memberships.order(id: :desc).first assert_equal member.principal, inherited_member.principal assert_equal member.roles.sort, inherited_member.roles.sort end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 967771c87..c98e39dc9 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -317,7 +317,7 @@ class UserTest < ActiveSupport::TestCase assert_difference 'JournalDetail.count' do issue.save! end - journal_detail = JournalDetail.order('id DESC').first + journal_detail = JournalDetail.order(id: :desc).first assert_equal '2', journal_detail.old_value User.find(2).destroy @@ -333,7 +333,7 @@ class UserTest < ActiveSupport::TestCase assert_difference 'JournalDetail.count' do issue.save! end - journal_detail = JournalDetail.order('id DESC').first + journal_detail = JournalDetail.order(id: :desc).first assert_equal '2', journal_detail.value User.find(2).destroy diff --git a/test/unit/wiki_content_test.rb b/test/unit/wiki_content_test.rb index 3b31f2f36..c72536010 100644 --- a/test/unit/wiki_content_test.rb +++ b/test/unit/wiki_content_test.rb @@ -68,7 +68,7 @@ class WikiContentTest < ActiveSupport::TestCase assert_equal version_count+1, content.version assert_equal version_count+1, content.versions.length - version = WikiContentVersion.order('id DESC').first + version = WikiContentVersion.order(id: :desc).first assert_equal @page.id, version.page_id assert_equal '', version.compression assert_equal "My new content", version.data @@ -84,7 +84,7 @@ class WikiContentTest < ActiveSupport::TestCase end end - version = WikiContentVersion.order('id DESC').first + version = WikiContentVersion.order(id: :desc).first assert_equal @page.id, version.page_id assert_equal 'gzip', version.compression assert_not_equal "My new content", version.data @@ -124,8 +124,8 @@ class WikiContentTest < ActiveSupport::TestCase def test_current_version content = WikiContent.find(11) assert_equal true, content.current_version? - assert_equal true, content.versions.order('version DESC').first.current_version? - assert_equal false, content.versions.order('version ASC').first.current_version? + assert_equal true, content.versions.order(version: :desc).first.current_version? + assert_equal false, content.versions.order(:version).first.current_version? end def test_previous_for_first_version_should_return_nil