diff options
-rw-r--r-- | app/serializers/merge_request_serializer.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 8 | ||||
-rw-r--r-- | spec/serializers/merge_request_serializer_spec.rb | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/app/serializers/merge_request_serializer.rb b/app/serializers/merge_request_serializer.rb index 52eb30d688a..caf193bdae3 100644 --- a/app/serializers/merge_request_serializer.rb +++ b/app/serializers/merge_request_serializer.rb @@ -7,7 +7,7 @@ class MergeRequestSerializer < BaseSerializer case opts[:serializer] when 'basic', 'sidebar' MergeRequestBasicEntity - when 'widget' + else # It's 'widget' MergeRequestWidgetEntity end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index d03ecefe47f..48674e06172 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -98,6 +98,14 @@ describe Projects::MergeRequestsController do expect(response).to match_response_schema('entities/merge_request_widget') end end + + context 'when no serialiser was passed' do + it 'renders widget MR entity as json' do + go(serializer: nil, format: :json) + + expect(response).to match_response_schema('entities/merge_request_widget') + end + end end describe "as diff" do diff --git a/spec/serializers/merge_request_serializer_spec.rb b/spec/serializers/merge_request_serializer_spec.rb index 1ad974c774b..b259cb92962 100644 --- a/spec/serializers/merge_request_serializer_spec.rb +++ b/spec/serializers/merge_request_serializer_spec.rb @@ -36,8 +36,8 @@ describe MergeRequestSerializer do context 'no serializer' do let(:serializer) { nil } - it 'raises an error' do - expect { json_entity }.to raise_error(NoMethodError) + it 'falls back to the widget entity' do + expect(json_entity).to match_schema('entities/merge_request_widget') end end end |