debian-mirror-gitlab/db/fixtures/development/12_snippets.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require './spec/support/sidekiq'
2014-09-02 18:07:02 +05:30
Gitlab::Seeder.quiet do
2015-04-26 12:48:37 +05:30
content =<<eos
class Member < ActiveRecord::Base
include Notifiable
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) }
2018-11-18 11:00:15 +05:30
scope :maintainers, -> { where(access_level: MAINTAINER) }
2015-04-26 12:48:37 +05:30
scope :owners, -> { where(access_level: OWNER) }
delegate :name, :username, :email, to: :user, prefix: true
end
eos
2014-09-02 18:07:02 +05:30
2015-10-24 18:46:33 +05:30
50.times do |i|
2014-09-02 18:07:02 +05:30
user = User.all.sample
PersonalSnippet.seed(:id, [{
id: i,
author_id: user.id,
2015-09-11 14:41:01 +05:30
title: FFaker::Lorem.sentence(3),
file_name: FFaker::Internet.domain_word + '.rb',
2015-04-26 12:48:37 +05:30
visibility_level: Gitlab::VisibilityLevel.values.sample,
content: content,
2014-09-02 18:07:02 +05:30
}])
2015-04-26 12:48:37 +05:30
2014-09-02 18:07:02 +05:30
print('.')
end
end