diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-11-20 16:14:22 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-11-20 16:14:22 +0000 |
commit | fcb6cdd6342d0272a8e7f05d20a4b0d87da70de9 (patch) | |
tree | 48ea4a5a796c4e95d26e4d4f36170ac09d368637 /spec/models/info_request_event_spec.rb | |
parent | b0d9551a83c4a101ac808f1c35f66dd138cbc0f1 (diff) | |
parent | 24c3ceb2315734ab6e43ae4f75673e251b98a96e (diff) |
Merge remote-tracking branch 'origin/feature/isolate-mail-handling' into develop
Diffstat (limited to 'spec/models/info_request_event_spec.rb')
-rw-r--r-- | spec/models/info_request_event_spec.rb | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 7352f3be0..796f8b840 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -54,36 +54,71 @@ describe InfoRequestEvent do end - describe "doing search/index stuff" do + describe "doing search/index stuff" do before(:each) do load_raw_emails_data parse_all_incoming_messages end - it 'should get search text for outgoing messages' do + it 'should get search text for outgoing messages' do event = info_request_events(:useless_outgoing_message_event) message = outgoing_messages(:useless_outgoing_message).body event.search_text_main.should == message + "\n\n" end - it 'should get search text for incoming messages' do + it 'should get search text for incoming messages' do event = info_request_events(:useless_incoming_message_event) event.search_text_main.strip.should == "No way! I'm not going to tell you that in a month of Thursdays.\n\nThe Geraldine Quango" end - it 'should get clipped text for incoming messages, and cache it too' do + it 'should get clipped text for incoming messages, and cache it too' do event = info_request_events(:useless_incoming_message_event) - + event.incoming_message_selective_columns("cached_main_body_text_folded").cached_main_body_text_folded = nil event.search_text_main(true).strip.should == "No way! I'm not going to tell you that in a month of Thursdays.\n\nThe Geraldine Quango" event.incoming_message_selective_columns("cached_main_body_text_folded").cached_main_body_text_folded.should_not == nil end - end + describe 'when asked if it has the same email as a previous send' do + + before do + @info_request_event = InfoRequestEvent.new + end + + it 'should return true if the email in its params and the previous email the request was sent to are both nil' do + @info_request_event.stub!(:params).and_return({}) + @info_request_event.stub_chain(:info_request, :get_previous_email_sent_to).and_return(nil) + @info_request_event.same_email_as_previous_send?.should be_true + end + + it 'should return false if one email address exists and the other does not' do + @info_request_event.stub!(:params).and_return(:email => 'test@example.com') + @info_request_event.stub_chain(:info_request, :get_previous_email_sent_to).and_return(nil) + @info_request_event.same_email_as_previous_send?.should be_false + end + it 'should return true if the addresses are identical' do + @info_request_event.stub!(:params).and_return(:email => 'test@example.com') + @info_request_event.stub_chain(:info_request, :get_previous_email_sent_to).and_return('test@example.com') + @info_request_event.same_email_as_previous_send?.should be_true + end + + it 'should return false if the addresses are different' do + @info_request_event.stub!(:params).and_return(:email => 'test@example.com') + @info_request_event.stub_chain(:info_request, :get_previous_email_sent_to).and_return('different@example.com') + @info_request_event.same_email_as_previous_send?.should be_false + end + + it 'should return true if the addresses have different formats' do + @info_request_event.stub!(:params).and_return(:email => 'A Test <test@example.com>') + @info_request_event.stub_chain(:info_request, :get_previous_email_sent_to).and_return('test@example.com') + @info_request_event.same_email_as_previous_send?.should be_true + end + + end end |