blob: 1318607a388015b0612c2f5dc0c9bb6cb209a62b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
require 'spec_helper'
describe Issues::CloseService, services: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:issue) { create(:issue, assignee: user2) }
let(:project) { issue.project }
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
before do
project.team << [user, :master]
project.team << [user2, :developer]
end
describe '#execute' do
context "valid params" do
before do
perform_enqueued_jobs do
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
end
end
it { expect(@issue).to be_valid }
it { expect(@issue).to be_closed }
it 'sends email to user2 about assign of new issue' do
email = ActionMailer::Base.deliveries.last
expect(email.to.first).to eq(user2.email)
expect(email.subject).to include(issue.title)
end
it 'creates system note about issue reassign' do
note = @issue.notes.last
expect(note.note).to include "Status changed to closed"
end
it 'marks todos as done' do
expect(todo.reload).to be_done
end
end
context "external issue tracker" do
before do
allow(project).to receive(:default_issues_tracker?).and_return(false)
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
end
it { expect(@issue).to be_valid }
it { expect(@issue).to be_opened }
it { expect(todo.reload).to be_pending }
end
end
end
|