Sha256: ada915269d807e1f1a33c82f37c025eaed3f7b15795e5aca9ee22b2ec8854b76

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

require 'spec_helper'
require 'active_record/pgcrypto/log_subscriber'

RSpec.describe ActiveRecord::PGCrypto::LogSubscriber do
  let(:pgcrypto_key) { FFaker::Internet.password }
  let(:subscriber) { ActiveRecord::LogSubscriber.new }
  let(:event_payload) do
    { sql: "SELECT PGP_SYM_ENCRYPT_BYTEA('data', '#{pgcrypto_key}')" }
  end
  let(:event) do
    ActiveSupport::Notifications::Event.new(:test, 0, 0, :id, event_payload)
  end

  before do
    ActiveRecord::PGCrypto.enable_log_subscriber!
  end

  it do
    subscriber.sql(event)

    expect(event.payload[:sql]).not_to include(pgcrypto_key)
    expect(event.payload[:sql]).to include(described_class::PLACEHOLDER)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_record-pgcrypto-0.2.6 spec/active_record/pgcrypto/log_subscriber_spec.rb
active_record-pgcrypto-0.2.5 spec/active_record/pgcrypto/log_subscriber_spec.rb