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

Revert jQuery changes to xhr var in image upload #4707

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Spree.Models.ImageUpload = Backbone.Model.extend({
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
xhr: function () {
var xhr = $.ajaxSetup.xhr(); // Using default ajax builder but inputting upload settings
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.onprogress = function (event) {
if (event.lengthComputable) {
Expand Down
62 changes: 41 additions & 21 deletions backend/spec/features/admin/products/edit/images_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,53 @@
end
end

it "should allow an admin to upload and edit an image for a product" do
click_link "new_image_link"
within_fieldset 'New Image' do
attach_file('image_attachment', file_path)
end
click_button "Update"
expect(page).to have_content("successfully created!")

# Icons are hidden, so hover to have them pop-up
find('tbody > tr').hover
within_row(1) do
within ".actions" do
click_icon :edit
context 'Using the new image link' do
it "should allow an admin to upload and edit an image for a product" do
click_link "new_image_link"
within_fieldset 'New Image' do
attach_file('image_attachment', file_path)
end
click_button "Update"
expect(page).to have_content("successfully created!")

# Icons are hidden, so hover to have them pop-up
find('tbody > tr').hover
within_row(1) do
within ".actions" do
click_icon :edit
end
end

fill_in "image_alt", with: "ruby on rails t-shirt"
click_button "Update"

expect(page).to have_content "successfully updated!"
expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"

find('tbody > tr').hover
accept_alert do
click_icon :trash
end
expect(page).not_to have_field "image[alt]", with: "ruby on rails t-shirt"
end
end

fill_in "image_alt", with: "ruby on rails t-shirt"
click_button "Update"
context 'Using the drag and drop upload window' do
it "should allow an admin to upload an image and edit an image for a product" do
page.find(".upload").drop(file_path)
find('tbody > tr').hover
within_row(1) do
within ".actions" do
click_icon :edit
end
end

expect(page).to have_content "successfully updated!"
expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
fill_in "image_alt", with: "ruby on rails t-shirt"
click_button "Update"

find('tbody > tr').hover
accept_alert do
click_icon :trash
expect(page).to have_content "successfully updated!"
expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
end
expect(page).not_to have_field "image[alt]", with: "ruby on rails t-shirt"
end

context 'Using Active Storage',
Expand Down