2018-10-10 05:43:02 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe DeploymentSerializer do
|
2020-02-24 22:08:49 -05:00
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
let_it_be(:user) { create(:user, email: project.commit.author_email) }
|
2021-04-14 11:09:04 -04:00
|
|
|
|
2018-10-10 05:43:02 -04:00
|
|
|
let(:resource) { create(:deployment, project: project, sha: project.commit.id) }
|
|
|
|
let(:serializer) { described_class.new(request) }
|
|
|
|
|
|
|
|
shared_examples 'json schema' do
|
|
|
|
let(:json_entity) { subject.as_json }
|
|
|
|
|
|
|
|
it 'matches deployment entity schema' do
|
|
|
|
expect(json_entity).to match_schema('deployment')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#represent' do
|
|
|
|
subject { serializer.represent(resource) }
|
|
|
|
|
|
|
|
let(:request) { { project: project, current_user: user } }
|
|
|
|
|
|
|
|
it_behaves_like 'json schema'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#represent_concise' do
|
|
|
|
subject { serializer.represent_concise(resource) }
|
|
|
|
|
|
|
|
let(:request) { { project: project } }
|
|
|
|
|
|
|
|
it_behaves_like 'json schema'
|
|
|
|
end
|
|
|
|
end
|