diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/serializers | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/ci/pipeline_entity_spec.rb | 3 | ||||
-rw-r--r-- | spec/serializers/clusters/kubernetes_error_entity_spec.rb (renamed from spec/serializers/cluster_error_entity_spec.rb) | 2 | ||||
-rw-r--r-- | spec/serializers/environment_entity_spec.rb | 2 | ||||
-rw-r--r-- | spec/serializers/environment_serializer_spec.rb | 19 | ||||
-rw-r--r-- | spec/serializers/fork_namespace_entity_spec.rb | 22 | ||||
-rw-r--r-- | spec/serializers/issue_sidebar_basic_entity_spec.rb | 28 | ||||
-rw-r--r-- | spec/serializers/label_serializer_spec.rb | 2 | ||||
-rw-r--r-- | spec/serializers/merge_request_widget_entity_spec.rb | 2 | ||||
-rw-r--r-- | spec/serializers/pipeline_details_entity_spec.rb | 14 | ||||
-rw-r--r-- | spec/serializers/service_event_entity_spec.rb | 4 | ||||
-rw-r--r-- | spec/serializers/service_field_entity_spec.rb | 4 |
11 files changed, 57 insertions, 45 deletions
diff --git a/spec/serializers/ci/pipeline_entity_spec.rb b/spec/serializers/ci/pipeline_entity_spec.rb index 4d9ed9fc22f..808dc38f653 100644 --- a/spec/serializers/ci/pipeline_entity_spec.rb +++ b/spec/serializers/ci/pipeline_entity_spec.rb @@ -224,7 +224,8 @@ RSpec.describe Ci::PipelineEntity do end it 'makes atached flag true' do - expect(subject[:flags][:merge_request_pipeline]).to be_truthy + expect(subject[:flags][:merge_request_pipeline]).to be true + expect(subject[:flags][:merge_request]).to be true end it 'exposes source sha and target sha' do diff --git a/spec/serializers/cluster_error_entity_spec.rb b/spec/serializers/clusters/kubernetes_error_entity_spec.rb index 43ec41adf14..1464e696c48 100644 --- a/spec/serializers/cluster_error_entity_spec.rb +++ b/spec/serializers/clusters/kubernetes_error_entity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ClusterErrorEntity do +RSpec.describe Clusters::KubernetesErrorEntity do describe '#as_json' do let(:cluster) { create(:cluster, :provided_by_user, :group) } diff --git a/spec/serializers/environment_entity_spec.rb b/spec/serializers/environment_entity_spec.rb index a6101f825e9..a59107ad309 100644 --- a/spec/serializers/environment_entity_spec.rb +++ b/spec/serializers/environment_entity_spec.rb @@ -31,7 +31,7 @@ RSpec.describe EnvironmentEntity do end it 'exposes core elements of environment' do - expect(subject).to include(:id, :global_id, :name, :state, :environment_path) + expect(subject).to include(:id, :global_id, :name, :state, :environment_path, :tier) end it 'exposes folder path' do diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb index 658062c9461..ec0dd735755 100644 --- a/spec/serializers/environment_serializer_spec.rb +++ b/spec/serializers/environment_serializer_spec.rb @@ -204,6 +204,25 @@ RSpec.describe EnvironmentSerializer do json end + + # Validates possible bug that can arise when order_by is not honoured in the preloader. + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/353966#note_861381504 + it 'fetches the last and upcoming deployment correctly' do + last_deployment = nil + upcoming_deployment = nil + create(:environment, project: project).tap do |environment| + create(:deployment, :success, environment: environment, project: project) + last_deployment = create(:deployment, :success, environment: environment, project: project) + + create(:deployment, :running, environment: environment, project: project) + upcoming_deployment = create(:deployment, :running, environment: environment, project: project) + end + + response_json = json + + expect(response_json.last[:last_deployment][:id]).to eq(last_deployment.id) + expect(response_json.last[:upcoming_deployment][:id]).to eq(upcoming_deployment.id) + end end def create_environment_with_associations(project) diff --git a/spec/serializers/fork_namespace_entity_spec.rb b/spec/serializers/fork_namespace_entity_spec.rb index 32223b0d41a..91c59c4bda8 100644 --- a/spec/serializers/fork_namespace_entity_spec.rb +++ b/spec/serializers/fork_namespace_entity_spec.rb @@ -59,26 +59,4 @@ RSpec.describe ForkNamespaceEntity do it 'exposes human readable permission level' do expect(json[:permission]).to eql 'Developer' end - - it 'exposes can_create_project' do - expect(json[:can_create_project]).to be true - end - - context 'when fork_project_form feature flag is disabled' do - before do - stub_feature_flags(fork_project_form: false) - end - - it 'sets can_create_project to true when user can create projects in namespace' do - allow(user).to receive(:can?).with(:create_projects, namespace).and_return(true) - - expect(json[:can_create_project]).to be true - end - - it 'sets can_create_project to false when user is not allowed create projects in namespace' do - allow(user).to receive(:can?).with(:create_projects, namespace).and_return(false) - - expect(json[:can_create_project]).to be false - end - end end diff --git a/spec/serializers/issue_sidebar_basic_entity_spec.rb b/spec/serializers/issue_sidebar_basic_entity_spec.rb index da07290f349..716c97f72af 100644 --- a/spec/serializers/issue_sidebar_basic_entity_spec.rb +++ b/spec/serializers/issue_sidebar_basic_entity_spec.rb @@ -3,9 +3,10 @@ require 'spec_helper' RSpec.describe IssueSidebarBasicEntity do - let_it_be(:project) { create(:project, :repository) } + let_it_be(:group) { create(:group, :crm_enabled) } + let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:user) { create(:user, developer_projects: [project]) } - let_it_be(:issue) { create(:issue, project: project, assignees: [user]) } + let_it_be_with_reload(:issue) { create(:issue, project: project, assignees: [user]) } let(:serializer) { IssueSerializer.new(current_user: user, project: project) } @@ -71,4 +72,27 @@ RSpec.describe IssueSidebarBasicEntity do end end end + + describe 'show_crm_contacts' do + using RSpec::Parameterized::TableSyntax + + where(:is_reporter, :contacts_exist_for_group, :expected) do + false | false | false + false | true | false + true | false | false + true | true | true + end + + with_them do + it 'sets proper boolean value for show_crm_contacts' do + allow(CustomerRelations::Contact).to receive(:exists_for_group?).with(group).and_return(contacts_exist_for_group) + + if is_reporter + project.root_ancestor.add_reporter(user) + end + + expect(entity[:show_crm_contacts]).to be(expected) + end + end + end end diff --git a/spec/serializers/label_serializer_spec.rb b/spec/serializers/label_serializer_spec.rb index 40249450f7f..05c74fca8a8 100644 --- a/spec/serializers/label_serializer_spec.rb +++ b/spec/serializers/label_serializer_spec.rb @@ -40,7 +40,7 @@ RSpec.describe LabelSerializer do expect(subject.keys).to eq([:id, :title, :color, :project_id, :text_color]) expect(subject[:id]).to eq(resource.id) expect(subject[:title]).to eq(resource.title) - expect(subject[:color]).to eq(resource.color) + expect(subject[:color]).to be_color(resource.color) expect(subject[:text_color]).to eq(resource.text_color) expect(subject[:project_id]).to eq(resource.project_id) end diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index 1712df6266c..f0779f1c57c 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -59,7 +59,7 @@ RSpec.describe MergeRequestWidgetEntity do data = described_class.new(resource, request: request, issues_links: true).as_json expect(data).to include(:issues_links) - expect(data[:issues_links]).to include(:assign_to_closing, :closing, :mentioned_but_not_closing, :closing_count, :mentioned_count) + expect(data[:issues_links]).to include(:assign_to_closing, :assign_to_closing_count, :closing, :mentioned_but_not_closing, :closing_count, :mentioned_count) end it 'omits issue links by default' do diff --git a/spec/serializers/pipeline_details_entity_spec.rb b/spec/serializers/pipeline_details_entity_spec.rb index 128f1922887..67f8860ed4a 100644 --- a/spec/serializers/pipeline_details_entity_spec.rb +++ b/spec/serializers/pipeline_details_entity_spec.rb @@ -70,20 +70,6 @@ RSpec.describe PipelineDetailsEntity do expect(subject[:flags][:retryable]).to eq false end end - - it 'does not contain code_quality_build_path in details' do - expect(subject[:details]).not_to include :code_quality_build_path - end - - context 'when option code_quality_walkthrough is set and pipeline is a success' do - let(:entity) do - described_class.represent(pipeline, request: request, code_quality_walkthrough: true) - end - - it 'contains details.code_quality_build_path' do - expect(subject[:details]).to include :code_quality_build_path - end - end end context 'when pipeline is cancelable' do diff --git a/spec/serializers/service_event_entity_spec.rb b/spec/serializers/service_event_entity_spec.rb index f610c8f1488..db82e84fcf8 100644 --- a/spec/serializers/service_event_entity_spec.rb +++ b/spec/serializers/service_event_entity_spec.rb @@ -19,7 +19,7 @@ RSpec.describe ServiceEventEntity do it 'exposes correct attributes' do expect(subject[:description]).to eq('Trigger event for pushes to the repository.') expect(subject[:name]).to eq('push_events') - expect(subject[:title]).to eq('push') + expect(subject[:title]).to eq('Push') expect(subject[:value]).to be(true) end end @@ -31,7 +31,7 @@ RSpec.describe ServiceEventEntity do it 'exposes correct attributes' do expect(subject[:description]).to eq('Trigger event for new comments.') expect(subject[:name]).to eq('note_events') - expect(subject[:title]).to eq('note') + expect(subject[:title]).to eq('Note') expect(subject[:value]).to eq(false) expect(subject[:field][:name]).to eq('note_channel') expect(subject[:field][:value]).to eq('note-channel') diff --git a/spec/serializers/service_field_entity_spec.rb b/spec/serializers/service_field_entity_spec.rb index a06fdf95159..3a574c522b0 100644 --- a/spec/serializers/service_field_entity_spec.rb +++ b/spec/serializers/service_field_entity_spec.rb @@ -20,6 +20,7 @@ RSpec.describe ServiceFieldEntity do it 'exposes correct attributes' do expected_hash = { + section: 'connection', type: 'text', name: 'username', title: 'Username or Email', @@ -40,6 +41,7 @@ RSpec.describe ServiceFieldEntity do it 'exposes correct attributes but hides password' do expected_hash = { + section: 'connection', type: 'password', name: 'password', title: 'Enter new password or API token', @@ -64,6 +66,7 @@ RSpec.describe ServiceFieldEntity do it 'exposes correct attributes and casts value to Boolean' do expected_hash = { + section: nil, type: 'checkbox', name: 'send_from_committer_email', title: 'Send from committer', @@ -84,6 +87,7 @@ RSpec.describe ServiceFieldEntity do it 'exposes correct attributes' do expected_hash = { + section: nil, type: 'select', name: 'branches_to_be_notified', title: 'Branches for which notifications are to be sent', |