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
6d0731e4
Commit
6d0731e4
authored
Oct 04, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test resetting password and validating username
parent
1e75c7db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
spec/models/project_services/jenkins_service_spec.rb
spec/models/project_services/jenkins_service_spec.rb
+28
-3
No files found.
spec/models/project_services/jenkins_service_spec.rb
View file @
6d0731e4
...
...
@@ -24,7 +24,9 @@ describe JenkinsService do
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
have_one
:service_hook
}
end
let
(
:project
)
{
create
(
:project
)
}
let
(
:jenkins_params
)
do
{
active:
true
,
...
...
@@ -44,19 +46,36 @@ describe JenkinsService do
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
password:
'password'
,
username:
nil
,
username:
'username'
,
}
)
end
subject
{
@jenkins_service
}
context
'when the service is active'
do
let
(
:active
)
{
true
}
it
{
is_expected
.
to
validate_presence_of
:username
}
context
'when password was not touched'
do
before
do
allow
(
subject
).
to
receive
(
:password_touched?
).
and_return
(
false
)
end
it
{
is_expected
.
not_to
validate_presence_of
:username
}
end
context
'when password was touched'
do
before
do
allow
(
subject
).
to
receive
(
:password_touched?
).
and_return
(
true
)
end
it
{
is_expected
.
to
validate_presence_of
:username
}
end
end
context
'when the service is inactive'
do
let
(
:active
)
{
false
}
it
{
is_expected
.
not_to
validate_presence_of
:username
}
end
end
...
...
@@ -130,12 +149,18 @@ describe JenkinsService do
)
end
it
'reset password if url changed'
do
it
'reset
s
password if url changed'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins-edited.example.com/'
@jenkins_service
.
save
expect
(
@jenkins_service
.
password
).
to
be_nil
end
it
'resets password if username is blank'
do
@jenkins_service
.
username
=
''
@jenkins_service
.
save
expect
(
@jenkins_service
.
password
).
to
be_nil
end
it
'does not reset password if username changed'
do
@jenkins_service
.
username
=
'some_name'
@jenkins_service
.
save
...
...
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