Commit d472810e authored by Sebastian Klier's avatar Sebastian Klier

formatting and test structure

parent a88f0a1f
...@@ -19,7 +19,7 @@ class SlackService ...@@ -19,7 +19,7 @@ class SlackService
@wiki_page_url = obj_attr[:url] @wiki_page_url = obj_attr[:url]
@description = obj_attr[:content] @description = obj_attr[:content]
@action = \ @action =
case obj_attr[:action] case obj_attr[:action]
when "create" when "create"
"created" "created"
......
class AddEventToServices < ActiveRecord::Migration class AddEventToServices < ActiveRecord::Migration
def change def change
add_column :services, :wiki_page_events, :boolean, :default => true add_column :services, :wiki_page_events, :boolean, default: true
end end
end end
...@@ -11,11 +11,9 @@ describe SlackService::WikiPageMessage, models: true do ...@@ -11,11 +11,9 @@ describe SlackService::WikiPageMessage, models: true do
}, },
project_name: 'project_name', project_name: 'project_name',
project_url: 'somewhere.com', project_url: 'somewhere.com',
object_attributes: { object_attributes: {
title: 'Wiki page title', title: 'Wiki page title',
url: 'url', url: 'url',
action: 'create',
content: 'Wiki page description' content: 'Wiki page description'
} }
} }
...@@ -23,12 +21,34 @@ describe SlackService::WikiPageMessage, models: true do ...@@ -23,12 +21,34 @@ describe SlackService::WikiPageMessage, models: true do
let(:color) { '#345' } let(:color) { '#345' }
context 'create' do describe '#pretext' do
it 'returns a message regarding creation of pages' do context 'when :action == "create"' do
expect(subject.pretext).to eq( before { args[:object_attributes][:action] = 'create' }
it do
expect(pretext).to eq(
'Test User created <url|wiki page> in <somewhere.com|project_name>: '\ 'Test User created <url|wiki page> in <somewhere.com|project_name>: '\
'*Wiki page title*') '*Wiki page title*')
expect(subject.attachments).to eq([ end
end
context 'when :action == "update"' do
before { args[:object_attributes][:action] = 'update' }
it do
expect(pretext).to eq(
'Test User edited <url|wiki page> in <somewhere.com|project_name>: '\
'*Wiki page title*')
end
end
end
describe '#attachments' do
context 'when :action == "create"' do
before { args[:object_attributes][:action] = 'create' }
it do
expect(attachments).to eq([
{ {
text: "Wiki page description", text: "Wiki page description",
color: color, color: color,
...@@ -37,15 +57,11 @@ describe SlackService::WikiPageMessage, models: true do ...@@ -37,15 +57,11 @@ describe SlackService::WikiPageMessage, models: true do
end end
end end
context 'update' do context 'when :action == "update"' do
before do before { args[:object_attributes][:action] = 'update' }
args[:object_attributes][:action] = 'update'
end it do
it 'returns a message regarding updating of pages' do expect(attachments).to eq([
expect(subject.pretext). to eq(
'Test User edited <url|wiki page> in <somewhere.com|project_name>: '\
'*Wiki page title*')
expect(subject.attachments).to eq([
{ {
text: "Wiki page description", text: "Wiki page description",
color: color, color: color,
...@@ -53,4 +69,5 @@ describe SlackService::WikiPageMessage, models: true do ...@@ -53,4 +69,5 @@ describe SlackService::WikiPageMessage, models: true do
]) ])
end end
end end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment