rails_admin 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. data/Gemfile +18 -20
  2. data/README.md +8 -1
  3. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +5 -4
  4. data/app/assets/stylesheets/rails_admin/base/theming.css.scss +4 -4
  5. data/app/controllers/rails_admin/main_controller.rb +11 -2
  6. data/app/helpers/rails_admin/application_helper.rb +1 -1
  7. data/app/helpers/rails_admin/form_builder.rb +3 -3
  8. data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +4 -4
  9. data/app/views/rails_admin/main/_form_filtering_select.html.haml +2 -2
  10. data/app/views/rails_admin/main/_form_nested_one.html.haml +1 -1
  11. data/app/views/rails_admin/main/_form_text.html.haml +2 -1
  12. data/app/views/rails_admin/main/export.html.haml +2 -2
  13. data/app/views/rails_admin/main/index.html.haml +5 -5
  14. data/app/views/rails_admin/main/show.html.haml +1 -1
  15. data/lib/generators/rails_admin/templates/initializer.erb +5 -5
  16. data/lib/rails_admin/abstract_model.rb +1 -0
  17. data/lib/rails_admin/config.rb +1 -1
  18. data/lib/rails_admin/config/actions/base.rb +1 -1
  19. data/lib/rails_admin/config/actions/edit.rb +5 -4
  20. data/lib/rails_admin/config/actions/new.rb +5 -4
  21. data/lib/rails_admin/config/fields/association.rb +10 -10
  22. data/lib/rails_admin/config/fields/base.rb +10 -4
  23. data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
  24. data/lib/rails_admin/config/fields/types/boolean.rb +4 -4
  25. data/lib/rails_admin/config/fields/types/bson_object_id.rb +4 -4
  26. data/lib/rails_admin/config/fields/types/carrierwave.rb +3 -3
  27. data/lib/rails_admin/config/fields/types/datetime.rb +5 -5
  28. data/lib/rails_admin/config/fields/types/enum.rb +5 -5
  29. data/lib/rails_admin/config/fields/types/file_upload.rb +10 -6
  30. data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -1
  31. data/lib/rails_admin/config/fields/types/has_one_association.rb +3 -3
  32. data/lib/rails_admin/config/fields/types/integer.rb +1 -1
  33. data/lib/rails_admin/config/fields/types/paperclip.rb +2 -2
  34. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +8 -4
  35. data/lib/rails_admin/config/fields/types/serialized.rb +2 -2
  36. data/lib/rails_admin/config/fields/types/string.rb +3 -3
  37. data/lib/rails_admin/config/fields/types/text.rb +22 -15
  38. data/lib/rails_admin/config/fields/types/time.rb +1 -1
  39. data/lib/rails_admin/config/hideable.rb +1 -1
  40. data/lib/rails_admin/config/model.rb +4 -0
  41. data/lib/rails_admin/config/sections/modal.rb +1 -1
  42. data/lib/rails_admin/engine.rb +1 -1
  43. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -1
  44. data/lib/rails_admin/support/csv_converter.rb +1 -1
  45. data/lib/rails_admin/version.rb +2 -2
  46. data/lib/rails_admin/version.rbc +582 -0
  47. data/lib/tasks/rails_admin.rake +2 -2
  48. data/spec/controllers/main_controller_spec.rb +113 -45
  49. data/spec/dummy_app/Gemfile +11 -25
  50. data/spec/dummy_app/Gemfile.lock +214 -0
  51. data/spec/dummy_app/app/active_record/comment.rb +1 -1
  52. data/spec/dummy_app/app/active_record/field_test.rb +0 -1
  53. data/spec/dummy_app/config/initializers/strong_parameters.rb +2 -0
  54. data/spec/dummy_app/db/test.sqlite3 +0 -0
  55. data/spec/dummy_app/log/test.log +97612 -0
  56. data/spec/helpers/application_helper_spec.rb +24 -24
  57. data/spec/helpers/form_builder_spec.rb +4 -4
  58. data/spec/integration/authorization/cancan_spec.rb +3 -3
  59. data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +2 -2
  60. data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +2 -2
  61. data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +9 -9
  62. data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -1
  63. data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +4 -4
  64. data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +9 -9
  65. data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +10 -10
  66. data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +5 -5
  67. data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +32 -25
  68. data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +8 -8
  69. data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +3 -3
  70. data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +6 -6
  71. data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +13 -13
  72. data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +97 -76
  73. data/spec/integration/config/list/rails_admin_config_list_spec.rb +32 -32
  74. data/spec/integration/config/show/rails_admin_config_show_spec.rb +23 -23
  75. data/spec/integration/history/rails_admin_history_spec.rb +6 -6
  76. data/spec/integration/rails_admin_spec.rb +17 -17
  77. data/spec/integration/relation_spec.rb +7 -7
  78. data/spec/unit/abstract_model_spec.rb +11 -5
  79. data/spec/unit/active_record_extension_spec.rb +2 -2
  80. data/spec/unit/adapters/active_record/abstract_object_spec.rb +8 -8
  81. data/spec/unit/adapters/active_record_spec.rb +6 -6
  82. data/spec/unit/adapters/mongoid/abstract_object_spec.rb +1 -1
  83. data/spec/unit/adapters/mongoid_spec.rb +12 -12
  84. data/spec/unit/config/actions/base_spec.rb +2 -2
  85. data/spec/unit/config/actions_spec.rb +16 -16
  86. data/spec/unit/config/fields/base_spec.rb +61 -49
  87. data/spec/unit/config/fields/date_spec.rb +4 -4
  88. data/spec/unit/config/fields/datetime_spec.rb +4 -4
  89. data/spec/unit/config/fields/file_upload_spec.rb +21 -0
  90. data/spec/unit/config/fields/time_spec.rb +3 -3
  91. data/spec/unit/config/fields/timestamp_spec.rb +1 -1
  92. data/spec/unit/config/model_spec.rb +10 -10
  93. data/spec/unit/config/sections_spec.rb +4 -4
  94. data/spec/unit/config_spec.rb +9 -9
  95. metadata +17 -218
