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
ea323463
Commit
ea323463
authored
Jun 23, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use stub_licensed_features everywhere it is appropriate
parent
68918387
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
25 additions
and
44 deletions
+25
-44
app/helpers/auditor_user_helper.rb
app/helpers/auditor_user_helper.rb
+1
-1
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+1
-1
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+4
-6
spec/features/admin/admin_license_spec.rb
spec/features/admin/admin_license_spec.rb
+2
-2
spec/features/issuables/related_issues_spec.rb
spec/features/issuables/related_issues_spec.rb
+2
-4
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+2
-2
spec/models/ee/user_spec.rb
spec/models/ee/user_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+7
-13
spec/policies/project_policy_spec.rb
spec/policies/project_policy_spec.rb
+0
-4
spec/requests/projects/issue_links_controller_spec.rb
spec/requests/projects/issue_links_controller_spec.rb
+1
-2
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+2
-4
spec/services/issue_links/create_service_spec.rb
spec/services/issue_links/create_service_spec.rb
+1
-2
spec/services/issue_links/list_service_spec.rb
spec/services/issue_links/list_service_spec.rb
+1
-2
No files found.
app/helpers/auditor_user_helper.rb
View file @
ea323463
module
AuditorUserHelper
module
AuditorUserHelper
def
license_allows_auditor_user?
def
license_allows_auditor_user?
@license_allows_auditor_user
||=
(
::
License
.
current
&
.
feature_available?
(
:auditor_user
)
)
@license_allows_auditor_user
||=
::
License
.
feature_available?
(
:auditor_user
)
end
end
end
end
lib/gitlab/geo.rb
View file @
ea323463
...
@@ -51,7 +51,7 @@ module Gitlab
...
@@ -51,7 +51,7 @@ module Gitlab
end
end
def
self
.
license_allows?
def
self
.
license_allows?
::
License
.
current
&
.
feature_available?
(
:geo
)
::
License
.
feature_available?
(
:geo
)
end
end
def
self
.
primary?
def
self
.
primary?
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
ea323463
...
@@ -9,8 +9,6 @@ describe Projects::EnvironmentsController do
...
@@ -9,8 +9,6 @@ describe Projects::EnvironmentsController do
end
end
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_return
(
false
)
project
.
add_master
(
user
)
project
.
add_master
(
user
)
sign_in
(
user
)
sign_in
(
user
)
...
@@ -46,7 +44,7 @@ describe Projects::EnvironmentsController do
...
@@ -46,7 +44,7 @@ describe Projects::EnvironmentsController do
context
'when requesting available environments scope'
do
context
'when requesting available environments scope'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
true
)
stub_licensed_features
(
deploy_board:
true
)
get
:index
,
environment_params
(
format: :json
,
scope: :available
)
get
:index
,
environment_params
(
format: :json
,
scope: :available
)
end
end
...
@@ -92,7 +90,7 @@ describe Projects::EnvironmentsController do
...
@@ -92,7 +90,7 @@ describe Projects::EnvironmentsController do
context
'when license does not has the GitLab_DeployBoard add-on'
do
context
'when license does not has the GitLab_DeployBoard add-on'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
false
)
stub_licensed_features
(
deploy_board:
false
)
get
:index
,
environment_params
(
format: :json
)
get
:index
,
environment_params
(
format: :json
)
end
end
...
@@ -305,7 +303,7 @@ describe Projects::EnvironmentsController do
...
@@ -305,7 +303,7 @@ describe Projects::EnvironmentsController do
let
(
:environment
)
{
create
(
:environment
,
name:
'production'
,
project:
project
)
}
let
(
:environment
)
{
create
(
:environment
,
name:
'production'
,
project:
project
)
}
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
true
)
stub_licensed_features
(
deploy_board:
true
)
allow_any_instance_of
(
Environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
allow_any_instance_of
(
Environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
end
end
...
@@ -333,7 +331,7 @@ describe Projects::EnvironmentsController do
...
@@ -333,7 +331,7 @@ describe Projects::EnvironmentsController do
context
'when license does not has the GitLab_DeployBoard add-on'
do
context
'when license does not has the GitLab_DeployBoard add-on'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
false
)
stub_licensed_features
(
deploy_board:
false
)
end
end
it
'does not return any data'
do
it
'does not return any data'
do
...
...
spec/features/admin/admin_license_spec.rb
View file @
ea323463
...
@@ -16,9 +16,9 @@ feature "License Admin", feature: true do
...
@@ -16,9 +16,9 @@ feature "License Admin", feature: true do
end
end
describe
'limited users'
do
describe
'limited users'
do
let!
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
it
'shows panel counts'
do
it
'shows panel counts'
do
restrictions
=
{
active_user_count:
2000
}
allow_any_instance_of
(
Gitlab
::
License
).
to
receive
(
:restrictions
).
and_return
(
restrictions
)
visit
admin_license_path
visit
admin_license_path
page
.
within
'.license-panel'
do
page
.
within
'.license-panel'
do
...
...
spec/features/issuables/related_issues_spec.rb
View file @
ea323463
...
@@ -19,8 +19,7 @@ describe 'Related issues', feature: true, js: true do
...
@@ -19,8 +19,7 @@ describe 'Related issues', feature: true, js: true do
context
'with related_issues enabled'
do
context
'with related_issues enabled'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
stub_licensed_features
(
related_issues:
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
end
end
context
'with existing related issues'
do
context
'with existing related issues'
do
...
@@ -79,8 +78,7 @@ describe 'Related issues', feature: true, js: true do
...
@@ -79,8 +78,7 @@ describe 'Related issues', feature: true, js: true do
context
'with related_issues enabled'
do
context
'with related_issues enabled'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
stub_licensed_features
(
related_issues:
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
end
end
context
'without existing related issues'
do
context
'without existing related issues'
do
...
...
spec/lib/gitlab/geo_spec.rb
View file @
ea323463
...
@@ -96,12 +96,12 @@ describe Gitlab::Geo, lib: true do
...
@@ -96,12 +96,12 @@ describe Gitlab::Geo, lib: true do
describe
'license_allows?'
do
describe
'license_allows?'
do
it
'returns true if license has Geo addon'
do
it
'returns true if license has Geo addon'
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:geo
)
{
true
}
stub_licensed_features
(
geo:
true
)
expect
(
described_class
.
license_allows?
).
to
be_truthy
expect
(
described_class
.
license_allows?
).
to
be_truthy
end
end
it
'returns false if license doesnt have Geo addon'
do
it
'returns false if license doesnt have Geo addon'
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:geo
)
{
false
}
stub_licensed_features
(
geo:
false
)
expect
(
described_class
.
license_allows?
).
to
be_falsey
expect
(
described_class
.
license_allows?
).
to
be_falsey
end
end
...
...
spec/models/ee/user_spec.rb
View file @
ea323463
...
@@ -7,7 +7,7 @@ describe EE::User, models: true do
...
@@ -7,7 +7,7 @@ describe EE::User, models: true do
before
do
before
do
# `auditor?` returns true only when the user is an auditor _and_ the auditor license
# `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.
# 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
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
auditor_user:
true
)
end
end
it
"does not set 'auditor' for an invalid access level"
do
it
"does not set 'auditor' for an invalid access level"
do
...
...
spec/models/user_spec.rb
View file @
ea323463
...
@@ -1816,15 +1816,9 @@ describe User, models: true do
...
@@ -1816,15 +1816,9 @@ describe User, models: true do
end
end
describe
'the GitLab_Auditor_User add-on'
do
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
context
'creating an auditor user'
do
it
"does not allow creating an auditor user if the addon isn't enabled"
do
it
"does not allow creating an auditor user if the addon isn't enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
,
:auditor
)).
to
be_invalid
expect
(
build
(
:user
,
:auditor
)).
to
be_invalid
end
end
...
@@ -1836,13 +1830,13 @@ describe User, models: true do
...
@@ -1836,13 +1830,13 @@ describe User, models: true do
end
end
it
"allows creating an auditor user if the addon is enabled"
do
it
"allows creating an auditor user if the addon is enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
auditor_user:
true
)
expect
(
build
(
:user
,
:auditor
)).
to
be_valid
expect
(
build
(
:user
,
:auditor
)).
to
be_valid
end
end
it
"allows creating a regular user if the addon isn't enabled"
do
it
"allows creating a regular user if the addon isn't enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
)).
to
be_valid
expect
(
build
(
:user
)).
to
be_valid
end
end
...
@@ -1850,25 +1844,25 @@ describe User, models: true do
...
@@ -1850,25 +1844,25 @@ describe User, models: true do
context
'#auditor?'
do
context
'#auditor?'
do
it
"returns true for an auditor user if the addon is enabled"
do
it
"returns true for an auditor user if the addon is enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
auditor_user:
true
)
expect
(
build
(
:user
,
:auditor
)).
to
be_auditor
expect
(
build
(
:user
,
:auditor
)).
to
be_auditor
end
end
it
"returns false for an auditor user if the addon is not enabled"
do
it
"returns false for an auditor user if the addon is not enabled"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
end
end
it
"returns false for an auditor user if a license is not present"
do
it
"returns false for an auditor user if a license is not present"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
expect
(
build
(
:user
,
:auditor
)).
not_to
be_auditor
end
end
it
"returns false for a non-auditor user even if the addon is present"
do
it
"returns false for a non-auditor user even if the addon is present"
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
auditor_user:
true
)
expect
(
build
(
:user
)).
not_to
be_auditor
expect
(
build
(
:user
)).
not_to
be_auditor
end
end
...
...
spec/policies/project_policy_spec.rb
View file @
ea323463
...
@@ -10,10 +10,6 @@ describe ProjectPolicy, models: true do
...
@@ -10,10 +10,6 @@ describe ProjectPolicy, models: true do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:empty_project
,
:public
,
namespace:
owner
.
namespace
)
}
let
(
:project
)
{
create
(
:empty_project
,
:public
,
namespace:
owner
.
namespace
)
}
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
true
}
end
let
(
:guest_permissions
)
do
let
(
:guest_permissions
)
do
%i[
%i[
read_project read_board read_list read_wiki read_issue read_label
read_project read_board read_list read_wiki read_issue read_label
...
...
spec/requests/projects/issue_links_controller_spec.rb
View file @
ea323463
...
@@ -6,8 +6,7 @@ describe Projects::IssueLinksController do
...
@@ -6,8 +6,7 @@ describe Projects::IssueLinksController do
let
(
:issue
)
{
create
:issue
,
project:
project
}
let
(
:issue
)
{
create
:issue
,
project:
project
}
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
stub_licensed_features
(
related_issues:
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
end
end
describe
'GET /*namespace_id/:project_id/issues/:issue_id/links'
do
describe
'GET /*namespace_id/:project_id/issues/:issue_id/links'
do
...
...
spec/serializers/environment_entity_spec.rb
View file @
ea323463
...
@@ -11,8 +11,6 @@ describe EnvironmentEntity do
...
@@ -11,8 +11,6 @@ describe EnvironmentEntity do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_return
(
false
)
environment
.
project
.
team
<<
[
user
,
:master
]
environment
.
project
.
team
<<
[
user
,
:master
]
end
end
...
@@ -46,7 +44,7 @@ describe EnvironmentEntity do
...
@@ -46,7 +44,7 @@ describe EnvironmentEntity do
context
'with deployment service ready'
do
context
'with deployment service ready'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
true
)
stub_licensed_features
(
deploy_board:
true
)
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
end
end
...
@@ -59,7 +57,7 @@ describe EnvironmentEntity do
...
@@ -59,7 +57,7 @@ describe EnvironmentEntity do
context
'when license does not has the GitLab_DeployBoard add-on'
do
context
'when license does not has the GitLab_DeployBoard add-on'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:deploy_board
).
and_return
(
false
)
stub_licensed_features
(
deploy_board:
false
)
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
allow
(
environment
).
to
receive
(
:deployment_service_ready?
).
and_return
(
true
)
end
end
...
...
spec/services/issue_links/create_service_spec.rb
View file @
ea323463
...
@@ -11,8 +11,7 @@ describe IssueLinks::CreateService, service: true do
...
@@ -11,8 +11,7 @@ describe IssueLinks::CreateService, service: true do
end
end
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
stub_licensed_features
(
related_issues:
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
end
end
...
...
spec/services/issue_links/list_service_spec.rb
View file @
ea323463
...
@@ -7,8 +7,7 @@ describe IssueLinks::ListService, service: true do
...
@@ -7,8 +7,7 @@ describe IssueLinks::ListService, service: true do
let
(
:user_role
)
{
:developer
}
let
(
:user_role
)
{
:developer
}
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
stub_licensed_features
(
related_issues:
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
project
.
team
<<
[
user
,
user_role
]
project
.
team
<<
[
user
,
user_role
]
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