diff options
author | Jarka Košanová <jarka@gitlab.com> | 2019-07-11 12:53:08 +0300 |
---|---|---|
committer | Jarka Košanová <jarka@gitlab.com> | 2019-07-16 11:04:54 +0300 |
commit | c8e24280c55b5678bc2c01435ab26781bbbb6cd2 (patch) | |
tree | 73c001626e005b7df622db6a329158376567697d /spec/factories | |
parent | 00b944afb88d1e52add0724c7d5cc6b62505ec32 (diff) |
Simplify factories for services
- use predefined factories when creating
projects with services
- remove unnecessary arguments
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/projects.rb | 22 | ||||
-rw-r--r-- | spec/factories/services.rb | 6 | ||||
-rw-r--r-- | spec/factories/services_data.rb | 8 |
3 files changed, 6 insertions, 30 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 743ec322885..7d7738a30c8 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -306,34 +306,18 @@ FactoryBot.define do factory :redmine_project, parent: :project do has_external_issue_tracker true - after :create do |project| - project.create_redmine_service( - active: true, - properties: { - 'project_url' => 'http://redmine/projects/project_name_in_redmine', - 'issues_url' => 'http://redmine/projects/project_name_in_redmine/issues/:id', - 'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new' - } - ) - end + redmine_service end factory :youtrack_project, parent: :project do has_external_issue_tracker true - after :create do |project| - project.create_youtrack_service( - active: true, - properties: { - 'project_url' => 'http://youtrack/projects/project_guid_in_youtrack', - 'issues_url' => 'http://youtrack/issues/:id' - } - ) - end + youtrack_service end factory :jira_project, parent: :project do has_external_issue_tracker true + jira_service end diff --git a/spec/factories/services.rb b/spec/factories/services.rb index cd1d2c33373..daf842e3075 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -79,14 +79,12 @@ FactoryBot.define do trait :issue_tracker do properties( project_url: 'http://issue-tracker.example.com', - issues_url: 'http://issue-tracker.example.com', + issues_url: 'http://issue-tracker.example.com/issues/:id', new_issue_url: 'http://issue-tracker.example.com' ) end - factory :jira_cloud_service, class: JiraService do - project - active true + trait :jira_cloud_service do properties( url: 'https://mysite.atlassian.net', username: 'jira_user', diff --git a/spec/factories/services_data.rb b/spec/factories/services_data.rb index 387e130a743..5a3639895b6 100644 --- a/spec/factories/services_data.rb +++ b/spec/factories/services_data.rb @@ -1,18 +1,12 @@ # frozen_string_literal: true +# these factories should never be called directly, they are used when creating services FactoryBot.define do factory :jira_tracker_data do service - url 'http://jira.example.com' - api_url 'http://api-jira.example.com' - username 'jira_username' - password 'jira_password' end factory :issue_tracker_data do service - project_url 'http://issuetracker.example.com' - issues_url 'http://issues.example.com' - new_issue_url 'http://new-issue.example.com' end end |