@@ -26,7 +26,7 @@ module RailsAdmin
26
26
  ::DateTime.parse(date_string)
27
27
  end
28
28
 
29
- register_instance_option(:strftime_format) do
29
+ register_instance_option :strftime_format do
30
30
  (localized_format.include? "%p") ? "%I:%M %p" : "%H:%M"
31
31
  end
32
32
  end
@@ -4,7 +4,7 @@ module RailsAdmin
4
4
  module Hideable
5
5
  # Visibility defaults to true.
6
6
  def self.included(klass)
7
- klass.register_instance_option(:visible?) do
7
+ klass.register_instance_option :visible? do
8
8
  !root.try :excluded?
9
9
  end
10
10
  end
@@ -63,6 +63,10 @@ module RailsAdmin
63
63
  (@label_plural ||= {})[::I18n.locale] ||= abstract_model.model.model_name.human(:count => 2, :default => label.pluralize)
64
64
  end
65
65
 
66
+ def pluralize(count)
67
+ count == 1 ? label : label_plural
68
+ end
69
+
66
70
  register_instance_option :weight do
67
71
  0
68
72
  end
@@ -7,4 +7,4 @@ module RailsAdmin
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -19,7 +19,7 @@ module RailsAdmin
19
19
  initializer "RailsAdmin pjax hook" do |app|
20
20
  app.config.middleware.use Rack::Pjax
21
21
  end
22
-
22
+
23
23
  rake_tasks do
24
24
  Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
25
25
  end
@@ -8,7 +8,8 @@ module RailsAdmin
8
8
  end
9
9
 
10
10
  def message
