Replaces find(:first) calls.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10928 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -117,7 +117,7 @@ class EnumerationsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_destroy_enumeration_in_use_with_reassignment
|
||||
issue = Issue.find(:first, :conditions => {:priority_id => 4})
|
||||
issue = Issue.where(:priority_id => 4).first
|
||||
assert_difference 'IssuePriority.count', -1 do
|
||||
delete :destroy, :id => 4, :reassign_to_id => 6
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ class FilesControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
a = Attachment.order('created_on DESC').first
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Project.find(1), a.container
|
||||
|
||||
@@ -88,7 +88,7 @@ class FilesControllerTest < ActionController::TestCase
|
||||
assert_response :redirect
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
a = Attachment.order('created_on DESC').first
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
end
|
||||
|
||||
@@ -133,7 +133,7 @@ class IssueCategoriesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use_with_reassignment
|
||||
issue = Issue.find(:first, :conditions => {:category_id => 1})
|
||||
issue = Issue.where(:category_id => 1).first
|
||||
delete :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2
|
||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||
assert_nil IssueCategory.find_by_id(1)
|
||||
@@ -142,7 +142,7 @@ class IssueCategoriesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use_without_reassignment
|
||||
issue = Issue.find(:first, :conditions => {:category_id => 1})
|
||||
issue = Issue.where(:category_id => 1).first
|
||||
delete :destroy, :id => 1, :todo => 'nullify'
|
||||
assert_redirected_to '/projects/ecookbook/settings/categories'
|
||||
assert_nil IssueCategory.find_by_id(1)
|
||||
|
||||
@@ -45,7 +45,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||
post :create, :issue_status => {:name => 'New status'}
|
||||
end
|
||||
assert_redirected_to :action => 'index'
|
||||
status = IssueStatus.find(:first, :order => 'id DESC')
|
||||
status = IssueStatus.order('id DESC').first
|
||||
assert_equal 'New status', status.name
|
||||
end
|
||||
|
||||
|
||||
@@ -1709,7 +1709,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_equal 2, issue.status_id
|
||||
assert_equal Date.parse('2010-11-07'), issue.start_date
|
||||
assert_nil issue.estimated_hours
|
||||
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
||||
v = issue.custom_values.where(:custom_field_id => 2).first
|
||||
assert_not_nil v
|
||||
assert_equal 'Value for field 2', v.value
|
||||
end
|
||||
@@ -2817,7 +2817,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue.reload
|
||||
assert_equal 2, issue.status_id
|
||||
j = Journal.find(:first, :order => 'id DESC')
|
||||
j = Journal.order('id DESC').first
|
||||
assert_equal 'Assigned to dlopper', j.notes
|
||||
assert_equal 2, j.details.size
|
||||
|
||||
@@ -2834,7 +2834,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:id => 1,
|
||||
:issue => { :notes => notes }
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
j = Journal.find(:first, :order => 'id DESC')
|
||||
j = Journal.order('id DESC').first
|
||||
assert_equal notes, j.notes
|
||||
assert_equal 0, j.details.size
|
||||
assert_equal User.anonymous, j.user
|
||||
@@ -2890,7 +2890,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
issue = Issue.find(1)
|
||||
|
||||
j = Journal.find(:first, :order => 'id DESC')
|
||||
j = Journal.order('id DESC').first
|
||||
assert_equal '2.5 hours added', j.notes
|
||||
assert_equal 0, j.details.size
|
||||
|
||||
@@ -2915,7 +2915,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
||||
j = Issue.find(1).journals.reorder('id DESC').first
|
||||
assert j.notes.blank?
|
||||
assert_equal 1, j.details.size
|
||||
assert_equal 'testfile.txt', j.details.first.value
|
||||
@@ -3278,7 +3278,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
||||
|
||||
issue = Issue.find(1)
|
||||
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
||||
journal = issue.journals.reorder('created_on DESC').first
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
assert_equal 'Bulk editing', journal.notes
|
||||
assert_equal 1, journal.details.size
|
||||
@@ -3313,7 +3313,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
|
||||
|
||||
issue = Issue.find(1)
|
||||
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
||||
journal = issue.journals.reorder('created_on DESC').first
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
assert_equal 'Bulk editing', journal.notes
|
||||
assert_equal 1, journal.details.size
|
||||
@@ -3438,7 +3438,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_response 302
|
||||
|
||||
issue = Issue.find(1)
|
||||
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
||||
journal = issue.journals.reorder('created_on DESC').first
|
||||
assert_equal '777', issue.custom_value_for(2).value
|
||||
assert_equal 1, journal.details.size
|
||||
assert_equal '125', journal.details.first.old_value
|
||||
|
||||
@@ -159,7 +159,7 @@ class MessagesControllerTest < ActionController::TestCase
|
||||
def test_reply
|
||||
@request.session[:user_id] = 2
|
||||
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
|
||||
reply = Message.find(:first, :order => 'id DESC')
|
||||
reply = Message.order('id DESC').first
|
||||
assert_redirected_to "/boards/1/topics/1?r=#{reply.id}"
|
||||
assert Message.find_by_subject('Test reply')
|
||||
end
|
||||
|
||||
@@ -75,14 +75,14 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase
|
||||
|
||||
project_activity = TimeEntryActivity.new({
|
||||
:name => 'Project Specific',
|
||||
:parent => TimeEntryActivity.find(:first),
|
||||
:parent => TimeEntryActivity.first,
|
||||
:project => Project.find(1),
|
||||
:active => true
|
||||
})
|
||||
assert project_activity.save
|
||||
project_activity_two = TimeEntryActivity.new({
|
||||
:name => 'Project Specific Two',
|
||||
:parent => TimeEntryActivity.find(:last),
|
||||
:parent => TimeEntryActivity.last,
|
||||
:project => Project.find(1),
|
||||
:active => true
|
||||
})
|
||||
@@ -156,14 +156,14 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2 # manager
|
||||
project_activity = TimeEntryActivity.new({
|
||||
:name => 'Project Specific',
|
||||
:parent => TimeEntryActivity.find(:first),
|
||||
:parent => TimeEntryActivity.first,
|
||||
:project => Project.find(1),
|
||||
:active => true
|
||||
})
|
||||
assert project_activity.save
|
||||
project_activity_two = TimeEntryActivity.new({
|
||||
:name => 'Project Specific Two',
|
||||
:parent => TimeEntryActivity.find(:last),
|
||||
:parent => TimeEntryActivity.last,
|
||||
:project => Project.find(1),
|
||||
:active => true
|
||||
})
|
||||
|
||||
@@ -37,7 +37,7 @@ class WelcomeControllerTest < ActionController::TestCase
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:news)
|
||||
assert_not_nil assigns(:projects)
|
||||
assert !assigns(:projects).include?(Project.find(:first, :conditions => {:is_public => false}))
|
||||
assert !assigns(:projects).include?(Project.where(:is_public => false).first)
|
||||
end
|
||||
|
||||
def test_browser_language
|
||||
|
||||
@@ -102,9 +102,9 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 3, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_not_nil WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
assert_nil WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4})
|
||||
assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count
|
||||
assert_not_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first
|
||||
assert_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4).first
|
||||
end
|
||||
|
||||
def test_post_edit_with_additional_transitions
|
||||
@@ -115,18 +115,18 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 4, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count
|
||||
|
||||
w = WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 4, :new_status_id => 5})
|
||||
w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 4, :new_status_id => 5).first
|
||||
assert ! w.author
|
||||
assert ! w.assignee
|
||||
w = WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 1})
|
||||
w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 1).first
|
||||
assert w.author
|
||||
assert ! w.assignee
|
||||
w = WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first
|
||||
assert ! w.author
|
||||
assert w.assignee
|
||||
w = WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 4})
|
||||
w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 4).first
|
||||
assert w.author
|
||||
assert w.assignee
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user