diff --git a/app/assets/javascripts/discourse/initializers/live-development.js.es6 b/app/assets/javascripts/discourse/initializers/live-development.js.es6 index 79b200107a7..c6dba5fdfcf 100644 --- a/app/assets/javascripts/discourse/initializers/live-development.js.es6 +++ b/app/assets/javascripts/discourse/initializers/live-development.js.es6 @@ -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("
"); diff --git a/app/models/stylesheet_cache.rb b/app/models/stylesheet_cache.rb index c545b04c8ae..08b98c30859 100644 --- a/app/models/stylesheet_cache.rb +++ b/app/models/stylesheet_cache.rb @@ -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 diff --git a/spec/models/stylesheet_cache_spec.rb b/spec/models/stylesheet_cache_spec.rb index 480fd86259c..bffa8564d84 100644 --- a/spec/models/stylesheet_cache_spec.rb +++ b/spec/models/stylesheet_cache_spec.rb @@ -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"