From a77243d9f6d6a7abe9fd3f966536420ac3c73981 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 14 Feb 2013 18:14:57 +0000 Subject: Rename spec file so that it's picked up by rake spec. --- spec/script/mailin_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/script/mailin_spec.rb (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb new file mode 100644 index 000000000..d80789635 --- /dev/null +++ b/spec/script/mailin_spec.rb @@ -0,0 +1,21 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require "external_command" + +def mailin_test(email_filename) + Dir.chdir Rails.root do + xc = ExternalCommand.new("script/mailin") + xc.run(load_file_fixture(email_filename)) + xc.err.should == "" + return xc + end +end + +describe "When importing mail into the application" do + + it "should not produce any output and should return a 0 code on importing a plain email" do + r = mailin_test("incoming-request-plain.email") + r.status.should == 0 + r.out.should == "" + end + +end \ No newline at end of file -- cgit v1.2.3 From 2fa740f048b27dc7c78b426e8f9d938405cdff6f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Sat, 16 Feb 2013 18:39:04 +0000 Subject: Direct the incoming mail to a fixture info_request so that it doesn't affect the holding pen if run before other tests that count holding pen entries. --- spec/script/mailin_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index d80789635..53f4ae125 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -4,7 +4,11 @@ require "external_command" def mailin_test(email_filename) Dir.chdir Rails.root do xc = ExternalCommand.new("script/mailin") - xc.run(load_file_fixture(email_filename)) + mail = load_file_fixture(email_filename) + ir = info_requests(:boring_request) + mail.gsub!('EMAIL_TO', ir.incoming_email) + mail.gsub!('EMAIL_FROM', 'geraldinequango@localhost') + xc.run(mail) xc.err.should == "" return xc end @@ -18,4 +22,4 @@ describe "When importing mail into the application" do r.out.should == "" end -end \ No newline at end of file +end -- cgit v1.2.3 From d37a185ed8312b2c6834b9c88812ad547477cdc2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Sat, 16 Feb 2013 19:30:34 +0000 Subject: Don't use a from address that will affect other tests. --- spec/script/mailin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index 53f4ae125..f9368996d 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -7,7 +7,7 @@ def mailin_test(email_filename) mail = load_file_fixture(email_filename) ir = info_requests(:boring_request) mail.gsub!('EMAIL_TO', ir.incoming_email) - mail.gsub!('EMAIL_FROM', 'geraldinequango@localhost') + mail.gsub!('EMAIL_FROM', 'responder@localhost') xc.run(mail) xc.err.should == "" return xc -- cgit v1.2.3 From b6686781bd378c44e7ccf3557969547c61e9248f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Sun, 17 Feb 2013 14:18:29 +0000 Subject: Use an empty incoming email to avoid interaction with other tests. --- spec/script/mailin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index f9368996d..f0bca2297 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -17,7 +17,7 @@ end describe "When importing mail into the application" do it "should not produce any output and should return a 0 code on importing a plain email" do - r = mailin_test("incoming-request-plain.email") + r = mailin_test("incoming-request-empty.email") r.status.should == 0 r.out.should == "" end -- cgit v1.2.3 From 84e81cbd2b0f98196050d3f5f758ced8a4f841df Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 11 Mar 2013 16:22:51 -0700 Subject: Add some more fixtures so that spec/script/mailin_spec.rb won't interfere with other tests. --- spec/script/mailin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index f0bca2297..ac04dcfcf 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -5,7 +5,7 @@ def mailin_test(email_filename) Dir.chdir Rails.root do xc = ExternalCommand.new("script/mailin") mail = load_file_fixture(email_filename) - ir = info_requests(:boring_request) + ir = info_requests(:other_request) mail.gsub!('EMAIL_TO', ir.incoming_email) mail.gsub!('EMAIL_FROM', 'responder@localhost') xc.run(mail) -- cgit v1.2.3 From 0735585de2d037e3b7495d701f2f2e199f483889 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 12 Mar 2013 09:35:47 -0700 Subject: Turn off transactional fixtures and fully destroy the message we import in order to cleanup the data created by this test. --- spec/script/mailin_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/script/mailin_spec.rb') diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index ac04dcfcf..acd06ff3b 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -16,10 +16,22 @@ end describe "When importing mail into the application" do + # Turn off transactional fixtures for this suite - incoming message is imported + # outside the transaction via ExternalCommand, so needs to be destroyed outside the + # transaction + self.use_transactional_fixtures = false + it "should not produce any output and should return a 0 code on importing a plain email" do r = mailin_test("incoming-request-empty.email") r.status.should == 0 r.out.should == "" end + # Destroy the incoming message so that it doesn't affect other tests + after do + ir = info_requests(:other_request) + incoming_message = ir.incoming_messages[0] + incoming_message.fully_destroy + end + end -- cgit v1.2.3