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
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RailsAdmin::ApplicationHelper do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
before do
|
6
|
+
controller.stub(:authorized?).and_return(true)
|
7
|
+
end
|
8
|
+
|
7
9
|
describe '#current_action?' do
|
8
10
|
it 'should return true if current_action, false otherwise' do
|
9
11
|
@action = RailsAdmin::Config::Actions.find(:index)
|
10
|
-
|
12
|
+
|
11
13
|
helper.current_action?(RailsAdmin::Config::Actions.find(:index)).should be_true
|
12
14
|
helper.current_action?(RailsAdmin::Config::Actions.find(:show)).should_not be_true
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
describe '#action' do
|
17
19
|
it 'should return action by :custom_key' do
|
18
20
|
RailsAdmin.config do |config|
|
@@ -22,10 +24,9 @@ describe RailsAdmin::ApplicationHelper do
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
25
|
-
|
26
|
-
helper.action(:my_custom_dashboard_key).should == RailsAdmin::Config::Actions.find(:my_custom_dashboard_key)
|
27
|
+
helper.action(:my_custom_dashboard_key).should be
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
it 'should return only visible actions' do
|
30
31
|
RailsAdmin.config do |config|
|
31
32
|
config.actions do
|
@@ -34,10 +35,10 @@ describe RailsAdmin::ApplicationHelper do
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
|
+
|
38
39
|
helper.action(:dashboard).should == nil
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
it 'should return only visible actions, passing all bindings' do
|
42
43
|
RailsAdmin.config do |config|
|
43
44
|
config.actions do
|
@@ -50,25 +51,22 @@ describe RailsAdmin::ApplicationHelper do
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
53
|
-
|
54
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team),
|
55
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(
|
56
|
-
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new).should == nil
|
54
|
+
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Team.new).should be
|
55
|
+
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Team), Player.new).should be_nil
|
56
|
+
helper.action(:test_bindings, RailsAdmin::AbstractModel.new(Player), Team.new).should be_nil
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
describe "#actions" do
|
61
61
|
it 'should return actions by type' do
|
62
62
|
abstract_model = RailsAdmin::AbstractModel.new(Player)
|
63
63
|
object = FactoryGirl.create :player
|
64
64
|
helper.actions(:all, abstract_model, object).map(&:custom_key).should == [:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app]
|
65
|
-
helper.actions(:
|
66
|
-
helper.actions.map(&:custom_key).should == [:
|
67
|
-
helper.actions(:
|
68
|
-
helper.actions(:collection).map(&:custom_key).should == [:index, :new, :export, :bulk_delete, :history_index]
|
69
|
-
helper.actions(:member).map(&:custom_key).should == [:show, :edit, :delete, :history_show]
|
65
|
+
helper.actions(:root, abstract_model, object).map(&:custom_key).should == [:dashboard]
|
66
|
+
helper.actions(:collection, abstract_model, object).map(&:custom_key).should == [:index, :new, :export, :bulk_delete, :history_index]
|
67
|
+
helper.actions(:member, abstract_model, object).map(&:custom_key).should == [:show, :edit, :delete, :history_show, :show_in_app]
|
70
68
|
end
|
71
|
-
|
69
|
+
|
72
70
|
it 'should only return visible actions, passing bindings correctly' do
|
73
71
|
RailsAdmin.config do |config|
|
74
72
|
config.actions do
|
@@ -81,13 +79,13 @@ describe RailsAdmin::ApplicationHelper do
|
|
81
79
|
end
|
82
80
|
end
|
83
81
|
end
|
84
|
-
|
82
|
+
|
85
83
|
helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Team.new).map(&:custom_key).should == [:test_bindings]
|
86
84
|
helper.actions(:all, RailsAdmin::AbstractModel.new(Team), Player.new).map(&:custom_key).should == []
|
87
85
|
helper.actions(:all, RailsAdmin::AbstractModel.new(Player), Team.new).map(&:custom_key).should == []
|
88
86
|
end
|
89
87
|
end
|
90
|
-
|
88
|
+
|
91
89
|
describe "#wording_for" do
|
92
90
|
it "gives correct wording even if action is not visible" do
|
93
91
|
RailsAdmin.config do |config|
|
@@ -97,35 +95,33 @@ describe RailsAdmin::ApplicationHelper do
|
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
100
|
-
|
98
|
+
|
101
99
|
helper.wording_for(:menu, :index).should == "List"
|
102
100
|
end
|
103
|
-
|
101
|
+
|
104
102
|
it "passes correct bindings" do
|
105
103
|
helper.wording_for(:title, :edit, RailsAdmin::AbstractModel.new(Team), Team.new(:name => 'the avengers')).should == "Edit Team 'the avengers'"
|
106
104
|
end
|
107
|
-
|
105
|
+
|
108
106
|
it "defaults correct bindings" do
|
109
107
|
@action = RailsAdmin::Config::Actions.find :edit
|
110
108
|
@abstract_model = RailsAdmin::AbstractModel.new(Team)
|
111
109
|
@object = Team.new(:name => 'the avengers')
|
112
110
|
helper.wording_for(:title).should == "Edit Team 'the avengers'"
|
113
111
|
end
|
114
|
-
|
112
|
+
|
115
113
|
it "does not try to use the wrong :label_metod" do
|
116
114
|
@abstract_model = RailsAdmin::AbstractModel.new(Draft)
|
117
115
|
@object = Draft.new
|
118
|
-
|
116
|
+
|
119
117
|
helper.wording_for(:link, :new, RailsAdmin::AbstractModel.new(Team)).should == "Add a new Team"
|
120
118
|
end
|
121
|
-
|
119
|
+
|
122
120
|
end
|
123
|
-
|
121
|
+
|
124
122
|
describe "#breadcrumb" do
|
125
|
-
it "gives us a breadcrumb
|
126
|
-
@action = RailsAdmin::Config::Actions.find :
|
127
|
-
@abstract_model = RailsAdmin::AbstractModel.new(Team)
|
128
|
-
@object = Team.new(:name => 'the avengers')
|
123
|
+
it "gives us a breadcrumb" do
|
124
|
+
@action = RailsAdmin::Config::Actions.find(:edit, {:abstract_model => RailsAdmin::AbstractModel.new(Team), :object => Team.new(:name => 'the avengers')})
|
129
125
|
bc = helper.breadcrumb
|
130
126
|
bc.should match /Dashboard/ # dashboard
|
131
127
|
bc.should match /Teams/ # list
|
@@ -133,7 +129,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
133
129
|
bc.should match /Edit/ # current (edit)
|
134
130
|
end
|
135
131
|
end
|
136
|
-
|
132
|
+
|
137
133
|
describe "#menu_for" do
|
138
134
|
it 'passes model and object as bindings and generates a menu, excluding non-get actions' do
|
139
135
|
RailsAdmin.config do |config|
|
@@ -154,7 +150,7 @@ describe RailsAdmin::ApplicationHelper do
|
|
154
150
|
end
|
155
151
|
end
|
156
152
|
end
|
157
|
-
|
153
|
+
|
158
154
|
@action = RailsAdmin::Config::Actions.find :show
|
159
155
|
@abstract_model = RailsAdmin::AbstractModel.new(Team)
|
160
156
|
@object = Team.new(:name => 'the avengers')
|
@@ -162,13 +158,13 @@ describe RailsAdmin::ApplicationHelper do
|
|
162
158
|
helper.menu_for(:root).should match /Dashboard/
|
163
159
|
helper.menu_for(:collection, @abstract_model).should match /List/
|
164
160
|
helper.menu_for(:member, @abstract_model, @object).should match /Show/
|
165
|
-
|
161
|
+
|
166
162
|
@abstract_model = RailsAdmin::AbstractModel.new(Player)
|
167
163
|
@object = Player.new
|
168
164
|
helper.menu_for(:collection, @abstract_model).should_not match /List/
|
169
165
|
helper.menu_for(:member, @abstract_model, @object).should_not match /Show/
|
170
166
|
end
|
171
|
-
|
167
|
+
|
172
168
|
it "excludes non-get actions" do
|
173
169
|
RailsAdmin.config do |config|
|
174
170
|
config.actions do
|
@@ -177,12 +173,82 @@ describe RailsAdmin::ApplicationHelper do
|
|
177
173
|
end
|
178
174
|
end
|
179
175
|
end
|
180
|
-
|
176
|
+
|
181
177
|
@action = RailsAdmin::Config::Actions.find :dashboard
|
182
178
|
helper.menu_for(:root).should_not match /Dashboard/
|
183
179
|
end
|
184
180
|
end
|
185
|
-
|
181
|
+
|
182
|
+
describe "#main_navigation" do
|
183
|
+
it 'should show included models' do
|
184
|
+
RailsAdmin.config do |config|
|
185
|
+
config.included_models = [Ball, Comment]
|
186
|
+
end
|
187
|
+
helper.main_navigation.should match /(nav\-header).*(Navigation).*(Balls).*(Comments)/m
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should not show unvisible models' do
|
191
|
+
RailsAdmin.config do |config|
|
192
|
+
config.included_models = [Ball, Comment]
|
193
|
+
config.model Comment do
|
194
|
+
hide
|
195
|
+
end
|
196
|
+
end
|
197
|
+
result = helper.main_navigation
|
198
|
+
result.should match /(nav\-header).*(Navigation).*(Balls)/m
|
199
|
+
result.should_not match "Comments"
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should show children of hidden models" do # https://github.com/sferik/rails_admin/issues/978
|
203
|
+
RailsAdmin.config do |config|
|
204
|
+
config.included_models = [Ball, Hardball]
|
205
|
+
config.model Ball do
|
206
|
+
hide
|
207
|
+
end
|
208
|
+
end
|
209
|
+
helper.main_navigation.should match /(nav\-header).*(Navigation).*(Hardballs)/m
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should show children of excluded models" do
|
213
|
+
RailsAdmin.config do |config|
|
214
|
+
config.included_models = [Hardball]
|
215
|
+
end
|
216
|
+
helper.main_navigation.should match /(nav\-header).*(Navigation).*(Hardballs)/m
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should "nest" in navigation label' do
|
220
|
+
RailsAdmin.config do |config|
|
221
|
+
config.included_models = [Comment]
|
222
|
+
config.model Comment do
|
223
|
+
navigation_label 'commentable'
|
224
|
+
end
|
225
|
+
end
|
226
|
+
helper.main_navigation.should match /(nav\-header).*(commentable).*(Comments)/m
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should "nest" in parent model' do
|
230
|
+
RailsAdmin.config do |config|
|
231
|
+
config.included_models = [Player, Comment]
|
232
|
+
config.model Comment do
|
233
|
+
parent Player
|
234
|
+
end
|
235
|
+
end
|
236
|
+
helper.main_navigation.should match /(Players).*(nav\-level\-1).*(Comments)/m
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should order' do
|
240
|
+
RailsAdmin.config do |config|
|
241
|
+
config.included_models = [Player, Comment]
|
242
|
+
end
|
243
|
+
helper.main_navigation.should match /(Comments).*(Players)/m
|
244
|
+
|
245
|
+
RailsAdmin.config(Comment) do
|
246
|
+
weight 1
|
247
|
+
end
|
248
|
+
helper.main_navigation.should match /(Players).*(Comments)/m
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
186
252
|
describe "#bulk_menu" do
|
187
253
|
it 'should include all visible bulkable actions' do
|
188
254
|
RailsAdmin.config do |config|
|
@@ -201,7 +267,6 @@ describe RailsAdmin::ApplicationHelper do
|
|
201
267
|
end
|
202
268
|
end
|
203
269
|
@action = RailsAdmin::Config::Actions.find :index
|
204
|
-
|
205
270
|
result = helper.bulk_menu(RailsAdmin::AbstractModel.new(Team))
|
206
271
|
result.should match "zorg_action"
|
207
272
|
result.should match "blub"
|
@@ -209,4 +274,4 @@ describe RailsAdmin::ApplicationHelper do
|
|
209
274
|
helper.bulk_menu(RailsAdmin::AbstractModel.new(Player)).should_not match "blub"
|
210
275
|
end
|
211
276
|
end
|
212
|
-
end
|
277
|
+
end
|
@@ -77,7 +77,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
77
77
|
]
|
78
78
|
|
79
79
|
visit index_path(:model_name => "player")
|
80
|
-
|
80
|
+
|
81
81
|
should have_content(@players[0].name)
|
82
82
|
should_not have_content(@players[1].name)
|
83
83
|
should_not have_content("Add new")
|
@@ -112,7 +112,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
112
112
|
should_not have_content("Delete")
|
113
113
|
|
114
114
|
should have_content("Save and add another")
|
115
|
-
fill_in "player[name]", :with
|
115
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
116
116
|
fill_in "player[number]", :with => "42"
|
117
117
|
fill_in "player[position]", :with => "Second baseman"
|
118
118
|
click_button "Save"
|
@@ -141,7 +141,6 @@ describe "RailsAdmin CanCan Authorization" do
|
|
141
141
|
it "GET /admin/player/1/edit should render and update record upon submission" do
|
142
142
|
@player = FactoryGirl.create :player
|
143
143
|
visit edit_path(:model_name => "player", :id => @player.id)
|
144
|
-
|
145
144
|
should have_content("Save and edit")
|
146
145
|
should_not have_content("Save and add another")
|
147
146
|
should_not have_content("Add new")
|
@@ -246,7 +245,7 @@ describe "RailsAdmin CanCan Authorization" do
|
|
246
245
|
visit delete_path(:model_name => "player", :id => player_id)
|
247
246
|
|
248
247
|
click_button "Yes, I'm sure"
|
249
|
-
|
248
|
+
|
250
249
|
Player.exists?(player_id).should be_false
|
251
250
|
end
|
252
251
|
|
@@ -347,4 +346,4 @@ describe "RailsAdmin CanCan Authorization" do
|
|
347
346
|
end
|
348
347
|
end
|
349
348
|
|
350
|
-
end
|
349
|
+
end
|
File without changes
|
data/spec/{requests → integration}/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb
RENAMED
@@ -5,7 +5,7 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
5
5
|
subject { page }
|
6
6
|
|
7
7
|
describe "successful bulk delete of records" do
|
8
|
-
before
|
8
|
+
before do
|
9
9
|
RailsAdmin::History.destroy_all
|
10
10
|
RailsAdmin.config { |c| c.audit_with :history }
|
11
11
|
@players = 3.times.map { FactoryGirl.create(:player) }
|
@@ -17,32 +17,19 @@ describe "RailsAdmin Basic Bulk Destroy" do
|
|
17
17
|
|
18
18
|
it "should not contain deleted records" do
|
19
19
|
RailsAdmin::AbstractModel.new("Player").count.should == 1
|
20
|
-
end
|
21
|
-
|
22
|
-
it "history count should be equal to number of deleted records" do
|
23
20
|
RailsAdmin::History.count.should == @delete_ids.count
|
24
|
-
end
|
25
|
-
|
26
|
-
it "history items should be for proper table" do
|
27
21
|
RailsAdmin::History.all.each do |history|
|
28
22
|
history.table.should == "Player"
|
29
23
|
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "history items should be for proper items" do
|
33
24
|
RailsAdmin::History.all.each do |history|
|
34
25
|
@delete_ids.should include(history.item)
|
35
26
|
end
|
36
|
-
|
37
|
-
|
38
|
-
it "displays a flash notice stating the number of records destroyed" do
|
39
|
-
# 2 Players because @delete_ids.count == 2:
|
40
|
-
page.should have_selector(".alert-message", :text => "2 Players successfully deleted")
|
27
|
+
page.should have_selector(".alert-success", :text => "2 Players successfully deleted")
|
41
28
|
end
|
42
29
|
end
|
43
30
|
|
44
31
|
describe "cancelled bulk_deletion" do
|
45
|
-
before
|
32
|
+
before do
|
46
33
|
RailsAdmin::History.destroy_all
|
47
34
|
@players = 3.times.map { FactoryGirl.create(:player) }
|
48
35
|
@delete_ids = @players[0..1].map(&:id)
|
@@ -6,12 +6,10 @@ describe "RailsAdmin Basic Create" do
|
|
6
6
|
describe "create" do
|
7
7
|
before(:each) do
|
8
8
|
visit new_path(:model_name => "player")
|
9
|
-
|
10
9
|
fill_in "player[name]", :with => "Jackie Robinson"
|
11
10
|
fill_in "player[number]", :with => "42"
|
12
11
|
fill_in "player[position]", :with => "Second baseman"
|
13
12
|
click_button "Save"
|
14
|
-
|
15
13
|
@player = RailsAdmin::AbstractModel.new("Player").first
|
16
14
|
end
|
17
15
|
|
@@ -21,19 +21,3 @@ describe "RailsAdmin Namespaced Model Create" do
|
|
21
21
|
}.to change(Cms::BasicPage, :count).by(1)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
|
26
|
-
describe "RailsAdmin Mounted Engine Model Create" do
|
27
|
-
|
28
|
-
subject { page }
|
29
|
-
|
30
|
-
before(:each) do
|
31
|
-
visit new_path(:model_name => "foo~bar")
|
32
|
-
fill_in "foo_bar[title]", :with => "Hello"
|
33
|
-
click_button "Save"
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should be successful' do
|
37
|
-
Foo::Bar.first.title.should == 'Hello'
|
38
|
-
end
|
39
|
-
end
|
File without changes
|
File without changes
|
@@ -63,7 +63,7 @@ describe "RailsAdmin Export" do
|
|
63
63
|
it "should allow to export to XML" do
|
64
64
|
visit export_path(:model_name => 'player')
|
65
65
|
click_button 'Export to xml'
|
66
|
-
|
66
|
+
|
67
67
|
# spec fails on non 1.9 mri rubies because of this https://github.com/rails/rails/pull/2076
|
68
68
|
# waiting for fix (rails-3.1.4?)
|
69
69
|
should have_content @player.team.name if RUBY_VERSION =~ /1\.9/
|
@@ -11,25 +11,25 @@ describe "RailsAdmin Basic List" do
|
|
11
11
|
visit dashboard_path
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe "GET /admin/typo" do
|
16
16
|
it "should redirect to dashboard and inform the user the model wasn't found" do
|
17
17
|
visit '/admin/whatever'
|
18
18
|
page.driver.status_code.should eql(404)
|
19
|
-
find('.alert-
|
19
|
+
find('.alert-error').should have_content("Model 'Whatever' could not be found")
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
describe "GET /admin/balls/545-typo" do
|
24
24
|
it "should redirect to balls index and inform the user the id wasn't found" do
|
25
25
|
visit '/admin/ball/545-typo'
|
26
26
|
page.driver.status_code.should eql(404)
|
27
|
-
find('.alert-
|
27
|
+
find('.alert-error').should have_content("Ball with id '545-typo' could not be found")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "GET /admin/player as list" do
|
32
|
-
before
|
32
|
+
before do
|
33
33
|
21.times { FactoryGirl.create :player } # two pages of players
|
34
34
|
visit index_path(:model_name => "player")
|
35
35
|
end
|
@@ -38,52 +38,26 @@ describe "RailsAdmin Basic List" do
|
|
38
38
|
should have_content("List of Players")
|
39
39
|
should have_content("Created at")
|
40
40
|
should have_content("Updated at")
|
41
|
-
end
|
42
41
|
|
43
|
-
|
42
|
+
# it "shows the show, edit and delete links" do
|
44
43
|
should have_selector("td a", :text => 'Show')
|
45
44
|
should have_selector("td a", :text => 'Edit')
|
46
45
|
should have_selector("td a", :text => 'Delete')
|
47
|
-
end
|
48
46
|
|
49
|
-
|
47
|
+
# it "has the search box with some prompt text" do
|
50
48
|
should have_selector("input[placeholder='Filter']")
|
51
|
-
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
# https://github.com/sferik/rails_admin/issues/362
|
51
|
+
# test that no link uses the "wildcard route" with the main
|
52
|
+
# controller and list method
|
53
|
+
# it "should not use the 'wildcard route'" do
|
57
54
|
should have_selector("a[href*='all=true']") # make sure we're fully testing pagination
|
58
55
|
should have_no_selector("a[href^='/rails_admin/main/list']")
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
62
|
-
describe "GET /admin/player with sort" do
|
63
|
-
before(:each) do
|
64
|
-
@players = 2.times.map { FactoryGirl.create :player }
|
65
|
-
visit index_path(:model_name => "player", :sort => "name")
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should be sorted correctly" do
|
69
|
-
2.times { |i| should have_selector("td", :text => /#{@players[i].name}/) }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "GET /admin/player with reverse sort" do
|
74
|
-
|
75
|
-
before(:each) do
|
76
|
-
@players = 2.times.map { FactoryGirl.create :player }
|
77
|
-
visit index_path(:model_name => "player", :sort => "name", :sort_reverse => "true")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should be sorted correctly" do
|
81
|
-
2.times { |i| should have_selector("td", :text => /#{@players.reverse[i].name}/) }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
59
|
describe "GET /admin/player" do
|
86
|
-
before
|
60
|
+
before do
|
87
61
|
@teams = 2.times.map do
|
88
62
|
FactoryGirl.create(:team)
|
89
63
|
end
|
File without changes
|
File without changes
|
@@ -5,7 +5,6 @@ describe "RailsAdmin Basic Show" do
|
|
5
5
|
|
6
6
|
describe "show" do
|
7
7
|
before(:each) do
|
8
|
-
|
9
8
|
@player = FactoryGirl.create :player
|
10
9
|
visit show_path(:model_name => "player", :id => @player.id)
|
11
10
|
end
|
@@ -27,7 +26,7 @@ describe "RailsAdmin Basic Show" do
|
|
27
26
|
should have_content(@player.number)
|
28
27
|
end
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
describe "GET /admin/players/123this-id-doesnt-exist" do
|
32
31
|
it "should raise NotFound" do
|
33
32
|
visit '/admin/players/123this-id-doesnt-exist'
|
@@ -85,7 +85,7 @@ describe "RailsAdmin Basic Update" do
|
|
85
85
|
RailsAdmin.config do |c|
|
86
86
|
c.audit_with :history
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
@league = FactoryGirl.create :league
|
90
90
|
@divisions = 3.times.map { Division.create!(:name => "div #{Time.now.to_f}", :league => League.create!(:name => "league #{Time.now.to_f}")) }
|
91
91
|
|
@@ -97,7 +97,7 @@ describe "RailsAdmin Basic Update" do
|
|
97
97
|
@league.divisions.should include(@divisions[0])
|
98
98
|
@league.divisions.should_not include(@divisions[1])
|
99
99
|
@league.divisions.should_not include(@divisions[2])
|
100
|
-
|
100
|
+
|
101
101
|
RailsAdmin::History.where(:item => @league.id).collect(&:message).should include("Added Divisions ##{@divisions[0].id} associations, Changed name")
|
102
102
|
|
103
103
|
page.driver.put edit_path(:model_name => "league", :id => @league.id, :league => {:division_ids => [""]})
|