Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥔✨ Journal: Strip whitespace from slug, headline, and name #1637

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/furniture/journal/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/furniture/journal/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
5 changes: 5 additions & 0 deletions spec/support/strip_attributes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "strip_attributes/matchers"

RSpec.configure do |config|
config.include StripAttributes::Matchers
end