FIX: blanking theme field was not properly removing it
This commit is contained in:
parent
9927489f4e
commit
809fbb25ce
|
@ -213,7 +213,7 @@ class Theme < ActiveRecord::Base
|
||||||
field = theme_fields.find{|f| f.name==name && f.target == target_id}
|
field = theme_fields.find{|f| f.name==name && f.target == target_id}
|
||||||
if field
|
if field
|
||||||
if value.blank?
|
if value.blank?
|
||||||
field.destroy
|
theme_fields.delete field.destroy
|
||||||
else
|
else
|
||||||
if field.value != value
|
if field.value != value
|
||||||
field.value = value
|
field.value = value
|
||||||
|
|
|
@ -69,7 +69,7 @@ describe Admin::ThemesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates a theme' do
|
it 'updates a theme' do
|
||||||
|
#focus
|
||||||
theme = Theme.new(name: 'my name', user_id: -1)
|
theme = Theme.new(name: 'my name', user_id: -1)
|
||||||
theme.set_field(:common, :scss, '.body{color: black;}')
|
theme.set_field(:common, :scss, '.body{color: black;}')
|
||||||
theme.save
|
theme.save
|
||||||
|
@ -80,7 +80,10 @@ describe Admin::ThemesController do
|
||||||
theme: {
|
theme: {
|
||||||
child_theme_ids: [child_theme.id],
|
child_theme_ids: [child_theme.id],
|
||||||
name: 'my test name',
|
name: 'my test name',
|
||||||
theme_fields: [name: 'scss', target: 'common', value: 'body{color: red;}']
|
theme_fields: [
|
||||||
|
{ name: 'scss', target: 'common', value: '' },
|
||||||
|
{ name: 'scss', target: 'desktop', value: 'body{color: blue;}' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
||||||
|
@ -88,8 +91,8 @@ describe Admin::ThemesController do
|
||||||
|
|
||||||
fields = json["theme"]["theme_fields"]
|
fields = json["theme"]["theme_fields"]
|
||||||
|
|
||||||
|
expect(fields.first["value"]).to eq('body{color: blue;}')
|
||||||
expect(fields.length).to eq(1)
|
expect(fields.length).to eq(1)
|
||||||
expect(fields.first["value"]).to eq('body{color: red;}')
|
|
||||||
|
|
||||||
expect(json["theme"]["child_themes"].length).to eq(1)
|
expect(json["theme"]["child_themes"].length).to eq(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue