summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-05-04 23:06:47 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-05-04 23:06:47 +0000
commit49fc255b48b617204e6ca903e4701abbd112ee02 (patch)
tree7f7d96a54068eeed1632130d99049b4093685701 /test
parent6c6467879afd7668d2c97a78af0ac6a92c02f4dd (diff)
downloadredmine-49fc255b48b617204e6ca903e4701abbd112ee02.tar.gz
redmine-49fc255b48b617204e6ca903e4701abbd112ee02.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb27
1 files changed, 12 insertions, 15 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index c89c2c8c5..0df513382 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -48,9 +48,9 @@ class QueryTest < ActiveSupport::TestCase
end
def find_issues_with_query(query)
- Issue.find :all,
- :include => [ :assigned_to, :status, :tracker, :project, :priority ],
- :conditions => query.statement
+ Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
+ query.statement
+ ).all
end
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' }
assert c
assert c.sortable
- issues = Issue.find :all,
- :include => [ :assigned_to, :status, :tracker, :project, :priority ],
- :conditions => q.statement,
- :order => "#{c.sortable} ASC"
+ issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
+ q.statement
+ ).order("#{c.sortable} ASC").all
values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
assert !values.empty?
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' }
assert c
assert c.sortable
- issues = Issue.find :all,
- :include => [ :assigned_to, :status, :tracker, :project, :priority ],
- :conditions => q.statement,
- :order => "#{c.sortable} DESC"
+ issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
+ q.statement
+ ).order("#{c.sortable} DESC").all
values = issues.collect {|i| i.custom_value_for(c.custom_field).to_s}
assert !values.empty?
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' }
assert c
assert c.sortable
- issues = Issue.find :all,
- :include => [ :assigned_to, :status, :tracker, :project, :priority ],
- :conditions => q.statement,
- :order => "#{c.sortable} ASC"
+ issues = Issue.includes([:assigned_to, :status, :tracker, :project, :priority]).where(
+ q.statement
+ ).order("#{c.sortable} ASC").all
values = issues.collect {|i| begin; Kernel.Float(i.custom_value_for(c.custom_field).to_s); rescue; nil; end}.compact
assert !values.empty?
assert_equal values.sort, values