andrewroth_activeadmin 0.3.4 → 0.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +159 -3
- data/CONTRIBUTING.md +113 -0
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js +9 -0
- data/app/assets/javascripts/active_admin/base.js +4 -12
- data/app/assets/stylesheets/active_admin/_base.css.scss +16 -340
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -7
- data/app/assets/stylesheets/active_admin/_header.css.scss +23 -4
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +2 -0
- data/app/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/app/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/app/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +101 -0
- data/app/assets/stylesheets/active_admin/mixins/_all.css.scss +2 -1
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +50 -13
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +7 -5
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/active_admin/page/index.html.arb +1 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +3 -2
- data/docs/1-general-configuration.md +46 -10
- data/docs/6-show-screens.md +7 -0
- data/docs/8-custom-actions.md +12 -2
- data/docs/9-custom-pages.md +84 -0
- data/features/belongs_to.feature +27 -0
- data/features/comments/commenting.feature +3 -2
- data/features/dashboard.feature +18 -0
- data/features/development_reloading.feature +19 -0
- data/features/index/filter_with_check_boxes.feature +25 -0
- data/features/index/index_as_table.feature +14 -0
- data/features/index/index_scopes.feature +42 -0
- data/features/index/pagination.feature +19 -1
- data/features/menu.feature +22 -2
- data/features/registering_assets.feature +2 -2
- data/features/registering_pages.feature +66 -0
- data/features/specifying_actions.feature +5 -0
- data/features/step_definitions/action_item_steps.rb +2 -6
- data/features/step_definitions/action_link_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +8 -0
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/configuration_steps.rb +56 -8
- data/features/step_definitions/dashboard_steps.rb +5 -1
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +16 -4
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +25 -10
- data/lib/active_admin/application.rb +63 -20
- data/lib/active_admin/arbre/html/element.rb +10 -0
- data/lib/active_admin/asset_registration.rb +15 -2
- data/lib/active_admin/base_controller.rb +61 -0
- data/lib/active_admin/{resource_controller → base_controller}/menu.rb +1 -1
- data/lib/active_admin/comments.rb +48 -54
- data/lib/active_admin/comments/comment.rb +13 -2
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +7 -3
- data/lib/active_admin/dashboards.rb +4 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +20 -4
- data/lib/active_admin/dsl.rb +6 -159
- data/lib/active_admin/event.rb +5 -3
- data/lib/active_admin/filter_form_builder.rb +53 -0
- data/lib/active_admin/form_builder.rb +25 -19
- data/lib/active_admin/inputs.rb +14 -0
- data/lib/active_admin/inputs/datepicker_input.rb +11 -0
- data/lib/active_admin/inputs/filter_base.rb +46 -0
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +40 -0
- data/lib/active_admin/inputs/filter_date_range_input.rb +34 -0
- data/lib/active_admin/inputs/filter_numeric_input.rb +55 -0
- data/lib/active_admin/inputs/filter_select_input.rb +23 -0
- data/lib/active_admin/inputs/filter_string_input.rb +22 -0
- data/lib/active_admin/locales/ca.yml +44 -0
- data/lib/active_admin/locales/cs.yml +14 -10
- data/lib/active_admin/locales/de.yml +43 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/ko.yml +40 -0
- data/lib/active_admin/locales/lv.yml +43 -0
- data/lib/active_admin/locales/nl.yml +40 -0
- data/lib/active_admin/locales/no-NB.yml +40 -0
- data/lib/active_admin/locales/pl.yml +7 -1
- data/lib/active_admin/locales/pt-BR.yml +6 -2
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +54 -0
- data/lib/active_admin/page_controller.rb +15 -0
- data/lib/active_admin/page_dsl.rb +21 -0
- data/lib/active_admin/page_presenter.rb +30 -0
- data/lib/active_admin/resource.rb +38 -44
- data/lib/active_admin/resource/action_items.rb +5 -0
- data/lib/active_admin/resource/belongs_to.rb +4 -2
- data/lib/active_admin/resource/controllers.rb +35 -0
- data/lib/active_admin/resource/menu.rb +1 -2
- data/lib/active_admin/resource/naming.rb +43 -31
- data/lib/active_admin/resource/page_presenters.rb +28 -0
- data/lib/active_admin/resource/scopes.rb +16 -3
- data/lib/active_admin/resource/sidebars.rb +4 -0
- data/lib/active_admin/resource_collection.rb +88 -0
- data/lib/active_admin/resource_controller.rb +18 -54
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +1 -1
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +8 -4
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/resource_class_methods.rb +24 -0
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +157 -0
- data/lib/active_admin/router.rb +21 -14
- data/lib/active_admin/scope.rb +15 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +4 -3
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -10
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +25 -21
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -150
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/scopes.rb +17 -17
- data/lib/active_admin/views/components/status_tag.rb +6 -5
- data/lib/active_admin/views/components/table_for.rb +6 -2
- data/lib/active_admin/views/header_renderer.rb +31 -12
- data/lib/active_admin/views/index_as_block.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +3 -3
- data/lib/active_admin/views/index_as_grid.rb +4 -4
- data/lib/active_admin/views/index_as_table.rb +13 -6
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/form.rb +49 -0
- data/lib/active_admin/views/pages/index.rb +18 -6
- data/lib/active_admin/views/pages/page.rb +24 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +19 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +38 -12
- data/lib/generators/active_admin/install/templates/dashboards.rb +6 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/templates/cucumber_with_reloading.rb +5 -0
- data/spec/unit/active_admin_spec.rb +8 -0
- data/spec/unit/application_spec.rb +48 -2
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/asset_registration_spec.rb +9 -3
- data/spec/unit/auto_link_spec.rb +2 -2
- data/spec/unit/base_controller_shared_examples.rb +28 -0
- data/spec/unit/base_controller_spec.rb +8 -0
- data/spec/unit/belongs_to_spec.rb +30 -33
- data/spec/unit/comments_spec.rb +45 -15
- data/spec/unit/config_shared_examples.rb +108 -0
- data/spec/unit/dashboard_controller_spec.rb +44 -0
- data/spec/unit/event_spec.rb +6 -0
- data/spec/unit/filter_form_builder_spec.rb +9 -0
- data/spec/unit/form_builder_spec.rb +8 -14
- data/spec/unit/namespace/register_page_spec.rb +102 -0
- data/spec/unit/namespace/register_resource_spec.rb +188 -0
- data/spec/unit/namespace_spec.rb +11 -183
- data/spec/unit/page_controller_spec.rb +8 -0
- data/spec/unit/page_spec.rb +60 -0
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +24 -19
- data/spec/unit/resource/page_presenters_spec.rb +32 -0
- data/spec/unit/resource/scopes_spec.rb +13 -0
- data/spec/unit/resource_collection_spec.rb +101 -0
- data/spec/unit/resource_controller_spec.rb +40 -32
- data/spec/unit/{registration_spec.rb → resource_registration_spec.rb} +0 -0
- data/spec/unit/resource_spec.rb +8 -24
- data/spec/unit/routing_spec.rb +50 -1
- data/spec/unit/scope_spec.rb +18 -4
- data/spec/unit/views/components/paginated_collection_spec.rb +150 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/tasks/test.rake +43 -27
- metadata +140 -31
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/comments/configuration.rb +0 -18
- data/lib/active_admin/page_config.rb +0 -15
- data/lib/active_admin/resource_controller/form.rb +0 -42
- data/lib/active_admin/resource_controller/page_configurations.rb +0 -53
- data/lib/active_admin/views/pages/edit.rb +0 -28
- data/lib/active_admin/views/pages/new.rb +0 -28
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +0 -427
- data/spec/integration/belongs_to_spec.rb +0 -42
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
module Pages
|
4
|
+
class Page < Base
|
5
|
+
|
6
|
+
def main_content
|
7
|
+
page_presenter = active_admin_config.get_page_presenter(:index)
|
8
|
+
|
9
|
+
if page_presenter && page_presenter.block
|
10
|
+
instance_exec &page_presenter.block
|
11
|
+
else
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def title
|
19
|
+
active_admin_config.name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -2,20 +2,38 @@ module ActiveAdmin
|
|
2
2
|
module Generators
|
3
3
|
class AssetsGenerator < Rails::Generators::Base
|
4
4
|
|
5
|
+
class_option :bourbon, :type => :boolean, :default => true,
|
6
|
+
:desc => "Generate Bourbon scss files if using Rails 3.0.x"
|
7
|
+
|
8
|
+
class_option :jquery, :type => :boolean, :default => true,
|
9
|
+
:desc => "Generate jQuery js files if using Rails 3.0.x"
|
10
|
+
|
5
11
|
def self.source_root
|
6
12
|
@_active_admin_source_root ||= File.expand_path("../templates", __FILE__)
|
7
13
|
end
|
8
14
|
|
9
15
|
def install_assets
|
16
|
+
require 'rails'
|
17
|
+
require 'active_admin'
|
18
|
+
|
10
19
|
if ActiveAdmin.use_asset_pipeline?
|
11
20
|
template '3.1/active_admin.js', 'app/assets/javascripts/active_admin.js'
|
12
21
|
template '3.1/active_admin.css.scss', 'app/assets/stylesheets/active_admin.css.scss'
|
13
22
|
else
|
14
|
-
template '
|
23
|
+
template '../../../../../app/assets/javascripts/active_admin/application.js', 'public/javascripts/active_admin.js'
|
15
24
|
directory '../../../../../app/assets/images/active_admin', 'public/images/active_admin'
|
25
|
+
generate "jquery:install --ui" if options.jquery?
|
26
|
+
install_bourbon if options.bourbon?
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
def install_bourbon
|
33
|
+
rake "bourbon:install"
|
34
|
+
create_file "public/stylesheets/sass/_bourbon.scss", '@import "bourbon/bourbon"'
|
35
|
+
end
|
36
|
+
|
19
37
|
end
|
20
38
|
end
|
21
39
|
end
|
@@ -7,17 +7,24 @@ ActiveAdmin.setup do |config|
|
|
7
7
|
#
|
8
8
|
config.site_title = "<%= Rails.application.class.name.split("::").first.titlecase %>"
|
9
9
|
|
10
|
-
# Set the link url for the title. For example, to take
|
10
|
+
# Set the link url for the title. For example, to take
|
11
11
|
# users to your main site. Defaults to no link.
|
12
12
|
#
|
13
13
|
# config.site_title_link = "/"
|
14
14
|
|
15
|
+
# Set an optional image to be displayed for the header
|
16
|
+
# instead of a string (overrides :site_title)
|
17
|
+
#
|
18
|
+
# Note: Recommended image height is 21px to properly fit in the header
|
19
|
+
#
|
20
|
+
# config.site_title_image = "/images/logo.png"
|
21
|
+
|
15
22
|
# == Default Namespace
|
16
23
|
#
|
17
24
|
# Set the default namespace each administration resource
|
18
|
-
# will be added to.
|
25
|
+
# will be added to.
|
19
26
|
#
|
20
|
-
# eg:
|
27
|
+
# eg:
|
21
28
|
# config.default_namespace = :hello_world
|
22
29
|
#
|
23
30
|
# This will create resources in the HelloWorld module and
|
@@ -28,11 +35,22 @@ ActiveAdmin.setup do |config|
|
|
28
35
|
#
|
29
36
|
# Default:
|
30
37
|
# config.default_namespace = :admin
|
38
|
+
#
|
39
|
+
# You can customize the settings for each namespace by using
|
40
|
+
# a namespace block. For example, to change the site title
|
41
|
+
# within a namespace:
|
42
|
+
#
|
43
|
+
# config.namespace :admin do |admin|
|
44
|
+
# admin.site_title = "Custom Admin Title"
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# This will ONLY change the title for the admin section. Other
|
48
|
+
# namespaces will continue to use the main "site_title" configuration.
|
31
49
|
|
32
50
|
# == User Authentication
|
33
51
|
#
|
34
|
-
# Active Admin will automatically call an authentication
|
35
|
-
# method in a before filter of all controller actions to
|
52
|
+
# Active Admin will automatically call an authentication
|
53
|
+
# method in a before filter of all controller actions to
|
36
54
|
# ensure that there is a currently logged in admin user.
|
37
55
|
#
|
38
56
|
# This setting changes the method which Active Admin calls
|
@@ -71,20 +89,25 @@ ActiveAdmin.setup do |config|
|
|
71
89
|
|
72
90
|
# == Admin Comments
|
73
91
|
#
|
74
|
-
# Admin comments allow you to add comments to any model for admin use
|
75
|
-
#
|
76
|
-
# Admin comments are enabled by default in the default
|
77
|
-
# namespace only. You can turn them on in a namesapce
|
78
|
-
# by adding them to the comments array.
|
92
|
+
# Admin comments allow you to add comments to any model for admin use.
|
93
|
+
# Admin comments are enabled by default.
|
79
94
|
#
|
80
95
|
# Default:
|
81
|
-
# config.
|
96
|
+
# config.allow_comments = true
|
97
|
+
#
|
98
|
+
# You can turn them on and off for any given namespace by using a
|
99
|
+
# namespace config block.
|
100
|
+
#
|
101
|
+
# Eg:
|
102
|
+
# config.namespace :without_comments do |without_comments|
|
103
|
+
# without_comments.allow_comments = false
|
104
|
+
# end
|
82
105
|
|
83
106
|
|
84
107
|
# == Controller Filters
|
85
108
|
#
|
86
109
|
# You can add before, after and around filters to all of your
|
87
|
-
# Active Admin resources from here.
|
110
|
+
# Active Admin resources from here.
|
88
111
|
#
|
89
112
|
# config.before_filter :do_something_awesome
|
90
113
|
|
@@ -98,6 +121,9 @@ ActiveAdmin.setup do |config|
|
|
98
121
|
# To load a stylesheet:
|
99
122
|
# config.register_stylesheet 'my_stylesheet.css'
|
100
123
|
#
|
124
|
+
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
|
125
|
+
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
|
126
|
+
#
|
101
127
|
# To load a javascript file:
|
102
128
|
# config.register_javascript 'my_javascript.js'
|
103
129
|
end
|
@@ -34,5 +34,11 @@ ActiveAdmin::Dashboards.build do
|
|
34
34
|
# section "Recent User", :priority => 1
|
35
35
|
#
|
36
36
|
# Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.
|
37
|
+
|
38
|
+
# == Conditionally Display
|
39
|
+
# Provide a method name or Proc object to conditionally render a section at run time.
|
40
|
+
#
|
41
|
+
# section "Membership Summary", :if => :memberships_enabled?
|
42
|
+
# section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }
|
37
43
|
|
38
44
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
# Create a cucumber database and environment
|
4
4
|
copy_file File.expand_path('../templates/cucumber.rb', __FILE__), "config/environments/cucumber.rb"
|
5
|
+
copy_file File.expand_path('../templates/cucumber_with_reloading.rb', __FILE__), "config/environments/cucumber_with_reloading.rb"
|
6
|
+
|
5
7
|
gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
|
6
8
|
gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test\n database: db/cucumber.sqlite3"
|
9
|
+
gsub_file 'config/database.yml', /\z/, "\ncucumber_with_reloading:\n <<: *test\n database: db/cucumber.sqlite3"
|
7
10
|
|
8
11
|
# Generate some test models
|
9
12
|
generate :model, "post title:string body:text published_at:datetime author_id:integer category_id:integer"
|
@@ -22,6 +25,14 @@ run "rm -r test"
|
|
22
25
|
run "rm -r spec"
|
23
26
|
|
24
27
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
28
|
+
|
29
|
+
# we need this routing path, named "logout_path", for testing
|
30
|
+
route <<-EOS
|
31
|
+
devise_scope :user do
|
32
|
+
match '/admin/logout' => 'active_admin/devise/sessions#destroy', :as => :logout
|
33
|
+
end
|
34
|
+
EOS
|
35
|
+
|
25
36
|
generate :'active_admin:install'
|
26
37
|
|
27
38
|
# Setup a root path for devise
|
@@ -14,4 +14,12 @@ describe ActiveAdmin do
|
|
14
14
|
ActiveAdmin.default_namespace
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
%w(register register_page unload! load! routes).each do |method|
|
19
|
+
it "delegates ##{method} to application" do
|
20
|
+
ActiveAdmin.application.should_receive(method)
|
21
|
+
|
22
|
+
ActiveAdmin.send(method)
|
23
|
+
end
|
24
|
+
end
|
17
25
|
end
|
@@ -39,6 +39,15 @@ describe ActiveAdmin::Application do
|
|
39
39
|
application.site_title_link = "http://www.mygreatsite.com"
|
40
40
|
application.site_title_link.should == "http://www.mygreatsite.com"
|
41
41
|
end
|
42
|
+
|
43
|
+
it "should store the site's title image" do
|
44
|
+
application.site_title_image.should == ""
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should set the site's title image" do
|
48
|
+
application.site_title_image = "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
49
|
+
application.site_title_image.should == "http://railscasts.com/assets/episodes/stills/284-active-admin.png?1316476106"
|
50
|
+
end
|
42
51
|
|
43
52
|
it "should have a view factory" do
|
44
53
|
application.view_factory.should be_an_instance_of(ActiveAdmin::ViewFactory)
|
@@ -48,8 +57,8 @@ describe ActiveAdmin::Application do
|
|
48
57
|
application.admin_notes.should be_nil
|
49
58
|
end
|
50
59
|
|
51
|
-
it "should
|
52
|
-
application.
|
60
|
+
it "should allow comments by default" do
|
61
|
+
application.allow_comments.should == true
|
53
62
|
end
|
54
63
|
|
55
64
|
describe "authentication settings" do
|
@@ -84,4 +93,41 @@ describe ActiveAdmin::Application do
|
|
84
93
|
end
|
85
94
|
end
|
86
95
|
|
96
|
+
describe "adding an inheritable setting" do
|
97
|
+
|
98
|
+
it "should add a setting to Application and Namespace" do
|
99
|
+
ActiveAdmin::Application.inheritable_setting :inheritable_setting, "inheritable_setting"
|
100
|
+
app = ActiveAdmin::Application.new
|
101
|
+
app.inheritable_setting.should == "inheritable_setting"
|
102
|
+
ns = ActiveAdmin::Namespace.new(app, :admin)
|
103
|
+
ns.inheritable_setting.should == "inheritable_setting"
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#namespace" do
|
109
|
+
it "should yield a new namespace" do
|
110
|
+
application.namespace :new_namespace do |ns|
|
111
|
+
ns.name.should == :new_namespace
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should return an instantiated namespace" do
|
116
|
+
admin = application.find_or_create_namespace :admin
|
117
|
+
application.namespace :admin do |ns|
|
118
|
+
ns.should == admin
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#register_page" do
|
124
|
+
it "finds or create the namespace and register the page to it" do
|
125
|
+
namespace = mock
|
126
|
+
application.should_receive(:find_or_create_namespace).with("public").and_return namespace
|
127
|
+
namespace.should_receive(:register_page).with("My Page", {:namespace => "public"})
|
128
|
+
|
129
|
+
application.register_page("My Page", :namespace => "public")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
87
133
|
end
|
@@ -49,6 +49,62 @@ describe Arbre::HTML::Element, "Finder Methods" do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe "finding an element by id"
|
53
|
-
|
52
|
+
#TODO: describe "finding an element by id"
|
53
|
+
|
54
|
+
describe "finding an element by a class name" do
|
55
|
+
it "should return 0 when no elements exist" do
|
56
|
+
div.get_elements_by_class_name("my_class").size.should == 0
|
57
|
+
end
|
58
|
+
it "should return a child element" do
|
59
|
+
html = div do
|
60
|
+
div :class => "some_class"
|
61
|
+
div :class => "my_class"
|
62
|
+
end
|
63
|
+
elements = html.get_elements_by_class_name("my_class")
|
64
|
+
elements.size.should == 1
|
65
|
+
elements[0].should be_instance_of(Arbre::HTML::Div)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return multple child elements" do
|
69
|
+
html = div do
|
70
|
+
div :class => "some_class"
|
71
|
+
div :class => "my_class"
|
72
|
+
div :class => "my_class"
|
73
|
+
end
|
74
|
+
elements = html.get_elements_by_class_name("my_class")
|
75
|
+
elements.size.should == 2
|
76
|
+
elements[0].should be_instance_of(Arbre::HTML::Div)
|
77
|
+
elements[1].should be_instance_of(Arbre::HTML::Div)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return elements that match one of several classes" do
|
81
|
+
html = div do
|
82
|
+
div :class => "some_class this_class"
|
83
|
+
div :class => "some_class"
|
84
|
+
div :class => "other_class"
|
85
|
+
|
86
|
+
end
|
87
|
+
elements = html.get_elements_by_class_name("this_class")
|
88
|
+
elements.size.should == 1
|
89
|
+
elements[0].should be_instance_of(Arbre::HTML::Div)
|
90
|
+
end
|
91
|
+
|
92
|
+
#TODO: find children's children by class name
|
93
|
+
|
94
|
+
#it "should return elements that are nested" do
|
95
|
+
# html = div do
|
96
|
+
# div :class => "my_class"
|
97
|
+
# div :class => "some_class" do
|
98
|
+
# ul :class => "other_class" do
|
99
|
+
# li :class => "special_awesome_class"
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# elements = html.get_elements_by_class_name("special_awesome_class")
|
105
|
+
#
|
106
|
+
# elements.size.should == 1
|
107
|
+
# elements[0].should be_instance_of(Arbre::HTML::Li)
|
108
|
+
#end
|
109
|
+
end
|
54
110
|
end
|
@@ -13,14 +13,20 @@ describe ActiveAdmin::AssetRegistration do
|
|
13
13
|
|
14
14
|
it "should register a stylesheet file" do
|
15
15
|
MockRegistration.register_stylesheet "active_admin.css"
|
16
|
-
MockRegistration.stylesheets.should ==
|
16
|
+
MockRegistration.stylesheets.length.should == 1
|
17
|
+
MockRegistration.stylesheets.first.path.should == "active_admin.css"
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should clear all existing stylesheets" do
|
20
21
|
MockRegistration.register_stylesheet "active_admin.css"
|
21
|
-
MockRegistration.stylesheets.should ==
|
22
|
+
MockRegistration.stylesheets.length.should == 1
|
22
23
|
MockRegistration.clear_stylesheets!
|
23
|
-
MockRegistration.stylesheets.should ==
|
24
|
+
MockRegistration.stylesheets.length.should == 0
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow media option when registering stylesheet" do
|
28
|
+
MockRegistration.register_stylesheet "active_admin.css", :media => :print
|
29
|
+
MockRegistration.stylesheets.first.options[:media].should == :print
|
24
30
|
end
|
25
31
|
|
26
32
|
it "should register a javascript file" do
|
data/spec/unit/auto_link_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe "auto linking resources" do
|
|
13
13
|
include ActiveAdmin::ViewHelpers::DisplayHelper
|
14
14
|
|
15
15
|
let(:active_admin_config) { AutoLinkMockResource.new(namespace) }
|
16
|
-
let(:
|
16
|
+
let(:active_admin_namespace){ ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin) }
|
17
17
|
let(:post){ Post.create! :title => "Hello World" }
|
18
18
|
|
19
19
|
def admin_post_path(post)
|
@@ -28,7 +28,7 @@ describe "auto linking resources" do
|
|
28
28
|
|
29
29
|
context "when the resource is registered" do
|
30
30
|
before do
|
31
|
-
|
31
|
+
active_admin_namespace.register Post
|
32
32
|
end
|
33
33
|
it "should return a link with the display name of the object" do
|
34
34
|
self.should_receive(:link_to).with("Hello World", admin_post_path(post))
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Required methods:
|
2
|
+
# * controller_class
|
3
|
+
# * controller
|
4
|
+
#
|
5
|
+
shared_examples_for "BaseController" do
|
6
|
+
let(:controller_class) { described_class }
|
7
|
+
|
8
|
+
describe "Menu" do
|
9
|
+
describe "setting the current tab" do
|
10
|
+
before do
|
11
|
+
controller.stub!(:active_admin_config => resource, :parent? => true)
|
12
|
+
controller.send :set_current_tab # Run the before filter
|
13
|
+
end
|
14
|
+
subject{ controller.instance_variable_get(:@current_tab) }
|
15
|
+
|
16
|
+
context "when menu item name is 'Resources' without a parent menu item" do
|
17
|
+
let(:resource){ mock(:menu_item_name => "Resources", :parent_menu_item_name => nil, :belongs_to? => false) }
|
18
|
+
it { should == "Resources" }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when there is a parent menu item of 'Admin'" do
|
22
|
+
let(:resource){ mock(:parent_menu_item_name => "Admin", :menu_item_name => "Resources", :belongs_to? => false) }
|
23
|
+
it { should == "Admin/Resources" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|