einzige / sneaky-save

Allows to update complex objects without triggering validations or callbacks.
45 stars 30 forks source link

Fix Rails 3 serialized attributes #14

Closed einzige closed 6 years ago

einzige commented 7 years ago

@ritikesh

Going forward, let's have our updates separated in commits.

For a spec, you'll need to update spec/spe_helper.rb where you'll find a test class called "Fake", just add a new column to it and serialize the way you did in your app.

It may also require you to add conditional spec / code depending on a currently running rails/AR version, eg: if ActiveRecord.version < 4 then add serialization, run this spec

ritikesh commented 7 years ago

It may also require you to add conditional spec / code depending on a currently running rails/AR version, eg: if ActiveRecord.version < 4 then add serialization, run this spec.

Doubt that it would require version checks. Serialized columns should work irrespective of whichever version we're on right? Let me know your thoughts. Thanks.

einzige commented 7 years ago

@ritikesh yep, sounds right.

Let's check if it is really saved in specs

ritikesh commented 7 years ago

@einzige when I ran specs, it ran with 0 failures. How about you?

einzige commented 7 years ago

@ritikesh 0 failures, but we need to make sure a serialized column gets saved. For instance:

it 'updates serialized column' do
  expect do
     fake.config = {one: :two}
     fake.sneaky_save!
  end.to change { fake.reload.config }.from(nil).to(one: :two)
end