2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe IssueSerializer do
|
2020-11-24 15:15:51 +05:30
|
|
|
let_it_be(:resource) { create(:issue) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|
|
|
|
let(:serializer) { 'sidebar' }
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
it 'matches issue_sidebar json schema' do
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(json_entity).to match_schema('entities/issue_sidebar')
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|