diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 12:09:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-17 12:09:20 +0000 |
commit | b84eeb256c4a780d902faee1f99ca9a711b3214a (patch) | |
tree | 32918aadbea9210eace50efbce9afbfb8cd3ba84 /spec/factories | |
parent | 53ae6b7e3f83591ad251a3f771f5bf3b8cf087ba (diff) | |
download | gitlab-ce-b84eeb256c4a780d902faee1f99ca9a711b3214a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/container_expiration_policies.rb | 13 | ||||
-rw-r--r-- | spec/factories/projects.rb | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/spec/factories/container_expiration_policies.rb b/spec/factories/container_expiration_policies.rb index 951127a4aa7..41c3a7f8cb9 100644 --- a/spec/factories/container_expiration_policies.rb +++ b/spec/factories/container_expiration_policies.rb @@ -2,7 +2,18 @@ FactoryBot.define do factory :container_expiration_policy, class: 'ContainerExpirationPolicy' do - association :project, factory: [:project, :without_container_expiration_policy] + # Note: because of the project_id primary_key on + # container_expiration_policies, and the create_container_expiration_policy + # callback on Project, we need to build the project first before assigning + # it to a container_expiration_policy. + # + # Also, if you wish to assign an existing project to a + # container_expiration_policy, you will then have to destroy the project's + # container_expiration_policy first. + before(:create) do |container_expiration_policy| + container_expiration_policy.project = build(:project) unless container_expiration_policy.project + end + cadence { '1d' } enabled { true } diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 9be0b308680..ba38e1bb312 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -140,12 +140,6 @@ FactoryBot.define do end end - trait :without_container_expiration_policy do - after(:build) do |project| - project.class.skip_callback(:create, :after, :create_container_expiration_policy, raise: false) - end - end - # Build a custom repository by specifying a hash of `filename => content` in # the transient `files` attribute. Each file will be created in its own # commit, operating against the master branch. So, the following call: |