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

50 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.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') }
2019-12-21 20:55:43 +05:30
let(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
let(:entity) do
2019-12-21 20:55:43 +05:30
described_class.new(job, request: request)
end
before do
allow(request).to receive(:current_user).and_return(user)
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