debian-mirror-gitlab/spec/support/shared_examples/querying_shared_examples.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
605 B
Ruby
Raw Permalink Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
def update_column_regex(column)
/UPDATE.+SET.+#{column}[^=*]=.+FROM.*/m
end
RSpec.shared_examples 'update on column' do |column|
it "#{column} column updated" do
qr = ActiveRecord::QueryRecorder.new do
subject
end
expect(qr.log).to include a_string_matching update_column_regex(column)
end
end
RSpec.shared_examples 'no update on column' do |column|
it "#{column} column is not updated" do
qr = ActiveRecord::QueryRecorder.new do
subject
end
expect(qr.log).not_to include a_string_matching update_column_regex(column)
end
end