Skip to content

Commit f18d01c

Browse files
committed
Answers generate email notifications
1 parent f330677 commit f18d01c

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/controllers/answers_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ def create
77
@answer = Answer.create params[:answer]
88
@answer.question = @question
99
@answer.user = current_user
10+
11+
Notification.new_answer(@question).deliver
12+
1013
create!(:notice => "Answer Posted!"){ question_url(params[:question_id]) }
1114
end
1215

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
:authentication => :plain,
5858
:user_name => ENV['SENDGRID_USERNAME'],
5959
:password => ENV['SENDGRID_PASSWORD'],
60-
:domain => 'hackety-hack.com'
60+
:domain => 'hackety.com'
6161
}
6262
ActionMailer::Base.delivery_method = :smtp
6363

features/answers.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Feature: CRUD actions for answers
66
Given a question exists
77
And I answer that question
88
Then I should be notified that my answer was submitted
9+
And an email should be sent to the author
910
And I should be able to see my answer
1011
And my answer should show on my profile page
1112

features/step_definitions/answer_steps.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@
2323
page.should have_content(@question.title)
2424
page.should have_content("Have you tried turning it off and on again?")
2525
end
26+
27+
Then /^an email should be sent to the author$/ do
28+
ActionMailer::Base.deliveries.should_not be_empty
29+
end
30+

features/support/mailer.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Before do
2+
ActionMailer::Base.deliveries.clear
3+
end

0 commit comments

Comments
 (0)