Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

665 consolidate emails #1161

Merged
merged 1 commit into from
Mar 2, 2015
Merged

665 consolidate emails #1161

merged 1 commit into from
Mar 2, 2015

Conversation

esoterik
Copy link
Collaborator

Resolves #665 and #938

@@ -59,6 +59,7 @@
<%= f.input :enable_renewals, label: 'Enable renewals', hint: 'Allow users to renew reservations.' %>
</fieldset>

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks leftover from a merge conflict :-P

@orenyk
Copy link
Contributor

orenyk commented Feb 20, 2015

This looks really nice. I left a bunch of inline comments, the biggest of which is the refactoring of the two reservations controller methods (checkin_email and checkout_email) into one and the re-introduction of that functionality to our views. The only other comment I have is that I encountered an ERB warning in both _due_today.html.erb:1 and _starts_today.html.erb:1:

_starts_today.html.erb:1: warning: encountered \r in the middle of line, treated as a mere space

Not sure what that's all about, see if it's something we need to deal with. Great work!

@orenyk
Copy link
Contributor

orenyk commented Feb 20, 2015

Also note that the query for the send_upcoming_checkin_reminder task in mailmain.rake has a typo (line 6). We need to add a space at the end of the line (after and) to make it work. Since we're fixing e-mails here I think it falls within scope.

@esoterik
Copy link
Collaborator Author

I fixed most of the issues you pointed out in the comments. I've refactored the checkin/checkout email methods, but it's failing quite a few tests so I haven't committed it yet. The parsing issues in the email bodies also have yet to be corrected.

@esoterik
Copy link
Collaborator Author

The tests no longer fail because of the refactored send_receipt method; tests still need to be written for the new method though.

@esoterik
Copy link
Collaborator Author

also--it seems like the \r issue is from a windows line ending character in the default messages for those two emails

@equipment_list@\n\n\
If you fail to return your equipment on time you will be subject to a late fee of @late_fee@ per day. If you have lost the item you may additioally have to pay a replacement fee of Replacement_fee@.\n\
If you fail to return your equipment on time you will be subject to a late fee of @late_fee@ per day. If you have lost the item you may additionally have to pay a replacement fee of @replacement_fee@.\n\
Copy link
Contributor

Choose a reason for hiding this comment

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

ha nice catch :-)

@orenyk
Copy link
Contributor

orenyk commented Feb 22, 2015

Also, HTML line breaks in the app config settings are being escaped improperly in the e-mail body:

selection_051

@orenyk
Copy link
Contributor

orenyk commented Feb 22, 2015

Also, the checkout receipt fails when the reservation is due back today or is overdue but hasn't yet been returned (since the status is now "due today" or "overdue"). We might need to pass a receipt parameter into UserMailer#reservation_status_update to enforce the checked out status for those calls.

Note also that my comment above also applies to the logic determining whether or not to display the "send receipt" button.

def checkin_email
if UserMailer.checkin_receipt(@reservation).deliver
def send_receipt
if UserMailer.reservation_status_update(@reservation).deliver
redirect_to :back
Copy link
Contributor

Choose a reason for hiding this comment

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

This is no good since if we call this from the receipt view that is rendered by the checkout or checkin methods, then it tries to run checkout or checkin again resulting in a RecordNotFound exception. Why don't we redirect to the reservation in both cases?

@orenyk
Copy link
Contributor

orenyk commented Feb 22, 2015

Nice job dealing with round 1, I left a few more inline comments and found a couple more issues while manually testing out this functionality (see above). Once those are addressed you should also play around with this branch and make sure everything works as expected (all buttons / links and all rake tasks). Hopefully we can get this done in tomorrow's meeting!

@esoterik
Copy link
Collaborator Author

okay, everything is fixed and working locally, about to force push onto this branch to fix the git issues, let's hope it works

@esoterik esoterik force-pushed the 665_consolidate_emails branch from 3058f59 to b88351b Compare February 28, 2015 04:06
@esoterik
Copy link
Collaborator Author

I think this is all set?

@orenyk
Copy link
Contributor

orenyk commented Mar 1, 2015

Thanks, I'll have to review this tomorrow but hopefully we'll be able to get it in as well. What was your ultimate solution to fixing all the Git weirdness?

@esoterik
Copy link
Collaborator Author

esoterik commented Mar 2, 2015

I made a new branch locally, merged in 938, cherrypicked from 665, then force pushed to this branch haha

@status = 'due today'
end

if receipt && (@status == 'due today' || @status == 'overdue')
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably also check to make sure it's been checked out if the receipt parameter is true. An alternative way to structure this would be to write a second method send_receipt that runs that validation (e.g. return unless reservation.checked_out) and then calls reservation_status_update(reservation, true).

On that note, what happens if it's returned overdue? As written, it's not called a "receipt", but we can fix that in the view below (I'll leave a comment there).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

perhaps the name "receipt" for the variable is misleading--I only wanted to use it to force sending a checkout receipt if requested from the reservations controller; other cases should work without the additional parameter

Copy link
Contributor

Choose a reason for hiding this comment

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

No I understand that, what I'm saying is that someone could end up issuing a request to the get_receipt route, passing a reservation that isn't yet checked out and therefore it should fail. Unless I missed it, we're not currently checking for that anywhere (so if you end up calling reservation_status_update(res, true) and res.checked_out == nil the e-mail view will probably fail since it will try to call strftime on nil). Does that make more sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right yeah, that was in response to returned overdue not being called a receipt. I think we're on the same page

@orenyk
Copy link
Contributor

orenyk commented Mar 2, 2015

Once we've dealt with validating the receipt requests, I think this should be good to go (whew).

@esoterik
Copy link
Collaborator Author

esoterik commented Mar 2, 2015

once travis finishes this should be good!

end

if checkout_receipt && (@status == 'due today' || @status == 'overdue') &&
@reservation.checked_out
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I almost feel like we should return here if it's not checked out. As I see it:

  1. If checkout_receipt (or receipt, I actually prefer the latter since we made one controller method for both cases)
    1. If checked out and status weirdness then fix status
    2. If checked out and status is checked out then do nothing
    3. If not checked out, don't send the e-mail
    4. If checked in, do nothing

Does that make sense?

@orenyk
Copy link
Contributor

orenyk commented Mar 2, 2015

Oh no! What's the merge conflict? In either case, you can just squash rebase, then rebase onto master to resolve it. Good work!

@esoterik esoterik force-pushed the 665_consolidate_emails branch 2 times, most recently from 94dfc8d to 9304e63 Compare March 2, 2015 04:30
generalized email methods

spec for overhauled mailer

replaced email methods everywhere

don't send fine emails if there's no fine

upcoming check out email added to unified email method

add email checkout reminders task to the heroku scheduler

refactored check in / out receipt methods
@esoterik esoterik force-pushed the 665_consolidate_emails branch from 9304e63 to 404634c Compare March 2, 2015 04:52
orenyk added a commit that referenced this pull request Mar 2, 2015
@orenyk orenyk merged commit 3159bf4 into master Mar 2, 2015
@orenyk orenyk deleted the 665_consolidate_emails branch April 22, 2015 13:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consolidate email methods
3 participants