summaryrefslogtreecommitdiffstats
path: root/test/functional/groups_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-05-31 17:32:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-05-31 17:32:34 +0000
commitb834e81d7f41121fc6d9bef95ee090f8f466493e (patch)
tree61fddb6214c64e96fddd504301029bdb382ba439 /test/functional/groups_controller_test.rb
parent1d4300b674f739d671a8be22d3ea617922f16517 (diff)
downloadredmine-b834e81d7f41121fc6d9bef95ee090f8f466493e.tar.gz
redmine-b834e81d7f41121fc6d9bef95ee090f8f466493e.zip
Use Rails 5 syntax for functional tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@16585 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/groups_controller_test.rb')
-rw-r--r--test/functional/groups_controller_test.rb91
1 files changed, 74 insertions, 17 deletions
diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb
index 19f95d357..68d624331 100644
--- a/test/functional/groups_controller_test.rb
+++ b/test/functional/groups_controller_test.rb
@@ -39,19 +39,25 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_index_with_name_filter
Group.generate!(:name => "Clients")
- get :index, :name => "cli"
+ get :index, :params => {
+ :name => "cli"
+ }
assert_response :success
assert_select 'table.groups tbody tr', 1
assert_select 'table.groups tbody td.name', :text => 'Clients'
end
def test_show
- get :show, :id => 10
+ get :show, :params => {
+ :id => 10
+ }
assert_response :success
end
def test_show_invalid_should_return_404
- get :show, :id => 99
+ get :show, :params => {
+ :id => 99
+ }
assert_response 404
end
@@ -63,7 +69,11 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_create
assert_difference 'Group.count' do
- post :create, :group => {:name => 'New group'}
+ post :create, :params => {
+ :group => {
+ :name => 'New group'
+ }
+ }
end
assert_redirected_to '/groups'
group = Group.order('id DESC').first
@@ -73,7 +83,12 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_create_and_continue
assert_difference 'Group.count' do
- post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
+ post :create, :params => {
+ :group => {
+ :name => 'New group'
+ },
+ :continue => 'Create and continue'
+ }
end
assert_redirected_to '/groups/new'
group = Group.order('id DESC').first
@@ -82,14 +97,20 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_create_with_failure
assert_no_difference 'Group.count' do
- post :create, :group => {:name => ''}
+ post :create, :params => {
+ :group => {
+ :name => ''
+ }
+ }
end
assert_response :success
assert_select_error /Name cannot be blank/i
end
def test_edit
- get :edit, :id => 10
+ get :edit, :params => {
+ :id => 10
+ }
assert_response :success
assert_select 'div#tab-content-users'
@@ -100,46 +121,70 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_update
new_name = 'New name'
- put :update, :id => 10, :group => {:name => new_name}
+ put :update, :params => {
+ :id => 10,
+ :group => {
+ :name => new_name
+ }
+ }
assert_redirected_to '/groups'
group = Group.find(10)
assert_equal new_name, group.name
end
def test_update_with_failure
- put :update, :id => 10, :group => {:name => ''}
+ put :update, :params => {
+ :id => 10,
+ :group => {
+ :name => ''
+ }
+ }
assert_response :success
assert_select_error /Name cannot be blank/i
end
def test_destroy
assert_difference 'Group.count', -1 do
- post :destroy, :id => 10
+ post :destroy, :params => {
+ :id => 10
+ }
end
assert_redirected_to '/groups'
end
def test_new_users
- get :new_users, :id => 10
+ get :new_users, :params => {
+ :id => 10
+ }
assert_response :success
assert_select 'input[name=?]', 'user_search'
end
def test_xhr_new_users
- xhr :get, :new_users, :id => 10
+ get :new_users, :params => {
+ :id => 10
+ },
+ :xhr => true
assert_response :success
assert_equal 'text/javascript', response.content_type
end
def test_add_users
assert_difference 'Group.find(10).users.count', 2 do
- post :add_users, :id => 10, :user_ids => ['2', '3']
+ post :add_users, :params => {
+ :id => 10,
+ :user_ids => ['2', '3']
+ }
end
end
def test_xhr_add_users
assert_difference 'Group.find(10).users.count', 2 do
- xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
+ post :add_users, :params => {
+ :id => 10,
+ :user_ids => ['2', '3']
+ },
+ :xhr => true
assert_response :success
assert_equal 'text/javascript', response.content_type
end
@@ -148,20 +193,32 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_remove_user
assert_difference 'Group.find(10).users.count', -1 do
- delete :remove_user, :id => 10, :user_id => '8'
+ delete :remove_user, :params => {
+ :id => 10,
+ :user_id => '8'
+ }
end
end
def test_xhr_remove_user
assert_difference 'Group.find(10).users.count', -1 do
- xhr :delete, :remove_user, :id => 10, :user_id => '8'
+ delete :remove_user, :params => {
+ :id => 10,
+ :user_id => '8'
+ },
+ :xhr => true
assert_response :success
assert_equal 'text/javascript', response.content_type
end
end
def test_autocomplete_for_user
- xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
+ get :autocomplete_for_user, :params => {
+ :id => 10,
+ :q => 'smi',
+ :format => 'js'
+ },
+ :xhr => true
assert_response :success
assert_include 'John Smith', response.body
end