Skip to content

Commit

Permalink
Merge pull request #324 from noahhaon/fix_log_silently_upstream
Browse files Browse the repository at this point in the history
Fix config.log_silently?
  • Loading branch information
PikachuEXE committed Apr 12, 2016
2 parents 051c384 + 7bc2054 commit 46cfb5f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/asset_sync/asset_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def warn(msg)
end

def log(msg)
stdout.puts msg if config.log_silently?
stdout.puts msg unless config.log_silently?
end

def enabled?
Expand Down
2 changes: 1 addition & 1 deletion lib/asset_sync/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def fail_silently?
end

def log_silently?
ENV['RAILS_GROUPS'] == 'assets' || self.log_silently == false
ENV['RAILS_GROUPS'] == 'assets' || !!self.log_silently
end

def enabled?
Expand Down
12 changes: 12 additions & 0 deletions spec/unit/asset_sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@
it "should default log_silently to true" do
expect(AssetSync.config.log_silently).to be_truthy
end

it "log_silently? should reflect the configuration" do
AssetSync.config.log_silently = false
expect(AssetSync.config.log_silently?).to eq(false)
end

it "log_silently? should always be true if ENV['RAILS_GROUPS'] == 'assets'" do
AssetSync.config.log_silently = false
# make sure ENV is actually being checked ...
expect(ENV).to receive(:[]).with('RAILS_GROUPS').and_return('assets')
expect(AssetSync.config.log_silently?).to eq(true)
end

it "should default cdn_distribution_id to nil" do
expect(AssetSync.config.cdn_distribution_id).to be_nil
Expand Down

0 comments on commit 46cfb5f

Please sign in to comment.