27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Summary<br />

This is because your original comment notification doesn’t have the reply separator,<br />

and therefore the if condition in the parse method you just wrote says “Oh, can’t<br />

find it, so I’ll just ignore this email,” or something to that effect. In order to get this to<br />

work, you must add that line to the comment notification. You can do this by opening<br />

app/views/notifier/comment_updated.text.erb and its HTML compatriot and adding<br />

this line to the beginning of both files:<br />

== ADD YOUR REPLY ABOVE THIS LINE ==<br />

Now when you run your spec once more with bundle exec rspec spec/mailers/<br />

receiver_spec.rb, it will pass because the parse method can find the separator:<br />

1 example, 0 failures<br />

Alright, now that you’ve got that feature passing, does everything else still work? Let’s<br />

find out by running rake cucumber:ok spec:<br />

63 scenarios (63 passed)<br />

732 steps (732 passed)<br />

# and<br />

41 examples, 0 failures, 19 pending<br />

Good! Everything is still going great. Let’s commit the new feature:<br />

git add .<br />

git commit -m "Add Receiver class to receive emails"<br />

git push<br />

Right, this feature isn’t complete quite yet, because it only takes mail objects but<br />

doesn’t actually do any of the fetching itself. You’ll revisit this feature in chapter 15<br />

and complete it there. This is a great start, however.<br />

12.5 Summary<br />

That completes chapter 12! In this chapter, you learned how to send out your own<br />

kind of emails. Before that, however, you added two ways that users can subscribe to a<br />

ticket.<br />

The first of these ways was an automatic subscription that occurred when a user<br />

created a ticket. Here, every time a comment was posted to a ticket, the owner of the<br />

ticket was notified through either a plain-text or HTML email, depending on what that<br />

user’s email client supported.<br />

The second of the two ways was to allow users to choose to subscribe or unsubscribe<br />

to a ticket. By doing this, all users, and not just those who created the ticket, can<br />

choose to receive emails when a ticket has had a comment posted to it. This way, all<br />

users can stay up to date on tickets they may be interested in.<br />

Next, you made sure that you could actually send emails into the real world by connecting<br />

to a real Gmail account using Action Mailer’s SMTP settings. You also ensured<br />

that when you send an email using the STMP setting, you can read it from the server by<br />

using the gmail gem.<br />

345

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!