2012-02-28 15:01:14 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ActivityObserver do
|
2012-11-06 04:31:55 +01:00
|
|
|
let(:project) { create(:project) }
|
2012-02-28 15:01:14 +01:00
|
|
|
|
2012-02-28 15:48:15 +01:00
|
|
|
def self.it_should_be_valid_event
|
|
|
|
it { @event.should_not be_nil }
|
|
|
|
it { @event.project.should == project }
|
|
|
|
end
|
|
|
|
|
2012-11-06 04:31:55 +01:00
|
|
|
describe "Merge Request created" do
|
2012-06-12 20:27:03 +02:00
|
|
|
before do
|
|
|
|
MergeRequest.observers.enable :activity_observer do
|
2012-11-06 04:31:55 +01:00
|
|
|
@merge_request = create(:merge_request, project: project)
|
2012-06-12 20:27:03 +02:00
|
|
|
@event = Event.last
|
|
|
|
end
|
2012-02-28 15:01:14 +01:00
|
|
|
end
|
|
|
|
|
2012-02-28 15:48:15 +01:00
|
|
|
it_should_be_valid_event
|
2013-02-13 12:48:16 +01:00
|
|
|
it { @event.action.should == Event::CREATED }
|
2012-02-28 15:01:14 +01:00
|
|
|
it { @event.target.should == @merge_request }
|
|
|
|
end
|
|
|
|
|
2012-11-06 04:31:55 +01:00
|
|
|
describe "Issue created" do
|
2012-06-12 20:27:03 +02:00
|
|
|
before do
|
|
|
|
Issue.observers.enable :activity_observer do
|
2012-11-06 04:31:55 +01:00
|
|
|
@issue = create(:issue, project: project)
|
2012-06-12 20:27:03 +02:00
|
|
|
@event = Event.last
|
|
|
|
end
|
2012-02-28 15:01:14 +01:00
|
|
|
end
|
|
|
|
|
2012-02-28 15:48:15 +01:00
|
|
|
it_should_be_valid_event
|
2013-02-13 12:48:16 +01:00
|
|
|
it { @event.action.should == Event::CREATED }
|
2012-02-28 15:01:14 +01:00
|
|
|
it { @event.target.should == @issue }
|
|
|
|
end
|
|
|
|
|
2012-12-14 21:05:10 +01:00
|
|
|
describe "Issue commented" do
|
|
|
|
before do
|
|
|
|
Note.observers.enable :activity_observer do
|
|
|
|
@issue = create(:issue, project: project)
|
|
|
|
@note = create(:note, noteable: @issue, project: project, author: @issue.author)
|
|
|
|
@event = Event.last
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_be_valid_event
|
2013-02-13 12:48:16 +01:00
|
|
|
it { @event.action.should == Event::COMMENTED }
|
2012-12-14 21:05:10 +01:00
|
|
|
it { @event.target.should == @note }
|
|
|
|
end
|
2012-02-28 15:01:14 +01:00
|
|
|
end
|