test: switch to Rails3 Active Record syntax at unit/query_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9622 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-05-04 23:06:47 +00:00
parent 6c6467879a
commit 49fc255b48
1 changed files with 12 additions and 15 deletions

View File

@ -48,9 +48,9 @@ class QueryTest < ActiveSupport::TestCase
end end
def find_issues_with_query(query) def find_issues_with_query(query)
Issue.find :all, Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
:include => [ :assigned_to, :status, :tracker, :project, :priority ], query.statement
:conditions => query.statement ).all
end end
def assert_find_issues_with_query_is_successful(query) def assert_find_issues_with_query_is_successful(query)
@ -619,10 +619,9 @@ class QueryTest < ActiveSupport::TestCase
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
assert c assert c
assert c.sortable assert c.sortable
issues = Issue.find :all, issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
:include => [ :assigned_to, :status, :tracker, :project, :priority ], q.statement
:conditions => q.statement, ).order("#{c.sortable} ASC").all
:order => "#{c.sortable} ASC"
values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
assert !values.empty? assert !values.empty?
assert_equal values.sort, values assert_equal values.sort, values
@ -633,10 +632,9 @@ class QueryTest < ActiveSupport::TestCase
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' } c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
assert c assert c
assert c.sortable assert c.sortable
issues = Issue.find :all, issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
:include => [ :assigned_to, :status, :tracker, :project, :priority ], q.statement
:conditions => q.statement, ).order("#{c.sortable} DESC").all
:order => "#{c.sortable} DESC"
values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s} values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
assert !values.empty? assert !values.empty?
assert_equal values.sort.reverse, values assert_equal values.sort.reverse, values
@ -647,10 +645,9 @@ class QueryTest < ActiveSupport::TestCase
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'float' } c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'float' }
assert c assert c
assert c.sortable assert c.sortable
issues = Issue.find :all, issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
:include => [ :assigned_to, :status, :tracker, :project, :priority ], q.statement
:conditions => q.statement, ).order("#{c.sortable} ASC").all
:order => "#{c.sortable} ASC"
values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom_field).to_s); rescue; nil; end}.compact values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom_field).to_s); rescue; nil; end}.compact
assert !values.empty? assert !values.empty?
assert_equal values.sort, values assert_equal values.sort, values