diff --git a/app/furniture/journal/entry.rb b/app/furniture/journal/entry.rb index 7c6b2de63..1c4ab0fd4 100644 --- a/app/furniture/journal/entry.rb +++ b/app/furniture/journal/entry.rb @@ -17,6 +17,8 @@ class Entry < ApplicationRecord attribute :slug, :string validates :slug, uniqueness: {scope: :journal_id} + strip_attributes only: [:body, :headline, :slug] + # FriendlyId does the legwork to make the slug uri-friendly extend FriendlyId friendly_id :headline, use: :scoped, scope: :journal diff --git a/spec/furniture/journal/entry_spec.rb b/spec/furniture/journal/entry_spec.rb index 0e0d660fc..bde0cc87d 100644 --- a/spec/furniture/journal/entry_spec.rb +++ b/spec/furniture/journal/entry_spec.rb @@ -5,6 +5,7 @@ it { is_expected.to validate_presence_of(:headline) } it { is_expected.to validate_presence_of(:body) } + it { is_expected.to strip_attributes(:slug, :body, :headline) } describe "#to_html" do subject(:to_html) { entry.to_html } diff --git a/spec/support/strip_attributes.rb b/spec/support/strip_attributes.rb new file mode 100644 index 000000000..e3e0ca552 --- /dev/null +++ b/spec/support/strip_attributes.rb @@ -0,0 +1,5 @@ +require "strip_attributes/matchers" + +RSpec.configure do |config| + config.include StripAttributes::Matchers +end