You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just upgraded to 0.0.5 to 0.1.2, and noticed some specs failing. With my Story model like:
class Story < ActiveRecord::Base
serialize :data, ActiveRecord::Coders::NestedHstore` I had a spec like:
def twitter_title
data && data["twitterDescription"] ? data["twitterDescription"] : title
end
end
Then my spec like:
story = create(:story, title: "This is the title", data: {twitterDescription: "Title"})
story.twitter_title.should == "Title"
This was passing before. Now it doesn't pass because story.data["twitterDescription"] == nil and story.data[:twitterDescription] == "Title".
To fix my spec, I need to change it to:
story = create(:story, title: "This is the title", data: {twitterDescription: "Title"})
story.reload
story.twitter_title.should == "Title"
Is this a bug or intended behavior? I'd prefer the previous behavior, where the output was consistent before and after the model had been reloaded. The keys were always strings and I could code for that.
To clarify: if you set a hash with string keys, they stay string keys before and after a model reload. If you set a hash with symbol keys, they'll be symbols until you reload the model and then they'll be strings.
The text was updated successfully, but these errors were encountered:
I just upgraded to 0.0.5 to 0.1.2, and noticed some specs failing. With my Story model like:
Then my spec like:
This was passing before. Now it doesn't pass because
story.data["twitterDescription"] == nil
andstory.data[:twitterDescription] == "Title"
.To fix my spec, I need to change it to:
Is this a bug or intended behavior? I'd prefer the previous behavior, where the output was consistent before and after the model had been reloaded. The keys were always strings and I could code for that.
To clarify: if you set a hash with string keys, they stay string keys before and after a model reload. If you set a hash with symbol keys, they'll be symbols until you reload the model and then they'll be strings.
The text was updated successfully, but these errors were encountered: