activeadmin 0.5.1 → 0.6.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/.travis.yml +8 -5
- data/CHANGELOG.md +151 -0
- data/Gemfile +16 -16
- data/LICENSE +1 -1
- data/activeadmin.gemspec +1 -0
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +10 -0
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +4 -0
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +13 -0
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +3 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +17 -44
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -4
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +0 -3
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +10 -12
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -10
- data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +3 -3
- data/app/assets/stylesheets/active_admin/_base.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/_header.css.scss +5 -2
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -4
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +14 -12
- data/docs/1-general-configuration.md +13 -0
- data/docs/10-custom-pages.md +40 -28
- data/docs/11-decorators.md +6 -4
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +206 -0
- data/docs/2-resource-customization.md +129 -14
- data/docs/3-index-pages.md +65 -0
- data/docs/3-index-pages/create-an-index.md +29 -0
- data/docs/3-index-pages/index-as-table.md +35 -11
- data/docs/5-forms.md +2 -2
- data/features/authorization.feature +64 -0
- data/features/authorization_cancan.feature +52 -0
- data/features/belongs_to.feature +41 -5
- data/features/index/batch_actions.feature +27 -3
- data/features/index/formats.feature +27 -0
- data/features/index/index_as_table.feature +74 -2
- data/features/index/index_parameters.feature +69 -0
- data/features/index/index_scopes.feature +7 -11
- data/features/index/page_title.feature +18 -0
- data/features/index/switch_index_view.feature +73 -0
- data/features/menu.feature +27 -0
- data/features/registering_pages.feature +21 -0
- data/features/step_definitions/additional_web_steps.rb +4 -0
- data/features/step_definitions/batch_action_steps.rb +16 -6
- data/features/step_definitions/index_scope_steps.rb +3 -3
- data/features/step_definitions/index_views_steps.rb +3 -0
- data/features/step_definitions/menu_steps.rb +4 -0
- data/features/support/env.rb +4 -0
- data/features/support/paths.rb +3 -0
- data/lib/active_admin.rb +4 -0
- data/lib/active_admin/application.rb +43 -76
- data/lib/active_admin/authorization_adapter.rb +128 -0
- data/lib/active_admin/base_controller.rb +18 -1
- data/lib/active_admin/base_controller/authorization.rb +153 -0
- data/lib/active_admin/base_controller/menu.rb +8 -3
- data/lib/active_admin/batch_actions/resource_extension.rb +8 -7
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +40 -0
- data/lib/active_admin/dashboards.rb +4 -5
- data/lib/active_admin/dashboards/dashboard_controller.rb +1 -1
- data/lib/active_admin/devise.rb +22 -7
- data/lib/active_admin/dsl.rb +18 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters/dsl.rb +1 -1
- data/lib/active_admin/filters/forms.rb +9 -7
- data/lib/active_admin/filters/resource_extension.rb +20 -15
- data/lib/active_admin/form_builder.rb +44 -49
- data/lib/active_admin/helpers/optional_display.rb +4 -8
- data/lib/active_admin/inputs/filter_boolean_input.rb +1 -1
- data/lib/active_admin/inputs/filter_string_input.rb +5 -1
- data/lib/active_admin/locales/bg.yml +1 -1
- data/lib/active_admin/locales/ca.yml +1 -1
- data/lib/active_admin/locales/cs.yml +26 -25
- data/lib/active_admin/locales/da.yml +1 -1
- data/lib/active_admin/locales/de.yml +1 -1
- data/lib/active_admin/locales/en.yml +11 -1
- data/lib/active_admin/locales/es.yml +16 -16
- data/lib/active_admin/locales/fr.yml +1 -1
- data/lib/active_admin/locales/he.yml +1 -1
- data/lib/active_admin/locales/hr.yml +1 -1
- data/lib/active_admin/locales/hu.yml +1 -1
- data/lib/active_admin/locales/it.yml +1 -1
- data/lib/active_admin/locales/ja.yml +4 -1
- data/lib/active_admin/locales/ko.yml +1 -1
- data/lib/active_admin/locales/lt.yml +1 -1
- data/lib/active_admin/locales/lv.yml +12 -1
- data/lib/active_admin/locales/nl.yml +2 -2
- data/lib/active_admin/locales/no-NB.yml +22 -1
- data/lib/active_admin/locales/pl.yml +1 -1
- data/lib/active_admin/locales/pt-BR.yml +1 -1
- data/lib/active_admin/locales/pt-PT.yml +81 -0
- data/lib/active_admin/locales/ro.yml +1 -1
- data/lib/active_admin/locales/ru.yml +1 -1
- data/lib/active_admin/locales/sv-SE.yml +1 -1
- data/lib/active_admin/locales/tr.yml +1 -1
- data/lib/active_admin/locales/vi.yml +1 -1
- data/lib/active_admin/locales/zh-CN.yml +1 -1
- data/lib/active_admin/locales/zh-TW.yml +1 -1
- data/lib/active_admin/menu.rb +76 -38
- data/lib/active_admin/menu_collection.rb +96 -0
- data/lib/active_admin/menu_item.rb +61 -71
- data/lib/active_admin/namespace.rb +67 -5
- data/lib/active_admin/page.rb +6 -0
- data/lib/active_admin/page_controller.rb +13 -3
- data/lib/active_admin/resource.rb +11 -20
- data/lib/active_admin/resource/action_items.rb +3 -3
- data/lib/active_admin/resource/controllers.rb +0 -17
- data/lib/active_admin/resource/menu.rb +52 -24
- data/lib/active_admin/resource/naming.rb +6 -10
- data/lib/active_admin/resource/page_presenters.rb +57 -3
- data/lib/active_admin/resource/routes.rb +46 -0
- data/lib/active_admin/resource_controller.rb +2 -17
- data/lib/active_admin/resource_controller/data_access.rb +299 -0
- data/lib/active_admin/resource_controller/decorators.rb +2 -1
- data/lib/active_admin/resource_dsl.rb +12 -14
- data/lib/active_admin/router.rb +61 -56
- data/lib/active_admin/scope.rb +28 -18
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +0 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +13 -19
- data/lib/active_admin/view_helpers/fields_for.rb +2 -0
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +66 -11
- data/lib/active_admin/views/components/attributes_table.rb +7 -4
- data/lib/active_admin/views/components/index_list.rb +68 -0
- data/lib/active_admin/views/components/paginated_collection.rb +13 -9
- data/lib/active_admin/views/components/scopes.rb +2 -8
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/footer.rb +1 -1
- data/lib/active_admin/views/header.rb +3 -2
- data/lib/active_admin/views/index_as_block.rb +4 -0
- data/lib/active_admin/views/index_as_blog.rb +4 -0
- data/lib/active_admin/views/index_as_grid.rb +4 -0
- data/lib/active_admin/views/index_as_table.rb +49 -7
- data/lib/active_admin/views/pages/index.rb +19 -4
- data/lib/active_admin/views/tabbed_navigation.rb +10 -54
- data/lib/generators/active_admin/install/install_generator.rb +5 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +58 -0
- data/spec/integration/{default_namespace.rb → default_namespace_spec.rb} +0 -16
- data/spec/spec_helper.rb +3 -0
- data/spec/support/detect_rails_version.rb +10 -3
- data/spec/support/rails_template.rb +1 -1
- data/spec/support/templates/post_decorator.rb +6 -6
- data/spec/unit/application_spec.rb +5 -5
- data/spec/unit/authorization/authorization_adapter_spec.rb +61 -0
- data/spec/unit/authorization/controller_authorization_spec.rb +47 -0
- data/spec/unit/base_controller_spec.rb +0 -2
- data/spec/unit/batch_actions/resource_spec.rb +1 -1
- data/spec/unit/breadcrumbs_spec.rb +3 -3
- data/spec/unit/cancan_adapter_spec.rb +35 -0
- data/spec/unit/config_shared_examples.rb +9 -30
- data/spec/unit/devise_spec.rb +29 -0
- data/spec/unit/dsl_spec.rb +61 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +58 -4
- data/spec/unit/filters/resource_spec.rb +17 -5
- data/spec/unit/form_builder_spec.rb +15 -0
- data/spec/unit/menu_collection_spec.rb +62 -0
- data/spec/unit/menu_item_spec.rb +51 -37
- data/spec/unit/menu_spec.rb +33 -29
- data/spec/unit/namespace/authorization_spec.rb +31 -0
- data/spec/unit/namespace/register_page_spec.rb +6 -28
- data/spec/unit/namespace/register_resource_spec.rb +11 -34
- data/spec/unit/namespace_spec.rb +63 -2
- data/spec/unit/page_controller_spec.rb +0 -3
- data/spec/unit/reloader_spec.rb +5 -5
- data/spec/unit/resource/menu_spec.rb +1 -13
- data/spec/unit/resource/naming_spec.rb +20 -2
- data/spec/unit/resource/page_presenters_spec.rb +14 -2
- data/spec/unit/resource_controller/{collection_spec.rb → data_access_spec.rb} +31 -13
- data/spec/unit/resource_controller_spec.rb +4 -5
- data/spec/unit/resource_spec.rb +33 -11
- data/spec/unit/routing_spec.rb +43 -0
- data/spec/unit/scope_spec.rb +13 -0
- data/spec/unit/view_factory_spec.rb +0 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +4 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +6 -2
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +97 -0
- data/spec/unit/views/components/attributes_table_spec.rb +11 -0
- data/spec/unit/views/components/index_list_spec.rb +32 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +42 -40
- data/tasks/test.rake +1 -1
- metadata +127 -40
- data/lib/active_admin/menu_builder.rb +0 -65
- data/lib/active_admin/resource_controller/callbacks.rb +0 -59
- data/lib/active_admin/resource_controller/collection.rb +0 -158
- data/lib/active_admin/views/utility_nav.rb +0 -41
- data/spec/unit/base_controller_shared_examples.rb +0 -25
- data/spec/unit/dsl_include_spec.rb +0 -20
@@ -69,12 +69,22 @@ module ActiveAdmin
|
|
69
69
|
# If a column is defined using a block, you must pass the key to turn on sorting. The key
|
70
70
|
# is the attribute which gets used to sort objects using Active Record.
|
71
71
|
#
|
72
|
+
# By default, this is the column on the resource's table that the attribute corresponds to.
|
73
|
+
# Otherwise, any attribute that the resource collection responds to can be used.
|
74
|
+
#
|
72
75
|
# index do
|
73
76
|
# column "Title", :sortable => :title do |post|
|
74
77
|
# link_to post.title, admin_post_path(post)
|
75
78
|
# end
|
76
79
|
# end
|
77
80
|
#
|
81
|
+
# You can also sort using an attribute on another table by passing the table name
|
82
|
+
# and the attribute separated by a dot:
|
83
|
+
#
|
84
|
+
# index do
|
85
|
+
# column :title, :sortable => 'categories.name'
|
86
|
+
# end
|
87
|
+
#
|
78
88
|
# You can turn off sorting on any column by passing false:
|
79
89
|
#
|
80
90
|
# index do
|
@@ -99,7 +109,7 @@ module ActiveAdmin
|
|
99
109
|
|
100
110
|
def build(page_presenter, collection)
|
101
111
|
table_options = {
|
102
|
-
:id => active_admin_config.resource_name.plural,
|
112
|
+
:id => "index_table_#{active_admin_config.resource_name.plural}",
|
103
113
|
:sortable => true,
|
104
114
|
:class => "index_table index",
|
105
115
|
:i18n => active_admin_config.resource_class,
|
@@ -126,6 +136,10 @@ module ActiveAdmin
|
|
126
136
|
end
|
127
137
|
end
|
128
138
|
|
139
|
+
def self.index_name
|
140
|
+
"table"
|
141
|
+
end
|
142
|
+
|
129
143
|
#
|
130
144
|
# Extend the default ActiveAdmin::Views::TableFor with some
|
131
145
|
# methods for quickly displaying items on the index page
|
@@ -145,24 +159,52 @@ module ActiveAdmin
|
|
145
159
|
end
|
146
160
|
end
|
147
161
|
|
148
|
-
#
|
149
|
-
|
162
|
+
# Add links to perform actions.
|
163
|
+
#
|
164
|
+
# # Add default links.
|
165
|
+
# actions
|
166
|
+
#
|
167
|
+
# # Append some actions onto the end of the default actions.
|
168
|
+
# actions do |admin_user|
|
169
|
+
# link_to 'Grant Admin', grant_admin_admin_user_path(admin_user)
|
170
|
+
# end
|
171
|
+
#
|
172
|
+
# # Custom actions without the defaults.
|
173
|
+
# actions :defaults => false do |admin_user|
|
174
|
+
# link_to 'Grant Admin', grant_admin_admin_user_path(admin_user)
|
175
|
+
# end
|
176
|
+
def actions(options = {}, &block)
|
150
177
|
options = {
|
151
|
-
:name => ""
|
178
|
+
:name => "",
|
179
|
+
:defaults => true
|
152
180
|
}.merge(options)
|
153
181
|
column options[:name] do |resource|
|
182
|
+
text_node default_actions(resource) if options[:defaults]
|
183
|
+
text_node instance_exec(resource, &block) if block_given?
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def default_actions(*args)
|
188
|
+
links = proc do |resource|
|
154
189
|
links = ''.html_safe
|
155
|
-
if controller.action_methods.include?('show')
|
190
|
+
if controller.action_methods.include?('show') && authorized?(ActiveAdmin::Auth::READ, resource)
|
156
191
|
links << link_to(I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link")
|
157
192
|
end
|
158
|
-
if controller.action_methods.include?('edit')
|
193
|
+
if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
|
159
194
|
links << link_to(I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link")
|
160
195
|
end
|
161
|
-
if controller.action_methods.include?('destroy')
|
196
|
+
if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
|
162
197
|
links << link_to(I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation')}, :class => "member_link delete_link")
|
163
198
|
end
|
164
199
|
links
|
165
200
|
end
|
201
|
+
|
202
|
+
options = args.extract_options!
|
203
|
+
if options.present? || args.empty?
|
204
|
+
actions options
|
205
|
+
else
|
206
|
+
links.call(args.first)
|
207
|
+
end
|
166
208
|
end
|
167
209
|
|
168
210
|
# Display A Status Tag Column
|
@@ -7,15 +7,16 @@ module ActiveAdmin
|
|
7
7
|
class Index < Base
|
8
8
|
|
9
9
|
def title
|
10
|
-
|
11
|
-
|
10
|
+
case config[:title]
|
11
|
+
when Proc then controller.instance_eval(&config[:title])
|
12
|
+
when String then config[:title]
|
12
13
|
else
|
13
14
|
active_admin_config.plural_resource_label
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
def config
|
18
|
-
active_admin_config.get_page_presenter(:index) || default_index_config
|
19
|
+
active_admin_config.get_page_presenter(:index, params[:as]) || default_index_config
|
19
20
|
end
|
20
21
|
|
21
22
|
# Render's the index configuration that was set in the
|
@@ -61,6 +62,7 @@ module ActiveAdmin
|
|
61
62
|
div :class => "table_tools" do
|
62
63
|
build_batch_actions_selector
|
63
64
|
build_scopes
|
65
|
+
build_index_list
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
@@ -80,6 +82,19 @@ module ActiveAdmin
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
85
|
+
def build_index_list
|
86
|
+
indexes = active_admin_config.page_presenters[:index]
|
87
|
+
|
88
|
+
if indexes.kind_of?(Hash) && indexes.length > 1
|
89
|
+
index_classes = []
|
90
|
+
active_admin_config.page_presenters[:index].each do |type, page_presenter|
|
91
|
+
index_classes << find_index_renderer_class(page_presenter[:as])
|
92
|
+
end
|
93
|
+
|
94
|
+
index_list_renderer index_classes
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
83
98
|
# Creates a default configuration for the resource class. This is a table
|
84
99
|
# with each column displayed as well as all the default actions
|
85
100
|
def default_index_config
|
@@ -122,7 +137,7 @@ module ActiveAdmin
|
|
122
137
|
def render_index
|
123
138
|
renderer_class = find_index_renderer_class(config[:as])
|
124
139
|
paginator = config[:paginator].nil? ? true : config[:paginator]
|
125
|
-
download_links = config[:download_links].nil? ?
|
140
|
+
download_links = config[:download_links].nil? ? active_admin_config.namespace.download_links : config[:download_links]
|
126
141
|
|
127
142
|
paginated_collection(collection, :entry_name => active_admin_config.resource_label,
|
128
143
|
:entries_name => active_admin_config.plural_resource_label,
|
@@ -22,9 +22,9 @@ module ActiveAdmin
|
|
22
22
|
build_menu
|
23
23
|
end
|
24
24
|
|
25
|
-
#
|
25
|
+
# The top-level menu items that should be displayed.
|
26
26
|
def menu_items
|
27
|
-
|
27
|
+
menu.items(self)
|
28
28
|
end
|
29
29
|
|
30
30
|
def tag_name
|
@@ -40,35 +40,16 @@ module ActiveAdmin
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def build_menu_item(item)
|
43
|
-
li :id => item.
|
44
|
-
|
45
|
-
link_path = url_for_menu_item(item)
|
43
|
+
li :id => item.id do |li|
|
44
|
+
li.add_class "current" if item.current? assigns[:current_tab]
|
46
45
|
|
47
|
-
|
48
|
-
li_element.add_class "has_nested"
|
49
|
-
text_node link_to(item.label, link_path)
|
50
|
-
render_nested_menu(item)
|
51
|
-
else
|
52
|
-
link_to item.label, link_path
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def url_for_menu_item(menu_item)
|
58
|
-
case menu_item.url
|
59
|
-
when Symbol
|
60
|
-
send(menu_item.url)
|
61
|
-
when nil
|
62
|
-
"#"
|
63
|
-
else
|
64
|
-
menu_item.url
|
65
|
-
end
|
66
|
-
end
|
46
|
+
text_node link_to item.label(self), item.url(self), item.html_options
|
67
47
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
48
|
+
if children = item.items(self).presence
|
49
|
+
li.add_class "has_nested"
|
50
|
+
ul do
|
51
|
+
children.each{ |child| build_menu_item child }
|
52
|
+
end
|
72
53
|
end
|
73
54
|
end
|
74
55
|
end
|
@@ -76,31 +57,6 @@ module ActiveAdmin
|
|
76
57
|
def default_options
|
77
58
|
{ :id => "tabs" }
|
78
59
|
end
|
79
|
-
|
80
|
-
# Returns true if the menu item name is @current_tab (set in controller)
|
81
|
-
def current?(menu_item)
|
82
|
-
assigns[:current_tab] == menu_item || menu_item.children.include?(assigns[:current_tab])
|
83
|
-
end
|
84
|
-
|
85
|
-
# Returns an Array of items to display
|
86
|
-
def displayable_items(items)
|
87
|
-
items.select do |item|
|
88
|
-
display_item? item
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Returns true if the item should be displayed
|
93
|
-
def display_item?(item)
|
94
|
-
return false unless call_method_or_proc_on(self, item.display_if_block)
|
95
|
-
return false if (!item.url || item.url == "#") && !displayable_children?(item)
|
96
|
-
true
|
97
|
-
end
|
98
|
-
|
99
|
-
# Returns true if the item has any children that should be displayed
|
100
|
-
def displayable_children?(item)
|
101
|
-
!item.children.find{|child| display_item?(child) }.nil?
|
102
|
-
end
|
103
60
|
end
|
104
|
-
|
105
61
|
end
|
106
62
|
end
|
@@ -27,7 +27,11 @@ module ActiveAdmin
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def setup_routes
|
30
|
-
|
30
|
+
if ARGV.include? "--skip-users"
|
31
|
+
route "ActiveAdmin.routes(self)"
|
32
|
+
else # Ensure Active Admin routes occur after Devise routes so that Devise has higher priority
|
33
|
+
inject_into_file "config/routes.rb", "\n ActiveAdmin.routes(self)", :after => /devise_for.*/
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def create_assets
|
@@ -149,4 +149,62 @@ ActiveAdmin.setup do |config|
|
|
149
149
|
#
|
150
150
|
# Set the CSV builder options (default is {})
|
151
151
|
# config.csv_options = {}
|
152
|
+
|
153
|
+
|
154
|
+
# == Menu System
|
155
|
+
#
|
156
|
+
# You can add a navigation menu to be used in your application, or configure a provided menu
|
157
|
+
#
|
158
|
+
# To change the default utility navigation to show a link to your website & a logout btn
|
159
|
+
#
|
160
|
+
# config.namespace :admin do |admin|
|
161
|
+
# admin.build_menu :utility_navigation do |menu|
|
162
|
+
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
|
163
|
+
# admin.add_logout_button_to_menu menu
|
164
|
+
# end
|
165
|
+
# end
|
166
|
+
#
|
167
|
+
# If you wanted to add a static menu item to the default menu provided:
|
168
|
+
#
|
169
|
+
# config.namespace :admin do |admin|
|
170
|
+
# admin.build_menu :default do |menu|
|
171
|
+
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
|
172
|
+
# end
|
173
|
+
# end
|
174
|
+
|
175
|
+
# == Download Links
|
176
|
+
#
|
177
|
+
# You can disable download links on resource listing pages,
|
178
|
+
# or customize the formats shown per namespace/globally
|
179
|
+
#
|
180
|
+
# To disable/customize for the :admin namespace:
|
181
|
+
#
|
182
|
+
# config.namespace :admin do |admin|
|
183
|
+
#
|
184
|
+
# # Disable the links entirely
|
185
|
+
# admin.download_links = false
|
186
|
+
#
|
187
|
+
# # Only show XML & PDF options
|
188
|
+
# admin.download_links = [:xml, :pdf]
|
189
|
+
#
|
190
|
+
# end
|
191
|
+
|
192
|
+
|
193
|
+
# == Pagination
|
194
|
+
#
|
195
|
+
# Pagination is enabled by default for all resources.
|
196
|
+
# You can control the default per page count for all resources here.
|
197
|
+
#
|
198
|
+
# config.default_per_page = 30
|
199
|
+
|
200
|
+
|
201
|
+
# == Filters
|
202
|
+
#
|
203
|
+
# By default the index screen includes a “Filters” sidebar on the right
|
204
|
+
# hand side with a filter for each attribute of the registered model.
|
205
|
+
# You can enable or disable them for all resources here.
|
206
|
+
#
|
207
|
+
# config.filters = true
|
208
|
+
|
209
|
+
|
152
210
|
end
|
@@ -21,14 +21,6 @@ describe ActiveAdmin::Application do
|
|
21
21
|
ActiveAdmin.application = @__original_application
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should generate a dashboard controller" do
|
25
|
-
defined?(::DashboardController).should be_true
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should generate a dashboard route" do
|
29
|
-
dashboard_path.should == "/"
|
30
|
-
end
|
31
|
-
|
32
24
|
it "should generate a log out path" do
|
33
25
|
destroy_admin_user_session_path.should == "/admin_users/logout"
|
34
26
|
end
|
@@ -56,14 +48,6 @@ describe ActiveAdmin::Application do
|
|
56
48
|
ActiveAdmin.application = @__original_application
|
57
49
|
end
|
58
50
|
|
59
|
-
it "should generate a dashboard controller" do
|
60
|
-
defined?(::Test::DashboardController).should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should generate a dashboard route" do
|
64
|
-
test_dashboard_path.should == "/test"
|
65
|
-
end
|
66
|
-
|
67
51
|
it "should generate a log out path" do
|
68
52
|
destroy_admin_user_session_path.should == "/test/logout"
|
69
53
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -116,6 +116,8 @@ ENV["RAILS_ASSET_ID"] = ''
|
|
116
116
|
RSpec.configure do |config|
|
117
117
|
config.use_transactional_fixtures = true
|
118
118
|
config.use_instantiated_fixtures = false
|
119
|
+
config.include Devise::TestHelpers, :type => :controller
|
120
|
+
config.render_views = false
|
119
121
|
end
|
120
122
|
|
121
123
|
# All RSpec configuration needs to happen before any examples
|
@@ -123,6 +125,7 @@ end
|
|
123
125
|
require 'integration_example_group'
|
124
126
|
RSpec.configure do |c|
|
125
127
|
c.include RSpec::Rails::IntegrationExampleGroup, :example_group => { :file_path => /\bspec\/integration\// }
|
128
|
+
c.include Devise::TestHelpers, :type => :controller
|
126
129
|
end
|
127
130
|
|
128
131
|
# Ensure this is defined for Ruby 1.8
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# Detects the current version of Rails that is being used
|
2
2
|
#
|
3
3
|
#
|
4
|
-
unless defined?
|
4
|
+
unless defined? RAILS_VERSION_FILE
|
5
5
|
RAILS_VERSION_FILE = File.expand_path("../../../.rails-version", __FILE__)
|
6
6
|
end
|
7
7
|
|
8
|
-
unless defined?
|
9
|
-
|
8
|
+
unless defined? TRAVIS_CONFIG
|
9
|
+
require 'yaml'
|
10
|
+
filename = File.expand_path("../../../.travis.yml", __FILE__)
|
11
|
+
TRAVIS_CONFIG = YAML.load_file filename
|
12
|
+
TRAVIS_RAILS_VERSIONS = TRAVIS_CONFIG['env'].grep(/RAILS=(.*)/){ $1 }.sort
|
13
|
+
end
|
14
|
+
|
15
|
+
unless defined? DEFAULT_RAILS_VERSION
|
16
|
+
DEFAULT_RAILS_VERSION = TRAVIS_RAILS_VERSIONS.last
|
10
17
|
end
|
11
18
|
|
12
19
|
def detect_rails_version
|
@@ -16,7 +16,7 @@ inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'Us
|
|
16
16
|
copy_file File.expand_path('../templates/post_decorator.rb', __FILE__), "app/models/post_decorator.rb"
|
17
17
|
|
18
18
|
# Rails 3.2.3 model generator declare attr_accessible
|
19
|
-
inject_into_file 'app/models/post.rb', " attr_accessible :author\n", :before => "end" if Rails::VERSION::STRING >= '3.2
|
19
|
+
inject_into_file 'app/models/post.rb', " attr_accessible :author\n", :before => "end" if Rails::VERSION::STRING >= '3.2'
|
20
20
|
generate :model, "user type:string first_name:string last_name:string username:string age:integer"
|
21
21
|
inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n"
|
22
22
|
generate :model, "publisher --migration=false --parent=User"
|
@@ -8,12 +8,12 @@ require_dependency 'post'
|
|
8
8
|
class PostDecorator < SimpleDelegator
|
9
9
|
delegate :id, :to => :__getobj__
|
10
10
|
|
11
|
-
def self.decorate(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def self.decorate(object)
|
12
|
+
new(object)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.decorate_collection(collection)
|
16
|
+
DecoratedEnumerableProxy.new(collection)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.model_name
|
@@ -95,18 +95,18 @@ describe ActiveAdmin::Application do
|
|
95
95
|
|
96
96
|
describe "files in load path" do
|
97
97
|
it "should load files in the first level directory" do
|
98
|
-
application.
|
98
|
+
application.files.should include(File.expand_path("app/admin/dashboard.rb", Rails.root))
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should load files from subdirectories" do
|
102
102
|
FileUtils.mkdir_p(File.expand_path("app/admin/public", Rails.root))
|
103
103
|
test_file = File.expand_path("app/admin/public/posts.rb", Rails.root)
|
104
104
|
FileUtils.touch(test_file)
|
105
|
-
application.
|
105
|
+
application.files.should include(test_file)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
describe "#namespace
|
109
|
+
describe "#namespace" do
|
110
110
|
|
111
111
|
it "should yield a new namespace" do
|
112
112
|
application.namespace :new_namespace do |ns|
|
@@ -115,7 +115,7 @@ describe ActiveAdmin::Application do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should return an instantiated namespace" do
|
118
|
-
admin = application.
|
118
|
+
admin = application.namespace :admin
|
119
119
|
admin.should == application.namespaces[:admin]
|
120
120
|
end
|
121
121
|
|
@@ -132,7 +132,7 @@ describe ActiveAdmin::Application do
|
|
132
132
|
describe "#register_page" do
|
133
133
|
it "finds or create the namespace and register the page to it" do
|
134
134
|
namespace = mock
|
135
|
-
application.should_receive(:
|
135
|
+
application.should_receive(:namespace).with("public").and_return namespace
|
136
136
|
namespace.should_receive(:register_page).with("My Page", {:namespace => "public"})
|
137
137
|
|
138
138
|
application.register_page("My Page", :namespace => "public")
|