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

Fix the 'Send Mailer' checkbox selection #1659

Closed

Conversation

aamyot
Copy link

@aamyot aamyot commented Dec 20, 2016

The user selection for suppressing the shipping confirmation email is not respected when shipping a package from the admin. It always sends it.

@aamyot
Copy link
Author

aamyot commented Dec 20, 2016

also #1659

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The link is currently an infinite loop.

@aamyot
Copy link
Author

aamyot commented Dec 20, 2016

lol... of course! this wasn't meant to be posted here. Sorry about the confusion.
Thanks.

expect {
find(".ship-shipment-button").click
wait_for_ajax
}.not_to change{ ActionMailer::Base.deliveries.count }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of the test.

It's testing with .not_to without a corresponding test to check when it does change. For all we know, it could not deliver anything, or this test isn't configured correctly and we wouldn't know it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can wrap the test above this one (it "can ship a completed order") with the opposite email expectation. You'll probably want to rebase first, since that spec was changed in #1668

it "can ship a completed order" do
  expect {
    find(".ship-shipment-button").click

    expect(page).to have_content("shipped package")
    expect(order.reload.shipment_state).to eq("shipped")
  }.to change{ ActionMailer::Base.deliveries.count }.by(1)
end


expect {
find(".ship-shipment-button").click
wait_for_ajax
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the wait_for_ajax eliminated. We should expect something on the page to happen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbrunsdon has removed all the wait_for_ajax in #1668 🎉.

We can replace the wait_for_ajax here with expect(page).to have_content("shipped package")

Copy link
Contributor

@jhawthorn jhawthorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the bug report and patch. I left a couple of suggestions with which I think we can get this merged :)

@@ -37,6 +37,15 @@
expect(page).to have_content("shipped package")
expect(order.reload.shipment_state).to eq("shipped")
end

it "doesn't send a shipping confirmation email when ask to suppress the mailer" do
find("#send_mailer").set(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be uncheck 'Send Mailer', which reads a little nicer :)


expect {
find(".ship-shipment-button").click
wait_for_ajax
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbrunsdon has removed all the wait_for_ajax in #1668 🎉.

We can replace the wait_for_ajax here with expect(page).to have_content("shipped package")

expect {
find(".ship-shipment-button").click
wait_for_ajax
}.not_to change{ ActionMailer::Base.deliveries.count }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can wrap the test above this one (it "can ship a completed order") with the opposite email expectation. You'll probably want to rebase first, since that spec was changed in #1668

it "can ship a completed order" do
  expect {
    find(".ship-shipment-button").click

    expect(page).to have_content("shipped package")
    expect(order.reload.shipment_state).to eq("shipped")
  }.to change{ ActionMailer::Base.deliveries.count }.by(1)
end

@jhawthorn
Copy link
Contributor

Rebased and merged as #1716. Thanks @aamyot

@jhawthorn jhawthorn closed this Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants