Commit b79e00881ec441c7266e8aca6083a3eb9586cd40

Authored by Dmitriy Zaporozhets
1 parent 0ff46816

Uncommented test observing comment event

app/models/milestone.rb
... ... @@ -14,7 +14,7 @@
14 14  
15 15 class Milestone < ActiveRecord::Base
16 16 attr_accessible :title, :description, :due_date, :closed, :author_id_of_changes
17   - attr_accessor :author_id, :author_id_of_changes
  17 + attr_accessor :author_id_of_changes
18 18  
19 19 belongs_to :project
20 20 has_many :issues
... ... @@ -68,4 +68,8 @@ class Milestone &lt; ActiveRecord::Base
68 68 def open?
69 69 !closed
70 70 end
  71 +
  72 + def author_id
  73 + author_id_of_changes
  74 + end
71 75 end
... ...
app/observers/activity_observer.rb
... ... @@ -2,7 +2,7 @@ class ActivityObserver &lt; ActiveRecord::Observer
2 2 observe :issue, :merge_request, :note, :milestone
3 3  
4 4 def after_create(record)
5   - event_author_id = record.author_id || record.author_id_of_changes
  5 + event_author_id = record.author_id
6 6  
7 7 # Skip status notes
8 8 if record.kind_of?(Note) && record.note.include?("_Status changed to ")
... ...
spec/observers/activity_observer_spec.rb
... ... @@ -34,15 +34,17 @@ describe ActivityObserver do
34 34 it { @event.target.should == @issue }
35 35 end
36 36  
37   - #describe "Issue commented" do
38   - #before do
39   - #@issue = create(:issue, project: project)
40   - #@note = create(:note, noteable: @issue, project: project)
41   - #@event = Event.last
42   - #end
43   -
44   - #it_should_be_valid_event
45   - #it { @event.action.should == Event::Commented }
46   - #it { @event.target.should == @note }
47   - #end
  37 + describe "Issue commented" do
  38 + before do
  39 + Note.observers.enable :activity_observer do
  40 + @issue = create(:issue, project: project)
  41 + @note = create(:note, noteable: @issue, project: project, author: @issue.author)
  42 + @event = Event.last
  43 + end
  44 + end
  45 +
  46 + it_should_be_valid_event
  47 + it { @event.action.should == Event::Commented }
  48 + it { @event.target.should == @note }
  49 + end
48 50 end
... ...