2019-07-25 05:11:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2016-02-17 03:55:24 +00:00
|
|
|
factory :service do
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
type { 'Service' }
|
2017-04-25 15:48:12 +00:00
|
|
|
end
|
|
|
|
|
2020-01-09 18:07:52 +00:00
|
|
|
factory :custom_issue_tracker_service, class: 'CustomIssueTrackerService' do
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
2019-09-16 15:06:26 +00:00
|
|
|
issue_tracker
|
2016-02-17 03:55:24 +00:00
|
|
|
end
|
2017-02-07 15:59:38 +00:00
|
|
|
|
2019-08-15 17:37:36 +00:00
|
|
|
factory :emails_on_push_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
type { 'EmailsOnPushService' }
|
|
|
|
active { true }
|
|
|
|
push_events { true }
|
|
|
|
tag_push_events { true }
|
|
|
|
properties do
|
|
|
|
{
|
|
|
|
recipients: 'test@example.com',
|
|
|
|
disable_diffs: true,
|
|
|
|
send_from_committer_email: true
|
|
|
|
}
|
|
|
|
end
|
2019-08-15 17:37:36 +00:00
|
|
|
end
|
|
|
|
|
2019-02-07 03:00:32 +00:00
|
|
|
factory :mock_deployment_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
type { 'MockDeploymentService' }
|
|
|
|
active { true }
|
2019-02-07 03:00:32 +00:00
|
|
|
end
|
|
|
|
|
2017-05-31 11:40:03 +00:00
|
|
|
factory :prometheus_service do
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
|
|
|
properties do
|
|
|
|
{
|
|
|
|
api_url: 'https://prometheus.example.com/',
|
|
|
|
manual_configuration: true
|
|
|
|
}
|
|
|
|
end
|
2017-05-31 11:40:03 +00:00
|
|
|
end
|
|
|
|
|
2020-02-12 15:09:37 +00:00
|
|
|
factory :alerts_service do
|
2020-06-09 18:08:28 +00:00
|
|
|
active
|
2020-02-12 15:09:37 +00:00
|
|
|
project
|
|
|
|
type { 'AlertsService' }
|
2020-06-09 18:08:28 +00:00
|
|
|
|
|
|
|
trait :active do
|
|
|
|
active { true }
|
|
|
|
end
|
2020-02-12 15:09:37 +00:00
|
|
|
|
|
|
|
trait :inactive do
|
|
|
|
active { false }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-17 15:08:15 +00:00
|
|
|
factory :drone_ci_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
drone_url { 'https://bamboo.example.com' }
|
|
|
|
token { 'test' }
|
|
|
|
end
|
|
|
|
|
2017-03-03 14:25:52 +00:00
|
|
|
factory :jira_service do
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
2020-03-14 06:09:14 +00:00
|
|
|
type { 'JiraService' }
|
2019-09-16 15:06:26 +00:00
|
|
|
|
|
|
|
transient do
|
2019-10-02 00:06:26 +00:00
|
|
|
create_data { true }
|
|
|
|
url { 'https://jira.example.com' }
|
|
|
|
api_url { nil }
|
|
|
|
username { 'jira_username' }
|
|
|
|
password { 'jira_password' }
|
|
|
|
jira_issue_transition_id { '56-1' }
|
2020-07-15 15:09:21 +00:00
|
|
|
issues_enabled { false }
|
|
|
|
project_key { nil }
|
2019-09-16 15:06:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |service, evaluator|
|
|
|
|
if evaluator.create_data
|
|
|
|
create(:jira_tracker_data, service: service,
|
|
|
|
url: evaluator.url, api_url: evaluator.api_url, jira_issue_transition_id: evaluator.jira_issue_transition_id,
|
2020-07-15 15:09:21 +00:00
|
|
|
username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled,
|
|
|
|
project_key: evaluator.project_key
|
2019-09-16 15:06:26 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2017-03-03 14:25:52 +00:00
|
|
|
end
|
2017-05-22 10:07:12 +00:00
|
|
|
|
2020-07-14 12:09:14 +00:00
|
|
|
factory :confluence_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
confluence_url { 'https://example.atlassian.net/wiki' }
|
|
|
|
end
|
|
|
|
|
2019-06-26 14:03:57 +00:00
|
|
|
factory :bugzilla_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
2019-06-26 14:03:57 +00:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :redmine_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
2019-06-26 14:03:57 +00:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :youtrack_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
active { true }
|
2019-06-26 14:03:57 +00:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :issue_tracker do
|
2019-09-16 15:06:26 +00:00
|
|
|
transient do
|
2019-10-02 00:06:26 +00:00
|
|
|
create_data { true }
|
|
|
|
project_url { 'http://issuetracker.example.com' }
|
|
|
|
issues_url { 'http://issues.example.com/issues/:id' }
|
|
|
|
new_issue_url { 'http://new-issue.example.com' }
|
2019-09-16 15:06:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |service, evaluator|
|
|
|
|
if evaluator.create_data
|
|
|
|
create(:issue_tracker_data, service: service,
|
|
|
|
project_url: evaluator.project_url, issues_url: evaluator.issues_url, new_issue_url: evaluator.new_issue_url
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2019-06-26 14:03:57 +00:00
|
|
|
end
|
|
|
|
|
2020-03-27 12:07:43 +00:00
|
|
|
factory :open_project_service 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 |service, evaluator|
|
|
|
|
create(:open_project_tracker_data, service: service,
|
|
|
|
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
|
|
|
|
|
2019-07-11 09:53:08 +00:00
|
|
|
trait :jira_cloud_service do
|
2019-10-02 00:06:26 +00:00
|
|
|
url { 'https://mysite.atlassian.net' }
|
|
|
|
username { 'jira_user' }
|
|
|
|
password { 'my-secret-password' }
|
2018-11-04 00:37:47 +00:00
|
|
|
end
|
2019-04-09 13:06:36 +00:00
|
|
|
|
|
|
|
factory :hipchat_service do
|
|
|
|
project
|
2019-10-02 00:06:26 +00:00
|
|
|
type { 'HipchatService' }
|
|
|
|
token { 'test_token' }
|
2019-04-09 13:06:36 +00:00
|
|
|
end
|
2019-07-04 17:09:58 +00:00
|
|
|
|
2020-05-14 15:08:14 +00:00
|
|
|
factory :slack_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
webhook { 'https://slack.service.url' }
|
|
|
|
type { 'SlackService' }
|
|
|
|
end
|
|
|
|
|
2020-06-09 12:08:55 +00:00
|
|
|
factory :pipelines_email_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
type { 'PipelinesEmailService' }
|
|
|
|
recipients { 'test@example.com' }
|
|
|
|
end
|
|
|
|
|
2019-09-16 15:06:26 +00:00
|
|
|
# this is for testing storing values inside properties, which is deprecated and will be removed in
|
2019-09-26 12:06:00 +00:00
|
|
|
# https://gitlab.com/gitlab-org/gitlab/issues/29404
|
2019-07-04 17:09:58 +00:00
|
|
|
trait :without_properties_callback do
|
2019-10-02 00:06:26 +00:00
|
|
|
jira_tracker_data { nil }
|
|
|
|
issue_tracker_data { nil }
|
|
|
|
create_data { false }
|
2019-09-16 15:06:26 +00:00
|
|
|
|
2019-07-04 17:09:58 +00:00
|
|
|
after(:build) do |service|
|
2019-09-16 15:06:26 +00:00
|
|
|
IssueTrackerService.skip_callback(:validation, :before, :handle_properties)
|
2019-07-04 17:09:58 +00:00
|
|
|
end
|
|
|
|
|
2020-07-21 12:09:30 +00:00
|
|
|
to_create { |instance| instance.save!(validate: false) }
|
2019-09-16 15:06:26 +00:00
|
|
|
|
|
|
|
after(:create) do
|
|
|
|
IssueTrackerService.set_callback(:validation, :before, :handle_properties)
|
2019-07-04 17:09:58 +00:00
|
|
|
end
|
|
|
|
end
|
2020-03-14 06:09:14 +00:00
|
|
|
|
|
|
|
trait :template do
|
|
|
|
project { nil }
|
|
|
|
template { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :instance do
|
|
|
|
project { nil }
|
|
|
|
instance { true }
|
|
|
|
end
|
2016-02-17 03:55:24 +00:00
|
|
|
end
|