forked from publify/publify
/
factories.rb
265 lines (231 loc) · 6.49 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# coding: utf-8
# Factory definitions
FactoryGirl.define do
sequence :name do |n|; "name_#{n}"; end
sequence :body do |n|; "body #{n}" * (n+3 % 5) ; end
sequence :user do |n|; "user#{n}" ; end
sequence :email do |n|; "user#{n}@example.com" ; end
sequence :guid do |n|; "deadbeef#{n}" ; end
sequence :label do |n|; "lab_#{n}" ; end
sequence :file_name do |f|; "file_name_#{f}" ; end
sequence :category do |n|; "c_#{n}" ; end
sequence :time do |n|; DateTime.new(2012,3,26,19,56) - n ; end
factory :user do
login { FactoryGirl.generate(:user) }
email { generate(:email) }
name 'Bond'
nickname "James Bond"
notify_via_email false
notify_on_new_articles false
notify_on_comments false
password 'top-secret'
avatar 'avatar.jpg'
medium_avatar 'medium_avatar.jpg'
thumb_avatar 'thumb_avatar.jpg'
large_avatar 'large_avatar.jpg'
state 'active'
twitter '@getpublify'
profile
association :text_filter, factory: :textile
end
factory :article do
title 'A big article'
body 'A content with several data'
extended 'extended content for fun'
guid
permalink 'a-big-article'
published_at DateTime.new(2005,1,1,2,0,0)
user
categories []
tags []
published_comments []
published_trackbacks []
allow_comments true
published true
allow_pings true
end
factory :unpublished_article, :parent => :article do |a|
a.published_at nil
a.published false
end
factory :content do
end
factory :post_type do |p|
p.name 'foobar'
p.description "Some description"
end
factory :markdown, :class => :text_filter do
name "markdown"
description "Markdown"
markup 'markdown'
filters '--- []'
params '--- {}'
after :stub do |filter|
TextFilter.stub(:find_by_name).with(filter.name) { filter }
end
end
factory :smartypants, :parent => :markdown do |m|
m.name "smartypants"
m.description "SmartyPants"
m.markup 'none'
m.filters %q{ [:smartypants].to_yaml.inspect }
end
factory 'markdown smartypants', :parent => :smartypants do |m|
m.name "markdown smartypants"
m.description "Markdown with SmartyPants"
m.markup 'markdown'
m.filters [:smartypants]
end
factory :textile, :parent => :markdown do |m|
m.name "textile"
m.description "Textile"
m.markup 'textile'
end
factory :none, :parent => :markdown do |m|
name "none"
description "None"
markup 'none'
after :stub do |filter|
TextFilter.stub(:find_by_name).with('') { nil }
end
end
factory :utf8article, :parent => :article do |u|
u.title 'ルビー'
u.permalink 'ルビー'
end
factory :second_article, :parent => :article do |a|
a.title 'Another big article'
end
factory :article_with_accent_in_html, :parent => :article do |a|
a.title 'article with accent'
a.body 'écoute The future is cool!'
a.permalink 'article-with-accent'
end
factory :blog do
base_url 'http://myblog.net'
hide_extended_on_rss true
blog_name 'test blog'
limit_article_display 2
sp_url_limit 3
plugin_avatar ''
blog_subtitle "test subtitles"
limit_rss_display 10
ping_urls "http://ping.example.com/ping
http://alsoping.example.com/rpc/ping"
geourl_location ""
default_allow_pings false
send_outbound_pings false
sp_global true
default_allow_comments true
email_from "scott@sigkill.org"
theme "typographic"
association :text_filter, factory: :textile
sp_article_auto_close 0
link_to_author false
comment_text_filter "markdown" #FactoryGirl.create(:markdown).name
permalink_format "/%year%/%month%/%day%/%title%"
use_canonical_url true
lang "en_US"
after :stub do |blog|
Blog.stub(:default) { blog }
[blog.text_filter, blog.comment_text_filter].uniq.each do |filter|
build_stubbed filter
end
end
end
factory :profile, :class => :profile do |l|
l.label {FactoryGirl.generate(:label)}
l.nicename 'Publify contributor'
l.modules [:dashboard, :profile]
end
factory :profile_admin, parent: :profile do
label Profile::ADMIN
nicename 'Publify administrator'
modules [ :dashboard, :write, :articles, :pages, :feedback, :themes,
:sidebar, :users, :seo, :media, :settings, :profile, :notes ]
end
factory :profile_publisher, :parent => :profile do |l|
l.label 'publisher'
l.nicename 'Blog publisher'
l.modules [:users, :dashboard, :write, :articles, :pages, :feedback, :media, :notes]
end
factory :profile_contributor, :parent => :profile do |l|
end
factory :category do |c|
c.name {FactoryGirl.generate(:category)}
c.permalink {FactoryGirl.generate(:category)}
c.position 1
end
factory :tag do |tag|
tag.name {FactoryGirl.generate(:name)}
tag.display_name { |a| a.name }
end
factory :resource do |r|
r.upload {FactoryGirl.generate(:file_name)}
r.mime 'image/jpeg'
r.size 110
end
factory :redirect do |r|
r.from_path 'foo/bar'
r.to_path '/someplace/else'
end
factory :comment do
published true
article
text_filter {FactoryGirl.create(:textile)}
author 'Bob Foo'
url 'http://fakeurl.com'
body 'Test <a href="http://fakeurl.co.uk">body</a>'
created_at '2005-01-01 02:00:00'
updated_at '2005-01-01 02:00:00'
published_at '2005-01-01 02:00:00'
guid
state 'ham'
end
factory :spam_comment, :parent => :comment do |c|
c.state 'spam'
c.published false
end
factory :ham_comment, :parent => :comment do |c|
c.state 'ham'
c.published false
end
factory :page do
name {FactoryGirl.generate(:name)}
title 'Page One Title'
body {FactoryGirl.generate(:body)}
created_at '2005-05-05 01:00:01'
published_at '2005-05-05 01:00:01'
updated_at '2005-05-05 01:00:01'
user
published true
state 'published'
end
factory :note do
body 'this is a note'
created_at '2013-07-14 01:00:01'
published_at '2013-07-14 01:00:01'
updated_at '2013-07-14 01:00:01'
user
published true
state 'published'
text_filter {FactoryGirl.create(:markdown)}
guid
end
factory :unpublished_note, :parent => :note do |n|
n.published false
end
factory :trackback do |t|
published true
state 'ham'
article
status_confirmed true
blog_name 'Trackback Blog'
title 'Trackback Entry'
url 'http://www.example.com'
excerpt 'This is an excerpt'
guid 'dsafsadffsdsf'
created_at Time.now
updated_at Time.now
end
end