Skip to content

Commit

Permalink
Commentors are added to the list of watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar1989 committed Mar 29, 2012
1 parent 4f1a397 commit 994e563
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions 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
Expand All @@ -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


20 changes: 19 additions & 1 deletion features/ticket_notifications.feature
Expand Up @@ -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.