diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-27 10:32:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-27 10:32:43 +0000 |
commit | 547a5884d1ab6a22d9fc9ce79e5cf6f0310bc23d (patch) | |
tree | 655c2c0252d6ac08f0a825fac872f83845ee2e7f /spec/lib | |
parent | 25e94f0fc4c4666dbbacfcbdd6bce0380b8fe1d0 (diff) | |
download | gitlab-ce-547a5884d1ab6a22d9fc9ce79e5cf6f0310bc23d.tar.gz |
Add latest changes from gitlab-org/security/gitlab@14-4-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/api/entities/project_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/api/entities/project_spec.rb b/spec/lib/api/entities/project_spec.rb new file mode 100644 index 00000000000..8d1c3aa878d --- /dev/null +++ b/spec/lib/api/entities/project_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::API::Entities::Project do + let(:project) { create(:project, :public) } + let(:current_user) { create(:user) } + let(:options) { { current_user: current_user } } + + let(:entity) do + ::API::Entities::Project.new(project, options) + end + + subject(:json) { entity.as_json } + + describe '.shared_with_groups' do + let(:group) { create(:group, :private) } + + before do + project.project_group_links.create!(group: group) + end + + context 'when the current user does not have access to the group' do + it 'is empty' do + expect(json[:shared_with_groups]).to be_empty + end + end + + context 'when the current user has access to the group' do + before do + group.add_guest(current_user) + end + + it 'contains information about the shared group' do + expect(json[:shared_with_groups]).to contain_exactly(include(group_id: group.id)) + end + end + end +end |