diff options
Diffstat (limited to 'spec/serializers')
6 files changed, 57 insertions, 1 deletions
diff --git a/spec/serializers/analytics_summary_serializer_spec.rb b/spec/serializers/analytics_summary_serializer_spec.rb index 7950f89bcc7..ed126720a55 100644 --- a/spec/serializers/analytics_summary_serializer_spec.rb +++ b/spec/serializers/analytics_summary_serializer_spec.rb @@ -34,7 +34,10 @@ describe AnalyticsSummarySerializer do end context 'when representing with unit' do - let(:resource) { { title: 'frequency', value: 1.12, unit: 'per day' } } + let(:resource) do + Gitlab::CycleAnalytics::Summary::DeploymentFrequency + .new(deployments: 10, from: 1.day.ago) + end subject { described_class.new.represent(resource, with_unit: true) } diff --git a/spec/serializers/discussion_entity_spec.rb b/spec/serializers/discussion_entity_spec.rb index 4adf1dc5994..b441fd08b98 100644 --- a/spec/serializers/discussion_entity_spec.rb +++ b/spec/serializers/discussion_entity_spec.rb @@ -73,9 +73,19 @@ describe DiscussionEntity do :diff_file, :truncated_diff_lines, :position, + :positions, + :line_codes, :line_code, :active ) end + + context 'diff_head_compare feature is disabled' do + it 'does not expose positions and line_codes attributes' do + stub_feature_flags(merge_ref_head_comments: false) + + expect(subject.keys).not_to include(:positions, :line_codes) + end + end end end diff --git a/spec/serializers/merge_request_basic_entity_spec.rb b/spec/serializers/merge_request_basic_entity_spec.rb new file mode 100644 index 00000000000..53ba66a79ac --- /dev/null +++ b/spec/serializers/merge_request_basic_entity_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe MergeRequestBasicEntity do + let(:resource) { build(:merge_request) } + + subject do + described_class.new(resource).as_json + end + + it 'has public_merge_status as merge_status' do + expect(resource).to receive(:public_merge_status).and_return('checking') + + expect(subject[:merge_status]).to eq 'checking' + end +end diff --git a/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb b/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb index 685abbf7e6c..9f96e5711a4 100644 --- a/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb +++ b/spec/serializers/merge_request_poll_cached_widget_entity_spec.rb @@ -19,6 +19,12 @@ describe MergeRequestPollCachedWidgetEntity do is_expected.to include(:target_branch_sha) end + it 'has public_merge_status as merge_status' do + expect(resource).to receive(:public_merge_status).and_return('checking') + + expect(subject[:merge_status]).to eq 'checking' + end + describe 'diverged_commits_count' do context 'when MR open and its diverging' do it 'returns diverged commits count' do diff --git a/spec/serializers/merge_request_poll_widget_entity_spec.rb b/spec/serializers/merge_request_poll_widget_entity_spec.rb index 29d35fdc811..fe0b717ede0 100644 --- a/spec/serializers/merge_request_poll_widget_entity_spec.rb +++ b/spec/serializers/merge_request_poll_widget_entity_spec.rb @@ -94,6 +94,10 @@ describe MergeRequestPollWidgetEntity do end describe 'auto merge' do + before do + project.add_maintainer(user) + end + context 'when auto merge is enabled' do let(:resource) { create(:merge_request, :merge_when_pipeline_succeeds) } diff --git a/spec/serializers/merge_request_serializer_spec.rb b/spec/serializers/merge_request_serializer_spec.rb index 871a47b0a02..90b3efae412 100644 --- a/spec/serializers/merge_request_serializer_spec.rb +++ b/spec/serializers/merge_request_serializer_spec.rb @@ -69,6 +69,22 @@ describe MergeRequestSerializer do end end + context 'poll cached widget merge request serialization' do + let(:serializer) { 'poll_cached_widget' } + + it 'matches basic merge request json schema' do + expect(json_entity).to match_schema('entities/merge_request_poll_cached_widget') + end + end + + context 'poll widget merge request serialization' do + let(:serializer) { 'poll_widget' } + + it 'matches basic merge request json schema' do + expect(json_entity).to match_schema('entities/merge_request_poll_widget') + end + end + context 'no serializer' do let(:serializer) { nil } |