debian-mirror-gitlab/spec/services/deployments/update_service_spec.rb

58 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Deployments::UpdateService do
2019-12-26 22:10:19 +05:30
let(:deploy) { create(:deployment) }
2019-12-21 20:55:43 +05:30
describe '#execute' do
2019-12-26 22:10:19 +05:30
it 'can update the status to running' do
expect(described_class.new(deploy, status: 'running').execute)
.to be_truthy
expect(deploy).to be_running
end
it 'can update the status to success' do
expect(described_class.new(deploy, status: 'success').execute)
.to be_truthy
expect(deploy).to be_success
end
it 'can update the status to failed' do
expect(described_class.new(deploy, status: 'failed').execute)
.to be_truthy
expect(deploy).to be_failed
end
it 'can update the status to canceled' do
expect(described_class.new(deploy, status: 'canceled').execute)
.to be_truthy
expect(deploy).to be_canceled
end
2020-01-01 13:55:28 +05:30
it 'raises ArgumentError if the status is invalid' do
expect { described_class.new(deploy, status: 'kittens').execute }
.to raise_error(ArgumentError)
2019-12-26 22:10:19 +05:30
end
it 'links merge requests when changing the status to success', :sidekiq_inline do
mr = create(
:merge_request,
:merged,
target_project: deploy.project,
source_project: deploy.project,
target_branch: 'master',
source_branch: 'foo'
)
described_class.new(deploy, status: 'success').execute
expect(deploy.merge_requests).to eq([mr])
2019-12-21 20:55:43 +05:30
end
end
end