Commit 7d45cd88 authored by James Edwards-Jones's avatar James Edwards-Jones

Can save GitHub service settings

parent ae965046
...@@ -41,12 +41,14 @@ module ServiceParams ...@@ -41,12 +41,14 @@ module ServiceParams
:notify, :notify,
:notify_only_broken_pipelines, :notify_only_broken_pipelines,
:notify_only_default_branch, :notify_only_default_branch,
:owner,
:password, :password,
:priority, :priority,
:project_key, :project_key,
:project_url, :project_url,
:recipients, :recipients,
:restrict_to_branch, :restrict_to_branch,
:repository_name,
:room, :room,
:send_from_committer_email, :send_from_committer_email,
:server, :server,
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
= boolean_to_icon @service.activated? = boolean_to_icon @service.activated?
%p= @service.description %p= @service.description
- if @service.respond_to?(:detailed_description)
%p= @service.detailed_description
.col-lg-9 .col-lg-9
= form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put, html: { class: 'gl-show-field-errors form-horizontal integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form| = form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put, html: { class: 'gl-show-field-errors form-horizontal integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form|
= render 'shared/service_settings', form: form, subject: @service = render 'shared/service_settings', form: form, subject: @service
......
class GithubService < Service class GithubService < Service
include Gitlab::Routing
include ActionView::Helpers::UrlHelper
prop_accessor :token, :api_url, :owner, :repository_name
validates :token, presence: true, if: :activated?
validates :api_url, url: true, allow_blank: true
validates :owner, presence: true, if: :activated?
validates :repository_name, presence: true, if: :activated?
default_value_for :pipeline_events, true
def title def title
'GitHub' 'GitHub'
end end
def description def description
'Sends pipeline notifications to GitHub' "See pipeline statuses on GitHub for your commits and pull requests"
end
def detailed_description
mirror_path = project_settings_repository_path(project)
mirror_link = link_to('mirroring your GitHub repository', mirror_path)
"This requires #{mirror_link} to this project.".html_safe
end end
def self.to_param def self.to_param
'github' 'github'
end end
def fields
[
{ type: 'text', name: "token", required: true, placeholder: "e.g. 8d3f016698e...", help: 'Create a <a href="https://github.com/settings/tokens">personal access token</a> with <code>repo:status</code> access granted and paste it here.'.html_safe },
{ type: 'text', name: "owner", required: true, help: 'The username or organization where the GitHub repository belongs. This can be found in the repository URL: https://github.com/<strong>owner</strong>/repository'.html_safe },
{ type: 'text', name: "repository_name", required: true, help: 'This can be found in the repository URL: https://github.com/owner/<strong>repository</strong>'.html_safe },
{ type: 'text', name: "api_url", placeholder: "https://api.github.com", help: 'Leave blank when using GitHub.com or use <code>https://YOUR-HOSTNAME/api/v3/</code> for GitHub Enterprise'.html_safe }
]
end
def self.supported_events
%w(pipeline)
end
end end
require 'spec_helper'
describe 'User activates GitHub Service' do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('GitHub')
end
it 'activates service' do
check('Active')
fill_in "Token", with: "aaaaaaaaaa"
fill_in "Api url", with: "https://api.github.com"
fill_in "Owner", with: "h5bp"
fill_in "Repository name", with: "html5-boilerplate"
click_button('Save')
expect(page).to have_content('GitHub activated.')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment