| ... | @@ -6,9 +6,13 @@ describe Groups::GroupLinksController do |
... | @@ -6,9 +6,13 @@ describe Groups::GroupLinksController do |
|
|
let(:shared_with_group) { create(:group, :private) }
|
|
let(:shared_with_group) { create(:group, :private) }
|
|
|
let(:shared_group) { create(:group, :private) }
|
|
let(:shared_group) { create(:group, :private) }
|
|
|
let(:user) { create(:user) }
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group_member) { create(:user) }
|
|
|
|
let!(:project) { create(:project, group: shared_group) }
|
|
|
|
|
|
|
|
before do
|
|
before do
|
|
|
sign_in(user)
|
|
sign_in(user)
|
|
|
|
|
|
|
|
shared_with_group.add_developer(group_member)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
describe '#create' do
|
|
describe '#create' do
|
| ... | @@ -22,13 +26,9 @@ describe Groups::GroupLinksController do |
... | @@ -22,13 +26,9 @@ describe Groups::GroupLinksController do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'when user has correct access to both groups' do
|
|
context 'when user has correct access to both groups' do
|
|
|
let(:group_member) { create(:user) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
before do
|
|
|
shared_with_group.add_developer(user)
|
|
shared_with_group.add_developer(user)
|
|
|
shared_group.add_owner(user)
|
|
shared_group.add_owner(user)
|
|
|
|
|
|
|
|
shared_with_group.add_developer(group_member)
|
|
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'links group with selected group' do
|
|
it 'links group with selected group' do
|
| ... | @@ -45,6 +45,10 @@ describe Groups::GroupLinksController do |
... | @@ -45,6 +45,10 @@ describe Groups::GroupLinksController do |
|
|
expect { subject }.to change { group_member.can?(:read_group, shared_group) }.from(false).to(true)
|
|
expect { subject }.to change { group_member.can?(:read_group, shared_group) }.from(false).to(true)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
it 'updates project permissions' do
|
|
|
|
expect { subject }.to change { group_member.can?(:read_project, project) }.from(false).to(true)
|
|
|
|
end
|
|
|
|
|
|
|
context 'when shared with group id is not present' do
|
|
context 'when shared with group id is not present' do
|
|
|
let(:shared_with_group_id) { nil }
|
|
let(:shared_with_group_id) { nil }
|
|
|
|
|
|
| ... | @@ -130,6 +134,7 @@ describe Groups::GroupLinksController do |
... | @@ -130,6 +134,7 @@ describe Groups::GroupLinksController do |
|
|
context 'when user has admin access to the shared group' do
|
|
context 'when user has admin access to the shared group' do
|
|
|
before do
|
|
before do
|
|
|
shared_group.add_owner(user)
|
|
shared_group.add_owner(user)
|
|
|
|
shared_with_group.refresh_members_authorized_projects
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'updates existing link' do
|
|
it 'updates existing link' do
|
| ... | @@ -143,6 +148,10 @@ describe Groups::GroupLinksController do |
... | @@ -143,6 +148,10 @@ describe Groups::GroupLinksController do |
|
|
expect(link.group_access).to eq(Gitlab::Access::GUEST)
|
|
expect(link.group_access).to eq(Gitlab::Access::GUEST)
|
|
|
expect(link.expires_at).to eq(expiry_date)
|
|
expect(link.expires_at).to eq(expiry_date)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'updates project permissions' do
|
|
|
|
expect { subject }.to change { group_member.can?(:create_release, project) }.from(true).to(false)
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'when user does not have admin access to the shared group' do
|
|
context 'when user does not have admin access to the shared group' do
|
| ... | @@ -180,11 +189,16 @@ describe Groups::GroupLinksController do |
... | @@ -180,11 +189,16 @@ describe Groups::GroupLinksController do |
|
|
context 'when user has admin access to the shared group' do
|
|
context 'when user has admin access to the shared group' do
|
|
|
before do
|
|
before do
|
|
|
shared_group.add_owner(user)
|
|
shared_group.add_owner(user)
|
|
|
|
shared_with_group.refresh_members_authorized_projects
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'deletes existing link' do
|
|
it 'deletes existing link' do
|
|
|
expect { subject }.to change(GroupGroupLink, :count).by(-1)
|
|
expect { subject }.to change(GroupGroupLink, :count).by(-1)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'updates project permissions' do
|
|
|
|
expect { subject }.to change { group_member.can?(:create_release, project) }.from(true).to(false)
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'when user does not have admin access to the shared group' do
|
|
context 'when user does not have admin access to the shared group' do
|
| ... | |
... | |
| ... | | ... | |