Commit 841a5ca4 authored by Shinya Maeda's avatar Shinya Maeda

Ignore unimportant StatusSyncError message

This commit fixes the Deployment.sync_status_with method
to ignore unimportant exception messages.
parent d9c9774f
...@@ -327,6 +327,7 @@ class Deployment < ApplicationRecord ...@@ -327,6 +327,7 @@ class Deployment < ApplicationRecord
def sync_status_with(build) def sync_status_with(build)
return false unless ::Deployment.statuses.include?(build.status) return false unless ::Deployment.statuses.include?(build.status)
return false if build.created? || build.status == self.status
update_status!(build.status) update_status!(build.status)
rescue StandardError => e rescue StandardError => e
......
...@@ -851,6 +851,12 @@ RSpec.describe Deployment do ...@@ -851,6 +851,12 @@ RSpec.describe Deployment do
context 'with created deployment' do context 'with created deployment' do
let(:deployment_status) { :created } let(:deployment_status) { :created }
context 'with created build' do
let(:build_status) { :created }
it_behaves_like 'ignoring build'
end
context 'with running build' do context 'with running build' do
let(:build_status) { :running } let(:build_status) { :running }
...@@ -873,12 +879,16 @@ RSpec.describe Deployment do ...@@ -873,12 +879,16 @@ RSpec.describe Deployment do
context 'with running deployment' do context 'with running deployment' do
let(:deployment_status) { :running } let(:deployment_status) { :running }
context 'with created build' do
let(:build_status) { :created }
it_behaves_like 'ignoring build'
end
context 'with running build' do context 'with running build' do
let(:build_status) { :running } let(:build_status) { :running }
it_behaves_like 'gracefully handling error' do it_behaves_like 'ignoring build'
let(:error_message) { %Q{Status cannot transition via \"run\"} }
end
end end
context 'with finished build' do context 'with finished build' do
...@@ -897,6 +907,12 @@ RSpec.describe Deployment do ...@@ -897,6 +907,12 @@ RSpec.describe Deployment do
context 'with finished deployment' do context 'with finished deployment' do
let(:deployment_status) { :success } let(:deployment_status) { :success }
context 'with created build' do
let(:build_status) { :created }
it_behaves_like 'ignoring build'
end
context 'with running build' do context 'with running build' do
let(:build_status) { :running } let(:build_status) { :running }
...@@ -908,9 +924,13 @@ RSpec.describe Deployment do ...@@ -908,9 +924,13 @@ RSpec.describe Deployment do
context 'with finished build' do context 'with finished build' do
let(:build_status) { :success } let(:build_status) { :success }
it_behaves_like 'gracefully handling error' do it_behaves_like 'ignoring build'
let(:error_message) { %Q{Status cannot transition via \"succeed\"} } end
end
context 'with failed build' do
let(:build_status) { :failed }
it_behaves_like 'synchronizing deployment'
end end
context 'with unrelated build' do context 'with unrelated build' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment