Permalink
Browse files

Users are now automatically subscribed to a ticket when they comment …

…on it
  • Loading branch information...
1 parent 31f5807 commit bd3e649c55213d8a91f01dd0e4e15b86f07de029 @weij committed Mar 14, 2012
Showing with 28 additions and 0 deletions.
  1. +5 −0 app/models/comment.rb
  2. BIN db/test.sqlite3-journal
  3. +23 −0 features/ticket_notifications.feature
View
5 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
belongs_to :ticket
belongs_to :user
@@ -21,4 +22,8 @@ def set_ticket_state
def set_previous_state
self.previous_state = ticket.state
end
+
+ def creator_watches_ticket
+ ticket.watchers << user
+ end
end
View
BIN db/test.sqlite3-journal
Binary file not shown.
View
23 features/ticket_notifications.feature
@@ -32,3 +32,26 @@ Feature: Ticket Notifications
And they should see "[ticketee] TextMate 2 - Release date" in the email subject
Then they follow "view this ticket online here" in the email
Then I should see "Release date" within "#ticket h2"
+
+ 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."
+ Then "alice@ticketee.com" should receive an email
+ 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 bd3e649

Please sign in to comment.