2018-11-07 11:44:21 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProjectSerializer do
|
2020-02-24 22:08:49 -05:00
|
|
|
let_it_be(:project) { create(:project) }
|
2018-11-07 11:44:21 -05:00
|
|
|
let(:provider_url) { 'http://provider.com' }
|
|
|
|
|
|
|
|
context 'when serializer option is :import' do
|
|
|
|
subject do
|
|
|
|
described_class.new.represent(project, serializer: :import, provider_url: provider_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(ProjectImportEntity).to receive(:represent)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'represents with ProjectImportEntity' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(ProjectImportEntity)
|
|
|
|
.to have_received(:represent)
|
|
|
|
.with(project, serializer: :import, provider_url: provider_url, request: an_instance_of(EntityRequest))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when serializer option is omitted' do
|
|
|
|
subject do
|
|
|
|
described_class.new.represent(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(ProjectEntity).to receive(:represent)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'represents with ProjectEntity' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(ProjectEntity)
|
|
|
|
.to have_received(:represent)
|
|
|
|
.with(project, request: an_instance_of(EntityRequest))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|