factories.rb 1.94 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2 3 4
require File.join(Rails.root, 'spec', 'factory')

Factory.add(:project, Project) do |obj|
  obj.name = Faker::Internet.user_name
5
  obj.path = 'gitlabhq'
gitlabhq's avatar
gitlabhq committed
6
  obj.owner = Factory(:user)
gitlabhq's avatar
gitlabhq committed
7 8 9 10 11
  obj.code = 'LGT'
end

Factory.add(:public_project, Project) do |obj|
  obj.name = Faker::Internet.user_name
12
  obj.path = 'gitlabhq'
gitlabhq's avatar
gitlabhq committed
13
  obj.private_flag = false
gitlabhq's avatar
gitlabhq committed
14
  obj.owner = Factory(:user)
gitlabhq's avatar
gitlabhq committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  obj.code = 'LGT'
end

Factory.add(:user, User) do |obj|
  obj.email = Faker::Internet.email
  obj.password = "123456"
  obj.name = Faker::Name.name
  obj.password_confirmation = "123456"
end

Factory.add(:admin, User) do |obj|
  obj.email = Faker::Internet.email
  obj.password = "123456"
  obj.name = Faker::Name.name
  obj.password_confirmation = "123456"
  obj.admin = true
end

Factory.add(:issue, Issue) do |obj|
  obj.title = Faker::Lorem.sentence
35 36
  obj.author = Factory :user
  obj.assignee = Factory :user
gitlabhq's avatar
gitlabhq committed
37 38
end

39 40
Factory.add(:merge_request, MergeRequest) do |obj|
  obj.title = Faker::Lorem.sentence
41 42
  obj.author = Factory :user
  obj.assignee = Factory :user
43
  obj.source_branch = "master"
44
  obj.target_branch = "stable"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
45
  obj.closed = false
46 47
end

gitlabhq's avatar
gitlabhq committed
48 49 50 51 52 53
Factory.add(:snippet, Snippet) do |obj|
  obj.title = Faker::Lorem.sentence
  obj.file_name = Faker::Lorem.sentence
  obj.content = Faker::Lorem.sentences
end

gitlabhq's avatar
gitlabhq committed
54 55 56 57 58 59 60 61
Factory.add(:note, Note) do |obj|
  obj.note = Faker::Lorem.sentence
end

Factory.add(:key, Key) do |obj|
  obj.title = "Example key"
  obj.key = File.read(File.join(Rails.root, "db", "pkey.example"))
end
62 63

Factory.add(:web_hook, WebHook) do |obj|
Nihad Abbasov's avatar
Nihad Abbasov committed
64
  obj.url = Faker::Internet.uri("http")
65
end
vsizov's avatar
vsizov committed
66

67
Factory.add(:wiki, Wiki) do |obj|
vsizov's avatar
vsizov committed
68 69
  obj.title = Faker::Lorem.sentence
  obj.content = Faker::Lorem.sentence
70 71
  obj.user = Factory(:user)
  obj.project = Factory(:project)
vsizov's avatar
vsizov committed
72
end
73 74 75 76 77

Factory.add(:event, Event) do |obj|
  obj.title = Faker::Lorem.sentence
  obj.project = Factory(:project)
end
78 79 80 81 82

Factory.add(:milestone, Milestone) do |obj|
  obj.title = Faker::Lorem.sentence
  obj.due_date = Date.today + 1.month
end