gitlab-org--gitlab-foss/spec/serializers/build_entity_spec.rb
Filipa Lacerda 1b85c5a73f Merge branch 'master' into tc-fix-unplayable-build-action-404
* master: (525 commits)
  Introduce "polling_interval_multiplier" as application setting
  fix spelling CI_REPOSITORY_URL (line:355) gitab-ci-token to gitlab-ci-token.
  Pass Gitaly Repository messages to workhorse
  Use gitaly 0.5.0
  Fix specs
  Improve specs examples
  Minor refactor
  Fix BrachFormatter for removed users
  Changelog
  Fix specs
  One more change to the branch names to preserve metadata
  Prefixes source branch name with short SHA to avoid collision
  Fix GitHub importer for PRs of deleted forked repositories
  Change order of specs
  Clean history after every test that changes history
  Clean history state after each test
  Fixes method not replacing URL parameters correctly
  Fix a transient failure caused by FFaker
  Remove unnecessary ORDER BY clause when updating todos
  Add a wait_for_ajax call to ensure Todos page cleans up properly
  ...
2017-04-03 17:22:18 +01:00

53 lines
1.3 KiB
Ruby

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: request)
end
subject { entity.as_json }
it 'contains paths to build page and retry action' do
expect(subject).to include(:build_path, :retry_path)
end
it 'does not contain sensitive information' do
expect(subject).not_to include(/token/)
expect(subject).not_to include(/variables/)
end
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
end
it 'contains timestamps' do
expect(subject).to include(:created_at, :updated_at)
end
it 'contains details' do
expect(subject).to include :status
expect(subject[: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)
end
end
context 'when build is a manual action' do
let(:build) { create(:ci_build, :manual) }
it 'contains path to play action' do
expect(subject).to include(:play_path)
end
end
end