diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-20 18:02:52 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-20 18:02:52 +0000 |
commit | c63da2c0a5b5481e9eb0d5a8218d92fec5e9dda7 (patch) | |
tree | 4b0d8251b1a23ec9375c73ca8b133225f78a83cb /test/integration | |
parent | e3e0f5440d0c92d42694f0567b53b4259a6d0473 (diff) | |
download | redmine-c63da2c0a5b5481e9eb0d5a8218d92fec5e9dda7.tar.gz redmine-c63da2c0a5b5481e9eb0d5a8218d92fec5e9dda7.zip |
Use generated groups.
git-svn-id: http://svn.redmine.org/redmine/trunk@14710 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/api_test/groups_test.rb | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/test/integration/api_test/groups_test.rb b/test/integration/api_test/groups_test.rb index b27a9f96c..107ece543 100644 --- a/test/integration/api_test/groups_test.rb +++ b/test/integration/api_test/groups_test.rb @@ -149,17 +149,18 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base end test "PUT /groups/:id.xml with valid parameters should update the group" do - put '/groups/10.xml', {:group => {:name => 'New name', :user_ids => [2, 3]}}, credentials('admin') + group = Group.generate! + put "/groups/#{group.id}.xml", {:group => {:name => 'New name', :user_ids => [2, 3]}}, credentials('admin') assert_response :ok assert_equal '', @response.body - group = Group.find(10) - assert_equal 'New name', group.name + assert_equal 'New name', group.reload.name assert_equal [2, 3], group.users.map(&:id).sort end test "PUT /groups/:id.xml with invalid parameters should return errors" do - put '/groups/10.xml', {:group => {:name => ''}}, credentials('admin') + group = Group.generate! + put "/groups/#{group.id}.xml", {:group => {:name => ''}}, credentials('admin') assert_response :unprocessable_entity assert_equal 'application/xml', response.content_type @@ -169,27 +170,30 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base end test "DELETE /groups/:id.xml should delete the group" do + group = Group.generate! assert_difference 'Group.count', -1 do - delete '/groups/10.xml', {}, credentials('admin') + delete "/groups/#{group.id}.xml", {}, credentials('admin') assert_response :ok assert_equal '', @response.body end end test "POST /groups/:id/users.xml should add user to the group" do - assert_difference 'Group.find(10).users.count' do - post '/groups/10/users.xml', {:user_id => 5}, credentials('admin') + group = Group.generate! + assert_difference 'group.reload.users.count' do + post "/groups/#{group.id}/users.xml", {:user_id => 5}, credentials('admin') assert_response :ok assert_equal '', @response.body end - assert_include User.find(5), Group.find(10).users + assert_include User.find(5), group.reload.users end test "POST /groups/:id/users.xml should not add the user if already added" do - Group.find(10).users << User.find(5) + group = Group.generate! + group.users << User.find(5) - assert_no_difference 'Group.find(10).users.count' do - post '/groups/10/users.xml', {:user_id => 5}, credentials('admin') + assert_no_difference 'group.reload.users.count' do + post "/groups/#{group.id}/users.xml", {:user_id => 5}, credentials('admin') assert_response :unprocessable_entity end @@ -199,11 +203,14 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base end test "DELETE /groups/:id/users/:user_id.xml should remove user from the group" do - assert_difference 'Group.find(10).users.count', -1 do - delete '/groups/10/users/8.xml', {}, credentials('admin') + group = Group.generate! + group.users << User.find(8) + + assert_difference 'group.reload.users.count', -1 do + delete "/groups/#{group.id}/users/8.xml", {}, credentials('admin') assert_response :ok assert_equal '', @response.body end - assert_not_include User.find(8), Group.find(10).users + assert_not_include User.find(8), group.reload.users end end |