11
- "#{@version.event} #{@version.item_type} id #{@version.item_id}"
11
+ @message = "#{@version.event} #{@version.item_type} ID #{@version.item_id}"
12
+ @version.respond_to?(:changeset) ? @message + " [" + @version.changeset.to_a.collect {|c| c[0] + " = " + c[1][1].to_s}.join(", ") + "]" : @message
12
13
  end
13
14
 
14
15
  def created_at
@@ -15,7 +15,7 @@ module RailsAdmin
15
15
  @abstract_model = RailsAdmin::AbstractModel.new(@model)
16
16
  @model_config = @abstract_model.config
17
17
  @methods = [(schema[:only] || []) + (schema[:methods] || [])].flatten.compact
18
- @fields = @methods.map {|m| @model_config.export.fields.find {|f| f.name == m} }
18
+ @fields = @methods.map {|m| @model_config.export.fields.find {|f| f.name == m} }
19
19
  @empty = ::I18n.t('admin.export.empty_value_for_associated_objects')
20
20
  @associations = {}
21
21
 
@@ -1,8 +1,8 @@
1
1
  module RailsAdmin
2
2
  class Version
3
3
  MAJOR = 0 unless defined? MAJOR
4
- MINOR = 1 unless defined? MINOR
5
- PATCH = 2 unless defined? PATCH
4
+ MINOR = 2 unless defined? MINOR
5
+ PATCH = 0 unless defined? PATCH
6
6
  PRE = nil unless defined? PRE
7
7
 
8
8
  class << self
