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
ab9e5cc1
Commit
ab9e5cc1
authored
Feb 23, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GithubService license check
parent
b9e08d97
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
11 deletions
+70
-11
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+5
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+4
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/models/project_services/github_service.rb
ee/app/models/project_services/github_service.rb
+6
-0
ee/spec/features/projects/services/user_activates_github_spec.rb
.../features/projects/services/user_activates_github_spec.rb
+30
-10
ee/spec/models/project_services/github_service_spec.rb
ee/spec/models/project_services/github_service_spec.rb
+24
-0
spec/features/projects/services/user_views_services_spec.rb
spec/features/projects/services/user_views_services_spec.rb
+0
-1
No files found.
app/controllers/projects/services_controller.rb
View file @
ab9e5cc1
...
...
@@ -3,6 +3,7 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
before_action
:authorize_admin_project!
before_action
:ensure_service_enabled
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
respond_to
:html
...
...
@@ -54,4 +55,8 @@ class Projects::ServicesController < Projects::ApplicationController
def
service
@service
||=
@project
.
find_or_initialize_service
(
params
[
:id
])
end
def
ensure_service_enabled
render_404
unless
service
end
end
ee/app/models/ee/project.rb
View file @
ab9e5cc1
...
...
@@ -451,6 +451,10 @@ module EE
disabled_services
.
push
(
'jenkins'
,
'jenkins_deprecated'
)
end
unless
feature_available?
(
:github_project_service_integration
)
disabled_services
.
push
(
'github'
)
end
disabled_services
end
end
...
...
ee/app/models/license.rb
View file @
ab9e5cc1
...
...
@@ -42,6 +42,7 @@ class License < ActiveRecord::Base
external_files_in_gitlab_ci
file_locks
geo
github_project_service_integration
group_issue_boards
jira_dev_panel_integration
ldap_group_sync_filter
...
...
ee/app/models/project_services/github_service.rb
View file @
ab9e5cc1
...
...
@@ -51,6 +51,8 @@ class GithubService < Service
end
def
execute
(
data
)
return
if
disabled?
status_message
=
StatusMessage
.
from_pipeline_data
(
project
,
data
)
update_status
(
status_message
)
...
...
@@ -80,6 +82,10 @@ class GithubService < Service
private
def
disabled?
project
.
disabled_services
.
include?
(
to_param
)
end
def
update_status
(
status_message
)
notifier
.
notify
(
status_message
.
sha
,
status_message
.
status
,
...
...
ee/spec/features/projects/services/user_activates_github_spec.rb
View file @
ab9e5cc1
...
...
@@ -7,8 +7,27 @@ describe 'User activates GitHub Service' do
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
end
context
'without a license'
do
it
"is excluded from the integrations index"
do
visit
project_settings_integrations_path
(
project
)
expect
(
page
).
not_to
have_link
(
'GitHub'
)
end
visit
(
project_settings_integrations_path
(
project
))
it
'renders 404 when trying to access service settings directly'
do
visit
edit_project_service_path
(
project
,
:github
)
expect
(
page
).
to
have_gitlab_http_status
(
404
)
end
end
context
'with valid license'
do
before
do
stub_licensed_features
(
github_project_service_integration:
true
)
visit
project_settings_integrations_path
(
project
)
click_link
(
'GitHub'
)
end
...
...
@@ -23,4 +42,5 @@ describe 'User activates GitHub Service' do
expect
(
page
).
to
have_content
(
'GitHub activated.'
)
end
end
end
ee/spec/models/project_services/github_service_spec.rb
View file @
ab9e5cc1
...
...
@@ -23,6 +23,10 @@ describe GithubService do
subject
{
described_class
.
create
(
service_params
)
}
before
do
stub_licensed_features
(
github_project_service_integration:
true
)
end
describe
"Associations"
do
it
{
is_expected
.
to
belong_to
:project
}
end
...
...
@@ -143,6 +147,16 @@ describe GithubService do
subject
.
execute
(
pipeline_sample_data
)
end
end
context
'without a license'
do
it
'does nothing'
do
stub_licensed_features
(
github_project_service_integration:
false
)
result
=
subject
.
execute
(
pipeline_sample_data
)
expect
(
result
).
to
be_nil
end
end
end
describe
'#can_test?'
do
...
...
@@ -196,5 +210,15 @@ describe GithubService do
expect
(
result
[
:success
]).
to
eq
false
expect
(
result
[
:result
].
to_s
).
to
end_with
(
'401 - Bad credentials'
)
end
context
'without a license'
do
it
'fails gracefully'
do
stub_licensed_features
(
github_project_service_integration:
false
)
result
=
subject
.
test
(
pipeline_sample_data
)
expect
(
result
[
:success
]).
to
eq
false
end
end
end
end
spec/features/projects/services/user_views_services_spec.rb
View file @
ab9e5cc1
...
...
@@ -22,6 +22,5 @@ describe 'User views services' do
expect
(
page
).
to
have_content
(
'Asana'
)
expect
(
page
).
to
have_content
(
'Irker (IRC gateway)'
)
expect
(
page
).
to
have_content
(
'Packagist'
)
expect
(
page
).
to
have_content
(
'GitHub'
)
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