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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
939d3d48
Commit
939d3d48
authored
Nov 05, 2019
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for external_wiki_service test
This checks that the execute method does what we expect it to do.
parent
9236ed07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
app/models/project_services/external_wiki_service.rb
app/models/project_services/external_wiki_service.rb
+7
-2
spec/models/project_services/external_wiki_service_spec.rb
spec/models/project_services/external_wiki_service_spec.rb
+30
-0
No files found.
app/models/project_services/external_wiki_service.rb
View file @
939d3d48
...
...
@@ -19,14 +19,19 @@ class ExternalWikiService < Service
def
fields
[
{
type:
'text'
,
name:
'external_wiki_url'
,
placeholder:
s_
(
'ExternalWikiService|The URL of the external Wiki'
),
required:
true
}
{
type:
'text'
,
name:
'external_wiki_url'
,
placeholder:
s_
(
'ExternalWikiService|The URL of the external Wiki'
),
required:
true
}
]
end
def
execute
(
_data
)
@response
=
Gitlab
::
HTTP
.
get
(
properties
[
'external_wiki_url'
],
verify:
true
)
rescue
nil
@response
if
@repons
e
==
200
@response
.
body
if
@response
.
cod
e
==
200
end
def
self
.
supported_events
...
...
spec/models/project_services/external_wiki_service_spec.rb
View file @
939d3d48
...
...
@@ -26,4 +26,34 @@ describe ExternalWikiService do
it
{
is_expected
.
not_to
validate_presence_of
(
:external_wiki_url
)
}
end
end
describe
'test'
do
before
do
subject
.
properties
[
'external_wiki_url'
]
=
url
end
let
(
:url
)
{
'http://foo'
}
let
(
:data
)
{
nil
}
let
(
:result
)
{
subject
.
test
(
data
)
}
context
'the URL is not reachable'
do
before
do
WebMock
.
stub_request
(
:get
,
url
).
to_return
(
status:
404
,
body:
'not a page'
)
end
it
'is not successful'
do
expect
(
result
[
:success
]).
to
be_falsey
end
end
context
'the URL is reachable'
do
before
do
WebMock
.
stub_request
(
:get
,
url
).
to_return
(
status:
200
,
body:
'foo'
)
end
it
'is successful'
do
expect
(
result
[
:success
]).
to
be_truthy
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