obitum-rails_admin 0.0.1 → 0.0.2
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 +1 -8
- data/README.md +6 -2
- data/app/assets/javascripts/rails_admin/custom/ui.js +5 -5
- data/app/assets/javascripts/rails_admin/jquery-ui-1.8.16.custom.js +4727 -4727
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -484
- data/app/assets/javascripts/rails_admin/jquery.pjax.js +250 -85
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1371 -1219
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +30 -30
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +11 -11
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +40 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +41 -39
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +4 -3
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +6 -6
- data/app/assets/javascripts/rails_admin/ui.js.coffee +44 -16
- data/app/assets/stylesheets/rails_admin/base/README +2 -2
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +226 -113
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +1 -1
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +3 -3
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +36 -1
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +16 -0
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +1 -1
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +2 -2
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +3 -3
- data/app/controllers/rails_admin/application_controller.rb +13 -18
- data/app/controllers/rails_admin/main_controller.rb +15 -16
- data/app/helpers/rails_admin/application_helper.rb +67 -41
- data/app/helpers/rails_admin/form_builder.rb +31 -29
- data/app/helpers/rails_admin/main_helper.rb +4 -4
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +12 -11
- data/app/views/layouts/rails_admin/application.html.haml +29 -29
- data/app/views/rails_admin/main/_dashboard_history.html.haml +1 -1
- data/app/views/rails_admin/main/_delete_notice.html.haml +4 -5
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +2 -1
- data/app/views/rails_admin/main/_form_datetime.html.haml +1 -1
- data/app/views/rails_admin/main/_form_enumeration.html.haml +1 -1
- data/app/views/rails_admin/main/_form_field.html.haml +1 -1
- data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -2
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +6 -4
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +6 -5
- data/app/views/rails_admin/main/_form_nested_many.html.haml +41 -6
- data/app/views/rails_admin/main/_form_nested_one.html.haml +34 -5
- data/app/views/rails_admin/main/_form_text.html.haml +3 -3
- data/app/views/rails_admin/main/_submit_buttons.html.haml +6 -4
- data/app/views/rails_admin/main/bulk_delete.html.haml +7 -3
- data/app/views/rails_admin/main/dashboard.html.haml +4 -4
- data/app/views/rails_admin/main/delete.html.haml +7 -3
- data/app/views/rails_admin/main/edit.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +57 -53
- data/app/views/rails_admin/main/history.html.haml +8 -8
- data/app/views/rails_admin/main/index.html.haml +22 -21
- data/app/views/rails_admin/main/new.html.haml +1 -1
- data/app/views/rails_admin/main/show.html.haml +2 -2
- data/config/initializers/active_record_extensions.rb +2 -2
- data/config/initializers/haml.rb +0 -1
- data/config/locales/rails_admin.en.yml +5 -5
- data/lib/generators/rails_admin/templates/initializer.erb +7 -7
- data/lib/rails_admin/abstract_model.rb +36 -53
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/active_record.rb +56 -137
- data/lib/rails_admin/config/actions/base.rb +40 -28
- data/lib/rails_admin/config/actions/bulk_delete.rb +10 -11
- data/lib/rails_admin/config/actions/dashboard.rb +9 -5
- data/lib/rails_admin/config/actions/delete.rb +12 -9
- data/lib/rails_admin/config/actions/edit.rb +13 -9
- data/lib/rails_admin/config/actions/export.rb +9 -6
- data/lib/rails_admin/config/actions/history_index.rb +9 -5
- data/lib/rails_admin/config/actions/history_show.rb +9 -5
- data/lib/rails_admin/config/actions/index.rb +23 -13
- data/lib/rails_admin/config/actions/new.rb +14 -10
- data/lib/rails_admin/config/actions/show.rb +10 -5
- data/lib/rails_admin/config/actions/show_in_app.rb +9 -4
- data/lib/rails_admin/config/actions.rb +16 -16
- data/lib/rails_admin/config/configurable.rb +92 -0
- data/lib/rails_admin/config/fields/association.rb +6 -23
- data/lib/rails_admin/config/fields/base.rb +58 -40
- data/lib/rails_admin/config/fields/factories/belongs_to_association.rb +26 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +21 -2
- data/lib/rails_admin/config/fields/factories/devise.rb +9 -12
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +13 -7
- data/lib/rails_admin/config/fields/factories/paperclip.rb +14 -15
- data/lib/rails_admin/config/fields/group.rb +16 -3
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/carrierwave.rb +0 -9
- data/lib/rails_admin/config/fields/types/color.rb +3 -3
- data/lib/rails_admin/config/fields/types/dragonfly.rb +1 -19
- data/lib/rails_admin/config/fields/types/file_upload.rb +7 -11
- data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -6
- data/lib/rails_admin/config/fields/types/has_one_association.rb +4 -4
- data/lib/rails_admin/config/fields/types/paperclip.rb +0 -18
- data/lib/rails_admin/config/fields/types/password.rb +2 -2
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +2 -2
- data/lib/rails_admin/config/fields/types/text.rb +2 -2
- data/lib/rails_admin/config/fields.rb +7 -17
- data/lib/rails_admin/config/has_fields.rb +9 -9
- data/lib/rails_admin/config/has_groups.rb +2 -2
- data/lib/rails_admin/config/hideable.rb +2 -2
- data/lib/rails_admin/config/model.rb +23 -17
- data/lib/rails_admin/config/proxyable/proxy.rb +43 -0
- data/lib/rails_admin/config/proxyable.rb +12 -0
- data/lib/rails_admin/config/sections/base.rb +14 -4
- data/lib/rails_admin/config.rb +38 -9
- data/lib/rails_admin/extension.rb +1 -1
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +6 -6
- data/lib/rails_admin/extensions/history/history.rb +2 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +13 -13
- data/lib/rails_admin/support/csv_converter.rb +6 -6
- data/lib/rails_admin/version.rb +1 -1
- data/lib/rails_admin.rb +0 -5
- data/spec/controllers/main_controller_spec.rb +7 -7
- data/spec/dummy_app/Gemfile +10 -7
- data/spec/dummy_app/Rakefile +1 -1
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +15 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy_app/app/controllers/players_controller.rb +1 -1
- data/spec/dummy_app/app/models/cms/basic_page.rb +1 -1
- data/spec/dummy_app/app/models/division.rb +5 -1
- data/spec/dummy_app/app/models/field_test.rb +4 -4
- data/spec/dummy_app/app/models/nested_field_test.rb +3 -0
- data/spec/dummy_app/app/models/player.rb +3 -3
- data/spec/dummy_app/app/views/layouts/application.html.erb +3 -2
- data/spec/dummy_app/app/views/players/show.html.haml +1 -1
- data/spec/dummy_app/config/application.rb +20 -5
- data/spec/dummy_app/config/database.yml +5 -2
- data/spec/dummy_app/config/environments/development.rb +11 -1
- data/spec/dummy_app/config/environments/production.rb +19 -3
- data/spec/dummy_app/config/environments/test.rb +5 -7
- data/spec/dummy_app/config/initializers/devise.rb +6 -0
- data/spec/dummy_app/config/initializers/inflections.rb +5 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +1 -1
- data/spec/dummy_app/{foo/test/dummy/config → config}/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy_app/config/routes.rb +1 -1
- data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +35 -5
- data/spec/dummy_app/db/migrate/20120118122004_add_categories.rb +1 -1
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/public/404.html +26 -0
- data/spec/dummy_app/{foo/test/dummy/public → public}/422.html +0 -0
- data/spec/dummy_app/{foo/test/dummy/public → public}/500.html +0 -1
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/helpers/application_helper_spec.rb +107 -42
- data/spec/{requests → integration}/authorization/cancan_spec.rb +4 -5
- data/spec/{requests → integration}/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +0 -0
- data/spec/{requests → integration}/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +3 -16
- data/spec/{requests → integration}/basic/create/rails_admin_basic_create_spec.rb +0 -2
- data/spec/{requests → integration}/basic/create/rails_admin_namespaced_model_create_spec.rb +0 -16
- data/spec/{requests → integration}/basic/delete/rails_admin_basic_delete_spec.rb +0 -0
- data/spec/{requests → integration}/basic/destroy/rails_admin_basic_destroy_spec.rb +0 -0
- data/spec/{requests → integration}/basic/edit/rails_admin_basic_edit_spec.rb +2 -2
- data/spec/{requests → integration}/basic/export/rails_admin_basic_export_spec.rb +1 -1
- data/spec/{requests → integration}/basic/list/rails_admin_basic_list_spec.rb +12 -38
- data/spec/{requests → integration}/basic/new/rails_admin_basic_new_spec.rb +0 -0
- data/spec/{requests → integration}/basic/new/rails_admin_namespaced_model_new_spec.rb +0 -0
- data/spec/{requests → integration}/basic/show/rails_admin_basic_show_spec.rb +1 -2
- data/spec/{requests → integration}/basic/update/rails_admin_basic_update_spec.rb +2 -2
- data/spec/{requests → integration}/config/edit/rails_admin_config_edit_spec.rb +65 -24
- data/spec/{requests → integration}/config/list/rails_admin_config_list_spec.rb +2 -2
- data/spec/{requests → integration}/config/show/rails_admin_config_show_spec.rb +20 -0
- data/spec/{requests → integration}/history/rails_admin_history_spec.rb +3 -3
- data/spec/{requests → integration}/rails_admin_spec.rb +8 -41
- data/spec/{requests → integration}/relation_spec.rb +0 -0
- data/spec/spec_helper.rb +13 -31
- data/spec/{lib → unit/adapters/active_record}/abstract_object_spec.rb +17 -5
- data/spec/unit/adapters/active_record_spec.rb +53 -0
- data/spec/{requests/actions.rb → unit/config/actions_spec.rb} +47 -31
- data/spec/unit/config/fields/base_spec.rb +291 -0
- data/spec/unit/config/model_spec.rb +75 -0
- data/spec/unit/config/sections_spec.rb +123 -0
- data/spec/{lib/rails_admin_spec.rb → unit/config_spec.rb} +65 -93
- metadata +127 -223
- data/app/assets/javascripts/rails_admin/jquery_nested_form.js +0 -58
- data/app/views/layouts/rails_admin/_navigation.html.haml +0 -17
- data/lib/rails_admin/abstract_object.rb +0 -28
- data/lib/rails_admin/config/base.rb +0 -111
- data/lib/rails_admin/config/proxy.rb +0 -40
- data/lib/rails_admin/generic_support.rb +0 -18
- data/spec/dummy_app/config/initializers/quiet_assets.rb +0 -10
- data/spec/dummy_app/foo/Gemfile +0 -17
- data/spec/dummy_app/foo/MIT-LICENSE +0 -20
- data/spec/dummy_app/foo/README.rdoc +0 -3
- data/spec/dummy_app/foo/Rakefile +0 -39
- data/spec/dummy_app/foo/app/assets/javascripts/foo/application.js +0 -9
- data/spec/dummy_app/foo/app/assets/stylesheets/foo/application.css +0 -7
- data/spec/dummy_app/foo/app/controllers/foo/application_controller.rb +0 -4
- data/spec/dummy_app/foo/app/helpers/foo/application_helper.rb +0 -4
- data/spec/dummy_app/foo/app/models/foo/bar.rb +0 -4
- data/spec/dummy_app/foo/app/views/layouts/foo/application.html.erb +0 -14
- data/spec/dummy_app/foo/config/routes.rb +0 -2
- data/spec/dummy_app/foo/foo.gemspec +0 -23
- data/spec/dummy_app/foo/lib/foo/engine.rb +0 -5
- data/spec/dummy_app/foo/lib/foo/version.rb +0 -3
- data/spec/dummy_app/foo/lib/foo.rb +0 -4
- data/spec/dummy_app/foo/lib/tasks/foo_tasks.rake +0 -4
- data/spec/dummy_app/foo/script/rails +0 -6
- data/spec/dummy_app/foo/test/dummy/Rakefile +0 -7
- data/spec/dummy_app/foo/test/dummy/app/assets/javascripts/application.js +0 -9
- data/spec/dummy_app/foo/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/spec/dummy_app/foo/test/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy_app/foo/test/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy_app/foo/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy_app/foo/test/dummy/config/application.rb +0 -45
- data/spec/dummy_app/foo/test/dummy/config/boot.rb +0 -10
- data/spec/dummy_app/foo/test/dummy/config/database.yml +0 -25
- data/spec/dummy_app/foo/test/dummy/config/environment.rb +0 -5
- data/spec/dummy_app/foo/test/dummy/config/environments/development.rb +0 -30
- data/spec/dummy_app/foo/test/dummy/config/environments/production.rb +0 -60
- data/spec/dummy_app/foo/test/dummy/config/environments/test.rb +0 -39
- data/spec/dummy_app/foo/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy_app/foo/test/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy_app/foo/test/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy_app/foo/test/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy_app/foo/test/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy_app/foo/test/dummy/config/locales/en.yml +0 -5
- data/spec/dummy_app/foo/test/dummy/config/routes.rb +0 -4
- data/spec/dummy_app/foo/test/dummy/config.ru +0 -4
- data/spec/dummy_app/foo/test/dummy/db/schema.rb +0 -21
- data/spec/dummy_app/foo/test/dummy/public/404.html +0 -26
- data/spec/dummy_app/foo/test/dummy/public/favicon.ico +0 -0
- data/spec/dummy_app/foo/test/dummy/script/rails +0 -6
- data/spec/dummy_app/foo/test/fixtures/foo/bars.yml +0 -11
- data/spec/dummy_app/foo/test/foo_test.rb +0 -7
- data/spec/dummy_app/foo/test/integration/navigation_test.rb +0 -10
- data/spec/dummy_app/foo/test/test_helper.rb +0 -10
- data/spec/dummy_app/foo/test/unit/foo/bar_test.rb +0 -9
- data/spec/generator_helpers.rb +0 -30
- data/spec/generators/install_generator_spec.rb +0 -85
- data/spec/generators/uninstall_generator_spec.rb +0 -35
- data/spec/lib/custom_field.rb +0 -7
- data/spec/requests/config/navigation/rails_admin_config_navigation_spec.rb +0 -107
- data/spec/requests/config/rails_admin_config_spec.rb +0 -227
@@ -7,29 +7,29 @@ describe RailsAdmin::Config::Actions do
|
|
7
7
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app]
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
describe 'find' do
|
12
12
|
it 'should find by custom key' do
|
13
13
|
RailsAdmin.config do |config|
|
14
|
-
config.actions do
|
14
|
+
config.actions do
|
15
15
|
dashboard do
|
16
16
|
custom_key :custom_dashboard
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
collection :custom_collection, :index
|
20
|
-
|
20
|
+
|
21
21
|
show
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
RailsAdmin::Config::Actions.find(:custom_dashboard).should be_a(RailsAdmin::Config::Actions::Dashboard)
|
26
26
|
RailsAdmin::Config::Actions.find(:custom_collection).should be_a(RailsAdmin::Config::Actions::Index)
|
27
27
|
RailsAdmin::Config::Actions.find(:show).should be_a(RailsAdmin::Config::Actions::Show)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it 'should return visible action passing binding if controller binding is given, and pass action visible or not if no' do
|
31
31
|
RailsAdmin.config do |config|
|
32
|
-
config.actions do
|
32
|
+
config.actions do
|
33
33
|
root :custom_root do
|
34
34
|
visible do
|
35
35
|
bindings[:controller] == "controller"
|
@@ -41,24 +41,40 @@ describe RailsAdmin::Config::Actions do
|
|
41
41
|
RailsAdmin::Config::Actions.find(:custom_root, {:controller => "not_controller"}).should be_nil
|
42
42
|
RailsAdmin::Config::Actions.find(:custom_root, {:controller => "controller"}).should be_a(RailsAdmin::Config::Actions::Base)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
|
+
it 'should check bindings[:abstract_model] visibility while checking action\'s visibility' do
|
46
|
+
RailsAdmin.config Team do
|
47
|
+
hide
|
48
|
+
end
|
49
|
+
|
50
|
+
RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Comment)}).should be_a(RailsAdmin::Config::Actions::Index) #decoy
|
51
|
+
RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Team)}).should be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should check bindings[:abstract_model] presence while checking action\'s visibility' do
|
55
|
+
RailsAdmin.config do |config|
|
56
|
+
config.excluded_models << Team
|
57
|
+
end
|
58
|
+
RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Comment)}).should be_a(RailsAdmin::Config::Actions::Index) #decoy
|
59
|
+
RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Team)}).should be_nil
|
60
|
+
end
|
45
61
|
end
|
46
|
-
|
62
|
+
|
47
63
|
describe 'all' do
|
48
64
|
it 'should return all defined actions' do
|
49
65
|
RailsAdmin.config do |config|
|
50
|
-
config.actions do
|
66
|
+
config.actions do
|
51
67
|
dashboard
|
52
68
|
index
|
53
69
|
end
|
54
70
|
end
|
55
|
-
|
71
|
+
|
56
72
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:dashboard, :index]
|
57
73
|
end
|
58
|
-
|
74
|
+
|
59
75
|
it 'should restrict by scope' do
|
60
76
|
RailsAdmin.config do |config|
|
61
|
-
config.actions do
|
77
|
+
config.actions do
|
62
78
|
root :custom_root
|
63
79
|
collection :custom_collection
|
64
80
|
member :custom_member
|
@@ -68,10 +84,10 @@ describe RailsAdmin::Config::Actions do
|
|
68
84
|
RailsAdmin::Config::Actions.all(:collection).map(&:key).should == [:custom_collection]
|
69
85
|
RailsAdmin::Config::Actions.all(:member).map(&:key).should == [:custom_member]
|
70
86
|
end
|
71
|
-
|
87
|
+
|
72
88
|
it 'should return all visible actions passing binding if controller binding is given, and pass all actions if no' do
|
73
89
|
RailsAdmin.config do |config|
|
74
|
-
config.actions do
|
90
|
+
config.actions do
|
75
91
|
root :custom_root do
|
76
92
|
visible do
|
77
93
|
bindings[:controller] == "controller"
|
@@ -84,23 +100,23 @@ describe RailsAdmin::Config::Actions do
|
|
84
100
|
RailsAdmin::Config::Actions.all(:root, {:controller => "controller"}).map(&:custom_key).should == [:custom_root]
|
85
101
|
end
|
86
102
|
end
|
87
|
-
|
103
|
+
|
88
104
|
describe "customized through DSL" do
|
89
105
|
it 'should add the one asked' do
|
90
106
|
RailsAdmin.config do |config|
|
91
|
-
config.actions do
|
107
|
+
config.actions do
|
92
108
|
dashboard
|
93
109
|
index
|
94
110
|
show
|
95
111
|
end
|
96
112
|
end
|
97
|
-
|
113
|
+
|
98
114
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:dashboard, :index, :show]
|
99
115
|
end
|
100
|
-
|
116
|
+
|
101
117
|
it 'should allow to customize the custom_key when customizing an existing action' do
|
102
118
|
RailsAdmin.config do |config|
|
103
|
-
config.actions do
|
119
|
+
config.actions do
|
104
120
|
dashboard do
|
105
121
|
custom_key :my_dashboard
|
106
122
|
end
|
@@ -109,10 +125,10 @@ describe RailsAdmin::Config::Actions do
|
|
109
125
|
RailsAdmin::Config::Actions.all.map(&:custom_key).should == [:my_dashboard]
|
110
126
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:dashboard]
|
111
127
|
end
|
112
|
-
|
128
|
+
|
113
129
|
it 'should allow to change the key and the custom_key when "subclassing" an existing action' do
|
114
130
|
RailsAdmin.config do |config|
|
115
|
-
config.actions do
|
131
|
+
config.actions do
|
116
132
|
root :my_dashboard_key, :dashboard do
|
117
133
|
custom_key :my_dashboard_custom_key
|
118
134
|
end
|
@@ -122,40 +138,40 @@ describe RailsAdmin::Config::Actions do
|
|
122
138
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:my_dashboard_key]
|
123
139
|
RailsAdmin::Config::Actions.all.map(&:class).should == [RailsAdmin::Config::Actions::Dashboard]
|
124
140
|
end
|
125
|
-
|
141
|
+
|
126
142
|
it 'should not add the same custom_key twice' do
|
127
143
|
lambda do
|
128
144
|
RailsAdmin.config do |config|
|
129
|
-
config.actions do
|
145
|
+
config.actions do
|
130
146
|
dashboard
|
131
147
|
dashboard
|
132
148
|
end
|
133
149
|
end
|
134
150
|
end.should raise_error("Action dashboard already exist. Please change its custom key")
|
135
|
-
|
136
|
-
|
151
|
+
|
152
|
+
|
137
153
|
lambda do
|
138
154
|
RailsAdmin.config do |config|
|
139
|
-
config.actions do
|
155
|
+
config.actions do
|
140
156
|
index
|
141
157
|
collection :index
|
142
158
|
end
|
143
159
|
end
|
144
160
|
end.should raise_error("Action index already exist. Please change its custom key")
|
145
161
|
end
|
146
|
-
|
162
|
+
|
147
163
|
it 'should add the same key with different custom key' do
|
148
164
|
RailsAdmin.config do |config|
|
149
|
-
config.actions do
|
165
|
+
config.actions do
|
150
166
|
dashboard
|
151
167
|
dashboard do
|
152
168
|
custom_key :my_dashboard
|
153
169
|
end
|
154
170
|
end
|
155
171
|
end
|
156
|
-
|
172
|
+
|
157
173
|
RailsAdmin::Config::Actions.all.map(&:custom_key).should == [:dashboard, :my_dashboard]
|
158
174
|
RailsAdmin::Config::Actions.all.map(&:key).should == [:dashboard, :dashboard]
|
159
175
|
end
|
160
176
|
end
|
161
|
-
end
|
177
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsAdmin::Config::Fields::Base do
|
4
|
+
|
5
|
+
describe "#children_fields" do
|
6
|
+
|
7
|
+
it 'should be empty by default' do
|
8
|
+
RailsAdmin.config(Team).fields.find{ |f| f.name == :name }.children_fields.should == []
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should contain child key for belongs to associations' do
|
12
|
+
RailsAdmin.config(Team).fields.find{ |f| f.name == :division }.children_fields.should == [:division_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should contain child keys for polymorphic belongs to associations' do
|
16
|
+
RailsAdmin.config(Comment).fields.find{ |f| f.name == :commentable }.children_fields.should == [:commentable_id, :commentable_type]
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'of a Paperclip installation' do
|
20
|
+
it 'should be a _file_name field' do
|
21
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.children_fields.should == [:paperclip_asset_file_name]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be hidden, not filterable' do
|
25
|
+
f = RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset_file_name }
|
26
|
+
f.hidden?.should be_true
|
27
|
+
f.filterable?.should be_false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'of a Dragonfly installation' do
|
32
|
+
it 'should be a _name field and _uid field' do
|
33
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.children_fields.should == [:dragonfly_asset_name, :dragonfly_asset_uid]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'of a Carrierwave installation' do
|
38
|
+
it 'should be the parent field itself' do
|
39
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.children_fields.should == [:carrierwave_asset]
|
40
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.hidden?.should be_false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#html_default_value" do
|
46
|
+
it 'should be default_value for new records when value is nil' do
|
47
|
+
RailsAdmin.config Team do
|
48
|
+
list do
|
49
|
+
field :name do
|
50
|
+
default_value 'default value'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@team = Team.new
|
55
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.with(:object => @team).html_default_value.should == 'default value'
|
56
|
+
@team.name = 'set value'
|
57
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.with(:object => @team).html_default_value.should be_nil
|
58
|
+
@team = FactoryGirl.create :team
|
59
|
+
@team.name = nil
|
60
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.with(:object => @team).html_default_value.should be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#default_value" do
|
65
|
+
it 'should be nil by default' do
|
66
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.default_value.should be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#css_class" do
|
71
|
+
it "should have a default and be user customizable" do
|
72
|
+
RailsAdmin.config Team do
|
73
|
+
list do
|
74
|
+
field :division do
|
75
|
+
css_class "custom"
|
76
|
+
end
|
77
|
+
field :name
|
78
|
+
end
|
79
|
+
end
|
80
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :division}.css_class.should == "custom" # custom
|
81
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :division}.type_css_class.should == "belongs_to_association_type" # type css class, non-customizable
|
82
|
+
RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.css_class.should == "name_field" # default
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#associated_collection_cache_all" do
|
87
|
+
it "should default to true if associated collection count < 100" do
|
88
|
+
RailsAdmin.config(Team).edit.fields.find{|f| f.name == :players}.associated_collection_cache_all.should == true
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should default to false if associated collection count >= 100" do
|
92
|
+
@players = 100.times.map do
|
93
|
+
FactoryGirl.create :player
|
94
|
+
end
|
95
|
+
RailsAdmin.config(Team).edit.fields.find{|f| f.name == :players}.associated_collection_cache_all.should == false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#searchable_columns' do
|
100
|
+
describe 'for belongs_to fields' do
|
101
|
+
it "should find label method on the opposite side for belongs_to associations by default" do
|
102
|
+
RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.should == [{:column=>"divisions.name", :type=>:string}, {:column=>"teams.division_id", :type=>:integer}]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should search on opposite table for belongs_to" do
|
106
|
+
RailsAdmin.config(Team) do
|
107
|
+
field :division do
|
108
|
+
searchable :custom_id
|
109
|
+
end
|
110
|
+
end
|
111
|
+
RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.should == [{:column=>"divisions.custom_id", :type=>:integer}]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should search on asked table with model name" do
|
115
|
+
RailsAdmin.config(Team) do
|
116
|
+
field :division do
|
117
|
+
searchable League => :name
|
118
|
+
end
|
119
|
+
end
|
120
|
+
RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.should == [{:column=>"leagues.name", :type=>:string}]
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should search on asked table with table name" do
|
124
|
+
RailsAdmin.config(Team) do
|
125
|
+
field :division do
|
126
|
+
searchable :leagues => :name
|
127
|
+
end
|
128
|
+
end
|
129
|
+
RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.should == [{:column=>"leagues.name", :type=>:string}]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'for basic type fields' do
|
134
|
+
|
135
|
+
it 'should use base table and find correct column type' do
|
136
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :text_field}.searchable_columns.should == [{:column=>"field_tests.text_field", :type=>:text}]
|
137
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :integer_field}.searchable_columns.should == [{:column=>"field_tests.integer_field", :type=>:integer}]
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should be customizable to another field on the same table' do
|
141
|
+
RailsAdmin.config(FieldTest) do
|
142
|
+
field :time_field do
|
143
|
+
searchable :date_field
|
144
|
+
end
|
145
|
+
end
|
146
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :time_field}.searchable_columns.should == [{:column=>"field_tests.date_field", :type=>:date}]
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should be customizable to another field on another table with :table_name' do
|
150
|
+
RailsAdmin.config(FieldTest) do
|
151
|
+
field :string_field do
|
152
|
+
searchable :nested_field_tests => :title
|
153
|
+
end
|
154
|
+
end
|
155
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :string_field}.searchable_columns.should == [{:column=>"nested_field_tests.title", :type=>:string}]
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should be customizable to another field on another model with ModelClass' do
|
159
|
+
RailsAdmin.config(FieldTest) do
|
160
|
+
field :string_field do
|
161
|
+
searchable NestedFieldTest => :title
|
162
|
+
end
|
163
|
+
end
|
164
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :string_field}.searchable_columns.should == [{:column=>"nested_field_tests.title", :type=>:string}]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe 'for mapped fields' do
|
169
|
+
|
170
|
+
it 'should find the underlying column on the base table' do
|
171
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :paperclip_asset}.searchable_columns.should == [{:column=>"field_tests.paperclip_asset_file_name", :type=>:string}]
|
172
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :dragonfly_asset}.searchable_columns.should == [{:column=>"field_tests.dragonfly_asset_name", :type=>:string}]
|
173
|
+
RailsAdmin.config(FieldTest).fields.find{|f| f.name == :carrierwave_asset}.searchable_columns.should == [{:column=>"field_tests.carrierwave_asset", :type=>:string}]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
describe "#searchable and #sortable" do
|
180
|
+
it 'should be false if column is virtual, true otherwise' do
|
181
|
+
RailsAdmin.config League do
|
182
|
+
field :virtual_column
|
183
|
+
field :name
|
184
|
+
end
|
185
|
+
@league = FactoryGirl.create :league
|
186
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :virtual_column }.sortable.should == false
|
187
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :virtual_column }.searchable.should == false
|
188
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :name }.sortable.should == true
|
189
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :name }.searchable.should == true
|
190
|
+
end
|
191
|
+
|
192
|
+
context 'of a virtual field with children fields' do
|
193
|
+
it 'should target the first children field' do
|
194
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.searchable.should == :paperclip_asset_file_name
|
195
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.sortable.should == :paperclip_asset_file_name
|
196
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.searchable.should == :dragonfly_asset_name
|
197
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.sortable.should == :dragonfly_asset_name
|
198
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.searchable.should == :carrierwave_asset
|
199
|
+
RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.sortable.should == :carrierwave_asset
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "#virtual?" do
|
205
|
+
it 'should be true if column has no properties, false otherwise' do
|
206
|
+
RailsAdmin.config League do
|
207
|
+
field :virtual_column
|
208
|
+
field :name
|
209
|
+
end
|
210
|
+
@league = FactoryGirl.create :league
|
211
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :virtual_column }.virtual?.should == true
|
212
|
+
RailsAdmin.config('League').export.fields.find{ |f| f.name == :name }.virtual?.should == false
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe "#default_search_operator" do
|
217
|
+
let(:abstract_model) { RailsAdmin::AbstractModel.new('Player') }
|
218
|
+
let(:model_config) { RailsAdmin.config(abstract_model) }
|
219
|
+
let(:queryable_fields) { model_config.list.fields.select(&:queryable?) }
|
220
|
+
|
221
|
+
context "when no search operator is specified for the field" do
|
222
|
+
it "uses 'default' search operator" do
|
223
|
+
queryable_fields.should have_at_least(1).field
|
224
|
+
queryable_fields.first.search_operator.should == RailsAdmin::Config.default_search_operator
|
225
|
+
end
|
226
|
+
|
227
|
+
it "uses config.default_search_operator if set" do
|
228
|
+
RailsAdmin.config do |config|
|
229
|
+
config.default_search_operator = 'starts_with'
|
230
|
+
end
|
231
|
+
queryable_fields.should have_at_least(1).field
|
232
|
+
queryable_fields.first.search_operator.should == RailsAdmin::Config.default_search_operator
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
context "when search operator is specified for the field" do
|
237
|
+
it "uses specified search operator" do
|
238
|
+
RailsAdmin.config Player do
|
239
|
+
list do
|
240
|
+
fields do
|
241
|
+
search_operator "starts_with"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
queryable_fields.should have_at_least(1).field
|
246
|
+
queryable_fields.first.search_operator.should == "starts_with"
|
247
|
+
end
|
248
|
+
|
249
|
+
it "uses specified search operator even if config.default_search_operator set" do
|
250
|
+
RailsAdmin.config do |config|
|
251
|
+
config.default_search_operator = 'starts_with'
|
252
|
+
|
253
|
+
config.model Player do
|
254
|
+
list do
|
255
|
+
fields do
|
256
|
+
search_operator "ends_with"
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
queryable_fields.should have_at_least(1).field
|
262
|
+
queryable_fields.first.search_operator.should == "ends_with"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "#render" do
|
268
|
+
it "is configurable" do
|
269
|
+
RailsAdmin.config Team do
|
270
|
+
field :name do
|
271
|
+
render do
|
272
|
+
'rendered'
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
RailsAdmin.config(Team).field(:name).render.should == 'rendered'
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe '#active' do
|
281
|
+
it 'is false by default' do
|
282
|
+
RailsAdmin.config(Team).field(:division).active?.should be_false
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe '#associated_collection' do
|
287
|
+
it 'returns [] when type is blank?' do
|
288
|
+
RailsAdmin.config(Comment).fields.find{|f|f.name == :commentable}.associated_collection('').should be_empty
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsAdmin::Config::Model do
|
4
|
+
|
5
|
+
describe "#excluded?" do
|
6
|
+
before do
|
7
|
+
RailsAdmin.config do |config|
|
8
|
+
config.included_models = [Comment]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should say false when included, true otherwise" do
|
13
|
+
RailsAdmin.config(Player).excluded?.should == true
|
14
|
+
RailsAdmin.config(Comment).excluded?.should == false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#object_label" do
|
19
|
+
before do
|
20
|
+
RailsAdmin.config(Comment) do
|
21
|
+
object_label_method :content
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should send object_label_method to binding[:object]" do
|
26
|
+
c = Comment.new(:content => 'test')
|
27
|
+
RailsAdmin.config(Comment).with(:object => c).object_label.should == 'test'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#object_label_method" do
|
32
|
+
it "should be first of Config.label_methods if found as a column on model, or :rails_admin_default_object_label_method" do
|
33
|
+
RailsAdmin.config(Comment).object_label_method.should == :rails_admin_default_object_label_method
|
34
|
+
RailsAdmin.config(Division).object_label_method.should == :name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#label" do
|
39
|
+
it "should be pretty" do
|
40
|
+
RailsAdmin.config(Comment).label.should == 'Comment'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#label_plural" do
|
45
|
+
it "should be pretty" do
|
46
|
+
RailsAdmin.config(Comment).label_plural.should == 'Comments'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#weight" do
|
51
|
+
it "should be 0" do
|
52
|
+
RailsAdmin.config(Comment).weight.should == 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#parent" do
|
57
|
+
it "should be nil for ActiveRecord::Base inherited models" do
|
58
|
+
RailsAdmin.config(Comment).parent.should be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be parent model otherwise" do
|
62
|
+
RailsAdmin.config(Hardball).parent.should == Ball
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#navigation_label" do
|
67
|
+
it "should be nil if parent module is Object" do
|
68
|
+
RailsAdmin.config(Comment).navigation_label.should be_nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should be parent module otherwise" do
|
72
|
+
RailsAdmin.config(Cms::BasicPage).navigation_label.should == "Cms"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsAdmin::Config::Sections do
|
4
|
+
|
5
|
+
describe "configure" do
|
6
|
+
it "should configure without changing the section default list" do
|
7
|
+
RailsAdmin.config Team do
|
8
|
+
edit do
|
9
|
+
configure :name do
|
10
|
+
label "Renamed"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
fields = RailsAdmin.config(Team).edit.fields
|
15
|
+
fields.find{|f| f.name == :name }.label.should == "Renamed"
|
16
|
+
fields.count.should >= 19 # not 1
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not change the section list if set" do
|
20
|
+
RailsAdmin.config Team do
|
21
|
+
edit do
|
22
|
+
field :manager
|
23
|
+
configure :name do
|
24
|
+
label "Renamed"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
fields = RailsAdmin.config(Team).edit.fields
|
29
|
+
fields.first.name.should == :manager
|
30
|
+
fields.count.should == 1 # not 19
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "DSL field inheritance" do
|
35
|
+
it 'should be tested' do
|
36
|
+
RailsAdmin.config do |config|
|
37
|
+
config.model Fan do
|
38
|
+
field :name do
|
39
|
+
label do
|
40
|
+
@label ||= "modified base #{label}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
list do
|
44
|
+
field :name do
|
45
|
+
label do
|
46
|
+
@label ||= "modified list #{label}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
edit do
|
51
|
+
field :name do
|
52
|
+
label do
|
53
|
+
@label ||= "modified edit #{label}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
create do
|
58
|
+
field :name do
|
59
|
+
label do
|
60
|
+
@label ||= "modified create #{label}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
RailsAdmin.config(Fan).visible_fields.count.should == 1
|
68
|
+
RailsAdmin.config(Fan).visible_fields.first.label.should == 'modified base His Name'
|
69
|
+
RailsAdmin.config(Fan).list.visible_fields.first.label.should == 'modified list His Name'
|
70
|
+
RailsAdmin.config(Fan).export.visible_fields.first.label.should == 'modified base His Name'
|
71
|
+
RailsAdmin.config(Fan).edit.visible_fields.first.label.should == 'modified edit His Name'
|
72
|
+
RailsAdmin.config(Fan).create.visible_fields.first.label.should == 'modified create His Name'
|
73
|
+
RailsAdmin.config(Fan).update.visible_fields.first.label.should == 'modified edit His Name'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "DSL group inheritance" do
|
78
|
+
it 'should be tested' do
|
79
|
+
RailsAdmin.config do |config|
|
80
|
+
config.model Team do
|
81
|
+
list do
|
82
|
+
group "a" do
|
83
|
+
field :founded
|
84
|
+
end
|
85
|
+
|
86
|
+
group "b" do
|
87
|
+
field :name
|
88
|
+
field :wins
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
edit do
|
93
|
+
group "a" do
|
94
|
+
field :name
|
95
|
+
end
|
96
|
+
|
97
|
+
group "c" do
|
98
|
+
field :founded
|
99
|
+
field :wins
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
update do
|
104
|
+
group "d" do
|
105
|
+
field :wins
|
106
|
+
end
|
107
|
+
|
108
|
+
group "e" do
|
109
|
+
field :losses
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
RailsAdmin.config(Team).list.visible_groups.map{|g| g.visible_fields.map(&:name) }.should == [[:founded], [:name, :wins]]
|
116
|
+
RailsAdmin.config(Team).edit.visible_groups.map{|g| g.visible_fields.map(&:name) }.should == [[:name], [:founded, :wins]]
|
117
|
+
RailsAdmin.config(Team).create.visible_groups.map{|g| g.visible_fields.map(&:name) }.should == [[:name], [:founded, :wins]]
|
118
|
+
RailsAdmin.config(Team).update.visible_groups.map{|g| g.visible_fields.map(&:name) }.should == [[:name], [:founded], [:wins], [:losses]]
|
119
|
+
RailsAdmin.config(Team).visible_groups.map{|g| g.visible_fields.map(&:name) }.flatten.count.should == 19
|
120
|
+
RailsAdmin.config(Team).export.visible_groups.map{|g| g.visible_fields.map(&:name) }.flatten.count.should == 19
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|