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.
- 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
|
@@ -30,7 +30,7 @@ describe "RailsAdmin Export" do
|
|
|
30
30
|
|
|
31
31
|
describe "POST /admin/players/export (prompt)" do
|
|
32
32
|
|
|
33
|
-
it "
|
|
33
|
+
it "allows to export to CSV with associations and default schema, containing properly translated header and follow configuration" do
|
|
34
34
|
RailsAdmin.config do |c|
|
|
35
35
|
c.model Player do
|
|
36
36
|
include_all_fields
|
|
@@ -63,13 +63,13 @@ describe "RailsAdmin Export" do
|
|
|
63
63
|
expect(csv.flatten.join(' ')).to include(@player.comments.second.content.split("\n").first.strip)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
it "
|
|
66
|
+
it "allows to export to JSON" do
|
|
67
67
|
visit export_path(:model_name => 'player')
|
|
68
68
|
click_button 'Export to json'
|
|
69
69
|
should have_content @player.team.name
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
it "
|
|
72
|
+
it "allows to export to XML" do
|
|
73
73
|
visit export_path(:model_name => 'player')
|
|
74
74
|
click_button 'Export to xml'
|
|
75
75
|
|
|
@@ -83,7 +83,7 @@ describe "RailsAdmin Export" do
|
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
it "
|
|
86
|
+
it "exports polymorphic fields the easy way for now" do
|
|
87
87
|
visit export_path(:model_name => 'comment')
|
|
88
88
|
select "<comma> ','", :from => "csv_options_generator_col_sep"
|
|
89
89
|
click_button 'Export to csv'
|
|
@@ -97,7 +97,7 @@ describe "RailsAdmin Export" do
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
describe "POST /admin/players/export :format => :csv" do
|
|
100
|
-
it "
|
|
100
|
+
it "exports with modified schema" do
|
|
101
101
|
page.driver.post(export_path(:model_name => 'player', :schema => @non_default_schema, :csv => true, :all => true, :csv_options => { :generator => { :col_sep => "," } }))
|
|
102
102
|
csv = CSV.parse find('body').text
|
|
103
103
|
expect(csv[0]).not_to include('Created at')
|
|
@@ -7,13 +7,13 @@ describe "RailsAdmin Basic List" do
|
|
|
7
7
|
subject { page }
|
|
8
8
|
|
|
9
9
|
describe "GET /admin" do
|
|
10
|
-
it "
|
|
10
|
+
it "responds successfully" do
|
|
11
11
|
visit dashboard_path
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe "GET /admin/typo" do
|
|
16
|
-
it "
|
|
16
|
+
it "redirects to dashboard and inform the user the model wasn't found" do
|
|
17
17
|
visit '/admin/whatever'
|
|
18
18
|
expect(page.driver.status_code).to eq(404)
|
|
19
19
|
expect(find('.alert-error')).to have_content("Model 'Whatever' could not be found")
|
|
@@ -21,7 +21,7 @@ describe "RailsAdmin Basic List" do
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
describe "GET /admin/balls/545-typo" do
|
|
24
|
-
it "
|
|
24
|
+
it "redirects to balls index and inform the user the id wasn't found" do
|
|
25
25
|
visit '/admin/ball/545-typo'
|
|
26
26
|
expect(page.driver.status_code).to eq(404)
|
|
27
27
|
expect(find('.alert-error')).to have_content("Ball with id '545-typo' could not be found")
|
|
@@ -29,7 +29,7 @@ describe "RailsAdmin Basic List" do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
describe "GET /admin/player as list" do
|
|
32
|
-
it "
|
|
32
|
+
it "shows \"List of Models\", should show filters and should show column headers" do
|
|
33
33
|
21.times { FactoryGirl.create :player } # two pages of players
|
|
34
34
|
visit index_path(:model_name => "player")
|
|
35
35
|
should have_content("List of Players")
|
|
@@ -47,7 +47,7 @@ describe "RailsAdmin Basic List" do
|
|
|
47
47
|
# https://github.com/sferik/rails_admin/issues/362
|
|
48
48
|
# test that no link uses the "wildcard route" with the main
|
|
49
49
|
# controller and list method
|
|
50
|
-
# it "
|
|
50
|
+
# it "does not use the 'wildcard route'" do
|
|
51
51
|
should have_selector("a[href*='all=true']") # make sure we're fully testing pagination
|
|
52
52
|
should have_no_selector("a[href^='/rails_admin/main/list']")
|
|
53
53
|
end
|
|
@@ -74,7 +74,7 @@ describe "RailsAdmin Basic List" do
|
|
|
74
74
|
]
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
it "
|
|
77
|
+
it "allows to query on any attribute" do
|
|
78
78
|
visit index_path(:model_name => "player", :query => @players[0].name)
|
|
79
79
|
should have_content(@players[0].name)
|
|
80
80
|
(1..3).each do |i|
|
|
@@ -82,7 +82,7 @@ describe "RailsAdmin Basic List" do
|
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
it "
|
|
85
|
+
it "allows to filter on one attribute" do
|
|
86
86
|
visit index_path(:model_name => "player", :f => {:injured => {"1" => {:v => "true"}}})
|
|
87
87
|
should have_content(@players[0].name)
|
|
88
88
|
should have_no_content(@players[1].name)
|
|
@@ -90,7 +90,7 @@ describe "RailsAdmin Basic List" do
|
|
|
90
90
|
should have_no_content(@players[3].name)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
it "
|
|
93
|
+
it "allows to combine filters on two different attributes" do
|
|
94
94
|
visit index_path(:model_name => "player", :f => {:retired => {"1" => {:v => "true"}}, :injured => {"1" => {:v => "true"}}})
|
|
95
95
|
should have_content(@players[0].name)
|
|
96
96
|
(1..3).each do |i|
|
|
@@ -98,7 +98,7 @@ describe "RailsAdmin Basic List" do
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it "
|
|
101
|
+
it "allows to filter on belongs_to relationships" do
|
|
102
102
|
visit index_path(:model_name => "player", :f => {:team => {"1" => { :v => @teams[0].name }}})
|
|
103
103
|
should have_content(@players[0].name)
|
|
104
104
|
should have_content(@players[1].name)
|
|
@@ -106,7 +106,7 @@ describe "RailsAdmin Basic List" do
|
|
|
106
106
|
should have_no_content(@players[3].name)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
it "
|
|
109
|
+
it "allows to disable search on attributes" do
|
|
110
110
|
RailsAdmin.config Player do
|
|
111
111
|
list do
|
|
112
112
|
field :position
|
|
@@ -119,7 +119,7 @@ describe "RailsAdmin Basic List" do
|
|
|
119
119
|
should have_no_content(@players[0].name)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
it "
|
|
122
|
+
it "allows to search a belongs_to attribute over the base table" do
|
|
123
123
|
RailsAdmin.config Player do
|
|
124
124
|
list do
|
|
125
125
|
field PK_COLUMN
|
|
@@ -137,7 +137,7 @@ describe "RailsAdmin Basic List" do
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
it "
|
|
140
|
+
it "allows to search a belongs_to attribute over the target table" do
|
|
141
141
|
RailsAdmin.config Player do
|
|
142
142
|
list do
|
|
143
143
|
field PK_COLUMN
|
|
@@ -154,7 +154,7 @@ describe "RailsAdmin Basic List" do
|
|
|
154
154
|
should have_no_content(@players[3].name)
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
it "
|
|
157
|
+
it "allows to search a belongs_to attribute over the target table with a table name specified as a hash" do
|
|
158
158
|
RailsAdmin.config Player do
|
|
159
159
|
list do
|
|
160
160
|
field PK_COLUMN
|
|
@@ -171,7 +171,7 @@ describe "RailsAdmin Basic List" do
|
|
|
171
171
|
should have_no_content(@players[3].name)
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
it "
|
|
174
|
+
it "allows to search a belongs_to attribute over the target table with a table name specified as a string" do
|
|
175
175
|
RailsAdmin.config Player do
|
|
176
176
|
list do
|
|
177
177
|
field PK_COLUMN
|
|
@@ -188,7 +188,7 @@ describe "RailsAdmin Basic List" do
|
|
|
188
188
|
should have_no_content(@players[3].name)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
|
-
it "
|
|
191
|
+
it "allows to search a belongs_to attribute over the label method by default" do
|
|
192
192
|
RailsAdmin.config Player do
|
|
193
193
|
list do
|
|
194
194
|
field PK_COLUMN
|
|
@@ -203,7 +203,7 @@ describe "RailsAdmin Basic List" do
|
|
|
203
203
|
should have_no_content(@players[3].name)
|
|
204
204
|
end
|
|
205
205
|
|
|
206
|
-
it "
|
|
206
|
+
it "allows to search a belongs_to attribute over the target table when an attribute is specified" do
|
|
207
207
|
RailsAdmin.config Player do
|
|
208
208
|
list do
|
|
209
209
|
field PK_COLUMN
|
|
@@ -220,7 +220,7 @@ describe "RailsAdmin Basic List" do
|
|
|
220
220
|
should have_no_content(@players[3].name)
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
it "
|
|
223
|
+
it "allows to search over more than one attribute" do
|
|
224
224
|
RailsAdmin.config Player do
|
|
225
225
|
list do
|
|
226
226
|
field PK_COLUMN
|
|
@@ -243,7 +243,7 @@ describe "RailsAdmin Basic List" do
|
|
|
243
243
|
should have_no_content(@players[3].name)
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
it "
|
|
246
|
+
it "displays base filters when no filters are present in the params" do
|
|
247
247
|
RailsAdmin.config Player do
|
|
248
248
|
list do
|
|
249
249
|
filters [:name, :team]
|
|
@@ -262,7 +262,7 @@ describe "RailsAdmin Basic List" do
|
|
|
262
262
|
visit index_path(:model_name => "player")
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
-
it "
|
|
265
|
+
it "shows \"2 results\"" do
|
|
266
266
|
should have_content("2 players")
|
|
267
267
|
end
|
|
268
268
|
end
|
|
@@ -273,7 +273,7 @@ describe "RailsAdmin Basic List" do
|
|
|
273
273
|
visit index_path(:model_name => "player")
|
|
274
274
|
end
|
|
275
275
|
|
|
276
|
-
it "
|
|
276
|
+
it "shows \"20 results\"" do
|
|
277
277
|
should have_content("20 players")
|
|
278
278
|
end
|
|
279
279
|
end
|
|
@@ -285,7 +285,7 @@ describe "RailsAdmin Basic List" do
|
|
|
285
285
|
visit index_path(:model_name => "player", :page => 2)
|
|
286
286
|
end
|
|
287
287
|
|
|
288
|
-
it "
|
|
288
|
+
it "paginates correctly" do
|
|
289
289
|
expect(find('.pagination ul li:first')).to have_content("« Prev")
|
|
290
290
|
expect(find('.pagination ul li:last')).to have_content("Next »")
|
|
291
291
|
expect(find('.pagination ul li.active')).to have_content("2")
|
|
@@ -299,7 +299,7 @@ describe "RailsAdmin Basic List" do
|
|
|
299
299
|
visit index_path(:model_name => "player", :page => 3)
|
|
300
300
|
end
|
|
301
301
|
|
|
302
|
-
it "
|
|
302
|
+
it "paginates correctly and contain the right item" do
|
|
303
303
|
expect(find('.pagination ul li:first')).to have_content("« Prev")
|
|
304
304
|
expect(find('.pagination ul li:last')).to have_content("Next »")
|
|
305
305
|
expect(find('.pagination ul li.active')).to have_content("3")
|
|
@@ -307,7 +307,14 @@ describe "RailsAdmin Basic List" do
|
|
|
307
307
|
end
|
|
308
308
|
|
|
309
309
|
describe "GET /admin/player show all" do
|
|
310
|
-
it "
|
|
310
|
+
it "responds successfully with a single model" do
|
|
311
|
+
FactoryGirl.create :player
|
|
312
|
+
visit index_path(:model_name => "player", :all => true)
|
|
313
|
+
expect(find('div.total-count')).to have_content("1 player")
|
|
314
|
+
expect(find('div.total-count')).not_to have_content("1 players")
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it "responds successfully with multiple models" do
|
|
311
318
|
2.times.map { FactoryGirl.create :player }
|
|
312
319
|
visit index_path(:model_name => "player", :all => true)
|
|
313
320
|
expect(find('div.total-count')).to have_content("2 players")
|
|
@@ -315,7 +322,7 @@ describe "RailsAdmin Basic List" do
|
|
|
315
322
|
end
|
|
316
323
|
|
|
317
324
|
describe "GET /admin/player show with pagination disabled by :associated_collection" do
|
|
318
|
-
it "
|
|
325
|
+
it "responds successfully" do
|
|
319
326
|
@team = FactoryGirl.create :team
|
|
320
327
|
2.times.map { FactoryGirl.create :player, :team => @team }
|
|
321
328
|
visit index_path(:model_name => "player", :associated_collection => "players", :compact => true, :current_action => 'update', :source_abstract_model => 'team', :source_object_id => @team.id)
|
|
@@ -324,7 +331,7 @@ describe "RailsAdmin Basic List" do
|
|
|
324
331
|
end
|
|
325
332
|
|
|
326
333
|
describe "list as compact json" do
|
|
327
|
-
it "
|
|
334
|
+
it "has_content an array with 2 elements and contain an array of elements with keys id and label" do
|
|
328
335
|
2.times.map { FactoryGirl.create :player }
|
|
329
336
|
response = page.driver.get(index_path(:model_name => "player", :compact => true, :format => :json))
|
|
330
337
|
expect(ActiveSupport::JSON.decode(response.body).length).to eq(2)
|
|
@@ -9,16 +9,16 @@ describe "RailsAdmin Basic New" do
|
|
|
9
9
|
visit new_path(:model_name => "player")
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
it "
|
|
12
|
+
it "shows \"New Model\"" do
|
|
13
13
|
should have_content("New Player")
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it "
|
|
16
|
+
it "shows required fields as \"Required\"" do
|
|
17
17
|
should have_selector("div", :text => /Name\s*Required/)
|
|
18
18
|
should have_selector("div", :text => /Number\s*Required/)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it "
|
|
21
|
+
it "shows non-required fields as \"Optional\"" do
|
|
22
22
|
should have_selector("#player_position_field .help-block", :text => "Optional")
|
|
23
23
|
should have_selector("#player_born_on_field .help-block", :text => "Optional")
|
|
24
24
|
should have_selector("#player_notes_field .help-block", :text => "Optional")
|
|
@@ -27,7 +27,7 @@ describe "RailsAdmin Basic New" do
|
|
|
27
27
|
# https://github.com/sferik/rails_admin/issues/362
|
|
28
28
|
# test that no link uses the "wildcard route" with the main
|
|
29
29
|
# controller and new method
|
|
30
|
-
it "
|
|
30
|
+
it "does not use the 'wildcard route'" do
|
|
31
31
|
should have_no_selector("a[href^='/rails_admin/main/new']")
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -38,7 +38,7 @@ describe "RailsAdmin Basic New" do
|
|
|
38
38
|
visit new_path(:model_name => "player")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
it "
|
|
41
|
+
it "shows selects" do
|
|
42
42
|
should have_selector("select#player_draft_id")
|
|
43
43
|
should have_selector("select#player_team_id")
|
|
44
44
|
should have_selector("select#player_comment_ids")
|
|
@@ -53,18 +53,18 @@ describe "RailsAdmin Basic New" do
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
describe "GET /admin/player/new with parameters for pre-population" do
|
|
56
|
-
it "
|
|
56
|
+
it "populates form field when corresponding parameters are passed in" do
|
|
57
57
|
visit new_path(:model_name => 'player', :player => {:name => 'Sam'})
|
|
58
58
|
expect(page).to have_css('input[value=Sam]')
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it "
|
|
61
|
+
it "prepropulates belongs to relationships" do
|
|
62
62
|
@team = FactoryGirl.create :team, :name => "belongs_to association prepopulated"
|
|
63
63
|
visit new_path(:model_name => 'player', :associations => { :team => @team.id } )
|
|
64
64
|
expect(page).to have_css("select#player_team_id option[selected='selected'][value='#{@team.id}']")
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
it "
|
|
67
|
+
it "prepropulates has_many relationships" do
|
|
68
68
|
@player = FactoryGirl.create :player, :name => "has_many association prepopulated"
|
|
69
69
|
visit new_path(:model_name => 'team', :associations => { :players => @player.id } )
|
|
70
70
|
expect(page).to have_css("select#team_player_ids option[selected='selected'][value='#{@player.id}']")
|
|
@@ -5,13 +5,13 @@ describe "RailsAdmin Namespaced Model New" do
|
|
|
5
5
|
subject { page }
|
|
6
6
|
|
|
7
7
|
describe "AbstractModel#to_param" do
|
|
8
|
-
it
|
|
8
|
+
it "turns namespaces into prefixes with ~" do
|
|
9
9
|
expect(RailsAdmin::AbstractModel.new("Cms::BasicPage").to_param).to eq('cms~basic_page')
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
describe "ApplicationController#to_model_name" do
|
|
14
|
-
it
|
|
14
|
+
it "turns cms~basic_page into Cms::BasicPage" do
|
|
15
15
|
expect(RailsAdmin::ApplicationController.new.to_model_name('cms~basic_page')).to eq('Cms::BasicPage')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -21,7 +21,7 @@ describe "RailsAdmin Namespaced Model New" do
|
|
|
21
21
|
visit new_path(:model_name => "cms~basic_page")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it
|
|
24
|
+
it "has correct input field names" do
|
|
25
25
|
should have_selector("label[for=cms_basic_page_title]")
|
|
26
26
|
should have_selector("input#cms_basic_page_title[name='cms_basic_page[title]']")
|
|
27
27
|
should have_selector("label[for=cms_basic_page_content]")
|
|
@@ -4,7 +4,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
4
4
|
subject { page }
|
|
5
5
|
|
|
6
6
|
describe "show" do
|
|
7
|
-
it "
|
|
7
|
+
it "has History, Edit, Delete, Details and attributes" do
|
|
8
8
|
@player = FactoryGirl.create :player
|
|
9
9
|
visit show_path(:model_name => "player", :id => @player.id)
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
describe "GET /admin/players/123this-id-doesnt-exist" do
|
|
23
|
-
it "
|
|
23
|
+
it "raises NotFound" do
|
|
24
24
|
visit '/admin/players/123this-id-doesnt-exist'
|
|
25
25
|
expect(page.driver.status_code).to eq(404)
|
|
26
26
|
end
|
|
@@ -34,7 +34,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
34
34
|
visit show_path(:model_name => "player", :id => @player.id)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
it "
|
|
37
|
+
it "shows associated objects" do
|
|
38
38
|
should have_css("a[href='/admin/team/#{@team.id}']")
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -46,7 +46,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
46
46
|
visit show_path(:model_name => "player", :id => @player.id)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
it "
|
|
49
|
+
it "shows associated objects" do
|
|
50
50
|
should have_css("a[href='/admin/draft/#{@draft.id}']")
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -61,7 +61,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
61
61
|
visit show_path(:model_name => "player", :id => @player.id)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
it "
|
|
64
|
+
it "shows associated objects" do
|
|
65
65
|
should have_css("a[href='/admin/comment/#{@comment1.id}']")
|
|
66
66
|
should have_css("a[href='/admin/comment/#{@comment2.id}']")
|
|
67
67
|
should_not have_css("a[href='/admin/comment/#{@comment3.id}']")
|
|
@@ -75,7 +75,7 @@ describe "RailsAdmin Basic Show" do
|
|
|
75
75
|
visit show_path(:model_name => "comment", :id => @comment.id)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
it "
|
|
78
|
+
it "shows associated object" do
|
|
79
79
|
should have_css("a[href='/admin/player/#{@player.id}']")
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -10,7 +10,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
10
10
|
visit edit_path(:model_name => "player", :id => @player.id)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
it "
|
|
13
|
+
it "returns to edit page" do
|
|
14
14
|
fill_in "player[name]", :with => ""
|
|
15
15
|
click_button "Save"
|
|
16
16
|
expect(page.driver.status_code).to eq(406)
|
|
@@ -32,7 +32,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
32
32
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
it "
|
|
35
|
+
it "updates an object with correct attributes" do
|
|
36
36
|
expect(@player.name).to eq("Jackie Robinson")
|
|
37
37
|
expect(@player.number).to eq(42)
|
|
38
38
|
expect(@player.position).to eq("Second baseman")
|
|
@@ -53,7 +53,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
53
53
|
@player.reload
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
it "
|
|
56
|
+
it "updates an object with correct attributes" do
|
|
57
57
|
expect(@player.name).to eq("Jackie Robinson")
|
|
58
58
|
expect(@player.number).to eq(42)
|
|
59
59
|
expect(@player.position).to eq("Second baseman")
|
|
@@ -69,20 +69,20 @@ describe "RailsAdmin Basic Update" do
|
|
|
69
69
|
@player.reload
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
it "
|
|
72
|
+
it "updates an object with correct attributes" do
|
|
73
73
|
expect(@player.name).to eq("Jackie Robinson")
|
|
74
74
|
expect(@player.number).to eq(@number)
|
|
75
75
|
expect(@player.position).to eq("Second baseman")
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
it "
|
|
78
|
+
it "updates an object with correct associations" do
|
|
79
79
|
@draft.reload
|
|
80
80
|
expect(@player.draft).to eq(@draft)
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
describe "update with has-many association" do
|
|
85
|
-
it "
|
|
85
|
+
it "is fillable and emptyable", :active_record => true do
|
|
86
86
|
RailsAdmin.config do |c|
|
|
87
87
|
c.audit_with :history
|
|
88
88
|
end
|
|
@@ -114,7 +114,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
114
114
|
page.driver.put(edit_path(:model_name => "player", :id => 1), :params => {:player => {:name => "Jackie Robinson", :number => 42, :position => "Second baseman"}})
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
-
it "
|
|
117
|
+
it "raises NotFound" do
|
|
118
118
|
expect(page.driver.status_code).to eq(404)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
@@ -133,7 +133,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
133
133
|
@player.reload
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
it "
|
|
136
|
+
it "shows an error message" do
|
|
137
137
|
# TODO: Mongoid 3.0.0 lacks ability of numericality validation on Integer field.
|
|
138
138
|
# This is caused by change in https://github.com/mongoid/mongoid/pull/1698
|
|
139
139
|
# I believe this should be a bug in Mongoid.
|
|
@@ -159,7 +159,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
159
159
|
@user.reload
|
|
160
160
|
end
|
|
161
161
|
|
|
162
|
-
it "
|
|
162
|
+
it "saves the serialized data" do
|
|
163
163
|
expect(@user.roles).to eq(['admin','user'])
|
|
164
164
|
end
|
|
165
165
|
end
|
|
@@ -171,7 +171,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
171
171
|
visit edit_path(:model_name => "field_test", :id => @field_test.id)
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
it "
|
|
174
|
+
it "saves the serialized data" do
|
|
175
175
|
fill_in "field_test[array_field]", :with => "[4, 2]"
|
|
176
176
|
fill_in "field_test[hash_field]", :with => "{ a: 6, b: 2 }"
|
|
177
177
|
click_button "Save"
|
|
@@ -181,7 +181,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
181
181
|
expect(@field_test.hash_field).to eq({ "a" => 6, "b" => 2 })
|
|
182
182
|
end
|
|
183
183
|
|
|
184
|
-
it "
|
|
184
|
+
it "clears data when empty string is passed" do
|
|
185
185
|
fill_in "field_test[array_field]", :with => ""
|
|
186
186
|
fill_in "field_test[hash_field]", :with => ""
|
|
187
187
|
click_button "Save"
|
|
@@ -204,7 +204,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
204
204
|
@ball.reload
|
|
205
205
|
end
|
|
206
206
|
|
|
207
|
-
it "
|
|
207
|
+
it "updates an object with correct attributes" do
|
|
208
208
|
expect(@ball.color).to eq("gray")
|
|
209
209
|
end
|
|
210
210
|
end
|
|
@@ -221,7 +221,7 @@ describe "RailsAdmin Basic Update" do
|
|
|
221
221
|
@hardball.reload
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
-
it "
|
|
224
|
+
it "updates an object with correct attributes" do
|
|
225
225
|
expect(@hardball.color).to eq("cyan")
|
|
226
226
|
end
|
|
227
227
|
end
|