diff --git a/app/models/comment.rb b/app/models/comment.rb index 9645c6a..e1f088c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,6 +1,7 @@ class Comment < ActiveRecord::Base before_create :set_previous_state after_create :set_ticket_state + after_create :creator_watches_ticket validates_presence_of :text belongs_to :ticket @@ -19,6 +20,10 @@ def set_ticket_state def set_previous_state self.previous_state = ticket.state end + + def creator_watches_ticket + ticket.watchers << user + end end diff --git a/features/ticket_notifications.feature b/features/ticket_notifications.feature index c67b6f7..229e31f 100644 --- a/features/ticket_notifications.feature +++ b/features/ticket_notifications.feature @@ -27,4 +27,22 @@ Feature: Ticket Notifications Then they click the first link in the email Then I should see "Release date" within "#ticket h2" And the email should contain 2 parts - + + Scenario: Comment authors are automatically subscribed to a ticket + When I follow "Textmate 2" + And I follow "Release date" + And I fill in "Text" with "Is it out yet?" + And I press "Create Comment" + Then I should see "Comment has been created" + When I follow "Sign out" + + Given a clear email queue + + Given I am signed in as "alice@ticketee.com" + When I follow "Textmate 2" + And I follow "Release date" + And I fill in "Text" with "Not yet!" + And I press "Create Comment" + Then I should see "Comment has been created" + Then "bob@ticketee.com" should receive an email + Then "alice@ticketee.com" should have no emails