activeadmin 1.0.0.pre4 → 1.0.0.pre5
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/.gitignore +3 -3
- data/.travis.yml +48 -26
- data/Appraisals +103 -0
- data/CHANGELOG.md +12 -1
- data/CONTRIBUTING.md +85 -32
- data/Gemfile +13 -38
- data/README.md +10 -26
- data/Rakefile +41 -9
- data/activeadmin.gemspec +7 -4
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +10 -3
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -4
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +8 -0
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +14 -3
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -0
- data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
- data/codecov.yml +23 -0
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +110 -0
- data/docs/0-installation.md +3 -0
- data/docs/1-general-configuration.md +11 -0
- data/docs/10-custom-pages.md +25 -0
- data/docs/11-decorators.md +3 -0
- data/docs/12-arbre-components.md +3 -0
- data/docs/13-authorization-adapter.md +3 -0
- data/docs/14-gotchas.md +19 -0
- data/docs/2-resource-customization.md +21 -2
- data/docs/3-index-pages.md +21 -0
- data/docs/3-index-pages/custom-index.md +3 -0
- data/docs/3-index-pages/index-as-block.md +3 -0
- data/docs/3-index-pages/index-as-blog.md +3 -0
- data/docs/3-index-pages/index-as-grid.md +3 -0
- data/docs/3-index-pages/index-as-table.md +22 -0
- data/docs/4-csv-format.md +15 -0
- data/docs/5-forms.md +7 -3
- data/docs/6-show-pages.md +3 -0
- data/docs/7-sidebars.md +3 -0
- data/docs/8-custom-actions.md +3 -0
- data/docs/9-batch-actions.md +4 -1
- data/docs/CNAME +1 -0
- data/docs/Gemfile +2 -0
- data/docs/_config.yml +2 -0
- data/docs/_includes/footer.html +8 -0
- data/docs/_includes/google-analytics.html +16 -0
- data/docs/_includes/head.html +7 -0
- data/docs/_includes/toc.html +97 -0
- data/docs/_includes/top-menu.html +9 -0
- data/docs/_layouts/default.html +21 -0
- data/docs/documentation.md +62 -0
- data/docs/images/activeadmin.png +0 -0
- data/docs/images/code-header.png +0 -0
- data/docs/images/divider.png +0 -0
- data/docs/images/features.png +0 -0
- data/docs/index.html +130 -0
- data/docs/stylesheets/main.css +1199 -0
- data/features/action_item.feature +2 -2
- data/features/authorization_cancan.feature +3 -3
- data/features/belongs_to.feature +60 -2
- data/features/comments/commenting.feature +7 -7
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +9 -9
- data/features/footer.feature +28 -0
- data/features/i18n.feature +11 -0
- data/features/index/batch_actions.feature +28 -6
- data/features/index/filters.feature +31 -11
- data/features/index/format_as_csv.feature +13 -13
- data/features/index/formats.feature +4 -4
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_blog.feature +6 -6
- data/features/index/index_as_grid.feature +3 -3
- data/features/index/index_as_table.feature +11 -11
- data/features/index/index_blank_slate.feature +4 -4
- data/features/index/index_parameters.feature +10 -10
- data/features/index/index_scope_to.feature +3 -3
- data/features/index/index_scopes.feature +37 -18
- data/features/index/page_title.feature +3 -3
- data/features/index/pagination.feature +1 -1
- data/features/index/switch_index_view.feature +8 -8
- data/features/menu.feature +3 -3
- data/features/new_page.feature +8 -8
- data/features/registering_assets.feature +1 -1
- data/features/registering_pages.feature +73 -2
- data/features/registering_resources.feature +1 -1
- data/features/renamed_resource.feature +1 -1
- data/features/show/page_title.feature +3 -3
- data/features/sidebar_sections.feature +6 -6
- data/features/specifying_actions.feature +29 -4
- data/features/step_definitions/factory_steps.rb +1 -1
- data/features/step_definitions/footer_steps.rb +11 -0
- data/features/step_definitions/i18n_steps.rb +8 -0
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/step_definitions/sidebar_steps.rb +1 -3
- data/features/step_definitions/table_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +7 -0
- data/features/support/env.rb +6 -33
- data/features/support/paths.rb +5 -0
- data/features/users/logging_in.feature +2 -0
- data/gemfiles/rails_32.gemfile +54 -0
- data/gemfiles/rails_40.gemfile +53 -0
- data/gemfiles/rails_41.gemfile +53 -0
- data/gemfiles/rails_42.gemfile +53 -0
- data/gemfiles/rails_50.gemfile +46 -0
- data/lib/active_admin.rb +1 -0
- data/lib/active_admin/application.rb +11 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +0 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/dsl.rb +0 -6
- data/lib/active_admin/filters/active.rb +9 -1
- data/lib/active_admin/filters/formtastic_addons.rb +1 -1
- data/lib/active_admin/filters/humanized.rb +1 -1
- data/lib/active_admin/filters/resource_extension.rb +2 -4
- data/lib/active_admin/form_builder.rb +12 -6
- data/lib/active_admin/helpers/collection.rb +2 -0
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +9 -4
- data/lib/active_admin/inputs/filters/text_input.rb +26 -0
- data/lib/active_admin/localizers.rb +11 -0
- data/lib/active_admin/localizers/resource_localizer.rb +35 -0
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/order_clause.rb +29 -7
- data/lib/active_admin/page.rb +18 -4
- data/lib/active_admin/page_dsl.rb +4 -0
- data/lib/active_admin/resource.rb +16 -1
- data/lib/active_admin/resource/action_items.rb +7 -4
- data/lib/active_admin/resource/belongs_to.rb +4 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource/ordering.rb +11 -0
- data/lib/active_admin/resource/routes.rb +34 -13
- data/lib/active_admin/resource/scopes.rb +1 -0
- data/lib/active_admin/resource_controller/data_access.rb +3 -10
- data/lib/active_admin/resource_dsl.rb +28 -1
- data/lib/active_admin/router.rb +5 -3
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -2
- data/lib/active_admin/view_helpers/display_helper.rb +8 -3
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -1
- data/lib/active_admin/views/components/active_admin_form.rb +11 -10
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/columns.rb +3 -3
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +4 -1
- data/lib/active_admin/views/components/paginated_collection.rb +1 -0
- data/lib/active_admin/views/components/scopes.rb +8 -1
- data/lib/active_admin/views/components/site_title.rb +2 -2
- data/lib/active_admin/views/components/table_for.rb +3 -3
- data/lib/active_admin/views/footer.rb +17 -3
- data/lib/active_admin/views/index_as_table.rb +3 -3
- data/lib/active_admin/views/pages/base.rb +4 -2
- data/lib/active_admin/views/pages/form.rb +2 -3
- data/lib/active_admin/views/pages/show.rb +2 -1
- data/lib/bug_report_templates/rails_5_master.rb +120 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +6 -3
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +15 -1
- data/lib/generators/active_admin/install/templates/migrations/{create_active_admin_comments.rb → create_active_admin_comments.rb.erb} +14 -1
- data/lib/ransack_ext.rb +2 -2
- data/spec/bug_report_templates_spec.rb +27 -0
- data/spec/javascripts/support/jasmine_runner.rb +4 -17
- data/spec/rails_helper.rb +20 -109
- data/spec/requests/default_namespace_spec.rb +16 -28
- data/spec/requests/javascript_spec.rb +1 -1
- data/spec/requests/memory_spec.rb +5 -1
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -10
- data/spec/support/active_admin_integration_spec_helper.rb +66 -0
- data/spec/support/active_admin_request_helpers.rb +12 -0
- data/spec/support/rails_template.rb +42 -15
- data/spec/support/rails_template_with_data.rb +24 -5
- data/spec/support/templates/manifest.js +3 -0
- data/spec/support/templates/policies/application_policy.rb +1 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +3 -12
- data/spec/unit/active_admin_spec.rb +1 -1
- data/spec/unit/application_spec.rb +5 -1
- data/spec/unit/asset_registration_spec.rb +1 -1
- data/spec/unit/authorization/authorization_adapter_spec.rb +1 -1
- data/spec/unit/authorization/controller_authorization_spec.rb +13 -9
- data/spec/unit/authorization/index_overriding_spec.rb +6 -6
- data/spec/unit/auto_link_spec.rb +48 -24
- data/spec/unit/batch_actions/resource_spec.rb +1 -14
- data/spec/unit/batch_actions/settings_spec.rb +1 -1
- data/spec/unit/belongs_to_spec.rb +9 -1
- data/spec/unit/cancan_adapter_spec.rb +1 -1
- data/spec/unit/comments_spec.rb +26 -19
- data/spec/unit/component_spec.rb +1 -1
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/controller_filters_spec.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +5 -5
- data/spec/unit/dependency_spec.rb +1 -1
- data/spec/unit/devise_spec.rb +17 -3
- data/spec/unit/dsl_spec.rb +2 -2
- data/spec/unit/filters/active_spec.rb +21 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +98 -31
- data/spec/unit/filters/humanized_spec.rb +9 -1
- data/spec/unit/filters/resource_spec.rb +5 -4
- data/spec/unit/form_builder_spec.rb +180 -33
- data/spec/unit/generators/install_spec.rb +12 -5
- data/spec/unit/helpers/collection_spec.rb +10 -7
- data/spec/unit/helpers/scope_chain_spec.rb +1 -1
- data/spec/unit/helpers/settings_spec.rb +1 -1
- data/spec/unit/i18n_spec.rb +1 -1
- data/spec/unit/localizers/resource_localizer_spec.rb +36 -0
- data/spec/unit/menu_collection_spec.rb +1 -1
- data/spec/unit/menu_item_spec.rb +1 -1
- data/spec/unit/menu_spec.rb +1 -1
- data/spec/unit/namespace/authorization_spec.rb +1 -1
- data/spec/unit/namespace/register_page_spec.rb +28 -2
- data/spec/unit/namespace/register_resource_spec.rb +3 -1
- data/spec/unit/namespace_spec.rb +23 -1
- data/spec/unit/order_clause_spec.rb +7 -7
- data/spec/unit/page_controller_spec.rb +1 -1
- data/spec/unit/page_spec.rb +55 -2
- data/spec/unit/pretty_format_spec.rb +8 -7
- data/spec/unit/pundit_adapter_spec.rb +1 -1
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +38 -0
- data/spec/unit/resource/page_presenters_spec.rb +1 -1
- data/spec/unit/resource/pagination_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +101 -53
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource/sidebars_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +50 -1
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +16 -17
- data/spec/unit/resource_controller_spec.rb +50 -56
- data/spec/unit/resource_registration_spec.rb +9 -4
- data/spec/unit/resource_spec.rb +9 -1
- data/spec/unit/routing_spec.rb +30 -2
- data/spec/unit/scope_spec.rb +26 -2
- data/spec/unit/settings_spec.rb +2 -2
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +1 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +18 -3
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +1 -1
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/batch_action_selector_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +1 -1
- data/spec/unit/views/components/columns_spec.rb +1 -1
- data/spec/unit/views/components/index_list_spec.rb +18 -4
- data/spec/unit/views/components/index_table_for_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +1 -1
- data/spec/unit/views/components/panel_spec.rb +1 -1
- data/spec/unit/views/components/sidebar_section_spec.rb +1 -1
- data/spec/unit/views/components/site_title_spec.rb +1 -1
- data/spec/unit/views/components/status_tag_spec.rb +1 -1
- data/spec/unit/views/components/table_for_spec.rb +9 -7
- data/spec/unit/views/components/tabs_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +3 -3
- data/spec/unit/views/index_as_blog_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +1 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -2
- data/tasks/local.rake +25 -0
- data/tasks/parallel_tests.rake +4 -4
- data/tasks/test.rake +8 -53
- metadata +61 -18
- data/Guardfile +0 -8
- data/script/local +0 -53
- data/script/travis_cache +0 -107
- data/script/use_rails +0 -53
- data/spec/javascripts/support/jasmine_config.rb +0 -23
- data/spec/support/detect_rails_version.rb +0 -34
@@ -1,32 +1,19 @@
|
|
1
1
|
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
3
|
require 'jasmine'
|
5
|
-
|
6
|
-
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
|
7
|
-
if Jasmine::rspec2?
|
8
|
-
require 'rspec'
|
9
|
-
else
|
10
|
-
require 'spec'
|
11
|
-
end
|
4
|
+
require 'spec'
|
12
5
|
|
13
6
|
jasmine_config = Jasmine::Config.new
|
14
7
|
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
15
8
|
|
16
9
|
should_stop = false
|
17
10
|
|
18
|
-
|
19
|
-
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
config.after(:suite) do
|
20
13
|
spec_builder.stop if should_stop
|
21
14
|
end
|
22
|
-
else
|
23
|
-
Spec::Runner.configure do |config|
|
24
|
-
config.after(:suite) do
|
25
|
-
spec_builder.stop if should_stop
|
26
|
-
end
|
27
|
-
end
|
28
15
|
end
|
29
16
|
|
30
17
|
spec_builder.start
|
31
18
|
should_stop = true
|
32
|
-
spec_builder.declare_suites
|
19
|
+
spec_builder.declare_suites
|
data/spec/rails_helper.rb
CHANGED
@@ -1,103 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module ActiveAdminIntegrationSpecHelper
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def load_defaults!
|
7
|
-
ActiveAdmin.unload!
|
8
|
-
ActiveAdmin.load!
|
9
|
-
ActiveAdmin.register(Category)
|
10
|
-
ActiveAdmin.register(User)
|
11
|
-
ActiveAdmin.register(Post){ belongs_to :user, optional: true }
|
12
|
-
reload_menus!
|
13
|
-
end
|
14
|
-
|
15
|
-
def reload_menus!
|
16
|
-
ActiveAdmin.application.namespaces.each{|n| n.reset_menu! }
|
17
|
-
end
|
18
|
-
|
19
|
-
# Sometimes we need to reload the routes within
|
20
|
-
# the application to test them out
|
21
|
-
def reload_routes!
|
22
|
-
Rails.application.reload_routes!
|
23
|
-
end
|
24
|
-
|
25
|
-
# Helper method to load resources and ensure that Active Admin is
|
26
|
-
# setup with the new configurations.
|
27
|
-
#
|
28
|
-
# Eg:
|
29
|
-
# load_resources do
|
30
|
-
# ActiveAdmin.regiser(Post)
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
def load_resources
|
34
|
-
ActiveAdmin.unload!
|
35
|
-
yield
|
36
|
-
reload_menus!
|
37
|
-
reload_routes!
|
38
|
-
end
|
39
|
-
|
40
|
-
# Sets up a describe block where you can render controller
|
41
|
-
# actions. Uses the Admin::PostsController as the subject
|
42
|
-
# for the describe block
|
43
|
-
def describe_with_render(*args, &block)
|
44
|
-
describe *args do
|
45
|
-
include RSpec::Rails::ControllerExampleGroup
|
46
|
-
render_views
|
47
|
-
# metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
|
48
|
-
module_eval &block
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def arbre(assigns = {}, helpers = mock_action_view, &block)
|
53
|
-
Arbre::Context.new(assigns, helpers, &block)
|
54
|
-
end
|
55
|
-
|
56
|
-
def render_arbre_component(assigns = {}, helpers = mock_action_view, &block)
|
57
|
-
arbre(assigns, helpers, &block).children.first
|
58
|
-
end
|
59
|
-
|
60
|
-
# Setup a describe block which uses capybara and rails integration
|
61
|
-
# test methods.
|
62
|
-
def describe_with_capybara(*args, &block)
|
63
|
-
describe *args do
|
64
|
-
include RSpec::Rails::IntegrationExampleGroup
|
65
|
-
module_eval &block
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# Returns a fake action view instance to use with our renderers
|
70
|
-
def mock_action_view(assigns = {})
|
71
|
-
controller = ActionView::TestCase::TestController.new
|
72
|
-
ActionView::Base.send :include, ActionView::Helpers
|
73
|
-
ActionView::Base.send :include, ActiveAdmin::ViewHelpers
|
74
|
-
ActionView::Base.send :include, Rails.application.routes.url_helpers
|
75
|
-
ActionView::Base.new(ActionController::Base.view_paths, assigns, controller)
|
76
|
-
end
|
77
|
-
alias_method :action_view, :mock_action_view
|
78
|
-
|
79
|
-
# A mock resource to register
|
80
|
-
class MockResource
|
81
|
-
end
|
82
|
-
|
83
|
-
def with_translation(translation)
|
84
|
-
I18n.backend.store_translations :en, translation
|
85
|
-
yield
|
86
|
-
ensure
|
87
|
-
I18n.backend.reload!
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
3
|
ENV['RAILS_ENV'] = 'test'
|
93
|
-
|
4
|
+
|
5
|
+
require 'rails'
|
6
|
+
ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{Rails.version}", __FILE__)
|
94
7
|
|
95
8
|
# Create the test app if it doesn't exists
|
96
9
|
unless File.exists?(ENV['RAILS_ROOT'])
|
97
10
|
system 'rake setup'
|
98
11
|
end
|
99
12
|
|
100
|
-
require 'rails'
|
101
13
|
require 'active_record'
|
102
14
|
require 'active_admin'
|
103
15
|
require 'devise'
|
@@ -111,37 +23,36 @@ require 'rspec/rails'
|
|
111
23
|
# JRuby
|
112
24
|
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
113
25
|
|
114
|
-
# Setup Some Admin stuff for us to play with
|
115
|
-
include ActiveAdminIntegrationSpecHelper
|
116
|
-
load_defaults!
|
117
|
-
reload_routes!
|
118
|
-
|
119
26
|
# Disabling authentication in specs so that we don't have to worry about
|
120
27
|
# it allover the place
|
121
28
|
ActiveAdmin.application.authentication_method = false
|
122
29
|
ActiveAdmin.application.current_user_method = false
|
123
30
|
|
124
|
-
# Don't add asset cache timestamps. Makes it easy to integration
|
125
|
-
# test for the presence of an asset file
|
126
|
-
ENV["RAILS_ASSET_ID"] = ''
|
127
|
-
|
128
31
|
RSpec.configure do |config|
|
32
|
+
config.disable_monkey_patching!
|
129
33
|
config.use_transactional_fixtures = true
|
130
34
|
config.use_instantiated_fixtures = false
|
131
|
-
config.include Devise::TestHelpers, type: :controller
|
132
35
|
config.render_views = false
|
133
36
|
config.filter_run focus: true
|
134
37
|
config.filter_run_excluding skip: true
|
135
38
|
config.run_all_when_everything_filtered = true
|
136
39
|
config.color = true
|
137
|
-
|
40
|
+
config.order = :random
|
138
41
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
42
|
+
devise = ActiveAdmin::Dependency.devise >= '4.2' ? Devise::Test::ControllerHelpers : Devise::TestHelpers
|
43
|
+
config.include devise, type: :controller
|
44
|
+
|
45
|
+
require 'support/active_admin_integration_spec_helper'
|
46
|
+
config.include ActiveAdminIntegrationSpecHelper
|
47
|
+
|
48
|
+
require 'support/active_admin_request_helpers'
|
49
|
+
config.include ActiveAdminRequestHelpers, type: :request
|
50
|
+
|
51
|
+
# Setup Some Admin stuff for us to play with
|
52
|
+
config.before(:suite) do
|
53
|
+
ActiveAdminIntegrationSpecHelper.load_defaults!
|
54
|
+
ActiveAdminIntegrationSpecHelper.reload_routes!
|
55
|
+
end
|
145
56
|
end
|
146
57
|
|
147
58
|
# Force deprecations to raise an exception.
|
@@ -154,7 +65,7 @@ end
|
|
154
65
|
|
155
66
|
# improve the performance of the specs suite by not logging anything
|
156
67
|
# see http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
|
157
|
-
Rails.logger.level =
|
68
|
+
Rails.logger.level = Logger::FATAL
|
158
69
|
|
159
70
|
# Improves performance by forcing the garbage collector to run less often.
|
160
71
|
unless ENV['DEFER_GC'] == '0' || ENV['DEFER_GC'] == 'false'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe ActiveAdmin::Application, :
|
3
|
+
RSpec.describe ActiveAdmin::Application, type: :request do
|
4
4
|
|
5
5
|
include Rails.application.routes.url_helpers
|
6
6
|
|
@@ -8,17 +8,11 @@ describe ActiveAdmin::Application, :type => :request do
|
|
8
8
|
|
9
9
|
describe "with a #{value} default namespace" do
|
10
10
|
|
11
|
-
|
12
|
-
@__original_application = ActiveAdmin.application
|
11
|
+
around(:all) do |example|
|
13
12
|
application = ActiveAdmin::Application.new
|
14
13
|
application.default_namespace = value
|
15
|
-
ActiveAdmin.application = application
|
16
|
-
load_defaults!
|
17
|
-
reload_routes!
|
18
|
-
end
|
19
14
|
|
20
|
-
|
21
|
-
ActiveAdmin.application = @__original_application
|
15
|
+
with_temp_application(application) { example.call }
|
22
16
|
end
|
23
17
|
|
24
18
|
it "should generate a log out path" do
|
@@ -33,29 +27,23 @@ describe ActiveAdmin::Application, :type => :request do
|
|
33
27
|
|
34
28
|
end
|
35
29
|
|
36
|
-
|
30
|
+
describe "with a test default namespace" do
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
application.default_namespace = :test
|
42
|
-
ActiveAdmin.application = application
|
43
|
-
load_defaults!
|
44
|
-
reload_routes!
|
45
|
-
end
|
32
|
+
around(:all) do |example|
|
33
|
+
application = ActiveAdmin::Application.new
|
34
|
+
application.default_namespace = :test
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should generate a log out path" do
|
52
|
-
expect(destroy_admin_user_session_path).to eq "/test/logout"
|
53
|
-
end
|
36
|
+
with_temp_application(application) { example.call }
|
37
|
+
end
|
54
38
|
|
55
|
-
|
56
|
-
|
57
|
-
|
39
|
+
it "should generate a log out path" do
|
40
|
+
expect(destroy_admin_user_session_path).to eq "/test/logout"
|
41
|
+
end
|
58
42
|
|
43
|
+
it "should generate a log in path" do
|
44
|
+
expect(new_admin_user_session_path).to eq "/test/login"
|
59
45
|
end
|
60
46
|
|
47
|
+
end
|
48
|
+
|
61
49
|
end
|
@@ -7,7 +7,7 @@ require 'rbconfig'
|
|
7
7
|
RbConfig::CONFIG['host_os'].include?('darwin') ? `/usr/libexec/java_home` : `which java`
|
8
8
|
java_installed = $?.success?
|
9
9
|
|
10
|
-
describe 'Javascript', type: :request, if: java_installed do
|
10
|
+
RSpec.describe 'Javascript', type: :request, if: java_installed do
|
11
11
|
let(:lint) {
|
12
12
|
JSLint::Lint.new \
|
13
13
|
paths: ['public/javascripts/**/*.js'],
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe "Memory Leak", type: :request, if: RUBY_ENGINE == 'ruby' do
|
3
|
+
RSpec.describe "Memory Leak", type: :request, if: RUBY_ENGINE == 'ruby' do
|
4
|
+
before do
|
5
|
+
load_defaults!
|
6
|
+
end
|
7
|
+
|
4
8
|
def count_instances_of(klass)
|
5
9
|
ObjectSpace.each_object(klass) { }
|
6
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH << File.expand_path('../support', __FILE__)
|
3
|
-
|
4
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
5
|
-
require "bundler"
|
6
|
-
Bundler.setup
|
7
|
-
|
8
|
-
require 'detect_rails_version'
|
9
|
-
ENV['RAILS'] = detect_rails_version
|
10
|
-
|
11
1
|
require 'simplecov'
|
12
2
|
|
13
3
|
SimpleCov.start do
|
@@ -15,3 +5,8 @@ SimpleCov.start do
|
|
15
5
|
add_filter 'features/'
|
16
6
|
add_filter 'bundle/' # for Travis
|
17
7
|
end
|
8
|
+
|
9
|
+
if ENV['CI'] == 'true'
|
10
|
+
require 'codecov'
|
11
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
12
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module ActiveAdminIntegrationSpecHelper
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def load_defaults!
|
5
|
+
ActiveAdmin.unload!
|
6
|
+
ActiveAdmin.load!
|
7
|
+
ActiveAdmin.register(Category)
|
8
|
+
ActiveAdmin.register(User)
|
9
|
+
ActiveAdmin.register(Post){ belongs_to :user, optional: true }
|
10
|
+
reload_menus!
|
11
|
+
end
|
12
|
+
|
13
|
+
def reload_menus!
|
14
|
+
ActiveAdmin.application.namespaces.each{|n| n.reset_menu! }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Sometimes we need to reload the routes within
|
18
|
+
# the application to test them out
|
19
|
+
def reload_routes!
|
20
|
+
Rails.application.reload_routes!
|
21
|
+
end
|
22
|
+
|
23
|
+
# Helper method to load resources and ensure that Active Admin is
|
24
|
+
# setup with the new configurations.
|
25
|
+
#
|
26
|
+
# Eg:
|
27
|
+
# load_resources do
|
28
|
+
# ActiveAdmin.register(Post)
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
def load_resources
|
32
|
+
ActiveAdmin.unload!
|
33
|
+
yield
|
34
|
+
reload_menus!
|
35
|
+
reload_routes!
|
36
|
+
end
|
37
|
+
|
38
|
+
def arbre(assigns = {}, helpers = mock_action_view, &block)
|
39
|
+
Arbre::Context.new(assigns, helpers, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def render_arbre_component(assigns = {}, helpers = mock_action_view, &block)
|
43
|
+
arbre(assigns, helpers, &block).children.first
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns a fake action view instance to use with our renderers
|
47
|
+
def mock_action_view(assigns = {})
|
48
|
+
controller = ActionView::TestCase::TestController.new
|
49
|
+
MockActionView.new(ActionController::Base.view_paths, assigns, controller)
|
50
|
+
end
|
51
|
+
alias_method :action_view, :mock_action_view
|
52
|
+
|
53
|
+
# A mock action view to test view helpers
|
54
|
+
class MockActionView < ::ActionView::Base
|
55
|
+
include ActionView::Helpers
|
56
|
+
include ActiveAdmin::ViewHelpers
|
57
|
+
include Rails.application.routes.url_helpers
|
58
|
+
end
|
59
|
+
|
60
|
+
def with_translation(translation)
|
61
|
+
I18n.backend.store_translations :en, translation
|
62
|
+
yield
|
63
|
+
ensure
|
64
|
+
I18n.backend.reload!
|
65
|
+
end
|
66
|
+
end
|
@@ -24,4 +24,16 @@ module ActiveAdminRequestHelpers
|
|
24
24
|
@router = ::Rails.application.routes
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
def with_temp_application(application)
|
29
|
+
original_application = ActiveAdmin.application
|
30
|
+
ActiveAdmin.application = application
|
31
|
+
load_defaults!
|
32
|
+
reload_routes!
|
33
|
+
|
34
|
+
yield
|
35
|
+
|
36
|
+
ensure
|
37
|
+
ActiveAdmin.application = original_application
|
38
|
+
end
|
27
39
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# Rails template to build the sample app for specs
|
2
2
|
|
3
|
-
|
3
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
4
|
+
copy_file File.expand_path('../templates/manifest.js', __FILE__), 'app/assets/config/manifest.js', force: true
|
5
|
+
end
|
6
|
+
|
7
|
+
generate :model, 'post title:string body:text published_date:date author_id:integer ' +
|
4
8
|
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
|
5
9
|
create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
|
6
10
|
class Post < ActiveRecord::Base
|
@@ -10,14 +14,26 @@ create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
10
14
|
accepts_nested_attributes_for :author
|
11
15
|
accepts_nested_attributes_for :taggings
|
12
16
|
|
17
|
+
ransacker :custom_title_searcher do |parent|
|
18
|
+
parent.table[:title]
|
19
|
+
end
|
20
|
+
|
21
|
+
ransacker :custom_created_at_searcher do |parent|
|
22
|
+
parent.table[:created_at]
|
23
|
+
end
|
24
|
+
|
25
|
+
ransacker :custom_searcher_numeric, type: :numeric do
|
26
|
+
# nothing to see here
|
27
|
+
end
|
28
|
+
|
13
29
|
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
|
14
|
-
attr_accessible :id, :title, :body, :starred, :author, :position, :
|
30
|
+
attr_accessible :id, :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
|
15
31
|
end
|
16
32
|
end
|
17
33
|
RUBY
|
18
34
|
copy_file File.expand_path('../templates/post_decorator.rb', __FILE__), 'app/models/post_decorator.rb'
|
19
35
|
|
20
|
-
generate :model, 'blog/post title:string body:text
|
36
|
+
generate :model, 'blog/post title:string body:text published_date:date author_id:integer ' +
|
21
37
|
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
|
22
38
|
create_file 'app/models/blog/post.rb', <<-RUBY.strip_heredoc, force: true
|
23
39
|
class Blog::Post < ActiveRecord::Base
|
@@ -28,7 +44,7 @@ create_file 'app/models/blog/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
28
44
|
accepts_nested_attributes_for :taggings
|
29
45
|
|
30
46
|
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
|
31
|
-
attr_accessible :title, :body, :starred, :author, :position, :
|
47
|
+
attr_accessible :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
|
32
48
|
end
|
33
49
|
end
|
34
50
|
RUBY
|
@@ -42,6 +58,10 @@ create_file 'app/models/user.rb', <<-RUBY.strip_heredoc, force: true
|
|
42
58
|
has_one :profile
|
43
59
|
accepts_nested_attributes_for :profile, allow_destroy: true
|
44
60
|
|
61
|
+
ransacker :age_in_five_years, type: :numeric, formatter: proc { |v| v.to_i - 5 } do |parent|
|
62
|
+
parent.table[:age]
|
63
|
+
end
|
64
|
+
|
45
65
|
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
|
46
66
|
attr_accessible :first_name, :last_name, :username, :age
|
47
67
|
end
|
@@ -55,6 +75,10 @@ RUBY
|
|
55
75
|
create_file 'app/models/profile.rb', <<-RUBY.strip_heredoc, force: true
|
56
76
|
class Profile < ActiveRecord::Base
|
57
77
|
belongs_to :user
|
78
|
+
|
79
|
+
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
|
80
|
+
attr_accessible :bio
|
81
|
+
end
|
58
82
|
end
|
59
83
|
RUBY
|
60
84
|
|
@@ -68,7 +92,7 @@ create_file 'app/models/category.rb', <<-RUBY.strip_heredoc, force: true
|
|
68
92
|
accepts_nested_attributes_for :posts
|
69
93
|
|
70
94
|
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
|
71
|
-
attr_accessible :name
|
95
|
+
attr_accessible :name, :description
|
72
96
|
end
|
73
97
|
end
|
74
98
|
RUBY
|
@@ -111,15 +135,21 @@ gsub_file 'config/environments/test.rb', / config.cache_classes = true/, <<-RUB
|
|
111
135
|
config.action_mailer.default_url_options = {host: 'example.com'}
|
112
136
|
config.assets.digest = false
|
113
137
|
|
138
|
+
if Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1
|
139
|
+
config.active_record.maintain_test_schema = false
|
140
|
+
end
|
141
|
+
|
114
142
|
RUBY
|
115
143
|
|
116
|
-
# Add our local Active Admin to the
|
117
|
-
|
144
|
+
# Add our local Active Admin to the application
|
145
|
+
gem 'activeadmin', path: '../..'
|
146
|
+
gem 'inherited_resources', git: 'https://github.com/activeadmin/inherited_resources'
|
147
|
+
gem 'devise'
|
118
148
|
|
119
|
-
|
120
|
-
require 'active_admin'
|
149
|
+
run 'bundle install'
|
121
150
|
|
122
|
-
|
151
|
+
# Setup Active Admin
|
152
|
+
generate 'active_admin:install'
|
123
153
|
|
124
154
|
# Force strong parameters to raise exceptions
|
125
155
|
inject_into_file 'config/application.rb', <<-RUBY, after: 'class Application < Rails::Application'
|
@@ -137,10 +167,6 @@ directory File.expand_path('../templates/admin', __FILE__), 'app/admin'
|
|
137
167
|
# Add predefined policies
|
138
168
|
directory File.expand_path('../templates/policies', __FILE__), 'app/policies'
|
139
169
|
|
140
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
141
|
-
|
142
|
-
generate 'active_admin:install'
|
143
|
-
|
144
170
|
if ENV['RAILS_ENV'] != 'test'
|
145
171
|
inject_into_file 'config/routes.rb', "\n root to: redirect('admin')", after: /.*routes.draw do/
|
146
172
|
end
|
@@ -151,7 +177,8 @@ remove_file 'public/index.html' if File.exists? 'public/index.html' # remove onc
|
|
151
177
|
# https://github.com/plataformatec/devise/issues/2554
|
152
178
|
gsub_file 'config/initializers/devise.rb', /# config.secret_key =/, 'config.secret_key ='
|
153
179
|
|
154
|
-
rake
|
180
|
+
rake "db:drop db:create db:migrate", env: 'development'
|
181
|
+
rake "db:drop db:create db:migrate", env: 'test'
|
155
182
|
|
156
183
|
if ENV['INSTALL_PARALLEL']
|
157
184
|
inject_into_file 'config/database.yml', "<%= ENV['TEST_ENV_NUMBER'] %>", after: 'test.sqlite3'
|