Skip to content
Snippets Groups Projects
Commit 61729204 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Add spec for entity and serializer

parent 01914554
No related branches found
No related tags found
No related merge requests found
require 'spec_helper'
 
describe BuildEntity do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:request) { double('request') }
before do
allow(request).to receive(:user).and_return(user)
end
 
let(:entity) do
described_class.new(build, request: double)
described_class.new(build, request: request)
end
 
subject { entity.as_json }
Loading
Loading
@@ -22,6 +28,11 @@ describe BuildEntity do
expect(subject).to include(:created_at, :updated_at)
end
 
it 'contains details' do
expect(subject).to include :details
expect(subject[:details][:status]).to include :icon, :favicon, :text, :label
end
context 'when build is a regular job' do
it 'does not contain path to play action' do
expect(subject).not_to include(:play_path)
Loading
Loading
require 'spec_helper'
describe BuildSerializer do
let(:user) { create(:user) }
let(:serializer) do
described_class.new(user: user)
end
subject { serializer.represent(resource) }
describe '#represent' do
context 'when used with status' do
let(:serializer) do
described_class.new(user: user)
.with_status
end
let(:resource) { create(:ci_build) }
it 'serializes only status' do
expect(subject[:details][:status]).not_to be_empty
expect(subject[:details].keys.count).to eq 1
end
end
end
end
Loading
Loading
@@ -30,7 +30,7 @@ describe PipelineEntity do
.to include :duration, :finished_at
expect(subject[:details])
.to include :stages, :artifacts, :manual_actions
expect(subject[:details][:status]).to include :icon, :text, :label
expect(subject[:details][:status]).to include :icon, :favicon, :text, :label
end
 
it 'contains flags' do
Loading
Loading
Loading
Loading
@@ -93,5 +93,18 @@ describe PipelineSerializer do
end
end
end
context 'when used with status' do
let(:serializer) do
described_class.new(user: user)
.with_status
end
let(:resource) { create(:ci_empty_pipeline) }
it 'serializes only status' do
expect(subject[:details][:status]).not_to be_empty
expect(subject[:details].keys.count).to eq 1
end
end
end
end
Loading
Loading
@@ -16,7 +16,7 @@ describe StatusEntity do
subject { entity.as_json }
 
it 'contains status details' do
expect(subject).to include :text, :icon, :label, :group
expect(subject).to include :text, :icon, :favicon, :label, :group
expect(subject).to include :has_details, :details_path
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment