Commit 458ee618 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'drop-legacy-deployed-at' into 'master'

Drop legacy finished at in Deployment

See merge request gitlab-org/gitlab!73172
parents 633d1197 b8f911e2
......@@ -294,10 +294,6 @@ class Deployment < ApplicationRecord
@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?
......@@ -405,10 +401,6 @@ class Deployment < ApplicationRecord
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')
......@@ -132,6 +132,29 @@ RSpec.describe 'Environment' do
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) }
......
......@@ -369,38 +369,6 @@ RSpec.describe Deployment do
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 }
......
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