Skip to content
Snippets Groups Projects
Commit d454486f authored by Mayra Cabrera's avatar Mayra Cabrera
Browse files

Merge branch '201855-rename-project_services_to_integrations-4' into 'master'

Move Jira integration model to `Integrations::` namespace [RUN AS-IF-FOSS] [RUN ALL RSPEC]

See merge request gitlab-org/gitlab!61743
parents 6c203b47 eade74bf
No related branches found
No related tags found
No related merge requests found
Showing
with 42 additions and 40 deletions
Loading
Loading
@@ -71,7 +71,7 @@
expect(finder).to receive(:execute).and_return(jira_issues)
end
 
expect_next_instance_of(Integrations::Jira::IssueSerializer) do |serializer|
expect_next_instance_of(Integrations::JiraSerializers::IssueSerializer) do |serializer|
expect(serializer).to receive(:represent).with(jira_issues, project: project)
end
 
Loading
Loading
@@ -203,11 +203,11 @@
before do
stub_licensed_features(jira_issues_integration: true)
 
expect_next_found_instance_of(JiraService) do |service|
expect_next_found_instance_of(Integrations::Jira) do |service|
expect(service).to receive(:find_issue).with('1', rendered_fields: true).and_return(jira_issue)
end
 
expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer|
expect_next_instance_of(Integrations::JiraSerializers::IssueDetailSerializer) do |serializer|
expect(serializer).to receive(:represent).with(jira_issue, project: project).and_return(issue_json)
end
end
Loading
Loading
Loading
Loading
@@ -15,7 +15,9 @@
context 'when Jira connection test succeeds' do
before do
stub_licensed_features(jira_issues_integration: true)
allow_any_instance_of(JiraService).to receive(:issues_enabled) { true }
allow_next_instance_of(Integrations::Jira) do |instance|
allow(instance).to receive(:issues_enabled) { true }
end
 
visit_project_integration('Jira')
fill_form
Loading
Loading
Loading
Loading
@@ -184,7 +184,7 @@
describe '#create_jira_issue_url_for' do
subject { helper.vulnerability_details(vulnerability, pipeline) }
 
let(:jira_service) { double('JiraService', new_issue_url_with_predefined_fields: 'https://jira.example.com/new') }
let(:jira_service) { double('Integrations::Jira', new_issue_url_with_predefined_fields: 'https://jira.example.com/new') }
 
before do
allow(helper).to receive(:can?).and_return(true)
Loading
Loading
@@ -231,7 +231,7 @@
subject
end
 
it 'delegates rendering URL to JiraService' do
it 'delegates rendering URL to Integrations::Jira' do
expect(jira_service).to receive(:new_issue_url_with_predefined_fields).with("Investigate vulnerability: #{vulnerability.title}", expected_jira_issue_description)
 
subject
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@
subject { described_class.new(context) }
 
describe 'render?' do
context 'when issue tracker is not a JiraService' do
context 'when issue tracker is not Jira' do
it 'returns false' do
create(:custom_issue_tracker_service, active: true, project: project, project_url: 'http://test.com')
 
Loading
Loading
@@ -20,7 +20,7 @@
end
end
 
context 'when issue tracker is a JiraService' do
context 'when issue tracker is Jira' do
let!(:jira) { create(:jira_service, project: project, project_key: 'GL') }
 
context 'when issues integration is disabled' do
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'spec_helper'
 
RSpec.describe JiraService do
RSpec.describe Integrations::Jira do
let(:jira_service) { build(:jira_service, **options) }
let(:headers) { { 'Content-Type' => 'application/json' } }
 
Loading
Loading
@@ -167,11 +167,11 @@
end
 
before do
WebMock.stub_request(:get, /api\/2\/project\/GL/).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: project_info_result.to_json )
WebMock.stub_request(:get, /api\/2\/project\/GL\z/).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: { 'id' => '10000' }.to_json, headers: headers)
WebMock.stub_request(:get, /api\/2\/issuetype\z/).to_return(body: issue_types_response.to_json, headers: headers)
WebMock.stub_request(:get, /api\/2\/issuetypescheme\/project\?projectId\=10000\z/).to_return(body: issue_type_scheme_response.to_json, headers: headers)
WebMock.stub_request(:get, /api\/2\/issuetypescheme\/mapping\?issueTypeSchemeId\=10126\z/).to_return(body: issue_type_mapping_response.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/project/GL}).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: project_info_result.to_json )
WebMock.stub_request(:get, %r{api/2/project/GL\z}).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: { 'id' => '10000' }.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/issuetype\z}).to_return(body: issue_types_response.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/issuetypescheme/project\?projectId\=10000\z}).to_return(body: issue_type_scheme_response.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/issuetypescheme/mapping\?issueTypeSchemeId\=10126\z}).to_return(body: issue_type_mapping_response.to_json, headers: headers)
end
 
