rails_admin 0.1.1 → 0.1.2
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/README.md +8 -57
- data/app/assets/stylesheets/rails_admin/base/{README → README.txt} +1 -1
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +4 -2
- data/app/assets/stylesheets/rails_admin/themes/cerulean/theming.css.scss +2 -2
- data/app/helpers/rails_admin/application_helper.rb +22 -28
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +1 -1
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +1 -1
- data/lib/generators/rails_admin/install_generator.rb +4 -3
- data/lib/rails_admin/adapters/mongoid.rb +2 -1
- data/lib/rails_admin/engine.rb +1 -0
- data/lib/rails_admin/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +4 -4
- data/spec/controllers/main_controller_spec.rb +26 -26
- data/spec/dummy_app/config/routes.rb +1 -1
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/dummy_app/log/test.log +161818 -0
- data/spec/helpers/application_helper_spec.rb +46 -46
- data/spec/helpers/form_builder_spec.rb +2 -2
- data/spec/integration/authorization/cancan_spec.rb +22 -22
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +6 -6
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +16 -16
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +1 -1
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +6 -6
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +8 -8
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +10 -10
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +16 -16
- data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +3 -3
- data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +2 -2
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +1 -2
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +27 -27
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +45 -45
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +35 -38
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +2 -2
- data/spec/integration/history/rails_admin_history_spec.rb +9 -9
- data/spec/integration/rails_admin_spec.rb +4 -4
- data/spec/integration/relation_spec.rb +3 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/unit/abstract_model_spec.rb +10 -10
- data/spec/unit/active_record_extension_spec.rb +1 -1
- data/spec/unit/adapters/active_record/abstract_object_spec.rb +24 -24
- data/spec/unit/adapters/active_record_spec.rb +131 -132
- data/spec/unit/adapters/mongoid/abstract_object_spec.rb +5 -5
- data/spec/unit/adapters/mongoid_spec.rb +180 -180
- data/spec/unit/config/actions/base_spec.rb +6 -6
- data/spec/unit/config/actions_spec.rb +31 -32
- data/spec/unit/config/fields/base_spec.rb +69 -70
- data/spec/unit/config/fields/date_spec.rb +5 -5
- data/spec/unit/config/fields/datetime_spec.rb +4 -4
- 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 +12 -12
- data/spec/unit/config/sections_spec.rb +17 -17
- data/spec/unit/config_spec.rb +23 -24
- data/spec/unit/support/csv_converter_spec.rb +2 -2
- metadata +19 -3
@@ -10,8 +10,8 @@ describe RailsAdmin::ApplicationHelper do
|
|
10
10
|
it 'should return true if current_action, false otherwise' do
|
11
11
|
@action = RailsAdmin::Config::Actions.find(:index)
|
12
12
|
|
13
|
-
helper.current_action?(RailsAdmin::Config::Actions.find(:index)).
|
14
|
-
helper.current_action?(RailsAdmin::Config::Actions.find(:show)).
|
13
|
+
expect(helper.current_action?(RailsAdmin::Config::Actions.find(:index))).to be_true
|
14
|
+
expect(helper.current_action?(RailsAdmin::Config::Actions.find(:show))).not_to be_true
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -24,7 +24,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
helper.action(:my_custom_dashboard_key).
|
27
|
+
expect(helper.action(:my_custom_dashboard_key)).to be
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should return only visible actions' do
|
@@ -36,7 +36,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
helper.action(:dashboard).
|
39
|
+
expect(helper.action(:dashboard)).to be_nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should return only visible actions, passing all bindings' do
|
@@ -51,9 +51,9 @@ describe RailsAdmin::ApplicationHelper do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Team.new).
|
55
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Player.new).
|
56
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new).
|
54
|
+
expect(helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Team.new)).to be
|
55
|
+
expect(helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Player.new)).to be_nil
|
56
|
+
expect(helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new)).to be_nil
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -61,10 +61,10 @@ describe RailsAdmin::ApplicationHelper do
|
|
61
61
|
it 'should return actions by type' do
|
62
62
|
abstract_model = RailsAdmin::AbstractModel.new(Player)
|
63
63
|
object = FactoryGirl.create :player
|
64
|
-
helper.actions(:all, abstract_model, object).map(&:custom_key).
|
65
|
-
helper.actions(:root, abstract_model, object).map(&:custom_key).
|
66
|
-
helper.actions(:collection, abstract_model, object).map(&:custom_key).
|
67
|
-
helper.actions(:member, abstract_model, object).map(&:custom_key).
|
64
|
+
expect(helper.actions(:all, abstract_model, object).map(&:custom_key)).to eq([:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app])
|
65
|
+
expect(helper.actions(:root, abstract_model, object).map(&:custom_key)).to eq([:dashboard])
|
66
|
+
expect(helper.actions(:collection, abstract_model, object).map(&:custom_key)).to eq([:index, :new, :export, :bulk_delete, :history_index])
|
67
|
+
expect(helper.actions(:member, abstract_model, object).map(&:custom_key)).to eq([:show, :edit, :delete, :history_show, :show_in_app])
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should only return visible actions, passing bindings correctly' do
|
@@ -80,9 +80,9 @@ describe RailsAdmin::ApplicationHelper do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Team.new).map(&:custom_key).
|
84
|
-
helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Player.new).map(&:custom_key).
|
85
|
-
helper.actions(:all, RailsAdmin::AbstractModel.new(Player), Team.new).map(&:custom_key).
|
83
|
+
expect(helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Team.new).map(&:custom_key)).to eq([:test_bindings])
|
84
|
+
expect(helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Player.new).map(&:custom_key)).to eq([])
|
85
|
+
expect(helper.actions(:all, RailsAdmin::AbstractModel.new(Player), Team.new).map(&:custom_key)).to eq([])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -96,25 +96,25 @@ describe RailsAdmin::ApplicationHelper do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
helper.wording_for(:menu, :index).
|
99
|
+
expect(helper.wording_for(:menu, :index)).to eq("List")
|
100
100
|
end
|
101
101
|
|
102
102
|
it "passes correct bindings" do
|
103
|
-
helper.wording_for(:title, :edit, RailsAdmin::AbstractModel.new(Team), Team.new(:name => 'the avengers')).
|
103
|
+
expect(helper.wording_for(:title, :edit, RailsAdmin::AbstractModel.new(Team), Team.new(:name => 'the avengers'))).to eq("Edit Team 'the avengers'")
|
104
104
|
end
|
105
105
|
|
106
106
|
it "defaults correct bindings" do
|
107
107
|
@action = RailsAdmin::Config::Actions.find :edit
|
108
108
|
@abstract_model = RailsAdmin::AbstractModel.new(Team)
|
109
109
|
@object = Team.new(:name => 'the avengers')
|
110
|
-
helper.wording_for(:title).
|
110
|
+
expect(helper.wording_for(:title)).to eq("Edit Team 'the avengers'")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "does not try to use the wrong :label_metod" do
|
114
114
|
@abstract_model = RailsAdmin::AbstractModel.new(Draft)
|
115
115
|
@object = Draft.new
|
116
116
|
|
117
|
-
helper.wording_for(:link, :new, RailsAdmin::AbstractModel.new(Team)).
|
117
|
+
expect(helper.wording_for(:link, :new, RailsAdmin::AbstractModel.new(Team))).to eq("Add a new Team")
|
118
118
|
end
|
119
119
|
|
120
120
|
end
|
@@ -123,10 +123,10 @@ describe RailsAdmin::ApplicationHelper do
|
|
123
123
|
it "gives us a breadcrumb" do
|
124
124
|
@action = RailsAdmin::Config::Actions.find(:edit, {:abstract_model => RailsAdmin::AbstractModel.new(Team), :object => Team.new(:name => 'the avengers')})
|
125
125
|
bc = helper.breadcrumb
|
126
|
-
bc.
|
127
|
-
bc.
|
128
|
-
bc.
|
129
|
-
bc.
|
126
|
+
expect(bc).to match /Dashboard/ # dashboard
|
127
|
+
expect(bc).to match /Teams/ # list
|
128
|
+
expect(bc).to match /the avengers/ # show
|
129
|
+
expect(bc).to match /Edit/ # current (edit)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -155,14 +155,14 @@ describe RailsAdmin::ApplicationHelper do
|
|
155
155
|
@abstract_model = RailsAdmin::AbstractModel.new(Team)
|
156
156
|
@object = Team.new(:name => 'the avengers')
|
157
157
|
|
158
|
-
helper.menu_for(:root).
|
159
|
-
helper.menu_for(:collection, @abstract_model).
|
160
|
-
helper.menu_for(:member, @abstract_model, @object).
|
158
|
+
expect(helper.menu_for(:root)).to match /Dashboard/
|
159
|
+
expect(helper.menu_for(:collection, @abstract_model)).to match /List/
|
160
|
+
expect(helper.menu_for(:member, @abstract_model, @object)).to match /Show/
|
161
161
|
|
162
162
|
@abstract_model = RailsAdmin::AbstractModel.new(Player)
|
163
163
|
@object = Player.new
|
164
|
-
helper.menu_for(:collection, @abstract_model).
|
165
|
-
helper.menu_for(:member, @abstract_model, @object).
|
164
|
+
expect(helper.menu_for(:collection, @abstract_model)).not_to match /List/
|
165
|
+
expect(helper.menu_for(:member, @abstract_model, @object)).not_to match /Show/
|
166
166
|
end
|
167
167
|
|
168
168
|
it "excludes non-get actions" do
|
@@ -175,7 +175,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
@action = RailsAdmin::Config::Actions.find :dashboard
|
178
|
-
helper.menu_for(:root).
|
178
|
+
expect(helper.menu_for(:root)).not_to match /Dashboard/
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -184,7 +184,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
184
184
|
RailsAdmin.config do |config|
|
185
185
|
config.included_models = [Ball, Comment]
|
186
186
|
end
|
187
|
-
helper.main_navigation.
|
187
|
+
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Balls).*(Comments)/m
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should not draw empty navigation labels' do
|
@@ -197,8 +197,8 @@ describe RailsAdmin::ApplicationHelper do
|
|
197
197
|
label_plural 'Confirmed'
|
198
198
|
end
|
199
199
|
end
|
200
|
-
helper.main_navigation.
|
201
|
-
helper.main_navigation.
|
200
|
+
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Balls).*(Commentz).*(Confirmed)/m
|
201
|
+
expect(helper.main_navigation).not_to match /(nav\-header).*(Navigation).*(Balls).*(Commentz).*(Confirmed).*(Comment)/m
|
202
202
|
end
|
203
203
|
|
204
204
|
it 'should not show unvisible models' do
|
@@ -209,8 +209,8 @@ describe RailsAdmin::ApplicationHelper do
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
result = helper.main_navigation
|
212
|
-
result.
|
213
|
-
result.
|
212
|
+
expect(result).to match /(nav\-header).*(Navigation).*(Balls)/m
|
213
|
+
expect(result).not_to match "Comments"
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should show children of hidden models" do # https://github.com/sferik/rails_admin/issues/978
|
@@ -220,14 +220,14 @@ describe RailsAdmin::ApplicationHelper do
|
|
220
220
|
hide
|
221
221
|
end
|
222
222
|
end
|
223
|
-
helper.main_navigation.
|
223
|
+
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Hardballs)/m
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should show children of excluded models" do
|
227
227
|
RailsAdmin.config do |config|
|
228
228
|
config.included_models = [Hardball]
|
229
229
|
end
|
230
|
-
helper.main_navigation.
|
230
|
+
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Hardballs)/m
|
231
231
|
end
|
232
232
|
|
233
233
|
it 'should "nest" in navigation label' do
|
@@ -237,7 +237,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
237
237
|
navigation_label 'commentable'
|
238
238
|
end
|
239
239
|
end
|
240
|
-
helper.main_navigation.
|
240
|
+
expect(helper.main_navigation).to match /(nav\-header).*(commentable).*(Comments)/m
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should "nest" in parent model' do
|
@@ -247,19 +247,19 @@ describe RailsAdmin::ApplicationHelper do
|
|
247
247
|
parent Player
|
248
248
|
end
|
249
249
|
end
|
250
|
-
helper.main_navigation.
|
250
|
+
expect(helper.main_navigation).to match /(Players).*(nav\-level\-1).*(Comments)/m
|
251
251
|
end
|
252
252
|
|
253
253
|
it 'should order' do
|
254
254
|
RailsAdmin.config do |config|
|
255
255
|
config.included_models = [Player, Comment]
|
256
256
|
end
|
257
|
-
helper.main_navigation.
|
257
|
+
expect(helper.main_navigation).to match /(Comments).*(Players)/m
|
258
258
|
|
259
259
|
RailsAdmin.config(Comment) do
|
260
260
|
weight 1
|
261
261
|
end
|
262
|
-
helper.main_navigation.
|
262
|
+
expect(helper.main_navigation).to match /(Players).*(Comments)/m
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
@@ -268,7 +268,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
268
268
|
RailsAdmin.config do |config|
|
269
269
|
config.navigation_static_links = {}
|
270
270
|
end
|
271
|
-
helper.static_navigation.
|
271
|
+
expect(helper.static_navigation).to be_empty
|
272
272
|
end
|
273
273
|
|
274
274
|
it 'should show links if defined' do
|
@@ -277,7 +277,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
277
277
|
'Test Link' => 'http://www.google.com'
|
278
278
|
}
|
279
279
|
end
|
280
|
-
helper.static_navigation.
|
280
|
+
expect(helper.static_navigation).to match /Test Link/
|
281
281
|
end
|
282
282
|
|
283
283
|
it 'should show default header if navigation_static_label not defined in config' do
|
@@ -286,7 +286,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
286
286
|
'Test Link' => 'http://www.google.com'
|
287
287
|
}
|
288
288
|
end
|
289
|
-
helper.static_navigation.
|
289
|
+
expect(helper.static_navigation).to match I18n.t('admin.misc.navigation_static_label')
|
290
290
|
end
|
291
291
|
|
292
292
|
it 'should show custom header if defined' do
|
@@ -296,7 +296,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
296
296
|
'Test Link' => 'http://www.google.com'
|
297
297
|
}
|
298
298
|
end
|
299
|
-
helper.static_navigation.
|
299
|
+
expect(helper.static_navigation).to match /Test Header/
|
300
300
|
end
|
301
301
|
end
|
302
302
|
|
@@ -319,10 +319,10 @@ describe RailsAdmin::ApplicationHelper do
|
|
319
319
|
end
|
320
320
|
@action = RailsAdmin::Config::Actions.find :index
|
321
321
|
result = helper.bulk_menu(RailsAdmin::AbstractModel.new(Team))
|
322
|
-
result.
|
323
|
-
result.
|
322
|
+
expect(result).to match "zorg_action"
|
323
|
+
expect(result).to match "blub"
|
324
324
|
|
325
|
-
helper.bulk_menu(RailsAdmin::AbstractModel.new(Player)).
|
325
|
+
expect(helper.bulk_menu(RailsAdmin::AbstractModel.new(Player))).not_to match "blub"
|
326
326
|
end
|
327
327
|
end
|
328
328
|
end
|
@@ -10,8 +10,8 @@ describe "RailsAdmin::FormBuilder" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should not add additional error div from default ActionView::Base.field_error_proc' do
|
13
|
-
@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) }).
|
14
|
-
@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) }).
|
13
|
+
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).not_to have_css(".field_with_errors")
|
14
|
+
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).to have_css(".control-group.error")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -18,8 +18,8 @@ class Ability
|
|
18
18
|
can :access, :rails_admin
|
19
19
|
can :manage, :all
|
20
20
|
can :show_in_app, :all
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
|
23
23
|
# fix for buggy and inconsistent behaviour in Cancan 1.6.8 => https://github.com/ryanb/cancan/issues/721
|
24
24
|
if CI_ORM != :mongoid
|
25
25
|
cannot [:update, :destroy], Player
|
@@ -76,9 +76,9 @@ describe "RailsAdmin CanCan Authorization" do
|
|
76
76
|
|
77
77
|
it "GET /admin should show Player but not League" do
|
78
78
|
visit dashboard_path
|
79
|
-
body.
|
80
|
-
body.
|
81
|
-
body.
|
79
|
+
expect(body).to have_content("Player")
|
80
|
+
expect(body).not_to have_content("League")
|
81
|
+
expect(body).not_to have_content("Add new")
|
82
82
|
end
|
83
83
|
|
84
84
|
it "GET /admin/player should render successfully but not list retired players and not show new, edit, or delete actions" do
|
@@ -136,10 +136,10 @@ describe "RailsAdmin CanCan Authorization" do
|
|
136
136
|
should_not have_content("Edit")
|
137
137
|
|
138
138
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
139
|
-
@player.name.
|
140
|
-
@player.number.
|
141
|
-
@player.position.
|
142
|
-
@player.
|
139
|
+
expect(@player.name).to eq("Jackie Robinson")
|
140
|
+
expect(@player.number).to eq(42)
|
141
|
+
expect(@player.position).to eq("Second baseman")
|
142
|
+
expect(@player).to be_suspended # suspended is inherited behavior based on permission
|
143
143
|
end
|
144
144
|
|
145
145
|
it "GET /admin/player/1/edit should raise access denied" do
|
@@ -167,7 +167,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
167
167
|
fill_in "player[name]", :with => "Jackie Robinson"
|
168
168
|
click_button "Save"
|
169
169
|
@player.reload
|
170
|
-
@player.name.
|
170
|
+
expect(@player.name).to eq("Jackie Robinson")
|
171
171
|
end
|
172
172
|
|
173
173
|
it "GET /admin/player/1/edit with retired player should raise access denied" do
|
@@ -263,7 +263,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
263
263
|
|
264
264
|
click_button "Yes, I'm sure"
|
265
265
|
|
266
|
-
@player_model.get(player_id).
|
266
|
+
expect(@player_model.get(player_id)).to be_nil
|
267
267
|
end
|
268
268
|
|
269
269
|
it "GET /admin/player/1/delete with retired player should raise access denied" do
|
@@ -287,8 +287,8 @@ describe "RailsAdmin CanCan Authorization" do
|
|
287
287
|
retired_player = FactoryGirl.create :player, :retired => true
|
288
288
|
|
289
289
|
page.driver.delete(bulk_delete_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
290
|
-
@player_model.get(active_player.id).
|
291
|
-
@player_model.get(retired_player.id).
|
290
|
+
expect(@player_model.get(active_player.id)).to be_nil
|
291
|
+
expect(@player_model.get(retired_player.id)).not_to be_nil
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
@@ -299,7 +299,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
299
299
|
retired_player = FactoryGirl.create :player, :retired => true
|
300
300
|
|
301
301
|
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
302
|
-
|
302
|
+
|
303
303
|
should have_content(active_player.name)
|
304
304
|
should_not have_content(retired_player.name)
|
305
305
|
end
|
@@ -310,8 +310,8 @@ describe "RailsAdmin CanCan Authorization" do
|
|
310
310
|
retired_player = FactoryGirl.create :player, :retired => true
|
311
311
|
|
312
312
|
page.driver.delete(bulk_delete_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
313
|
-
@player_model.get(active_player.id).
|
314
|
-
@player_model.get(retired_player.id).
|
313
|
+
expect(@player_model.get(active_player.id)).to be_nil
|
314
|
+
expect(@player_model.get(retired_player.id)).not_to be_nil
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
@@ -329,36 +329,36 @@ describe "RailsAdmin CanCan Authorization" do
|
|
329
329
|
|
330
330
|
it "GET /admin/team should render successfully" do
|
331
331
|
visit index_path(:model_name => "team")
|
332
|
-
page.status_code.
|
332
|
+
expect(page.status_code).to eq(200)
|
333
333
|
end
|
334
334
|
|
335
335
|
it "GET /admin/player/new should render successfully" do
|
336
336
|
visit new_path(:model_name => "player")
|
337
|
-
page.status_code.
|
337
|
+
expect(page.status_code).to eq(200)
|
338
338
|
end
|
339
339
|
|
340
340
|
it "GET /admin/player/1/edit should render successfully" do
|
341
341
|
@player = FactoryGirl.create :player
|
342
342
|
visit edit_path(:model_name => "player", :id => @player.id)
|
343
|
-
page.status_code.
|
343
|
+
expect(page.status_code).to eq(200)
|
344
344
|
end
|
345
345
|
|
346
346
|
it "GET /admin/player/1/edit with retired player should render successfully" do
|
347
347
|
@player = FactoryGirl.create :player, :retired => true
|
348
348
|
visit edit_path(:model_name => "player", :id => @player.id)
|
349
|
-
page.status_code.
|
349
|
+
expect(page.status_code).to eq(200)
|
350
350
|
end
|
351
351
|
|
352
352
|
it "GET /admin/player/1/delete should render successfully" do
|
353
353
|
@player = FactoryGirl.create :player
|
354
354
|
visit delete_path(:model_name => "player", :id => @player.id)
|
355
|
-
page.status_code.
|
355
|
+
expect(page.status_code).to eq(200)
|
356
356
|
end
|
357
357
|
|
358
358
|
it "GET /admin/player/1/delete with retired player should render successfully" do
|
359
359
|
@player = FactoryGirl.create :player, :retired => true
|
360
360
|
visit delete_path(:model_name => "player", :id => @player.id)
|
361
|
-
page.status_code.
|
361
|
+
expect(page.status_code).to eq(200)
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
@@ -15,15 +15,15 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should not contain deleted records" do
|
18
|
-
RailsAdmin::AbstractModel.new("Player").count.
|
19
|
-
RailsAdmin::History.count.
|
18
|
+
expect(RailsAdmin::AbstractModel.new("Player").count).to eq(1)
|
19
|
+
expect(RailsAdmin::History.count).to eq(@delete_ids.count)
|
20
20
|
RailsAdmin::History.all.each do |history|
|
21
|
-
history.table.
|
21
|
+
expect(history.table).to eq("Player")
|
22
22
|
end
|
23
23
|
RailsAdmin::History.all.each do |history|
|
24
|
-
@delete_ids.
|
24
|
+
expect(@delete_ids).to include(history.item)
|
25
25
|
end
|
26
|
-
page.
|
26
|
+
expect(page).to have_selector(".alert-success", :text => "2 Players successfully deleted")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -36,7 +36,7 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should not delete records" do
|
39
|
-
RailsAdmin::AbstractModel.new("Player").count.
|
39
|
+
expect(RailsAdmin::AbstractModel.new("Player").count).to eq(3)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -14,9 +14,9 @@ describe "RailsAdmin Basic Create" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should create an object with correct attributes" do
|
17
|
-
@player.name.
|
18
|
-
@player.number.
|
19
|
-
@player.position.
|
17
|
+
expect(@player.name).to eq("Jackie Robinson")
|
18
|
+
expect(@player.number).to eq(42)
|
19
|
+
expect(@player.position).to eq("Second baseman")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -33,9 +33,9 @@ describe "RailsAdmin Basic Create" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should create an object with correct attributes" do
|
36
|
-
@player.name.
|
37
|
-
@player.number.
|
38
|
-
@player.position.
|
36
|
+
expect(@player.name).to eq("Jackie Robinson")
|
37
|
+
expect(@player.number).to eq(42)
|
38
|
+
expect(@player.position).to eq("Second baseman")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -52,9 +52,9 @@ describe "RailsAdmin Basic Create" do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should create an object with correct attributes" do
|
55
|
-
@player.name.
|
56
|
-
@player.number.
|
57
|
-
@player.position.
|
55
|
+
expect(@player.name).to eq("Jackie Robinson")
|
56
|
+
expect(@player.number).to eq(42)
|
57
|
+
expect(@player.position).to eq("Second baseman")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -69,7 +69,7 @@ describe "RailsAdmin Basic Create" do
|
|
69
69
|
|
70
70
|
it "should create an object with correct associations" do
|
71
71
|
@draft.reload
|
72
|
-
@player.draft.
|
72
|
+
expect(@player.draft).to eq(@draft)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -82,9 +82,9 @@ describe "RailsAdmin Basic Create" do
|
|
82
82
|
|
83
83
|
it "should create an object with correct associations" do
|
84
84
|
@divisions[0].reload
|
85
|
-
@league.divisions.
|
86
|
-
@league.divisions.
|
87
|
-
@league.divisions.
|
85
|
+
expect(@league.divisions).to include(@divisions[0])
|
86
|
+
expect(@league.divisions).not_to include(@divisions[1])
|
87
|
+
expect(@league.divisions).not_to include(@divisions[2])
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -97,9 +97,9 @@ describe "RailsAdmin Basic Create" do
|
|
97
97
|
|
98
98
|
it "should create an object with correct associations" do
|
99
99
|
@teams[0].reload
|
100
|
-
@fan.teams.
|
101
|
-
@fan.teams.
|
102
|
-
@fan.teams.
|
100
|
+
expect(@fan.teams).to include(@teams[0])
|
101
|
+
expect(@fan.teams).not_to include(@teams[1])
|
102
|
+
expect(@fan.teams).not_to include(@teams[2])
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|