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
@@ -6,6 +6,49 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
6
6
|
|
7
7
|
subject { page }
|
8
8
|
|
9
|
+
describe "default_value" do
|
10
|
+
|
11
|
+
it "should be set for all types of input fields" do
|
12
|
+
RailsAdmin.config do |config|
|
13
|
+
config.excluded_models = []
|
14
|
+
config.model(FieldTest) do
|
15
|
+
|
16
|
+
field :string_field do
|
17
|
+
default_value 'string_field default_value'
|
18
|
+
end
|
19
|
+
field :text_field do
|
20
|
+
default_value 'string_field text_field'
|
21
|
+
end
|
22
|
+
field :boolean_field do
|
23
|
+
default_value true
|
24
|
+
end
|
25
|
+
field :date_field do
|
26
|
+
default_value Date.today.to_s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
visit new_path(:model_name => "field_test")
|
32
|
+
find_field('field_test[string_field]').value.should == 'string_field default_value'
|
33
|
+
find_field('field_test[text_field]').value.should == 'string_field text_field'
|
34
|
+
find_field('field_test[date_field]').value.should == Date.today.to_s
|
35
|
+
has_checked_field?('field_test[boolean_field]').should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set default value for selects" do
|
39
|
+
RailsAdmin.config(Team) do
|
40
|
+
field :color, :enum do
|
41
|
+
default_value 'black'
|
42
|
+
enum do
|
43
|
+
['black', 'white']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
visit new_path(:model_name => "team")
|
48
|
+
find_field('team[color]').value.should == 'black'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
9
52
|
describe "attr_accessible" do
|
10
53
|
|
11
54
|
|
@@ -40,7 +83,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
40
83
|
describe "css hooks" do
|
41
84
|
it "should be present" do
|
42
85
|
visit new_path(:model_name => "team")
|
43
|
-
should have_selector("#team_division_id_field.
|
86
|
+
should have_selector("#team_division_id_field.belongs_to_association_type.division_field")
|
44
87
|
end
|
45
88
|
end
|
46
89
|
|
@@ -112,7 +155,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
112
155
|
end
|
113
156
|
end
|
114
157
|
visit new_path(:model_name => "team")
|
115
|
-
should have_selector('
|
158
|
+
should have_selector('fieldset>p', :text => "help paragraph to display")
|
116
159
|
end
|
117
160
|
|
118
161
|
it "should not show help if not present" do
|
@@ -124,7 +167,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
124
167
|
end
|
125
168
|
end
|
126
169
|
visit new_path(:model_name => "team")
|
127
|
-
should_not have_selector('
|
170
|
+
should_not have_selector('fieldset>p')
|
128
171
|
end
|
129
172
|
|
130
173
|
it "should be able to display multiple help if there are multiple sections" do
|
@@ -142,9 +185,9 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
142
185
|
end
|
143
186
|
end
|
144
187
|
visit new_path(:model_name => "team")
|
145
|
-
should have_selector("
|
146
|
-
should have_selector("
|
147
|
-
should have_selector("
|
188
|
+
should have_selector("fieldset>p", :text => 'help for default')
|
189
|
+
should have_selector("fieldset>p", :text => 'help for other section')
|
190
|
+
should have_selector("fieldset>p", :count => 2)
|
148
191
|
end
|
149
192
|
|
150
193
|
it "should use the db column size for the maximum length" do
|
@@ -229,7 +272,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
229
272
|
should have_selector("label", :text => "Name")
|
230
273
|
should have_selector("label", :text => "Logo url")
|
231
274
|
should have_selector("label", :text => "Division")
|
232
|
-
should have_selector(".
|
275
|
+
should have_selector(".control-group", :count => 3)
|
233
276
|
end
|
234
277
|
|
235
278
|
it "should have accessor for its fields by type" do
|
@@ -301,7 +344,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
301
344
|
visit new_path(:model_name => "team")
|
302
345
|
should have_selector("label", :text => "Division")
|
303
346
|
should have_selector("label", :text => "Name")
|
304
|
-
should have_selector(".
|
347
|
+
should have_selector(".control-group", :count => 2)
|
305
348
|
end
|
306
349
|
|
307
350
|
it "should delegates the label option to the ActiveModel API and memoize I18n awarly" do
|
@@ -511,7 +554,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
511
554
|
after(:each) do
|
512
555
|
Time.zone = 'UTC'
|
513
556
|
end
|
514
|
-
|
557
|
+
|
515
558
|
describe "a datetime field" do
|
516
559
|
|
517
560
|
it "should default to %B %d, %Y %H:%M" do
|
@@ -534,7 +577,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
534
577
|
fill_in "field_test[datetime_field]", :with => @time.strftime("%a, %d %b %Y %H:%M:%S")
|
535
578
|
click_button "Save"
|
536
579
|
@record = RailsAdmin::AbstractModel.new("FieldTest").first
|
537
|
-
@record.datetime_field.should eql(
|
580
|
+
@record.datetime_field.to_s(:rfc822).should eql(@time.to_s(:rfc822))
|
538
581
|
end
|
539
582
|
|
540
583
|
it "should have a customization option" do
|
@@ -549,7 +592,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
549
592
|
fill_in "field_test[datetime_field]", :with => @time.strftime("%Y-%m-%d %H:%M:%S")
|
550
593
|
click_button "Save"
|
551
594
|
@record = RailsAdmin::AbstractModel.new("FieldTest").first
|
552
|
-
@record.datetime_field.should eql(
|
595
|
+
@record.datetime_field.to_s(:rfc822).should eql(@time.to_s(:rfc822))
|
553
596
|
end
|
554
597
|
end
|
555
598
|
|
@@ -575,7 +618,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
575
618
|
fill_in "field_test[timestamp_field]", :with => @time.strftime("%a, %d %b %Y %H:%M:%S")
|
576
619
|
click_button "Save"
|
577
620
|
@record = RailsAdmin::AbstractModel.new("FieldTest").first
|
578
|
-
@record.timestamp_field.should eql(
|
621
|
+
@record.timestamp_field.to_s(:rfc822).should eql(@time.to_s(:rfc822))
|
579
622
|
end
|
580
623
|
|
581
624
|
it "should have a customization option" do
|
@@ -590,7 +633,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
590
633
|
fill_in "field_test[timestamp_field]", :with => @time.strftime("%Y-%m-%d %H:%M:%S")
|
591
634
|
click_button "Save"
|
592
635
|
@record = RailsAdmin::AbstractModel.new("FieldTest").first
|
593
|
-
@record.timestamp_field.should eql(
|
636
|
+
@record.timestamp_field.to_s(:rfc822).should eql(@time.to_s(:rfc822))
|
594
637
|
end
|
595
638
|
end
|
596
639
|
|
@@ -698,7 +741,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
698
741
|
end
|
699
742
|
end
|
700
743
|
end
|
701
|
-
|
744
|
+
|
702
745
|
describe 'bindings' do
|
703
746
|
it 'should be present at creation time' do
|
704
747
|
RailsAdmin.config do |config|
|
@@ -711,7 +754,7 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
711
754
|
end
|
712
755
|
end
|
713
756
|
end
|
714
|
-
|
757
|
+
|
715
758
|
visit new_path(:model_name => 'category')
|
716
759
|
should have_no_css('#category_parent_category_id')
|
717
760
|
click_button 'Save'
|
@@ -721,8 +764,8 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
721
764
|
should have_content('Category successfully updated')
|
722
765
|
end
|
723
766
|
end
|
724
|
-
|
725
|
-
describe 'nested form' do
|
767
|
+
|
768
|
+
describe 'nested form' do
|
726
769
|
|
727
770
|
it 'should work' do
|
728
771
|
RailsAdmin::Config.excluded_models = [RelTest]
|
@@ -734,15 +777,13 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
734
777
|
@record.nested_field_tests = [NestedFieldTest.create!(:title => 'title 1'), NestedFieldTest.create!(:title => 'title 2')]
|
735
778
|
visit edit_path(:model_name => "field_test", :id => @record.id)
|
736
779
|
fill_in "field_test_nested_field_tests_attributes_0_title", :with => 'nested field test title 1 edited'
|
737
|
-
page.find('#field_test_comment_attributes__destroy').set('true')
|
738
780
|
page.find('#field_test_nested_field_tests_attributes_1__destroy').set('true')
|
739
781
|
click_button "Save"
|
740
782
|
@record.reload
|
741
|
-
@record.comment.should == nil
|
742
783
|
@record.nested_field_tests.length.should == 1
|
743
784
|
@record.nested_field_tests[0].title.should == 'nested field test title 1 edited'
|
744
785
|
end
|
745
|
-
|
786
|
+
|
746
787
|
it 'should set bindings[:object] to nested object' do
|
747
788
|
RailsAdmin::Config.excluded_models = [RelTest]
|
748
789
|
RailsAdmin.config(NestedFieldTest) do
|
@@ -759,19 +800,19 @@ describe "RailsAdmin Config DSL Edit Section" do
|
|
759
800
|
visit edit_path(:model_name => "field_test", :id => @record.id)
|
760
801
|
find('#field_test_nested_field_tests_attributes_0_title_field').should have_content('NestedFieldTest')
|
761
802
|
end
|
762
|
-
|
803
|
+
|
763
804
|
it 'should be desactivable' do
|
764
805
|
RailsAdmin::Config.excluded_models = [RelTest]
|
765
|
-
|
806
|
+
|
766
807
|
visit new_path(:model_name => "field_test")
|
767
|
-
should have_selector('.
|
808
|
+
should have_selector('.add_nested_fields')
|
768
809
|
RailsAdmin.config(FieldTest) do
|
769
810
|
configure :nested_field_tests do
|
770
811
|
nested_form false
|
771
812
|
end
|
772
813
|
end
|
773
814
|
visit new_path(:model_name => "field_test")
|
774
|
-
should have_no_selector('.
|
815
|
+
should have_no_selector('.add_nested_fields')
|
775
816
|
end
|
776
817
|
end
|
777
818
|
|
@@ -421,7 +421,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
421
421
|
let(:player_names_by_date){ players.sort_by{|p| p[:created_at]}.map{|p| p[:name]} }
|
422
422
|
let(:league_names_by_date){ leagues.sort_by{|l| l[:created_at]}.map{|l| l[:name]} }
|
423
423
|
|
424
|
-
before(:each) { @players =
|
424
|
+
before(:each) { @players = Player.create(players) }
|
425
425
|
|
426
426
|
context "should be configurable" do
|
427
427
|
it "globaly" do
|
@@ -453,7 +453,7 @@ describe "RailsAdmin Config DSL List Section" do
|
|
453
453
|
end
|
454
454
|
|
455
455
|
it "globaly and overrideable per model" do
|
456
|
-
|
456
|
+
League.create(leagues)
|
457
457
|
|
458
458
|
RailsAdmin::Config.models do
|
459
459
|
list do
|
@@ -13,6 +13,26 @@ describe "RailsAdmin Config DSL Show Section" do
|
|
13
13
|
visit show_path(:model_name => "team", :id => team.id)
|
14
14
|
end
|
15
15
|
|
16
|
+
describe "compact_show_view" do
|
17
|
+
|
18
|
+
it 'should hide empty fields in show view by default' do
|
19
|
+
@player = FactoryGirl.create :player
|
20
|
+
visit show_path(:model_name => "league", :id => @player.id)
|
21
|
+
should_not have_css(".born_on_field")
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
it 'should be disactivable' do
|
26
|
+
RailsAdmin.config do |c|
|
27
|
+
c.compact_show_view = false
|
28
|
+
end
|
29
|
+
|
30
|
+
@player = FactoryGirl.create :player
|
31
|
+
visit show_path(:model_name => "player", :id => @player.id)
|
32
|
+
should have_css(".born_on_field")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
16
36
|
describe "css hooks" do
|
17
37
|
it "should be present" do
|
18
38
|
do_request
|
@@ -18,7 +18,7 @@ describe "RailsAdmin History" do
|
|
18
18
|
histories.total_count.should == 30
|
19
19
|
histories.count.should == 20
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should respect RailsAdmin::Config.default_items_per_page" do
|
23
23
|
RailsAdmin.config.default_items_per_page = 15
|
24
24
|
histories = RailsAdmin::History.history_for_model @model, nil, false, false, false, nil
|
@@ -45,13 +45,13 @@ describe "RailsAdmin History" do
|
|
45
45
|
|
46
46
|
context "with a lot of histories" do
|
47
47
|
before :each do
|
48
|
-
player =
|
48
|
+
player = Player.create(:team_id => -1, :number => -1, :name => "Player 1")
|
49
49
|
101.times do |i|
|
50
50
|
player.number = i
|
51
51
|
RailsAdmin::History.create_history_item "change #{i}", player, @model, nil
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it 'should get latest ones' do
|
56
56
|
RailsAdmin::History.latest.count.should == 100
|
57
57
|
end
|
@@ -39,9 +39,8 @@ describe "RailsAdmin" do
|
|
39
39
|
should have_selector('head script[src^="/assets/rails_admin/rails_admin.js"]')
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
describe 'hidden fields with default values' do
|
44
|
-
|
45
44
|
it "should show up with default value, hidden" do
|
46
45
|
RailsAdmin.config Player do
|
47
46
|
include_all_fields
|
@@ -53,16 +52,16 @@ describe "RailsAdmin" do
|
|
53
52
|
end
|
54
53
|
end
|
55
54
|
end
|
56
|
-
|
55
|
+
|
57
56
|
visit new_path(:model_name => "player")
|
58
57
|
should have_selector("#player_name[type=hidden][value='username@example.com']")
|
59
58
|
should_not have_selector("#player_name[type=hidden][value='toto@example.com']")
|
60
59
|
end
|
61
60
|
end
|
62
|
-
|
63
|
-
describe '_current_user
|
64
|
-
|
65
|
-
it 'should
|
61
|
+
|
62
|
+
describe '_current_user' do # https://github.com/sferik/rails_admin/issues/549
|
63
|
+
|
64
|
+
it 'should be accessible from the list view' do
|
66
65
|
RailsAdmin.config Player do
|
67
66
|
list do
|
68
67
|
field :name do
|
@@ -70,7 +69,7 @@ describe "RailsAdmin" do
|
|
70
69
|
bindings[:view]._current_user.email == 'username@example.com'
|
71
70
|
end
|
72
71
|
end
|
73
|
-
|
72
|
+
|
74
73
|
field :team do
|
75
74
|
visible do
|
76
75
|
bindings[:view]._current_user.email == 'foo@example.com'
|
@@ -78,7 +77,7 @@ describe "RailsAdmin" do
|
|
78
77
|
end
|
79
78
|
end
|
80
79
|
end
|
81
|
-
|
80
|
+
|
82
81
|
visit index_path(:model_name => "player")
|
83
82
|
should have_selector(".header.name_field")
|
84
83
|
should_not have_selector(".header.team_field")
|
@@ -111,36 +110,4 @@ describe "RailsAdmin" do
|
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
114
|
-
describe "model whitelist:" do
|
115
|
-
|
116
|
-
it 'should only use included models' do
|
117
|
-
RailsAdmin.config.included_models = [Team, League]
|
118
|
-
RailsAdmin::AbstractModel.all.map(&:model).should == [League, Team] #it gets sorted
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'should not restrict models if included_models is left empty' do
|
122
|
-
RailsAdmin.config.included_models = []
|
123
|
-
RailsAdmin::AbstractModel.all.map(&:model).should include(Team, League)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should further remove excluded models (whitelist - blacklist)' do
|
127
|
-
RailsAdmin.config.excluded_models = [Team]
|
128
|
-
RailsAdmin.config.included_models = [Team, League]
|
129
|
-
RailsAdmin::AbstractModel.all.map(&:model).should == [League]
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should always exclude history' do
|
133
|
-
RailsAdmin::AbstractModel.all.map(&:model).should_not include(RailsAdmin::History)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'excluded? returns true for any model not on the list' do
|
137
|
-
RailsAdmin.config.included_models = [Team, League]
|
138
|
-
|
139
|
-
team_config = RailsAdmin.config(RailsAdmin::AbstractModel.new('Team'))
|
140
|
-
fan_config = RailsAdmin.config(RailsAdmin::AbstractModel.new('Fan'))
|
141
|
-
|
142
|
-
fan_config.should be_excluded
|
143
|
-
team_config.should_not be_excluded
|
144
|
-
end
|
145
|
-
end
|
146
113
|
end
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,20 +1,12 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
require 'simplecov'
|
5
|
-
SimpleCov.start 'rails'
|
6
|
-
|
7
3
|
ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'true'
|
8
4
|
require File.expand_path('../dummy_app/config/environment', __FILE__)
|
9
5
|
|
10
|
-
require 'generator_spec/test_case'
|
11
|
-
require 'generators/rails_admin/install_generator'
|
12
|
-
require 'generators/rails_admin/uninstall_generator'
|
13
6
|
require 'rspec/rails'
|
14
7
|
require 'factory_girl'
|
15
8
|
require 'factories'
|
16
9
|
require 'database_helpers'
|
17
|
-
require 'generator_helpers'
|
18
10
|
|
19
11
|
ActionMailer::Base.delivery_method = :test
|
20
12
|
ActionMailer::Base.perform_deliveries = true
|
@@ -23,13 +15,9 @@ ActionMailer::Base.default_url_options[:host] = "example.com"
|
|
23
15
|
Rails.backtrace_cleaner.remove_silencers!
|
24
16
|
|
25
17
|
include DatabaseHelpers
|
26
|
-
# Run any available migration
|
27
|
-
puts 'Setting up database...'
|
28
18
|
drop_all_tables
|
29
19
|
migrate_database
|
30
20
|
ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'false'
|
31
|
-
# Load support files
|
32
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each{|f| require f}
|
33
21
|
|
34
22
|
# Don't need passwords in test DB to be secure, but we would like 'em to be
|
35
23
|
# fast -- and the stretches mechanism is intended to make passwords
|
@@ -45,6 +33,7 @@ module Devise
|
|
45
33
|
end
|
46
34
|
end
|
47
35
|
end
|
36
|
+
|
48
37
|
Devise.setup do |config|
|
49
38
|
config.stretches = 0
|
50
39
|
end
|
@@ -54,38 +43,31 @@ RSpec.configure do |config|
|
|
54
43
|
|
55
44
|
config.include RSpec::Matchers
|
56
45
|
config.include DatabaseHelpers
|
57
|
-
config.include GeneratorHelpers
|
58
46
|
config.include RailsAdmin::Engine.routes.url_helpers
|
59
47
|
|
60
48
|
config.include Warden::Test::Helpers
|
61
49
|
|
62
50
|
config.before(:each) do
|
63
|
-
RailsAdmin.reset
|
51
|
+
RailsAdmin::Config.reset
|
52
|
+
RailsAdmin::AbstractModel.reset
|
64
53
|
RailsAdmin::Config.excluded_models = [RelTest, FieldTest, Category]
|
65
54
|
RailsAdmin::Config.audit_with :history
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
RailsAdmin::AbstractModel.new("Foo::Bar").destroy_all!
|
77
|
-
RailsAdmin::AbstractModel.new("FieldTest").destroy_all!
|
78
|
-
|
79
|
-
user = RailsAdmin::AbstractModel.new("User").create(
|
55
|
+
Category.delete_all
|
56
|
+
Division.delete_all
|
57
|
+
Draft.delete_all
|
58
|
+
Fan.delete_all
|
59
|
+
League.delete_all
|
60
|
+
Player.delete_all
|
61
|
+
Team.delete_all
|
62
|
+
User.delete_all
|
63
|
+
FieldTest.delete_all
|
64
|
+
login_as User.create(
|
80
65
|
:email => "username@example.com",
|
81
66
|
:password => "password"
|
82
67
|
)
|
83
|
-
|
84
|
-
login_as user
|
85
68
|
end
|
86
69
|
|
87
70
|
config.after(:each) do
|
88
|
-
|
89
71
|
Warden.test_reset!
|
90
72
|
end
|
91
73
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "AbstractObject" do
|
4
4
|
describe "proxy" do
|
5
5
|
let(:object) { mock("object") }
|
6
|
-
let(:abstract_object) { RailsAdmin::AbstractObject.new(object) }
|
6
|
+
let(:abstract_object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new(object) }
|
7
7
|
|
8
8
|
it "should act like a proxy" do
|
9
9
|
object.should_receive(:method_call)
|
@@ -13,7 +13,7 @@ describe "AbstractObject" do
|
|
13
13
|
|
14
14
|
describe "create" do
|
15
15
|
let(:player) { Player.new }
|
16
|
-
let(:object) { RailsAdmin::AbstractObject.new player }
|
16
|
+
let(:object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new player }
|
17
17
|
let(:name) { "Stefan Kiszonka" }
|
18
18
|
let(:number) { 87 }
|
19
19
|
let(:position) { "Fifth baseman" }
|
@@ -59,7 +59,7 @@ describe "AbstractObject" do
|
|
59
59
|
|
60
60
|
describe "a record with has_many associations" do
|
61
61
|
let(:league) { League.new }
|
62
|
-
let(:object) { RailsAdmin::AbstractObject.new league }
|
62
|
+
let(:object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new league }
|
63
63
|
let(:name) { "Awesome League" }
|
64
64
|
let(:teams) { [Factory(:team)] }
|
65
65
|
let(:divisions) { [Division.create!(:name => 'div 1', :league => League.create!(:name => 'north')), Division.create!(:name => 'div 2', :league => League.create!(:name => 'south'))] }
|
@@ -82,7 +82,7 @@ describe "AbstractObject" do
|
|
82
82
|
let(:name) { "Stefan Koza" }
|
83
83
|
let(:suspended) { true }
|
84
84
|
let(:player) { Factory :player, :suspended => true, :name => name, :draft => Factory(:draft) }
|
85
|
-
let(:object) { RailsAdmin::AbstractObject.new player }
|
85
|
+
let(:object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new player }
|
86
86
|
let(:new_team) { Factory :team }
|
87
87
|
let(:new_suspended) { false }
|
88
88
|
let(:new_draft) { nil }
|
@@ -106,7 +106,7 @@ describe "AbstractObject" do
|
|
106
106
|
|
107
107
|
describe "destroy" do
|
108
108
|
let(:player) { Factory :player }
|
109
|
-
let(:object) { RailsAdmin::AbstractObject.new player }
|
109
|
+
let(:object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new player }
|
110
110
|
|
111
111
|
before do
|
112
112
|
object.destroy
|
@@ -116,4 +116,16 @@ describe "AbstractObject" do
|
|
116
116
|
Player.exists?(player.id).should == false
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
describe "object_label_method" do
|
121
|
+
it 'should be configurable' do
|
122
|
+
RailsAdmin.config League do
|
123
|
+
object_label_method { :custom_name }
|
124
|
+
end
|
125
|
+
|
126
|
+
@league = FactoryGirl.create :league
|
127
|
+
|
128
|
+
RailsAdmin.config('League').with(:object => @league).object_label.should == "League '#{@league.name}'"
|
129
|
+
end
|
130
|
+
end
|
119
131
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_admin/adapters/active_record'
|
3
|
+
|
4
|
+
|
5
|
+
describe RailsAdmin::Adapters::ActiveRecord do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
|
9
|
+
class ARBlog < ActiveRecord::Base
|
10
|
+
has_many :a_r_posts
|
11
|
+
has_many :a_r_comments, :as => :commentable
|
12
|
+
end
|
13
|
+
|
14
|
+
class ARPost < ActiveRecord::Base
|
15
|
+
belongs_to :a_r_blog
|
16
|
+
has_and_belongs_to_many :a_r_categories
|
17
|
+
has_many :a_r_comments, :as => :commentable
|
18
|
+
end
|
19
|
+
|
20
|
+
class ARCategory < ActiveRecord::Base
|
21
|
+
has_and_belongs_to_many :a_r_posts
|
22
|
+
end
|
23
|
+
|
24
|
+
class ARUser < ActiveRecord::Base
|
25
|
+
has_one :a_r_profile
|
26
|
+
end
|
27
|
+
|
28
|
+
class ARProfile < ActiveRecord::Base
|
29
|
+
belongs_to :a_r_user
|
30
|
+
end
|
31
|
+
|
32
|
+
class ARComment < ActiveRecord::Base
|
33
|
+
belongs_to :commentable, :polymorphic => true
|
34
|
+
end
|
35
|
+
|
36
|
+
@blog = RailsAdmin::AbstractModel.new(ARBlog)
|
37
|
+
@post = RailsAdmin::AbstractModel.new(ARPost)
|
38
|
+
@category = RailsAdmin::AbstractModel.new(ARCategory)
|
39
|
+
@user = RailsAdmin::AbstractModel.new(ARUser)
|
40
|
+
@profile = RailsAdmin::AbstractModel.new(ARProfile)
|
41
|
+
@comment = RailsAdmin::AbstractModel.new(ARComment)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#associations' do
|
45
|
+
it 'lists associations' do
|
46
|
+
@post.associations.map{|a|a[:name].to_s}.sort.should == ['a_r_blog', 'a_r_categories', 'a_r_comments']
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
|
50
|
+
(@post.associations + @blog.associations + @user.associations).map{|a|a[:type]}.uniq.map(&:to_s).sort.should == ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|