Silence CSS logging in development - it's way too noisy

This commit is contained in:
Robin Ward 2017-08-16 10:59:38 -04:00
parent c68999e128
commit b78958fbfc
3 changed files with 13 additions and 3 deletions

View File

@ -22,6 +22,7 @@ export default {
// Observe file changes
messageBus.subscribe("/file-change", function(data) {
if (Handlebars.compile && !Ember.TEMPLATES.empty) {
// hbs notifications only happen in dev
Ember.TEMPLATES.empty = Handlebars.compile("<div></div>");

View File

@ -4,9 +4,14 @@ class StylesheetCache < ActiveRecord::Base
MAX_TO_KEEP = 50
def self.add(target, digest, content, source_map)
old_logger = ActiveRecord::Base.logger
return false if where(target: target, digest: digest).exists?
if Rails.env.development?
ActiveRecord::Base.logger = nil
end
success = create(target: target, digest: digest, content: content, source_map: source_map)
count = StylesheetCache.count
@ -25,6 +30,10 @@ class StylesheetCache < ActiveRecord::Base
success
rescue ActiveRecord::RecordNotUnique
false
ensure
if Rails.env.development? && old_logger
ActiveRecord::Base.logger = old_logger
end
end
end

View File

@ -15,10 +15,10 @@ describe StylesheetCache do
end
it "does nothing if digest is set and already exists" do
StylesheetCache.destroy_all
StylesheetCache.delete_all
StylesheetCache.add("a", "b", "c", "map")
StylesheetCache.add("a", "b", "cc", "map")
expect(StylesheetCache.add("a", "b", "c", "map")).to be_present
expect(StylesheetCache.add("a", "b", "cc", "map")).to eq(false)
expect(StylesheetCache.count).to eq 1
expect(StylesheetCache.first.content).to eq "c"