Commit 65d1adb6 authored by Furkan Ayhan's avatar Furkan Ayhan Committed by Lin Jen-Shin

Fix update-older-statuses query

It was wrongly trying to update all statuses
parent d48de25d
...@@ -293,7 +293,8 @@ class CommitStatus < ApplicationRecord ...@@ -293,7 +293,8 @@ class CommitStatus < ApplicationRecord
end end
def update_older_statuses_retried! def update_older_statuses_retried!
self.class pipeline
.statuses
.latest .latest
.where(name: name) .where(name: name)
.where.not(id: id) .where.not(id: id)
......
...@@ -870,4 +870,23 @@ RSpec.describe CommitStatus do ...@@ -870,4 +870,23 @@ RSpec.describe CommitStatus do
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
end end
describe '#update_older_statuses_retried!' do
let!(:build_old) { create_status(name: 'build') }
let!(:build_new) { create_status(name: 'build') }
let!(:test) { create_status(name: 'test') }
let!(:build_from_other_pipeline) do
new_pipeline = create(:ci_pipeline, project: project, sha: project.commit.id)
create_status(name: 'build', pipeline: new_pipeline)
end
it "updates 'retried' and 'status' columns of the latest status with the same name in the same pipeline" do
build_new.update_older_statuses_retried!
expect(build_new.reload).to have_attributes(retried: false, processed: false)
expect(build_old.reload).to have_attributes(retried: true, processed: true)
expect(test.reload).to have_attributes(retried: false, processed: false)
expect(build_from_other_pipeline.reload).to have_attributes(retried: false, processed: false)
end
end
end end
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