Commit bfe7d57d authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'issue_6536' into 'master'

Extract EE specific files/lines for spec/controllers/groups

Closes #6536

See merge request gitlab-org/gitlab-ee!10524
parents f16112e3 649d23b9
...@@ -31,6 +31,14 @@ describe Groups::GroupMembersController do ...@@ -31,6 +31,14 @@ describe Groups::GroupMembersController do
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(302)
end end
it 'creates an audit event' do
expect do
post :create, params: { group_id: group,
user_ids: user.id,
access_level: Gitlab::Access::GUEST }
end.to change(AuditEvent, :count).by(1)
end
end end
describe 'PUT #update' do describe 'PUT #update' do
...@@ -82,6 +90,32 @@ describe Groups::GroupMembersController do ...@@ -82,6 +90,32 @@ describe Groups::GroupMembersController do
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(302)
end end
context 'when member is not an owner' do
it 'creates an audit event' do
developer = create(:user)
group.add_developer(developer)
sign_in(developer)
expect { delete :leave, params: { group_id: group } }.to change(AuditEvent, :count).by(1)
end
end
context 'when member is an owner' do
it 'does not create an audit event' do
expect { delete :leave, params: { group_id: group } }.not_to change(AuditEvent, :count)
end
end
context 'when member requested access' do
it 'creates an audit event' do
requester = create(:user)
group.request_access(requester)
sign_in(requester)
expect { delete :leave, params: { group_id: group } }.to change(AuditEvent, :count).by(1)
end
end
end end
describe 'POST #resend_invite' do describe 'POST #resend_invite' do
......
...@@ -55,7 +55,7 @@ describe Groups::BoardsController do ...@@ -55,7 +55,7 @@ describe Groups::BoardsController do
context 'when format is JSON' do context 'when format is JSON' do
it 'return an array with one group board' do it 'return an array with one group board' do
create(:board, group: group, milestone: create(:milestone, group: group)) create(:board, group: group)
expect(Boards::Visits::LatestService).not_to receive(:new) expect(Boards::Visits::LatestService).not_to receive(:new)
......
...@@ -54,14 +54,6 @@ describe Groups::GroupMembersController do ...@@ -54,14 +54,6 @@ describe Groups::GroupMembersController do
expect(group.users).to include group_user expect(group.users).to include group_user
end end
it 'creates an audit event' do
expect do
post :create, params: { group_id: group,
user_ids: group_user.id,
access_level: Gitlab::Access::GUEST }
end.to change(AuditEvent, :count).by(1)
end
it 'adds no user to members' do it 'adds no user to members' do
post :create, params: { post :create, params: {
group_id: group, group_id: group,
...@@ -182,10 +174,6 @@ describe Groups::GroupMembersController do ...@@ -182,10 +174,6 @@ describe Groups::GroupMembersController do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['notice']).to eq "You left the \"#{group.name}\" group." expect(json_response['notice']).to eq "You left the \"#{group.name}\" group."
end end
it 'creates an audit event' do
expect { delete :leave, params: { group_id: group } }.to change(AuditEvent, :count).by(1)
end
end end
context 'and is an owner' do context 'and is an owner' do
...@@ -198,10 +186,6 @@ describe Groups::GroupMembersController do ...@@ -198,10 +186,6 @@ describe Groups::GroupMembersController do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(403)
end end
it 'does not create an audit event' do
expect { delete :leave, params: { group_id: group } }.not_to change(AuditEvent, :count)
end
end end
context 'and is a requester' do context 'and is a requester' do
...@@ -217,10 +201,6 @@ describe Groups::GroupMembersController do ...@@ -217,10 +201,6 @@ describe Groups::GroupMembersController do
expect(group.requesters).to be_empty expect(group.requesters).to be_empty
expect(group.users).not_to include user expect(group.users).not_to include user
end end
it 'creates an audit event' do
expect { delete :leave, params: { group_id: group } }.to change(AuditEvent, :count).by(1)
end
end end
end end
end end
......
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