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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'spec_helper'
describe ChatMessage::WikiPageMessage, models: true do
subject { described_class.new(args) }
let(:args) do
{
user: {
name: 'Test User',
username: 'test.user'
},
project_name: 'project_name',
project_url: 'http://somewhere.com',
object_attributes: {
title: 'Wiki page title',
url: 'http://url.com',
content: 'Wiki page description'
}
}
end
describe '#pretext' do
context 'when :action == "create"' do
before { args[:object_attributes][:action] = 'create' }
it 'returns a message that a new wiki page was created' do
expect(subject.pretext).to eq(
'test.user created <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\
'*Wiki page title*')
end
end
context 'when :action == "update"' do
before { args[:object_attributes][:action] = 'update' }
it 'returns a message that a wiki page was updated' do
expect(subject.pretext).to eq(
'test.user edited <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\
'*Wiki page title*')
end
end
end
describe '#attachments' do
let(:color) { '#345' }
context 'when :action == "create"' do
before { args[:object_attributes][:action] = 'create' }
it 'returns the attachment for a new wiki page' do
expect(subject.attachments).to eq([
{
text: "Wiki page description",
color: color,
}
])
end
end
context 'when :action == "update"' do
before { args[:object_attributes][:action] = 'update' }
it 'returns the attachment for an updated wiki page' do
expect(subject.attachments).to eq([
{
text: "Wiki page description",
color: color,
}
])
end
end
end
end