diff options
Diffstat (limited to 'spec/models/info_request_spec.rb')
-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) |