diff options
author | Rémy Coutable <remy@rymai.me> | 2017-02-07 19:22:35 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-02-15 11:40:24 +0300 |
commit | 0aa7e3b27ed93da4566eeb50b5af97ddbccaf8a6 (patch) | |
tree | b7b2a13b9c5bf90c124fcc4f6cc0f1b468225ad1 /spec | |
parent | 60f299b5969cbb7d5f574f7257c6feaabbf0610b (diff) |
Merge branch 'refresh-permissions-when-moving-projects' into 'master'
Refresh authorizations when transferring projects
See merge request !9029
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/group_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 7 | ||||
-rw-r--r-- | spec/services/projects/transfer_service_spec.rb | 26 |
3 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 7402e9f8c7b..e69e271de16 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -294,4 +294,17 @@ describe Group, models: true do expect(group.members_with_parents).to include(master) end end + + describe '#user_ids_for_project_authorizations' do + it 'returns the user IDs for which to refresh authorizations' do + master = create(:user) + developer = create(:user) + + group.add_user(master, GroupMember::MASTER) + group.add_user(developer, GroupMember::DEVELOPER) + + expect(group.user_ids_for_project_authorizations). + to include(master.id, developer.id) + end + end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index f8e03fa114a..d5e580dd288 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -202,4 +202,11 @@ describe Namespace, models: true do expect(group.parents).to eq([]) end end + + describe '#user_ids_for_project_authorizations' do + it 'returns the user IDs for which to refresh authorizations' do + expect(namespace.user_ids_for_project_authorizations). + to eq([namespace.owner_id]) + end + end end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 1540b90163a..16b5d4aa080 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -81,4 +81,30 @@ describe Projects::TransferService, services: true do transfer_project(project, user, group) end end + + describe 'refreshing project authorizations' do + let(:group) { create(:group) } + let(:owner) { project.namespace.owner } + let(:group_member) { create(:user) } + + before do + group.add_user(owner, GroupMember::MASTER) + group.add_user(group_member, GroupMember::DEVELOPER) + end + + it 'refreshes the permissions of the old and new namespace' do + transfer_project(project, owner, group) + + expect(group_member.authorized_projects).to include(project) + expect(owner.authorized_projects).to include(project) + end + + it 'only schedules a single job for every user' do + expect(UserProjectAccessChangedService).to receive(:new). + with([owner.id, group_member.id]). + and_call_original + + transfer_project(project, owner, group) + end + end end |