summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-25 14:48:02 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-25 14:48:02 +0200
commitd89130b0974782824fb11d4e0cc0fd9b12fe7cab (patch)
treee49166cf05debb04ba221ab6eb8f7f43ae11dd3b /spec
parentcce80d04fe0271709170222d3b5774c39203ea07 (diff)
downloadgitlab-ce-d89130b0974782824fb11d4e0cc0fd9b12fe7cab.tar.gz
Collect all event creation logic in one place called EventCreateService
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/services/event_create_service_spec.rb103
1 files changed, 103 insertions, 0 deletions
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
new file mode 100644
index 00000000000..713aa3e7e74
--- /dev/null
+++ b/spec/services/event_create_service_spec.rb
@@ -0,0 +1,103 @@
+require 'spec_helper'
+
+describe EventCreateService do
+ let(:service) { EventCreateService.new }
+
+ describe 'Issues' do
+ describe :open_issue do
+ let(:issue) { create(:issue) }
+
+ it { service.open_issue(issue, issue.author).should be_true }
+
+ it "should create new event" do
+ expect { service.open_issue(issue, issue.author) }.to change { Event.count }
+ end
+ end
+
+ describe :close_issue do
+ let(:issue) { create(:issue) }
+
+ it { service.close_issue(issue, issue.author).should be_true }
+
+ it "should create new event" do
+ expect { service.close_issue(issue, issue.author) }.to change { Event.count }
+ end
+ end
+
+ describe :reopen_issue do
+ let(:issue) { create(:issue) }
+
+ it { service.reopen_issue(issue, issue.author).should be_true }
+
+ it "should create new event" do
+ expect { service.reopen_issue(issue, issue.author) }.to change { Event.count }
+ end
+ end
+ end
+
+ describe 'Merge Requests' do
+ describe :open_mr do
+ let(:merge_request) { create(:merge_request) }
+
+ it { service.open_mr(merge_request, merge_request.author).should be_true }
+
+ it "should create new event" do
+ expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count }
+ end
+ end
+
+ describe :close_mr do
+ let(:merge_request) { create(:merge_request) }
+
+ it { service.close_mr(merge_request, merge_request.author).should be_true }
+
+ it "should create new event" do
+ expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count }
+ end
+ end
+
+ describe :merge_mr do
+ let(:merge_request) { create(:merge_request) }
+
+ it { service.merge_mr(merge_request, merge_request.author).should be_true }
+
+ it "should create new event" do
+ expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count }
+ end
+ end
+
+ describe :reopen_mr do
+ let(:merge_request) { create(:merge_request) }
+
+ it { service.reopen_mr(merge_request, merge_request.author).should be_true }
+
+ it "should create new event" do
+ expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count }
+ end
+ end
+ end
+
+ describe 'Milestone' do
+ let(:user) { create :user }
+
+ describe :open_milestone do
+ let(:milestone) { create(:milestone) }
+
+ it { service.open_milestone(milestone, user).should be_true }
+
+ it "should create new event" do
+ expect { service.open_milestone(milestone, user) }.to change { Event.count }
+ end
+ end
+
+ describe :close_mr do
+ let(:milestone) { create(:milestone) }
+
+ it { service.close_milestone(milestone, user).should be_true }
+
+ it "should create new event" do
+ expect { service.close_milestone(milestone, user) }.to change { Event.count }
+ end
+ end
+ end
+end