@@ -0,0 +1,582 @@
1
+ !RBIX
2
+ 9595534255132031488
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 28
13
+ 99
14
+ 7
15
+ 0
16
+ 65
17
+ 49
18
+ 1
19
+ 2
20
+ 13
21
+ 99
22
+ 12
23
+ 7
24
+ 2
25
+ 12
26
+ 7
27
+ 3
28
+ 12
29
+ 65
30
+ 12
31
+ 49
32
+ 4
33
+ 4
34
+ 15
35
+ 49
36
+ 2
37
+ 0
38
+ 15
39
+ 2
40
+ 11
41
+ I
42
+ 6
43
+ I
44
+ 0
45
+ I
46
+ 0
47
+ I
48
+ 0
49
+ n
50
+ p
51
+ 5
52
+ x
53
+ 10
54
+ RailsAdmin
55
+ x
56
+ 11
57
+ open_module
58
+ x
59
+ 15
60
+ __module_init__
61
+ M
62
+ 1
63
+ n
64
+ n
65
+ x
66
+ 10
67
+ RailsAdmin
68
+ i
69
+ 29
70
+ 5
71
+ 66
72
+ 99
73
+ 7
74
+ 0
75
+ 1
76
+ 65
77
+ 49
78
+ 1
79
+ 3
80
+ 13
81
+ 99
82
+ 12
83
+ 7
84
+ 2
85
+ 12
86
+ 7
87
+ 3
88
+ 12
89
+ 65
90
+ 12
91
+ 49
92
+ 4
93
+ 4
94
+ 15
95
+ 49
96
+ 2
97
+ 0
98
+ 11
99
+ I
100
+ 6
101
+ I
102
+ 0
103
+ I
104
+ 0
105
+ I
106
+ 0
107
+ n
108
+ p
109
+ 5
110
+ x
111
+ 7
112
+ Version
113
+ x
114
+ 10
115
+ open_class
116
+ x
117
+ 14
118
+ __class_init__
119
+ M
120
+ 1
121
+ n
122
+ n
123
+ x
124
+ 7
125
+ Version
126
+ i
127
+ 190
128
+ 5
129
+ 66
130
+ 26
131
+ 93
132
+ 0
133
+ 15
134
+ 29
135
+ 17
136
+ 0
137
+ 7
138
+ 0
139
+ 98
140
+ 1
141
+ 1
142
+ 30
143
+ 8
144
+ 23
145
+ 25
146
+ 92
147
+ 0
148
+ 27
149
+ 8
150
+ 28
151
+ 15
152
+ 7
153
+ 2
154
+ 8
155
+ 29
156
+ 1
157
+ 9
158
+ 34
159
+ 1
160
+ 8
161
+ 41
162
+ 65
163
+ 7
164
+ 0
165
+ 78
166
+ 49
167
+ 3
168
+ 2
169
+ 15
170
+ 26
171
+ 93
172
+ 1
173
+ 15
174
+ 29
175
+ 57
176
+ 0
177
+ 7
178
+ 4
179
+ 98
180
+ 1
181
+ 1
182
+ 30
183
+ 8
184
+ 63
185
+ 25
186
+ 92
187
+ 1
188
+ 27
189
+ 8
190
+ 68
191
+ 15
192
+ 7
193
+ 2
194
+ 8
195
+ 69
196
+ 1
197
+ 9
198
+ 74
199
+ 1
200
+ 8
201
+ 81
202
+ 65
203
+ 7
204
+ 4
205
+ 79
206
+ 49
207
+ 3
208
+ 2
209
+ 15
210
+ 26
211
+ 93
212
+ 2
213
+ 15
214
+ 29
215
+ 97
216
+ 0
217
+ 7
218
+ 5
219
+ 98
220
+ 1
221
+ 1
222
+ 30
223
+ 8
224
+ 103
225
+ 25
226
+ 92
227
+ 2
228
+ 27
229
+ 8
230
+ 108
231
+ 15
232
+ 7
233
+ 2
234
+ 8
235
+ 109
236
+ 1
237
+ 9
238
+ 114
239
+ 1
240
+ 8
241
+ 121
242
+ 65
243
+ 7
244
+ 5
245
+ 80
246
+ 49
247
+ 3
248
+ 2
249
+ 15
250
+ 26
251
+ 93
252
+ 3
253
+ 15
254
+ 29
255
+ 137
256
+ 0
257
+ 7
258
+ 6
259
+ 98
260
+ 1
261
+ 1
262
+ 30
263
+ 8
264
+ 143
265
+ 25
266
+ 92
267
+ 3
268
+ 27
269
+ 8
270
+ 148
271
+ 15
272
+ 7
273
+ 2
274
+ 8
275
+ 149
276
+ 1
277
+ 9
278
+ 154
279
+ 1
280
+ 8
281
+ 161
282
+ 65
283
+ 7
284
+ 6
285
+ 1
286
+ 49
287
+ 3
288
+ 2
289
+ 15
290
+ 5
291
+ 99
292
+ 43
293
+ 7
294
+ 12
295
+ 49
296
+ 8
297
+ 1
298
+ 13
299
+ 99
300
+ 12
301
+ 7
302
+ 9
303
+ 12
304
+ 7
305
+ 10
306
+ 12
307
+ 65
308
+ 12
309
+ 49
310
+ 11
311
+ 4
312
+ 15
313
+ 54
314
+ 50
315
+ 9
316
+ 0
317
+ 11
318
+ I
319
+ a
320
+ I
321
+ 0
322
+ I
323
+ 0
324
+ I
325
+ 0
326
+ n
327
+ p
328
+ 12
329
+ x
330
+ 5
331
+ MAJOR
332
+ x
333
+ 16
334
+ vm_const_defined
335
+ s
336
+ 8
337
+ constant
338
+ x
339
+ 9
340
+ const_set
341
+ x
342
+ 5
343
+ MINOR
344
+ x
345
+ 5
346
+ PATCH
347
+ x
348
+ 3
349
+ PRE
350
+ x
351
+ 4
352
+ Type
353
+ x
354
+ 22
355
+ object_singleton_class
356
+ x
357
+ 18
358
+ __metaclass_init__
359
+ M
360
+ 1
361
+ n
362
+ n
363
+ x
364
+ 18
365
+ __metaclass_init__
366
+ i
367
+ 16
368
+ 5
369
+ 66
370
+ 99
371
+ 7
372
+ 0
373
+ 7
374
+ 1
375
+ 65
376
+ 67
377
+ 49
378
+ 2
379
+ 0
380
+ 49
381
+ 3
382
+ 4
383
+ 11
384
+ I
385
+ 5
386
+ I
387
+ 0
388
+ I
389
+ 0
390
+ I
391
+ 0
392
+ n
393
+ p
394
+ 4
395
+ x
396
+ 4
397
+ to_s
398
+ M
399
+ 1
400
+ n
401
+ n
402
+ x
403
+ 4
404
+ to_s
405
+ i
406
+ 24
407
+ 45
408
+ 0
409
+ 1
410
+ 45
411
+ 2
412
+ 3
413
+ 45
414
+ 4
415
+ 5
416
+ 45
417
+ 6
418
+ 7
419
+ 35
420
+ 4
421
+ 49
422
+ 8
423
+ 0
424
+ 7
425
+ 9
426
+ 64
427
+ 49
428
+ 10
429
+ 1
430
+ 11
431
+ I
432
+ 4
433
+ I
434
+ 0
435
+ I
436
+ 0
437
+ I
438
+ 0
439
+ n
440
+ p
441
+ 11
442
+ x
443
+ 5
444
+ MAJOR
445
+ n
446
+ x
447
+ 5
448
+ MINOR
449
+ n
450
+ x
451
+ 5
452
+ PATCH
453
+ n
454
+ x
455
+ 3
456
+ PRE
457
+ n
458
+ x
459
+ 7
460
+ compact
461
+ s
462
+ 1
463
+ .
464
+ x
465
+ 4
466
+ join
467
+ p
468
+ 5
469
+ I
470
+ -1
471
+ I
472
+ b
473
+ I
474
+ 0
475
+ I
476
+ c
477
+ I
478
+ 18
479
+ x
480
+ 71
481
+ /Users/sferik/Projects/Ruby/gems/rails_admin/lib/rails_admin/version.rb
482
+ p
483
+ 0
484
+ x
485
+ 17
486
+ method_visibility
487
+ x
488
+ 15
489
+ add_defn_method
490
+ p
491
+ 3
492
+ I
493
+ 2
494
+ I
495
+ b
496
+ I
497
+ 10
498
+ x
499
+ 71
500
+ /Users/sferik/Projects/Ruby/gems/rails_admin/lib/rails_admin/version.rb
501
+ p
502
+ 0
503
+ x
504
+ 13
505
+ attach_method
506
+ p
507
+ 19
508
+ I
509
+ 2
510
+ I
511
+ 3
512
+ I
513
+ 29
514
+ I
515
+ 0
516
+ I
517
+ 2a
518
+ I
519
+ 4
520
+ I
521
+ 51
522
+ I
523
+ 0
524
+ I
525
+ 52
526
+ I
527
+ 5
528
+ I
529
+ 79
530
+ I
531
+ 0
532
+ I
533
+ 7a
534
+ I
535
+ 6
536
+ I
537
+ a1
538
+ I
539
+ 0
540
+ I
541
+ a2
542
+ I
543
+ 8
544
+ I
545
+ be
546
+ x
547
+ 71
548
+ /Users/sferik/Projects/Ruby/gems/rails_admin/lib/rails_admin/version.rb
549
+ p
550
+ 0
551
+ x
552
+ 13
553
+ attach_method
554
+ p
555
+ 3
556
+ I
557
+ 2
558
+ I
559
+ 2
560
+ I
561
+ 1d
562
+ x
563
+ 71
564
+ /Users/sferik/Projects/Ruby/gems/rails_admin/lib/rails_admin/version.rb
565
+ p
566
+ 0
567
+ x
568
+ 13
569
+ attach_method
570
+ p
571
+ 3
572
+ I
573
+ 0
574
+ I
575
+ 1
576
+ I
577
+ 1c
578
+ x
579
+ 71
580
+ /Users/sferik/Projects/Ruby/gems/rails_admin/lib/rails_admin/version.rb
581
+ p
582
+ 0