2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2016-02-16 22:55:24 -05:00
|
|
|
factory :snippet do
|
|
|
|
author
|
2017-03-23 12:37:14 -04:00
|
|
|
title { generate(:title) }
|
|
|
|
content { generate(:title) }
|
2017-05-03 11:26:49 -04:00
|
|
|
description { generate(:title) }
|
2017-03-23 12:37:14 -04:00
|
|
|
file_name { generate(:filename) }
|
2019-11-19 01:06:07 -05:00
|
|
|
secret { false }
|
2016-03-08 16:39:53 -05:00
|
|
|
|
|
|
|
trait :public do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Snippet::PUBLIC }
|
2016-03-08 16:39:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :internal do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Snippet::INTERNAL }
|
2016-03-08 16:39:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :private do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Snippet::PRIVATE }
|
2016-03-08 16:39:53 -05:00
|
|
|
end
|
2020-02-13 10:08:52 -05:00
|
|
|
|
|
|
|
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
|
|
|
|
trait :repository do
|
|
|
|
after :create do |snippet|
|
|
|
|
TestEnv.copy_repo(snippet,
|
|
|
|
bare_repo: TestEnv.factory_repo_path_bare,
|
|
|
|
refs: TestEnv::BRANCH_SHA)
|
2020-02-27 19:09:08 -05:00
|
|
|
|
2020-03-25 08:08:19 -04:00
|
|
|
snippet.track_snippet_repository(snippet.repository.storage)
|
2020-02-13 10:08:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :empty_repo do
|
|
|
|
after(:create) do |snippet|
|
2020-03-06 13:08:08 -05:00
|
|
|
raise "Failed to create repository!" unless snippet.create_repository
|
2020-02-13 10:08:52 -05:00
|
|
|
end
|
|
|
|
end
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|
2017-06-22 10:43:52 -04:00
|
|
|
|
|
|
|
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2017-08-04 13:14:04 -04:00
|
|
|
author { project.creator }
|
2017-06-22 10:43:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do
|
2019-11-19 01:06:07 -05:00
|
|
|
trait :secret do
|
|
|
|
visibility_level { Snippet::PUBLIC }
|
|
|
|
secret { true }
|
2020-03-16 20:09:12 -04:00
|
|
|
project { nil }
|
2019-11-19 01:06:07 -05:00
|
|
|
end
|
2017-06-22 10:43:52 -04:00
|
|
|
end
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|