Skip to content

Instantly share code, notes, and snippets.

@nettofarah
Created December 4, 2015 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nettofarah/9c83964b0eeef291d9fc to your computer and use it in GitHub Desktop.
Save nettofarah/9c83964b0eeef291d9fc to your computer and use it in GitHub Desktop.
Testing Polo with custom obfuscation strategy
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord'
gem 'polo', github: 'IFTTT/polo'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :password_digest
end
end
class User < ActiveRecord::Base
end
class BugTest < Minitest::Test
def setup
User.create(name: 'netto', password_digest: 'blablabla')
end
def test_configuration
Polo.configure do
obfuscate password_digest: -> {'changeme'}
end
inserts = Polo.explore(User, 1)
assert_equal inserts, [ %q{INSERT INTO `users` (`id`, `name`, `password_digest`) VALUES (1, 'netto', 'blablabla')} ]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment