debian-mirror-gitlab/spec/serializers/build_action_entity_spec.rb

43 lines
1 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe BuildActionEntity do
2017-09-10 17:25:29 +05:30
let(:job) { create(:ci_build, name: 'test_job') }
2017-08-17 22:00:37 +05:30
let(:request) { double('request') }
let(:entity) do
2017-09-10 17:25:29 +05:30
described_class.new(job, request: spy('request'))
2017-08-17 22:00:37 +05:30
end
describe '#as_json' do
subject { entity.as_json }
2017-09-10 17:25:29 +05:30
it 'contains original job name' do
expect(subject[:name]).to eq 'test_job'
2017-08-17 22:00:37 +05:30
end
it 'contains path to the action play' do
2017-09-10 17:25:29 +05:30
expect(subject[:path]).to include "jobs/#{job.id}/play"
2017-08-17 22:00:37 +05:30
end
it 'contains whether it is playable' do
2017-09-10 17:25:29 +05:30
expect(subject[:playable]).to eq job.playable?
2017-08-17 22:00:37 +05:30
end
2018-12-05 23:21:45 +05:30
context 'when job is scheduled' do
let(:job) { create(:ci_build, :scheduled) }
2018-12-13 13:39:08 +05:30
it 'returns scheduled' do
expect(subject[:scheduled]).to be_truthy
end
2018-12-05 23:21:45 +05:30
it 'returns scheduled_at' do
expect(subject[:scheduled_at]).to eq(job.scheduled_at)
end
it 'returns unschedule path' do
expect(subject[:unschedule_path]).to include "jobs/#{job.id}/unschedule"
end
end
2017-08-17 22:00:37 +05:30
end
end