Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
d472810e
Commit
d472810e
authored
Apr 05, 2016
by
Sebastian Klier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting and test structure
parent
a88f0a1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
28 deletions
+45
-28
app/models/project_services/slack_service/wiki_page_message.rb
...odels/project_services/slack_service/wiki_page_message.rb
+1
-1
db/migrate/20160227120047_add_event_to_services.rb
db/migrate/20160227120047_add_event_to_services.rb
+1
-1
spec/models/project_services/slack_service/wiki_page_message_spec.rb
.../project_services/slack_service/wiki_page_message_spec.rb
+43
-26
No files found.
app/models/project_services/slack_service/wiki_page_message.rb
View file @
d472810e
...
@@ -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"
...
...
db/migrate/20160227120047_add_event_to_services.rb
View file @
d472810e
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
spec/models/project_services/slack_service/wiki_page_message_spec.rb
View file @
d472810e
...
@@ -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,34 +21,53 @@ describe SlackService::WikiPageMessage, models: true do
...
@@ -23,34 +21,53 @@ 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'
}
'Test User created <url|wiki page> in <somewhere.com|project_name>: '
\
'*Wiki page title*'
)
it
do
expect
(
subject
.
attachments
).
to
eq
([
expect
(
pretext
).
to
eq
(
{
'Test User created <url|wiki page> in <somewhere.com|project_name>: '
\
text:
"Wiki page description"
,
'*Wiki page title*'
)
color:
color
,
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
end
end
context
'update'
do
describe
'#attachments'
do
before
do
context
'when :action == "create"'
do
args
[
:object_attributes
][
:action
]
=
'update'
before
{
args
[
:object_attributes
][
:action
]
=
'create'
}
it
do
expect
(
attachments
).
to
eq
([
{
text:
"Wiki page description"
,
color:
color
,
}
])
end
end
end
it
'returns a message regarding updating of pages'
do
expect
(
subject
.
pretext
).
to
eq
(
context
'when :action == "update"'
do
'Test User edited <url|wiki page> in <somewhere.com|project_name>: '
\
before
{
args
[
:object_attributes
][
:action
]
=
'update'
}
'*Wiki page title*'
)
expect
(
subject
.
attachments
).
to
eq
([
it
do
{
expect
(
attachments
).
to
eq
([
text:
"Wiki page description"
,
{
color:
color
,
text:
"Wiki page description"
,
}
color:
color
,
])
}
])
end
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment