Skip to content

Commit

Permalink
Allowed things that belong_to_app to have their own log
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Evans committed May 3, 2010
1 parent 96bac6f commit ac7ec8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/dragonfly/belongs_to_app.rb
@@ -1,3 +1,5 @@
require 'logger'

module Dragonfly
module BelongsToApp

Expand All @@ -15,7 +17,7 @@ def app_set?
end

def log
app.log
app_set? ? app.log : (@log ||= Logger.new(STDOUT))
end

end
Expand Down
13 changes: 12 additions & 1 deletion spec/dragonfly/belongs_to_app_spec.rb
Expand Up @@ -19,11 +19,22 @@ class Testoast
it "should say it's not set" do
@object.app_set?.should be_false
end
it "should still return a log" do
@object.log.should be_a(Logger)
end
it "should cache the log" do
@object.log.should == @object.log
end
it "should return the app's log if it's subsequently set" do
@object.log.should be_a(Logger)
@object.app = (app = mock('app', :log => mock))
@object.log.should == app.log
end
end

describe "when the app is set" do
before(:each) do
@app = Dragonfly::App[:test]
@app = mock('app', :log => mock)
@object.app = @app
end

Expand Down

0 comments on commit ac7ec8d

Please sign in to comment.