diff options
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/admin/abuse_report_details_entity_spec.rb | 3 | ||||
-rw-r--r-- | spec/serializers/admin/abuse_report_entity_spec.rb | 1 | ||||
-rw-r--r-- | spec/serializers/base_discussion_entity_spec.rb | 12 | ||||
-rw-r--r-- | spec/serializers/deployment_entity_spec.rb | 20 | ||||
-rw-r--r-- | spec/serializers/integrations/event_entity_spec.rb | 21 | ||||
-rw-r--r-- | spec/serializers/profile/event_entity_spec.rb | 11 | ||||
-rw-r--r-- | spec/serializers/project_note_entity_spec.rb | 14 | ||||
-rw-r--r-- | spec/serializers/stage_entity_spec.rb | 4 |
8 files changed, 73 insertions, 13 deletions
diff --git a/spec/serializers/admin/abuse_report_details_entity_spec.rb b/spec/serializers/admin/abuse_report_details_entity_spec.rb index 08bfa57b062..727716d76a4 100644 --- a/spec/serializers/admin/abuse_report_details_entity_spec.rb +++ b/spec/serializers/admin/abuse_report_details_entity_spec.rb @@ -134,7 +134,8 @@ RSpec.describe Admin::AbuseReportDetailsEntity, feature_category: :insider_threa :content, :url, :screenshot, - :update_path + :update_path, + :moderate_user_path ]) end end diff --git a/spec/serializers/admin/abuse_report_entity_spec.rb b/spec/serializers/admin/abuse_report_entity_spec.rb index 003d76a172f..c7f57258f40 100644 --- a/spec/serializers/admin/abuse_report_entity_spec.rb +++ b/spec/serializers/admin/abuse_report_entity_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Admin::AbuseReportEntity, feature_category: :insider_threat do :category, :created_at, :updated_at, + :count, :reported_user, :reporter, :report_path diff --git a/spec/serializers/base_discussion_entity_spec.rb b/spec/serializers/base_discussion_entity_spec.rb index 334e71d23f4..d94dc702977 100644 --- a/spec/serializers/base_discussion_entity_spec.rb +++ b/spec/serializers/base_discussion_entity_spec.rb @@ -30,11 +30,23 @@ RSpec.describe BaseDiscussionEntity do :id, :individual_note, :resolvable, + :resolved, + :resolved_by_push, + :resolved_by, + :resolved_at, :resolve_path, :resolve_with_issue_path ) end + context 'when note is on an issue' do + let_it_be(:note) { create(:discussion_note_on_issue) } + + it 'does not include resolve_with_issue_path' do + expect(subject.keys.sort).not_to include(:resolve_with_issue_path) + end + end + context 'when is LegacyDiffDiscussion' do let(:project) { create(:project) } let(:merge_request) { create(:merge_request, source_project: project) } diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index 0746e68d7c5..b0f3f328a4f 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -116,20 +116,28 @@ RSpec.describe DeploymentEntity do describe 'playable_build' do before do - deployment.update!(deployable: build) + deployment.update!(deployable: job) end context 'when the deployment has a playable deployable' do - context 'when this build is ready to be played' do - let(:build) { create(:ci_build, :playable, :scheduled, pipeline: pipeline) } + context 'when this job is build and ready to be played' do + let(:job) { create(:ci_build, :playable, :scheduled, pipeline: pipeline) } + + it 'exposes only the play_path' do + expect(subject[:playable_build].keys).to contain_exactly(:play_path) + end + end + + context 'when this job is bridge and ready to be played' do + let(:job) { create(:ci_bridge, :playable, :manual, pipeline: pipeline, downstream: project) } it 'exposes only the play_path' do expect(subject[:playable_build].keys).to contain_exactly(:play_path) end end - context 'when this build has failed' do - let(:build) { create(:ci_build, :playable, :failed, pipeline: pipeline) } + context 'when this job has failed' do + let(:job) { create(:ci_build, :playable, :failed, pipeline: pipeline) } it 'exposes the play_path and the retry_path' do expect(subject[:playable_build].keys).to contain_exactly(:play_path, :retry_path) @@ -138,7 +146,7 @@ RSpec.describe DeploymentEntity do end context 'when the deployment does not have a playable deployable' do - let(:build) { create(:ci_build, pipeline: pipeline) } + let(:job) { create(:ci_build, pipeline: pipeline) } it 'is not exposed' do expect(subject[:playable_build]).to be_nil diff --git a/spec/serializers/integrations/event_entity_spec.rb b/spec/serializers/integrations/event_entity_spec.rb index 1b72b5d290c..a15c1bea61a 100644 --- a/spec/serializers/integrations/event_entity_spec.rb +++ b/spec/serializers/integrations/event_entity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Integrations::EventEntity do +RSpec.describe Integrations::EventEntity, feature_category: :integrations do let(:request) { EntityRequest.new(integration: integration) } subject { described_class.new(event, request: request, integration: integration).as_json } @@ -38,5 +38,24 @@ RSpec.describe Integrations::EventEntity do expect(subject[:field][:placeholder]).to eq('#general, #development') end end + + context 'with integration with fields when channels are masked' do + let(:integration) { create(:integrations_slack, note_events: false, note_channel: 'note-channel') } + let(:event) { 'note' } + + before do + allow(integration).to receive(:mask_configurable_channels?).and_return(true) + end + + 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[:value]).to eq(false) + expect(subject[:field][:name]).to eq('note_channel') + expect(subject[:field][:value]).to eq(Integrations::BaseChatNotification::SECRET_MASK) + expect(subject[:field][:placeholder]).to eq('#general, #development') + end + end end end diff --git a/spec/serializers/profile/event_entity_spec.rb b/spec/serializers/profile/event_entity_spec.rb index dbd748d3b11..b1246e7e47d 100644 --- a/spec/serializers/profile/event_entity_spec.rb +++ b/spec/serializers/profile/event_entity_spec.rb @@ -140,6 +140,17 @@ RSpec.describe Profile::EventEntity, feature_category: :user_profile do expect(subject[:target][:issue_type]).to eq('incident') end end + + context 'when target is an issue' do + let(:issue) { build_stubbed(:issue, author: target_user, project: project) } + let(:event) do + build(:event, :created, author: target_user, project: project, target: issue) + end + + it 'exposes `issue_type`' do + expect(subject[:target][:issue_type]).to eq('issue') + end + end end context 'with resource parent' do diff --git a/spec/serializers/project_note_entity_spec.rb b/spec/serializers/project_note_entity_spec.rb index aaf7764a123..ffa9cf54e10 100644 --- a/spec/serializers/project_note_entity_spec.rb +++ b/spec/serializers/project_note_entity_spec.rb @@ -5,11 +5,11 @@ require 'spec_helper' RSpec.describe ProjectNoteEntity do include Gitlab::Routing - let(:request) { double('request', current_user: user, noteable: note.noteable) } + let_it_be(:note) { create(:note_on_merge_request) } + let_it_be(:user) { create(:user) } + let(:request) { double('request', current_user: user, noteable: note.noteable) } let(:entity) { described_class.new(note, request: request) } - let(:note) { create(:note) } - let(:user) { create(:user) } subject { entity.as_json } @@ -28,5 +28,13 @@ RSpec.describe ProjectNoteEntity do it 'exposes paths to resolve note' do expect(subject).to include(:resolve_path, :resolve_with_issue_path) end + + context 'when note is on an issue' do + let(:note) { create(:note_on_issue) } + + it 'does not include resolve_with_issue_path' do + expect(subject).not_to include(:resolve_with_issue_path) + end + end end end diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb index fe8ee027245..81cb89d0c38 100644 --- a/spec/serializers/stage_entity_spec.rb +++ b/spec/serializers/stage_entity_spec.rb @@ -76,8 +76,8 @@ RSpec.describe StageEntity, feature_category: :continuous_integration do context 'with a skipped stage ' do let(:stage) { create(:ci_stage, status: 'skipped') } - it 'does not contain play_all_manual' do - expect(subject[:status][:action]).not_to be_present + it 'contains play_all_manual' do + expect(subject[:status][:action]).to be_present end end |