summaryrefslogtreecommitdiffstats
path: root/test/functional/queries_controller_test.rb
diff options
context:
space:
mode:
authorEtienne Massip <etienne.massip@gmail.com>2011-10-24 20:19:26 +0000
committerEtienne Massip <etienne.massip@gmail.com>2011-10-24 20:19:26 +0000
commit8f96f0c40d8032e4787f2548e0f0fd7da7e36a07 (patch)
treecb7a9ac1efdede90bd38638e4119d57e309ee7a2 /test/functional/queries_controller_test.rb
parent657fcd97aa1a6fc289dcb998dd994c9499112737 (diff)
downloadredmine-8f96f0c40d8032e4787f2548e0f0fd7da7e36a07.tar.gz
redmine-8f96f0c40d8032e4787f2548e0f0fd7da7e36a07.zip
Refactor : convert queries to REST resources (also fixes #9108).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7649 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/queries_controller_test.rb')
-rw-r--r--test/functional/queries_controller_test.rb35
1 files changed, 22 insertions, 13 deletions
diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb
index b40ea6e7c..dfa5d6153 100644
--- a/test/functional/queries_controller_test.rb
+++ b/test/functional/queries_controller_test.rb
@@ -60,9 +60,8 @@ class QueriesControllerTest < ActionController::TestCase
def test_new_project_public_query
@request.session[:user_id] = 2
- post :new,
+ post :create,
:project_id => 'ecookbook',
- :confirm => '1',
:default_columns => '1',
:f => ["status_id", "assigned_to_id"],
:op => {"assigned_to_id" => "=", "status_id" => "o"},
@@ -78,9 +77,8 @@ class QueriesControllerTest < ActionController::TestCase
def test_new_project_private_query
@request.session[:user_id] = 3
- post :new,
+ post :create,
:project_id => 'ecookbook',
- :confirm => '1',
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
@@ -96,8 +94,7 @@ class QueriesControllerTest < ActionController::TestCase
def test_new_global_private_query_with_custom_columns
@request.session[:user_id] = 3
- post :new,
- :confirm => '1',
+ post :create,
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
@@ -112,10 +109,24 @@ class QueriesControllerTest < ActionController::TestCase
assert q.valid?
end
+ def test_new_global_query_with_custom_filters
+ @request.session[:user_id] = 3
+ post :create,
+ :fields => ["assigned_to_id"],
+ :operators => {"assigned_to_id" => "="},
+ :values => { "assigned_to_id" => ["me"]},
+ :query => {"name" => "test_new_global_query"}
+
+ q = Query.find_by_name('test_new_global_query')
+ assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
+ assert !q.has_filter?(:status_id)
+ assert_equal ['assigned_to_id'], q.filters.keys
+ assert q.valid?
+ end
+
def test_new_with_sort
@request.session[:user_id] = 1
- post :new,
- :confirm => '1',
+ post :create,
:default_columns => '1',
:operators => {"status_id" => "o"},
:values => {"status_id" => ["1"]},
@@ -144,9 +155,8 @@ class QueriesControllerTest < ActionController::TestCase
def test_edit_global_public_query
@request.session[:user_id] = 1
- post :edit,
+ put :update,
:id => 4,
- :confirm => '1',
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
@@ -175,9 +185,8 @@ class QueriesControllerTest < ActionController::TestCase
def test_edit_global_private_query
@request.session[:user_id] = 3
- post :edit,
+ put :update,
:id => 3,
- :confirm => '1',
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
@@ -234,7 +243,7 @@ class QueriesControllerTest < ActionController::TestCase
def test_destroy
@request.session[:user_id] = 2
- post :destroy, :id => 1
+ delete :destroy, :id => 1
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
assert_nil Query.find_by_id(1)
end