Skip to content
Snippets Groups Projects
Commit b8f911e2 authored by Shinya Maeda's avatar Shinya Maeda Committed by Mikołaj Wawrzyniak
Browse files

Drop legacy finished at in Deployment

This commit drops the legacy finished at calculation
of deployments.

Changelog: fixed
parent 765884f5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -294,10 +294,6 @@ def stop_action
@stop_action ||= manual_actions.find { |action| action.name == self.on_stop }
end
 
def finished_at
read_attribute(:finished_at) || legacy_finished_at
end
def deployed_at
return unless success?
 
Loading
Loading
@@ -405,10 +401,6 @@ def update_status!(status)
raise ArgumentError, "The status #{status.inspect} is invalid"
end
end
def legacy_finished_at
self.created_at if success? && !read_attribute(:finished_at)
end
end
 
Deployment.prepend_mod_with('Deployment')
Loading
Loading
@@ -132,6 +132,29 @@ def auto_stop_button_selector
end
end
 
context 'with upcoming deployments' do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let!(:runnind_deployment_1) { create(:deployment, environment: environment, deployable: build, status: :running) }
let!(:runnind_deployment_2) { create(:deployment, environment: environment, deployable: build, status: :running) }
# Success deployments must have present `finished_at`. We'll backfill in the future.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/350618 for more information.
let!(:success_without_finished_at) { create(:deployment, environment: environment, deployable: build, status: :success, finished_at: nil) }
before do
visit_environment(environment)
end
# This ordering is unexpected and to be fixed.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/350618 for more information.
it 'shows upcoming deployments in unordered way' do
displayed_ids = find_all('[data-testid="deployment-id"]').map { |e| e.text }
internal_ids = [runnind_deployment_1, runnind_deployment_2, success_without_finished_at].map { |d| "##{d.iid}" }
expect(displayed_ids).to match_array(internal_ids)
end
end
context 'with related deployable present' do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
Loading
Loading
Loading
Loading
@@ -369,38 +369,6 @@
end
end
 
describe '#finished_at' do
subject { deployment.finished_at }
context 'when deployment status is created' do
let(:deployment) { create(:deployment) }
it { is_expected.to be_nil }
end
context 'when deployment status is success' do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to eq(deployment.read_attribute(:finished_at)) }
end
context 'when deployment status is success' do
let(:deployment) { create(:deployment, :success, finished_at: nil) }
before do
deployment.update_column(:finished_at, nil)
end
it { is_expected.to eq(deployment.read_attribute(:created_at)) }
end
context 'when deployment status is running' do
let(:deployment) { create(:deployment, :running) }
it { is_expected.to be_nil }
end
end
describe '#deployed_at' do
subject { deployment.deployed_at }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment