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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
33d82ccb
Commit
33d82ccb
authored
May 22, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify test&save actions when setting a service integration
parent
dd0f8b8c
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
187 additions
and
174 deletions
+187
-174
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+19
-13
app/models/project_services/asana_service.rb
app/models/project_services/asana_service.rb
+2
-1
app/models/project_services/assembla_service.rb
app/models/project_services/assembla_service.rb
+1
-1
app/models/project_services/bamboo_service.rb
app/models/project_services/bamboo_service.rb
+2
-2
app/models/project_services/buildkite_service.rb
app/models/project_services/buildkite_service.rb
+2
-2
app/models/project_services/campfire_service.rb
app/models/project_services/campfire_service.rb
+2
-2
app/models/project_services/chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+1
-1
app/models/project_services/custom_issue_tracker_service.rb
app/models/project_services/custom_issue_tracker_service.rb
+3
-3
app/models/project_services/drone_ci_service.rb
app/models/project_services/drone_ci_service.rb
+2
-2
app/models/project_services/external_wiki_service.rb
app/models/project_services/external_wiki_service.rb
+1
-1
app/models/project_services/flowdock_service.rb
app/models/project_services/flowdock_service.rb
+1
-1
app/models/project_services/gemnasium_service.rb
app/models/project_services/gemnasium_service.rb
+2
-2
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+1
-1
app/models/project_services/irker_service.rb
app/models/project_services/irker_service.rb
+1
-1
app/models/project_services/issue_tracker_service.rb
app/models/project_services/issue_tracker_service.rb
+3
-3
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+5
-5
app/models/project_services/mock_ci_service.rb
app/models/project_services/mock_ci_service.rb
+2
-1
app/models/project_services/pipelines_email_service.rb
app/models/project_services/pipelines_email_service.rb
+2
-1
app/models/project_services/pivotaltracker_service.rb
app/models/project_services/pivotaltracker_service.rb
+2
-1
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+2
-1
app/models/project_services/pushover_service.rb
app/models/project_services/pushover_service.rb
+3
-3
app/models/project_services/teamcity_service.rb
app/models/project_services/teamcity_service.rb
+2
-2
app/views/shared/_field.html.haml
app/views/shared/_field.html.haml
+1
-0
config/routes/project.rb
config/routes/project.rb
+1
-1
features/project/service.feature
features/project/service.feature
+13
-13
features/steps/project/services.rb
features/steps/project/services.rb
+29
-41
spec/controllers/projects/services_controller_spec.rb
spec/controllers/projects/services_controller_spec.rb
+52
-63
spec/factories/services.rb
spec/factories/services.rb
+6
-0
spec/features/projects/services/mattermost_slash_command_spec.rb
...atures/projects/services/mattermost_slash_command_spec.rb
+13
-3
spec/features/projects/services/slack_slash_command_spec.rb
spec/features/projects/services/slack_slash_command_spec.rb
+11
-3
No files found.
app/controllers/projects/services_controller.rb
View file @
33d82ccb
...
@@ -4,6 +4,7 @@ class Projects::ServicesController < Projects::ApplicationController
...
@@ -4,6 +4,7 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
# Authorize
before_action
:authorize_admin_project!
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
before_action
:build_service
,
only:
[
:update
,
:test
]
respond_to
:html
respond_to
:html
...
@@ -13,36 +14,41 @@ class Projects::ServicesController < Projects::ApplicationController
...
@@ -13,36 +14,41 @@ class Projects::ServicesController < Projects::ApplicationController
end
end
def
update
def
update
@service
.
assign_attributes
(
service_params
[
:service
])
if
@service
.
save
(
context: :manual_change
)
if
@service
.
save
(
context: :manual_change
)
redirect_to
(
redirect_to
(
namespace_project_settings_integrations_path
(
@project
.
namespace
,
@project
),
notice:
success_message
)
edit_namespace_project_service_path
(
@project
.
namespace
,
@project
,
@service
.
to_param
),
notice:
'Successfully updated.'
)
else
else
render
'edit'
render
'edit'
end
end
end
end
def
test
def
test
return
render
_404
unless
@service
.
can_test?
return
render
json:
{},
status: :not_found
unless
@service
.
can_test?
data
=
@service
.
test_data
(
project
,
current_user
)
data
=
@service
.
test_data
(
project
,
current_user
)
outcome
=
@service
.
test
(
data
)
outcome
=
@service
.
test
(
data
)
if
outcome
[
:success
]
message
=
{}
message
=
{
notice:
'We sent a request to the provided URL'
}
unless
outcome
[
:success
]
else
message
=
{
error:
true
,
message:
'Test failed'
,
service_response:
outcome
[
:result
].
to_s
}
error_message
=
"We tried to send a request to the provided URL but an error occurred"
error_message
<<
":
#{
outcome
[
:result
]
}
"
if
outcome
[
:result
].
present?
message
=
{
alert:
error_message
}
end
end
re
direct_back_or_default
(
options:
message
)
re
nder
json:
message
,
status: :ok
end
end
private
private
def
success_message
if
@service
.
active?
"
#{
@service
.
title
}
activated."
else
"
#{
@service
.
title
}
settings saved, but not activated."
end
end
def
build_service
@service
.
assign_attributes
(
service_params
[
:service
])
end
def
service
def
service
@service
||=
@project
.
find_or_initialize_service
(
params
[
:id
])
@service
||=
@project
.
find_or_initialize_service
(
params
[
:id
])
end
end
...
...
app/models/project_services/asana_service.rb
View file @
33d82ccb
...
@@ -34,7 +34,8 @@ http://app.asana.com/-/account_api'
...
@@ -34,7 +34,8 @@ http://app.asana.com/-/account_api'
{
{
type:
'text'
,
type:
'text'
,
name:
'api_key'
,
name:
'api_key'
,
placeholder:
'User Personal Access Token. User must have access to task, all comments will be attributed to this user.'
placeholder:
'User Personal Access Token. User must have access to task, all comments will be attributed to this user.'
,
required:
true
},
},
{
{
type:
'text'
,
type:
'text'
,
...
...
app/models/project_services/assembla_service.rb
View file @
33d82ccb
...
@@ -18,7 +18,7 @@ class AssemblaService < Service
...
@@ -18,7 +18,7 @@ class AssemblaService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'token'
,
placeholder:
''
},
{
type:
'text'
,
name:
'token'
,
placeholder:
''
,
required:
true
},
{
type:
'text'
,
name:
'subdomain'
,
placeholder:
''
}
{
type:
'text'
,
name:
'subdomain'
,
placeholder:
''
}
]
]
end
end
...
...
app/models/project_services/bamboo_service.rb
View file @
33d82ccb
...
@@ -47,9 +47,9 @@ class BambooService < CiService
...
@@ -47,9 +47,9 @@ class BambooService < CiService
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'bamboo_url'
,
{
type:
'text'
,
name:
'bamboo_url'
,
placeholder:
'Bamboo root URL like https://bamboo.example.com'
},
placeholder:
'Bamboo root URL like https://bamboo.example.com'
,
required:
true
},
{
type:
'text'
,
name:
'build_key'
,
{
type:
'text'
,
name:
'build_key'
,
placeholder:
'Bamboo build plan key like KEY'
},
placeholder:
'Bamboo build plan key like KEY'
,
required:
true
},
{
type:
'text'
,
name:
'username'
,
{
type:
'text'
,
name:
'username'
,
placeholder:
'A user with API access, if applicable'
},
placeholder:
'A user with API access, if applicable'
},
{
type:
'password'
,
name:
'password'
}
{
type:
'password'
,
name:
'password'
}
...
...
app/models/project_services/buildkite_service.rb
View file @
33d82ccb
...
@@ -58,11 +58,11 @@ class BuildkiteService < CiService
...
@@ -58,11 +58,11 @@ class BuildkiteService < CiService
[
[
{
type:
'text'
,
{
type:
'text'
,
name:
'token'
,
name:
'token'
,
placeholder:
'Buildkite project GitLab token'
},
placeholder:
'Buildkite project GitLab token'
,
required:
true
},
{
type:
'text'
,
{
type:
'text'
,
name:
'project_url'
,
name:
'project_url'
,
placeholder:
"
#{
ENDPOINT
}
/example/project"
},
placeholder:
"
#{
ENDPOINT
}
/example/project"
,
required:
true
},
{
type:
'checkbox'
,
{
type:
'checkbox'
,
name:
'enable_ssl_verification'
,
name:
'enable_ssl_verification'
,
...
...
app/models/project_services/campfire_service.rb
View file @
33d82ccb
...
@@ -18,7 +18,7 @@ class CampfireService < Service
...
@@ -18,7 +18,7 @@ class CampfireService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'token'
,
placeholder:
''
},
{
type:
'text'
,
name:
'token'
,
placeholder:
''
,
required:
true
},
{
type:
'text'
,
name:
'subdomain'
,
placeholder:
''
},
{
type:
'text'
,
name:
'subdomain'
,
placeholder:
''
},
{
type:
'text'
,
name:
'room'
,
placeholder:
''
}
{
type:
'text'
,
name:
'room'
,
placeholder:
''
}
]
]
...
@@ -76,7 +76,7 @@ class CampfireService < Service
...
@@ -76,7 +76,7 @@ class CampfireService < Service
# Returns a list of rooms, or [].
# Returns a list of rooms, or [].
# https://github.com/basecamp/campfire-api/blob/master/sections/rooms.md#get-rooms
# https://github.com/basecamp/campfire-api/blob/master/sections/rooms.md#get-rooms
def
rooms
(
auth
)
def
rooms
(
auth
)
res
=
self
.
class
.
get
(
"/rooms.json"
,
auth
)
res
=
self
.
class
.
get
(
"/rooms.json"
,
auth
)
res
.
code
==
200
?
res
[
"rooms"
]
:
[]
res
.
code
==
200
?
res
[
"rooms"
]
:
[]
end
end
...
...
app/models/project_services/chat_notification_service.rb
View file @
33d82ccb
...
@@ -36,7 +36,7 @@ class ChatNotificationService < Service
...
@@ -36,7 +36,7 @@ class ChatNotificationService < Service
def
default_fields
def
default_fields
[
[
{
type:
'text'
,
name:
'webhook'
,
placeholder:
"e.g.
#{
webhook_placeholder
}
"
},
{
type:
'text'
,
name:
'webhook'
,
placeholder:
"e.g.
#{
webhook_placeholder
}
"
,
required:
true
},
{
type:
'text'
,
name:
'username'
,
placeholder:
'e.g. GitLab'
},
{
type:
'text'
,
name:
'username'
,
placeholder:
'e.g. GitLab'
},
{
type:
'checkbox'
,
name:
'notify_only_broken_pipelines'
},
{
type:
'checkbox'
,
name:
'notify_only_broken_pipelines'
},
{
type:
'checkbox'
,
name:
'notify_only_default_branch'
}
{
type:
'checkbox'
,
name:
'notify_only_default_branch'
}
...
...
app/models/project_services/custom_issue_tracker_service.rb
View file @
33d82ccb
...
@@ -31,9 +31,9 @@ class CustomIssueTrackerService < IssueTrackerService
...
@@ -31,9 +31,9 @@ class CustomIssueTrackerService < IssueTrackerService
[
[
{
type:
'text'
,
name:
'title'
,
placeholder:
title
},
{
type:
'text'
,
name:
'title'
,
placeholder:
title
},
{
type:
'text'
,
name:
'description'
,
placeholder:
description
},
{
type:
'text'
,
name:
'description'
,
placeholder:
description
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Project url'
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Project url'
,
required:
true
},
{
type:
'text'
,
name:
'issues_url'
,
placeholder:
'Issue url'
},
{
type:
'text'
,
name:
'issues_url'
,
placeholder:
'Issue url'
,
required:
true
},
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
}
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
,
required:
true
}
]
]
end
end
end
end
app/models/project_services/drone_ci_service.rb
View file @
33d82ccb
...
@@ -93,8 +93,8 @@ class DroneCiService < CiService
...
@@ -93,8 +93,8 @@ class DroneCiService < CiService
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'token'
,
placeholder:
'Drone CI project specific token'
},
{
type:
'text'
,
name:
'token'
,
placeholder:
'Drone CI project specific token'
,
required:
true
},
{
type:
'text'
,
name:
'drone_url'
,
placeholder:
'http://drone.example.com'
},
{
type:
'text'
,
name:
'drone_url'
,
placeholder:
'http://drone.example.com'
,
required:
true
},
{
type:
'checkbox'
,
name:
'enable_ssl_verification'
,
title:
"Enable SSL verification"
}
{
type:
'checkbox'
,
name:
'enable_ssl_verification'
,
title:
"Enable SSL verification"
}
]
]
end
end
...
...
app/models/project_services/external_wiki_service.rb
View file @
33d82ccb
...
@@ -19,7 +19,7 @@ class ExternalWikiService < Service
...
@@ -19,7 +19,7 @@ class ExternalWikiService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'external_wiki_url'
,
placeholder:
'The URL of the external Wiki'
}
{
type:
'text'
,
name:
'external_wiki_url'
,
placeholder:
'The URL of the external Wiki'
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/flowdock_service.rb
View file @
33d82ccb
...
@@ -18,7 +18,7 @@ class FlowdockService < Service
...
@@ -18,7 +18,7 @@ class FlowdockService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'token'
,
placeholder:
'Flowdock Git source token'
}
{
type:
'text'
,
name:
'token'
,
placeholder:
'Flowdock Git source token'
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/gemnasium_service.rb
View file @
33d82ccb
...
@@ -18,8 +18,8 @@ class GemnasiumService < Service
...
@@ -18,8 +18,8 @@ class GemnasiumService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'api_key'
,
placeholder:
'Your personal API KEY on gemnasium.com '
},
{
type:
'text'
,
name:
'api_key'
,
placeholder:
'Your personal API KEY on gemnasium.com '
,
required:
true
},
{
type:
'text'
,
name:
'token'
,
placeholder:
'The project\'s slug on gemnasium.com'
}
{
type:
'text'
,
name:
'token'
,
placeholder:
'The project\'s slug on gemnasium.com'
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/hipchat_service.rb
View file @
33d82ccb
...
@@ -33,7 +33,7 @@ class HipchatService < Service
...
@@ -33,7 +33,7 @@ class HipchatService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'token'
,
placeholder:
'Room token'
},
{
type:
'text'
,
name:
'token'
,
placeholder:
'Room token'
,
required:
true
},
{
type:
'text'
,
name:
'room'
,
placeholder:
'Room name or ID'
},
{
type:
'text'
,
name:
'room'
,
placeholder:
'Room name or ID'
},
{
type:
'checkbox'
,
name:
'notify'
},
{
type:
'checkbox'
,
name:
'notify'
},
{
type:
'select'
,
name:
'color'
,
choices:
%w(yellow red green purple gray random)
},
{
type:
'select'
,
name:
'color'
,
choices:
%w(yellow red green purple gray random)
},
...
...
app/models/project_services/irker_service.rb
View file @
33d82ccb
...
@@ -49,7 +49,7 @@ class IrkerService < Service
...
@@ -49,7 +49,7 @@ class IrkerService < Service
help:
'A default IRC URI to prepend before each recipient (optional)'
,
help:
'A default IRC URI to prepend before each recipient (optional)'
,
placeholder:
'irc://irc.network.net:6697/'
},
placeholder:
'irc://irc.network.net:6697/'
},
{
type:
'textarea'
,
name:
'recipients'
,
{
type:
'textarea'
,
name:
'recipients'
,
placeholder:
'Recipients/channels separated by whitespaces'
,
placeholder:
'Recipients/channels separated by whitespaces'
,
required:
true
,
help:
'Recipients have to be specified with a full URI: '
\
help:
'Recipients have to be specified with a full URI: '
\
'irc[s]://irc.network.net[:port]/#channel. Special cases: if '
\
'irc[s]://irc.network.net[:port]/#channel. Special cases: if '
\
'you want the channel to be a nickname instead, append ",isnick" to '
\
'you want the channel to be a nickname instead, append ",isnick" to '
\
...
...
app/models/project_services/issue_tracker_service.rb
View file @
33d82ccb
...
@@ -32,9 +32,9 @@ class IssueTrackerService < Service
...
@@ -32,9 +32,9 @@ class IssueTrackerService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'description'
,
placeholder:
description
},
{
type:
'text'
,
name:
'description'
,
placeholder:
description
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Project url'
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Project url'
,
required:
true
},
{
type:
'text'
,
name:
'issues_url'
,
placeholder:
'Issue url'
},
{
type:
'text'
,
name:
'issues_url'
,
placeholder:
'Issue url'
,
required:
true
},
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
}
{
type:
'text'
,
name:
'new_issue_url'
,
placeholder:
'New Issue url'
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/jira_service.rb
View file @
33d82ccb
...
@@ -86,12 +86,12 @@ class JiraService < IssueTrackerService
...
@@ -86,12 +86,12 @@ class JiraService < IssueTrackerService
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'url'
,
title:
'Web URL'
,
placeholder:
'https://jira.example.com'
},
{
type:
'text'
,
name:
'url'
,
title:
'Web URL'
,
placeholder:
'https://jira.example.com'
,
required:
true
},
{
type:
'text'
,
name:
'api_url'
,
title:
'JIRA API URL'
,
placeholder:
'If different from Web URL'
},
{
type:
'text'
,
name:
'api_url'
,
title:
'JIRA API URL'
,
placeholder:
'If different from Web URL'
},
{
type:
'text'
,
name:
'project_key'
,
placeholder:
'Project Key'
},
{
type:
'text'
,
name:
'project_key'
,
placeholder:
'Project Key'
,
required:
true
},
{
type:
'text'
,
name:
'username'
,
placeholder:
''
},
{
type:
'text'
,
name:
'username'
,
placeholder:
''
,
required:
true
},
{
type:
'password'
,
name:
'password'
,
placeholder:
''
},
{
type:
'password'
,
name:
'password'
,
placeholder:
''
,
required:
true
},
{
type:
'text'
,
name:
'jira_issue_transition_id'
,
placeholder:
''
}
{
type:
'text'
,
name:
'jira_issue_transition_id'
,
placeholder:
''
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/mock_ci_service.rb
View file @
33d82ccb
...
@@ -21,7 +21,8 @@ class MockCiService < CiService
...
@@ -21,7 +21,8 @@ class MockCiService < CiService
[
[
{
type:
'text'
,
{
type:
'text'
,
name:
'mock_service_url'
,
name:
'mock_service_url'
,
placeholder:
'http://localhost:4004'
}
placeholder:
'http://localhost:4004'
,
required:
true
}
]
]
end
end
...
...
app/models/project_services/pipelines_email_service.rb
View file @
33d82ccb
...
@@ -53,7 +53,8 @@ class PipelinesEmailService < Service
...
@@ -53,7 +53,8 @@ class PipelinesEmailService < Service
[
[
{
type:
'textarea'
,
{
type:
'textarea'
,
name:
'recipients'
,
name:
'recipients'
,
placeholder:
'Emails separated by comma'
},
placeholder:
'Emails separated by comma'
,
required:
true
},
{
type:
'checkbox'
,
{
type:
'checkbox'
,
name:
'notify_only_broken_pipelines'
}
name:
'notify_only_broken_pipelines'
}
]
]
...
...
app/models/project_services/pivotaltracker_service.rb
View file @
33d82ccb
...
@@ -23,7 +23,8 @@ class PivotaltrackerService < Service
...
@@ -23,7 +23,8 @@ class PivotaltrackerService < Service
{
{
type:
'text'
,
type:
'text'
,
name:
'token'
,
name:
'token'
,
placeholder:
'Pivotal Tracker API token.'
placeholder:
'Pivotal Tracker API token.'
,
required:
true
},
},
{
{
type:
'text'
,
type:
'text'
,
...
...
app/models/project_services/prometheus_service.rb
View file @
33d82ccb
...
@@ -49,7 +49,8 @@ class PrometheusService < MonitoringService
...
@@ -49,7 +49,8 @@ class PrometheusService < MonitoringService
type:
'text'
,
type:
'text'
,
name:
'api_url'
,
name:
'api_url'
,
title:
'API URL'
,
title:
'API URL'
,
placeholder:
'Prometheus API Base URL, like http://prometheus.example.com/'
placeholder:
'Prometheus API Base URL, like http://prometheus.example.com/'
,
required:
true
}
}
]
]
end
end
...
...
app/models/project_services/pushover_service.rb
View file @
33d82ccb
...
@@ -19,10 +19,10 @@ class PushoverService < Service
...
@@ -19,10 +19,10 @@ class PushoverService < Service
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'api_key'
,
placeholder:
'Your application key'
},
{
type:
'text'
,
name:
'api_key'
,
placeholder:
'Your application key'
,
required:
true
},
{
type:
'text'
,
name:
'user_key'
,
placeholder:
'Your user key'
},
{
type:
'text'
,
name:
'user_key'
,
placeholder:
'Your user key'
,
required:
true
},
{
type:
'text'
,
name:
'device'
,
placeholder:
'Leave blank for all active devices'
},
{
type:
'text'
,
name:
'device'
,
placeholder:
'Leave blank for all active devices'
},
{
type:
'select'
,
name:
'priority'
,
choices:
{
type:
'select'
,
name:
'priority'
,
required:
true
,
choices:
[
[
[
'Lowest Priority'
,
-
2
],
[
'Lowest Priority'
,
-
2
],
[
'Low Priority'
,
-
1
],
[
'Low Priority'
,
-
1
],
...
...
app/models/project_services/teamcity_service.rb
View file @
33d82ccb
...
@@ -50,9 +50,9 @@ class TeamcityService < CiService
...
@@ -50,9 +50,9 @@ class TeamcityService < CiService
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'teamcity_url'
,
{
type:
'text'
,
name:
'teamcity_url'
,
placeholder:
'TeamCity root URL like https://teamcity.example.com'
},
placeholder:
'TeamCity root URL like https://teamcity.example.com'
,
required:
true
},
{
type:
'text'
,
name:
'build_type'
,
{
type:
'text'
,
name:
'build_type'
,
placeholder:
'Build configuration ID'
},
placeholder:
'Build configuration ID'
,
required:
true
},
{
type:
'text'
,
name:
'username'
,
{
type:
'text'
,
name:
'username'
,
placeholder:
'A user with permissions to trigger a manual build'
},
placeholder:
'A user with permissions to trigger a manual build'
},
{
type:
'password'
,
name:
'password'
}
{
type:
'password'
,
name:
'password'
}
...
...
app/views/shared/_field.html.haml
View file @
33d82ccb
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
-
value
=
@service
.
send
(
name
)
-
value
=
@service
.
send
(
name
)
-
type
=
field
[
:type
]
-
type
=
field
[
:type
]
-
placeholder
=
field
[
:placeholder
]
-
placeholder
=
field
[
:placeholder
]
-
required
=
field
[
:required
]
-
choices
=
field
[
:choices
]
-
choices
=
field
[
:choices
]
-
default_choice
=
field
[
:default_choice
]
-
default_choice
=
field
[
:default_choice
]
-
help
=
field
[
:help
]
-
help
=
field
[
:help
]
...
...
config/routes/project.rb
View file @
33d82ccb
...
@@ -67,7 +67,7 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -67,7 +67,7 @@ constraints(ProjectUrlConstrainer.new) do
resources
:services
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:edit
,
:update
]
do
resources
:services
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:edit
,
:update
]
do
member
do
member
do
ge
t
:test
pu
t
:test
end
end
end
end
...
...
features/project/service.feature
View file @
33d82ccb
...
@@ -11,77 +11,77 @@ Feature: Project Services
...
@@ -11,77 +11,77 @@ Feature: Project Services
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click hipchat service link
And
I click hipchat service link
And
I fill hipchat settings
And
I fill hipchat settings
Then
I should see
hipchat service settings saved
Then
I should see
the Hipchat success message
Scenario
:
Activate hipchat service with custom server
Scenario
:
Activate hipchat service with custom server
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click hipchat service link
And
I click hipchat service link
And
I fill hipchat settings with custom server
And
I fill hipchat settings with custom server
Then
I should see
hipchat service settings with custom server saved
Then
I should see
the Hipchat success message
Scenario
:
Activate pivotaltracker service
Scenario
:
Activate pivotaltracker service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click pivotaltracker service link
And
I click pivotaltracker service link
And
I fill pivotaltracker settings
And
I fill pivotaltracker settings
Then
I should see
pivotaltracker service settings saved
Then
I should see
the Pivotaltracker success message
Scenario
:
Activate Flowdock service
Scenario
:
Activate Flowdock service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Flowdock service link
And
I click Flowdock service link
And
I fill Flowdock settings
And
I fill Flowdock settings
Then
I should see
Flowdock service settings saved
Then
I should see
the Flowdock success message
Scenario
:
Activate Assembla service
Scenario
:
Activate Assembla service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Assembla service link
And
I click Assembla service link
And
I fill Assembla settings
And
I fill Assembla settings
Then
I should see
Assembla service settings saved
Then
I should see
the Assembla success message
Scenario
:
Activate Slack notifications service
Scenario
:
Activate Slack notifications service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Slack notifications service link
And
I click Slack notifications service link
And
I fill Slack notifications settings
And
I fill Slack notifications settings
Then
I should see
Slack Notifications service settings saved
Then
I should see
the Slack notifications success message
Scenario
:
Activate Pushover service
Scenario
:
Activate Pushover service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Pushover service link
And
I click Pushover service link
And
I fill Pushover settings
And
I fill Pushover settings
Then
I should see
Pushover service settings saved
Then
I should see
the Pushover success message
Scenario
:
Activate email on push service
Scenario
:
Activate email on push service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click email on push service link
And
I click email on push service link
And
I fill email on push settings
And
I fill email on push settings
Then
I should see
email on push service settings saved
Then
I should see
the Emails on push success message
Scenario
:
Activate JIRA service
Scenario
:
Activate JIRA service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click jira service link
And
I click jira service link
And
I fill jira settings
And
I fill jira settings
Then
I should see
jira service settings saved
Then
I should see
the JIRA success message
Scenario
:
Activate Irker (IRC Gateway) service
Scenario
:
Activate Irker (IRC Gateway) service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Irker service link
And
I click Irker service link
And
I fill Irker settings
And
I fill Irker settings
Then
I should see
Irker service settings saved
Then
I should see
the Irker success message
Scenario
:
Activate Atlassian Bamboo CI service
Scenario
:
Activate Atlassian Bamboo CI service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Atlassian Bamboo CI service link
And
I click Atlassian Bamboo CI service link
And
I fill Atlassian Bamboo CI settings
And
I fill Atlassian Bamboo CI settings
Then
I should see
Atlassian Bamboo CI service settings saved
Then
I should see
the Bamboo success message
And
I should see empty field Change Password
And
I should see empty field Change Password
Scenario
:
Activate jetBrains TeamCity CI service
Scenario
:
Activate jetBrains TeamCity CI service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click jetBrains TeamCity CI service link
And
I click jetBrains TeamCity CI service link
And
I fill jetBrains TeamCity CI settings
And
I fill jetBrains TeamCity CI settings
Then
I should see
jetBrains TeamCity CI service settings saved
Then
I should see
the JetBrains success message
Scenario
:
Activate Asana service
Scenario
:
Activate Asana service
When
I visit project
"Shop"
services page
When
I visit project
"Shop"
services page
And
I click Asana service link
And
I click Asana service link
And
I fill Asana settings
And
I fill Asana settings
Then
I should see
Asana service settings saved
Then
I should see
the Asana success message
features/steps/project/services.rb
View file @
33d82ccb
...
@@ -34,8 +34,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -34,8 +34,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
hipchat service settings saved
'
do
step
'I should see
the Hipchat success message
'
do
expect
(
find_field
(
'Room'
).
value
).
to
eq
'gitlab
'
expect
(
page
).
to
have_content
'HipChat activated.
'
end
end
step
'I fill hipchat settings with custom server'
do
step
'I fill hipchat settings with custom server'
do
...
@@ -46,10 +46,6 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -46,10 +46,6 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see hipchat service settings with custom server saved'
do
expect
(
find_field
(
'Server'
).
value
).
to
eq
'https://chat.example.com'
end
step
'I click pivotaltracker service link'
do
step
'I click pivotaltracker service link'
do
click_link
'PivotalTracker'
click_link
'PivotalTracker'
end
end
...
@@ -60,8 +56,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -60,8 +56,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
pivotaltracker service settings saved
'
do
step
'I should see
the Pivotaltracker success message
'
do
expect
(
find_field
(
'Token'
).
value
).
to
eq
'verySecret
'
expect
(
page
).
to
have_content
'PivotalTracker activated.
'
end
end
step
'I click Flowdock service link'
do
step
'I click Flowdock service link'
do
...
@@ -74,8 +70,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -74,8 +70,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
Flowdock service settings saved
'
do
step
'I should see
the Flowdock success message
'
do
expect
(
find_field
(
'Token'
).
value
).
to
eq
'verySecret
'
expect
(
page
).
to
have_content
'Flowdock activated.
'
end
end
step
'I click Assembla service link'
do
step
'I click Assembla service link'
do
...
@@ -88,8 +84,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -88,8 +84,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
Assembla service settings saved
'
do
step
'I should see
the Assembla success message
'
do
expect
(
find_field
(
'Token'
).
value
).
to
eq
'verySecret
'
expect
(
page
).
to
have_content
'Assembla activated.
'
end
end
step
'I click Asana service link'
do
step
'I click Asana service link'
do
...
@@ -103,9 +99,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -103,9 +99,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see Asana service settings saved'
do
step
'I should see the Asana success message'
do
expect
(
find_field
(
'Api key'
).
value
).
to
eq
'verySecret'
expect
(
page
).
to
have_content
'Asana activated.'
expect
(
find_field
(
'Restrict to branch'
).
value
).
to
eq
'master'
end
end
step
'I click email on push service link'
do
step
'I click email on push service link'
do
...
@@ -113,12 +108,13 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -113,12 +108,13 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
end
end
step
'I fill email on push settings'
do
step
'I fill email on push settings'
do
check
'Active'
fill_in
'Recipients'
,
with:
'qa@company.name'
fill_in
'Recipients'
,
with:
'qa@company.name'
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
email on push service settings saved
'
do
step
'I should see
the Emails on push success message
'
do
expect
(
find_field
(
'Recipients'
).
value
).
to
eq
'qa@company.name
'
expect
(
page
).
to
have_content
'Emails on push activated.
'
end
end
step
'I click Irker service link'
do
step
'I click Irker service link'
do
...
@@ -132,9 +128,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -132,9 +128,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see Irker service settings saved'
do
step
'I should see the Irker success message'
do
expect
(
find_field
(
'Recipients'
).
value
).
to
eq
'irc://chat.freenode.net/#commits'
expect
(
page
).
to
have_content
'Irker (IRC gateway) activated.'
expect
(
find_field
(
'Colorize messages'
).
value
).
to
eq
'1'
end
end
step
'I click Slack notifications service link'
do
step
'I click Slack notifications service link'
do
...
@@ -147,8 +142,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -147,8 +142,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see
Slack Notifications service settings saved
'
do
step
'I should see
the Slack notifications success message
'
do
expect
(
find_field
(
'Webhook'
).
value
).
to
eq
'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685
'
expect
(
page
).
to
have_content
'Slack notifications activated.
'
end
end
step
'I click Pushover service link'
do
step
'I click Pushover service link'
do
...
@@ -165,12 +160,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -165,12 +160,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see Pushover service settings saved'
do
step
'I should see the Pushover success message'
do
expect
(
find_field
(
'Api key'
).
value
).
to
eq
'verySecret'
expect
(
page
).
to
have_content
'Pushover activated.'
expect
(
find_field
(
'User key'
).
value
).
to
eq
'verySecret'
expect
(
find_field
(
'Device'
).
value
).
to
eq
'myDevice'
expect
(
find_field
(
'Priority'
).
find
(
'option[selected]'
).
value
).
to
eq
'1'
expect
(
find_field
(
'Sound'
).
find
(
'option[selected]'
).
value
).
to
eq
'bike'
end
end
step
'I click jira service link'
do
step
'I click jira service link'
do
...
@@ -178,6 +169,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -178,6 +169,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
end
end
step
'I fill jira settings'
do
step
'I fill jira settings'
do
check
'Active'
fill_in
'Web URL'
,
with:
'http://jira.example'
fill_in
'Web URL'
,
with:
'http://jira.example'
fill_in
'JIRA API URL'
,
with:
'http://jira.example/api'
fill_in
'JIRA API URL'
,
with:
'http://jira.example/api'
fill_in
'Username'
,
with:
'gitlab'
fill_in
'Username'
,
with:
'gitlab'
...
@@ -186,11 +179,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -186,11 +179,8 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see jira service settings saved'
do
step
'I should see the JIRA success message'
do
expect
(
find_field
(
'Web URL'
).
value
).
to
eq
'http://jira.example'
expect
(
page
).
to
have_content
'JIRA activated.'
expect
(
find_field
(
'JIRA API URL'
).
value
).
to
eq
'http://jira.example/api'
expect
(
find_field
(
'Username'
).
value
).
to
eq
'gitlab'
expect
(
find_field
(
'Project Key'
).
value
).
to
eq
'GITLAB'
end
end
step
'I click Atlassian Bamboo CI service link'
do
step
'I click Atlassian Bamboo CI service link'
do
...
@@ -206,13 +196,13 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -206,13 +196,13 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see Atlassian Bamboo CI service settings saved'
do
step
'I should see the Bamboo success message'
do
expect
(
find_field
(
'Bamboo url'
).
value
).
to
eq
'http://bamboo.example.com'
expect
(
page
).
to
have_content
'Atlassian Bamboo CI activated.'
expect
(
find_field
(
'Build key'
).
value
).
to
eq
'KEY'
expect
(
find_field
(
'Username'
).
value
).
to
eq
'user'
end
end
step
'I should see empty field Change Password'
do
step
'I should see empty field Change Password'
do
click_link
'Atlassian Bamboo CI'
expect
(
find_field
(
'Enter new password'
).
value
).
to
be_nil
expect
(
find_field
(
'Enter new password'
).
value
).
to
be_nil
end
end
...
@@ -229,9 +219,7 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
...
@@ -229,9 +219,7 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
click_button
'Save'
click_button
'Save'
end
end
step
'I should see JetBrains TeamCity CI service settings saved'
do
step
'I should see the JetBrains success message'
do
expect
(
find_field
(
'Teamcity url'
).
value
).
to
eq
'http://teamcity.example.com'
expect
(
page
).
to
have_content
'JetBrains TeamCity CI activated.'
expect
(
find_field
(
'Build type'
).
value
).
to
eq
'GitlabTest_Build'
expect
(
find_field
(
'Username'
).
value
).
to
eq
'user'
end
end
end
end
spec/controllers/projects/services_controller_spec.rb
View file @
33d82ccb
...
@@ -3,7 +3,9 @@ require 'spec_helper'
...
@@ -3,7 +3,9 @@ require 'spec_helper'
describe
Projects
::
ServicesController
do
describe
Projects
::
ServicesController
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
create
(
:service
,
project:
project
)
}
let
(
:service
)
{
create
(
:hipchat_service
,
project:
project
)
}
let
(
:hipchat_client
)
{
{
'#room'
=>
double
(
send:
true
)
}
}
let
(
:service_params
)
{
{
token:
'hipchat_token_p'
,
room:
'#room'
}
}
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
...
@@ -13,97 +15,84 @@ describe Projects::ServicesController do
...
@@ -13,97 +15,84 @@ describe Projects::ServicesController do
controller
.
instance_variable_set
(
:@service
,
service
)
controller
.
instance_variable_set
(
:@service
,
service
)
end
end
shared_examples_for
'services controller'
do
|
referrer
|
describe
'#test'
do
before
do
context
'when can_test? returns false'
do
request
.
env
[
"HTTP_REFERER"
]
=
referrer
it
'renders 404'
do
end
allow_any_instance_of
(
Service
).
to
receive
(
:can_test?
).
and_return
(
false
)
describe
"#test"
do
context
'when can_test? returns false'
do
it
'renders 404'
do
allow_any_instance_of
(
Service
).
to
receive
(
:can_test?
).
and_return
(
false
)
get
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
format: :html
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
end
context
'success'
do
context
'success'
do
context
'with empty project'
do
context
'with empty project'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
context
'with chat notification service'
do
let
(
:service
)
{
project
.
create_microsoft_teams_service
(
webhook:
'http://webhook.com'
)
}
it
'redirects and show success message'
do
allow_any_instance_of
(
MicrosoftTeams
::
Notifier
).
to
receive
(
:ping
).
and_return
(
true
)
get
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
format: :html
expect
(
response
).
to
redirect_to
(
root_path
)
context
'with chat notification service'
do
expect
(
flash
[
:notice
]).
to
eq
(
'We sent a request to the provided URL'
)
let
(
:service
)
{
project
.
create_microsoft_teams_service
(
webhook:
'http://webhook.com'
)
}
end
end
it
're
directs and show success message
'
do
it
're
turns success
'
do
expect
(
service
).
to
receive
(
:test
).
and_return
(
success:
true
,
result:
'done'
)
allow_any_instance_of
(
MicrosoftTeams
::
Notifier
).
to
receive
(
:ping
).
and_return
(
true
)
get
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
format: :html
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
expect
(
response
).
to
redirect_to
(
root_path
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
flash
[
:notice
]).
to
eq
(
'We sent a request to the provided URL'
)
end
end
end
end
it
"redirects and show success message"
do
it
'returns success'
do
expect
(
service
).
to
receive
(
:test
).
and_return
(
success:
true
,
result:
'done'
)
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
get
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
format: :html
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
expect
(
response
).
to
redirect_to
(
root_path
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
flash
[
:notice
]).
to
eq
(
'We sent a request to the provided URL'
)
end
end
end
end
context
'failure'
do
it
'returns success'
do
it
"redirects and show failure message"
do
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_return
(
hipchat_client
)
expect
(
service
).
to
receive
(
:test
).
and_return
(
success:
false
,
result:
'Bad test'
)
get
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
format: :html
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
expect
(
response
).
to
redirect_to
(
root_path
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
flash
[
:alert
]).
to
eq
(
'We tried to send a request to the provided URL but an error occurred: Bad test'
)
end
end
end
end
end
describe
'referrer defined'
do
def
built_service
it_should_behave_like
'services controller'
do
end
let!
(
:referrer
)
{
"/"
}
end
end
end
describe
'referrer undefined'
do
context
'failure'
do
it_should_behave_like
'services controller'
do
it
'returns 500 status code and the error message'
do
let!
(
:referrer
)
{
nil
}
expect
(
HipChat
::
Client
).
to
receive
(
:new
).
with
(
'hipchat_token_p'
,
anything
).
and_raise
(
'Bad test'
)
put
:test
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
service_params
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
JSON
.
parse
(
response
.
body
)).
to
eq
(
'error'
=>
true
,
'message'
=>
'Test failed'
,
'service_response'
=>
'Bad test'
)
end
end
end
end
end
describe
'PUT #update'
do
describe
'PUT #update'
do
context
'on successful update'
do
context
'when param `active` is set to true'
do
it
'sets the flash'
do
it
'activates the service and redirects to integrations paths'
do
expect
(
service
).
to
receive
(
:to_param
).
and_return
(
'hipchat'
)
put
:update
,
expect
(
service
).
to
receive
(
:event_names
).
and_return
(
HipchatService
.
event_names
)
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
true
}
expect
(
response
).
to
redirect_to
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
flash
[
:notice
]).
to
eq
'HipChat activated.'
end
end
context
'when param `active` is set to false'
do
it
'does not activate the service but saves the settings'
do
put
:update
,
put
:update
,
namespace_id:
project
.
namespace
.
id
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
false
}
project_id:
project
.
id
,
id:
service
.
id
,
service:
{
active:
false
}
expect
(
flash
[
:notice
]).
to
eq
'
Successfully upd
ated.'
expect
(
flash
[
:notice
]).
to
eq
'
HipChat settings saved, but not activ
ated.'
end
end
end
end
end
end
...
...
spec/factories/services.rb
View file @
33d82ccb
...
@@ -33,4 +33,10 @@ FactoryGirl.define do
...
@@ -33,4 +33,10 @@ FactoryGirl.define do
project_key:
'jira-key'
project_key:
'jira-key'
)
)
end
end
factory
:hipchat_service
do
project
factory: :empty_project
type
'HipchatService'
token
'test_token'
end
end
end
spec/features/projects/services/mattermost_slash_command_spec.rb
View file @
33d82ccb
...
@@ -24,15 +24,25 @@ feature 'Setup Mattermost slash commands', :feature, :js do
...
@@ -24,15 +24,25 @@ feature 'Setup Mattermost slash commands', :feature, :js do
expect
(
token_placeholder
).
to
eq
(
'XXxxXXxxXXxxXXxxXXxxXXxx'
)
expect
(
token_placeholder
).
to
eq
(
'XXxxXXxxXXxxXXxxXXxxXXxx'
)
end
end
it
'
shows the token after sav
ing'
do
it
'
redirects to the integrations page after saving but not activat
ing'
do
token
=
(
'a'
..
'z'
).
to_a
.
join
token
=
(
'a'
..
'z'
).
to_a
.
join
fill_in
'service_token'
,
with:
token
fill_in
'service_token'
,
with:
token
click_on
'Save'
click_on
'Save'
value
=
find_field
(
'service_token'
).
value
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
'Mattermost slash commands settings saved, but not activated.'
)
end
it
'redirects to the integrations page after activating'
do
token
=
(
'a'
..
'z'
).
to_a
.
join
fill_in
'service_token'
,
with:
token
check
'service_active'
click_on
'Save'
expect
(
value
).
to
eq
(
token
)
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
' Mattermost slash commands activated.'
)
end
end
it
'shows the add to mattermost button'
do
it
'shows the add to mattermost button'
do
...
...
spec/features/projects/services/slack_slash_command_spec.rb
View file @
33d82ccb
...
@@ -21,13 +21,21 @@ feature 'Slack slash commands', feature: true do
...
@@ -21,13 +21,21 @@ feature 'Slack slash commands', feature: true do
expect
(
page
).
to
have_content
(
'This service allows users to perform common'
)
expect
(
page
).
to
have_content
(
'This service allows users to perform common'
)
end
end
it
'
shows the token after sav
ing'
do
it
'
redirects to the integrations page after saving but not activat
ing'
do
fill_in
'service_token'
,
with:
'token'
fill_in
'service_token'
,
with:
'token'
click_on
'Save'
click_on
'Save'
value
=
find_field
(
'service_token'
).
value
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
'Slack slash commands settings saved, but not activated.'
)
end
it
'redirects to the integrations page after activating'
do
fill_in
'service_token'
,
with:
'token'
check
'service_active'
click_on
'Save'
expect
(
value
).
to
eq
(
'token'
)
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
'Slack slash commands activated.'
)
end
end
it
'shows the correct trigger url'
do
it
'shows the correct trigger url'
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