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 :snippet do
|
|
|
|
author
|
2017-08-17 22:00:37 +05:30
|
|
|
title { generate(:title) }
|
|
|
|
content { generate(:title) }
|
2017-09-10 17:25:29 +05:30
|
|
|
description { generate(:title) }
|
2017-08-17 22:00:37 +05:30
|
|
|
file_name { generate(:filename) }
|
2020-01-01 13:55:28 +05:30
|
|
|
secret { false }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
trait :public do
|
2019-12-21 20:55:43 +05:30
|
|
|
visibility_level { Snippet::PUBLIC }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :internal do
|
2019-12-21 20:55:43 +05:30
|
|
|
visibility_level { Snippet::INTERNAL }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
trait :private do
|
2019-12-21 20:55:43 +05:30
|
|
|
visibility_level { Snippet::PRIVATE }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
# 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-04-08 14:13:33 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
snippet.track_snippet_repository(snippet.repository.storage)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :empty_repo do
|
|
|
|
after(:create) do |snippet|
|
2020-04-08 14:13:33 +05:30
|
|
|
raise "Failed to create repository!" unless snippet.create_repository
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
|
|
|
|
project
|
2018-03-17 18:26:18 +05:30
|
|
|
author { project.creator }
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do
|
2020-01-01 13:55:28 +05:30
|
|
|
trait :secret do
|
|
|
|
visibility_level { Snippet::PUBLIC }
|
|
|
|
secret { true }
|
2020-04-08 14:13:33 +05:30
|
|
|
project { nil }
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|