Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix 5.1.0 regression from using saved_changes instead of changes #2133

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

paulsturgess
Copy link
Contributor

The PR I raised: #2130 successfully removed the deprecation warnings but unfortunately introduced a regression.

Rails 5.1.0 saved_changes behaves differently to changes: it returns the previous non existent change for the images column as nil instead of an empty array.

saved_changes returns:

{"id"=>[nil, 1], "images"=>[nil, ["test.jpeg"]]}

whereas changes returns:

{
 "id"=>[nil, 1],
 "images"=>
  [[],
   [#<#<Class:0x00000003dbe158>:0x0000000322a828
     @cache_id=nil,
     @cache_storage=#<CarrierWave::Storage::File:0x0000000321cbd8 @uploader=#<#<Class:0x00000003dbe158>:0x0000000322a828 ...>>,
     @file=#<CarrierWave::SanitizedFile:0x000000028dfd90 @content_type="image/jpeg", @file="/app/spec/public/uploads/test.jpeg", @original_filename=nil>,
     @filename="test.jpeg",
     @model=#<Event:0x0000000345cb78 id: 1, image: nil, images: ["test.jpeg"], textfile: nil, textfiles: nil, foo: nil>,
     @mounted_as=:images,
     @original_filename="test.jpeg",
     @storage=#<CarrierWave::Storage::File:0x000000031f33f0 @uploader=#<#<Class:0x00000003dbe158>:0x0000000322a828 ...>>,
     @versions={}>]]
}

Rails 5.1.0 saved_changes behaves differently to changes: it returns
the previous non existent change for the images column as nil instead
of an empty array.
@mshibuya
Copy link
Member

mshibuya commented Mar 6, 2017

We need failing spec on this issue, could you provide one?

@paulsturgess
Copy link
Contributor Author

@mshibuya Looking again there are two specs for removing images that already cover this:

They failed on master in this build and now in the build for this PR they pass.

Those two specs specifically test the CarrierWave::Mounter when being used with ActiveRecord and call remove_previous as part of the after_comit callback "remove_previously_stored_#{column}".

@mshibuya mshibuya merged commit 97c028c into carrierwaveuploader:master Mar 7, 2017
@mshibuya
Copy link
Member

mshibuya commented Mar 7, 2017

Sorry for that, thanks ❤️

fragoulis added a commit to skroutz/carrierwave that referenced this pull request Dec 10, 2018
fragoulis added a commit to skroutz/carrierwave that referenced this pull request Dec 10, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants