Commit 1eba14ae authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor create member tests from group_members_controller_spec

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c8227889
......@@ -13,27 +13,18 @@ describe Groups::GroupMembersController do
end
end
describe '#create' do
let(:group) { create(:group, :public) }
context 'when users are added' do
let(:user) { create(:user) }
describe 'POST create' do
let(:group_user) { create(:user) }
let(:member) do
group.add_developer(group_user)
group.members.find_by(user_id: group_user)
end
before { sign_in(user) }
context 'when user does not have enough rights' do
before do
group.members.delete(member)
group.add_developer(user)
sign_in(user)
end
before { group.add_developer(user) }
it 'returns 403' do
post :create, group_id: group,
user_ids: member
user_ids: group_user.id,
access_level: Gitlab::Access::GUEST
expect(response).to have_http_status(403)
expect(group.users).not_to include group_user
......@@ -41,14 +32,12 @@ describe Groups::GroupMembersController do
end
context 'when user has enough rights' do
before do
group.add_owner(user)
sign_in(user)
end
before { group.add_owner(user) }
it 'adds user to members' do
post :create, group_id: group,
user_ids: member
user_ids: group_user.id,
access_level: Gitlab::Access::GUEST
expect(response).to set_flash.to 'Users were successfully added.'
expect(response).to redirect_to(group_group_members_path(group))
......@@ -57,7 +46,8 @@ describe Groups::GroupMembersController do
it 'adds no user to members' do
post :create, group_id: group,
user_ids: ''
user_ids: '',
access_level: Gitlab::Access::GUEST
expect(response).to set_flash.to 'No users specified.'
expect(response).to redirect_to(group_group_members_path(group))
......@@ -65,7 +55,6 @@ describe Groups::GroupMembersController do
end
end
end
end
describe 'DELETE destroy' do
let(:member) { create(:group_member, :developer, group: group) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment