rails_admin 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- data/Gemfile +18 -20
- data/README.md +8 -1
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +5 -4
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +4 -4
- data/app/controllers/rails_admin/main_controller.rb +11 -2
- data/app/helpers/rails_admin/application_helper.rb +1 -1
- data/app/helpers/rails_admin/form_builder.rb +3 -3
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +4 -4
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +2 -2
- data/app/views/rails_admin/main/_form_nested_one.html.haml +1 -1
- data/app/views/rails_admin/main/_form_text.html.haml +2 -1
- data/app/views/rails_admin/main/export.html.haml +2 -2
- data/app/views/rails_admin/main/index.html.haml +5 -5
- data/app/views/rails_admin/main/show.html.haml +1 -1
- data/lib/generators/rails_admin/templates/initializer.erb +5 -5
- data/lib/rails_admin/abstract_model.rb +1 -0
- data/lib/rails_admin/config.rb +1 -1
- data/lib/rails_admin/config/actions/base.rb +1 -1
- data/lib/rails_admin/config/actions/edit.rb +5 -4
- data/lib/rails_admin/config/actions/new.rb +5 -4
- data/lib/rails_admin/config/fields/association.rb +10 -10
- data/lib/rails_admin/config/fields/base.rb +10 -4
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/boolean.rb +4 -4
- data/lib/rails_admin/config/fields/types/bson_object_id.rb +4 -4
- data/lib/rails_admin/config/fields/types/carrierwave.rb +3 -3
- data/lib/rails_admin/config/fields/types/datetime.rb +5 -5
- data/lib/rails_admin/config/fields/types/enum.rb +5 -5
- data/lib/rails_admin/config/fields/types/file_upload.rb +10 -6
- data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -1
- data/lib/rails_admin/config/fields/types/has_one_association.rb +3 -3
- data/lib/rails_admin/config/fields/types/integer.rb +1 -1
- data/lib/rails_admin/config/fields/types/paperclip.rb +2 -2
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +8 -4
- data/lib/rails_admin/config/fields/types/serialized.rb +2 -2
- data/lib/rails_admin/config/fields/types/string.rb +3 -3
- data/lib/rails_admin/config/fields/types/text.rb +22 -15
- data/lib/rails_admin/config/fields/types/time.rb +1 -1
- data/lib/rails_admin/config/hideable.rb +1 -1
- data/lib/rails_admin/config/model.rb +4 -0
- data/lib/rails_admin/config/sections/modal.rb +1 -1
- data/lib/rails_admin/engine.rb +1 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -1
- data/lib/rails_admin/support/csv_converter.rb +1 -1
- data/lib/rails_admin/version.rb +2 -2
- data/lib/rails_admin/version.rbc +582 -0
- data/lib/tasks/rails_admin.rake +2 -2
- data/spec/controllers/main_controller_spec.rb +113 -45
- data/spec/dummy_app/Gemfile +11 -25
- data/spec/dummy_app/Gemfile.lock +214 -0
- data/spec/dummy_app/app/active_record/comment.rb +1 -1
- data/spec/dummy_app/app/active_record/field_test.rb +0 -1
- data/spec/dummy_app/config/initializers/strong_parameters.rb +2 -0
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +97612 -0
- data/spec/helpers/application_helper_spec.rb +24 -24
- data/spec/helpers/form_builder_spec.rb +4 -4
- data/spec/integration/authorization/cancan_spec.rb +3 -3
- data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +2 -2
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +2 -2
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +9 -9
- data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +1 -1
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +4 -4
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +9 -9
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +10 -10
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +5 -5
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +32 -25
- data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +8 -8
- data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +3 -3
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +6 -6
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +13 -13
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +97 -76
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +32 -32
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +23 -23
- data/spec/integration/history/rails_admin_history_spec.rb +6 -6
- data/spec/integration/rails_admin_spec.rb +17 -17
- data/spec/integration/relation_spec.rb +7 -7
- data/spec/unit/abstract_model_spec.rb +11 -5
- data/spec/unit/active_record_extension_spec.rb +2 -2
- data/spec/unit/adapters/active_record/abstract_object_spec.rb +8 -8
- data/spec/unit/adapters/active_record_spec.rb +6 -6
- data/spec/unit/adapters/mongoid/abstract_object_spec.rb +1 -1
- data/spec/unit/adapters/mongoid_spec.rb +12 -12
- data/spec/unit/config/actions/base_spec.rb +2 -2
- data/spec/unit/config/actions_spec.rb +16 -16
- data/spec/unit/config/fields/base_spec.rb +61 -49
- data/spec/unit/config/fields/date_spec.rb +4 -4
- data/spec/unit/config/fields/datetime_spec.rb +4 -4
- data/spec/unit/config/fields/file_upload_spec.rb +21 -0
- data/spec/unit/config/fields/time_spec.rb +3 -3
- data/spec/unit/config/fields/timestamp_spec.rb +1 -1
- data/spec/unit/config/model_spec.rb +10 -10
- data/spec/unit/config/sections_spec.rb +4 -4
- data/spec/unit/config_spec.rb +9 -9
- metadata +17 -218
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe RailsAdmin::Config::Fields::Base do
|
4
4
|
|
5
5
|
describe "#required" do
|
6
|
-
it "
|
6
|
+
it "reads the :on => :create/:update validate option" do
|
7
7
|
RailsAdmin.config Ball do
|
8
8
|
field 'color'
|
9
9
|
end
|
@@ -14,7 +14,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#name" do
|
17
|
-
it
|
17
|
+
it "is normalized to Symbol" do
|
18
18
|
RailsAdmin.config Team do
|
19
19
|
field 'name'
|
20
20
|
end
|
@@ -30,19 +30,19 @@ describe RailsAdmin::Config::Fields::Base do
|
|
30
30
|
[:commentable_id, :commentable_type]
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "is empty by default" do
|
34
34
|
expect(RailsAdmin.config(Team).fields.find{ |f| f.name == :name }.children_fields).to eq([])
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "contains child key for belongs to associations" do
|
38
38
|
expect(RailsAdmin.config(Team).fields.find{ |f| f.name == :division }.children_fields).to eq([:division_id])
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "contains child keys for polymorphic belongs to associations" do
|
42
42
|
expect(RailsAdmin.config(Comment).fields.find{ |f| f.name == :commentable }.children_fields).to match_array POLYMORPHIC_CHILDREN
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "has correct fields when polymorphic_type column comes ahead of polymorphic foreign_key column" do
|
46
46
|
class CommentReversed < Tableless
|
47
47
|
column :commentable_type, :string
|
48
48
|
column :commentable_id, :integer
|
@@ -51,26 +51,26 @@ describe RailsAdmin::Config::Fields::Base do
|
|
51
51
|
expect(RailsAdmin.config(CommentReversed).fields.map{|f| f.name.to_s}.select{|f| /^comment/ =~ f}).to match_array ['commentable'].concat(POLYMORPHIC_CHILDREN.map(&:to_s))
|
52
52
|
end
|
53
53
|
|
54
|
-
context
|
55
|
-
it
|
54
|
+
context "of a Paperclip installation" do
|
55
|
+
it "is a _file_name field" do
|
56
56
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.children_fields.include?(:paperclip_asset_file_name)).to be_true
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "is hidden, not filterable" do
|
60
60
|
f = RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset_file_name }
|
61
61
|
expect(f.hidden?).to be_true
|
62
62
|
expect(f.filterable?).to be_false
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context
|
67
|
-
it
|
66
|
+
context "of a Dragonfly installation" do
|
67
|
+
it "is a _name field and _uid field" do
|
68
68
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.children_fields).to eq([:dragonfly_asset_name, :dragonfly_asset_uid])
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
73
|
-
it
|
72
|
+
context "of a Carrierwave installation" do
|
73
|
+
it "is the parent field itself" do
|
74
74
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.children_fields).to eq([:carrierwave_asset])
|
75
75
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.hidden?).to be_false
|
76
76
|
end
|
@@ -78,7 +78,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
describe "#html_default_value" do
|
81
|
-
it
|
81
|
+
it "is default_value for new records when value is nil" do
|
82
82
|
RailsAdmin.config Team do
|
83
83
|
list do
|
84
84
|
field :name do
|
@@ -97,13 +97,13 @@ describe RailsAdmin::Config::Fields::Base do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
describe "#default_value" do
|
100
|
-
it
|
100
|
+
it "is nil by default" do
|
101
101
|
expect(RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.default_value).to be_nil
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
105
|
describe "#hint" do
|
106
|
-
it "
|
106
|
+
it "is user customizable" do
|
107
107
|
RailsAdmin.config Team do
|
108
108
|
list do
|
109
109
|
field :division do
|
@@ -118,7 +118,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "#css_class" do
|
121
|
-
it "
|
121
|
+
it "has a default and be user customizable" do
|
122
122
|
RailsAdmin.config Team do
|
123
123
|
list do
|
124
124
|
field :division do
|
@@ -134,11 +134,11 @@ describe RailsAdmin::Config::Fields::Base do
|
|
134
134
|
end
|
135
135
|
|
136
136
|
describe "#associated_collection_cache_all" do
|
137
|
-
it "
|
137
|
+
it "defaults to true if associated collection count < 100" do
|
138
138
|
expect(RailsAdmin.config(Team).edit.fields.find{|f| f.name == :players}.associated_collection_cache_all).to be_true
|
139
139
|
end
|
140
140
|
|
141
|
-
it "
|
141
|
+
it "defaults to false if associated collection count >= 100" do
|
142
142
|
@players = 100.times.map do
|
143
143
|
FactoryGirl.create :player
|
144
144
|
end
|
@@ -146,13 +146,13 @@ describe RailsAdmin::Config::Fields::Base do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe
|
150
|
-
describe
|
151
|
-
it "
|
149
|
+
describe "#searchable_columns" do
|
150
|
+
describe "for belongs_to fields" do
|
151
|
+
it "finds label method on the opposite side for belongs_to associations by default" do
|
152
152
|
expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.map{|c| c[:column]}).to eq(["divisions.name", "teams.division_id"])
|
153
153
|
end
|
154
154
|
|
155
|
-
it "
|
155
|
+
it "searches on opposite table for belongs_to" do
|
156
156
|
RailsAdmin.config(Team) do
|
157
157
|
field :division do
|
158
158
|
searchable :custom_id
|
@@ -161,7 +161,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
161
161
|
expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.map{|c| c[:column]}).to eq(["divisions.custom_id"])
|
162
162
|
end
|
163
163
|
|
164
|
-
it "
|
164
|
+
it "searches on asked table with model name" do
|
165
165
|
RailsAdmin.config(Team) do
|
166
166
|
field :division do
|
167
167
|
searchable League => :name
|
@@ -170,7 +170,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
170
170
|
expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns).to eq([{:column=>"leagues.name", :type=>:string}])
|
171
171
|
end
|
172
172
|
|
173
|
-
it "
|
173
|
+
it "searches on asked table with table name" do
|
174
174
|
RailsAdmin.config(Team) do
|
175
175
|
field :division do
|
176
176
|
searchable :leagues => :name
|
@@ -180,14 +180,14 @@ describe RailsAdmin::Config::Fields::Base do
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
-
describe
|
183
|
+
describe "for basic type fields" do
|
184
184
|
|
185
|
-
it
|
185
|
+
it "uses base table and find correct column type" do
|
186
186
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :text_field}.searchable_columns).to eq([{:column=>"field_tests.text_field", :type=>:text}])
|
187
187
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :integer_field}.searchable_columns).to eq([{:column=>"field_tests.integer_field", :type=>:integer}])
|
188
188
|
end
|
189
189
|
|
190
|
-
it
|
190
|
+
it "is customizable to another field on the same table" do
|
191
191
|
RailsAdmin.config(FieldTest) do
|
192
192
|
field :time_field do
|
193
193
|
searchable :date_field
|
@@ -196,7 +196,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
196
196
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :time_field}.searchable_columns).to eq([{:column=>"field_tests.date_field", :type=>:date}])
|
197
197
|
end
|
198
198
|
|
199
|
-
it
|
199
|
+
it "is customizable to another field on another table with :table_name" do
|
200
200
|
RailsAdmin.config(FieldTest) do
|
201
201
|
field :string_field do
|
202
202
|
searchable :nested_field_tests => :title
|
@@ -205,7 +205,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
205
205
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :string_field}.searchable_columns).to eq([{:column=>"nested_field_tests.title", :type=>:string}])
|
206
206
|
end
|
207
207
|
|
208
|
-
it
|
208
|
+
it "is customizable to another field on another model with ModelClass" do
|
209
209
|
RailsAdmin.config(FieldTest) do
|
210
210
|
field :string_field do
|
211
211
|
searchable NestedFieldTest => :title
|
@@ -215,16 +215,16 @@ describe RailsAdmin::Config::Fields::Base do
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
describe
|
219
|
-
it
|
218
|
+
describe "for mapped fields" do
|
219
|
+
it "of paperclip should find the underlying column on the base table" do
|
220
220
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :paperclip_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.paperclip_asset_file_name"])
|
221
221
|
end
|
222
222
|
|
223
|
-
it
|
223
|
+
it "of dragonfly should find the underlying column on the base table" do
|
224
224
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :dragonfly_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.dragonfly_asset_name"])
|
225
225
|
end
|
226
226
|
|
227
|
-
it
|
227
|
+
it "of carrierwave should find the underlying column on the base table" do
|
228
228
|
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :carrierwave_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.carrierwave_asset"])
|
229
229
|
end
|
230
230
|
end
|
@@ -232,7 +232,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
232
232
|
|
233
233
|
|
234
234
|
describe "#searchable and #sortable" do
|
235
|
-
it
|
235
|
+
it "is false if column is virtual, true otherwise" do
|
236
236
|
RailsAdmin.config League do
|
237
237
|
field :virtual_column
|
238
238
|
field :name
|
@@ -244,18 +244,18 @@ describe RailsAdmin::Config::Fields::Base do
|
|
244
244
|
expect(RailsAdmin.config('League').export.fields.find{ |f| f.name == :name }.searchable).to be_true
|
245
245
|
end
|
246
246
|
|
247
|
-
context
|
248
|
-
it
|
247
|
+
context "of a virtual field with children fields" do
|
248
|
+
it "of paperclip should target the first children field" do
|
249
249
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.searchable).to eq(:paperclip_asset_file_name)
|
250
250
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.sortable).to eq(:paperclip_asset_file_name)
|
251
251
|
end
|
252
252
|
|
253
|
-
it
|
253
|
+
it "of dragonfly should target the first children field" do
|
254
254
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.searchable).to eq(:dragonfly_asset_name)
|
255
255
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.sortable).to eq(:dragonfly_asset_name)
|
256
256
|
end
|
257
257
|
|
258
|
-
it
|
258
|
+
it "of carrierwave should target the first children field" do
|
259
259
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.searchable).to eq(:carrierwave_asset)
|
260
260
|
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.sortable).to eq(:carrierwave_asset)
|
261
261
|
end
|
@@ -263,7 +263,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
263
263
|
end
|
264
264
|
|
265
265
|
describe "#virtual?" do
|
266
|
-
it
|
266
|
+
it "is true if column has no properties, false otherwise" do
|
267
267
|
RailsAdmin.config League do
|
268
268
|
field :virtual_column
|
269
269
|
field :name
|
@@ -338,20 +338,20 @@ describe RailsAdmin::Config::Fields::Base do
|
|
338
338
|
end
|
339
339
|
end
|
340
340
|
|
341
|
-
describe
|
342
|
-
it
|
341
|
+
describe "#active" do
|
342
|
+
it "is false by default" do
|
343
343
|
expect(RailsAdmin.config(Team).field(:division).active?).to be_false
|
344
344
|
end
|
345
345
|
end
|
346
346
|
|
347
|
-
describe
|
348
|
-
it
|
347
|
+
describe "#associated_collection" do
|
348
|
+
it "returns [] when type is blank?" do
|
349
349
|
expect(RailsAdmin.config(Comment).fields.find{|f|f.name == :commentable}.associated_collection('')).to be_empty
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
353
|
-
describe
|
354
|
-
it "
|
353
|
+
describe "#visible?" do
|
354
|
+
it "is false when fields have specific name " do
|
355
355
|
class FieldVisibilityTest < Tableless
|
356
356
|
column :id, :integer
|
357
357
|
column :_id, :integer
|
@@ -371,12 +371,12 @@ describe RailsAdmin::Config::Fields::Base do
|
|
371
371
|
end
|
372
372
|
end
|
373
373
|
|
374
|
-
describe
|
374
|
+
describe "#editable?" do
|
375
375
|
before do
|
376
376
|
Moped.logger.stub!(:debug) if defined?(Moped)
|
377
377
|
end
|
378
378
|
|
379
|
-
it
|
379
|
+
it "yells for non attr_accessible fields if config.yell_for_non_accessible_fields is true" do
|
380
380
|
RailsAdmin.config do |config|
|
381
381
|
config.yell_for_non_accessible_fields = true
|
382
382
|
config.model FieldTest do
|
@@ -388,7 +388,7 @@ describe RailsAdmin::Config::Fields::Base do
|
|
388
388
|
expect(editable).to be_false
|
389
389
|
end
|
390
390
|
|
391
|
-
it
|
391
|
+
it "does not yell for non attr_accessible fields if config.yell_for_non_accessible_fields is false" do
|
392
392
|
RailsAdmin.config do |config|
|
393
393
|
config.yell_for_non_accessible_fields = false
|
394
394
|
config.model FieldTest do
|
@@ -400,4 +400,16 @@ describe RailsAdmin::Config::Fields::Base do
|
|
400
400
|
expect(editable).to be_false
|
401
401
|
end
|
402
402
|
end
|
403
|
+
|
404
|
+
describe "#allowed_methods" do
|
405
|
+
it 'includes method_name' do
|
406
|
+
RailsAdmin.config do |config|
|
407
|
+
config.model Team do
|
408
|
+
field :name
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
expect(RailsAdmin.config(Team).field(:name).allowed_methods).to eq [:name]
|
413
|
+
end
|
414
|
+
end
|
403
415
|
end
|
@@ -12,19 +12,19 @@ describe RailsAdmin::Config::Fields::Types::Date do
|
|
12
12
|
Time.zone = 'UTC'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "reads %B %d, %Y by default" do
|
16
16
|
@object.date_field = @field.parse_input({ :date_field => @time.strftime("%B %d, %Y") })
|
17
17
|
expect(@object.date_field).to eq(::Date.parse(@time.to_s))
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "covers a timezone lag even if in UTC+n:00 timezone." do
|
21
21
|
Time.zone = 'Tokyo' # +09:00
|
22
22
|
|
23
23
|
@object.date_field = @field.parse_input({ :date_field => @time.strftime("%B %d, %Y") })
|
24
24
|
expect(@object.date_field).to eq(::Date.parse(@time.to_s))
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "has a simple customization option" do
|
28
28
|
RailsAdmin.config FieldTest do
|
29
29
|
edit do
|
30
30
|
field :date_field do
|
@@ -37,7 +37,7 @@ describe RailsAdmin::Config::Fields::Types::Date do
|
|
37
37
|
expect(@object.date_field).to eq(::Date.parse(@time.to_s))
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "has a customization option" do
|
41
41
|
RailsAdmin.config FieldTest do
|
42
42
|
edit do
|
43
43
|
field :date_field do
|
@@ -12,13 +12,13 @@ describe RailsAdmin::Config::Fields::Types::Datetime do
|
|
12
12
|
Time.zone = 'UTC'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "is able to read %B %d, %Y %H:%M" do
|
16
16
|
@object = FactoryGirl.create(:field_test)
|
17
17
|
@object.datetime_field = @field.parse_input({ :datetime_field => @time.strftime("%B %d, %Y %H:%M") })
|
18
18
|
expect(@object.datetime_field.strftime("%Y-%m-%d %H:%M")).to eq(@time.strftime("%Y-%m-%d %H:%M"))
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "is able to read %a, %d %b %Y %H:%M:%S" do
|
22
22
|
RailsAdmin.config FieldTest do
|
23
23
|
edit do
|
24
24
|
field :datetime_field do
|
@@ -31,7 +31,7 @@ describe RailsAdmin::Config::Fields::Types::Datetime do
|
|
31
31
|
expect(@object.datetime_field.to_s(:rfc822)).to eq(@time.to_s(:rfc822))
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "has a customization option" do
|
35
35
|
RailsAdmin.config FieldTest do
|
36
36
|
list do
|
37
37
|
field :datetime_field do
|
@@ -44,7 +44,7 @@ describe RailsAdmin::Config::Fields::Types::Datetime do
|
|
44
44
|
expect(@object.datetime_field.to_s(:rfc822)).to eq(@time.to_s(:rfc822))
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "does round-trip saving properly with non-UTC timezones" do
|
48
48
|
Time.zone = 'Vienna'
|
49
49
|
@object = FactoryGirl.create(:field_test)
|
50
50
|
@object.datetime_field = @field.parse_input({ :datetime_field => '2012-09-01 12:00:00 +02:00' })
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsAdmin::Config::Fields::Types::FileUpload do
|
4
|
+
describe "#allowed_methods" do
|
5
|
+
it 'includes delete_method and cache_method' do
|
6
|
+
RailsAdmin.config do |config|
|
7
|
+
config.model FieldTest do
|
8
|
+
field :carrierwave_asset
|
9
|
+
field :dragonfly_asset
|
10
|
+
field :paperclip_asset do
|
11
|
+
delete_method :delete_paperclip_asset
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
expect(RailsAdmin.config(FieldTest).field(:carrierwave_asset).allowed_methods.map(&:to_s)).to eq ["carrierwave_asset", "remove_carrierwave_asset", "carrierwave_asset_cache"]
|
16
|
+
expect(RailsAdmin.config(FieldTest).field(:dragonfly_asset).allowed_methods.map(&:to_s)).to eq ["dragonfly_asset", "remove_dragonfly_asset", "retained_dragonfly_asset"]
|
17
|
+
expect(RailsAdmin.config(FieldTest).field(:paperclip_asset).allowed_methods.map(&:to_s)).to eq ["paperclip_asset", "delete_paperclip_asset"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -12,18 +12,18 @@ describe RailsAdmin::Config::Fields::Types::Time do
|
|
12
12
|
Time.zone = 'UTC'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "reads %H:%M" do
|
16
16
|
@object.time_field = @field.parse_input({ :time_field => @time.strftime("%H:%M") })
|
17
17
|
expect(@object.time_field.strftime("%H:%M")).to eq(@time.strftime("%H:%M"))
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "interprets time value as UTC when timezone is specified" do
|
21
21
|
Time.zone = 'Eastern Time (US & Canada)' # -05:00
|
22
22
|
@object.time_field = @field.parse_input({ :time_field => @time.strftime("%H:%M") })
|
23
23
|
expect(@object.time_field.strftime("%H:%M")).to eq(@time.strftime("%H:%M"))
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "has a customization option" do
|
27
27
|
RailsAdmin.config FieldTest do
|
28
28
|
edit do
|
29
29
|
field :time_field do
|
@@ -12,7 +12,7 @@ describe RailsAdmin::Config::Fields::Types::Timestamp do
|
|
12
12
|
Time.zone = 'UTC'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "reads %B %d, %Y %H:%M" do
|
16
16
|
@object.timestamp_field = @field.parse_input({ :timestamp_field => @time.strftime("%B %d, %Y %H:%M") })
|
17
17
|
expect(@object.timestamp_field.strftime("%Y-%m-%d %H:%M")).to eq(@time.strftime("%Y-%m-%d %H:%M"))
|
18
18
|
end
|
@@ -9,7 +9,7 @@ describe RailsAdmin::Config::Model do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "returns false when included, true otherwise" do
|
13
13
|
expect(RailsAdmin.config(Player).excluded?).to be_true
|
14
14
|
expect(RailsAdmin.config(Comment).excluded?).to be_false
|
15
15
|
end
|
@@ -22,53 +22,53 @@ describe RailsAdmin::Config::Model do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "sends object_label_method to binding[:object]" do
|
26
26
|
c = Comment.new(:content => 'test')
|
27
27
|
expect(RailsAdmin.config(Comment).with(:object => c).object_label).to eq('test')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "#object_label_method" do
|
32
|
-
it "
|
32
|
+
it "is first of Config.label_methods if found as a column on model, or :rails_admin_default_object_label_method" do
|
33
33
|
expect(RailsAdmin.config(Comment).object_label_method).to eq(:rails_admin_default_object_label_method)
|
34
34
|
expect(RailsAdmin.config(Division).object_label_method).to eq(:name)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#label" do
|
39
|
-
it "
|
39
|
+
it "is pretty" do
|
40
40
|
expect(RailsAdmin.config(Comment).label).to eq('Comment')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "#label_plural" do
|
45
|
-
it "
|
45
|
+
it "is pretty" do
|
46
46
|
expect(RailsAdmin.config(Comment).label_plural).to eq('Comments')
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "#weight" do
|
51
|
-
it "
|
51
|
+
it "is 0" do
|
52
52
|
expect(RailsAdmin.config(Comment).weight).to eq(0)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "#parent" do
|
57
|
-
it "
|
57
|
+
it "is nil for ActiveRecord::Base inherited models" do
|
58
58
|
expect(RailsAdmin.config(Comment).parent).to be_nil
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "is parent model otherwise" do
|
62
62
|
expect(RailsAdmin.config(Hardball).parent).to eq(Ball)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "#navigation_label" do
|
67
|
-
it "
|
67
|
+
it "is nil if parent module is Object" do
|
68
68
|
expect(RailsAdmin.config(Comment).navigation_label).to be_nil
|
69
69
|
end
|
70
70
|
|
71
|
-
it "
|
71
|
+
it "is parent module otherwise" do
|
72
72
|
expect(RailsAdmin.config(Cms::BasicPage).navigation_label).to eq("Cms")
|
73
73
|
end
|
74
74
|
end
|