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

Default Locale Slug is emptied, when another Locale has the same value #184

Open
wzowee opened this issue Mar 28, 2015 · 8 comments
Open
Labels

Comments

@wzowee
Copy link

wzowee commented Mar 28, 2015

When creating a document with a localized title and slug based off of this title, if only the english locale value is set first, and then another locale is set with the same value - the english slug value is removed.

This is very similar to an older issue #153 however the flow that surfaces it is.

page = PageSlugLocalized.create!(title:"Title On English") 
# page["_slugs"] returns {"en" => ["title-on-english"]}

# Switch Locales
I18n.locale = "nl"
page.update_attributes(title:"Title On English")

# page["_slugs"] now returns {"en" => [], "nl" => ["title-on-english"]} 

Some environment versions:
Rails 4.2.0
Ruby 2.1.1p76
mongoid-slug (4.0.0)

@onomated
Copy link

+1

@dblock
Copy link
Collaborator

dblock commented Sep 22, 2015

Care to write a spec for this, @wzowee or @onomated. Lets fix it.

@wzowee
Copy link
Author

wzowee commented Sep 22, 2015

Have created a spec based on my issue description above - it's passing 👍 I should be back in the code base where I was having this issue originally this week so will check in see if it's still a problem and if the spec correctly covers the issue I'm seeing there.

wzowee added a commit to wzowee/mongoid-slug that referenced this issue Sep 23, 2015
@wzowee
Copy link
Author

wzowee commented Sep 23, 2015

Ok I can reproduce the error now - I have I18n Fallbacks enabled and this is causing the issue.

See my recent commit where all I have done is added a require to "i18n/backend/fallbacks" this is enough to cause a number of specs to fail, in my actual app I also have the fallbacks properly mapped but adding the require here has been enough to cause the issue.

If I comment out the following line https://github.com/digitalplaywright/mongoid-slug/blob/master/lib/mongoid/slug.rb#L183 then the new spec passes but others of course fail.

@dblock
Copy link
Collaborator

dblock commented Sep 23, 2015

This is helpful, @wzowee do you think you can turn this into a single failing spec in this project? I mean something we'll be able to commit with a fix?

@wzowee
Copy link
Author

wzowee commented Sep 24, 2015

I've broken this out into a seperate fallback_spec.rb spec in my fork. However there is an issue where the use of require "i18n/backend/fallbacks" in fallback_spec.rb is causing tests in slug_spec.rb to fail. I'm unsure of a way to correctly isolate the inclusion of I18n Fallbacks - have asked a question on stack overflow - http://stackoverflow.com/questions/32750536/isolate-a-required-class-within-the-scope-of-a-single-spec - but no response. Any thoughts?

@dblock
Copy link
Collaborator

dblock commented Sep 24, 2015

I think there's no way to unload something easily without having intimate knowledge of it, but maybe there's a way to do two test runs in Rakefile? Either way we need to understand why it's failing and fix it now :)

@dblock
Copy link
Collaborator

dblock commented Sep 9, 2016

Bump @wzowee I'd like a fix for this still, looks like you got pretty far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants