Skip to content

Commit

Permalink
Merge pull request #11 from ChalkSchools/jt-uniq
Browse files Browse the repository at this point in the history
Do not return duplicate 'good' emails when repairing a collection
  • Loading branch information
mockdeep authored Jun 29, 2016
2 parents a15c873 + 781dacd commit d399bb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/email_repair/mechanic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def repair_all(emails)
end

OpenStruct.new(
sanitized_emails: sanitized_emails,
invalid_emails: invalid_emails,
sanitized_emails: sanitized_emails.uniq,
invalid_emails: invalid_emails.uniq,
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/email_repair/mechanic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module EmailRepair

it 'sanitizes an array of emails and returns bulk results' do
mechanic = Mechanic.new
salvageable_emails = %w(One@@two.com three@four.com)
salvageable_emails = %w(One@@two.com three@four.com one@twO.com)
sanitized_emails = %w(one@two.com three@four.com)
bad_emails = %w(bleep@blop plooooooop)
bad_emails = %w(bleep@blop plooooooop plooOOooop)

result = mechanic.repair_all(salvageable_emails + bad_emails)
expect(result.sanitized_emails).to match_array sanitized_emails
Expand Down

0 comments on commit d399bb5

Please sign in to comment.