aboutsummaryrefslogtreecommitdiffstats
path: root/spec/script
diff options
context:
space:
mode:
Diffstat (limited to 'spec/script')
-rw-r--r--spec/script/mailin-spec.rb21
-rw-r--r--spec/script/mailin_spec.rb37
2 files changed, 37 insertions, 21 deletions
diff --git a/spec/script/mailin-spec.rb b/spec/script/mailin-spec.rb
deleted file mode 100644
index d80789635..000000000
--- a/spec/script/mailin-spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-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
diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb
new file mode 100644
index 000000000..acd06ff3b
--- /dev/null
+++ b/spec/script/mailin_spec.rb
@@ -0,0 +1,37 @@
+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")
+ mail = load_file_fixture(email_filename)
+ ir = info_requests(:other_request)
+ mail.gsub!('EMAIL_TO', ir.incoming_email)
+ mail.gsub!('EMAIL_FROM', 'responder@localhost')
+ xc.run(mail)
+ xc.err.should == ""
+ return xc
+ end
+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