1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Fix RuboCop Rails/OrderArguments (#43438).

git-svn-id: https://svn.redmine.org/redmine/trunk@24125 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2025-11-05 07:41:46 +00:00
parent 2376d29a93
commit 157986c778
62 changed files with 190 additions and 190 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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}'",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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'}

View File

@ -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

View File

@ -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

View File

@ -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