debian-mirror-gitlab/spec/factories/snippets.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

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-09 13:42:32 +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)
end
end
trait :empty_repo do
after(:create) do |snippet|
raise "Failed to create repository!" unless snippet.repository.create_if_not_exists
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 }
end
2017-09-10 17:25:29 +05:30
end
2016-06-02 11:05:42 +05:30
end