diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-03 13:39:20 +0200 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-03 13:39:20 +0200 |
commit | bf790c26c58e214c27132e7a54fdf4a4cc77bdaf (patch) | |
tree | 918a36ccb23fe2fbbe671e9914ad6536af9fb5a8 /spec | |
parent | 7bc24ec2e524b55402fa5caeb64e75e02f97ddc5 (diff) | |
download | gitlab-ce-bf790c26c58e214c27132e7a54fdf4a4cc77bdaf.tar.gz |
Use factory in specs for ProjectCiCdSettings
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/project_ci_cd_settings.rb | 10 | ||||
-rw-r--r-- | spec/factories/projects.rb | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/spec/factories/project_ci_cd_settings.rb b/spec/factories/project_ci_cd_settings.rb new file mode 100644 index 00000000000..2e85b54e245 --- /dev/null +++ b/spec/factories/project_ci_cd_settings.rb @@ -0,0 +1,10 @@ +FactoryBot.define do + factory :project_ci_cd_setting do + project + + initialize_with do + # ci_cd_settings are automatically created when a project is created + project&.ci_cd_settings || new + end + end +end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index aed5eab8044..e0e72e7f2ce 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -14,6 +14,7 @@ FactoryBot.define do # Associations namespace creator { group ? create(:user) : namespace&.owner } + ci_cd_settings strategy: :build, factory: :project_ci_cd_setting, project: nil transient do # Nest Project Feature attributes @@ -23,10 +24,6 @@ FactoryBot.define do 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| @@ -51,9 +48,6 @@ 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 |