Welcome to mirror list, hosted at ThFree Co, Russian Federation.

querying_shared_examples.rb « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1f554ddb44158946af827c5a249a08853c890869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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