summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-09 14:10:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-09 14:10:49 +0000
commitab066317e62b3a6082fc82ba57915ed02f0f6699 (patch)
tree7889bbe8150f7aa9ed03a8970e9c999e33e378f1 /test
parentfb9a87f53ecd1bce3afef08cea0237e227cd400d (diff)
downloadredmine-ab066317e62b3a6082fc82ba57915ed02f0f6699.tar.gz
redmine-ab066317e62b3a6082fc82ba57915ed02f0f6699.zip
Adds STI to Query model. Issue queries are now IssueQuery instances.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10964 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/queries.yml9
-rw-r--r--test/functional/calendars_controller_test.rb2
-rw-r--r--test/functional/issues_controller_test.rb20
-rw-r--r--test/functional/issues_controller_transaction_test.rb2
-rw-r--r--test/unit/helpers/queries_helper_test.rb4
-rw-r--r--test/unit/lib/redmine/helpers/gantt_test.rb2
-rw-r--r--test/unit/query_test.rb243
7 files changed, 145 insertions, 137 deletions
diff --git a/test/fixtures/queries.yml b/test/fixtures/queries.yml
index a49f82fbb..f88da94d1 100644
--- a/test/fixtures/queries.yml
+++ b/test/fixtures/queries.yml
@@ -1,6 +1,7 @@
---
queries_001:
id: 1
+ type: IssueQuery
project_id: 1
is_public: true
name: Multiple custom fields query
@@ -23,6 +24,7 @@ queries_001:
column_names:
queries_002:
id: 2
+ type: IssueQuery
project_id: 1
is_public: false
name: Private query for cookbook
@@ -41,6 +43,7 @@ queries_002:
column_names:
queries_003:
id: 3
+ type: IssueQuery
project_id:
is_public: false
name: Private query for all projects
@@ -55,6 +58,7 @@ queries_003:
column_names:
queries_004:
id: 4
+ type: IssueQuery
project_id:
is_public: true
name: Public query for all projects
@@ -69,6 +73,7 @@ queries_004:
column_names:
queries_005:
id: 5
+ type: IssueQuery
project_id:
is_public: true
name: Open issues by priority and tracker
@@ -89,6 +94,7 @@ queries_005:
- asc
queries_006:
id: 6
+ type: IssueQuery
project_id:
is_public: true
name: Open issues grouped by tracker
@@ -108,6 +114,7 @@ queries_006:
- desc
queries_007:
id: 7
+ type: IssueQuery
project_id: 2
is_public: true
name: Public query for project 2
@@ -122,6 +129,7 @@ queries_007:
column_names:
queries_008:
id: 8
+ type: IssueQuery
project_id: 2
is_public: false
name: Private query for project 2
@@ -136,6 +144,7 @@ queries_008:
column_names:
queries_009:
id: 9
+ type: IssueQuery
project_id:
is_public: true
name: Open issues grouped by list custom field
diff --git a/test/functional/calendars_controller_test.rb b/test/functional/calendars_controller_test.rb
index 2855afbbf..a8ab5750f 100644
--- a/test/functional/calendars_controller_test.rb
+++ b/test/functional/calendars_controller_test.rb
@@ -42,7 +42,7 @@ class CalendarsControllerTest < ActionController::TestCase
context "GET :show" do
should "run custom queries" do
- @query = Query.create!(:name => 'Calendar', :is_public => true)
+ @query = IssueQuery.create!(:name => 'Calendar', :is_public => true)
get :show, :query_id => @query.id
assert_response :success
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index e0d11d7ef..e91fbd41c 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -327,7 +327,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_index_with_cross_project_query_in_session_should_show_project_issues
- q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
@request.session[:query] = {:id => q.id, :project_id => 1}
with_settings :display_subprojects_issues => '0' do
@@ -341,7 +341,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_private_query_should_not_be_available_to_other_users
- q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
@request.session[:user_id] = 3
get :index, :query_id => q.id
@@ -349,7 +349,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_private_query_should_be_available_to_its_user
- q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
@request.session[:user_id] = 2
get :index, :query_id => q.id
@@ -357,7 +357,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_public_query_should_be_available_to_other_users
- q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
@request.session[:user_id] = 3
get :index, :query_id => q.id
@@ -666,7 +666,7 @@ class IssuesControllerTest < ActionController::TestCase
# query should use specified columns
query = assigns(:query)
- assert_kind_of Query, query
+ assert_kind_of IssueQuery, query
assert_equal columns, query.column_names.map(&:to_s)
# columns should be stored in session
@@ -688,7 +688,7 @@ class IssuesControllerTest < ActionController::TestCase
# query should use specified columns
query = assigns(:query)
- assert_kind_of Query, query
+ assert_kind_of IssueQuery, query
assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
end
@@ -699,7 +699,7 @@ class IssuesControllerTest < ActionController::TestCase
# query should use specified columns
query = assigns(:query)
- assert_kind_of Query, query
+ assert_kind_of IssueQuery, query
assert_equal columns.map(&:to_sym), query.columns.map(&:name)
end
@@ -710,7 +710,7 @@ class IssuesControllerTest < ActionController::TestCase
# query should use specified columns
query = assigns(:query)
- assert_kind_of Query, query
+ assert_kind_of IssueQuery, query
assert_equal columns, query.column_names.map(&:to_s)
assert_select 'table.issues td.cf_2.string'
@@ -1136,7 +1136,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_show_should_display_prev_next_links_with_saved_query_in_session
- query = Query.create!(:name => 'test', :is_public => true, :user_id => 1,
+ query = IssueQuery.create!(:name => 'test', :is_public => true, :user_id => 1,
:filters => {'status_id' => {:values => ['5'], :operator => '='}},
:sort_criteria => [['id', 'asc']])
@request.session[:query] = {:id => query.id, :project_id => nil}
@@ -1228,7 +1228,7 @@ class IssuesControllerTest < ActionController::TestCase
CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
- query = Query.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
+ query = IssueQuery.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
:sort_criteria => [["cf_#{cf.id}", 'asc'], ['id', 'asc']])
@request.session[:query] = {:id => query.id, :project_id => nil}
diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb
index 85c573f9d..6c662d89d 100644
--- a/test/functional/issues_controller_transaction_test.rb
+++ b/test/functional/issues_controller_transaction_test.rb
@@ -252,7 +252,7 @@ class IssuesControllerTransactionTest < ActionController::TestCase
end
def test_index_should_rescue_invalid_sql_query
- Query.any_instance.stubs(:statement).returns("INVALID STATEMENT")
+ IssueQuery.any_instance.stubs(:statement).returns("INVALID STATEMENT")
get :index
assert_response 500
diff --git a/test/unit/helpers/queries_helper_test.rb b/test/unit/helpers/queries_helper_test.rb
index ce23648d2..bc06499a9 100644
--- a/test/unit/helpers/queries_helper_test.rb
+++ b/test/unit/helpers/queries_helper_test.rb
@@ -31,7 +31,7 @@ class QueriesHelperTest < ActionView::TestCase
def test_order
User.current = User.find_by_login('admin')
- query = Query.new(:project => nil, :name => '_')
+ query = IssueQuery.new(:project => nil, :name => '_')
assert_equal 30, query.available_filters.size
fo = filters_options(query)
assert_equal 31, fo.size
@@ -52,7 +52,7 @@ class QueriesHelperTest < ActionView::TestCase
)
assert field.save
User.current = User.find_by_login('admin')
- query = Query.new(:project => nil, :name => '_')
+ query = IssueQuery.new(:project => nil, :name => '_')
assert_equal 32, query.available_filters.size
fo = filters_options(query)
assert_equal 33, fo.size
diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb
index 291662d67..591503389 100644
--- a/test/unit/lib/redmine/helpers/gantt_test.rb
+++ b/test/unit/lib/redmine/helpers/gantt_test.rb
@@ -50,7 +50,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
@project = project
@gantt = Redmine::Helpers::Gantt.new(options)
@gantt.project = @project
- @gantt.query = Query.create!(:project => @project, :name => 'Gantt')
+ @gantt.query = IssueQuery.create!(:project => @project, :name => 'Gantt')
@gantt.view = self
@gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14))
@gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14))
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 6b1dda1e0..7c13156f8 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -29,20 +29,20 @@ class QueryTest < ActiveSupport::TestCase
:custom_fields_trackers
def test_custom_fields_for_all_projects_should_be_available_in_global_queries
- query = Query.new(:project => nil, :name => '_')
+ query = IssueQuery.new(:project => nil, :name => '_')
assert query.available_filters.has_key?('cf_1')
assert !query.available_filters.has_key?('cf_3')
end
def test_system_shared_versions_should_be_available_in_global_queries
Version.find(2).update_attribute :sharing, 'system'
- query = Query.new(:project => nil, :name => '_')
+ query = IssueQuery.new(:project => nil, :name => '_')
assert query.available_filters.has_key?('fixed_version_id')
assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'}
end
def test_project_filter_in_global_queries
- query = Query.new(:project => nil, :name => '_')
+ query = IssueQuery.new(:project => nil, :name => '_')
project_filter = query.available_filters["project_id"]
assert_not_nil project_filter
project_ids = project_filter[:values].map{|p| p[1]}
@@ -75,14 +75,14 @@ class QueryTest < ActiveSupport::TestCase
def test_query_should_allow_shared_versions_for_a_project_query
subproject_version = Version.find(4)
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('fixed_version_id', '=', [subproject_version.id.to_s])
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IN ('4')")
end
def test_query_with_multiple_custom_fields
- query = Query.find(1)
+ query = IssueQuery.find(1)
assert query.valid?
assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')")
issues = find_issues_with_query(query)
@@ -91,7 +91,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_none
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('fixed_version_id', '!*', [''])
query.add_filter('cf_1', '!*', [''])
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL")
@@ -100,7 +100,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_none_for_integer
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('estimated_hours', '!*', [''])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -108,7 +108,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_none_for_date
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('start_date', '!*', [''])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -116,7 +116,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_none_for_string_custom_field
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('cf_2', '!*', [''])
assert query.has_filter?('cf_2')
issues = find_issues_with_query(query)
@@ -125,7 +125,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_all
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('fixed_version_id', '*', [''])
query.add_filter('cf_1', '*', [''])
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL")
@@ -134,7 +134,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_all_for_date
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('start_date', '*', [''])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -142,7 +142,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_all_for_string_custom_field
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('cf_2', '*', [''])
assert query.has_filter?('cf_2')
issues = find_issues_with_query(query)
@@ -151,7 +151,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_numeric_filter_should_not_accept_non_numeric_values
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('estimated_hours', '=', ['a'])
assert query.has_filter?('estimated_hours')
@@ -161,7 +161,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_is_on_float
Issue.update_all("estimated_hours = 171.2", "id=2")
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('estimated_hours', '=', ['171.20'])
issues = find_issues_with_query(query)
assert_equal 1, issues.size
@@ -174,7 +174,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['12'])
issues = find_issues_with_query(query)
assert_equal 1, issues.size
@@ -187,7 +187,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '-12')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['-12'])
assert query.valid?
issues = find_issues_with_query(query)
@@ -201,7 +201,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12.7')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['12.7'])
issues = find_issues_with_query(query)
assert_equal 1, issues.size
@@ -214,7 +214,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '-12.7')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['-12.7'])
assert query.valid?
issues = find_issues_with_query(query)
@@ -229,12 +229,12 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => 'value2')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => 'value1')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['value1'])
issues = find_issues_with_query(query)
assert_equal [1, 3], issues.map(&:id).sort
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '=', ['value2'])
issues = find_issues_with_query(query)
assert_equal [1], issues.map(&:id).sort
@@ -247,13 +247,13 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => 'value2')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => 'value1')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '!', ['value1'])
issues = find_issues_with_query(query)
assert !issues.map(&:id).include?(1)
assert !issues.map(&:id).include?(3)
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter("cf_#{f.id}", '!', ['value2'])
issues = find_issues_with_query(query)
assert !issues.map(&:id).include?(1)
@@ -264,7 +264,7 @@ class QueryTest < ActiveSupport::TestCase
# is_private filter only available for those who can set issues private
User.current = User.find(2)
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
assert query.available_filters.key?('is_private')
query.add_filter("is_private", '=', ['1'])
@@ -279,7 +279,7 @@ class QueryTest < ActiveSupport::TestCase
# is_private filter only available for those who can set issues private
User.current = User.find(2)
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
assert query.available_filters.key?('is_private')
query.add_filter("is_private", '!', ['1'])
@@ -291,14 +291,14 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_greater_than
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('done_ratio', '>=', ['40'])
assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40.0")
find_issues_with_query(query)
end
def test_operator_greater_than_a_float
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('estimated_hours', '>=', ['40.5'])
assert query.statement.include?("#{Issue.table_name}.estimated_hours >= 40.5")
find_issues_with_query(query)
@@ -310,7 +310,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => f, :customized => Issue.find(2), :value => '12')
CustomValue.create!(:custom_field => f, :customized => Issue.find(3), :value => '')
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter("cf_#{f.id}", '>=', ['8'])
issues = find_issues_with_query(query)
assert_equal 1, issues.size
@@ -318,7 +318,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_lesser_than
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('done_ratio', '<=', ['30'])
assert query.statement.include?("#{Issue.table_name}.done_ratio <= 30.0")
find_issues_with_query(query)
@@ -326,14 +326,14 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_lesser_than_on_custom_field
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter("cf_#{f.id}", '<=', ['30'])
assert query.statement.include?("CAST(custom_values.value AS decimal(60,3)) <= 30.0")
find_issues_with_query(query)
end
def test_operator_between
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('done_ratio', '><', ['30', '40'])
assert_include "#{Issue.table_name}.done_ratio BETWEEN 30.0 AND 40.0", query.statement
find_issues_with_query(query)
@@ -341,14 +341,14 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_between_on_custom_field
f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_filter => true, :is_for_all => true)
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter("cf_#{f.id}", '><', ['30', '40'])
assert_include "CAST(custom_values.value AS decimal(60,3)) BETWEEN 30.0 AND 40.0", query.statement
find_issues_with_query(query)
end
def test_date_filter_should_not_accept_non_date_values
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('created_on', '=', ['a'])
assert query.has_filter?('created_on')
@@ -356,7 +356,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_date_filter_should_not_accept_invalid_date_values
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('created_on', '=', ['2011-01-34'])
assert query.has_filter?('created_on')
@@ -364,7 +364,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_relative_date_filter_should_not_accept_non_integer_values
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('created_on', '>t-', ['a'])
assert query.has_filter?('created_on')
@@ -372,28 +372,28 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_date_equals
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '=', ['2011-07-10'])
assert_match /issues\.due_date > '2011-07-09 23:59:59(\.9+)?' AND issues\.due_date <= '2011-07-10 23:59:59(\.9+)?/, query.statement
find_issues_with_query(query)
end
def test_operator_date_lesser_than
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '<=', ['2011-07-10'])
assert_match /issues\.due_date <= '2011-07-10 23:59:59(\.9+)?/, query.statement
find_issues_with_query(query)
end
def test_operator_date_greater_than
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '>=', ['2011-07-10'])
assert_match /issues\.due_date > '2011-07-09 23:59:59(\.9+)?'/, query.statement
find_issues_with_query(query)
end
def test_operator_date_between
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.add_filter('due_date', '><', ['2011-06-23', '2011-07-10'])
assert_match /issues\.due_date > '2011-06-22 23:59:59(\.9+)?' AND issues\.due_date <= '2011-07-10 23:59:59(\.9+)?/, query.statement
find_issues_with_query(query)
@@ -401,7 +401,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_in_more_than
Issue.find(7).update_attribute(:due_date, (Date.today + 15))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '>t+', ['15'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -409,7 +409,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_in_less_than
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '<t+', ['15'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -417,7 +417,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_in_the_next_days
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '><t+', ['15'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -426,7 +426,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_less_than_ago
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '>t-', ['3'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -435,7 +435,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_in_the_past_days
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '><t-', ['3'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -444,7 +444,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_more_than_ago
Issue.find(7).update_attribute(:due_date, (Date.today - 10))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', '<t-', ['10'])
assert query.statement.include?("#{Issue.table_name}.due_date <=")
issues = find_issues_with_query(query)
@@ -454,7 +454,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_in
Issue.find(7).update_attribute(:due_date, (Date.today + 2))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 't+', ['2'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -463,7 +463,7 @@ class QueryTest < ActiveSupport::TestCase
def test_operator_ago
Issue.find(7).update_attribute(:due_date, (Date.today - 3))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 't-', ['3'])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -471,7 +471,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_today
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 't', [''])
issues = find_issues_with_query(query)
assert !issues.empty?
@@ -479,19 +479,19 @@ class QueryTest < ActiveSupport::TestCase
end
def test_operator_this_week_on_date
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 'w', [''])
find_issues_with_query(query)
end
def test_operator_this_week_on_datetime
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('created_on', 'w', [''])
find_issues_with_query(query)
end
def test_operator_contains
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('subject', '~', ['uNable'])
assert query.statement.include?("LOWER(#{Issue.table_name}.subject) LIKE '%unable%'")
result = find_issues_with_query(query)
@@ -505,7 +505,7 @@ class QueryTest < ActiveSupport::TestCase
Date.stubs(:today).returns(Date.parse('2011-04-29'))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 'w', [''])
assert query.statement.match(/issues\.due_date > '2011-04-24 23:59:59(\.9+)?' AND issues\.due_date <= '2011-05-01 23:59:59(\.9+)?/), "range not found in #{query.statement}"
I18n.locale = :en
@@ -517,13 +517,13 @@ class QueryTest < ActiveSupport::TestCase
Date.stubs(:today).returns(Date.parse('2011-04-29'))
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 'w', [''])
assert query.statement.match(/issues\.due_date > '2011-04-23 23:59:59(\.9+)?' AND issues\.due_date <= '2011-04-30 23:59:59(\.9+)?/), "range not found in #{query.statement}"
end
def test_operator_does_not_contains
- query = Query.new(:project => Project.find(1), :name => '_')
+ query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('subject', '!~', ['uNable'])
assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'")
find_issues_with_query(query)
@@ -538,7 +538,7 @@ class QueryTest < ActiveSupport::TestCase
i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => Group.find(11))
group.users << user
- query = Query.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
+ query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
result = query.issues
assert_equal Issue.visible.all(:conditions => {:assigned_to_id => ([2] + user.reload.group_ids)}).sort_by(&:id), result.sort_by(&:id)
@@ -553,7 +553,7 @@ class QueryTest < ActiveSupport::TestCase
issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :custom_field_values => {cf.id.to_s => '2'}, :subject => 'Test', :author_id => 1)
issue2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {cf.id.to_s => '3'})
- query = Query.new(:name => '_', :project => Project.find(1))
+ query = IssueQuery.new(:name => '_', :project => Project.find(1))
filter = query.available_filters["cf_#{cf.id}"]
assert_not_nil filter
assert_include 'me', filter[:values].map{|v| v[1]}
@@ -566,7 +566,7 @@ class QueryTest < ActiveSupport::TestCase
def test_filter_my_projects
User.current = User.find(2)
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
filter = query.available_filters['project_id']
assert_not_nil filter
assert_include 'mine', filter[:values].map{|v| v[1]}
@@ -578,7 +578,7 @@ class QueryTest < ActiveSupport::TestCase
def test_filter_watched_issues
User.current = User.find(1)
- query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
+ query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
result = find_issues_with_query(query)
assert_not_nil result
assert !result.empty?
@@ -588,7 +588,7 @@ class QueryTest < ActiveSupport::TestCase
def test_filter_unwatched_issues
User.current = User.find(1)
- query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '!', :values => ['me']}})
+ query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '!', :values => ['me']}})
result = find_issues_with_query(query)
assert_not_nil result
assert !result.empty?
@@ -601,7 +601,7 @@ class QueryTest < ActiveSupport::TestCase
CustomValue.create!(:custom_field => field, :customized => Project.find(3), :value => 'Foo')
CustomValue.create!(:custom_field => field, :customized => Project.find(5), :value => 'Foo')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
filter_name = "project.cf_#{field.id}"
assert_include filter_name, query.available_filters.keys
query.filters = {filter_name => {:operator => '=', :values => ['Foo']}}
@@ -612,7 +612,7 @@ class QueryTest < ActiveSupport::TestCase
field = UserCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
CustomValue.create!(:custom_field => field, :customized => User.find(3), :value => 'Foo')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
filter_name = "author.cf_#{field.id}"
assert_include filter_name, query.available_filters.keys
query.filters = {filter_name => {:operator => '=', :values => ['Foo']}}
@@ -623,7 +623,7 @@ class QueryTest < ActiveSupport::TestCase
field = UserCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
CustomValue.create!(:custom_field => field, :customized => User.find(3), :value => 'Foo')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
filter_name = "assigned_to.cf_#{field.id}"
assert_include filter_name, query.available_filters.keys
query.filters = {filter_name => {:operator => '=', :values => ['Foo']}}
@@ -634,7 +634,7 @@ class QueryTest < ActiveSupport::TestCase
field = VersionCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
CustomValue.create!(:custom_field => field, :customized => Version.find(2), :value => 'Foo')
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
filter_name = "fixed_version.cf_#{field.id}"
assert_include filter_name, query.available_filters.keys
query.filters = {filter_name => {:operator => '=', :values => ['Foo']}}
@@ -646,11 +646,11 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=', :values => ['1']}}
assert_equal [2, 3], find_issues_with_query(query).map(&:id).sort
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=', :values => ['2']}}
assert_equal [1], find_issues_with_query(query).map(&:id).sort
end
@@ -663,15 +663,15 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(3).issues.first)
end
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=p', :values => ['2']}}
assert_equal [1, 2], find_issues_with_query(query).map(&:id).sort
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=p', :values => ['3']}}
assert_equal [1], find_issues_with_query(query).map(&:id).sort
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=p', :values => ['4']}}
assert_equal [], find_issues_with_query(query).map(&:id).sort
end
@@ -684,7 +684,7 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Project.find(3).issues.first)
end
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '=!p', :values => ['1']}}
assert_equal [1], find_issues_with_query(query).map(&:id).sort
end
@@ -697,7 +697,7 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_to => Project.find(2).issues.first, :issue_from => Issue.find(3))
end
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '!p', :values => ['2']}}
ids = find_issues_with_query(query).map(&:id).sort
assert_include 2, ids
@@ -710,7 +710,7 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '!*', :values => ['']}}
ids = find_issues_with_query(query).map(&:id)
assert_equal [], ids & [1, 2, 3]
@@ -722,13 +722,13 @@ class QueryTest < ActiveSupport::TestCase
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
- query = Query.new(:name => '_')
+ query = IssueQuery.new(:name => '_')
query.filters = {"relates" => {:operator => '*', :values => ['']}}
assert_equal [1, 2, 3], find_issues_with_query(query).map(&:id).sort
end
def test_statement_should_be_nil_with_no_filters
- q = Query.new(:name => '_')
+ q = IssueQuery.new(:name => '_')
q.filters = {}
assert q.valid?
@@ -736,14 +736,14 @@ class QueryTest < ActiveSupport::TestCase
end
def test_default_columns
- q = Query.new
+ q = IssueQuery.new
assert q.columns.any?
assert q.inline_columns.any?
assert q.block_columns.empty?
end
def test_set_column_names
- q = Query.new
+ q = IssueQuery.new
q.column_names = ['tracker', :subject, '', 'unknonw_column']
assert_equal [:tracker, :subject], q.columns.collect {|c| c.name}
c = q.columns.first
@@ -751,7 +751,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_inline_and_block_columns
- q = Query.new
+ q = IssueQuery.new
q.column_names = ['subject', 'description', 'tracker']
assert_equal [:subject, :tracker], q.inline_columns.map(&:name)
@@ -759,21 +759,21 @@ class QueryTest < ActiveSupport::TestCase
end
def test_custom_field_columns_should_be_inline
- q = Query.new
+ q = IssueQuery.new
columns = q.available_columns.select {|column| column.is_a? QueryCustomFieldColumn}
assert columns.any?
assert_nil columns.detect {|column| !column.inline?}
end
def test_query_should_preload_spent_hours
- q = Query.new(:name => '_', :column_names => [:subject, :spent_hours])
+ q = IssueQuery.new(:name => '_', :column_names => [:subject, :spent_hours])
assert q.has_column?(:spent_hours)
issues = q.issues
assert_not_nil issues.first.instance_variable_get("@spent_hours")
end
def test_groupable_columns_should_include_custom_fields
- q = Query.new
+ q = IssueQuery.new
column = q.groupable_columns.detect {|c| c.name == :cf_1}
assert_not_nil column
assert_kind_of QueryCustomFieldColumn, column
@@ -783,7 +783,7 @@ class QueryTest < ActiveSupport::TestCase
field = CustomField.find(1)
field.update_attribute :multiple, true
- q = Query.new
+ q = IssueQuery.new
column = q.groupable_columns.detect {|c| c.name == :cf_1}
assert_nil column
end
@@ -791,19 +791,19 @@ class QueryTest < ActiveSupport::TestCase
def test_groupable_columns_should_include_user_custom_fields
cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1], :field_format => 'user')
- q = Query.new
+ q = IssueQuery.new
assert q.groupable_columns.detect {|c| c.name == "cf_#{cf.id}".to_sym}
end
def test_groupable_columns_should_include_version_custom_fields
cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1], :field_format => 'version')
- q = Query.new
+ q = IssueQuery.new
assert q.groupable_columns.detect {|c| c.name == "cf_#{cf.id}".to_sym}
end
def test_grouped_with_valid_column
- q = Query.new(:group_by => 'status')
+ q = IssueQuery.new(:group_by => 'status')
assert q.grouped?
assert_not_nil q.group_by_column
assert_equal :status, q.group_by_column.name
@@ -812,7 +812,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_grouped_with_invalid_column
- q = Query.new(:group_by => 'foo')
+ q = IssueQuery.new(:group_by => 'foo')
assert !q.grouped?
assert_nil q.group_by_column
assert_nil q.group_by_statement
@@ -820,7 +820,7 @@ class QueryTest < ActiveSupport::TestCase
def test_sortable_columns_should_sort_assignees_according_to_user_format_setting
with_settings :user_format => 'lastname_coma_firstname' do
- q = Query.new
+ q = IssueQuery.new
assert q.sortable_columns.has_key?('assigned_to')
assert_equal %w(users.lastname users.firstname users.id), q.sortable_columns['assigned_to']
end
@@ -828,14 +828,14 @@ class QueryTest < ActiveSupport::TestCase
def test_sortable_columns_should_sort_authors_according_to_user_format_setting
with_settings :user_format => 'lastname_coma_firstname' do
- q = Query.new
+ q = IssueQuery.new
assert q.sortable_columns.has_key?('author')
assert_equal %w(authors.lastname authors.firstname authors.id), q.sortable_columns['author']
end
end
def test_sortable_columns_should_include_custom_field
- q = Query.new
+ q = IssueQuery.new
assert q.sortable_columns['cf_1']
end
@@ -843,29 +843,29 @@ class QueryTest < ActiveSupport::TestCase
field = CustomField.find(1)
field.update_attribute :multiple, true
- q = Query.new
+ q = IssueQuery.new
assert !q.sortable_columns['cf_1']
end
def test_default_sort
- q = Query.new
+ q = IssueQuery.new
assert_equal [], q.sort_criteria
end
def test_set_sort_criteria_with_hash
- q = Query.new
+ q = IssueQuery.new
q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']}
assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria
end
def test_set_sort_criteria_with_array
- q = Query.new
+ q = IssueQuery.new
q.sort_criteria = [['priority', 'desc'], 'tracker']
assert_equal [['priority', 'desc'], ['tracker', 'asc']], q.sort_criteria
end
def test_create_query_with_sort
- q = Query.new(:name => 'Sorted')
+ q = IssueQuery.new(:name => 'Sorted')
q.sort_criteria = [['priority', 'desc'], 'tracker']
assert q.save
q.reload
@@ -873,7 +873,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_sort_by_string_custom_field_asc
- q = Query.new
+ q = IssueQuery.new
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
assert c
assert c.sortable
@@ -886,7 +886,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_sort_by_string_custom_field_desc
- q = Query.new
+ q = IssueQuery.new
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'string' }
assert c
assert c.sortable
@@ -899,7 +899,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_sort_by_float_custom_field_asc
- q = Query.new
+ q = IssueQuery.new
c = q.available_columns.find {|col| col.is_a?(QueryCustomFieldColumn) && col.custom_field.field_format == 'float' }
assert c
assert c.sortable
@@ -912,14 +912,14 @@ class QueryTest < ActiveSupport::TestCase
end
def test_invalid_query_should_raise_query_statement_invalid_error
- q = Query.new
+ q = IssueQuery.new
assert_raise Query::StatementInvalid do
q.issues(:conditions => "foo = 1")
end
end
def test_issue_count
- q = Query.new(:name => '_')
+ q = IssueQuery.new(:name => '_')
issue_count = q.issue_count
assert_equal q.issues.size, issue_count
end
@@ -935,7 +935,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_issue_count_by_association_group
- q = Query.new(:name => '_', :group_by => 'assigned_to')
+ q = IssueQuery.new(:name => '_', :group_by => 'assigned_to')
count_by_group = q.issue_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(NilClass User), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
@@ -944,7 +944,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_issue_count_by_list_custom_field_group
- q = Query.new(:name => '_', :group_by => 'cf_1')
+ q = IssueQuery.new(:name => '_', :group_by => 'cf_1')
count_by_group = q.issue_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(NilClass String), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
@@ -953,7 +953,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_issue_count_by_date_custom_field_group
- q = Query.new(:name => '_', :group_by => 'cf_8')
+ q = IssueQuery.new(:name => '_', :group_by => 'cf_8')
count_by_group = q.issue_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(Date NilClass), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
@@ -963,7 +963,7 @@ class QueryTest < ActiveSupport::TestCase
def test_issue_count_with_nil_group_only
Issue.update_all("assigned_to_id = NULL")
- q = Query.new(:name => '_', :group_by => 'assigned_to')
+ q = IssueQuery.new(:name => '_', :group_by => 'assigned_to')
count_by_group = q.issue_count_by_group
assert_kind_of Hash, count_by_group
assert_equal 1, count_by_group.keys.size
@@ -971,7 +971,7 @@ class QueryTest < ActiveSupport::TestCase
end
def test_issue_ids
- q = Query.new(:name => '_')
+ q = IssueQuery.new(:name => '_')
order = "issues.subject, issues.id"
issues = q.issues(:order => order)
assert_equal issues.map(&:id), q.issue_ids(:order => order)
@@ -979,13 +979,13 @@ class QueryTest < ActiveSupport::TestCase
def test_label_for
set_language_if_valid 'en'
- q = Query.new
+ q = IssueQuery.new
assert_equal 'Assignee', q.label_for('assigned_to_id')
end
def test_label_for_fr
set_language_if_valid 'fr'
- q = Query.new
+ q = IssueQuery.new
s = "Assign\xc3\xa9 \xc3\xa0"
s.force_encoding('UTF-8') if s.respond_to?(:force_encoding)
assert_equal s, q.label_for('assigned_to_id')
@@ -997,32 +997,32 @@ class QueryTest < ActiveSupport::TestCase
developer = User.find(3)
# Public query on project 1
- q = Query.find(1)
+ q = IssueQuery.find(1)
assert q.editable_by?(admin)
assert q.editable_by?(manager)
assert !q.editable_by?(developer)
# Private query on project 1
- q = Query.find(2)
+ q = IssueQuery.find(2)
assert q.editable_by?(admin)
assert !q.editable_by?(manager)
assert q.editable_by?(developer)
# Private query for all projects
- q = Query.find(3)
+ q = IssueQuery.find(3)
assert q.editable_by?(admin)
assert !q.editable_by?(manager)
assert q.editable_by?(developer)
# Public query for all projects
- q = Query.find(4)
+ q = IssueQuery.find(4)
assert q.editable_by?(admin)
assert !q.editable_by?(manager)
assert !q.editable_by?(developer)
end
def test_visible_scope
- query_ids = Query.visible(User.anonymous).map(&:id)
+ query_ids = IssueQuery.visible(User.anonymous).map(&:id)
assert query_ids.include?(1), 'public query on public project was not visible'
assert query_ids.include?(4), 'public query for all projects was not visible'
@@ -1033,7 +1033,7 @@ class QueryTest < ActiveSupport::TestCase
context "#available_filters" do
setup do
- @query = Query.new(:name => "_")
+ @query = IssueQuery.new(:name => "_")
end
should "include users of visible projects in cross-project view" do
@@ -1127,7 +1127,7 @@ class QueryTest < ActiveSupport::TestCase
end
should "search assigned to for users in the group" do
- @query = Query.new(:name => '_')
+ @query = IssueQuery.new(:name => '_')
@query.add_filter('member_of_group', '=', [@group.id.to_s])
assert_query_statement_includes @query, "#{Issue.table_name}.assigned_to_id IN ('#{@user_in_group.id}','#{@second_user_in_group.id}')"
@@ -1135,7 +1135,7 @@ class QueryTest < ActiveSupport::TestCase
end
should "search not assigned to any group member (none)" do
- @query = Query.new(:name => '_')
+ @query = IssueQuery.new(:name => '_')
@query.add_filter('member_of_group', '!*', [''])
# Users not in a group
@@ -1144,7 +1144,7 @@ class QueryTest < ActiveSupport::TestCase
end
should "search assigned to any group member (all)" do
- @query = Query.new(:name => '_')
+ @query = IssueQuery.new(:name => '_')
@query.add_filter('member_of_group', '*', [''])
# Only users in a group
@@ -1154,7 +1154,7 @@ class QueryTest < ActiveSupport::TestCase
should "return an empty set with = empty group" do
@empty_group = Group.generate!
- @query = Query.new(:name => '_')
+ @query = IssueQuery.new(:name => '_')
@query.add_filter('member_of_group', '=', [@empty_group.id.to_s])
assert_equal [], find_issues_with_query(@query)
@@ -1162,7 +1162,7 @@ class QueryTest < ActiveSupport::TestCase
should "return issues with ! empty group" do
@empty_group = Group.generate!
- @query = Query.new(:name => '_')
+ @query = IssueQuery.new(:name => '_')
@query.add_filter('member_of_group', '!', [@empty_group.id.to_s])
assert_find_issues_with_query_is_successful @query
@@ -1191,7 +1191,7 @@ class QueryTest < ActiveSupport::TestCase
end
should "search assigned to for users with the Role" do
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '=', [@manager_role.id.to_s])
assert_query_result [@issue1, @issue3], @query
@@ -1201,7 +1201,7 @@ class QueryTest < ActiveSupport::TestCase
other_project = Project.generate!
User.add_to_project(@developer, other_project, @manager_role)
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '=', [@manager_role.id.to_s])
assert_query_result [@issue1, @issue3], @query
@@ -1209,28 +1209,28 @@ class QueryTest < ActiveSupport::TestCase
should "return an empty set with empty role" do
@empty_role = Role.generate!
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '=', [@empty_role.id.to_s])
assert_query_result [], @query
end
should "search assigned to for users without the Role" do
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '!', [@manager_role.id.to_s])
assert_query_result [@issue2, @issue4, @issue5], @query
end
should "search assigned to for users not assigned to any Role (none)" do
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '!*', [''])
assert_query_result [@issue4, @issue5], @query
end
should "search assigned to for users assigned to any Role (all)" do
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '*', [''])
assert_query_result [@issue1, @issue2, @issue3], @query
@@ -1238,12 +1238,11 @@ class QueryTest < ActiveSupport::TestCase
should "return issues with ! empty role" do
@empty_role = Role.generate!
- @query = Query.new(:name => '_', :project => @project)
+ @query = IssueQuery.new(:name => '_', :project => @project)
@query.add_filter('assigned_to_role', '!', [@empty_role.id.to_s])
assert_query_result [@issue1, @issue2, @issue3, @issue4, @issue5], @query
end
end
end
-
end