forked from redbooth/teambox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactories.rb
240 lines (201 loc) · 6.02 KB
/
factories.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
require 'factory_girl'
Factory.sequence :login do |n|
"gandhi_#{n}"
end
Factory.sequence :email do |n|
"gandhi_#{n}@localhost.com"
end
Factory.sequence :name do |n|
"Teambox ##{n}"
end
Factory.sequence :folder_name do |n|
"the files #{n}"
end
Factory.sequence :permalink do |n|
"teambox#{n}"
end
Factory.define :user do |user|
user.login { Factory.next(:login) }
user.email { Factory.next(:email) }
user.first_name 'Andrew'
user.last_name 'Wiggin'
user.password 'dragons'
user.password_confirmation 'dragons'
user.confirmed_user true
user.splash_screen false
end
# compatibility with older specs/cukes
Factory.define :confirmed_user, :parent => :user do |user|
end
Factory.define :unconfirmed_user, :parent => :user do |user|
user.splash_screen true
user.confirmed_user false
end
Factory.define :mislav, :parent => :user do |user|
user.login 'mislav'
user.email '[email protected]'
user.first_name 'Mislav'
user.last_name 'Marohnić'
end
Factory.define :organization do |organization|
organization.name { Factory.next(:name) }
organization.permalink { Factory.next(:permalink )}
end
Factory.define :person do |person|
person.association(:project)
person.association(:user)
end
Factory.define :project do |project|
project.name { Factory.next(:name) }
project.association(:user)
project.association(:organization)
end
Factory.define :ruby_rockstars, :class => 'Project' do |project|
project.name "Ruby Rockstars"
project.permalink "ruby_rockstars"
project.user_id do
(User.find_by_login('mislav') || Factory(:mislav)).id
end
project.association(:organization, :name => "ACME")
end
Factory.define :procial_network, :class => 'Project' do |project|
project.name "Procial Network"
project.permalink "procial_network"
project.public true
project.user_id do
(User.find_by_login('mislav') || Factory(:mislav)).id
end
project.association(:organization, :name => "ACME")
end
Factory.define :archived_project, :parent => :project do |project|
project.archived true
end
Factory.define :conversation do |conversation|
conversation.name 'The Master Plan'
conversation.body 'Shorter than a New York minute'
conversation.simple false
conversation.association(:user)
conversation.association(:project)
end
Factory.define :simple_conversation, :parent => :conversation do |conversation|
conversation.name nil
conversation.simple true
end
Factory.define :task_list_template do |template|
template.association(:organization)
template.name 'I will come up with a better name later'
template.tasks [['First task'],['Second task'],['Third task']]
end
Factory.define :complete_task_list_template, :parent => :task_list_template do |template|
template.tasks [['First task', 'Bla bla bla'],['Second task','You motherfucker'],['Third task','Booh yah.']]
end
Factory.define :task_list do |task_list|
task_list.name 'Buy Groceries'
task_list.association(:user)
task_list.association(:project)
end
Factory.define :task do |task|
task.name 'Buy milk'
task.association(:user)
task.association(:project)
task.association(:task_list)
end
Factory.define :archived_task, :class => Task do |task|
task.name 'Buy milk'
task.association(:user)
task.association(:project)
task.association(:task_list)
task.archived true
end
Factory.define :held_task, :class => Task do |task|
task.name 'Buy milk'
task.association(:user)
task.association(:project)
task.association(:task_list)
task.status Task::STATUSES[:hold]
end
Factory.define :resolved_task, :class => Task do |task|
task.name 'Buy milk'
task.association(:user)
task.association(:project)
task.association(:task_list)
task.status Task::STATUSES[:resolved]
end
Factory.define :rejected_task, :class => Task do |task|
task.name 'Buy milk'
task.association(:user)
task.association(:project)
task.association(:task_list)
task.status Task::STATUSES[:rejected]
end
Factory.define :comment do |comment|
comment.association(:user)
comment.association(:project)
comment.target { |comment| comment.project }
comment.body 'Just finished posting this comment'
end
Factory.define :upload do |upload|
upload.asset_file_name 'pic.png'
upload.asset_file_size 42
upload.asset_content_type 'image/png'
upload.association(:project)
upload.association(:user)
end
Factory.define :folder do |folder|
folder.name {Factory.next(:folder_name)}
folder.association(:project)
folder.association(:user)
end
Factory.define :page do |page|
page.association(:user)
page.association(:project)
page.name 'Keys to the Castle'
end
Factory.define :reset_password do |reset_pw|
reset_pw.reset_code "d1b9547cb3ec99180acfe951c807ec567c8b9252"
reset_pw.email { Factory.next(:email) }
reset_pw.association(:user)
end
Factory.define :invitation do |i|
i.association(:project)
i.user { |i| i.project.user }
i.email { Factory.next(:email) }
end
Factory.define :email_bounce do |f|
f.email { Factory.next(:email) }
end
Factory.define :google_doc do |d|
d.title "Very interesting spreadsheet"
d.url "https://google.com/document/1234"
d.document_type "spreadsheet"
d.association :user
d.association :project
d.association :comment
end
Factory.define :client_application do |f|
f.association(:user)
f.name "MyString"
f.url "http://test.com"
f.support_url "http://test.com/support"
f.callback_url "http://application/callback"
f.key "one_key"
f.secret "MyString"
f.created_at Time.parse("2007-11-17 16:56:51")
f.updated_at Time.parse("2007-11-17 16:56:51")
end
Factory.define :cucumber_ly, :parent => :client_application do |f|
f.association(:user)
f.name "Cucumber.ly"
f.url "http://cucumber.ly"
f.support_url "http://cucumber.ly/support"
f.callback_url "http://cucumber.ly/callback"
f.created_at Time.parse("2007-11-17 16:56:51")
f.updated_at Time.parse("2007-11-17 16:56:51")
end
Factory.define :app_link do |d|
d.provider "google"
d.app_user_id { Factory.next(:login) }
d.credentials({'token' => 'xxx', 'secret' => 'blabla'})
d.custom_attributes({'custom' => 1})
d.association :user
end