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
|
@@ -6,8 +6,8 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
6
6
|
controller.stub(:authorized?).and_return(true)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
describe
|
|
10
|
-
it
|
|
9
|
+
describe "#current_action?" do
|
|
10
|
+
it "returns true if current_action, false otherwise" do
|
|
11
11
|
@action = RailsAdmin::Config::Actions.find(:index)
|
|
12
12
|
|
|
13
13
|
expect(helper.current_action?(RailsAdmin::Config::Actions.find(:index))).to be_true
|
|
@@ -15,8 +15,8 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
describe
|
|
19
|
-
it
|
|
18
|
+
describe "#action" do
|
|
19
|
+
it "returns action by :custom_key" do
|
|
20
20
|
RailsAdmin.config do |config|
|
|
21
21
|
config.actions do
|
|
22
22
|
dashboard do
|
|
@@ -27,7 +27,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
27
27
|
expect(helper.action(:my_custom_dashboard_key)).to be
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it
|
|
30
|
+
it "returns only visible actions" do
|
|
31
31
|
RailsAdmin.config do |config|
|
|
32
32
|
config.actions do
|
|
33
33
|
dashboard do
|
|
@@ -39,7 +39,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
39
39
|
expect(helper.action(:dashboard)).to be_nil
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
it
|
|
42
|
+
it "returns only visible actions, passing all bindings" do
|
|
43
43
|
RailsAdmin.config do |config|
|
|
44
44
|
config.actions do
|
|
45
45
|
member :test_bindings do
|
|
@@ -58,7 +58,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
describe "#actions" do
|
|
61
|
-
it
|
|
61
|
+
it "returns actions by type" do
|
|
62
62
|
abstract_model = RailsAdmin::AbstractModel.new(Player)
|
|
63
63
|
object = FactoryGirl.create :player
|
|
64
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])
|
|
@@ -67,7 +67,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
67
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
|
-
it
|
|
70
|
+
it "only returns visible actions, passing bindings correctly" do
|
|
71
71
|
RailsAdmin.config do |config|
|
|
72
72
|
config.actions do
|
|
73
73
|
member :test_bindings do
|
|
@@ -131,7 +131,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
describe "#menu_for" do
|
|
134
|
-
it
|
|
134
|
+
it "passes model and object as bindings and generates a menu, excluding non-get actions" do
|
|
135
135
|
RailsAdmin.config do |config|
|
|
136
136
|
config.actions do
|
|
137
137
|
dashboard
|
|
@@ -180,14 +180,14 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
describe "#main_navigation" do
|
|
183
|
-
it
|
|
183
|
+
it "shows included models" do
|
|
184
184
|
RailsAdmin.config do |config|
|
|
185
185
|
config.included_models = [Ball, Comment]
|
|
186
186
|
end
|
|
187
187
|
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Balls).*(Comments)/m
|
|
188
188
|
end
|
|
189
189
|
|
|
190
|
-
it
|
|
190
|
+
it "does not draw empty navigation labels" do
|
|
191
191
|
RailsAdmin.config do |config|
|
|
192
192
|
config.included_models = [Ball, Comment, Comment::Confirmed]
|
|
193
193
|
config.model Comment do
|
|
@@ -201,7 +201,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
201
201
|
expect(helper.main_navigation).not_to match /(nav\-header).*(Navigation).*(Balls).*(Commentz).*(Confirmed).*(Comment)/m
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
it
|
|
204
|
+
it "does not show unvisible models" do
|
|
205
205
|
RailsAdmin.config do |config|
|
|
206
206
|
config.included_models = [Ball, Comment]
|
|
207
207
|
config.model Comment do
|
|
@@ -213,7 +213,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
213
213
|
expect(result).not_to match "Comments"
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
it "
|
|
216
|
+
it "shows children of hidden models" do # https://github.com/sferik/rails_admin/issues/978
|
|
217
217
|
RailsAdmin.config do |config|
|
|
218
218
|
config.included_models = [Ball, Hardball]
|
|
219
219
|
config.model Ball do
|
|
@@ -223,14 +223,14 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
223
223
|
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Hardballs)/m
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
-
it "
|
|
226
|
+
it "shows children of excluded models" do
|
|
227
227
|
RailsAdmin.config do |config|
|
|
228
228
|
config.included_models = [Hardball]
|
|
229
229
|
end
|
|
230
230
|
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Hardballs)/m
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
-
it
|
|
233
|
+
it "nests in navigation label" do
|
|
234
234
|
RailsAdmin.config do |config|
|
|
235
235
|
config.included_models = [Comment]
|
|
236
236
|
config.model Comment do
|
|
@@ -240,17 +240,17 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
240
240
|
expect(helper.main_navigation).to match /(nav\-header).*(commentable).*(Comments)/m
|
|
241
241
|
end
|
|
242
242
|
|
|
243
|
-
it
|
|
243
|
+
it "nests in parent model" do
|
|
244
244
|
RailsAdmin.config do |config|
|
|
245
245
|
config.included_models = [Player, Comment]
|
|
246
246
|
config.model Comment do
|
|
247
247
|
parent Player
|
|
248
248
|
end
|
|
249
249
|
end
|
|
250
|
-
expect(helper.main_navigation).to match /(Players).*(nav\-level\-1).*(Comments)/m
|
|
250
|
+
expect(helper.main_navigation).to match /(Players).* (nav\-level\-1).*(Comments)/m
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
it
|
|
253
|
+
it "orders" do
|
|
254
254
|
RailsAdmin.config do |config|
|
|
255
255
|
config.included_models = [Player, Comment]
|
|
256
256
|
end
|
|
@@ -263,15 +263,15 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
263
263
|
end
|
|
264
264
|
end
|
|
265
265
|
|
|
266
|
-
describe
|
|
267
|
-
it
|
|
266
|
+
describe "#static_navigation" do
|
|
267
|
+
it "shows not show static nav if no static links defined" do
|
|
268
268
|
RailsAdmin.config do |config|
|
|
269
269
|
config.navigation_static_links = {}
|
|
270
270
|
end
|
|
271
271
|
expect(helper.static_navigation).to be_empty
|
|
272
272
|
end
|
|
273
273
|
|
|
274
|
-
it
|
|
274
|
+
it "shows links if defined" do
|
|
275
275
|
RailsAdmin.config do |config|
|
|
276
276
|
config.navigation_static_links = {
|
|
277
277
|
'Test Link' => 'http://www.google.com'
|
|
@@ -280,7 +280,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
280
280
|
expect(helper.static_navigation).to match /Test Link/
|
|
281
281
|
end
|
|
282
282
|
|
|
283
|
-
it
|
|
283
|
+
it "shows default header if navigation_static_label not defined in config" do
|
|
284
284
|
RailsAdmin.config do |config|
|
|
285
285
|
config.navigation_static_links = {
|
|
286
286
|
'Test Link' => 'http://www.google.com'
|
|
@@ -289,7 +289,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
289
289
|
expect(helper.static_navigation).to match I18n.t('admin.misc.navigation_static_label')
|
|
290
290
|
end
|
|
291
291
|
|
|
292
|
-
it
|
|
292
|
+
it "shows custom header if defined" do
|
|
293
293
|
RailsAdmin.config do |config|
|
|
294
294
|
config.navigation_static_label = "Test Header"
|
|
295
295
|
config.navigation_static_links = {
|
|
@@ -301,7 +301,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
|
301
301
|
end
|
|
302
302
|
|
|
303
303
|
describe "#bulk_menu" do
|
|
304
|
-
it
|
|
304
|
+
it "includes all visible bulkable actions" do
|
|
305
305
|
RailsAdmin.config do |config|
|
|
306
306
|
config.actions do
|
|
307
307
|
index
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "RailsAdmin::FormBuilder" do
|
|
4
|
-
describe
|
|
4
|
+
describe "#generate" do
|
|
5
5
|
before do
|
|
6
6
|
helper.stub(:authorized?).and_return(true)
|
|
7
7
|
(@object = Player.new).save
|
|
8
8
|
@builder = RailsAdmin::FormBuilder.new(:player, @object, helper, {}, nil)
|
|
9
9
|
@builder.stub(:field_for).and_return("field")
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
it
|
|
11
|
+
|
|
12
|
+
it "does not add additional error div from default ActionView::Base.field_error_proc" do
|
|
13
13
|
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).not_to have_css(".field_with_errors")
|
|
14
14
|
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).to have_css(".control-group.error")
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
end
|
|
17
|
+
end
|
|
@@ -185,7 +185,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
describe "with history role" do
|
|
188
|
-
it
|
|
188
|
+
it "shows links to history action" do
|
|
189
189
|
|
|
190
190
|
@user.update_attributes(:roles => [:admin, :read_player, :history_player])
|
|
191
191
|
@player = FactoryGirl.create :player
|
|
@@ -206,7 +206,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
describe "with show in app role" do
|
|
209
|
-
it
|
|
209
|
+
it "shows links to show in app action" do
|
|
210
210
|
|
|
211
211
|
@user.update_attributes(:roles => [:admin, :read_player, :show_in_app_player])
|
|
212
212
|
@player = FactoryGirl.create :player
|
|
@@ -229,7 +229,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
describe "with all roles" do
|
|
232
|
-
it
|
|
232
|
+
it "shows links to all actions" do
|
|
233
233
|
|
|
234
234
|
@user.update_attributes(:roles => [:admin, :manage_player])
|
|
235
235
|
@player = FactoryGirl.create :player
|
|
@@ -9,14 +9,14 @@ describe "RailsAdmin Basic Bulk Action" do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe "bulk_delete" do
|
|
12
|
-
it
|
|
12
|
+
it "shows names of to-be-deleted players" do
|
|
13
13
|
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => @players.map(&:id)))
|
|
14
14
|
@players.each { |player| should have_content(player.name) }
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe "bulk_export" do
|
|
19
|
-
it
|
|
19
|
+
it "shows form for export" do
|
|
20
20
|
visit index_path(:model_name => "player")
|
|
21
21
|
click_link "Export found Players"
|
|
22
22
|
@players.each { |player| should have_content("Select fields to export") }
|
|
@@ -14,7 +14,7 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
|
14
14
|
click_button "Yes, I'm sure"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
it "
|
|
17
|
+
it "does not contain deleted records" do
|
|
18
18
|
expect(RailsAdmin::AbstractModel.new("Player").count).to eq(1)
|
|
19
19
|
expect(RailsAdmin::History.count).to eq(@delete_ids.count)
|
|
20
20
|
RailsAdmin::History.all.each do |history|
|
|
@@ -35,7 +35,7 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
|
35
35
|
click_button "Cancel"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
it "
|
|
38
|
+
it "does not delete records" do
|
|
39
39
|
expect(RailsAdmin::AbstractModel.new("Player").count).to eq(3)
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -13,7 +13,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
13
13
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it "
|
|
16
|
+
it "creates an object with correct attributes" do
|
|
17
17
|
expect(@player.name).to eq("Jackie Robinson")
|
|
18
18
|
expect(@player.number).to eq(42)
|
|
19
19
|
expect(@player.position).to eq("Second baseman")
|
|
@@ -32,7 +32,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
32
32
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
it "
|
|
35
|
+
it "creates 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")
|
|
@@ -51,7 +51,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
51
51
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
it "
|
|
54
|
+
it "creates an object with correct attributes" do
|
|
55
55
|
expect(@player.name).to eq("Jackie Robinson")
|
|
56
56
|
expect(@player.number).to eq(42)
|
|
57
57
|
expect(@player.position).to eq("Second baseman")
|
|
@@ -67,7 +67,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
67
67
|
@player = RailsAdmin::AbstractModel.new("Player").all.last # first is created by FactoryGirl
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
it "
|
|
70
|
+
it "creates an object with correct associations" do
|
|
71
71
|
@draft.reload
|
|
72
72
|
expect(@player.draft).to eq(@draft)
|
|
73
73
|
end
|
|
@@ -80,7 +80,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
80
80
|
@league = RailsAdmin::AbstractModel.new("League").all.last
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
it "
|
|
83
|
+
it "creates an object with correct associations" do
|
|
84
84
|
@divisions[0].reload
|
|
85
85
|
expect(@league.divisions).to include(@divisions[0])
|
|
86
86
|
expect(@league.divisions).not_to include(@divisions[1])
|
|
@@ -95,7 +95,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
95
95
|
@fan = RailsAdmin::AbstractModel.new("Fan").first
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
it "
|
|
98
|
+
it "creates an object with correct associations" do
|
|
99
99
|
@teams[0].reload
|
|
100
100
|
expect(@fan.teams).to include(@teams[0])
|
|
101
101
|
expect(@fan.teams).not_to include(@teams[1])
|
|
@@ -111,7 +111,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
111
111
|
page.driver.post new_path(:model_name => "player", :player => {:name => @player.name, :number => @player.number.to_s, :position => @player.position, :team_id => @team.id})
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
it "
|
|
114
|
+
it "shows an error message" do
|
|
115
115
|
should have_content("There is already a player with that number on this team")
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -121,7 +121,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
121
121
|
page.driver.post(new_path(:model_name => "player", :id => 1), :params => {:player => {}})
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
it "
|
|
124
|
+
it "shows an error message" do
|
|
125
125
|
should have_content("Player failed to be created")
|
|
126
126
|
should have_selector "form", :action => "/admin/players"
|
|
127
127
|
end
|
|
@@ -134,7 +134,7 @@ describe "RailsAdmin Basic Create" do
|
|
|
134
134
|
click_button "Save and add another"
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
it "
|
|
137
|
+
it "shows error base error message in flash" do
|
|
138
138
|
should have_content("Player failed to be created. Player is cheating")
|
|
139
139
|
end
|
|
140
140
|
end
|
|
@@ -4,7 +4,7 @@ describe "RailsAdmin Namespaced Model Create" do
|
|
|
4
4
|
|
|
5
5
|
subject { page }
|
|
6
6
|
|
|
7
|
-
it
|
|
7
|
+
it "creates object with correct attributes" do
|
|
8
8
|
visit new_path(:model_name => "cms~basic_page")
|
|
9
9
|
|
|
10
10
|
fill_in "cms_basic_page[title]", :with => "Hello"
|
|
@@ -5,7 +5,7 @@ describe "RailsAdmin Basic Delete" do
|
|
|
5
5
|
subject { page }
|
|
6
6
|
|
|
7
7
|
describe "delete" do
|
|
8
|
-
it "
|
|
8
|
+
it "shows \"Delete model\"" do
|
|
9
9
|
@draft = FactoryGirl.create :draft
|
|
10
10
|
@player = @draft.player
|
|
11
11
|
@comment = @player.comments.create
|
|
@@ -22,7 +22,7 @@ describe "RailsAdmin Basic Delete" do
|
|
|
22
22
|
visit delete_path(:model_name => "player", :id => 1)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
it "
|
|
25
|
+
it "raises NotFound" do
|
|
26
26
|
expect(page.driver.status_code).to eq(404)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -40,7 +40,7 @@ describe "RailsAdmin Basic Delete" do
|
|
|
40
40
|
visit delete_path(:model_name => "player", :id => @player.id)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
it "
|
|
43
|
+
it "shows \"Delete model\"" do
|
|
44
44
|
should have_content("delete this player")
|
|
45
45
|
should_not have_selector("a[href=\"/admin/player/#{@player.id}\"]")
|
|
46
46
|
should_not have_selector("a[href=\"/admin/draft/#{@draft.id}\"]")
|
|
@@ -55,7 +55,7 @@ describe "RailsAdmin Basic Delete" do
|
|
|
55
55
|
visit delete_path(:model_name => "player", :id => @player.id)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
it "
|
|
58
|
+
it "shows \"Delete model\"" do
|
|
59
59
|
should_not have_content("Routing Error")
|
|
60
60
|
should have_content("delete this player")
|
|
61
61
|
should have_link(@player.name, :href => "/admin/player/#{@player.id}")
|
|
@@ -12,11 +12,11 @@ describe "RailsAdmin Basic Destroy" do
|
|
|
12
12
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
it "
|
|
15
|
+
it "destroys an object" do
|
|
16
16
|
expect(@player).to be_nil
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
it "
|
|
19
|
+
it "shows success message" do
|
|
20
20
|
should have_content('Player successfully deleted')
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -29,11 +29,11 @@ describe "RailsAdmin Basic Destroy" do
|
|
|
29
29
|
click_button "Yes, I'm sure"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
it "
|
|
32
|
+
it "does not destroy an object" do
|
|
33
33
|
expect(@player.reload).to be
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
it "
|
|
36
|
+
it "shows error message" do
|
|
37
37
|
should have_content('Player failed to be deleted')
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -46,7 +46,7 @@ describe "RailsAdmin Basic Destroy" do
|
|
|
46
46
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
it "
|
|
49
|
+
it "does not destroy an object" do
|
|
50
50
|
expect(@player).to be
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -56,13 +56,13 @@ describe "RailsAdmin Basic Destroy" do
|
|
|
56
56
|
page.driver.delete(delete_path(:model_name => "player", :id => 1))
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
it "
|
|
59
|
+
it "raises NotFound" do
|
|
60
60
|
expect(page.driver.status_code).to eq(404)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
describe
|
|
65
|
-
it
|
|
64
|
+
describe "destroy from show page" do
|
|
65
|
+
it "redirects to the index instead of trying to show the deleted object" do
|
|
66
66
|
@player = FactoryGirl.create :player
|
|
67
67
|
visit show_path(:model_name => 'player', :id => @player.id)
|
|
68
68
|
visit delete_path(:model_name => "player", :id => @player.id)
|
|
@@ -71,7 +71,7 @@ describe "RailsAdmin Basic Destroy" do
|
|
|
71
71
|
expect(URI.parse(page.current_url).path).to eq(index_path(:model_name => 'player'))
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
it
|
|
74
|
+
it "redirects back to the object on error" do
|
|
75
75
|
Player.any_instance.stub(:destroy_hook).and_return false
|
|
76
76
|
@player = FactoryGirl.create :player
|
|
77
77
|
visit show_path(:model_name => 'player', :id => @player.id)
|
|
@@ -10,16 +10,16 @@ describe "RailsAdmin Basic Edit" do
|
|
|
10
10
|
visit edit_path(:model_name => "player", :id => @player.id)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
it "
|
|
13
|
+
it "shows \"Edit model\"" do
|
|
14
14
|
should have_content("Edit Player")
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
it "
|
|
17
|
+
it "shows required fields as \"Required\"" do
|
|
18
18
|
should have_selector("div", :text => /Name\s*Required/)
|
|
19
19
|
should have_selector("div", :text => /Number\s*Required/)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
it "
|
|
22
|
+
it "shows non-required fields as \"Optional\"" do
|
|
23
23
|
expect(find("#player_position_field .help-block")).to have_content("Optional")
|
|
24
24
|
expect(find("#player_born_on_field .help-block")).to have_content("Optional")
|
|
25
25
|
expect(find("#player_notes_field .help-block")).to have_content("Optional")
|
|
@@ -27,13 +27,13 @@ describe "RailsAdmin Basic Edit" do
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe "association with inverse_of option" do
|
|
30
|
-
it "
|
|
30
|
+
it "adds a related id to the belongs_to create team link" do
|
|
31
31
|
@player = FactoryGirl.create :player
|
|
32
32
|
visit edit_path(:model_name => "player", :id => @player.id)
|
|
33
33
|
should have_selector("a", :href => 'admin/teams/new?associations[players]=' + @player.id.to_s)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
it "
|
|
36
|
+
it "adds a related id to the has_many create team link" do
|
|
37
37
|
@team = FactoryGirl.create :team
|
|
38
38
|
visit edit_path(:model_name => "team", :id => @team.id)
|
|
39
39
|
should have_selector("a", :href => 'admin/players/new?associations[team]=' + @team.id.to_s)
|
|
@@ -42,7 +42,7 @@ describe "RailsAdmin Basic Edit" do
|
|
|
42
42
|
|
|
43
43
|
describe "readonly associations" do
|
|
44
44
|
|
|
45
|
-
it
|
|
45
|
+
it "is not editable" do
|
|
46
46
|
@league = FactoryGirl.create :league
|
|
47
47
|
visit edit_path(:model_name => "league", :id => @league.id)
|
|
48
48
|
should_not have_selector('select#league_team_ids')
|
|
@@ -57,7 +57,7 @@ describe "RailsAdmin Basic Edit" do
|
|
|
57
57
|
visit edit_path(:model_name => "fan", :id => @fan.id)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
it "
|
|
60
|
+
it "shows associated objects" do
|
|
61
61
|
should have_selector "#fan_team_ids" do |select|
|
|
62
62
|
expect(select[0]).to have_selector 'option[selected="selected"]'
|
|
63
63
|
expect(select[1]).not_to have_selector 'option[selected="selected"]'
|
|
@@ -71,7 +71,7 @@ describe "RailsAdmin Basic Edit" do
|
|
|
71
71
|
visit edit_path(:model_name => "player", :id => 1)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
it "
|
|
74
|
+
it "raises NotFound" do
|
|
75
75
|
expect(page.driver.status_code).to eq(404)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
@@ -90,7 +90,7 @@ describe "RailsAdmin Basic Edit" do
|
|
|
90
90
|
visit edit_path(:model_name => "ball", :id => @ball.id)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
it "
|
|
93
|
+
it "displays a link to the delete page" do
|
|
94
94
|
should have_selector "a[href='/admin/ball/#{@ball.id}/delete']"
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -98,7 +98,7 @@ describe "RailsAdmin Basic Edit" do
|
|
|
98
98
|
|
|
99
99
|
describe "clicking cancel when editing an object" do
|
|
100
100
|
|
|
101
|
-
it "
|
|
101
|
+
it "sends back to previous URL" do
|
|
102
102
|
@ball = FactoryGirl.create :ball
|
|
103
103
|
visit '/admin/ball?sort=color'
|
|
104
104
|
click_link 'Edit'
|