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

does not modify source column during normalization #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.2
2 changes: 1 addition & 1 deletion lib/slug/slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def set_slug(opts={})
validate_slug_columns
return if self[self.slug_column].present? && !opts[:force]

self[self.slug_column] = normalize_slug(self.send(self.slug_source))
self[self.slug_column] = normalize_slug(self.send(self.slug_source).dup)

# if normalize_slug returned a blank string, try the generic_default handling
if generic_default && self[self.slug_column].blank?
Expand Down
5 changes: 5 additions & 0 deletions test/slug_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
assert_equal(orphan.id.to_s, query)
end

it "does not modify the source column" do
article = Article.create(headline: 'A long, complex, headline')
assert_equal('A long, complex, headline', article.headline)
end

describe "slug column" do
it "saves slug to 'slug' column by default" do
article = Article.create!(:headline => 'Test Headline')
Expand Down