Commit 7d8d9bd1a16e8cf1d87bc7e5115d6c1e7eb14c75
1 parent
ed67ba96
Exists in
spb-stable
and in
3 other branches
Remove issue observer tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
0 additions
and
99 deletions
Show diff stats
spec/observers/issue_observer_spec.rb
@@ -1,99 +0,0 @@ | @@ -1,99 +0,0 @@ | ||
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe IssueObserver do | ||
4 | - let(:some_user) { create :user } | ||
5 | - let(:assignee) { create :user } | ||
6 | - let(:author) { create :user } | ||
7 | - let(:mock_issue) { create(:issue, assignee: assignee, author: author) } | ||
8 | - | ||
9 | - | ||
10 | - before { subject.stub(:current_user).and_return(some_user) } | ||
11 | - before { subject.stub(:current_commit).and_return(nil) } | ||
12 | - before { subject.stub(notification: double('NotificationService').as_null_object) } | ||
13 | - before { mock_issue.project.stub_chain(:repository, :commit).and_return(nil) } | ||
14 | - | ||
15 | - subject { IssueObserver.instance } | ||
16 | - | ||
17 | - describe '#after_create' do | ||
18 | - it 'trigger notification to send emails' do | ||
19 | - subject.should_receive(:notification) | ||
20 | - | ||
21 | - subject.after_create(mock_issue) | ||
22 | - end | ||
23 | - | ||
24 | - it 'should create cross-reference notes' do | ||
25 | - other_issue = create(:issue) | ||
26 | - mock_issue.stub(references: [other_issue]) | ||
27 | - | ||
28 | - Note.should_receive(:create_cross_reference_note).with(other_issue, mock_issue, | ||
29 | - some_user, mock_issue.project) | ||
30 | - subject.after_create(mock_issue) | ||
31 | - end | ||
32 | - end | ||
33 | - | ||
34 | - context '#after_close' do | ||
35 | - context 'a status "closed"' do | ||
36 | - before { mock_issue.stub(state: 'closed') } | ||
37 | - | ||
38 | - it 'note is created if the issue is being closed' do | ||
39 | - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'closed', nil) | ||
40 | - | ||
41 | - subject.after_close(mock_issue, nil) | ||
42 | - end | ||
43 | - | ||
44 | - it 'trigger notification to send emails' do | ||
45 | - subject.notification.should_receive(:close_issue).with(mock_issue, some_user) | ||
46 | - subject.after_close(mock_issue, nil) | ||
47 | - end | ||
48 | - | ||
49 | - it 'appends a mention to the closing commit if one is present' do | ||
50 | - commit = double('commit', gfm_reference: 'commit 123456') | ||
51 | - subject.stub(current_commit: commit) | ||
52 | - | ||
53 | - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'closed', commit) | ||
54 | - | ||
55 | - subject.after_close(mock_issue, nil) | ||
56 | - end | ||
57 | - end | ||
58 | - | ||
59 | - context 'a status "reopened"' do | ||
60 | - before { mock_issue.stub(state: 'reopened') } | ||
61 | - | ||
62 | - it 'note is created if the issue is being reopened' do | ||
63 | - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'reopened', nil) | ||
64 | - | ||
65 | - subject.after_reopen(mock_issue, nil) | ||
66 | - end | ||
67 | - end | ||
68 | - end | ||
69 | - | ||
70 | - context '#after_update' do | ||
71 | - before(:each) do | ||
72 | - mock_issue.stub(:is_being_reassigned?).and_return(false) | ||
73 | - end | ||
74 | - | ||
75 | - context 'notification' do | ||
76 | - it 'triggered if the issue is being reassigned' do | ||
77 | - mock_issue.should_receive(:is_being_reassigned?).and_return(true) | ||
78 | - subject.should_receive(:notification) | ||
79 | - | ||
80 | - subject.after_update(mock_issue) | ||
81 | - end | ||
82 | - | ||
83 | - it 'is not triggered if the issue is not being reassigned' do | ||
84 | - mock_issue.should_receive(:is_being_reassigned?).and_return(false) | ||
85 | - subject.should_not_receive(:notification) | ||
86 | - | ||
87 | - subject.after_update(mock_issue) | ||
88 | - end | ||
89 | - end | ||
90 | - | ||
91 | - context 'cross-references' do | ||
92 | - it 'notices added references' do | ||
93 | - mock_issue.should_receive(:notice_added_references) | ||
94 | - | ||
95 | - subject.after_update(mock_issue) | ||
96 | - end | ||
97 | - end | ||
98 | - end | ||
99 | -end |