it { is_expected.to eq(success: true, result: { jira: true }, data: { issuetypes: [{ id: '10001', name: 'Bug', description: 'Jira Bug' }] }) }
Loading
Loading
@@ -236,8 +236,8 @@
allow(jira_service.data_fields).to receive(:deployment_cloud?).and_return(false)
allow(jira_service.data_fields).to receive(:deployment_server?).and_return(true)
 
WebMock.stub_request(:get, /api\/2\/project\/GL/).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: project_info_result.to_json, headers: headers)
WebMock.stub_request(:get, /api\/2\/issuetype\z/).to_return(body: issue_types_response.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/project/GL}).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: project_info_result.to_json, headers: headers)
WebMock.stub_request(:get, %r{api/2/issuetype\z}).to_return(body: issue_types_response.to_json, headers: headers)
end
 
it { is_expected.to eq(success: true, result: { jira: true }, data: { issuetypes: [{ description: "A task that needs to be done.", id: "10003", name: "Task" }, { description: "Created by Jira Software - do not edit or delete. Issue type for a user story.", id: "10002", name: "Story" }, { description: "A problem which impairs or prevents the functions of the product.", id: "10004", name: "Bug" }, { description: "Created by Jira Software - do not edit or delete. Issue type for a big user story that needs to be broken down.", id: "10001", name: "Epic" }] }) }
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'spec_helper'
 
RSpec.describe Integrations::Jira::IssueDetailEntity do
RSpec.describe Integrations::JiraSerializers::IssueDetailEntity do
include JiraServiceHelper
 
let_it_be(:project) { create(:project) }
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'spec_helper'
 
RSpec.describe Integrations::Jira::IssueEntity do
RSpec.describe Integrations::JiraSerializers::IssueEntity do
include JiraServiceHelper
 
let_it_be(:project) { create(:project) }
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'spec_helper'
 
RSpec.describe Integrations::Jira::IssueSerializer do
RSpec.describe Integrations::JiraSerializers::IssueSerializer do
let_it_be(:project) { create(:project) }
let_it_be(:jira_service) { create(:jira_service, project: project) }
 
Loading
Loading
Loading
Loading
@@ -102,7 +102,7 @@
 
before do
stub_licensed_features(jira_vulnerabilities_integration: true)
allow_next_found_instance_of(JiraService) do |jira|
allow_next_found_instance_of(Integrations::Jira) do |jira|
allow(jira).to receive(:jira_project_id).and_return('11223')
end
end
Loading
Loading
Loading
Loading
@@ -784,6 +784,7 @@ def self.service_classes
::Integrations::Datadog,
::Integrations::EmailsOnPush,
::Integrations::Ewm,
::Integrations::Jira,
::Integrations::Redmine,
::Integrations::Youtrack,
::BuildkiteService,
Loading
Loading
@@ -794,7 +795,6 @@ def self.service_classes
::HangoutsChatService,
::IrkerService,
::JenkinsService,
::JiraService,
::MattermostSlashCommandsService,
::SlackSlashCommandsService,
::PackagistService,
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ module Integrations
class StiType < ActiveRecord::Type::String
NAMESPACED_INTEGRATIONS = Set.new(%w(
Asana Assembla Bamboo Bugzilla Campfire Confluence CustomIssueTracker Datadog
EmailsOnPush Ewm IssueTracker Redmine Youtrack
EmailsOnPush Ewm IssueTracker Jira Redmine Youtrack
)).freeze
 
def cast(value)
Loading
Loading
Loading
Loading
@@ -227,7 +227,7 @@ def jira_service_data
}
 
# rubocop: disable CodeReuse/ActiveRecord
JiraService.active.includes(:jira_tracker_data).find_in_batches(batch_size: 100) do |services|
::Integrations::Jira.active.includes(:jira_tracker_data).find_in_batches(batch_size: 100) do |services|
counts = services.group_by do |service|
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
service_url = service.data_fields&.url || (service.properties && service.properties['url'])
Loading
Loading
Loading
Loading
@@ -18662,6 +18662,9 @@ msgstr ""
msgid "JiraService|GitLab for Jira Configuration"
msgstr ""
 
