diff options
Diffstat (limited to 'spec/models/project_authorization_spec.rb')
-rw-r--r-- | spec/models/project_authorization_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb index 9fed05342aa..a5f29fcbe8b 100644 --- a/spec/models/project_authorization_spec.rb +++ b/spec/models/project_authorization_spec.rb @@ -83,8 +83,10 @@ RSpec.describe ProjectAuthorization, feature_category: :groups_and_projects do end describe 'scopes' do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, namespace: user.namespace) } + describe '.non_guests' do - let_it_be(:project) { create(:project) } let_it_be(:project_original_owner_authorization) { project.owner.project_authorizations.first } let_it_be(:project_authorization_guest) { create(:project_authorization, :guest, project: project) } let_it_be(:project_authorization_reporter) { create(:project_authorization, :reporter, project: project) } @@ -100,6 +102,28 @@ RSpec.describe ProjectAuthorization, feature_category: :groups_and_projects do ].map(&:attributes)) end end + + describe '.for_project' do + let_it_be(:project_2) { create(:project, namespace: user.namespace) } + let_it_be(:project_3) { create(:project, namespace: user.namespace) } + + let_it_be(:project_authorization_3) { project_3.project_authorizations.first } + let_it_be(:project_authorization_2) { project_2.project_authorizations.first } + let_it_be(:project_authorization) { project.project_authorizations.first } + + it 'returns all records for the project' do + expect(described_class.for_project(project).map(&:attributes)).to match_array([ + project_authorization + ].map(&:attributes)) + end + + it 'returns all records for multiple projects' do + expect(described_class.for_project([project, project_3]).map(&:attributes)).to match_array([ + project_authorization, + project_authorization_3 + ].map(&:attributes)) + end + end end describe '.insert_all' do |