Commit 866c97fb authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bvl-patch-mr-serializer' into 'master'

Fall back to the `MergeRequestWidgetEntity`

Closes #41296

See merge request gitlab-org/gitlab-ce!16074
parents 45031729 c27c65f9
......@@ -7,7 +7,7 @@ class MergeRequestSerializer < BaseSerializer
case opts[:serializer]
when 'basic', 'sidebar'
MergeRequestBasicEntity
when 'widget'
else # It's 'widget'
MergeRequestWidgetEntity
end
......
......@@ -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
......
......@@ -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
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