From 5365973c0ac6c00c8a554e0e23682e9f9493ef05 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 20 Apr 2017 16:55:09 -0400 Subject: [PATCH] FIX: detection of error changed, so you can clear errors --- app/models/theme_field.rb | 8 +++++--- spec/models/theme_field_spec.rb | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb index 9f80dd1c567..65b89db5143 100644 --- a/app/models/theme_field.rb +++ b/app/models/theme_field.rb @@ -95,10 +95,12 @@ COMPILED self.error = nil unless error.nil? rescue SassC::SyntaxError => e self.error = e.message - if error_changed? - update_columns(error: self.error) - end end + + if error_changed? + update_columns(error: self.error) + end + end end diff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rb index abd341f07d7..f120526e1c1 100644 --- a/spec/models/theme_field_spec.rb +++ b/spec/models/theme_field_spec.rb @@ -21,8 +21,10 @@ HTML field = ThemeField.create!(theme_id: 1, target: 0, name: "scss", value: css) field.reload expect(field.error).not_to eq(nil) - field.value = "" + field.value = "body {color: blue};" field.save! + field.reload + expect(field.error).to eq(nil) end end