-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from IFTTT/fix-custom-strategies
Fix Custom Strategy
- Loading branch information
Showing
4 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,18 +28,20 @@ | |
end | ||
|
||
defaults = Polo.defaults | ||
expect(defaults.blacklist).to eq([:email, :password]) | ||
expect(defaults.blacklist).to eq({ :email => nil, :password => nil }) | ||
end | ||
|
||
it 'allows for the user to define fields with strategies in blacklist' do | ||
Polo.configure do | ||
|
||
email_strategy = lambda {|e| "#{e.split("@")[0]}[email protected]" } | ||
credit_card_strategy = lambda {|_| "4111111111111111"} | ||
|
||
obfuscate({email: email_strategy, credit_card: credit_card_strategy}) | ||
end | ||
|
||
defaults = Polo.defaults | ||
expect(defaults.blacklist.first[:email].call("[email protected]")).to eq("[email protected]") | ||
expect(defaults.blacklist[:email].call("[email protected]")).to eq("[email protected]") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,16 @@ | |
expect(scrambled_email).to_not eq('[email protected]') | ||
expect(insert).to match(exp.first) | ||
end | ||
|
||
it 'can apply custom strategies' do | ||
Polo.configure do | ||
obfuscate(email: lambda { |_| 'changeme' }) | ||
end | ||
|
||
inserts = Polo.explore(AR::Chef, 1) | ||
|
||
expect(inserts).to eq [ %q{INSERT INTO `chefs` (`id`, `name`, `email`) VALUES (1, 'Netto', 'changeme')} ] | ||
end | ||
end | ||
|
||
describe 'on_duplicate' do | ||
|