typus 3.0.11 → 3.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/app/helpers/admin/relationships_helper.rb +2 -2
- data/app/views/admin/dashboard/_applications.html.erb +1 -1
- data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +2 -2
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/app/views/admin/templates/_has_one.html.erb +1 -1
- data/config/locales/typus.ca.yml +1 -1
- data/config/locales/typus.de.models.yml +6 -5
- data/config/locales/typus.de.yml +39 -36
- data/config/locales/typus.el.yml +1 -1
- data/config/locales/typus.es.yml +1 -1
- data/config/locales/typus.fr.yml +1 -1
- data/config/locales/typus.hu.yml +1 -1
- data/config/locales/typus.locale.yml.template +1 -1
- data/config/locales/typus.pt-BR.yml +1 -1
- data/config/locales/typus.pt-PT.yml +1 -1
- data/config/locales/typus.ru.yml +1 -1
- data/config/locales/typus.zh-CN.yml +1 -1
- data/lib/typus/version.rb +1 -1
- data/typus.gemspec +7 -4
- metadata +16 -164
- data/test/app/controllers/admin/account_controller_test.rb +0 -106
- data/test/app/controllers/admin/assets_controller_test.rb +0 -156
- data/test/app/controllers/admin/base_controller_test.rb +0 -41
- data/test/app/controllers/admin/birds_controller_test.rb +0 -42
- data/test/app/controllers/admin/cases_controller_test.rb +0 -21
- data/test/app/controllers/admin/categories_controller_test.rb +0 -134
- data/test/app/controllers/admin/comments_controller_test.rb +0 -79
- data/test/app/controllers/admin/dashboard_controller_test.rb +0 -162
- data/test/app/controllers/admin/image_holders_controller_test.rb +0 -75
- data/test/app/controllers/admin/invoices_controller_test.rb +0 -78
- data/test/app/controllers/admin/orders_controller_test.rb +0 -18
- data/test/app/controllers/admin/pages_controller_test.rb +0 -37
- data/test/app/controllers/admin/posts_controller_test.rb +0 -770
- data/test/app/controllers/admin/projects_controller_test.rb +0 -52
- data/test/app/controllers/admin/session_controller_test.rb +0 -92
- data/test/app/controllers/admin/status_controller_test.rb +0 -54
- data/test/app/controllers/admin/typus_users_controller_test.rb +0 -156
- data/test/app/controllers/admin/users_controller_test.rb +0 -106
- data/test/app/controllers/admin/views_controller_test.rb +0 -36
- data/test/app/helpers/admin/base_helper_test.rb +0 -83
- data/test/app/helpers/admin/dashboard_helper_test.rb +0 -32
- data/test/app/helpers/admin/file_preview_helper_test.rb +0 -90
- data/test/app/helpers/admin/filters_helper_test.rb +0 -166
- data/test/app/helpers/admin/form_helper_test.rb +0 -126
- data/test/app/helpers/admin/list_helper_test.rb +0 -76
- data/test/app/helpers/admin/relationships_helper_test.rb +0 -19
- data/test/app/helpers/admin/resources_helper_test.rb +0 -46
- data/test/app/helpers/admin/search_helper_test.rb +0 -60
- data/test/app/helpers/admin/sidebar_helper_test.rb +0 -34
- data/test/app/helpers/admin/table_helper_test.rb +0 -241
- data/test/app/mailers/admin/mailer_test.rb +0 -32
- data/test/app/models/admin_user_test.rb +0 -5
- data/test/app/models/typus_user_roles_test.rb +0 -125
- data/test/app/models/typus_user_test.rb +0 -228
- data/test/config/routes_test.rb +0 -29
- data/test/factories.rb +0 -122
- data/test/fixtures/config/broken/application.yml +0 -68
- data/test/fixtures/config/broken/application_roles.yml +0 -20
- data/test/fixtures/config/broken/empty.yml +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/fixtures/config/broken/undefined.yml +0 -3
- data/test/fixtures/config/broken/undefined_roles.yml +0 -6
- data/test/fixtures/config/default/typus.yml +0 -13
- data/test/fixtures/config/default/typus_roles.yml +0 -2
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/fixtures/config/locales/es.yml +0 -10
- data/test/fixtures/config/namespaced/application.yml +0 -5
- data/test/fixtures/config/namespaced/application_roles.yml +0 -2
- data/test/fixtures/config/ordered/001_roles.yml +0 -2
- data/test/fixtures/config/ordered/002_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
- data/test/lib/support/active_record_test.rb +0 -174
- data/test/lib/support/fake_user_test.rb +0 -63
- data/test/lib/support/hash_test.rb +0 -29
- data/test/lib/support/object_test.rb +0 -17
- data/test/lib/support/string_test.rb +0 -98
- data/test/lib/typus/configuration_test.rb +0 -46
- data/test/lib/typus/controller/actions_test.rb +0 -141
- data/test/lib/typus/controller/associations_test.rb +0 -7
- data/test/lib/typus/controller/autocomplete_test.rb +0 -7
- data/test/lib/typus/controller/filters_test.rb +0 -73
- data/test/lib/typus/controller/format_test.rb +0 -7
- data/test/lib/typus/i18n_test.rb +0 -9
- data/test/lib/typus/orm/active_record/class_methods_test.rb +0 -390
- data/test/lib/typus/orm/active_record/search_test.rb +0 -330
- data/test/lib/typus/regex_test.rb +0 -53
- data/test/lib/typus/resources_test.rb +0 -41
- data/test/lib/typus_test.rb +0 -142
- data/test/test_helper.rb +0 -15
@@ -1,330 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ActiveRecordTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
context "build_search_conditions" do
|
6
|
-
|
7
|
-
should "work for Post (title)" do
|
8
|
-
output = Post.build_search_conditions("search", "bacon")
|
9
|
-
|
10
|
-
expected = case ENV["DB"]
|
11
|
-
when "postgresql"
|
12
|
-
"LOWER(TEXT(posts.title)) LIKE '%bacon%'"
|
13
|
-
else
|
14
|
-
"posts.title LIKE '%bacon%'"
|
15
|
-
end
|
16
|
-
|
17
|
-
assert_equal expected, output
|
18
|
-
end
|
19
|
-
|
20
|
-
should "work for Comment (email, body)" do
|
21
|
-
output = Comment.build_search_conditions("search", "bacon")
|
22
|
-
|
23
|
-
expected = case ENV["DB"]
|
24
|
-
when "postgresql"
|
25
|
-
["LOWER(TEXT(comments.body)) LIKE '%bacon%'",
|
26
|
-
"LOWER(TEXT(comments.email)) LIKE '%bacon%'"]
|
27
|
-
else
|
28
|
-
["comments.body LIKE '%bacon%'",
|
29
|
-
"comments.email LIKE '%bacon%'"]
|
30
|
-
end
|
31
|
-
|
32
|
-
expected.each { |e| assert_match e, output }
|
33
|
-
assert_match /OR/, output
|
34
|
-
end
|
35
|
-
|
36
|
-
should "generate conditions for id" do
|
37
|
-
Post.expects(:typus_defaults_for).with(:search).returns(["id"])
|
38
|
-
|
39
|
-
expected = case ENV["DB"]
|
40
|
-
when "postgresql"
|
41
|
-
"LOWER(TEXT(posts.id)) LIKE '%1%'"
|
42
|
-
else
|
43
|
-
"posts.id LIKE '%1%'"
|
44
|
-
end
|
45
|
-
output = Post.build_search_conditions("search", "1")
|
46
|
-
|
47
|
-
assert_equal expected, output
|
48
|
-
end
|
49
|
-
|
50
|
-
should "generate conditions for fields starting with equal" do
|
51
|
-
Post.expects(:typus_defaults_for).with(:search).returns(["=id"])
|
52
|
-
|
53
|
-
expected = case ENV["DB"]
|
54
|
-
when "postgresql"
|
55
|
-
"LOWER(TEXT(posts.id)) LIKE '1'"
|
56
|
-
else
|
57
|
-
"posts.id LIKE '1'"
|
58
|
-
end
|
59
|
-
output = Post.build_search_conditions("search", "1")
|
60
|
-
|
61
|
-
assert_equal expected, output
|
62
|
-
end
|
63
|
-
|
64
|
-
should "generate conditions for fields starting with ^" do
|
65
|
-
Post.expects(:typus_defaults_for).with(:search).returns(["^id"])
|
66
|
-
|
67
|
-
expected = case ENV["DB"]
|
68
|
-
when "postgresql"
|
69
|
-
"LOWER(TEXT(posts.id)) LIKE '1%'"
|
70
|
-
else
|
71
|
-
"posts.id LIKE '1%'"
|
72
|
-
end
|
73
|
-
output = Post.build_search_conditions("search", "1")
|
74
|
-
|
75
|
-
assert_equal expected, output
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
context "build_boolean_conditions" do
|
81
|
-
|
82
|
-
should "return true" do
|
83
|
-
expected = {'status'=>true}
|
84
|
-
output = Page.build_boolean_conditions('status', 'true')
|
85
|
-
assert_equal expected, output
|
86
|
-
end
|
87
|
-
|
88
|
-
should "return false" do
|
89
|
-
expected = {'status'=>false}
|
90
|
-
output = Page.build_boolean_conditions('status', 'false')
|
91
|
-
assert_equal expected, output
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
context "build_datetime_conditions" do
|
97
|
-
|
98
|
-
setup do
|
99
|
-
@tomorrow = Time.zone.now.beginning_of_day.tomorrow.to_s(:db)
|
100
|
-
end
|
101
|
-
|
102
|
-
[["today", 0.days.ago.beginning_of_day.to_s(:db)],
|
103
|
-
["last_few_days", 3.days.ago.beginning_of_day.to_s(:db)],
|
104
|
-
["last_7_days", 6.days.ago.beginning_of_day.to_s(:db)],
|
105
|
-
["last_30_days", 30.days.ago.beginning_of_day.to_s(:db)]].each do |interval|
|
106
|
-
|
107
|
-
should "generate the condition for #{interval.first}" do
|
108
|
-
output = Article.build_datetime_conditions('created_at', interval.first).first
|
109
|
-
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
110
|
-
end
|
111
|
-
|
112
|
-
should "work for #{interval.first}" do
|
113
|
-
expected = [interval.last, @tomorrow]
|
114
|
-
output = Article.build_datetime_conditions('created_at', interval.first)[1..-1]
|
115
|
-
assert_equal expected, output
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
context "build_date_conditions" do
|
123
|
-
|
124
|
-
setup do
|
125
|
-
@tomorrow = Date.tomorrow.to_s(:db)
|
126
|
-
end
|
127
|
-
|
128
|
-
should "generate the condition for today (which is an special case)" do
|
129
|
-
output = Article.build_date_conditions('created_at', "today").first
|
130
|
-
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
131
|
-
end
|
132
|
-
|
133
|
-
should "work for today (which is an special case)" do
|
134
|
-
expected = [0.days.ago.to_date.to_s(:db), 0.days.ago.tomorrow.to_date.to_s(:db)]
|
135
|
-
output = Article.build_date_conditions('created_at', "today")[1..-1]
|
136
|
-
assert_equal expected, output
|
137
|
-
end
|
138
|
-
|
139
|
-
[["last_few_days", 3.days.ago.to_date.to_s(:db)],
|
140
|
-
["last_7_days", 6.days.ago.to_date.to_s(:db)],
|
141
|
-
["last_30_days", 30.days.ago.to_date.to_s(:db)]].each do |interval|
|
142
|
-
|
143
|
-
should "generate the condition for #{interval.first}" do
|
144
|
-
output = Article.build_date_conditions('created_at', interval.first).first
|
145
|
-
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
146
|
-
end
|
147
|
-
|
148
|
-
should "work for #{interval.first}" do
|
149
|
-
expected = [interval.last, @tomorrow]
|
150
|
-
output = Article.build_date_conditions('created_at', interval.first)[1..-1]
|
151
|
-
assert_equal expected, output
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
context "build_string_conditions" do
|
159
|
-
|
160
|
-
should "work" do
|
161
|
-
expected = {'test'=>'true'}
|
162
|
-
output = Page.build_string_conditions('test', 'true')
|
163
|
-
assert_equal expected, output
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
context "build_has_many_conditions" do
|
169
|
-
|
170
|
-
should "work" do
|
171
|
-
expected = ["projects.id = ?", "1"]
|
172
|
-
output = User.build_has_many_conditions('projects', '1')
|
173
|
-
assert_equal expected, output
|
174
|
-
end
|
175
|
-
|
176
|
-
should_eventually "work for non standard primary keys"
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
context "build_conditions" do
|
181
|
-
|
182
|
-
should "return an array" do
|
183
|
-
params = { :search => '1' }
|
184
|
-
assert Post.build_conditions(params).is_a?(Array)
|
185
|
-
end
|
186
|
-
|
187
|
-
should "return_sql_conditions_on_search_for_typus_user" do
|
188
|
-
expected = case ENV["DB"]
|
189
|
-
when "postgresql"
|
190
|
-
["LOWER(TEXT(typus_users.first_name)) LIKE '%francesc%'",
|
191
|
-
"LOWER(TEXT(typus_users.last_name)) LIKE '%francesc%'",
|
192
|
-
"LOWER(TEXT(typus_users.email)) LIKE '%francesc%'",
|
193
|
-
"LOWER(TEXT(typus_users.role)) LIKE '%francesc%'"]
|
194
|
-
else
|
195
|
-
["typus_users.first_name LIKE '%francesc%'",
|
196
|
-
"typus_users.last_name LIKE '%francesc%'",
|
197
|
-
"typus_users.email LIKE '%francesc%'",
|
198
|
-
"typus_users.role LIKE '%francesc%'"]
|
199
|
-
end
|
200
|
-
|
201
|
-
[{:search =>"francesc"}, {:search => "Francesc"}].each do |params|
|
202
|
-
expected.each do |expect|
|
203
|
-
assert_match expect, TypusUser.build_conditions(params).first
|
204
|
-
end
|
205
|
-
assert_no_match /AND/, TypusUser.build_conditions(params).first
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
should "return_sql_conditions_on_search_and_filter_for_typus_user" do
|
210
|
-
expected = case ENV["DB"]
|
211
|
-
when "postgresql"
|
212
|
-
["LOWER(TEXT(typus_users.role)) LIKE '%francesc%'",
|
213
|
-
"LOWER(TEXT(typus_users.last_name)) LIKE '%francesc%'",
|
214
|
-
"LOWER(TEXT(typus_users.email)) LIKE '%francesc%'",
|
215
|
-
"LOWER(TEXT(typus_users.first_name)) LIKE '%francesc%'"]
|
216
|
-
else
|
217
|
-
["typus_users.first_name LIKE '%francesc%'",
|
218
|
-
"typus_users.last_name LIKE '%francesc%'",
|
219
|
-
"typus_users.email LIKE '%francesc%'",
|
220
|
-
"typus_users.role LIKE '%francesc%'"]
|
221
|
-
end
|
222
|
-
|
223
|
-
params = { :search => "francesc", :status => "true" }
|
224
|
-
|
225
|
-
Factory(:typus_user, :email => "francesc.one@example.com")
|
226
|
-
Factory(:typus_user, :email => "francesc.dos@example.com", :status => false)
|
227
|
-
|
228
|
-
resource = TypusUser
|
229
|
-
resource.build_conditions(params).each do |condition|
|
230
|
-
resource = resource.where(condition)
|
231
|
-
end
|
232
|
-
|
233
|
-
assert_equal 1, resource.count
|
234
|
-
assert_equal ["francesc.one@example.com"], resource.map(&:email)
|
235
|
-
end
|
236
|
-
|
237
|
-
should "return_sql_conditions_on_filtering_typus_users_by_status true" do
|
238
|
-
params = { :status => "true" }
|
239
|
-
expected = { :status => true }
|
240
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
241
|
-
end
|
242
|
-
|
243
|
-
should "return_sql_conditions_on_filtering_typus_users_by_status false" do
|
244
|
-
params = { :status => "false" }
|
245
|
-
expected = { :status => false }
|
246
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
247
|
-
end
|
248
|
-
|
249
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at today" do
|
250
|
-
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
251
|
-
Time.zone.now.beginning_of_day.to_s(:db),
|
252
|
-
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
253
|
-
params = { :created_at => "today" }
|
254
|
-
|
255
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
256
|
-
end
|
257
|
-
|
258
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_few_days" do
|
259
|
-
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
260
|
-
3.days.ago.beginning_of_day.to_s(:db),
|
261
|
-
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
262
|
-
params = { :created_at => "last_few_days" }
|
263
|
-
|
264
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
265
|
-
end
|
266
|
-
|
267
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_7_days" do
|
268
|
-
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
269
|
-
6.days.ago.beginning_of_day.to_s(:db),
|
270
|
-
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
271
|
-
params = { :created_at => "last_7_days" }
|
272
|
-
|
273
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
274
|
-
end
|
275
|
-
|
276
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_30_days" do
|
277
|
-
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
278
|
-
30.days.ago.beginning_of_day.to_s(:db),
|
279
|
-
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
280
|
-
params = { :created_at => "last_30_days" }
|
281
|
-
|
282
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
283
|
-
end
|
284
|
-
|
285
|
-
should "return_sql_conditions_on_filtering_posts_by_published_at today" do
|
286
|
-
expected = ["posts.published_at BETWEEN ? AND ?",
|
287
|
-
Time.zone.now.beginning_of_day.to_s(:db),
|
288
|
-
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
289
|
-
params = { :published_at => "today" }
|
290
|
-
|
291
|
-
assert_equal expected, Post.build_conditions(params).first
|
292
|
-
end
|
293
|
-
|
294
|
-
should "return_sql_conditions_on_filtering_posts_by_string" do
|
295
|
-
params = { :role => "admin" }
|
296
|
-
assert_equal params, TypusUser.build_conditions(params).first
|
297
|
-
end
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
context "build_joins" do
|
302
|
-
|
303
|
-
setup do
|
304
|
-
@project = Factory(:project)
|
305
|
-
2.times { Factory(:project) }
|
306
|
-
end
|
307
|
-
|
308
|
-
should "return the expected joins" do
|
309
|
-
params = { :projects => @project.id }
|
310
|
-
assert_equal [:projects], User.build_joins(params)
|
311
|
-
end
|
312
|
-
|
313
|
-
##
|
314
|
-
# Get all user which are on project 1
|
315
|
-
#
|
316
|
-
|
317
|
-
should "work when users are filtered by projects" do
|
318
|
-
params = { :projects => @project.id }
|
319
|
-
|
320
|
-
@resource = User
|
321
|
-
@resource.build_conditions(params).each { |c| @resource = @resource.where(c) }
|
322
|
-
@resource.build_joins(params).each { |j| @resource = @resource.joins(j) }
|
323
|
-
|
324
|
-
assert_equal 1, @resource.count
|
325
|
-
assert_equal [@project.user.id], @resource.map(&:id)
|
326
|
-
end
|
327
|
-
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class RegexTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
context "email_regex" do
|
6
|
-
|
7
|
-
should "match valid emails" do
|
8
|
-
["john@example.com",
|
9
|
-
"john+locke@example.com",
|
10
|
-
"john.locke@example.com",
|
11
|
-
"john.locke@example.us"].each do |value|
|
12
|
-
assert_match Typus::Regex::Email, value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
should "not match invalid emails" do
|
17
|
-
[%Q(this_is_chelm@example.com\n<script>location.href="http://spammersite.com"</script>),
|
18
|
-
"admin",
|
19
|
-
"TEST@EXAMPLE.COM",
|
20
|
-
"test@example",
|
21
|
-
"test@example.c",
|
22
|
-
"testexample.com"].each do |value|
|
23
|
-
assert_no_match Typus::Regex::Email, value
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
context "uri_regex" do
|
30
|
-
|
31
|
-
should "match valid urls" do
|
32
|
-
["http://example.com",
|
33
|
-
"http://www.example.com",
|
34
|
-
"http://www.example.es",
|
35
|
-
"http://www.example.co.uk",
|
36
|
-
"http://four.sentenc.es",
|
37
|
-
"http://www.ex-ample.com"].each do |value|
|
38
|
-
assert_match Typus::Regex::Url, value
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
should "not match invalid urls" do
|
43
|
-
[%Q(this_is_chelm@example.com\n<script>location.href="http://spammersite.com"</script>),
|
44
|
-
"example.com",
|
45
|
-
"http://examplecom",
|
46
|
-
"http://ex+ample.com"].each do |value|
|
47
|
-
assert_no_match Typus::Regex::Url, value
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ResourcesTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
should "return action_after_save" do
|
6
|
-
assert_equal "edit", Typus::Resources.action_after_save
|
7
|
-
end
|
8
|
-
|
9
|
-
should "return default_action_on_item" do
|
10
|
-
assert_equal "edit", Typus::Resources.default_action_on_item
|
11
|
-
end
|
12
|
-
|
13
|
-
should "return end_year" do
|
14
|
-
assert_nil Typus::Resources.end_year
|
15
|
-
end
|
16
|
-
|
17
|
-
should "return form_rows" do
|
18
|
-
assert_equal 15, Typus::Resources.form_rows
|
19
|
-
end
|
20
|
-
|
21
|
-
should "return minute_step" do
|
22
|
-
assert_equal 5, Typus::Resources.minute_step
|
23
|
-
end
|
24
|
-
|
25
|
-
should "return only_user_items" do
|
26
|
-
assert !Typus::Resources.only_user_items
|
27
|
-
end
|
28
|
-
|
29
|
-
should "return per_page" do
|
30
|
-
assert_equal 15, Typus::Resources.per_page
|
31
|
-
end
|
32
|
-
|
33
|
-
should "return sortable" do
|
34
|
-
assert Typus::Resources.sortable
|
35
|
-
end
|
36
|
-
|
37
|
-
should "return start_year" do
|
38
|
-
assert_nil Typus::Resources.start_year
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/test/lib/typus_test.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TypusTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
should "verify default_config for autocomplete" do
|
6
|
-
assert Typus.autocomplete.nil?
|
7
|
-
end
|
8
|
-
|
9
|
-
should "verify default_config for admin_title" do
|
10
|
-
assert_equal "Typus", Typus.admin_title
|
11
|
-
end
|
12
|
-
|
13
|
-
should "verify default_config for admin_sub_title" do
|
14
|
-
assert Typus.admin_sub_title.is_a?(String)
|
15
|
-
end
|
16
|
-
|
17
|
-
should "verify default_config for authentication" do
|
18
|
-
assert_equal :session, Typus.authentication
|
19
|
-
end
|
20
|
-
|
21
|
-
should "verify default_config for mailer_sender" do
|
22
|
-
assert_nil Typus.mailer_sender
|
23
|
-
end
|
24
|
-
|
25
|
-
should "verify default_config for username" do
|
26
|
-
assert_equal "admin", Typus.username
|
27
|
-
end
|
28
|
-
|
29
|
-
should "verify default_config for password" do
|
30
|
-
assert_equal "columbia", Typus.password
|
31
|
-
end
|
32
|
-
|
33
|
-
context "file management" do
|
34
|
-
|
35
|
-
context "paperclip" do
|
36
|
-
|
37
|
-
should "verify default_config for file_preview" do
|
38
|
-
assert_equal :medium, Typus.file_preview
|
39
|
-
end
|
40
|
-
|
41
|
-
should "verify default_config for file_thumbnail" do
|
42
|
-
assert_equal :thumb, Typus.file_thumbnail
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
context "dragonfly" do
|
48
|
-
|
49
|
-
should "verify default_config for image_preview_size" do
|
50
|
-
assert_equal "x450", Typus.image_preview_size
|
51
|
-
end
|
52
|
-
|
53
|
-
should "verify default_config for image_thumb_size" do
|
54
|
-
assert_equal "150x150#", Typus.image_thumb_size
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
should "verify default_config for relationship" do
|
62
|
-
assert_equal "typus_users", Typus.relationship
|
63
|
-
end
|
64
|
-
|
65
|
-
should "verify default_config for master_role" do
|
66
|
-
assert_equal "admin", Typus.master_role
|
67
|
-
end
|
68
|
-
|
69
|
-
should "verify config_folder is a Pathname" do
|
70
|
-
assert Typus.config_folder.is_a?(Pathname)
|
71
|
-
end
|
72
|
-
|
73
|
-
should "return applications sorted" do
|
74
|
-
expected = ["Admin", "CRUD", "CRUD Extended", "HasManyThrough", "HasOne", "MongoDB", "Polymorphic", "STI"]
|
75
|
-
assert_equal expected, Typus.applications
|
76
|
-
end
|
77
|
-
|
78
|
-
should "return modules of the CRUD Extended application" do
|
79
|
-
expected = ["Asset", "Category", "Comment", "Page", "Post"]
|
80
|
-
assert_equal expected, Typus.application("CRUD Extended")
|
81
|
-
end
|
82
|
-
|
83
|
-
should "return models and should be sorted" do
|
84
|
-
expected = ["Animal",
|
85
|
-
"Asset",
|
86
|
-
"Bird",
|
87
|
-
"Case",
|
88
|
-
"Category",
|
89
|
-
"Comment",
|
90
|
-
"Dog",
|
91
|
-
"Entry",
|
92
|
-
"Hit",
|
93
|
-
"ImageHolder",
|
94
|
-
"Invoice",
|
95
|
-
"Order",
|
96
|
-
"Page",
|
97
|
-
"Post",
|
98
|
-
"Project",
|
99
|
-
"ProjectCollaborator",
|
100
|
-
"TypusUser",
|
101
|
-
"User",
|
102
|
-
"View"]
|
103
|
-
assert_equal expected, Typus.models
|
104
|
-
end
|
105
|
-
|
106
|
-
should "verify resources class_method" do
|
107
|
-
assert_equal %w(Git Status WatchDog), Typus.resources
|
108
|
-
end
|
109
|
-
|
110
|
-
context "user_class" do
|
111
|
-
|
112
|
-
should "return default value" do
|
113
|
-
assert_equal TypusUser, Typus.user_class
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
context "user_class_name" do
|
119
|
-
|
120
|
-
should "return default value" do
|
121
|
-
assert_equal "TypusUser", Typus.user_class_name
|
122
|
-
end
|
123
|
-
|
124
|
-
should "be overrided on demand" do
|
125
|
-
assert Typus.respond_to?("user_class_name=")
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
context "user_fk" do
|
131
|
-
|
132
|
-
should "return default value" do
|
133
|
-
assert_equal "typus_user_id", Typus.user_fk
|
134
|
-
end
|
135
|
-
|
136
|
-
should "be overrided on demand" do
|
137
|
-
assert Typus.respond_to?("user_fk=")
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|