activeadmin 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +164 -5
- data/CONTRIBUTING.md +113 -0
- data/Gemfile +7 -9
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +4 -2
- 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 +17 -341
- 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/components/_tables.css.scss +43 -2
- 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/_utilities.scss +9 -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 +43 -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 +59 -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 +11 -3
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/comment_steps.rb +3 -3
- data/features/step_definitions/configuration_steps.rb +69 -13
- data/features/step_definitions/dashboard_steps.rb +7 -3
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/format_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +18 -6
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/pagination_steps.rb +2 -2
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/step_definitions/tab_steps.rb +1 -1
- data/features/step_definitions/user_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +4 -4
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +26 -10
- data/lib/active_admin/application.rb +64 -22
- data/lib/active_admin/arbre.rb +0 -1
- data/lib/active_admin/arbre/builder.rb +8 -5
- data/lib/active_admin/arbre/context.rb +1 -1
- data/lib/active_admin/arbre/html/attributes.rb +1 -1
- data/lib/active_admin/arbre/html/class_list.rb +0 -4
- data/lib/active_admin/arbre/html/collection.rb +2 -2
- data/lib/active_admin/arbre/html/document.rb +1 -1
- data/lib/active_admin/arbre/html/element.rb +19 -9
- data/lib/active_admin/arbre/html/tag.rb +3 -3
- data/lib/active_admin/arbre/html/text_node.rb +2 -2
- 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/callbacks.rb +16 -18
- 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 +21 -5
- 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/helpers/settings.rb +6 -10
- 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 +44 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/hu.yml +45 -0
- data/lib/active_admin/locales/it.yml +11 -6
- 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/menu_item.rb +25 -17
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +65 -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/reloader.rb +109 -42
- 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 +53 -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 +8 -8
- 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/columns.rb +4 -4
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/panel.rb +8 -0
- data/lib/active_admin/views/components/scopes.rb +24 -18
- 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/script/use_rails +14 -7
- data/spec/spec_helper.rb +9 -14
- data/spec/spec_helper_without_rails.rb +10 -0
- data/spec/support/detect_rails_version.rb +22 -3
- data/spec/support/integration_example_group.rb +5 -7
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/rails_template_with_data.rb +25 -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/context_spec.rb +1 -1
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/arbre/html/element_spec.rb +18 -5
- data/spec/unit/arbre/html/tag_attributes_spec.rb +3 -3
- data/spec/unit/arbre/html/tag_spec.rb +1 -1
- data/spec/unit/arbre/html_spec.rb +32 -22
- 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 +119 -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/menu_item_spec.rb +25 -20
- 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/reloader_spec.rb +82 -38
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +25 -20
- 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 +163 -0
- data/spec/unit/views/components/panel_spec.rb +9 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -1
- data/tasks/test.rake +44 -26
- metadata +176 -69
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/arbre/core_extensions.rb +0 -5
- 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
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
|
data/spec/unit/reloader_spec.rb
CHANGED
@@ -13,68 +13,112 @@ rescue
|
|
13
13
|
module ActionDispatch; module Callbacks; def self.to_prepare; end; end; end
|
14
14
|
end
|
15
15
|
|
16
|
+
major_rails_version = Rails.version[0..2]
|
17
|
+
|
16
18
|
|
17
19
|
describe ActiveAdmin::Reloader do
|
18
20
|
|
19
21
|
let(:rails_app){ mock(:reload_routes! => true)}
|
20
22
|
let(:mock_app){ mock(:load_paths => ["app/admin"], :unload! => true)}
|
21
|
-
let(:reloader){ ActiveAdmin::Reloader.
|
23
|
+
let(:reloader){ ActiveAdmin::Reloader.build(rails_app, mock_app, rails_version) }
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
ActiveAdmin::Reloader.new(rails_app, mock_app, '3.1.0').attach!
|
26
|
-
end
|
25
|
+
context "when Rails version < 3.2" do
|
26
|
+
let(:rails_version){ "3.1.0" }
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
describe "initialization" do
|
29
|
+
|
30
|
+
it "should initialize a new file update checker" do
|
31
|
+
ActiveSupport::FileUpdateChecker.should_receive(:new).with(mock_app.load_paths).and_return(mock(:execute_if_updated => true))
|
32
|
+
ActiveAdmin::Reloader.build(rails_app, mock_app, '3.1.0')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should build a RailsLessThan31Reloader" do
|
36
|
+
reloader.class.should == ActiveAdmin::Reloader::RailsLessThan31Reloader
|
37
|
+
end
|
33
38
|
|
34
|
-
it "should use ActionDispatch::Callbacks if rails 3.0" do
|
35
|
-
reloader = ActiveAdmin::Reloader.new rails_app, mock_app, '3.0.0'
|
36
|
-
reloader.reloader_class.should == ActionDispatch::Callbacks
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
+
describe "#reloader_class" do
|
42
|
+
|
43
|
+
it "should use ActionDispatch::Reloader if rails 3.1" do
|
44
|
+
reloader = ActiveAdmin::Reloader.build rails_app, mock_app, '3.1.0'
|
45
|
+
reloader.reloader_class.should == ActionDispatch::Reloader
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should use ActionDispatch::Callbacks if rails 3.0" do
|
49
|
+
reloader = ActiveAdmin::Reloader.build rails_app, mock_app, '3.0.0'
|
50
|
+
reloader.reloader_class.should == ActionDispatch::Callbacks
|
51
|
+
end
|
41
52
|
|
42
|
-
it "should unload the active admin app" do
|
43
|
-
mock_app.should_receive(:unload!)
|
44
|
-
reloader.reload!
|
45
53
|
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
55
|
+
describe "#reload!" do
|
56
|
+
|
57
|
+
it "should unload the active admin app" do
|
58
|
+
mock_app.should_receive(:unload!)
|
59
|
+
reloader.reload!
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should reload the rails app routes" do
|
63
|
+
rails_app.should_receive(:reload_routes!)
|
64
|
+
reloader.reload!
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should reset the files within the file_update_checker' do
|
68
|
+
reloader.file_update_checker.paths.should_receive(:clear)
|
69
|
+
reloader.file_update_checker.paths.should_receive(:<<).with("app/admin")
|
70
|
+
reloader.reload!
|
71
|
+
end
|
72
|
+
|
50
73
|
end
|
51
74
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
75
|
+
describe "#watched_paths" do
|
76
|
+
let(:mock_app){ ActiveAdmin::Application.new }
|
77
|
+
let(:admin_path){ File.join(Rails.root, "app", "admin") }
|
78
|
+
|
79
|
+
before do
|
80
|
+
mock_app.load_paths = [admin_path]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return the load path directories" do
|
84
|
+
reloader.watched_paths.should include(admin_path)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should include all files in the directory" do
|
88
|
+
root = Rails.root + "/app/admin"
|
89
|
+
reloader.watched_paths.should include(*Dir["#{admin_path}/**/*.rb"])
|
90
|
+
end
|
91
|
+
|
56
92
|
end
|
57
93
|
|
58
94
|
end
|
59
95
|
|
60
|
-
|
61
|
-
let(:
|
62
|
-
let(:admin_path){ File.join(Rails.root, "app", "admin") }
|
96
|
+
context "when Rails >= 3.2" do
|
97
|
+
let(:rails_version){ "3.2.0" }
|
63
98
|
|
64
|
-
|
65
|
-
mock_app.load_paths = [admin_path]
|
66
|
-
end
|
99
|
+
describe "initialization" do
|
67
100
|
|
68
|
-
|
69
|
-
|
70
|
-
|
101
|
+
it "should build a Rails32Reloader" do
|
102
|
+
reloader.class.should == ActiveAdmin::Reloader::Rails32Reloader
|
103
|
+
end
|
71
104
|
|
72
|
-
it "should include all files in the directory" do
|
73
|
-
root = Rails.root + "/app/admin"
|
74
|
-
reloader.watched_paths.should include(*Dir["#{admin_path}/**/*.rb"])
|
75
105
|
end
|
76
106
|
|
77
|
-
|
107
|
+
describe "attach!" do
|
108
|
+
before do
|
109
|
+
mock_app.load_paths << "app/active_admin"
|
110
|
+
ActionDispatch::Reloader.stub!(:to_prepare => true)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should the load paths to the watchable_dirs" do
|
114
|
+
config = mock(:watchable_dirs => {})
|
115
|
+
rails_app.should_receive(:config).twice.and_return(config)
|
116
|
+
reloader.attach!
|
78
117
|
|
118
|
+
config.watchable_dirs["app/admin"].should == [:rb]
|
119
|
+
config.watchable_dirs["app/active_admin"].should == [:rb]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
79
123
|
|
80
124
|
end
|
@@ -16,65 +16,15 @@ module ActiveAdmin
|
|
16
16
|
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
17
17
|
subject{ resource }
|
18
18
|
|
19
|
-
context "when regular resource" do
|
20
|
-
let(:resource){ namespace.register(Post) }
|
21
|
-
it { should be_include_in_menu }
|
22
|
-
end
|
23
19
|
context "when belongs to" do
|
24
20
|
let(:resource){ namespace.register(Post){ belongs_to :author } }
|
25
21
|
it { should_not be_include_in_menu }
|
26
22
|
end
|
23
|
+
|
27
24
|
context "when belongs to optional" do
|
28
25
|
let(:resource){ namespace.register(Post){ belongs_to :author, :optional => true} }
|
29
26
|
it { should be_include_in_menu }
|
30
27
|
end
|
31
|
-
context "when menu set to false" do
|
32
|
-
let(:resource){ namespace.register(Post){ menu false } }
|
33
|
-
it { should_not be_include_in_menu }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "menu item name" do
|
38
|
-
it "should be the resource name when not set" do
|
39
|
-
config.menu_item_name.should == "Categories"
|
40
|
-
end
|
41
|
-
it "should be settable" do
|
42
|
-
config.menu :label => "My Label"
|
43
|
-
config.menu_item_name.should == "My Label"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "parent menu item name" do
|
48
|
-
it "should be nil when not set" do
|
49
|
-
config.parent_menu_item_name.should == nil
|
50
|
-
end
|
51
|
-
it "should return the name if set" do
|
52
|
-
config.tap do |c|
|
53
|
-
c.menu :parent => "Blog"
|
54
|
-
end.parent_menu_item_name.should == "Blog"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "menu item priority" do
|
59
|
-
it "should be 10 when not set" do
|
60
|
-
config.menu_item_priority.should == 10
|
61
|
-
end
|
62
|
-
it "should be settable" do
|
63
|
-
config.menu :priority => 2
|
64
|
-
config.menu_item_priority.should == 2
|
65
|
-
end
|
66
28
|
end
|
67
|
-
|
68
|
-
describe "menu item display if" do
|
69
|
-
it "should be a proc always returning true if not set" do
|
70
|
-
config.menu_item_display_if.should be_instance_of(Proc)
|
71
|
-
config.menu_item_display_if.call.should == true
|
72
|
-
end
|
73
|
-
it "should be settable" do
|
74
|
-
config.menu :if => proc { false }
|
75
|
-
config.menu_item_display_if.call.should == false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
29
|
end
|
80
30
|
end
|