2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2016-06-02 11:05:42 +05:30
|
|
|
factory :service do
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
type { 'Service' }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
factory :custom_issue_tracker_service, class: 'CustomIssueTrackerService' do
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2019-12-04 20:38:33 +05:30
|
|
|
issue_tracker
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
factory :emails_on_push_service do
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
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
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
factory :mock_deployment_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
type { 'MockDeploymentService' }
|
|
|
|
active { true }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
factory :prometheus_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
|
|
|
properties do
|
|
|
|
{
|
|
|
|
api_url: 'https://prometheus.example.com/',
|
|
|
|
manual_configuration: true
|
|
|
|
}
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
factory :alerts_service do
|
2020-06-23 00:09:42 +05:30
|
|
|
active
|
2020-03-13 15:44:24 +05:30
|
|
|
project
|
|
|
|
type { 'AlertsService' }
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
trait :active do
|
|
|
|
active { true }
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
trait :inactive do
|
|
|
|
active { false }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
factory :drone_ci_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
drone_url { 'https://bamboo.example.com' }
|
|
|
|
token { 'test' }
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
factory :jira_service do
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2020-04-08 14:13:33 +05:30
|
|
|
type { 'JiraService' }
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
transient do
|
2019-12-21 20:55:43 +05:30
|
|
|
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-28 23:09:34 +05:30
|
|
|
issues_enabled { false }
|
|
|
|
project_key { nil }
|
2019-12-04 20:38:33 +05:30
|
|
|
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-28 23:09:34 +05:30
|
|
|
username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled,
|
|
|
|
project_key: evaluator.project_key
|
2019-12-04 20:38:33 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
factory :confluence_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
confluence_url { 'https://example.atlassian.net/wiki' }
|
|
|
|
end
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
factory :bugzilla_service do
|
2018-12-13 13:39:08 +05:30
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2019-09-30 21:07:59 +05:30
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :redmine_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2019-09-30 21:07:59 +05:30
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :youtrack_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2019-09-30 21:07:59 +05:30
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :gitlab_issue_tracker_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
active { true }
|
2019-09-30 21:07:59 +05:30
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :issue_tracker do
|
2019-12-04 20:38:33 +05:30
|
|
|
transient do
|
2019-12-21 20:55:43 +05:30
|
|
|
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-12-04 20:38:33 +05:30
|
|
|
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-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
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-09-30 21:07:59 +05:30
|
|
|
trait :jira_cloud_service do
|
2019-12-21 20:55:43 +05:30
|
|
|
url { 'https://mysite.atlassian.net' }
|
|
|
|
username { 'jira_user' }
|
|
|
|
password { 'my-secret-password' }
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
factory :hipchat_service do
|
|
|
|
project
|
2019-12-21 20:55:43 +05:30
|
|
|
type { 'HipchatService' }
|
|
|
|
token { 'test_token' }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
factory :slack_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
webhook { 'https://slack.service.url' }
|
|
|
|
type { 'SlackService' }
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
factory :pipelines_email_service do
|
|
|
|
project
|
|
|
|
active { true }
|
|
|
|
type { 'PipelinesEmailService' }
|
|
|
|
recipients { 'test@example.com' }
|
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
# this is for testing storing values inside properties, which is deprecated and will be removed in
|
2019-12-21 20:55:43 +05:30
|
|
|
# https://gitlab.com/gitlab-org/gitlab/issues/29404
|
2019-09-30 21:07:59 +05:30
|
|
|
trait :without_properties_callback do
|
2019-12-21 20:55:43 +05:30
|
|
|
jira_tracker_data { nil }
|
|
|
|
issue_tracker_data { nil }
|
|
|
|
create_data { false }
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
after(:build) do |service|
|
2019-12-04 20:38:33 +05:30
|
|
|
IssueTrackerService.skip_callback(:validation, :before, :handle_properties)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
to_create { |instance| instance.save(validate: false) }
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
after(:create) do
|
|
|
|
IssueTrackerService.set_callback(:validation, :before, :handle_properties)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
trait :template do
|
|
|
|
project { nil }
|
|
|
|
template { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :instance do
|
|
|
|
project { nil }
|
|
|
|
instance { true }
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|