Permalink
Browse files

Commentors are added to the list of watchers

  • Loading branch information...
1 parent 4f1a397 commit 994e56335cb57c1b2946dcb7a7a7cbcb975e4c1c @prakhar1989 committed Mar 29, 2012
Showing with 24 additions and 1 deletion.
  1. +5 −0 app/models/comment.rb
  2. +19 −1 features/ticket_notifications.feature
View
@@ -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
@@ -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

0 comments on commit 994e563

Please sign in to comment.