Add missing specs for new pipeline related entities

[ci skip]
This commit is contained in:
Grzegorz Bizon 2016-12-21 14:47:20 +01:00
parent c8b16068be
commit d549a96558
6 changed files with 52 additions and 8 deletions

View file

@ -5,7 +5,7 @@ class PipelineActionEntity < Grape::Entity
build.name.humanize
end
expose :url do |build|
expose :path do |build|
play_namespace_project_build_path(
build.project.namespace,
build.project,

View file

@ -5,7 +5,7 @@ class PipelineArtifactEntity < Grape::Entity
build.name
end
expose :url do |build|
expose :path do |build|
download_namespace_project_build_artifacts_path(
build.project.namespace,
build.project,

View file

@ -1,7 +1,7 @@
class StatusEntity < Grape::Entity
include RequestAwareEntity
expose :icon, :text, :label
expose :icon, :text, :label, :group
expose :has_details?, as: :has_details
expose :details_path

View file

@ -0,0 +1,21 @@
require 'spec_helper'
describe PipelineActionEntity do
let(:build) { create(:ci_build, name: 'test_build') }
let(:entity) do
described_class.new(build, request: double)
end
describe '#as_json' do
subject { entity.as_json }
it 'contains humanized build name' do
expect(subject[:name]).to eq 'Test build'
end
it 'contains path to the action play' do
expect(subject[:path]).to include "builds/#{build.id}/play"
end
end
end

View file

@ -0,0 +1,22 @@
require 'spec_helper'
describe PipelineArtifactEntity do
let(:build) { create(:ci_build, name: 'test:build') }
let(:entity) do
described_class.new(build, request: double)
end
describe '#as_json' do
subject { entity.as_json }
it 'contains build name' do
expect(subject[:name]).to eq 'test:build'
end
it 'contains path to the artifacts' do
expect(subject[:path])
.to include "builds/#{build.id}/artifacts/download"
end
end
end

View file

@ -12,11 +12,12 @@ describe StatusEntity do
allow(status).to receive(:details_path).and_return('some/path')
end
describe '#as_json' do
subject { entity.as_json }
it 'contains status details' do
expect(subject).to include :text, :icon, :label
expect(subject).to include :has_details
expect(subject).to include :details_path
expect(subject).to include :text, :icon, :label, :group
expect(subject).to include :has_details, :details_path
end
end
end