Commit 32d0bf3a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix snippets seeds

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d6fdca9a
Gitlab::Seeder.quiet do Gitlab::Seeder.quiet do
contents = [ content =<<eos
`curl https://gist.githubusercontent.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`, class Member < ActiveRecord::Base
`curl https://gist.githubusercontent.com/randx/3754594/raw/11026a295e6ef3a151c635707a3e1e8e15fc4725/gitlab_setup.sh`, include Notifiable
`curl https://gist.githubusercontent.com/randx/3065552/raw/29fbd09f4605a5ea22a5a9095e35fd1938dea4d6/gistfile1.sh`, include Gitlab::Access
]
belongs_to :user
belongs_to :source, polymorphic: true
validates :user, presence: true
validates :source, presence: true
validates :user_id, uniqueness: { scope: [:source_type, :source_id], message: "already exists in source" }
validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
scope :guests, -> { where(access_level: GUEST) }
scope :reporters, -> { where(access_level: REPORTER) }
scope :developers, -> { where(access_level: DEVELOPER) }
scope :masters, -> { where(access_level: MASTER) }
scope :owners, -> { where(access_level: OWNER) }
delegate :name, :username, :email, to: :user, prefix: true
end
eos
(1..50).each do |i| (1..50).each do |i|
user = User.all.sample user = User.all.sample
...@@ -12,10 +29,11 @@ Gitlab::Seeder.quiet do ...@@ -12,10 +29,11 @@ Gitlab::Seeder.quiet do
id: i, id: i,
author_id: user.id, author_id: user.id,
title: Faker::Lorem.sentence(3), title: Faker::Lorem.sentence(3),
file_name: Faker::Internet.domain_word + '.sh', file_name: Faker::Internet.domain_word + '.rb',
private: [true, false].sample, visibility_level: Gitlab::VisibilityLevel.values.sample,
content: contents.sample, content: content,
}]) }])
print('.') print('.')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment