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
Show 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
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
lib/gitlab/geo.rb
View file @
ea323463
...
...
@@ -51,7 +51,7 @@ module Gitlab
end
def
self
.
license_allows?
::
License
.
current
&
.
feature_available?
(
:geo
)
::
License
.
feature_available?
(
:geo
)
end
def
self
.
primary?
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
ea323463
...
...
@@ -9,8 +9,6 @@ describe Projects::EnvironmentsController do
end
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_return
(
false
)
project
.
add_master
(
user
)
sign_in
(
user
)
...
...
@@ -46,7 +44,7 @@ describe Projects::EnvironmentsController do
context
'when requesting available environments scope'
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
)
end
...
...
@@ -92,7 +90,7 @@ describe Projects::EnvironmentsController do
context
'when license does not has the GitLab_DeployBoard add-on'
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
)
end
...
...
@@ -305,7 +303,7 @@ describe Projects::EnvironmentsController do
let
(
:environment
)
{
create
(
:environment
,
name:
'production'
,
project:
project
)
}
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
)
end
...
...
@@ -333,7 +331,7 @@ describe Projects::EnvironmentsController do
context
'when license does not has the GitLab_DeployBoard add-on'
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
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
end
describe
'limited users'
do
let!
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
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
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
context
'with related_issues enabled'
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
stub_licensed_features
(
related_issues:
true
)
end
context
'with existing related issues'
do
...
...
@@ -79,8 +78,7 @@ describe 'Related issues', feature: true, js: true do
context
'with related_issues enabled'
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
stub_licensed_features
(
related_issues:
true
)
end
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
describe
'license_allows?'
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
end
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
end
...
...
spec/models/ee/user_spec.rb
View file @
ea323463
...
...
@@ -7,7 +7,7 @@ describe EE::User, models: true do
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
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
auditor_user:
true
)
end
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
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
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
,
:auditor
)).
to
be_invalid
end
...
...
@@ -1836,13 +1830,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
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
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
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
auditor_user:
false
)
expect
(
build
(
:user
)).
to
be_valid
end
...
...
@@ -1850,25 +1844,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
(
:feature_available?
).
with
(
:auditor_user
)
{
true
}
stub_licensed_features
(
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
(
:feature_available?
).
with
(
:auditor_user
)
{
false
}
stub_licensed_features
(
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_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
end
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
end
...
...
spec/policies/project_policy_spec.rb
View file @
ea323463
...
...
@@ -10,10 +10,6 @@ describe ProjectPolicy, models: true do
let
(
:admin
)
{
create
(
:admin
)
}
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
%i[
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
let
(
:issue
)
{
create
:issue
,
project:
project
}
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
stub_licensed_features
(
related_issues:
true
)
end
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
subject
{
entity
.
as_json
}
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_return
(
false
)
environment
.
project
.
team
<<
[
user
,
:master
]
end
...
...
@@ -46,7 +44,7 @@ describe EnvironmentEntity do
context
'with deployment service ready'
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
)
end
...
...
@@ -59,7 +57,7 @@ describe EnvironmentEntity do
context
'when license does not has the GitLab_DeployBoard add-on'
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
)
end
...
...
spec/services/issue_links/create_service_spec.rb
View file @
ea323463
...
...
@@ -11,8 +11,7 @@ describe IssueLinks::CreateService, service: true do
end
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
stub_licensed_features
(
related_issues:
true
)
project
.
team
<<
[
user
,
:developer
]
end
...
...
spec/services/issue_links/list_service_spec.rb
View file @
ea323463
...
...
@@ -7,8 +7,7 @@ describe IssueLinks::ListService, service: true do
let
(
:user_role
)
{
:developer
}
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
)
{
false
}
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:related_issues
)
{
true
}
stub_licensed_features
(
related_issues:
true
)
project
.
team
<<
[
user
,
user_role
]
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