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

60 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Deployments::UpdateService, feature_category: :continuous_delivery 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
2021-11-18 22:05:49 +05:30
it 'does not change the state if the status is invalid' do
expect(described_class.new(deploy, status: 'kittens').execute)
.to be_falsy
expect(deploy).to be_created
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