diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 11:00:37 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 11:00:37 +1100 |
commit | fe44b665147ed9422998b8a35982fb25ee68eb1e (patch) | |
tree | 7387ca85bf0e9ef85e0f592fc080e10a8ad33295 | |
parent | fa4d356514c2fab1a55c2bb5e9d6eebb01624354 (diff) |
Added tests for reloading same log file
-rw-r--r-- | spec/models/exim_log_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/exim_log_spec.rb b/spec/models/exim_log_spec.rb index 3151bcbe8..8a879bcbc 100644 --- a/spec/models/exim_log_spec.rb +++ b/spec/models/exim_log_spec.rb @@ -23,5 +23,21 @@ describe EximLog do log.order.should == 2 log.line.should == "This is the second line for the same foi+request-1234@example.com email address" end + + it "doesn't load the log file twice if it's unchanged" do + File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 10)) + File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").once.and_return([]) + + EximLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10") + EximLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10") + end + + it "loads the log file again if it's changed" do + File.should_receive(:open).with("/var/log/exim4/exim-mainlog-2012-10-10", "r").twice.and_return([]) + File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 10)) + EximLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10") + File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 11)) + EximLog.load_file("/var/log/exim4/exim-mainlog-2012-10-10") + end end end |