Permalink
Browse files

make sure that we use strings and not strings/symbols when we compare…

… the locales of a site
  • Loading branch information...
did committed Mar 9, 2017
1 parent f733772 commit f78bc497e45d0a717856d418828deea9eaa3df12
Showing with 3 additions and 1 deletion.
  1. +1 −1 app/models/locomotive/concerns/site/locales.rb
  2. +2 −0 spec/models/locomotive/site_spec.rb
@@ -109,7 +109,7 @@ def add_default_locale
end
def can_not_remove_default_locale
if self.persisted? && !self.locales.include?(self.default_locale_was)
if self.persisted? && !self.locales.map(&:to_s).include?(self.default_locale_was.to_s)
self.errors.add :locales, I18n.t(:default_locale_removed, scope: [:errors, :messages, :site])
end
end
@@ -147,6 +147,8 @@
it 'does not allow to remove the default locale' do
site.update_attributes locales: %w(fr)
expect(site.errors[:locales]).to eq(['The previous default locale can not be removed right away.'])
site.update_attributes locales: [:en]
expect(site.errors[:locales]).to eq []
end
end

0 comments on commit f78bc49

Please sign in to comment.