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
c1870909
Commit
c1870909
authored
Feb 06, 2017
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build.
There were failures related to cross-spec contamination of the `License` mocks.
parent
9b071cd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
spec/models/user_spec.rb
spec/models/user_spec.rb
+19
-7
spec/requests/api/license_spec.rb
spec/requests/api/license_spec.rb
+1
-1
No files found.
spec/models/user_spec.rb
View file @
c1870909
...
...
@@ -1494,9 +1494,15 @@ describe User, models: true do
end
describe
'the GitLab_Auditor_User add-on'
do
let
(
:license
)
{
build
(
:license
)
}
before
do
allow
(
::
License
).
to
receive
(
:current
).
and_return
(
license
)
end
context
'creating an auditor user'
do
it
"does not allow creating an auditor user if the addon isn't enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
false
}
expect
(
build
(
:user
,
:auditor
)).
to
be_invalid
end
...
...
@@ -1508,13 +1514,13 @@ describe User, models: true do
end
it
"allows creating an auditor user if the addon is enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({
'GitLab_Auditor_User'
=>
1
})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
true
}
expect
(
build
(
:user
,
:auditor
)).
to
be_valid
end
it
"allows creating a regular user if the addon isn't enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
false
}
expect
(
build
(
:user
)).
to
be_valid
end
...
...
@@ -1522,25 +1528,25 @@ describe User, models: true do
context
'#auditor?'
do
it
"returns true for an auditor user if the addon is enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({
'GitLab_Auditor_User'
=>
1
})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
true
}
expect
(
build
(
:user
,
:auditor
)).
to
be_auditor
end
it
"returns false for an auditor user if the addon is not enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
false
}
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
end
it
"returns false for an auditor user if a license is not present"
do
allow
(
License
).
to
receive
(
:current
).
and_return
nil
allow
_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_Auditor_User'
)
{
false
}
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
end
it
"returns false for a non-auditor user even if the addon is present"
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on
s
).
and_return
({
'GitLab_Auditor_User'
=>
1
})
allow_any_instance_of
(
License
).
to
receive
(
:add_on
?
).
with
(
'GitLab_Auditor_User'
)
{
true
}
expect
(
build
(
:user
)).
not_to
be_auditor
end
...
...
@@ -1549,6 +1555,12 @@ describe User, models: true do
context
'access_level='
do
let
(
:user
)
{
build
(
:user
)
}
before
do
# `auditor?` returns true only when the user is an auditor _and_ the auditor license
# add-on is present. We aren't testing this here, so we can assume that the add-on exists.
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_Auditor_User'
)
{
true
}
end
it
'does nothing for an invalid access level'
do
user
.
access_level
=
:invalid_access_level
...
...
spec/requests/api/license_spec.rb
View file @
c1870909
...
...
@@ -17,7 +17,7 @@ describe API::License, api: true do
expect
(
Date
.
parse
(
json_response
[
'expires_at'
])).
to
eq
Date
.
today
+
11
.
months
expect
(
json_response
[
'active_users'
]).
to
eq
1
expect
(
json_response
[
'licensee'
]).
not_to
be_empty
expect
(
json_response
[
'add_ons'
]).
to
eq
({
'GitLab_FileLocks'
=>
1
})
expect
(
json_response
[
'add_ons'
]).
to
eq
({
'GitLab_FileLocks'
=>
1
,
'GitLab_Auditor_User'
=>
1
})
end
it
'denies access if not admin'
do
...
...
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