BigW Consortium Gitlab

Commit c27c65f9 by Bob Van Landuyt

Fall back to the `MergeRequestWidgetEntity`

When no serializer was passed.
parent 3ee5fd15
...@@ -7,7 +7,7 @@ class MergeRequestSerializer < BaseSerializer ...@@ -7,7 +7,7 @@ class MergeRequestSerializer < BaseSerializer
case opts[:serializer] case opts[:serializer]
when 'basic', 'sidebar' when 'basic', 'sidebar'
MergeRequestBasicEntity MergeRequestBasicEntity
when 'widget' else # It's 'widget'
MergeRequestWidgetEntity MergeRequestWidgetEntity
end end
......
...@@ -98,6 +98,14 @@ describe Projects::MergeRequestsController do ...@@ -98,6 +98,14 @@ describe Projects::MergeRequestsController do
expect(response).to match_response_schema('entities/merge_request_widget') expect(response).to match_response_schema('entities/merge_request_widget')
end end
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 end
describe "as diff" do describe "as diff" do
......
...@@ -36,8 +36,8 @@ describe MergeRequestSerializer do ...@@ -36,8 +36,8 @@ describe MergeRequestSerializer do
context 'no serializer' do context 'no serializer' do
let(:serializer) { nil } let(:serializer) { nil }
it 'raises an error' do it 'falls back to the widget entity' do
expect { json_entity }.to raise_error(NoMethodError) expect(json_entity).to match_schema('entities/merge_request_widget')
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment