summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 14:39:19 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 14:39:19 +0100
commit8a03cb87442a42c8fc1630ab356dfd35dbb476f7 (patch)
treec8d7dcd2da6a359ba46d94a88a44a4bacfd5c197
parent98d6d491b5187945b2d86db20af411240716980a (diff)
downloadgitlab-ce-8a03cb87442a42c8fc1630ab356dfd35dbb476f7.tar.gz
Lets add more tests to Milestones services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/finders/milestones_finder.rb1
-rw-r--r--spec/services/milestones/close_service_spec.rb28
-rw-r--r--spec/services/milestones/create_service_spec.rb24
3 files changed, 52 insertions, 1 deletions
diff --git a/app/finders/milestones_finder.rb b/app/finders/milestones_finder.rb
index 71f207ca030..b704e878903 100644
--- a/app/finders/milestones_finder.rb
+++ b/app/finders/milestones_finder.rb
@@ -10,4 +10,3 @@ class MilestonesFinder
end
end
end
-
diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb
new file mode 100644
index 00000000000..034c0f22e12
--- /dev/null
+++ b/spec/services/milestones/close_service_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe Milestones::CloseService do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+ let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) }
+
+ before do
+ project.team << [user, :master]
+ end
+
+ describe :execute do
+ before do
+ Milestones::CloseService.new(project, user, {}).execute(milestone)
+ end
+
+ it { expect(milestone).to be_valid }
+ it { expect(milestone).to be_closed }
+
+ describe :event do
+ let(:event) { Event.first }
+
+ it { expect(event.milestone).to be_truthy }
+ it { expect(event.target).to eq(milestone) }
+ it { expect(event.action_name).to eq('closed') }
+ end
+ end
+end
diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb
new file mode 100644
index 00000000000..757c9a226d8
--- /dev/null
+++ b/spec/services/milestones/create_service_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe Milestones::CreateService do
+ let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
+
+ describe :execute do
+ context "valid params" do
+ before do
+ project.team << [user, :master]
+
+ opts = {
+ title: 'v2.1.9',
+ description: 'Patch release to fix security issue'
+ }
+
+ @milestone = Milestones::CreateService.new(project, user, opts).execute
+ end
+
+ it { expect(@milestone).to be_valid }
+ it { expect(@milestone.title).to eq('v2.1.9') }
+ end
+ end
+end