Commit d5e38b00 authored by Kotau Yauhen's avatar Kotau Yauhen

Remove new_issue_url field from YouTrack integration service

parent dd6fbbc4
# frozen_string_literal: true # frozen_string_literal: true
class YoutrackService < IssueTrackerService class YoutrackService < IssueTrackerService
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? validates :project_url, :issues_url, presence: true, public_url: true, if: :activated?
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url prop_accessor :title, :description, :project_url, :issues_url
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1 # {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1
def self.reference_pattern(only_long: false) def self.reference_pattern(only_long: false)
...@@ -15,12 +15,8 @@ class YoutrackService < IssueTrackerService ...@@ -15,12 +15,8 @@ class YoutrackService < IssueTrackerService
end end
def title def title
if self.properties && self.properties['title'].present?
self.properties['title']
else
'YouTrack' 'YouTrack'
end end
end
def description def description
if self.properties && self.properties['description'].present? if self.properties && self.properties['description'].present?
...@@ -33,4 +29,12 @@ class YoutrackService < IssueTrackerService ...@@ -33,4 +29,12 @@ class YoutrackService < IssueTrackerService
def self.to_param def self.to_param
'youtrack' 'youtrack'
end end
def fields
[
{ type: 'text', name: 'description', placeholder: description },
{ type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
{ type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true }
]
end
end end
...@@ -10,7 +10,6 @@ in the table below. ...@@ -10,7 +10,6 @@ in the table below.
| `description` | A name for the issue tracker (to differentiate between instances, for example) | | `description` | A name for the issue tracker (to differentiate between instances, for example) |
| `project_url` | The URL to the project in YouTrack which is being linked to this GitLab project | | `project_url` | The URL to the project in YouTrack which is being linked to this GitLab project |
| `issues_url` | The URL to the issue in YouTrack project that is linked to this GitLab project. Note that the `issues_url` requires `:id` in the URL. This ID is used by GitLab as a placeholder to replace the issue number. | | `issues_url` | The URL to the issue in YouTrack project that is linked to this GitLab project. Note that the `issues_url` requires `:id` in the URL. This ID is used by GitLab as a placeholder to replace the issue number. |
| `new_issue_url` | This is the URL to create a new issue in YouTrack for the project linked to this GitLab project. **This is currently not being used and will be removed in a future release.** |
Once you have configured and enabled YouTrack you'll see the YouTrack link on the GitLab project pages that takes you to the appropriate YouTrack project. Once you have configured and enabled YouTrack you'll see the YouTrack link on the GitLab project pages that takes you to the appropriate YouTrack project.
......
...@@ -593,12 +593,6 @@ module API ...@@ -593,12 +593,6 @@ module API
} }
], ],
'youtrack' => [ 'youtrack' => [
{
required: true,
name: :new_issue_url,
type: String,
desc: 'The new issue URL'
},
{ {
required: true, required: true,
name: :project_url, name: :project_url,
......
...@@ -321,8 +321,7 @@ FactoryBot.define do ...@@ -321,8 +321,7 @@ FactoryBot.define do
active: true, active: true,
properties: { properties: {
'project_url' => 'http://youtrack/projects/project_guid_in_youtrack', 'project_url' => 'http://youtrack/projects/project_guid_in_youtrack',
'issues_url' => 'http://youtrack/issues/:id', 'issues_url' => 'http://youtrack/issues/:id'
'new_issue_url' => 'http://youtrack/newIssue'
} }
) )
end end
......
...@@ -87,7 +87,6 @@ describe 'User activates issue tracker', :js do ...@@ -87,7 +87,6 @@ describe 'User activates issue tracker', :js do
end end
it_behaves_like 'external issue tracker activation', tracker: 'Redmine' it_behaves_like 'external issue tracker activation', tracker: 'Redmine'
it_behaves_like 'external issue tracker activation', tracker: 'YouTrack'
it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla' it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla'
it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker' it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker'
end end
require 'spec_helper'
describe 'User activates issue tracker', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:url) { 'http://tracker.example.com' }
def fill_form(active = true)
check 'Active' if active
fill_in 'service_project_url', with: url
fill_in 'service_issues_url', with: "#{url}/:id"
end
before do
project.add_maintainer(user)
sign_in(user)
visit project_settings_integrations_path(project)
end
shared_examples 'external issue tracker activation' do |tracker:|
describe 'user sets and activates the Service' do
context 'when the connection test succeeds' do
before do
stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })
click_link(tracker)
fill_form
click_button('Test settings and save changes')
wait_for_requests
end
it 'activates the service' do
expect(page).to have_content("#{tracker} activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
it 'shows the link in the menu' do
page.within('.nav-sidebar') do
expect(page).to have_link(tracker, href: url)
end
end
end
context 'when the connection test fails' do
it 'activates the service' do
stub_request(:head, url).to_raise(HTTParty::Error)
click_link(tracker)
fill_form
click_button('Test settings and save changes')
wait_for_requests
expect(find('.flash-container-page')).to have_content 'Test failed.'
expect(find('.flash-container-page')).to have_content 'Save anyway'
find('.flash-alert .flash-action').click
wait_for_requests
expect(page).to have_content("#{tracker} activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
end
end
describe 'user sets the service but keeps it disabled' do
before do
click_link(tracker)
fill_form(false)
click_button('Save changes')
end
it 'saves but does not activate the service' do
expect(page).to have_content("#{tracker} settings saved, but not activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
it 'does not show the external tracker link in the menu' do
page.within('.nav-sidebar') do
expect(page).not_to have_link(tracker, href: url)
end
end
end
end
it_behaves_like 'external issue tracker activation', tracker: 'YouTrack'
end
...@@ -14,10 +14,8 @@ describe YoutrackService do ...@@ -14,10 +14,8 @@ describe YoutrackService do
it { is_expected.to validate_presence_of(:project_url) } it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) } it { is_expected.to validate_presence_of(:issues_url) }
it { is_expected.to validate_presence_of(:new_issue_url) }
it_behaves_like 'issue tracker service URL attribute', :project_url it_behaves_like 'issue tracker service URL attribute', :project_url
it_behaves_like 'issue tracker service URL attribute', :issues_url it_behaves_like 'issue tracker service URL attribute', :issues_url
it_behaves_like 'issue tracker service URL attribute', :new_issue_url
end end
context 'when service is inactive' do context 'when service is inactive' do
...@@ -27,7 +25,6 @@ describe YoutrackService do ...@@ -27,7 +25,6 @@ describe YoutrackService do
it { is_expected.not_to validate_presence_of(:project_url) } it { is_expected.not_to validate_presence_of(:project_url) }
it { is_expected.not_to validate_presence_of(:issues_url) } it { is_expected.not_to validate_presence_of(:issues_url) }
it { is_expected.not_to validate_presence_of(:new_issue_url) }
end end
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