Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/admin/abuse_report_details_entity_spec.rb3
-rw-r--r--spec/serializers/admin/abuse_report_details_serializer_spec.rb3
-rw-r--r--spec/serializers/build_details_entity_spec.rb12
-rw-r--r--spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb13
-rw-r--r--spec/serializers/discussion_entity_spec.rb7
-rw-r--r--spec/serializers/group_link/group_group_link_entity_spec.rb8
-rw-r--r--spec/serializers/group_link/group_link_entity_spec.rb6
-rw-r--r--spec/serializers/group_link/project_group_link_entity_spec.rb88
-rw-r--r--spec/serializers/merge_request_poll_widget_entity_spec.rb3
-rw-r--r--spec/serializers/personal_access_token_entity_spec.rb2
10 files changed, 99 insertions, 46 deletions
diff --git a/spec/serializers/admin/abuse_report_details_entity_spec.rb b/spec/serializers/admin/abuse_report_details_entity_spec.rb
index 47904a4e7e5..67f6bdfee85 100644
--- a/spec/serializers/admin/abuse_report_details_entity_spec.rb
+++ b/spec/serializers/admin/abuse_report_details_entity_spec.rb
@@ -21,7 +21,8 @@ RSpec.describe Admin::AbuseReportDetailsEntity, feature_category: :insider_threa
it 'exposes correct attributes' do
expect(entity_hash.keys).to match_array([
:user,
- :report
+ :report,
+ :upload_note_attachment_path
])
end
diff --git a/spec/serializers/admin/abuse_report_details_serializer_spec.rb b/spec/serializers/admin/abuse_report_details_serializer_spec.rb
index 3bdd2e46ba3..f320d9538f5 100644
--- a/spec/serializers/admin/abuse_report_details_serializer_spec.rb
+++ b/spec/serializers/admin/abuse_report_details_serializer_spec.rb
@@ -11,7 +11,8 @@ RSpec.describe Admin::AbuseReportDetailsSerializer, feature_category: :insider_t
it 'serializes an abuse report' do
is_expected.to match_array([
:user,
- :report
+ :report,
+ :upload_note_attachment_path
])
end
end
diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb
index 874bcbfceaf..a899a798fa0 100644
--- a/spec/serializers/build_details_entity_spec.rb
+++ b/spec/serializers/build_details_entity_spec.rb
@@ -281,21 +281,11 @@ RSpec.describe BuildDetailsEntity do
end
context 'when the build has non public archive type artifacts' do
- let(:build) { create(:ci_build, :artifacts, :with_private_artifacts_config, pipeline: pipeline) }
+ let(:build) { create(:ci_build, :private_artifacts, :with_private_artifacts_config, pipeline: pipeline) }
it 'does not expose non public artifacts' do
expect(subject.keys).not_to include(:artifact)
end
-
- context 'with the non_public_artifacts feature flag disabled' do
- before do
- stub_feature_flags(non_public_artifacts: false)
- end
-
- it 'exposes artifact details' do
- expect(subject[:artifact].keys).to include(:download_path, :browse_path, :locked)
- end
- end
end
end
diff --git a/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb b/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
index 7df6413f416..8645bbd49fb 100644
--- a/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
+++ b/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe DeployKeys::BasicDeployKeyEntity do
+RSpec.describe DeployKeys::BasicDeployKeyEntity, feature_category: :continuous_delivery do
include RequestAwareEntity
let(:user) { create(:user) }
@@ -56,7 +56,18 @@ RSpec.describe DeployKeys::BasicDeployKeyEntity do
end
context 'project deploy key' do
+ let(:options) { { user: user, project: project } }
+
it { expect(entity.as_json).to include(can_edit: true) }
+ it { expect(entity.as_json).to include(edit_path: edit_project_deploy_key_path(options[:project], deploy_key)) }
+
+ it do
+ expect(entity.as_json).to include(enable_path: enable_project_deploy_key_path(options[:project], deploy_key))
+ end
+
+ it do
+ expect(entity.as_json).to include(disable_path: disable_project_deploy_key_path(options[:project], deploy_key))
+ end
end
context 'public deploy key' do
diff --git a/spec/serializers/discussion_entity_spec.rb b/spec/serializers/discussion_entity_spec.rb
index 0fe10ed2c6d..4b818ce35e6 100644
--- a/spec/serializers/discussion_entity_spec.rb
+++ b/spec/serializers/discussion_entity_spec.rb
@@ -53,13 +53,6 @@ RSpec.describe DiscussionEntity do
.to match_schema('entities/note_user_entity')
end
- it 'exposes the url for custom award emoji' do
- custom_emoji = create(:custom_emoji, group: group)
- create(:award_emoji, awardable: note, name: custom_emoji.name)
-
- expect(subject[:notes].last[:award_emoji].first.keys).to include(:url)
- end
-
context 'when is LegacyDiffDiscussion' do
let(:discussion) { create(:legacy_diff_note_on_merge_request, noteable: note.noteable, project: project).to_discussion }
diff --git a/spec/serializers/group_link/group_group_link_entity_spec.rb b/spec/serializers/group_link/group_group_link_entity_spec.rb
index 8f31c53e841..c1ee92e55ba 100644
--- a/spec/serializers/group_link/group_group_link_entity_spec.rb
+++ b/spec/serializers/group_link/group_group_link_entity_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GroupLink::GroupGroupLinkEntity do
+RSpec.describe GroupLink::GroupGroupLinkEntity, feature_category: :groups_and_projects do
include_context 'group_group_link'
let_it_be(:current_user) { create(:user) }
@@ -17,6 +17,10 @@ RSpec.describe GroupLink::GroupGroupLinkEntity do
expect(entity.to_json).to match_schema('group_link/group_group_link')
end
+ it 'correctly exposes `valid_roles`' do
+ expect(entity.as_json[:valid_roles]).to include(Gitlab::Access.options_with_owner)
+ end
+
context 'source' do
it 'exposes `source`' do
expect(as_json[:source]).to include(
@@ -59,7 +63,7 @@ RSpec.describe GroupLink::GroupGroupLinkEntity do
allow(entity).to receive(:direct_member?).and_return(false)
end
- it 'exposes `can_update` and `can_remove` as `true`' do
+ it 'exposes `can_update` and `can_remove` as `false`' do
expect(as_json[:can_update]).to be false
expect(as_json[:can_remove]).to be false
end
diff --git a/spec/serializers/group_link/group_link_entity_spec.rb b/spec/serializers/group_link/group_link_entity_spec.rb
index 941445feaa2..01c01f492aa 100644
--- a/spec/serializers/group_link/group_link_entity_spec.rb
+++ b/spec/serializers/group_link/group_link_entity_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GroupLink::GroupLinkEntity do
+RSpec.describe GroupLink::GroupLinkEntity, feature_category: :groups_and_projects do
include_context 'group_group_link'
let(:entity) { described_class.new(group_group_link) }
@@ -12,10 +12,6 @@ RSpec.describe GroupLink::GroupLinkEntity do
expect(entity.to_json).to match_schema('group_link/group_link')
end
- it 'correctly exposes `valid_roles`' do
- expect(entity_hash[:valid_roles]).to include(Gitlab::Access.options_with_owner)
- end
-
it 'correctly exposes `shared_with_group.avatar_url`' do
avatar_url = 'https://gitlab.com/uploads/-/system/group/avatar/24/foobar.png?width=40'
allow(shared_with_group).to receive(:avatar_url).with(only_path: false, size: Member::AVATAR_SIZE).and_return(avatar_url)
diff --git a/spec/serializers/group_link/project_group_link_entity_spec.rb b/spec/serializers/group_link/project_group_link_entity_spec.rb
index 00bfc43f17e..9f09020b91d 100644
--- a/spec/serializers/group_link/project_group_link_entity_spec.rb
+++ b/spec/serializers/group_link/project_group_link_entity_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GroupLink::ProjectGroupLinkEntity do
+RSpec.describe GroupLink::ProjectGroupLinkEntity, feature_category: :groups_and_projects do
let_it_be(:current_user) { create(:user) }
let_it_be(:project_group_link) { create(:project_group_link) }
@@ -16,32 +16,86 @@ RSpec.describe GroupLink::ProjectGroupLinkEntity do
expect(entity.to_json).to match_schema('group_link/project_group_link')
end
- context 'when current user is a project maintainer' do
- before_all do
- project_group_link.project.add_maintainer(current_user)
+ context 'when current user is a direct member' do
+ before do
+ allow(entity).to receive(:direct_member?).and_return(true)
+ allow(entity).to receive(:can?).and_call_original
end
- it 'exposes `can_update` and `can_remove` as `true`' do
- expect(as_json[:can_update]).to be true
- expect(as_json[:can_remove]).to be true
- end
- end
+ describe 'can_update' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(
+ :can_admin_project_member,
+ :can_manage_group_link_with_owner_access,
+ :expected_can_update
+ ) do
+ false | false | false
+ true | false | false
+ true | true | true
+ end
- context 'when current user is a group owner' do
- before_all do
- project_group_link.group.add_owner(current_user)
+ with_them do
+ before do
+ allow(entity)
+ .to receive(:can?)
+ .with(current_user, :admin_project_member, project_group_link.shared_from)
+ .and_return(can_admin_project_member)
+ allow(entity)
+ .to receive(:can?)
+ .with(current_user, :manage_group_link_with_owner_access, project_group_link)
+ .and_return(can_manage_group_link_with_owner_access)
+ end
+
+ it "exposes `can_update` as `#{params[:expected_can_update]}`" do
+ expect(entity.as_json[:can_update]).to be expected_can_update
+ end
+ end
end
- it 'exposes `can_remove` as true' do
- expect(as_json[:can_remove]).to be true
+ describe 'can_remove' do
+ context 'when current user has `destroy_project_group_link` ability' do
+ before do
+ allow(entity)
+ .to receive(:can?)
+ .with(current_user, :destroy_project_group_link, project_group_link)
+ .and_return(true)
+ end
+
+ it 'exposes `can_remove` as `true`' do
+ expect(entity.as_json[:can_remove]).to be(true)
+ end
+ end
+
+ context 'when current user does not have `destroy_project_group_link` ability' do
+ before do
+ allow(entity)
+ .to receive(:can?)
+ .with(current_user, :destroy_project_group_link, project_group_link)
+ .and_return(false)
+ end
+
+ it 'exposes `can_remove` as `false`' do
+ expect(entity.as_json[:can_remove]).to be(false)
+ end
+ end
end
end
- context 'when current user is not a group owner' do
- it 'exposes `can_remove` as false' do
- expect(as_json[:can_remove]).to be false
+ context 'when current user is not a direct member' do
+ before do
+ allow(entity).to receive(:direct_member?).and_return(false)
end
+ it 'exposes `can_update` and `can_remove` as `false`' do
+ json = entity.as_json
+
+ expect(json[:can_update]).to be false
+ expect(json[:can_remove]).to be false
+ end
+ end
+
+ context 'when current user is not a project member' do
context 'when group is public' do
it 'does expose shared_with_group details' do
expect(as_json[:shared_with_group].keys).to include(:id, :avatar_url, :web_url, :name)
diff --git a/spec/serializers/merge_request_poll_widget_entity_spec.rb b/spec/serializers/merge_request_poll_widget_entity_spec.rb
index 6b80609c348..171f2324cf1 100644
--- a/spec/serializers/merge_request_poll_widget_entity_spec.rb
+++ b/spec/serializers/merge_request_poll_widget_entity_spec.rb
@@ -22,6 +22,9 @@ RSpec.describe MergeRequestPollWidgetEntity do
.to eq(resource.default_merge_commit_message(include_description: true))
end
+ it { is_expected.to include(ff_only_enabled: false) }
+ it { is_expected.to include(ff_merge_possible: false) }
+
describe 'new_blob_path' do
context 'when user can push to project' do
it 'returns path' do
diff --git a/spec/serializers/personal_access_token_entity_spec.rb b/spec/serializers/personal_access_token_entity_spec.rb
index 8a77a4e0036..817d112d15f 100644
--- a/spec/serializers/personal_access_token_entity_spec.rb
+++ b/spec/serializers/personal_access_token_entity_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe PersonalAccessTokenEntity do
it 'has the correct attributes' do
expected_revoke_path = Gitlab::Routing.url_helpers
- .revoke_profile_personal_access_token_path(
+ .revoke_user_settings_personal_access_token_path(
{ id: token })
expect(json).to(