Commit 60b96837 authored by Andy Soiron's avatar Andy Soiron

Merge branch 'remove-open-project-service-integration-data-spec' into 'master'

Remove OpenProjectTrackerData model and spec

See merge request gitlab-org/gitlab!70294
parents 4866cbed c8f11585
......@@ -45,7 +45,6 @@ module Integrations
included do
has_one :issue_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::IssueTrackerData'
has_one :jira_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::JiraTrackerData'
has_one :open_project_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::OpenProjectTrackerData'
has_one :zentao_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :integration_id, class_name: 'Integrations::ZentaoTrackerData'
def data_fields
......
# frozen_string_literal: true
module Integrations
class OpenProject < BaseIssueTracker
validates :url, public_url: true, presence: true, if: :activated?
validates :api_url, public_url: true, allow_blank: true, if: :activated?
validates :token, presence: true, if: :activated?
validates :project_identifier_code, presence: true, if: :activated?
data_field :url, :api_url, :token, :closed_status_id, :project_identifier_code
def data_fields
open_project_tracker_data || self.build_open_project_tracker_data
end
def self.to_param
'open_project'
end
end
end
# frozen_string_literal: true
module Integrations
class OpenProjectTrackerData < ApplicationRecord
include BaseDataFields
# When the Open Project is fresh installed, the default closed status id is "13" based on current version: v8.
DEFAULT_CLOSED_STATUS_ID = "13"
attr_encrypted :url, encryption_options
attr_encrypted :api_url, encryption_options
attr_encrypted :token, encryption_options
def closed_status_id
super || DEFAULT_CLOSED_STATUS_ID
end
end
end
......@@ -18,12 +18,4 @@ FactoryBot.define do
factory :issue_tracker_data, class: 'Integrations::IssueTrackerData' do
integration
end
factory :open_project_tracker_data, class: 'Integrations::OpenProjectTrackerData' do
integration factory: :open_project_service
url { 'http://openproject.example.com' }
token { 'supersecret' }
project_identifier_code { 'PRJ-1' }
closed_status_id { '15' }
end
end
......@@ -166,26 +166,6 @@ FactoryBot.define do
external_wiki_url { 'http://external-wiki-url.com' }
end
factory :open_project_service, class: 'Integrations::OpenProject' do
project
active { true }
transient do
url { 'http://openproject.example.com' }
api_url { 'http://openproject.example.com/issues/:id' }
token { 'supersecret' }
closed_status_id { '15' }
project_identifier_code { 'PRJ-1' }
end
after(:build) do |integration, evaluator|
integration.open_project_tracker_data = build(:open_project_tracker_data,
integration: integration, url: evaluator.url, api_url: evaluator.api_url, token: evaluator.token,
closed_status_id: evaluator.closed_status_id, project_identifier_code: evaluator.project_identifier_code
)
end
end
trait :jira_cloud_service do
url { 'https://mysite.atlassian.net' }
username { 'jira_user' }
......
......@@ -324,7 +324,6 @@ integrations:
- jira_tracker_data
- zentao_tracker_data
- issue_tracker_data
- open_project_tracker_data
hooks:
- project
- web_hook_logs
......
......@@ -14,7 +14,6 @@ RSpec.describe Integration do
it { is_expected.to have_one(:service_hook).inverse_of(:integration).with_foreign_key(:service_id) }
it { is_expected.to have_one(:issue_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::IssueTrackerData') }
it { is_expected.to have_one(:jira_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::JiraTrackerData') }
it { is_expected.to have_one(:open_project_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::OpenProjectTrackerData') }
end
describe 'validations' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::OpenProject do
describe 'Validations' do
context 'when integration is active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:token) }
it { is_expected.to validate_presence_of(:project_identifier_code) }
it_behaves_like 'issue tracker integration URL attribute', :url
it_behaves_like 'issue tracker integration URL attribute', :api_url
end
context 'when integration is inactive' do
before do
subject.active = false
end
it { is_expected.not_to validate_presence_of(:url) }
it { is_expected.not_to validate_presence_of(:token) }
it { is_expected.not_to validate_presence_of(:project_identifier_code) }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::OpenProjectTrackerData do
describe 'associations' do
it { is_expected.to belong_to(:integration) }
end
describe 'closed_status_id' do
it 'returns the set value' do
expect(build(:open_project_tracker_data).closed_status_id).to eq('15')
end
it 'returns the default value if not set' do
expect(build(:open_project_tracker_data, closed_status_id: nil).closed_status_id).to eq('13')
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