diff options
author | francis <francis> | 2008-06-11 15:00:35 +0000 |
---|---|---|
committer | francis <francis> | 2008-06-11 15:00:35 +0000 |
commit | 50ef06b630cd9847c68ab36e459d879b51539fe6 (patch) | |
tree | f460014ffbf9db241a18baea95ddc1f2cdf0c78c /spec/models | |
parent | 75be1213513666c720c3b4a7f3c06a0d9d2b5e6b (diff) |
Cope with mistyped l instead of 1, and o instead of 0 in request emails.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/info_request_spec.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 8c968ef3b..0c76c3176 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe InfoRequest, " when emailing" do - fixtures :info_requests + fixtures :info_requests, :public_bodies, :users before do @info_request = info_requests(:fancy_dog_request) @@ -23,6 +23,26 @@ describe InfoRequest, " when emailing" do found_info_request.should == (@info_request) end + it "should recognise l and 1 as the same in incoming emails" do + # Make info request with a 1 in it + while true + ir = InfoRequest.new(:title => "testing", :public_body => public_bodies(:geraldine_public_body), + :user => users(:bob_smith_user)) + ir.save! + hash_part = ir.incoming_email.match(/-[0-9a-f]+@/)[0] + break if hash_part.match(/1/) + end + + # Make email with a 1 in the hash part changed to l + test_email = ir.incoming_email + new_hash_part = hash_part.gsub(/1/, "l") + test_email.gsub!(hash_part, new_hash_part) + + # Try and find with an l + found_info_request = InfoRequest.find_by_incoming_email(test_email) + found_info_request.should == (ir) + end + it "should recognise old style request-bounce- addresses" do incoming_email = @info_request.magic_email("request-bounce-") found_info_request = InfoRequest.find_by_incoming_email(incoming_email) |