aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2012-10-10 09:12:28 +1100
committerMatthew Landauer <matthew@openaustralia.org>2012-10-10 09:12:28 +1100
commit4047684a7b3ae795852711af747402ab6aceae16 (patch)
treedab9a59c941e91eb3c84c996a6d64fe8417ef890
parentd23ea224d976115f6a1e83d34c878b4a0e42c924 (diff)
Added test for EximLog.load_file
-rw-r--r--spec/models/exim_log_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/exim_log_spec.rb b/spec/models/exim_log_spec.rb
new file mode 100644
index 000000000..f4fc984e9
--- /dev/null
+++ b/spec/models/exim_log_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe EximLog do
+ describe ".load_file" do
+ it "loads relevant lines of an uncompressed exim log file" do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ File.stub_chain(:stat, :mtime).and_return(Date.new(2012, 10, 10))
+ log = ["This is a line of a logfile relevant to foi+request-1234@example.com"]
+ File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").and_return(log)
+ ir = info_requests(:fancy_dog_request)
+ InfoRequest.should_receive(:find_by_incoming_email).with("request-1234@example.com").and_return(ir)
+ EximLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10")
+
+ ir.exim_logs.count.should == 1
+ log = ir.exim_logs.first
+ log.order.should == 1
+ log.line.should == "This is a line of a logfile relevant to foi+request-1234@example.com"
+ end
+ end
+end