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

Crop attachments before saving associated model #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/papercrop/model_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def crop_attached_file(attachment_name, opts = {})
processors << :papercrop
end

after_update :"reprocess_to_crop_#{attachment_name}_attachment"
before_update :"reprocess_to_crop_#{attachment_name}_attachment"
end


Expand Down
8 changes: 5 additions & 3 deletions spec/integration/papercrop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@

find("#landscape_picture_original_w").value.should eq("1024")
find("#landscape_picture_original_h").value.should eq("768")

find("#picture_cropbox")[:"data-box-width"].should eq("600")
find("#picture_cropbox")[:"data-aspect-ratio"].should eq((4.0 / 3.0).to_s)

find("#picture_crop_x").set "300"
find("#picture_crop_y").set "200"
find("#picture_crop_w").set "400"
find("#picture_crop_h").set "300"
picture_updated_at = Landscape.last.picture_updated_at

click_button "Crop image"


expect(Landscape.last.picture_updated_at).to_not eq(picture_updated_at)
compare_images(expected_mountains_img_path, Landscape.last.picture.path(:medium)).round(2).should eq(0.0)
end
end
end