activeadmin 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.mdlrc +1 -0
- data/.rubocop.yml +52 -3
- data/.simplecov +13 -0
- data/.travis.yml +9 -24
- data/.yardopts +0 -1
- data/CHANGELOG.md +85 -4
- data/CONTRIBUTING.md +33 -57
- data/Gemfile +26 -17
- data/Rakefile +1 -12
- data/activeadmin.gemspec +9 -11
- data/app/assets/javascripts/active_admin/base.js.coffee +6 -2
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +6 -3
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +9 -7
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +5 -2
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +6 -2
- data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +3 -5
- data/app/assets/stylesheets/active_admin/_base.scss +2 -2
- data/app/assets/stylesheets/active_admin/_forms.scss +6 -12
- data/app/assets/stylesheets/active_admin/components/_batch_actions.scss +0 -5
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +11 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -0
- data/app/assets/stylesheets/active_admin/components/_tables.scss +4 -1
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -2
- data/app/assets/stylesheets/active_admin/print.scss +2 -3
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +12 -6
- data/app/views/kaminari/active_admin/_first_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_gap.html.erb +8 -0
- data/app/views/kaminari/active_admin/_last_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_next_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_page.html.erb +12 -0
- data/app/views/kaminari/active_admin/_paginator.html.erb +25 -0
- data/app/views/kaminari/active_admin/_prev_page.html.erb +11 -0
- data/codecov.yml +14 -12
- data/config/i18n-tasks.yml +26 -0
- data/config/locales/ar.yml +1 -3
- data/config/locales/bg.yml +0 -2
- data/config/locales/bs.yml +0 -2
- data/config/locales/ca.yml +0 -2
- data/config/locales/cs.yml +0 -2
- data/config/locales/da.yml +1 -3
- data/config/locales/de-CH.yml +1 -3
- data/config/locales/de.yml +1 -3
- data/config/locales/el.yml +1 -3
- data/config/locales/en-CA.yml +138 -0
- data/config/locales/en-GB.yml +43 -3
- data/config/locales/en.yml +8 -4
- data/config/locales/es-MX.yml +3 -2
- data/config/locales/es.yml +10 -4
- data/config/locales/fa.yml +0 -2
- data/config/locales/fi.yml +0 -2
- data/config/locales/fr.yml +9 -2
- data/config/locales/he.yml +53 -7
- data/config/locales/hr.yml +0 -2
- data/config/locales/hu.yml +0 -2
- data/config/locales/id.yml +1 -3
- data/config/locales/it.yml +2 -4
- data/config/locales/ja.yml +1 -3
- data/config/locales/ko.yml +0 -2
- data/config/locales/lt.yml +24 -4
- data/config/locales/lv.yml +0 -2
- data/config/locales/nb.yml +0 -2
- data/config/locales/nl.yml +1 -3
- data/config/locales/pl.yml +3 -2
- data/config/locales/pt-BR.yml +1 -3
- data/config/locales/pt-PT.yml +0 -2
- data/config/locales/ro.yml +0 -2
- data/config/locales/ru.yml +1 -3
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv-SE.yml +1 -3
- data/config/locales/tr.yml +0 -2
- data/config/locales/uk.yml +1 -3
- data/config/locales/vi.yml +0 -2
- data/config/locales/zh-CN.yml +0 -2
- data/config/locales/zh-TW.yml +1 -3
- data/config/mdl_style.rb +9 -0
- data/cucumber.yml +3 -3
- data/docs/0-installation.md +15 -12
- data/docs/1-general-configuration.md +10 -3
- data/docs/10-custom-pages.md +10 -5
- data/docs/11-decorators.md +1 -0
- data/docs/12-arbre-components.md +7 -9
- data/docs/13-authorization-adapter.md +39 -24
- data/docs/14-gotchas.md +41 -22
- data/docs/2-resource-customization.md +41 -18
- data/docs/3-index-pages.md +30 -12
- data/docs/3-index-pages/custom-index.md +1 -0
- data/docs/3-index-pages/index-as-block.md +0 -5
- data/docs/3-index-pages/index-as-blog.md +0 -5
- data/docs/3-index-pages/index-as-grid.md +0 -5
- data/docs/3-index-pages/index-as-table.md +1 -9
- data/docs/4-csv-format.md +2 -1
- data/docs/5-forms.md +45 -21
- data/docs/6-show-pages.md +2 -1
- data/docs/7-sidebars.md +2 -1
- data/docs/8-custom-actions.md +4 -1
- data/docs/9-batch-actions.md +4 -2
- data/docs/documentation.md +19 -21
- data/features/comments/commenting.feature +20 -0
- data/features/index/filters.feature +41 -1
- data/features/index/format_as_csv.feature +17 -0
- data/features/index/index_scopes.feature +15 -0
- data/features/registering_assets.feature +8 -4
- data/features/show/attributes_table_title.feature +54 -0
- data/features/show/tabs.feature +10 -4
- data/features/step_definitions/action_link_steps.rb +0 -1
- data/features/step_definitions/attributes_table_title_steps.rb +11 -0
- data/features/step_definitions/batch_action_steps.rb +2 -2
- data/features/step_definitions/comment_steps.rb +21 -1
- data/features/step_definitions/configuration_steps.rb +1 -1
- data/features/step_definitions/filter_steps.rb +9 -0
- data/features/step_definitions/format_steps.rb +1 -1
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/support/env.rb +5 -4
- data/features/support/regular_env.rb +7 -0
- data/features/support/reload_env.rb +7 -0
- data/gemfiles/rails_42.gemfile +2 -37
- data/gemfiles/rails_50.gemfile +5 -40
- data/gemfiles/rails_51.gemfile +5 -40
- data/lib/active_admin.rb +0 -3
- data/lib/active_admin/application.rb +6 -4
- data/lib/active_admin/asset_registration.rb +8 -0
- data/lib/active_admin/authorization_adapter.rb +0 -3
- data/lib/active_admin/base_controller.rb +1 -2
- data/lib/active_admin/base_controller/authorization.rb +0 -1
- data/lib/active_admin/base_controller/menu.rb +9 -9
- data/lib/active_admin/batch_actions/controller.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +6 -5
- data/lib/active_admin/csv_builder.rb +3 -3
- data/lib/active_admin/dependency.rb +1 -1
- data/lib/active_admin/devise.rb +2 -2
- data/lib/active_admin/dsl.rb +2 -2
- data/lib/active_admin/filters.rb +2 -0
- data/lib/active_admin/filters/active.rb +13 -14
- data/lib/active_admin/filters/active_filter.rb +87 -0
- data/lib/active_admin/filters/active_sidebar.rb +50 -0
- data/lib/active_admin/filters/forms.rb +1 -2
- data/lib/active_admin/filters/resource_extension.rb +2 -30
- data/lib/active_admin/helpers/settings.rb +0 -1
- data/lib/active_admin/inputs/datepicker_input.rb +5 -5
- data/lib/active_admin/inputs/filters/date_range_input.rb +12 -4
- data/lib/active_admin/inputs/filters/text_input.rb +0 -1
- data/lib/active_admin/menu.rb +4 -4
- data/lib/active_admin/menu_collection.rb +0 -2
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -5
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +4 -2
- data/lib/active_admin/page_controller.rb +1 -1
- data/lib/active_admin/resource/action_items.rb +4 -0
- data/lib/active_admin/resource/attributes.rb +1 -1
- data/lib/active_admin/resource/page_presenters.rb +1 -1
- data/lib/active_admin/resource/routes.rb +0 -1
- data/lib/active_admin/resource/scopes.rb +2 -1
- data/lib/active_admin/resource_controller.rb +1 -1
- data/lib/active_admin/resource_controller/data_access.rb +8 -9
- data/lib/active_admin/resource_dsl.rb +10 -10
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers.rb +1 -0
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/view_helpers/scope_name_helper.rb +16 -0
- data/lib/active_admin/views/action_items.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +1 -1
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -10
- data/lib/active_admin/views/components/status_tag.rb +19 -11
- data/lib/active_admin/views/components/tabs.rb +2 -2
- data/lib/active_admin/views/header.rb +0 -1
- data/lib/active_admin/views/index_as_blog.rb +1 -2
- data/lib/active_admin/views/index_as_grid.rb +2 -2
- data/lib/active_admin/views/index_as_table.rb +19 -1
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/show.rb +6 -1
- data/lib/active_admin/views/title_bar.rb +4 -4
- data/lib/bug_report_templates/{rails_5_master.rb → active_admin_master.rb} +35 -40
- data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +1 -1
- data/spec/bug_report_templates_spec.rb +2 -3
- data/spec/rails_helper.rb +0 -3
- data/spec/spec_helper.rb +1 -12
- data/spec/support/active_admin_integration_spec_helper.rb +1 -1
- data/spec/support/rails_template.rb +5 -37
- data/spec/support/rails_template_with_data.rb +262 -3
- data/spec/support/templates/policies/active_admin/comment_policy.rb +1 -1
- data/spec/support/templates/policies/active_admin/page_policy.rb +1 -1
- data/spec/support/templates/policies/application_policy.rb +1 -2
- data/spec/support/templates/post_decorator.rb +0 -1
- data/spec/unit/abstract_view_factory_spec.rb +0 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/asset_registration_spec.rb +29 -0
- data/spec/unit/belongs_to_spec.rb +1 -2
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +2 -4
- data/spec/unit/dependency_spec.rb +7 -7
- data/spec/unit/dsl_spec.rb +0 -2
- data/spec/unit/filters/active_filter_spec.rb +135 -0
- data/spec/unit/filters/active_spec.rb +11 -1
- data/spec/unit/filters/filter_form_builder_spec.rb +9 -7
- data/spec/unit/form_builder_spec.rb +14 -14
- data/spec/unit/helpers/scope_chain_spec.rb +0 -1
- data/spec/unit/i18n_spec.rb +17 -0
- data/spec/unit/menu_item_spec.rb +1 -3
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace_spec.rb +0 -1
- data/spec/unit/page_spec.rb +0 -3
- data/spec/unit/resource/action_items_spec.rb +5 -1
- data/spec/unit/resource/attributes_spec.rb +1 -2
- data/spec/unit/resource/ordering_spec.rb +0 -3
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +2 -2
- data/spec/unit/resource_controller_spec.rb +1 -2
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/routing_spec.rb +0 -2
- data/spec/unit/scope_spec.rb +3 -3
- data/spec/unit/settings_spec.rb +0 -1
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +0 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +3 -4
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +0 -1
- data/spec/unit/views/components/attributes_table_spec.rb +0 -1
- data/spec/unit/views/components/columns_spec.rb +0 -2
- data/spec/unit/views/components/site_title_spec.rb +0 -2
- data/spec/unit/views/components/status_tag_spec.rb +23 -7
- data/spec/unit/views/components/tabs_spec.rb +29 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/tasks/docs.rake +37 -10
- data/tasks/lint.rake +14 -1
- data/tasks/local.rake +2 -2
- data/tasks/test.rake +8 -25
- data/vendor/assets/javascripts/jquery-ui/data.js +41 -0
- data/vendor/assets/javascripts/jquery-ui/disable-selection.js +48 -0
- data/vendor/assets/javascripts/jquery-ui/escape-selector.js +23 -0
- data/vendor/assets/javascripts/jquery-ui/focusable.js +86 -0
- data/vendor/assets/javascripts/jquery-ui/ie.js +17 -0
- data/vendor/assets/javascripts/jquery-ui/keycode.js +47 -0
- data/vendor/assets/javascripts/jquery-ui/plugin.js +46 -0
- data/vendor/assets/javascripts/jquery-ui/position.js +500 -0
- data/vendor/assets/javascripts/jquery-ui/safe-active-element.js +42 -0
- data/vendor/assets/javascripts/jquery-ui/safe-blur.js +23 -0
- data/vendor/assets/javascripts/jquery-ui/scroll-parent.js +47 -0
- data/vendor/assets/javascripts/jquery-ui/tabbable.js +38 -0
- data/vendor/assets/javascripts/jquery-ui/unique-id.js +51 -0
- data/vendor/assets/javascripts/jquery-ui/version.js +17 -0
- data/vendor/assets/javascripts/jquery-ui/widget.js +735 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/button.js +391 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +300 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/controlgroup.js +300 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/datepicker.js +2123 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/dialog.js +954 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/draggable.js +1259 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/mouse.js +230 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/resizable.js +1207 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/sortable.js +1561 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/tabs.js +931 -0
- data/vendor/assets/stylesheets/active_admin/_normalize.scss +447 -0
- metadata +62 -51
- data/.hound.yml +0 -14
- data/Appraisals +0 -41
- data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +0 -18
- data/app/assets/stylesheets/active_admin/mixins/_reset.scss +0 -165
- data/lib/active_admin/filters/humanized.rb +0 -68
- data/spec/requests/javascript_spec.rb +0 -22
- data/spec/support/jslint.yml +0 -80
- data/spec/unit/filters/humanized_spec.rb +0 -64
- data/tasks/yard.rake +0 -9
@@ -29,6 +29,10 @@ module ActiveAdmin
|
|
29
29
|
text_node stylesheet_link_tag(style, options).html_safe
|
30
30
|
end
|
31
31
|
|
32
|
+
active_admin_namespace.meta_tags.each do |name, content|
|
33
|
+
text_node(tag(:meta, name: name, content: content))
|
34
|
+
end
|
35
|
+
|
32
36
|
active_admin_application.javascripts.each do |path|
|
33
37
|
text_node(javascript_include_tag(path))
|
34
38
|
end
|
@@ -37,10 +41,6 @@ module ActiveAdmin
|
|
37
41
|
text_node(favicon_link_tag(active_admin_namespace.favicon))
|
38
42
|
end
|
39
43
|
|
40
|
-
active_admin_namespace.meta_tags.each do |name, content|
|
41
|
-
text_node(tag(:meta, name: name, content: content))
|
42
|
-
end
|
43
|
-
|
44
44
|
text_node csrf_meta_tag
|
45
45
|
end
|
46
46
|
end
|
@@ -25,7 +25,12 @@ module ActiveAdmin
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def attributes_table(*args, &block)
|
28
|
-
|
28
|
+
opts = args.extract_options!
|
29
|
+
table_title = if opts.has_key?(:title)
|
30
|
+
render_or_call_method_or_proc_on(resource, opts[:title])
|
31
|
+
else
|
32
|
+
ActiveAdmin::Localizers.resource(active_admin_config).t(:details)
|
33
|
+
end
|
29
34
|
panel(table_title) do
|
30
35
|
attributes_table_for resource, *args, &block
|
31
36
|
end
|
@@ -29,10 +29,10 @@ module ActiveAdmin
|
|
29
29
|
breadcrumb_config = active_admin_config && active_admin_config.breadcrumb
|
30
30
|
|
31
31
|
links = if breadcrumb_config.is_a?(Proc)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
instance_exec(controller, &active_admin_config.breadcrumb)
|
33
|
+
elsif breadcrumb_config.present?
|
34
|
+
breadcrumb_links
|
35
|
+
end
|
36
36
|
return unless links.present? && links.is_a?(::Array)
|
37
37
|
span class: "breadcrumb" do
|
38
38
|
links.each do |link|
|
@@ -8,22 +8,24 @@ end
|
|
8
8
|
gemfile(true) do
|
9
9
|
source 'https://rubygems.org'
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
# Use local changes or ActiveAdmin master.
|
12
|
+
if ENV['ACTIVE_ADMIN_PATH']
|
13
|
+
gem 'activeadmin', path: ENV['ACTIVE_ADMIN_PATH'], require: false
|
14
|
+
else
|
15
|
+
gem 'activeadmin', github: 'activeadmin/activeadmin', require: false
|
16
|
+
end
|
13
17
|
|
18
|
+
# Change Rails version if necessary.
|
19
|
+
gem 'rails', '~> 5.1.0'
|
20
|
+
|
21
|
+
gem 'sass-rails'
|
22
|
+
gem 'sqlite3', platform: :mri
|
14
23
|
gem 'activerecord-jdbcsqlite3-adapter',
|
15
24
|
git: 'https://github.com/jruby/activerecord-jdbc-adapter',
|
16
25
|
branch: 'rails-5',
|
17
26
|
platform: :jruby
|
18
|
-
|
19
|
-
if ENV['ACTIVE_ADMIN_PATH']
|
20
|
-
gem 'activeadmin', path: ENV['ACTIVE_ADMIN_PATH'], require: false
|
21
|
-
else
|
22
|
-
gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin', require: false
|
23
|
-
end
|
24
27
|
end
|
25
28
|
|
26
|
-
# prepare active_record database
|
27
29
|
require 'active_record'
|
28
30
|
|
29
31
|
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
@@ -33,81 +35,74 @@ ActiveRecord::Schema.define do
|
|
33
35
|
create_table :active_admin_comments, force: true do |_t|
|
34
36
|
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
t.string :name
|
38
|
+
create_table :users, force: true do |t|
|
39
|
+
t.string :full_name
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
# prepare Rails app
|
43
43
|
require 'action_controller/railtie'
|
44
44
|
require 'action_view/railtie'
|
45
45
|
require 'active_admin'
|
46
46
|
|
47
|
-
class ApplicationController < ActionController::Base
|
48
|
-
end
|
49
|
-
|
50
47
|
class TestApp < Rails::Application
|
51
|
-
config.root =
|
52
|
-
config.
|
53
|
-
|
48
|
+
config.root = __dir__
|
49
|
+
config.session_store :cookie_store, key: "cookie_store_key"
|
54
50
|
secrets.secret_token = 'secret_token'
|
55
51
|
secrets.secret_key_base = 'secret_key_base'
|
56
52
|
|
57
53
|
config.eager_load = false
|
54
|
+
config.logger = Logger.new($stdout)
|
55
|
+
Rails.logger = config.logger
|
58
56
|
end
|
59
57
|
|
60
|
-
|
61
|
-
|
58
|
+
class ApplicationController < ActionController::Base
|
59
|
+
include Rails.application.routes.url_helpers
|
60
|
+
end
|
61
|
+
|
62
|
+
class User < ActiveRecord::Base
|
62
63
|
end
|
63
64
|
|
64
|
-
# configure active_admin
|
65
65
|
ActiveAdmin.setup do |config|
|
66
|
-
# Authentication disabled by default. Override if necessary
|
66
|
+
# Authentication disabled by default. Override if necessary.
|
67
67
|
config.authentication_method = false
|
68
68
|
config.current_user_method = false
|
69
69
|
end
|
70
70
|
|
71
|
-
# initialize app
|
72
71
|
Rails.application.initialize!
|
73
72
|
|
74
|
-
# register pages and resources
|
75
73
|
ActiveAdmin.register_page 'Dashboard' do
|
76
74
|
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
|
77
|
-
|
78
75
|
content do
|
79
76
|
'Test Me'
|
80
77
|
end
|
81
78
|
end
|
82
79
|
|
83
|
-
ActiveAdmin.register
|
80
|
+
ActiveAdmin.register User do
|
84
81
|
end
|
85
82
|
|
86
|
-
# draw active_admin routes
|
87
83
|
Rails.application.routes.draw do
|
88
84
|
ActiveAdmin.routes(self)
|
89
85
|
end
|
90
86
|
|
91
|
-
# prepare tests
|
92
87
|
require 'minitest/autorun'
|
93
88
|
require 'rack/test'
|
89
|
+
require 'rails/test_help'
|
94
90
|
|
95
91
|
# Replace this with the code necessary to make your test fail.
|
96
|
-
class BugTest <
|
97
|
-
include Rack::Test::Methods
|
92
|
+
class BugTest < ActionDispatch::IntegrationTest
|
98
93
|
|
99
94
|
def test_admin_root_success?
|
100
|
-
get
|
101
|
-
|
102
|
-
assert_match 'Test Me',
|
103
|
-
assert_match '
|
95
|
+
get admin_root_url
|
96
|
+
assert_response :success
|
97
|
+
assert_match 'Test Me', response.body # has content
|
98
|
+
assert_match 'Users', response.body # has 'Your Models' in menu
|
104
99
|
end
|
105
100
|
|
106
|
-
def
|
107
|
-
|
108
|
-
get
|
109
|
-
|
110
|
-
assert_match 'John Doe',
|
101
|
+
def test_admin_users
|
102
|
+
User.create! full_name: 'John Doe'
|
103
|
+
get admin_users_url
|
104
|
+
assert_response :success
|
105
|
+
assert_match 'John Doe', response.body # has created row
|
111
106
|
end
|
112
107
|
|
113
108
|
private
|
@@ -59,7 +59,7 @@ module ActiveAdmin
|
|
59
59
|
seeds_file = seeds_paths.existent.first
|
60
60
|
return if seeds_file.nil? || !options[:default_user]
|
61
61
|
|
62
|
-
create_user_code = "#{class_name}.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password')"
|
62
|
+
create_user_code = "#{class_name}.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?"
|
63
63
|
|
64
64
|
append_to_file seeds_file, create_user_code
|
65
65
|
end
|
@@ -15,13 +15,12 @@ RSpec.describe 'bug_report_templates' do
|
|
15
15
|
let(:active_admin_root) { File.expand_path('../..', __FILE__) }
|
16
16
|
let(:chdir_path) { File.join(active_admin_root, 'lib', 'bug_report_templates') }
|
17
17
|
|
18
|
-
context 'when runs
|
19
|
-
let(:template_path) { '
|
18
|
+
context 'when runs active_admin_master.rb' do
|
19
|
+
let(:template_path) { 'active_admin_master.rb' }
|
20
20
|
|
21
21
|
it 'passes' do
|
22
22
|
expect(subject).to be_truthy
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
26
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -57,6 +57,3 @@ ActiveSupport::Deprecation.behavior = :raise
|
|
57
57
|
# improve the performance of the specs suite by not logging anything
|
58
58
|
# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
|
59
59
|
Rails.logger.level = Logger::FATAL
|
60
|
-
|
61
|
-
# Make input type=hidden visible
|
62
|
-
Capybara.ignore_hidden_elements = false
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter 'spec/'
|
5
|
-
add_filter 'features/'
|
6
|
-
add_filter 'bundle/' # for Travis
|
7
|
-
end
|
8
|
-
|
9
|
-
if ENV['CI'] == 'true'
|
10
|
-
require 'codecov'
|
11
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
12
|
-
end
|
1
|
+
require 'simplecov' if ENV["COVERAGE"] == "true"
|
@@ -62,7 +62,7 @@ module ActiveAdminIntegrationSpecHelper
|
|
62
62
|
# If no translations have been loaded, any later calls to `I18n.t` will
|
63
63
|
# cause the full translation hash to be loaded, possibly overwritting what
|
64
64
|
# we've loaded via `store_translations`. We use this hack to prevent that.
|
65
|
-
#
|
65
|
+
# TODO: Might not be necessary anymore once
|
66
66
|
# https://github.com/svenfuchs/i18n/pull/353 lands.
|
67
67
|
I18n.backend.send(:init_translations)
|
68
68
|
I18n.backend.store_translations I18n.locale, translation
|
@@ -14,7 +14,7 @@ create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
14
14
|
belongs_to :author, class_name: 'User'
|
15
15
|
has_many :taggings
|
16
16
|
accepts_nested_attributes_for :author
|
17
|
-
accepts_nested_attributes_for :taggings
|
17
|
+
accepts_nested_attributes_for :taggings, allow_destroy: true
|
18
18
|
|
19
19
|
ransacker :custom_title_searcher do |parent|
|
20
20
|
parent.table[:title]
|
@@ -28,9 +28,6 @@ create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
28
28
|
# nothing to see here
|
29
29
|
end
|
30
30
|
|
31
|
-
if defined? ProtectedAttributes
|
32
|
-
attr_accessible :id, :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
|
33
|
-
end
|
34
31
|
end
|
35
32
|
RUBY
|
36
33
|
copy_file File.expand_path('../templates/post_decorator.rb', __FILE__), 'app/models/post_decorator.rb'
|
@@ -43,11 +40,8 @@ create_file 'app/models/blog/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
43
40
|
belongs_to :author, class_name: 'User'
|
44
41
|
has_many :taggings
|
45
42
|
accepts_nested_attributes_for :author
|
46
|
-
accepts_nested_attributes_for :taggings
|
43
|
+
accepts_nested_attributes_for :taggings, allow_destroy: true
|
47
44
|
|
48
|
-
if defined? ProtectedAttributes
|
49
|
-
attr_accessible :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
|
50
|
-
end
|
51
45
|
end
|
52
46
|
RUBY
|
53
47
|
|
@@ -64,10 +58,6 @@ create_file 'app/models/user.rb', <<-RUBY.strip_heredoc, force: true
|
|
64
58
|
parent.table[:age]
|
65
59
|
end
|
66
60
|
|
67
|
-
if defined? ProtectedAttributes
|
68
|
-
attr_accessible :first_name, :last_name, :username, :age
|
69
|
-
end
|
70
|
-
|
71
61
|
def display_name
|
72
62
|
"\#{first_name} \#{last_name}"
|
73
63
|
end
|
@@ -77,10 +67,6 @@ RUBY
|
|
77
67
|
create_file 'app/models/profile.rb', <<-RUBY.strip_heredoc, force: true
|
78
68
|
class Profile < ActiveRecord::Base
|
79
69
|
belongs_to :user
|
80
|
-
|
81
|
-
if defined? ProtectedAttributes
|
82
|
-
attr_accessible :bio
|
83
|
-
end
|
84
70
|
end
|
85
71
|
RUBY
|
86
72
|
|
@@ -92,42 +78,24 @@ create_file 'app/models/category.rb', <<-RUBY.strip_heredoc, force: true
|
|
92
78
|
has_many :posts, foreign_key: :custom_category_id
|
93
79
|
has_many :authors, through: :posts
|
94
80
|
accepts_nested_attributes_for :posts
|
95
|
-
|
96
|
-
if defined? ProtectedAttributes
|
97
|
-
attr_accessible :name, :description
|
98
|
-
end
|
99
81
|
end
|
100
82
|
RUBY
|
101
83
|
|
102
84
|
generate :model, 'store name:string'
|
103
85
|
|
104
|
-
# Generate a model with string ids
|
105
86
|
generate :model, 'tag name:string'
|
106
|
-
gsub_file Dir['db/migrate/*_create_tags.rb'].first, /\:tags do .*/, <<-RUBY.strip_heredoc
|
107
|
-
:tags, id: false, primary_key: :id do |t|
|
108
|
-
t.string :id
|
109
|
-
RUBY
|
110
87
|
create_file 'app/models/tag.rb', <<-RUBY.strip_heredoc, force: true
|
111
88
|
class Tag < ActiveRecord::Base
|
112
|
-
self.primary_key = :id
|
113
|
-
before_create :set_id
|
114
|
-
|
115
|
-
private
|
116
|
-
def set_id
|
117
|
-
self.id = SecureRandom.uuid
|
118
|
-
end
|
119
|
-
|
120
|
-
if defined? ProtectedAttributes
|
121
|
-
attr_accessible :name
|
122
|
-
end
|
123
89
|
end
|
124
90
|
RUBY
|
125
91
|
|
126
|
-
generate :model, 'tagging post_id:integer tag_id:integer'
|
92
|
+
generate :model, 'tagging post_id:integer tag_id:integer position:integer'
|
127
93
|
create_file 'app/models/tagging.rb', <<-RUBY.strip_heredoc, force: true
|
128
94
|
class Tagging < ActiveRecord::Base
|
129
95
|
belongs_to :post
|
130
96
|
belongs_to :tag
|
97
|
+
|
98
|
+
delegate :name, to: :tag, prefix: true
|
131
99
|
end
|
132
100
|
RUBY
|
133
101
|
|
@@ -1,22 +1,145 @@
|
|
1
1
|
apply File.expand_path("../rails_template.rb", __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
inject_into_file 'config/initializers/active_admin.rb', <<-RUBY, after: "ActiveAdmin.setup do |config|\n"
|
4
|
+
|
5
|
+
config.comments_menu = { parent: 'Administrative' }
|
6
|
+
RUBY
|
7
|
+
|
8
|
+
inject_into_file 'app/admin/admin_user.rb', <<-RUBY, after: "ActiveAdmin.register AdminUser do\n"
|
9
|
+
|
10
|
+
menu parent: "Administrative", priority: 1
|
11
|
+
RUBY
|
12
|
+
|
13
|
+
generate :'active_admin:page', 'KitchenSink'
|
14
|
+
|
15
|
+
gsub_file 'app/admin/kitchen_sink.rb', /^ *content.*?end/m, <<-RUBY
|
16
|
+
|
17
|
+
sidebar "Sample Sidebar" do
|
18
|
+
para "Sidebars can also be used on custom pages."
|
19
|
+
para do
|
20
|
+
a "Active Admin", href: "https://github.com/activeadmin/activeadmin"
|
21
|
+
text_node "is a Ruby on Rails framework for"
|
22
|
+
em "creating elegant backends"
|
23
|
+
text_node "for"
|
24
|
+
strong "website administration."
|
25
|
+
end
|
26
|
+
para do
|
27
|
+
abbr "HTML", title: "HyperText Markup Language"
|
28
|
+
text_node "is the most basic building block of the Web."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
content do
|
33
|
+
columns do
|
34
|
+
column do
|
35
|
+
panel "Panel title" do
|
36
|
+
h1 "This is an h1"
|
37
|
+
h2 "This is an h2"
|
38
|
+
h3 "This is an h3"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
column do
|
42
|
+
table_for User.all do
|
43
|
+
column :id
|
44
|
+
column :display_name
|
45
|
+
column :username
|
46
|
+
column :age
|
47
|
+
column :updated_at
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
tabs do
|
53
|
+
tab :first do
|
54
|
+
ul do
|
55
|
+
li "List item"
|
56
|
+
li "Another list item"
|
57
|
+
li "Last item"
|
58
|
+
end
|
59
|
+
ol do
|
60
|
+
li "First list item"
|
61
|
+
li "Second list item"
|
62
|
+
li "Third list item"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
tab :second do
|
66
|
+
para "A popular quote."
|
67
|
+
blockquote do
|
68
|
+
text_node "&ldqou;Be yourself; everyone else is already taken.&rdqou;".html_safe
|
69
|
+
cite "― Oscar Wilde"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
tab :third do
|
73
|
+
para "Third tab content."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
RUBY
|
78
|
+
|
79
|
+
%w{Post User Category Tag}.each do |type|
|
4
80
|
generate :'active_admin:resource', type
|
5
81
|
end
|
6
82
|
|
7
83
|
inject_into_file 'app/admin/category.rb', <<-RUBY, after: "ActiveAdmin.register Category do\n"
|
8
84
|
|
85
|
+
config.create_another = true
|
86
|
+
|
9
87
|
permit_params [:name, :description]
|
10
88
|
RUBY
|
11
89
|
|
12
90
|
inject_into_file 'app/admin/user.rb', <<-RUBY, after: "ActiveAdmin.register User do\n"
|
13
91
|
|
92
|
+
config.create_another = true
|
93
|
+
|
14
94
|
permit_params [:first_name, :last_name, :username, :age]
|
95
|
+
|
96
|
+
index as: :grid do |user|
|
97
|
+
div for: user do
|
98
|
+
resource_selection_cell user
|
99
|
+
h2 link_to(user.display_name, admin_user_path(user)), style: 'margin-bottom: 0'
|
100
|
+
para do
|
101
|
+
strong user.username, style: 'text-transform: uppercase; font-size: 10px;'
|
102
|
+
br
|
103
|
+
em user.age
|
104
|
+
text_node 'years old'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
show do
|
110
|
+
attributes_table do
|
111
|
+
row :id
|
112
|
+
row :first_name
|
113
|
+
row :last_name
|
114
|
+
row :username
|
115
|
+
row :age
|
116
|
+
row :created_at
|
117
|
+
row :updated_at
|
118
|
+
end
|
119
|
+
|
120
|
+
panel 'Posts' do
|
121
|
+
table_for(user.posts.includes(:category).order(:updated_at).limit(10)) do
|
122
|
+
column :id do |post|
|
123
|
+
link_to post.id, admin_post_path(post)
|
124
|
+
end
|
125
|
+
column :title
|
126
|
+
column :published_date
|
127
|
+
column :category
|
128
|
+
column :created_at
|
129
|
+
column :updated_at
|
130
|
+
end
|
131
|
+
para do
|
132
|
+
link_to "View all posts", admin_posts_path('q[author_id_eq]' => user.id)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
15
136
|
RUBY
|
16
137
|
|
17
|
-
inject_into_file 'app/admin/post.rb', <<-RUBY, after: "ActiveAdmin.register Post do\n"
|
138
|
+
inject_into_file 'app/admin/post.rb', <<-'RUBY', after: "ActiveAdmin.register Post do\n"
|
18
139
|
|
19
|
-
permit_params
|
140
|
+
permit_params :custom_category_id, :author_id, :title, :body, :published_date, :position, :starred, taggings_attributes: [ :id, :tag_id, :name, :position, :_destroy ]
|
141
|
+
|
142
|
+
includes :author, :category, :taggings
|
20
143
|
|
21
144
|
scope :all, default: true
|
22
145
|
|
@@ -35,6 +158,133 @@ inject_into_file 'app/admin/post.rb', <<-RUBY, after: "ActiveAdmin.register Post
|
|
35
158
|
scope :my_posts do |posts|
|
36
159
|
posts.where(author_id: current_admin_user.id)
|
37
160
|
end
|
161
|
+
|
162
|
+
batch_action :set_starred, form: { starred: :checkbox } do |ids, inputs|
|
163
|
+
Post.where(id: ids).update_all(starred: inputs['starred'].present?)
|
164
|
+
redirect_to collection_path, notice: "The posts have been updated."
|
165
|
+
end
|
166
|
+
|
167
|
+
index do
|
168
|
+
selectable_column
|
169
|
+
id_column
|
170
|
+
column :title
|
171
|
+
column :published_date
|
172
|
+
column :author
|
173
|
+
column :category
|
174
|
+
column :starred
|
175
|
+
column :position
|
176
|
+
column :created_at
|
177
|
+
column :updated_at
|
178
|
+
end
|
179
|
+
|
180
|
+
sidebar :author, only: :show do
|
181
|
+
attributes_table_for post.author do
|
182
|
+
row :id do |author|
|
183
|
+
link_to author.id, admin_user_path(author)
|
184
|
+
end
|
185
|
+
row :first_name
|
186
|
+
row :last_name
|
187
|
+
row :username
|
188
|
+
row :age
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
member_action :toggle_starred, method: :put do
|
193
|
+
resource.update(starred: !resource.starred)
|
194
|
+
redirect_to resource_path, notice: "Post updated."
|
195
|
+
end
|
196
|
+
|
197
|
+
action_item :toggle_starred, only: :show do
|
198
|
+
link_to 'Toggle Starred', toggle_starred_admin_post_path(post), method: :put
|
199
|
+
end
|
200
|
+
|
201
|
+
show do |post|
|
202
|
+
attributes_table do
|
203
|
+
row :id
|
204
|
+
row :title
|
205
|
+
row :published_date
|
206
|
+
row :author
|
207
|
+
row :body
|
208
|
+
row :category
|
209
|
+
row :starred
|
210
|
+
row :position
|
211
|
+
row :created_at
|
212
|
+
row :updated_at
|
213
|
+
end
|
214
|
+
|
215
|
+
columns do
|
216
|
+
column do
|
217
|
+
panel 'Tags' do
|
218
|
+
table_for(post.taggings.order(:position)) do
|
219
|
+
column :id do |tagging|
|
220
|
+
link_to tagging.tag_id, admin_tag_path(tagging.tag)
|
221
|
+
end
|
222
|
+
column :tag, &:tag_name
|
223
|
+
column :position
|
224
|
+
column :updated_at
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
column do
|
229
|
+
panel 'Category' do
|
230
|
+
attributes_table_for post.category do
|
231
|
+
row :id do |category|
|
232
|
+
link_to category.id, admin_category_path(category)
|
233
|
+
end
|
234
|
+
row :description
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
form do |f|
|
242
|
+
columns do
|
243
|
+
column do
|
244
|
+
f.inputs 'Details' do
|
245
|
+
f.input :title
|
246
|
+
f.input :author
|
247
|
+
f.input :published_date,
|
248
|
+
hint: f.object.persisted? && "Created at #{f.object.created_at}"
|
249
|
+
f.input :custom_category_id
|
250
|
+
f.input :category
|
251
|
+
f.input :position
|
252
|
+
f.input :starred
|
253
|
+
end
|
254
|
+
end
|
255
|
+
column do
|
256
|
+
f.inputs 'Content' do
|
257
|
+
f.input :body
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
f.inputs "Tags" do
|
262
|
+
f.has_many :taggings, sortable: :position do |t|
|
263
|
+
t.input :tag
|
264
|
+
t.input :_destroy, as: :boolean
|
265
|
+
end
|
266
|
+
end
|
267
|
+
para "Press cancel to return to the list without saving."
|
268
|
+
f.actions
|
269
|
+
end
|
270
|
+
RUBY
|
271
|
+
|
272
|
+
inject_into_file 'app/admin/tag.rb', <<-RUBY, after: "ActiveAdmin.register Tag do\n"
|
273
|
+
|
274
|
+
config.create_another = true
|
275
|
+
|
276
|
+
permit_params [:name]
|
277
|
+
|
278
|
+
index do
|
279
|
+
selectable_column
|
280
|
+
id_column
|
281
|
+
column :name
|
282
|
+
column :created_at
|
283
|
+
actions dropdown: true do |tag|
|
284
|
+
item "Preview", admin_tag_path(tag)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
38
288
|
RUBY
|
39
289
|
|
40
290
|
append_file "db/seeds.rb", "\n\n" + <<-RUBY.strip_heredoc
|
@@ -63,6 +313,15 @@ append_file "db/seeds.rb", "\n\n" + <<-RUBY.strip_heredoc
|
|
63
313
|
author: user,
|
64
314
|
starred: true
|
65
315
|
end
|
316
|
+
|
317
|
+
800.times do |i|
|
318
|
+
ActiveAdmin::Comment.create!(
|
319
|
+
namespace: :admin,
|
320
|
+
author: AdminUser.first,
|
321
|
+
body: "Test comment #{i}",
|
322
|
+
resource: categories.sample,
|
323
|
+
)
|
324
|
+
end
|
66
325
|
RUBY
|
67
326
|
|
68
327
|
rake 'db:seed'
|