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
b71025c0
Commit
b71025c0
authored
7 years ago
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature tests for improved JIRA settings
parent
44f2504a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
19 deletions
+99
-19
app/assets/javascripts/integrations/integration_settings_form.js
...ets/javascripts/integrations/integration_settings_form.js
+1
-1
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+12
-7
app/models/project_services/chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+0
-4
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+0
-4
changelogs/unreleased/31511-jira-settings.yml
changelogs/unreleased/31511-jira-settings.yml
+4
-0
spec/features/projects/services/jira_service_spec.rb
spec/features/projects/services/jira_service_spec.rb
+79
-0
spec/features/projects/services/mattermost_slash_command_spec.rb
...atures/projects/services/mattermost_slash_command_spec.rb
+3
-3
No files found.
app/assets/javascripts/integrations/integration_settings_form.js
View file @
b71025c0
...
...
@@ -93,7 +93,7 @@ export default class IntegrationSettingsForm {
})
.
done
((
res
)
=>
{
if
(
res
.
error
)
{
new
Flash
(
`
${
res
.
message
}
.
`
,
null
,
null
,
{
new
Flash
(
`
${
res
.
message
}
`
,
null
,
null
,
{
title
:
'
Save anyway
'
,
clickHandler
:
(
e
)
=>
{
e
.
preventDefault
();
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/services_controller.rb
View file @
b71025c0
...
...
@@ -22,17 +22,22 @@ class Projects::ServicesController < Projects::ApplicationController
end
def
test
return
render
json:
{},
status: :not_found
unless
@service
.
can_test?
message
=
{}
data
=
@service
.
test_data
(
project
,
current_user
)
outcome
=
@service
.
test
(
data
)
if
@service
.
can_test?
data
=
@service
.
test_data
(
project
,
current_user
)
outcome
=
@service
.
test
(
data
)
message
=
{}
unless
outcome
[
:success
]
message
=
{
error:
true
,
message:
'Test failed'
,
service_response:
outcome
[
:result
].
to_s
}
unless
outcome
[
:success
]
message
=
{
error:
true
,
message:
'Test failed.'
,
service_response:
outcome
[
:result
].
to_s
}
end
status
=
:ok
else
status
=
:not_found
end
render
json:
message
,
status:
:ok
render
json:
message
,
status:
status
end
private
...
...
This diff is collapsed.
Click to expand it.
app/models/project_services/chat_notification_service.rb
View file @
b71025c0
...
...
@@ -21,10 +21,6 @@ class ChatNotificationService < Service
end
end
def
can_test?
valid?
end
def
self
.
supported_events
%w[push issue confidential_issue merge_request note tag_push
pipeline wiki_page]
...
...
This diff is collapsed.
Click to expand it.
app/models/project_services/jira_service.rb
View file @
b71025c0
...
...
@@ -175,10 +175,6 @@ class JiraService < IssueTrackerService
{
success:
result
.
present?
,
result:
result
}
end
def
can_test?
username
.
present?
&&
password
.
present?
end
# JIRA does not need test data.
# We are requesting the project that belongs to the project key.
def
test_data
(
user
=
nil
,
project
=
nil
)
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/31511-jira-settings.yml
0 → 100644
View file @
b71025c0
---
title
:
Simplify test&save actions when setting a service integration
merge_request
:
11599
author
:
This diff is collapsed.
Click to expand it.
spec/features/projects/services/jira_service_spec.rb
0 → 100644
View file @
b71025c0
require
'spec_helper'
feature
'Setup Jira service'
,
:feature
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:service
)
{
project
.
create_jira_service
}
let
(
:url
)
{
'http://jira.example.com'
}
let
(
:project_url
)
{
'http://username:password@jira.example.com/rest/api/2/project/GitLabProject'
}
def
fill_form
(
active
=
true
)
check
'Active'
if
active
fill_in
'service_url'
,
with:
url
fill_in
'service_project_key'
,
with:
'GitLabProject'
fill_in
'service_username'
,
with:
'username'
fill_in
'service_password'
,
with:
'password'
fill_in
'service_jira_issue_transition_id'
,
with:
'25'
end
before
do
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
visit
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
)
end
describe
'user sets and activates Jira Service'
do
context
'when Jira connection test succeeds'
do
before
do
WebMock
.
stub_request
(
:get
,
project_url
)
end
it
'activates the JIRA service'
do
click_link
(
'JIRA'
)
fill_form
click_button
(
'Test settings and save changes'
)
wait_for_ajax
expect
(
page
).
to
have_content
(
'JIRA activated.'
)
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
end
end
context
'when Jira connection test fails'
do
before
do
WebMock
.
stub_request
(
:get
,
project_url
).
to_return
(
status:
401
)
end
it
'activates the JIRA service'
do
click_link
(
'JIRA'
)
fill_form
click_button
(
'Test settings and save changes'
)
wait_for_ajax
expect
(
page
).
to
have_content
(
'Test failed.Save anyway'
)
click_on
(
'Save anyway'
)
wait_for_ajax
expect
(
page
).
to
have_content
(
'JIRA activated.'
)
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
end
end
end
describe
'user sets Jira Service but keeps it non active'
do
context
'when Jira connection test succeeds'
do
it
'activates the JIRA service'
do
click_link
(
'JIRA'
)
fill_form
(
false
)
click_button
(
'Save changes'
)
expect
(
page
).
to
have_content
(
'JIRA settings saved, but not activated.'
)
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
end
end
end
end
This diff is collapsed.
Click to expand it.
spec/features/projects/services/mattermost_slash_command_spec.rb
View file @
b71025c0
...
...
@@ -28,7 +28,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do
token
=
(
'a'
..
'z'
).
to_a
.
join
fill_in
'service_token'
,
with:
token
click_on
'Save'
click_on
'Save
changes
'
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.'
)
...
...
@@ -39,10 +39,10 @@ feature 'Setup Mattermost slash commands', :feature, :js do
fill_in
'service_token'
,
with:
token
check
'service_active'
click_on
'Save'
click_on
'Save
changes
'
expect
(
current_path
).
to
eq
(
namespace_project_settings_integrations_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
'
Mattermost slash commands activated.'
)
expect
(
page
).
to
have_content
(
'Mattermost slash commands activated.'
)
end
it
'shows the add to mattermost button'
do
...
...
This diff is collapsed.
Click to expand it.
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