rubyforgood / playtime

Supporting children and families experiencing homelessness in Washington, DC. Live app - https://wishlist.playtimeproject.org Organization Website:
http://www.playtimeproject.org/
MIT License
89 stars 50 forks source link

Updates to ensure new tab is opened for all pledges #200

Closed memcmahon closed 6 years ago

memcmahon commented 6 years ago

Resolves #195

Description

This PR is in response to issue #195 which described an issue where a logged in user was not getting a new tab opened to the item's amazon page when they clicked on 'Pledge to Donate' from the home page. After initial review, the issue looked to be much broader in scope - and is described below:

Expected Behavior:

As a user (logged in or not) When I visit the root page And click on 'Pledge To Donate' A new tab is opened with the item's amazon url And the current page is redirected to the pledges page Then when I click on 'home' And click on 'Pledge to Donate' A new tab is opened with the item's amazon url And the current page is redirected to the pledges page

Actual Behavior:

As a user (logged in or not) When I visit the root page And click on 'Pledge To Donate' A new tab is opened with the item's amazon url And the current page is redirected to the pledges page Then when I click on 'home' And click on 'Pledge to Donate' Then the current page is redirected to the pledges page

-- OR --

As a user (logged in or not) When I visit the root page And click on 'Pledge To Donate' A new tab is opened with the item's amazon url And the current page is redirected to the pledges page Then when I click on my browser's back button A new tab is opened with the item's amazon url And the current page is redirected to the pledges page

As outlined above, the issue is that the expected behavior (a new tab being opened) is only happening the first time the home page is loaded and subsequently, only if the browser's back button is used. The fix should allow for the expected behavior regardless of the user's method of returning to the home page.

This pull request fixes this issue by changing the document ready function in pledges.js to be triggered when turbolinks loads, rather than when the page loads. With turbolinks enabled, the home page is not being fully loaded when the home button is clicked, and so the previous configuration was missing the pickup of the new tab event listener. The change to turbolinks:load from page:load fixes the issue for all users, whether logged in, or not.

Type of change

How Has This Been Tested?

I have user-tested this locally with chrome, firefox and safari with the steps outlined below: As a guest:

  1. Start you local server: rails server
  2. Navigate to localhost:3000 in your browser of choice
  3. Click on any 'Pledge to Donate' button
  4. A new tab should open, taking you to the amazon page for that item
  5. Click back to the 'Playtime' tab
  6. Click on 'Home'
  7. Click on any 'Pledge to Donate' button
  8. A new tab should open, taking you to the amazon page for that item

As a logged in user:

  1. Start you local server: rails server
  2. Navigate to localhost:3000 in your browser of choice
  3. Click on Log In
  4. Enter your Name and Email
  5. Click on Sign In
  6. Click on any 'Pledge to Donate' button
  7. A new tab should open, taking you to the amazon page for that item
  8. Click back to the 'Playtime' tab
  9. Click on 'Home'
  10. Click on any 'Pledge to Donate' button
  11. A new tab should open, taking you to the amazon page for that item
seanmarcia commented 6 years ago

Hey Megan! Looks great, thank you so much for fixing this!

memcmahon commented 6 years ago

Hey Sean - happy to help!