Commit abad5ea8 authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-remove-deprecation-warning-commit-status' into 'master'

Remove Rails deprecation warning in CommitStatus

See merge request gitlab-org/gitlab!27283
parents 1a707d90 e24e5046
......@@ -62,13 +62,16 @@ class CommitStatus < ApplicationRecord
preload(project: :namespace)
end
scope :match_id_and_lock_version, -> (slice) do
scope :match_id_and_lock_version, -> (items) do
# it expects that items are an array of attributes to match
# each hash needs to have `id` and `lock_version`
slice.inject(self) do |relation, item|
match = CommitStatus.where(item.slice(:id, :lock_version))
or_conditions = items.inject(none) do |relation, item|
match = CommitStatus.default_scoped.where(item.slice(:id, :lock_version))
relation.or(match)
end
merge(or_conditions)
end
# We use `CommitStatusEnums.failure_reasons` here so that EE can more easily
......
......@@ -449,6 +449,19 @@ describe CommitStatus do
end
end
describe '.match_id_and_lock_version' do
let(:status_1) { create_status(lock_version: 1) }
let(:status_2) { create_status(lock_version: 2) }
it 'returns statuses that match the given id and lock versions' do
params = [
{ id: status_1.id, lock_version: 1 },
{ id: status_2.id, lock_version: 3 }
]
expect(described_class.match_id_and_lock_version(params)).to contain_exactly(status_1)
end
end
describe '#before_sha' do
subject { commit_status.before_sha }
......
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