2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2016-02-16 22:55:24 -05:00
|
|
|
factory :service do
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
type { 'Service' }
|
2017-04-25 11:48:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :custom_issue_tracker_service, class: CustomIssueTrackerService do
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-09-16 11:06:26 -04:00
|
|
|
issue_tracker
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|
2017-02-07 10:59:38 -05:00
|
|
|
|
2019-08-15 13:37:36 -04:00
|
|
|
factory :emails_on_push_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04: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 13:37:36 -04:00
|
|
|
end
|
|
|
|
|
2019-02-06 22:00:32 -05:00
|
|
|
factory :mock_deployment_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
type { 'MockDeploymentService' }
|
|
|
|
active { true }
|
2019-02-06 22:00:32 -05:00
|
|
|
end
|
|
|
|
|
2017-05-31 07:40:03 -04:00
|
|
|
factory :prometheus_service do
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
|
|
|
properties do
|
|
|
|
{
|
|
|
|
api_url: 'https://prometheus.example.com/',
|
|
|
|
manual_configuration: true
|
|
|
|
}
|
|
|
|
end
|
2017-05-31 07:40:03 -04:00
|
|
|
end
|
|
|
|
|
2017-03-03 09:25:52 -05:00
|
|
|
factory :jira_service do
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-09-16 11:06:26 -04:00
|
|
|
|
|
|
|
transient do
|
2019-10-01 20:06:26 -04:00
|
|
|
create_data { true }
|
|
|
|
url { 'https://jira.example.com' }
|
|
|
|
api_url { nil }
|
|
|
|
username { 'jira_username' }
|
|
|
|
password { 'jira_password' }
|
|
|
|
jira_issue_transition_id { '56-1' }
|
2019-09-16 11:06:26 -04: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,
|
|
|
|
username: evaluator.username, password: evaluator.password
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2017-03-03 09:25:52 -05:00
|
|
|
end
|
2017-05-22 06:07:12 -04:00
|
|
|
|
2019-06-26 10:03:57 -04:00
|
|
|
factory :bugzilla_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-06-26 10:03:57 -04:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :redmine_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-06-26 10:03:57 -04:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :youtrack_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-06-26 10:03:57 -04:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :gitlab_issue_tracker_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
active { true }
|
2019-06-26 10:03:57 -04:00
|
|
|
issue_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :issue_tracker do
|
2019-09-16 11:06:26 -04:00
|
|
|
transient do
|
2019-10-01 20:06:26 -04: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 11:06:26 -04: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 10:03:57 -04:00
|
|
|
end
|
|
|
|
|
2019-07-11 05:53:08 -04:00
|
|
|
trait :jira_cloud_service do
|
2019-10-01 20:06:26 -04:00
|
|
|
url { 'https://mysite.atlassian.net' }
|
|
|
|
username { 'jira_user' }
|
|
|
|
password { 'my-secret-password' }
|
2018-11-03 20:37:47 -04:00
|
|
|
end
|
2019-04-09 09:06:36 -04:00
|
|
|
|
|
|
|
factory :hipchat_service do
|
|
|
|
project
|
2019-10-01 20:06:26 -04:00
|
|
|
type { 'HipchatService' }
|
|
|
|
token { 'test_token' }
|
2019-04-09 09:06:36 -04:00
|
|
|
end
|
2019-07-04 13:09:58 -04:00
|
|
|
|
2019-09-16 11:06:26 -04:00
|
|
|
# this is for testing storing values inside properties, which is deprecated and will be removed in
|
2019-09-26 08:06:00 -04:00
|
|
|
# https://gitlab.com/gitlab-org/gitlab/issues/29404
|
2019-07-04 13:09:58 -04:00
|
|
|
trait :without_properties_callback do
|
2019-10-01 20:06:26 -04:00
|
|
|
jira_tracker_data { nil }
|
|
|
|
issue_tracker_data { nil }
|
|
|
|
create_data { false }
|
2019-09-16 11:06:26 -04:00
|
|
|
|
2019-07-04 13:09:58 -04:00
|
|
|
after(:build) do |service|
|
2019-09-16 11:06:26 -04:00
|
|
|
IssueTrackerService.skip_callback(:validation, :before, :handle_properties)
|
2019-07-04 13:09:58 -04:00
|
|
|
end
|
|
|
|
|
2019-10-01 20:06:26 -04:00
|
|
|
to_create { |instance| instance.save(validate: false) }
|
2019-09-16 11:06:26 -04:00
|
|
|
|
|
|
|
after(:create) do
|
|
|
|
IssueTrackerService.set_callback(:validation, :before, :handle_properties)
|
2019-07-04 13:09:58 -04:00
|
|
|
end
|
|
|
|
end
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|