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 :event do
|
2017-09-10 17:25:29 +05:30
|
|
|
project
|
2018-03-17 18:26:18 +05:30
|
|
|
author(factory: :user) { project.creator }
|
2020-06-23 00:09:42 +05:30
|
|
|
action { :joined }
|
|
|
|
|
|
|
|
trait(:created) { action { :created } }
|
|
|
|
trait(:updated) { action { :updated } }
|
|
|
|
trait(:closed) { action { :closed } }
|
|
|
|
trait(:reopened) { action { :reopened } }
|
|
|
|
trait(:pushed) { action { :pushed } }
|
|
|
|
trait(:commented) { action { :commented } }
|
|
|
|
trait(:merged) { action { :merged } }
|
|
|
|
trait(:joined) { action { :joined } }
|
|
|
|
trait(:left) { action { :left } }
|
|
|
|
trait(:destroyed) { action { :destroyed } }
|
|
|
|
trait(:expired) { action { :expired } }
|
2021-01-03 14:25:43 +05:30
|
|
|
trait(:approved) { action { :approved } }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
factory :closed_issue_event do
|
2020-06-23 00:09:42 +05:30
|
|
|
action { :closed }
|
2020-07-28 23:09:34 +05:30
|
|
|
target { association(:closed_issue, project: project) }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
factory :wiki_page_event do
|
2020-06-23 00:09:42 +05:30
|
|
|
action { :created }
|
2022-11-25 23:54:43 +05:30
|
|
|
# rubocop: disable RSpec/FactoryBot/InlineAssociation
|
2021-04-29 21:17:54 +05:30
|
|
|
# A persistent project is needed to have a wiki page being created properly.
|
2020-05-24 23:13:21 +05:30
|
|
|
project { @overrides[:wiki_page]&.container || create(:project, :wiki_repo) }
|
2022-11-25 23:54:43 +05:30
|
|
|
# rubocop: enable RSpec/FactoryBot/InlineAssociation
|
2021-04-29 21:17:54 +05:30
|
|
|
target { association(:wiki_page_meta, :for_wiki_page, wiki_page: wiki_page) }
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
transient do
|
2021-04-29 21:17:54 +05:30
|
|
|
wiki_page { association(:wiki_page, container: project) }
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
trait :has_design do
|
2020-05-24 23:13:21 +05:30
|
|
|
transient do
|
2021-04-29 21:17:54 +05:30
|
|
|
design { association(:design, issue: association(:issue, project: project)) }
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :for_design do
|
|
|
|
has_design
|
|
|
|
|
|
|
|
transient do
|
2021-04-29 21:17:54 +05:30
|
|
|
note { association(:note, author: author, project: project, noteable: design) }
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
action { :commented }
|
2020-05-24 23:13:21 +05:30
|
|
|
target { note }
|
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
trait :for_issue do
|
|
|
|
target { association(:issue, issue_type: :issue) }
|
|
|
|
target_type { 'Issue' }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :for_work_item do
|
|
|
|
target { association(:work_item, :task) }
|
|
|
|
target_type { 'WorkItem' }
|
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
trait :for_merge_request do
|
|
|
|
target { association(:merge_request) }
|
|
|
|
target_type { 'MergeRequest' }
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
factory :design_event, traits: [:has_design] do
|
|
|
|
action { :created }
|
|
|
|
target { design }
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
factory :design_updated_event, traits: [:has_design] do
|
|
|
|
action { :updated }
|
|
|
|
target { design }
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
factory :project_created_event do
|
|
|
|
project factory: :project
|
|
|
|
action { :created }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :project_imported_event do
|
|
|
|
project factory: [:project, :with_import_url]
|
|
|
|
action { :created }
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
factory :push_event, class: 'PushEvent' do
|
2017-09-10 17:25:29 +05:30
|
|
|
project factory: :project_empty_repo
|
2018-12-05 23:21:45 +05:30
|
|
|
author(factory: :user) { project.creator }
|
2020-06-23 00:09:42 +05:30
|
|
|
action { :pushed }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
factory :push_event_payload do
|
|
|
|
event
|
2019-12-21 20:55:43 +05:30
|
|
|
commit_count { 1 }
|
|
|
|
action { :pushed }
|
|
|
|
ref_type { :branch }
|
|
|
|
ref { 'master' }
|
|
|
|
commit_to { '3cdce97ed87c91368561584e7358f4d46e3e173c' }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|