diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-07 05:59:43 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-07 05:59:43 +0300 |
commit | 1f39fcd1123c1a65798a0a0b3e5f3b2fa43651ac (patch) | |
tree | 8d8a6a5a6a424c3f61332e509b97ab85cf0167b5 /spec/factories | |
parent | c1d3b48c96ce44a2ff3e84cb89063a00c67297f5 (diff) | |
parent | 58aa2d7f395be4aee38b5202ef1666879505c737 (diff) |
Merge branch 'master' into live-trace-v2
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/import_state.rb | 38 | ||||
-rw-r--r-- | spec/factories/projects.rb | 41 | ||||
-rw-r--r-- | spec/factories/term_agreements.rb | 6 | ||||
-rw-r--r-- | spec/factories/terms.rb | 5 |
4 files changed, 85 insertions, 5 deletions
diff --git a/spec/factories/import_state.rb b/spec/factories/import_state.rb new file mode 100644 index 00000000000..15d0a9d466a --- /dev/null +++ b/spec/factories/import_state.rb @@ -0,0 +1,38 @@ +FactoryBot.define do + factory :import_state, class: ProjectImportState do + status :none + association :project, factory: :project + + transient do + import_url { generate(:url) } + end + + trait :repository do + association :project, factory: [:project, :repository] + end + + trait :none do + status :none + end + + trait :scheduled do + status :scheduled + end + + trait :started do + status :started + end + + trait :finished do + status :finished + end + + trait :failed do + status :failed + end + + after(:create) do |import_state, evaluator| + import_state.project.update_columns(import_url: evaluator.import_url) + end + end +end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 1904615778c..a6128903546 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -15,14 +15,18 @@ FactoryBot.define do namespace creator { group ? create(:user) : namespace&.owner } - # Nest Project Feature attributes transient do + # Nest Project Feature attributes wiki_access_level ProjectFeature::ENABLED builds_access_level ProjectFeature::ENABLED snippets_access_level ProjectFeature::ENABLED issues_access_level ProjectFeature::ENABLED merge_requests_access_level ProjectFeature::ENABLED repository_access_level ProjectFeature::ENABLED + + # we can't assign the delegated `#ci_cd_settings` attributes directly, as the + # `#ci_cd_settings` relation needs to be created first + group_runners_enabled nil end after(:create) do |project, evaluator| @@ -47,6 +51,9 @@ FactoryBot.define do end project.group&.refresh_members_authorized_projects + + # assign the delegated `#ci_cd_settings` attributes after create + project.reload.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil? end trait :public do @@ -62,19 +69,43 @@ FactoryBot.define do end trait :import_scheduled do - import_status :scheduled + transient do + status :scheduled + end + + before(:create) do |project, evaluator| + project.create_import_state(status: evaluator.status) + end end trait :import_started do - import_status :started + transient do + status :started + end + + before(:create) do |project, evaluator| + project.create_import_state(status: evaluator.status) + end end trait :import_finished do - import_status :finished + transient do + status :finished + end + + before(:create) do |project, evaluator| + project.create_import_state(status: evaluator.status) + end end trait :import_failed do - import_status :failed + transient do + status :failed + end + + before(:create) do |project, evaluator| + project.create_import_state(status: evaluator.status) + end end trait :archived do diff --git a/spec/factories/term_agreements.rb b/spec/factories/term_agreements.rb new file mode 100644 index 00000000000..557599e663d --- /dev/null +++ b/spec/factories/term_agreements.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :term_agreement do + term + user + end +end diff --git a/spec/factories/terms.rb b/spec/factories/terms.rb new file mode 100644 index 00000000000..5ffca365a5f --- /dev/null +++ b/spec/factories/terms.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :term, class: ApplicationSetting::Term do + terms "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + end +end |