msgid "JiraService|IDs must be a list of numbers that can be split with , or ;"
msgstr ""
msgid "JiraService|If different from Web URL."
msgstr ""
 
Loading
Loading
@@ -18677,10 +18680,10 @@ msgstr ""
msgid "JiraService|Jira Issues"
msgstr ""
 
msgid "JiraService|Jira comments will be created when an issue gets referenced in a commit."
msgid "JiraService|Jira comments are created when an issue is referenced in a commit."
msgstr ""
 
msgid "JiraService|Jira comments will be created when an issue gets referenced in a merge request."
msgid "JiraService|Jira comments are created when an issue is referenced in a merge request."
msgstr ""
 
msgid "JiraService|Jira issue type"
Loading
Loading
@@ -18770,9 +18773,6 @@ msgstr ""
msgid "JiraService|You need to configure Jira before enabling this integration. For more details, read the %{jira_doc_link_start}Jira integration documentation%{link_end}."
msgstr ""
 
msgid "JiraService|transition ids can have only numbers which can be split with , or ;"
msgstr ""
msgid "Job"
msgstr ""
 
Loading
Loading
Loading
Loading
@@ -93,8 +93,8 @@
end
 
it 'deletes the integration and all inheriting integrations' do
expect { subject }.to change { JiraService.for_instance.count }.by(-1)
.and change { JiraService.inherit_from_id(integration.id).count }.by(-1)
expect { subject }.to change { Integrations::Jira.for_instance.count }.by(-1)
.and change { Integrations::Jira.inherit_from_id(integration.id).count }.by(-1)
end
end
end
Loading
Loading
@@ -124,8 +124,8 @@
end
 
it 'deletes the integration and all inheriting integrations' do
expect { subject }.to change { JiraService.for_group(group.id).count }.by(-1)
.and change { JiraService.inherit_from_id(integration.id).count }.by(-1)
expect { subject }.to change { Integrations::Jira.for_group(group.id).count }.by(-1)
.and change { Integrations::Jira.inherit_from_id(integration.id).count }.by(-1)
end
end
end
Loading
Loading
Loading
Loading
@@ -45,7 +45,7 @@
token { 'test' }
end
 
factory :jira_service do
factory :jira_service, class: 'Integrations::Jira' do
project
active { true }
type { 'JiraService' }
Loading
Loading
Loading
Loading
@@ -43,7 +43,7 @@
context 'When external issue tracker is enabled and issues enabled on project settings' do
it 'does not hide issues tab and hides labels tab' do
allow_next_instance_of(Project) do |instance|
allow(instance).to receive(:external_issue_tracker).and_return(JiraService.new)
allow(instance).to receive(:external_issue_tracker).and_return(Integrations::Jira.new)
end
 
visit project_path(project)
Loading
Loading
@@ -58,7 +58,7 @@
project.issues_enabled = false
project.save!
allow_next_instance_of(Project) do |instance|
allow(instance).to receive(:external_issue_tracker).and_return(JiraService.new)
allow(instance).to receive(:external_issue_tracker).and_return(Integrations::Jira.new)
end
end
 
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
require 'spec_helper'
 
RSpec.describe JiraService do
RSpec.describe Integrations::Jira do
include AssetsHelpers
 
let_it_be(:project) { create(:project, :repository) }
Loading
Loading
@@ -493,7 +493,7 @@
before do
jira_service.jira_issue_transition_id = '999'
 
# These stubs are needed to test JiraService#close_issue.
# These stubs are needed to test Integrations::Jira#close_issue.
# We close the issue then do another request to API to check if it got closed.
# Here is stubbed the API return with a closed and an opened issues.
open_issue = JIRA::Resource::Issue.new(jira_service.client, attrs: issue_fields.deep_stringify_keys)
Loading
Loading
@@ -829,7 +829,7 @@ def close_issue
 
context 'when disabled' do
before do
allow_next_instance_of(JiraService) do |instance|
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:commit_events) { false }
end
end
Loading
Loading
@@ -847,7 +847,7 @@ def close_issue
 
context 'when disabled' do
before do
allow_next_instance_of(JiraService) do |instance|
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:merge_requests_events) { false }
end
end
Loading
Loading
Loading
Loading
@@ -100,7 +100,7 @@
 
context 'when service and data_fields are not persisted' do
let(:service) do
JiraService.new
Integrations::Jira.new
end
 
describe 'data_fields_present?' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment