public
Description: The code that runs webjam.com.au
Homepage: http://webjam.com.au
Clone URL: git://github.com/webjam/webjam.git
webjam / spec / factories.rb
100644 74 lines (64 sloc) 2.08 kb
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
require 'factory_girl'
 
Factory.define :user do |u|
  u.nick_name {Factory.next(:nick_name)}
  u.email {Factory.next(:email)}
  u.full_name 'Full name'
end
 
Factory.define(:identity_url) do |iu|
  iu.url {Factory.next(:identity_url)}
  iu.association :user
end
 
Factory.define :post do |u|
  u.title "Title"
  u.body "<p>Body</p>"
  u.published_at Time.now.utc
  u.permalink {|a| "#{a.published_at.year}-#{Factory.next(:permalink)}"}
  u.association :user
end
 
Factory.define :post_comment, :class => Comment do |c|
  c.body "Me too!"
  c.association :user
  c.association :commentable, :factory => :post
end
 
Factory.define :event do |e|
  e.name {"Webjam #{Factory.next(:event_number)}"}
  e.tag {"webjam#{Factory.next(:event_number)}"}
  e.location "Sydney"
  e.hype "<p>Buy it.</p>"
  e.timezone "Sydney"
  e.published_at Time.now.utc
  e.map_iframe_url "http://iframe.com"
  e.map_url "http://map.com"
end
 
Factory.define :past_event, :class => Event do |e|
  e.name {"Webjam #{Factory.next(:event_number)}"}
  e.tag {"webjam#{Factory.next(:event_number)}"}
  e.location "Sydney"
  e.hype "<p>Buy it.</p>"
  e.timezone "Sydney"
  e.published_at Time.now.utc
  e.map_iframe_url "http://iframe.com"
  e.map_url "http://map.com"
  e.held_at 5.days.ago
  e.proposals_close_at 7.days.ago
end
 
Factory.define :user_presenter, :class => Presenter do |p|
  p.association :user
end
 
Factory.define :non_user_presenter, :class => Presenter do |p|
  p.name 'Ms Presenter'
  p.url 'http://mspresenter.com/'
end
 
Factory.define :presentation, :class => Jam do |p|
  p.title 'Preso title'
  p.description 'Preso description'
  p.number {Factory.next(:jam_number)}
  p.presenters {|p| [p.association(:user_presenter), p.association(:non_user_presenter)]}
  p.association :event
end
 
Factory.sequence(:email) {|n| "user#{n}@domain.com"}
Factory.sequence(:nick_name) {|n| "nick_name_#{n}"}
Factory.sequence(:permalink) {|n| "permalink_#{n}"}
Factory.sequence(:event_number) {|n| n}
Factory.sequence(:identity_url) {|n| "http://openid-provider-#{n}.com/"}
Factory.sequence(:jam_number) {|n| n}