Commit 928fbeeec057692d923146994c4b8dff57024417
1 parent
1b5fb4ac
Exists in
spb-stable
and in
3 other branches
More tests for Isses services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
57 additions
and
2 deletions
Show diff stats
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Issues::CloseService do | ||
4 | + let(:project) { create(:empty_project) } | ||
5 | + let(:user) { create(:user) } | ||
6 | + let(:user2) { create(:user) } | ||
7 | + let(:issue) { create(:issue, assignee: user2) } | ||
8 | + | ||
9 | + before do | ||
10 | + project.team << [user, :master] | ||
11 | + project.team << [user2, :developer] | ||
12 | + end | ||
13 | + | ||
14 | + describe :execute do | ||
15 | + context "valid params" do | ||
16 | + before do | ||
17 | + @issue = Issues::CloseService.new(project, user, {}).execute(issue) | ||
18 | + end | ||
19 | + | ||
20 | + it { @issue.should be_valid } | ||
21 | + it { @issue.should be_closed } | ||
22 | + | ||
23 | + it 'should send email to user2 about assign of new issue' do | ||
24 | + email = ActionMailer::Base.deliveries.last | ||
25 | + email.to.first.should == user2.email | ||
26 | + email.subject.should include(issue.title) | ||
27 | + end | ||
28 | + | ||
29 | + it 'should create system note about issue reassign' do | ||
30 | + note = @issue.notes.last | ||
31 | + note.note.should include "Status changed to closed" | ||
32 | + end | ||
33 | + end | ||
34 | + end | ||
35 | +end |
spec/services/issues/update_service_spec.rb
@@ -3,15 +3,22 @@ require 'spec_helper' | @@ -3,15 +3,22 @@ require 'spec_helper' | ||
3 | describe Issues::UpdateService do | 3 | describe Issues::UpdateService do |
4 | let(:project) { create(:empty_project) } | 4 | let(:project) { create(:empty_project) } |
5 | let(:user) { create(:user) } | 5 | let(:user) { create(:user) } |
6 | + let(:user2) { create(:user) } | ||
6 | let(:issue) { create(:issue) } | 7 | let(:issue) { create(:issue) } |
7 | 8 | ||
9 | + before do | ||
10 | + project.team << [user, :master] | ||
11 | + project.team << [user2, :developer] | ||
12 | + end | ||
13 | + | ||
8 | describe :execute do | 14 | describe :execute do |
9 | context "valid params" do | 15 | context "valid params" do |
10 | before do | 16 | before do |
11 | - project.team << [user, :master] | ||
12 | opts = { | 17 | opts = { |
13 | title: 'New title', | 18 | title: 'New title', |
14 | - description: 'Also please fix' | 19 | + description: 'Also please fix', |
20 | + assignee_id: user2.id, | ||
21 | + state_event: 'close' | ||
15 | } | 22 | } |
16 | 23 | ||
17 | @issue = Issues::UpdateService.new(project, user, opts).execute(issue) | 24 | @issue = Issues::UpdateService.new(project, user, opts).execute(issue) |
@@ -19,6 +26,19 @@ describe Issues::UpdateService do | @@ -19,6 +26,19 @@ describe Issues::UpdateService do | ||
19 | 26 | ||
20 | it { @issue.should be_valid } | 27 | it { @issue.should be_valid } |
21 | it { @issue.title.should == 'New title' } | 28 | it { @issue.title.should == 'New title' } |
29 | + it { @issue.assignee.should == user2 } | ||
30 | + it { @issue.should be_closed } | ||
31 | + | ||
32 | + it 'should send email to user2 about assign of new issue' do | ||
33 | + email = ActionMailer::Base.deliveries.last | ||
34 | + email.to.first.should == user2.email | ||
35 | + email.subject.should include(issue.title) | ||
36 | + end | ||
37 | + | ||
38 | + it 'should create system note about issue reassign' do | ||
39 | + note = @issue.notes.last | ||
40 | + note.note.should include "Reassigned to \@#{user2.username}" | ||
41 | + end | ||
22 | end | 42 | end |
23 | end | 43 | end |
24 | end | 44 | end |