diff options
Diffstat (limited to 'spec/factories/services.rb')
-rw-r--r-- | spec/factories/services.rb | 74 |
1 files changed, 27 insertions, 47 deletions
diff --git a/spec/factories/services.rb b/spec/factories/services.rb index c4cb3f07fe7..b2d6ada91fa 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -9,7 +9,11 @@ FactoryBot.define do factory :custom_issue_tracker_service, class: CustomIssueTrackerService do project active true - issue_tracker + properties( + project_url: 'https://project.url.com', + issues_url: 'https://issues.url.com', + new_issue_url: 'https://newissue.url.com' + ) end factory :emails_on_push_service do @@ -43,24 +47,12 @@ FactoryBot.define do factory :jira_service do project active true - - transient do - create_data true - url 'https://jira.example.com' - api_url nil - username 'jira_username' - password 'jira_password' - jira_issue_transition_id '56-1' - 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 + properties( + url: 'https://jira.example.com', + username: 'jira_user', + password: 'my-secret-password', + project_key: 'jira-key' + ) end factory :bugzilla_service do @@ -88,26 +80,20 @@ FactoryBot.define do end trait :issue_tracker do - transient do - 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' - 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 + properties( + project_url: 'http://issue-tracker.example.com', + issues_url: 'http://issue-tracker.example.com/issues/:id', + new_issue_url: 'http://issue-tracker.example.com' + ) end trait :jira_cloud_service do - url 'https://mysite.atlassian.net' - username 'jira_user' - password 'my-secret-password' + properties( + url: 'https://mysite.atlassian.net', + username: 'jira_user', + password: 'my-secret-password', + project_key: 'jira-key' + ) end factory :hipchat_service do @@ -116,21 +102,15 @@ FactoryBot.define do token 'test_token' end - # this is for testing storing values inside properties, which is deprecated and will be removed in - # https://gitlab.com/gitlab-org/gitlab-ce/issues/63084 trait :without_properties_callback do - jira_tracker_data nil - issue_tracker_data nil - create_data false - after(:build) do |service| - IssueTrackerService.skip_callback(:validation, :before, :handle_properties) + allow(service).to receive(:handle_properties) end - to_create { |instance| instance.save(validate: false)} - - after(:create) do - IssueTrackerService.set_callback(:validation, :before, :handle_properties) + after(:create) do |service| + # we have to remove the stub because the behaviour of + # handle_properties method is tested after the creation + allow(service).to receive(:handle_properties).and_call_original end end end |