diff options
Diffstat (limited to 'spec/serializers')
4 files changed, 23 insertions, 21 deletions
diff --git a/spec/serializers/analytics/cycle_analytics/stage_entity_spec.rb b/spec/serializers/analytics/cycle_analytics/stage_entity_spec.rb index 90cc7f7827b..8b45e8a64fc 100644 --- a/spec/serializers/analytics/cycle_analytics/stage_entity_spec.rb +++ b/spec/serializers/analytics/cycle_analytics/stage_entity_spec.rb @@ -11,4 +11,12 @@ RSpec.describe Analytics::CycleAnalytics::StageEntity do expect(entity_json).to have_key(:start_event_html_description) expect(entity_json).to have_key(:end_event_html_description) end + + it 'exposes start_event and end_event objects' do + expect(entity_json[:start_event][:identifier]).to eq(entity_json[:start_event_identifier]) + expect(entity_json[:end_event][:identifier]).to eq(entity_json[:end_event_identifier]) + + expect(entity_json[:start_event][:html_description]).to eq(entity_json[:start_event_html_description]) + expect(entity_json[:end_event][:html_description]).to eq(entity_json[:end_event_html_description]) + end end diff --git a/spec/serializers/paginated_diff_entity_spec.rb b/spec/serializers/paginated_diff_entity_spec.rb index a8ac89a8481..f408deb734e 100644 --- a/spec/serializers/paginated_diff_entity_spec.rb +++ b/spec/serializers/paginated_diff_entity_spec.rb @@ -19,21 +19,12 @@ RSpec.describe PaginatedDiffEntity do subject { entity.as_json } - before do - stub_feature_flags(diffs_gradual_load: false) - end - it 'exposes diff_files' do expect(subject[:diff_files]).to be_present end it 'exposes pagination data' do - expect(subject[:pagination]).to eq( - current_page: 2, - next_page: 3, - next_page_href: "/#{merge_request.project.full_path}/-/merge_requests/#{merge_request.iid}/diffs_batch.json?page=3", - total_pages: 7 - ) + expect(subject[:pagination]).to eq(total_pages: 20) end context 'when there are conflicts' do diff --git a/spec/serializers/service_event_entity_spec.rb b/spec/serializers/service_event_entity_spec.rb index 91254c7dd27..f610c8f1488 100644 --- a/spec/serializers/service_event_entity_spec.rb +++ b/spec/serializers/service_event_entity_spec.rb @@ -12,7 +12,7 @@ RSpec.describe ServiceEventEntity do end describe '#as_json' do - context 'service without fields' do + context 'integration without fields' do let(:integration) { create(:emails_on_push_integration, push_events: true) } let(:event) { 'push' } @@ -24,8 +24,8 @@ RSpec.describe ServiceEventEntity do end end - context 'service with fields' do - let(:integration) { create(:slack_service, note_events: false, note_channel: 'note-channel') } + context 'integration with fields' do + let(:integration) { create(:integrations_slack, note_events: false, note_channel: 'note-channel') } let(:event) { 'note' } it 'exposes correct attributes' do diff --git a/spec/serializers/service_field_entity_spec.rb b/spec/serializers/service_field_entity_spec.rb index 20ca98416f8..6e9ebfb66d9 100644 --- a/spec/serializers/service_field_entity_spec.rb +++ b/spec/serializers/service_field_entity_spec.rb @@ -5,18 +5,18 @@ require 'spec_helper' RSpec.describe ServiceFieldEntity do let(:request) { double('request') } - subject { described_class.new(field, request: request, service: service).as_json } + subject { described_class.new(field, request: request, service: integration).as_json } before do - allow(request).to receive(:service).and_return(service) + allow(request).to receive(:service).and_return(integration) end describe '#as_json' do context 'Jira Service' do - let(:service) { create(:jira_service) } + let(:integration) { create(:jira_integration) } context 'field with type text' do - let(:field) { service.global_fields.find { |field| field[:name] == 'username' } } + let(:field) { integration_field('username') } it 'exposes correct attributes' do expected_hash = { @@ -35,7 +35,7 @@ RSpec.describe ServiceFieldEntity do end context 'field with type password' do - let(:field) { service.global_fields.find { |field| field[:name] == 'password' } } + let(:field) { integration_field('password') } it 'exposes correct attributes but hides password' do expected_hash = { @@ -56,10 +56,9 @@ RSpec.describe ServiceFieldEntity do context 'EmailsOnPush Service' do let(:integration) { create(:emails_on_push_integration, send_from_committer_email: '1') } - let(:service) { integration } # TODO: remove when https://gitlab.com/gitlab-org/gitlab/-/issues/330300 is complete context 'field with type checkbox' do - let(:field) { integration.global_fields.find { |field| field[:name] == 'send_from_committer_email' } } + let(:field) { integration_field('send_from_committer_email') } it 'exposes correct attributes and casts value to Boolean' do expected_hash = { @@ -78,7 +77,7 @@ RSpec.describe ServiceFieldEntity do end context 'field with type select' do - let(:field) { integration.global_fields.find { |field| field[:name] == 'branches_to_be_notified' } } + let(:field) { integration_field('branches_to_be_notified') } it 'exposes correct attributes' do expected_hash = { @@ -97,4 +96,8 @@ RSpec.describe ServiceFieldEntity do end end end + + def integration_field(name) + integration.global_fields.find { |f| f[:name] == name } + end end |