Skip to content

Commit

Permalink
Add spec that should fail
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Aug 4, 2018
1 parent f5d952f commit d5cb148
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions spec/friendly_id/mobility_spec.rb
Expand Up @@ -226,6 +226,19 @@
expect(Post.friendly.find("new-title")).to eq(Post.last)
end
end

# Ref: https://github.com/shioyama/friendly_id-mobility/issues/10
it "regenerates slug records for all locales with present values" do
post = Post.new(title_en: "English title", title_es: "Título español")
post.save

post.slug_en = nil
post.slug_es = nil
post.save

expect(post.slug_en).to eq("english-title")
expect(post.slug_es).to eq("titulo-espanol")
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -86,8 +86,8 @@ class Article < ActiveRecord::Base

class Post < ActiveRecord::Base
extend Mobility
translates :slug, :title, type: :string, dirty: true, backend: :key_value
translates :content, type: :text, dirty: true, backend: :key_value
translates :slug, :title, type: :string, dirty: true, backend: :key_value, locale_accessors: true
translates :content, type: :text, dirty: true, backend: :key_value, locale_accessors: true

extend FriendlyId
friendly_id :title, use: [:history, :mobility]
Expand Down

0 comments on commit d5cb148

Please sign in to comment.