summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-11 17:45:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-11 17:45:10 +0000
commit888c3581eb0fbfc5ede87a24f7f03bfa4f7d810b (patch)
tree17bb48e3b640635b2fa62b85e2b10ccaf5b4f65c /test/functional
parent4545b906b4c58e2bd1d201fd18a49249aa571dfc (diff)
downloadredmine-888c3581eb0fbfc5ede87a24f7f03bfa4f7d810b.tar.gz
redmine-888c3581eb0fbfc5ede87a24f7f03bfa4f7d810b.zip
Role based custom queries (#1019).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11994 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/calendars_controller_test.rb2
-rw-r--r--test/functional/issues_controller_test.rb12
-rw-r--r--test/functional/queries_controller_test.rb34
3 files changed, 19 insertions, 29 deletions
diff --git a/test/functional/calendars_controller_test.rb b/test/functional/calendars_controller_test.rb
index dc302f456..5848e7601 100644
--- a/test/functional/calendars_controller_test.rb
+++ b/test/functional/calendars_controller_test.rb
@@ -34,7 +34,7 @@ class CalendarsControllerTest < ActionController::TestCase
end
def test_show_should_run_custom_queries
- @query = IssueQuery.create!(:name => 'Calendar', :is_public => true)
+ @query = IssueQuery.create!(:name => 'Calendar', :visibility => IssueQuery::VISIBILITY_PUBLIC)
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 707b57438..ec10af116 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 = IssueQuery.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "test", :user_id => 2, :visibility => IssueQuery::VISIBILITY_PRIVATE, :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 = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PRIVATE, :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 = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PRIVATE, :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 = IssueQuery.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil)
+ q = IssueQuery.create!(:name => "private", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PUBLIC, :project => nil)
@request.session[:user_id] = 3
get :index, :query_id => q.id
@@ -1151,7 +1151,7 @@ class IssuesControllerTest < ActionController::TestCase
end
def test_show_should_display_prev_next_links_with_saved_query_in_session
- query = IssueQuery.create!(:name => 'test', :is_public => true, :user_id => 1,
+ query = IssueQuery.create!(:name => 'test', :visibility => IssueQuery::VISIBILITY_PUBLIC, :user_id => 1,
:filters => {'status_id' => {:values => ['5'], :operator => '='}},
:sort_criteria => [['id', 'asc']])
@request.session[:query] = {:id => query.id, :project_id => nil}
@@ -1243,7 +1243,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 = IssueQuery.create!(:name => 'test', :is_public => true, :user_id => 1, :filters => {},
+ query = IssueQuery.create!(:name => 'test', :visibility => IssueQuery::VISIBILITY_PUBLIC, :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/queries_controller_test.rb b/test/functional/queries_controller_test.rb
index a232fec2e..b2bbb22fd 100644
--- a/test/functional/queries_controller_test.rb
+++ b/test/functional/queries_controller_test.rb
@@ -35,9 +35,7 @@ class QueriesControllerTest < ActionController::TestCase
get :new, :project_id => 1
assert_response :success
assert_template 'new'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]',
- :checked => nil }
+ assert_select 'input[name=?][value=0][checked=checked]', 'query[visibility]'
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
@@ -53,8 +51,7 @@ class QueriesControllerTest < ActionController::TestCase
get :new
assert_response :success
assert_template 'new'
- assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]' }
+ assert_select 'input[name=?]', 'query[visibility]', 0
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
@@ -75,7 +72,7 @@ class QueriesControllerTest < ActionController::TestCase
:f => ["status_id", "assigned_to_id"],
:op => {"assigned_to_id" => "=", "status_id" => "o"},
:v => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
- :query => {"name" => "test_new_project_public_query", "is_public" => "1"}
+ :query => {"name" => "test_new_project_public_query", "visibility" => "2"}
q = Query.find_by_name('test_new_project_public_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
@@ -92,7 +89,7 @@ class QueriesControllerTest < ActionController::TestCase
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
- :query => {"name" => "test_new_project_private_query", "is_public" => "1"}
+ :query => {"name" => "test_new_project_private_query", "visibility" => "2"}
q = Query.find_by_name('test_new_project_private_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
@@ -107,7 +104,7 @@ class QueriesControllerTest < ActionController::TestCase
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
- :query => {"name" => "test_new_global_private_query", "is_public" => "1"},
+ :query => {"name" => "test_new_global_private_query", "visibility" => "2"},
:c => ["", "tracker", "subject", "priority", "category"]
q = Query.find_by_name('test_new_global_private_query')
@@ -140,7 +137,7 @@ class QueriesControllerTest < ActionController::TestCase
:operators => {"status_id" => "o"},
:values => {"status_id" => ["1"]},
:query => {:name => "test_new_with_sort",
- :is_public => "1",
+ :visibility => "2",
:sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}}
query = Query.find_by_name("test_new_with_sort")
@@ -163,9 +160,7 @@ class QueriesControllerTest < ActionController::TestCase
get :edit, :id => 4
assert_response :success
assert_template 'edit'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]',
- :checked => 'checked' }
+ assert_select 'input[name=?][value=2][checked=checked]', 'query[visibility]'
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
@@ -177,8 +172,7 @@ class QueriesControllerTest < ActionController::TestCase
get :edit, :id => 3
assert_response :success
assert_template 'edit'
- assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]' }
+ assert_select 'input[name=?]', 'query[visibility]', 0
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => 'checked',
@@ -190,8 +184,7 @@ class QueriesControllerTest < ActionController::TestCase
get :edit, :id => 2
assert_response :success
assert_template 'edit'
- assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]' }
+ assert_select 'input[name=?]', 'query[visibility]', 0
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
@@ -203,10 +196,7 @@ class QueriesControllerTest < ActionController::TestCase
get :edit, :id => 1
assert_response :success
assert_template 'edit'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query[is_public]',
- :checked => 'checked'
- }
+ assert_select 'input[name=?][value=2][checked=checked]', 'query[visibility]'
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
:name => 'query_is_for_all',
:checked => nil,
@@ -240,7 +230,7 @@ class QueriesControllerTest < ActionController::TestCase
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
- :query => {"name" => "test_edit_global_private_query", "is_public" => "1"}
+ :query => {"name" => "test_edit_global_private_query", "visibility" => "2"}
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
q = Query.find_by_name('test_edit_global_private_query')
@@ -257,7 +247,7 @@ class QueriesControllerTest < ActionController::TestCase
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
- :query => {"name" => "test_edit_global_public_query", "is_public" => "1"}
+ :query => {"name" => "test_edit_global_public_query", "visibility" => "2"}
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
q = Query.find_by_name('test_edit_global_public_query')