2019-09-30 05:06:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-31 12:15:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe IssueSerializer do
|
2020-08-20 11:10:18 -04:00
|
|
|
let_it_be(:resource) { create(:issue) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2017-10-31 12:15:03 -04:00
|
|
|
let(:json_entity) do
|
|
|
|
described_class.new(current_user: user)
|
|
|
|
.represent(resource, serializer: serializer)
|
|
|
|
.with_indifferent_access
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'non-sidebar issue serialization' do
|
|
|
|
let(:serializer) { nil }
|
|
|
|
|
|
|
|
it 'matches issue json schema' do
|
|
|
|
expect(json_entity).to match_schema('entities/issue')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'sidebar issue serialization' do
|
2018-11-29 22:16:40 -05:00
|
|
|
let(:serializer) { 'sidebar' }
|
2017-10-31 12:15:03 -04:00
|
|
|
|
2018-11-29 22:16:40 -05:00
|
|
|
it 'matches issue_sidebar json schema' do
|
2017-10-31 12:15:03 -04:00
|
|
|
expect(json_entity).to match_schema('entities/issue_sidebar')
|
|
|
|
end
|
|
|
|
end
|
2018-12-03 10:23:38 -05:00
|
|
|
|
2018-11-29 22:16:40 -05:00
|
|
|
context 'sidebar extras issue serialization' do
|
|
|
|
let(:serializer) { 'sidebar_extras' }
|
|
|
|
|
|
|
|
it 'matches issue_sidebar_extras json schema' do
|
|
|
|
expect(json_entity).to match_schema('entities/issue_sidebar_extras')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-03 10:23:38 -05:00
|
|
|
context 'board issue serialization' do
|
|
|
|
let(:serializer) { 'board' }
|
|
|
|
|
|
|
|
it 'matches board issue json schema' do
|
|
|
|
expect(json_entity).to match_schema('entities/issue_board')
|
|
|
|
end
|
|
|
|
end
|
2017-10-31 12:15:03 -04:00
|
|
|
end
|