andrewroth_activeadmin 0.3.4 → 0.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +159 -3
- data/CONTRIBUTING.md +113 -0
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js +9 -0
- data/app/assets/javascripts/active_admin/base.js +4 -12
- data/app/assets/stylesheets/active_admin/_base.css.scss +16 -340
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -7
- data/app/assets/stylesheets/active_admin/_header.css.scss +23 -4
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +2 -0
- data/app/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/app/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/app/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +101 -0
- data/app/assets/stylesheets/active_admin/mixins/_all.css.scss +2 -1
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +50 -13
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +7 -5
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/active_admin/page/index.html.arb +1 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +3 -2
- data/docs/1-general-configuration.md +46 -10
- data/docs/6-show-screens.md +7 -0
- data/docs/8-custom-actions.md +12 -2
- data/docs/9-custom-pages.md +84 -0
- data/features/belongs_to.feature +27 -0
- data/features/comments/commenting.feature +3 -2
- data/features/dashboard.feature +18 -0
- data/features/development_reloading.feature +19 -0
- data/features/index/filter_with_check_boxes.feature +25 -0
- data/features/index/index_as_table.feature +14 -0
- data/features/index/index_scopes.feature +42 -0
- data/features/index/pagination.feature +19 -1
- data/features/menu.feature +22 -2
- data/features/registering_assets.feature +2 -2
- data/features/registering_pages.feature +66 -0
- data/features/specifying_actions.feature +5 -0
- data/features/step_definitions/action_item_steps.rb +2 -6
- data/features/step_definitions/action_link_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +8 -0
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/configuration_steps.rb +56 -8
- data/features/step_definitions/dashboard_steps.rb +5 -1
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +16 -4
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +25 -10
- data/lib/active_admin/application.rb +63 -20
- data/lib/active_admin/arbre/html/element.rb +10 -0
- data/lib/active_admin/asset_registration.rb +15 -2
- data/lib/active_admin/base_controller.rb +61 -0
- data/lib/active_admin/{resource_controller → base_controller}/menu.rb +1 -1
- data/lib/active_admin/comments.rb +48 -54
- data/lib/active_admin/comments/comment.rb +13 -2
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +7 -3
- data/lib/active_admin/dashboards.rb +4 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +20 -4
- data/lib/active_admin/dsl.rb +6 -159
- data/lib/active_admin/event.rb +5 -3
- data/lib/active_admin/filter_form_builder.rb +53 -0
- data/lib/active_admin/form_builder.rb +25 -19
- data/lib/active_admin/inputs.rb +14 -0
- data/lib/active_admin/inputs/datepicker_input.rb +11 -0
- data/lib/active_admin/inputs/filter_base.rb +46 -0
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +40 -0
- data/lib/active_admin/inputs/filter_date_range_input.rb +34 -0
- data/lib/active_admin/inputs/filter_numeric_input.rb +55 -0
- data/lib/active_admin/inputs/filter_select_input.rb +23 -0
- data/lib/active_admin/inputs/filter_string_input.rb +22 -0
- data/lib/active_admin/locales/ca.yml +44 -0
- data/lib/active_admin/locales/cs.yml +14 -10
- data/lib/active_admin/locales/de.yml +43 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/ko.yml +40 -0
- data/lib/active_admin/locales/lv.yml +43 -0
- data/lib/active_admin/locales/nl.yml +40 -0
- data/lib/active_admin/locales/no-NB.yml +40 -0
- data/lib/active_admin/locales/pl.yml +7 -1
- data/lib/active_admin/locales/pt-BR.yml +6 -2
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +54 -0
- data/lib/active_admin/page_controller.rb +15 -0
- data/lib/active_admin/page_dsl.rb +21 -0
- data/lib/active_admin/page_presenter.rb +30 -0
- data/lib/active_admin/resource.rb +38 -44
- data/lib/active_admin/resource/action_items.rb +5 -0
- data/lib/active_admin/resource/belongs_to.rb +4 -2
- data/lib/active_admin/resource/controllers.rb +35 -0
- data/lib/active_admin/resource/menu.rb +1 -2
- data/lib/active_admin/resource/naming.rb +43 -31
- data/lib/active_admin/resource/page_presenters.rb +28 -0
- data/lib/active_admin/resource/scopes.rb +16 -3
- data/lib/active_admin/resource/sidebars.rb +4 -0
- data/lib/active_admin/resource_collection.rb +88 -0
- data/lib/active_admin/resource_controller.rb +18 -54
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +1 -1
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +8 -4
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/resource_class_methods.rb +24 -0
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +157 -0
- data/lib/active_admin/router.rb +21 -14
- data/lib/active_admin/scope.rb +15 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +4 -3
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -10
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +25 -21
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -150
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/scopes.rb +17 -17
- data/lib/active_admin/views/components/status_tag.rb +6 -5
- data/lib/active_admin/views/components/table_for.rb +6 -2
- data/lib/active_admin/views/header_renderer.rb +31 -12
- data/lib/active_admin/views/index_as_block.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +3 -3
- data/lib/active_admin/views/index_as_grid.rb +4 -4
- data/lib/active_admin/views/index_as_table.rb +13 -6
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/form.rb +49 -0
- data/lib/active_admin/views/pages/index.rb +18 -6
- data/lib/active_admin/views/pages/page.rb +24 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +19 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +38 -12
- data/lib/generators/active_admin/install/templates/dashboards.rb +6 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/templates/cucumber_with_reloading.rb +5 -0
- data/spec/unit/active_admin_spec.rb +8 -0
- data/spec/unit/application_spec.rb +48 -2
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/asset_registration_spec.rb +9 -3
- data/spec/unit/auto_link_spec.rb +2 -2
- data/spec/unit/base_controller_shared_examples.rb +28 -0
- data/spec/unit/base_controller_spec.rb +8 -0
- data/spec/unit/belongs_to_spec.rb +30 -33
- data/spec/unit/comments_spec.rb +45 -15
- data/spec/unit/config_shared_examples.rb +108 -0
- data/spec/unit/dashboard_controller_spec.rb +44 -0
- data/spec/unit/event_spec.rb +6 -0
- data/spec/unit/filter_form_builder_spec.rb +9 -0
- data/spec/unit/form_builder_spec.rb +8 -14
- data/spec/unit/namespace/register_page_spec.rb +102 -0
- data/spec/unit/namespace/register_resource_spec.rb +188 -0
- data/spec/unit/namespace_spec.rb +11 -183
- data/spec/unit/page_controller_spec.rb +8 -0
- data/spec/unit/page_spec.rb +60 -0
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +24 -19
- data/spec/unit/resource/page_presenters_spec.rb +32 -0
- data/spec/unit/resource/scopes_spec.rb +13 -0
- data/spec/unit/resource_collection_spec.rb +101 -0
- data/spec/unit/resource_controller_spec.rb +40 -32
- data/spec/unit/{registration_spec.rb → resource_registration_spec.rb} +0 -0
- data/spec/unit/resource_spec.rb +8 -24
- data/spec/unit/routing_spec.rb +50 -1
- data/spec/unit/scope_spec.rb +18 -4
- data/spec/unit/views/components/paginated_collection_spec.rb +150 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/tasks/test.rake +43 -27
- metadata +140 -31
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/comments/configuration.rb +0 -18
- data/lib/active_admin/page_config.rb +0 -15
- data/lib/active_admin/resource_controller/form.rb +0 -42
- data/lib/active_admin/resource_controller/page_configurations.rb +0 -53
- data/lib/active_admin/views/pages/edit.rb +0 -28
- data/lib/active_admin/views/pages/new.rb +0 -28
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +0 -427
- data/spec/integration/belongs_to_spec.rb +0 -42
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveAdmin::Namespace, "registering a resource" do
|
4
|
+
|
5
|
+
let(:application){ ActiveAdmin::Application.new }
|
6
|
+
|
7
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
8
|
+
|
9
|
+
context "with no configuration" do
|
10
|
+
before do
|
11
|
+
namespace.register Category
|
12
|
+
end
|
13
|
+
it "should store the namespaced registered configuration" do
|
14
|
+
namespace.resources.keys.should include('Category')
|
15
|
+
end
|
16
|
+
it "should create a new controller in the default namespace" do
|
17
|
+
defined?(Admin::CategoriesController).should be_true
|
18
|
+
end
|
19
|
+
it "should create the dashboard controller" do
|
20
|
+
defined?(Admin::DashboardController).should be_true
|
21
|
+
end
|
22
|
+
it "should create a menu item" do
|
23
|
+
namespace.load_menu!
|
24
|
+
namespace.menu["Categories"].should be_an_instance_of(ActiveAdmin::MenuItem)
|
25
|
+
namespace.menu["Categories"].url.should == "/admin/categories"
|
26
|
+
end
|
27
|
+
end # context "with no configuration"
|
28
|
+
|
29
|
+
context "with a block configuration" do
|
30
|
+
it "should be evaluated in the dsl" do
|
31
|
+
lambda {
|
32
|
+
namespace.register Category do
|
33
|
+
raise "Hello World"
|
34
|
+
end
|
35
|
+
}.should raise_error
|
36
|
+
end
|
37
|
+
end # context "with a block configuration"
|
38
|
+
|
39
|
+
context "with a resource that's namespaced" do
|
40
|
+
before do
|
41
|
+
module ::Mock; class Resource; def self.has_many(arg1, arg2); end; end; end
|
42
|
+
namespace.register Mock::Resource
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should store the namespaced registered configuration" do
|
46
|
+
namespace.resources.keys.should include('MockResource')
|
47
|
+
end
|
48
|
+
it "should create a new controller in the default namespace" do
|
49
|
+
defined?(Admin::MockResourcesController).should be_true
|
50
|
+
end
|
51
|
+
it "should create a menu item" do
|
52
|
+
namespace.load_menu!
|
53
|
+
namespace.menu["Mock Resources"].should be_an_instance_of(ActiveAdmin::MenuItem)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should use the resource as the model in the controller" do
|
57
|
+
Admin::MockResourcesController.resource_class.should == Mock::Resource
|
58
|
+
end
|
59
|
+
|
60
|
+
end # context "with a resource that's namespaced"
|
61
|
+
|
62
|
+
describe "finding resource instances" do
|
63
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
64
|
+
|
65
|
+
it "should return the resource when its been registered" do
|
66
|
+
post = namespace.register Post
|
67
|
+
namespace.resource_for(Post).should == post
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return nil when the resource has not been registered' do
|
71
|
+
namespace.resource_for(Post).should == nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return the parent when the parent class has been registered and the child has not" do
|
75
|
+
user = namespace.register User
|
76
|
+
namespace.resource_for(Publisher).should == user
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should return the resource if it and it's parent were registered" do
|
80
|
+
user = namespace.register User
|
81
|
+
publisher = namespace.register Publisher
|
82
|
+
namespace.resource_for(Publisher).should == publisher
|
83
|
+
end
|
84
|
+
|
85
|
+
end # describe "finding resource instances"
|
86
|
+
|
87
|
+
describe "adding to the menu" do
|
88
|
+
describe "adding as a top level item" do
|
89
|
+
before do
|
90
|
+
namespace.register Category
|
91
|
+
namespace.load_menu!
|
92
|
+
end
|
93
|
+
it "should add a new menu item" do
|
94
|
+
namespace.menu['Categories'].should_not be_nil
|
95
|
+
end
|
96
|
+
end # describe "adding as a top level item"
|
97
|
+
|
98
|
+
describe "adding as a child" do
|
99
|
+
before do
|
100
|
+
namespace.register Category do
|
101
|
+
menu :parent => 'Blog'
|
102
|
+
end
|
103
|
+
namespace.load_menu!
|
104
|
+
end
|
105
|
+
it "should generate the parent menu item" do
|
106
|
+
namespace.menu['Blog'].should_not be_nil
|
107
|
+
end
|
108
|
+
it "should generate its own child item" do
|
109
|
+
namespace.menu['Blog']['Categories'].should_not be_nil
|
110
|
+
end
|
111
|
+
end # describe "adding as a child"
|
112
|
+
|
113
|
+
describe "disabling the menu" do
|
114
|
+
before do
|
115
|
+
namespace.register Category do
|
116
|
+
menu false
|
117
|
+
end
|
118
|
+
namespace.load_menu!
|
119
|
+
end
|
120
|
+
it "should not create a menu item" do
|
121
|
+
namespace.menu["Categories"].should be_nil
|
122
|
+
end
|
123
|
+
end # describe "disabling the menu"
|
124
|
+
|
125
|
+
describe "setting menu priority" do
|
126
|
+
before do
|
127
|
+
namespace.register Category do
|
128
|
+
menu :priority => 2
|
129
|
+
end
|
130
|
+
namespace.load_menu!
|
131
|
+
end
|
132
|
+
it "should have a custom priority of 2" do
|
133
|
+
namespace.menu["Categories"].priority.should == 2
|
134
|
+
end
|
135
|
+
end # describe "setting menu priority"
|
136
|
+
|
137
|
+
describe "setting a condition for displaying" do
|
138
|
+
before do
|
139
|
+
namespace.register Category do
|
140
|
+
menu :if => proc { false }
|
141
|
+
end
|
142
|
+
namespace.load_menu!
|
143
|
+
end
|
144
|
+
it "should have a proc returning false" do
|
145
|
+
namespace.menu["Categories"].display_if_block.should be_instance_of(Proc)
|
146
|
+
namespace.menu["Categories"].display_if_block.call.should == false
|
147
|
+
end
|
148
|
+
end # describe "setting a condition for displaying"
|
149
|
+
|
150
|
+
describe "adding as a belongs to" do
|
151
|
+
context "when not optional" do
|
152
|
+
before do
|
153
|
+
namespace.register Post do
|
154
|
+
belongs_to :author
|
155
|
+
end
|
156
|
+
end
|
157
|
+
it "should not show up in the menu" do
|
158
|
+
namespace.menu["Posts"].should be_nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
context "when optional" do
|
162
|
+
before do
|
163
|
+
namespace.register Post do
|
164
|
+
belongs_to :author, :optional => true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
it "should show up in the menu" do
|
168
|
+
namespace.menu["Posts"].should_not be_nil
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end # describe "adding to the menu"
|
173
|
+
|
174
|
+
describe "dashboard controller name" do
|
175
|
+
context "when namespaced" do
|
176
|
+
it "should be namespaced" do
|
177
|
+
namespace = ActiveAdmin::Namespace.new(application, :admin)
|
178
|
+
namespace.dashboard_controller_name.should == "Admin::DashboardController"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
context "when not namespaced" do
|
182
|
+
it "should not be namespaced" do
|
183
|
+
namespace = ActiveAdmin::Namespace.new(application, :root)
|
184
|
+
namespace.dashboard_controller_name.should == "DashboardController"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end # describe "dashboard controller name"
|
188
|
+
end # describe "registering a resource"
|
data/spec/unit/namespace_spec.rb
CHANGED
@@ -16,199 +16,27 @@ describe ActiveAdmin::Namespace do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have no resources" do
|
19
|
-
namespace.resources.should
|
19
|
+
namespace.resources.resources.should be_empty
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have an empty menu" do
|
23
23
|
namespace.menu.items.should be_empty
|
24
24
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "registering a resource" do
|
25
|
+
end # context "when new"
|
28
26
|
|
27
|
+
describe "settings" do
|
29
28
|
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
it "should store the namespaced registered configuration" do
|
36
|
-
namespace.resources.keys.should include('Category')
|
37
|
-
end
|
38
|
-
it "should create a new controller in the default namespace" do
|
39
|
-
defined?(Admin::CategoriesController).should be_true
|
40
|
-
end
|
41
|
-
it "should create the dashboard controller" do
|
42
|
-
defined?(Admin::DashboardController).should be_true
|
43
|
-
end
|
44
|
-
it "should create a menu item" do
|
45
|
-
namespace.load_menu!
|
46
|
-
namespace.menu["Categories"].should be_an_instance_of(ActiveAdmin::MenuItem)
|
47
|
-
namespace.menu["Categories"].url.should == "/admin/categories"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "with a block configuration" do
|
52
|
-
it "should be evaluated in the dsl" do
|
53
|
-
lambda {
|
54
|
-
namespace.register Category do
|
55
|
-
raise "Hello World"
|
56
|
-
end
|
57
|
-
}.should raise_error
|
58
|
-
end
|
30
|
+
it "should inherit the site title from the application" do
|
31
|
+
ActiveAdmin::Namespace.setting :site_title, "Not the Same"
|
32
|
+
namespace.site_title.should == application.site_title
|
59
33
|
end
|
60
34
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
namespace.register Mock::Resource
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should store the namespaced registered configuration" do
|
69
|
-
namespace.resources.keys.should include('MockResource')
|
70
|
-
end
|
71
|
-
it "should create a new controller in the default namespace" do
|
72
|
-
defined?(Admin::MockResourcesController).should be_true
|
73
|
-
end
|
74
|
-
it "should create a menu item" do
|
75
|
-
namespace.load_menu!
|
76
|
-
namespace.menu["Mock Resources"].should be_an_instance_of(ActiveAdmin::MenuItem)
|
77
|
-
end
|
78
|
-
it "should use the resource as the model in the controller" do
|
79
|
-
Admin::MockResourcesController.resource_class.should == Mock::Resource
|
80
|
-
end
|
81
|
-
|
35
|
+
it "should be able to override the site title" do
|
36
|
+
namespace.site_title.should == application.site_title
|
37
|
+
namespace.site_title = "My Site Title"
|
38
|
+
namespace.site_title.should_not == application.site_title
|
82
39
|
end
|
83
|
-
|
84
|
-
describe "finding resource instances" do
|
85
|
-
|
86
|
-
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
87
|
-
|
88
|
-
it "should return the resource when its been registered" do
|
89
|
-
post = namespace.register Post
|
90
|
-
namespace.resource_for(Post).should == post
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should return nil when the resource has not been registered' do
|
94
|
-
namespace.resource_for(Post).should == nil
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should return the parent when the parent class has been registered and the child has not" do
|
98
|
-
user = namespace.register User
|
99
|
-
namespace.resource_for(Publisher).should == user
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should return the resource if it and it's parent were registered" do
|
103
|
-
user = namespace.register User
|
104
|
-
publisher = namespace.register Publisher
|
105
|
-
namespace.resource_for(Publisher).should == publisher
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "adding to the menu" do
|
111
|
-
|
112
|
-
describe "adding as a top level item" do
|
113
|
-
before do
|
114
|
-
namespace.register Category
|
115
|
-
namespace.load_menu!
|
116
|
-
end
|
117
|
-
it "should add a new menu item" do
|
118
|
-
namespace.menu['Categories'].should_not be_nil
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "adding as a child" do
|
123
|
-
before do
|
124
|
-
namespace.register Category do
|
125
|
-
menu :parent => 'Blog'
|
126
|
-
end
|
127
|
-
namespace.load_menu!
|
128
|
-
end
|
129
|
-
it "should generate the parent menu item" do
|
130
|
-
namespace.menu['Blog'].should_not be_nil
|
131
|
-
end
|
132
|
-
it "should generate its own child item" do
|
133
|
-
namespace.menu['Blog']['Categories'].should_not be_nil
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "disabling the menu" do
|
138
|
-
before do
|
139
|
-
namespace.register Category do
|
140
|
-
menu false
|
141
|
-
end
|
142
|
-
namespace.load_menu!
|
143
|
-
end
|
144
|
-
it "should not create a menu item" do
|
145
|
-
namespace.menu["Categories"].should be_nil
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "setting menu priority" do
|
150
|
-
before do
|
151
|
-
namespace.register Category do
|
152
|
-
menu :priority => 2
|
153
|
-
end
|
154
|
-
namespace.load_menu!
|
155
|
-
end
|
156
|
-
it "should have a custom priority of 2" do
|
157
|
-
namespace.menu["Categories"].priority.should == 2
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
describe "setting a condition for displaying" do
|
162
|
-
before do
|
163
|
-
namespace.register Category do
|
164
|
-
menu :if => proc { false }
|
165
|
-
end
|
166
|
-
namespace.load_menu!
|
167
|
-
end
|
168
|
-
it "should have a proc returning false" do
|
169
|
-
namespace.menu["Categories"].display_if_block.should be_instance_of(Proc)
|
170
|
-
namespace.menu["Categories"].display_if_block.call.should == false
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe "adding as a belongs to" do
|
175
|
-
context "when not optional" do
|
176
|
-
before do
|
177
|
-
namespace.register Post do
|
178
|
-
belongs_to :author
|
179
|
-
end
|
180
|
-
end
|
181
|
-
it "should not show up in the menu" do
|
182
|
-
namespace.menu["Posts"].should be_nil
|
183
|
-
end
|
184
|
-
end
|
185
|
-
context "when optional" do
|
186
|
-
before do
|
187
|
-
namespace.register Post do
|
188
|
-
belongs_to :author, :optional => true
|
189
|
-
end
|
190
|
-
end
|
191
|
-
it "should show up in the menu" do
|
192
|
-
namespace.menu["Posts"].should_not be_nil
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
describe "dashboard controller name" do
|
199
|
-
context "when namespaced" do
|
200
|
-
it "should be namespaced" do
|
201
|
-
namespace = ActiveAdmin::Namespace.new(application, :admin)
|
202
|
-
namespace.dashboard_controller_name.should == "Admin::DashboardController"
|
203
|
-
end
|
204
|
-
end
|
205
|
-
context "when not namespaced" do
|
206
|
-
it "should not be namespaced" do
|
207
|
-
namespace = ActiveAdmin::Namespace.new(application, :root)
|
208
|
-
namespace.dashboard_controller_name.should == "DashboardController"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
40
|
end
|
41
|
+
|
214
42
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require File.expand_path('config_shared_examples', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
module ActiveAdmin
|
5
|
+
describe Page do
|
6
|
+
|
7
|
+
it_should_behave_like "ActiveAdmin::Config"
|
8
|
+
before { load_defaults! }
|
9
|
+
|
10
|
+
let(:application){ ActiveAdmin::Application.new }
|
11
|
+
let(:namespace){ Namespace.new(application, :admin) }
|
12
|
+
|
13
|
+
def config(options = {})
|
14
|
+
@config ||= Page.new(namespace, "Status", options)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "controller name" do
|
18
|
+
it "should return a namespaced controller name" do
|
19
|
+
config.controller_name.should == "Admin::StatusController"
|
20
|
+
end
|
21
|
+
context "when non namespaced controller" do
|
22
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :root) }
|
23
|
+
it "should return a non namespaced controller name" do
|
24
|
+
config.controller_name.should == "StatusController"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#resource_name" do
|
30
|
+
it "returns the name" do
|
31
|
+
config.resource_name.should == "Status"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#plural_resource_name" do
|
36
|
+
it "returns the singular name" do
|
37
|
+
config.plural_resource_name.should == "Status"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#underscored_resource_name" do
|
42
|
+
it "returns the underscored name" do
|
43
|
+
config.underscored_resource_name.should == "status"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not belong_to anything" do
|
48
|
+
config.belongs_to?.should == false
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not have any action_items" do
|
52
|
+
config.action_items?.should == false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not have any sidebar_sections" do
|
56
|
+
config.sidebar_sections?.should == false
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|