activeadmin 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +34 -0
- data/.travis.yml +4 -0
- data/.yardopts +8 -0
- data/CHANGELOG.md +177 -0
- data/Gemfile +21 -32
- data/Guardfile +8 -0
- data/README.rdoc +75 -14
- data/Rakefile +7 -100
- data/activeadmin.gemspec +21 -353
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/admin_notes_icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-header-bg.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-next-link-icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-nipple.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-prev-link-icon.png +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/loading.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow_dark.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/orderable.png +0 -0
- data/app/assets/javascripts/active_admin/base.js +12 -0
- data/{lib/generators/active_admin/install/templates/active_admin_vendor.js → app/assets/javascripts/active_admin/vendor.js} +0 -0
- data/{lib/active_admin/stylesheets/active_admin.scss → app/assets/stylesheets/active_admin/_base.css.scss} +58 -82
- data/{lib/active_admin/stylesheets/active_admin/_forms.scss → app/assets/stylesheets/active_admin/_forms.css.scss} +94 -5
- data/{lib/active_admin/stylesheets/active_admin/_header.scss → app/assets/stylesheets/active_admin/_header.css.scss} +13 -11
- data/app/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
- data/{lib/active_admin/stylesheets/active_admin/_typography.scss → app/assets/stylesheets/active_admin/_typography.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/_comments.scss → app/assets/stylesheets/active_admin/components/_comments.css.scss} +0 -0
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +38 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_all.scss → app/assets/stylesheets/active_admin/mixins/_all.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_buttons.scss → app/assets/stylesheets/active_admin/mixins/_buttons.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_gradients.scss → app/assets/stylesheets/active_admin/mixins/_gradients.css.scss} +8 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_icons.scss → app/assets/stylesheets/active_admin/mixins/_icons.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_reset.scss → app/assets/stylesheets/active_admin/mixins/_reset.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_rounded.scss → app/assets/stylesheets/active_admin/mixins/_rounded.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_sections.scss → app/assets/stylesheets/active_admin/mixins/_sections.css.scss} +9 -2
- data/{lib/active_admin/stylesheets/active_admin/mixins/_shadows.scss → app/assets/stylesheets/active_admin/mixins/_shadows.css.scss} +1 -1
- data/{lib/active_admin/stylesheets/active_admin/mixins/_variables.scss → app/assets/stylesheets/active_admin/mixins/_variables.css.scss} +12 -3
- data/{lib/active_admin/views/templates/active_admin_dashboard → app/views/active_admin/dashboard}/index.html.arb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/reset_password_instructions.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/unlock_instructions.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/edit.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/new.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/sessions/new.html.erb +1 -1
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/shared/_links.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/unlocks/new.html.erb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/edit.html.arb +0 -0
- data/app/views/active_admin/resource/index.csv.erb +20 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/index.html.arb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/new.html.arb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/show.html.arb +0 -0
- data/app/views/layouts/active_admin.html.arb +1 -0
- data/{lib/active_admin/views/templates → app/views}/layouts/active_admin_logged_out.html.erb +8 -4
- data/docs/0-installation.md +50 -0
- data/docs/1-general-configuration.md +43 -0
- data/docs/2-resource-customization.md +35 -0
- data/docs/3-index-pages.md +55 -0
- data/docs/3-index-pages/index-as-block.md +16 -0
- data/docs/3-index-pages/index-as-blog.md +61 -0
- data/docs/3-index-pages/index-as-grid.md +21 -0
- data/docs/3-index-pages/index-as-table.md +90 -0
- data/docs/4-csv-format.md +14 -0
- data/docs/5-forms.md +39 -0
- data/docs/6-show-screens.md +22 -0
- data/docs/7-sidebars.md +35 -0
- data/docs/8-custom-actions.md +123 -0
- data/features/comments/commenting.feature +31 -4
- data/features/edit_page.feature +30 -1
- data/features/index/filters.feature +35 -0
- data/features/index/format_as_csv.feature +46 -0
- data/features/index/formats.feature +2 -0
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_grid.feature +1 -1
- data/features/index/index_as_table.feature +2 -0
- data/features/index/index_blank_slate.feature +56 -0
- data/features/index/pagination.feature +0 -6
- data/features/registering_assets.feature +2 -2
- data/features/sidebar_sections.feature +7 -8
- data/features/specifying_actions.feature +72 -1
- data/features/step_definitions/action_item_steps.rb +2 -2
- data/features/step_definitions/additional_web_steps.rb +26 -16
- data/features/step_definitions/attribute_steps.rb +5 -7
- data/features/step_definitions/configuration_steps.rb +9 -9
- data/features/step_definitions/factory_steps.rb +4 -3
- data/features/step_definitions/format_steps.rb +29 -1
- data/features/step_definitions/layout_steps.rb +3 -0
- data/features/step_definitions/menu_steps.rb +2 -2
- data/features/step_definitions/sidebar_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +8 -2
- data/features/step_definitions/web_steps.rb +82 -90
- data/features/sti_resource.feature +12 -0
- data/features/support/env.rb +12 -10
- data/features/support/paths.rb +2 -0
- data/features/support/selectors.rb +45 -0
- data/lib/active_admin.rb +33 -263
- data/lib/active_admin/application.rb +228 -0
- data/lib/active_admin/arbre.rb +10 -10
- data/lib/active_admin/arbre/{html.rb → builder.rb} +29 -2
- data/lib/active_admin/arbre/context.rb +8 -0
- data/lib/active_admin/arbre/{attributes.rb → html/attributes.rb} +0 -0
- data/lib/active_admin/arbre/{class_list.rb → html/class_list.rb} +0 -0
- data/lib/active_admin/arbre/{collection.rb → html/collection.rb} +0 -0
- data/lib/active_admin/arbre/{document.rb → html/document.rb} +0 -0
- data/lib/active_admin/arbre/{element.rb → html/element.rb} +6 -6
- data/lib/active_admin/arbre/{html5_elements.rb → html/html5_elements.rb} +0 -0
- data/lib/active_admin/arbre/{tag.rb → html/tag.rb} +0 -0
- data/lib/active_admin/arbre/{text_node.rb → html/text_node.rb} +0 -0
- data/lib/active_admin/asset_registration.rb +1 -1
- data/lib/active_admin/callbacks.rb +5 -3
- data/lib/active_admin/comments.rb +3 -3
- data/lib/active_admin/comments/comment.rb +6 -0
- data/lib/active_admin/comments/configuration.rb +8 -6
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +1 -1
- data/lib/active_admin/csv_builder.rb +45 -0
- data/lib/active_admin/dashboards.rb +1 -1
- data/lib/active_admin/dashboards/dashboard_controller.rb +3 -10
- data/lib/active_admin/dependency_checker.rb +28 -0
- data/lib/active_admin/deprecation.rb +36 -0
- data/lib/active_admin/devise.rb +14 -3
- data/lib/active_admin/dsl.rb +26 -4
- data/lib/active_admin/engine.rb +4 -0
- data/lib/active_admin/form_builder.rb +18 -9
- data/lib/active_admin/helpers/scope_chain.rb +23 -0
- data/lib/active_admin/helpers/settings.rb +70 -0
- data/lib/active_admin/locales/cs.yml +34 -0
- data/lib/active_admin/locales/da.yml +28 -0
- data/lib/active_admin/locales/en.yml +40 -0
- data/lib/active_admin/locales/es.yml +40 -0
- data/lib/active_admin/locales/fr.yml +40 -0
- data/lib/active_admin/locales/it.yml +39 -0
- data/lib/active_admin/locales/pl.yml +34 -0
- data/lib/active_admin/locales/pt-BR.yml +41 -0
- data/lib/active_admin/locales/ru.yml +40 -0
- data/lib/active_admin/locales/zh_cn.yml +40 -0
- data/lib/active_admin/menu_item.rb +6 -0
- data/lib/active_admin/namespace.rb +14 -5
- data/lib/active_admin/reloader.rb +30 -0
- data/lib/active_admin/renderer.rb +1 -1
- data/lib/active_admin/resource.rb +45 -88
- data/lib/active_admin/resource/action_items.rb +88 -0
- data/lib/active_admin/resource/menu.rb +45 -0
- data/lib/active_admin/resource/naming.rb +46 -0
- data/lib/active_admin/resource/scopes.rb +33 -0
- data/lib/active_admin/resource/sidebars.rb +36 -0
- data/lib/active_admin/resource_controller.rb +32 -37
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +66 -40
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +9 -14
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/form.rb +1 -1
- data/lib/active_admin/resource_controller/menu.rb +1 -1
- data/lib/active_admin/resource_controller/page_configurations.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -21
- data/lib/active_admin/router.rb +85 -0
- data/lib/active_admin/sass/active_admin.scss +3 -0
- data/lib/active_admin/sass/css_loader.rb +16 -0
- data/lib/active_admin/sass/helpers.rb +45 -0
- data/lib/active_admin/scope.rb +16 -2
- data/lib/active_admin/sidebar_section.rb +41 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +5 -3
- data/lib/active_admin/view_helpers.rb +1 -2
- data/lib/active_admin/view_helpers/active_admin_application_helper.rb +12 -0
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/filter_form_helper.rb +26 -14
- data/lib/active_admin/view_helpers/form_helper.rb +1 -0
- data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
- data/lib/active_admin/views/components/attributes_table.rb +2 -2
- data/lib/active_admin/views/components/blank_slate.rb +17 -0
- data/lib/active_admin/views/components/columns.rb +1 -3
- data/lib/active_admin/views/components/paginated_collection.rb +26 -8
- data/lib/active_admin/views/components/scopes.rb +13 -8
- data/lib/active_admin/views/components/sidebar_section.rb +1 -3
- data/lib/active_admin/views/components/status_tag.rb +55 -0
- data/lib/active_admin/views/components/table_for.rb +25 -6
- data/lib/active_admin/views/header_renderer.rb +20 -4
- data/lib/active_admin/views/index_as_block.rb +12 -7
- data/lib/active_admin/views/index_as_blog.rb +61 -21
- data/lib/active_admin/views/index_as_grid.rb +22 -1
- data/lib/active_admin/views/index_as_table.rb +97 -6
- data/lib/active_admin/views/pages/base.rb +20 -9
- data/lib/active_admin/views/pages/dashboard.rb +7 -4
- data/lib/active_admin/views/pages/edit.rb +3 -2
- data/lib/active_admin/views/pages/index.rb +30 -5
- data/lib/active_admin/views/pages/layout.rb +26 -0
- data/lib/active_admin/views/pages/new.rb +3 -2
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/active_admin/views/tabbed_navigation.rb +94 -0
- data/lib/generators/active_admin/assets/assets_generator.rb +21 -0
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +427 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +6 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.js +1 -0
- data/lib/generators/active_admin/assets/templates/dashboards.rb +36 -0
- data/lib/generators/active_admin/install/install_generator.rb +2 -4
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +26 -4
- data/lib/generators/active_admin/install/templates/dashboards.rb +4 -2
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +2 -2
- data/script/local +44 -0
- data/script/use_rails +46 -0
- data/spec/integration/belongs_to_spec.rb +1 -1
- data/spec/integration/default_namespace.rb +77 -0
- data/spec/integration/javascript_spec.rb +20 -0
- data/spec/integration/stylesheets_spec.rb +41 -0
- data/spec/spec_helper.rb +21 -11
- data/spec/support/detect_rails_version.rb +10 -0
- data/spec/support/integration_example_group.rb +1 -1
- data/spec/support/jslint.yml +80 -0
- data/spec/support/rails_template.rb +1 -1
- data/spec/support/rails_template_with_data.rb +2 -1
- data/spec/support/templates/cucumber.rb +0 -4
- data/spec/unit/active_admin_spec.rb +8 -44
- data/spec/unit/application_spec.rb +78 -0
- data/spec/unit/arbre/context_spec.rb +22 -0
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +2 -2
- data/spec/unit/arbre/html/element_spec.rb +2 -3
- data/spec/unit/arbre/html/tag_attributes_spec.rb +2 -2
- data/spec/unit/arbre/html/tag_spec.rb +2 -2
- data/spec/unit/arbre/html_spec.rb +2 -3
- data/spec/unit/auto_link_spec.rb +2 -1
- data/spec/unit/belongs_to_spec.rb +2 -1
- data/spec/unit/comments_spec.rb +43 -39
- data/spec/unit/controller_filters_spec.rb +11 -3
- data/spec/unit/csv_builder_spec.rb +83 -0
- data/spec/unit/devise_spec.rb +66 -0
- data/spec/unit/display_name_spec.rb +2 -2
- data/spec/unit/filter_form_builder_spec.rb +6 -3
- data/spec/unit/form_builder_spec.rb +20 -2
- data/spec/unit/generators/install_rails_3_1_spec.rb +16 -0
- data/spec/unit/helpers/scope_chain_spec.rb +36 -0
- data/spec/unit/helpers/settings_spec.rb +30 -0
- data/spec/unit/menu_item_spec.rb +6 -0
- data/spec/unit/namespace_spec.rb +68 -19
- data/spec/unit/rails_spec.rb +43 -0
- data/spec/unit/registration_spec.rb +18 -27
- data/spec/unit/reloader_spec.rb +28 -0
- data/spec/unit/resource/action_items_spec.rb +62 -0
- data/spec/unit/resource/menu_spec.rb +80 -0
- data/spec/unit/resource/naming_spec.rb +64 -0
- data/spec/unit/resource/scopes_spec.rb +30 -0
- data/spec/unit/resource/sidebars_spec.rb +50 -0
- data/spec/unit/resource_controller/collection_spec.rb +1 -1
- data/spec/unit/resource_controller_spec.rb +29 -24
- data/spec/unit/resource_spec.rb +78 -94
- data/spec/unit/sass/helpers_spec.rb +47 -0
- data/spec/unit/scope_spec.rb +11 -1
- data/spec/unit/view_factory_spec.rb +4 -1
- data/spec/unit/{components → views/components}/attributes_table_spec.rb +2 -2
- data/spec/unit/views/components/blank_slate_spec.rb +15 -0
- data/spec/unit/{components → views/components}/columns_spec.rb +2 -2
- data/spec/unit/{components → views/components}/panel_spec.rb +1 -3
- data/spec/unit/{components → views/components}/sidebar_section_spec.rb +3 -3
- data/spec/unit/views/components/status_tag_spec.rb +79 -0
- data/spec/unit/{components → views/components}/table_for_spec.rb +2 -1
- data/spec/unit/views/pages/layout_spec.rb +22 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +125 -0
- data/tasks/docs.rake +39 -0
- data/tasks/test.rake +55 -0
- data/tasks/yard.rake +6 -0
- metadata +310 -189
- data/CHANGELOG.rdoc +0 -76
- data/lib/active_admin/action_items.rb +0 -37
- data/lib/active_admin/sidebar.rb +0 -39
- data/lib/active_admin/stylesheets/active_admin/_flash_messages.scss +0 -13
- data/lib/active_admin/view_helpers/status_tag_helper.rb +0 -13
- data/lib/active_admin/view_helpers/table_helper.rb +0 -12
- data/lib/active_admin/views/tabs_renderer.rb +0 -52
- data/lib/active_admin/views/templates/active_admin_default/index.csv.erb +0 -2
- data/lib/active_admin/views/templates/layouts/active_admin.html.erb +0 -39
- data/lib/generators/active_admin/install/templates/active_admin.js +0 -51
- data/spec/controllers/index_as_csv_spec.rb +0 -35
- data/spec/unit/action_items_spec.rb +0 -27
- data/spec/unit/tabs_renderer_spec.rb +0 -56
|
@@ -26,7 +26,7 @@ describe ActiveAdmin::ResourceController::Collection do
|
|
|
26
26
|
let(:params){ {:order => "id_asc" }}
|
|
27
27
|
it "should prepend the table name" do
|
|
28
28
|
chain = mock("ChainObj")
|
|
29
|
-
chain.should_receive(:order).with("posts.id asc").once.and_return(Post.search)
|
|
29
|
+
chain.should_receive(:order).with("\"posts\".id asc").once.and_return(Post.search)
|
|
30
30
|
controller.send :sort_order, chain
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -45,31 +45,36 @@ describe ActiveAdmin::ResourceController do
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
ActiveAdmin.register Post do
|
|
49
|
-
after_build :call_after_build
|
|
50
|
-
before_save :call_before_save
|
|
51
|
-
after_save :call_after_save
|
|
52
|
-
before_create :call_before_create
|
|
53
|
-
after_create :call_after_create
|
|
54
|
-
before_update :call_before_update
|
|
55
|
-
after_update :call_after_update
|
|
56
|
-
before_destroy :call_before_destroy
|
|
57
|
-
after_destroy :call_after_destroy
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class Admin::PostsController < ActiveAdmin::ResourceController
|
|
61
|
-
def call_after_build(obj); end
|
|
62
|
-
def call_before_save(obj); end
|
|
63
|
-
def call_after_save(obj); end
|
|
64
|
-
def call_before_create(obj); end
|
|
65
|
-
def call_after_create(obj); end
|
|
66
|
-
def call_before_update(obj); end
|
|
67
|
-
def call_after_update(obj); end
|
|
68
|
-
def call_before_destroy(obj); end
|
|
69
|
-
def call_after_destroy(obj); end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
48
|
describe "callbacks" do
|
|
49
|
+
let(:application){ ::ActiveAdmin::Application.new }
|
|
50
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
|
51
|
+
|
|
52
|
+
before :all do
|
|
53
|
+
namespace.register Post do
|
|
54
|
+
after_build :call_after_build
|
|
55
|
+
before_save :call_before_save
|
|
56
|
+
after_save :call_after_save
|
|
57
|
+
before_create :call_before_create
|
|
58
|
+
after_create :call_after_create
|
|
59
|
+
before_update :call_before_update
|
|
60
|
+
after_update :call_after_update
|
|
61
|
+
before_destroy :call_before_destroy
|
|
62
|
+
after_destroy :call_after_destroy
|
|
63
|
+
|
|
64
|
+
controller do
|
|
65
|
+
def call_after_build(obj); end
|
|
66
|
+
def call_before_save(obj); end
|
|
67
|
+
def call_after_save(obj); end
|
|
68
|
+
def call_before_create(obj); end
|
|
69
|
+
def call_after_create(obj); end
|
|
70
|
+
def call_before_update(obj); end
|
|
71
|
+
def call_after_update(obj); end
|
|
72
|
+
def call_before_destroy(obj); end
|
|
73
|
+
def call_after_destroy(obj); end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
73
78
|
describe "performing create" do
|
|
74
79
|
let(:controller){ Admin::PostsController.new }
|
|
75
80
|
let(:resource){ mock("Resource", :save => true) }
|
data/spec/unit/resource_spec.rb
CHANGED
|
@@ -5,58 +5,20 @@ module ActiveAdmin
|
|
|
5
5
|
|
|
6
6
|
before { load_defaults! }
|
|
7
7
|
|
|
8
|
-
let(:
|
|
8
|
+
let(:application){ ActiveAdmin::Application.new }
|
|
9
|
+
let(:namespace){ Namespace.new(application, :admin) }
|
|
9
10
|
|
|
10
11
|
def config(options = {})
|
|
11
12
|
@config ||= Resource.new(namespace, Category, options)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
describe "underscored resource name" do
|
|
15
|
-
context "when class" do
|
|
16
|
-
it "should be the underscored singular resource name" do
|
|
17
|
-
config.underscored_resource_name.should == "category"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
context "when a class in a module" do
|
|
21
|
-
it "should underscore the module and the class" do
|
|
22
|
-
module ::Mock; class Resource; end; end
|
|
23
|
-
Resource.new(namespace, Mock::Resource).underscored_resource_name.should == "mock_resource"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
context "when you pass the 'as' option" do
|
|
27
|
-
it "should underscore the passed through string and singulralize" do
|
|
28
|
-
config(:as => "Blog Categories").underscored_resource_name.should == "blog_category"
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe "camelized resource name" do
|
|
34
|
-
it "should return a camelized version of the underscored resource name" do
|
|
35
|
-
config(:as => "Blog Categories").camelized_resource_name.should == "BlogCategory"
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe "resource name" do
|
|
40
|
-
it "should return a pretty name" do
|
|
41
|
-
config.resource_name.should == "Category"
|
|
42
|
-
end
|
|
43
|
-
it "should return the plural version" do
|
|
44
|
-
config.plural_resource_name.should == "Categories"
|
|
45
|
-
end
|
|
46
|
-
context "when the :as option is given" do
|
|
47
|
-
it "should return the custom name" do
|
|
48
|
-
config(:as => "My Category").resource_name.should == "My Category"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
15
|
describe "#resource_table_name" do
|
|
54
16
|
it "should return the resource's table name" do
|
|
55
|
-
config.resource_table_name.should == 'categories'
|
|
17
|
+
config.resource_table_name.should == '"categories"'
|
|
56
18
|
end
|
|
57
19
|
context "when the :as option is given" do
|
|
58
20
|
it "should return the resource's table name" do
|
|
59
|
-
config(:as => "My Category").resource_table_name.should == 'categories'
|
|
21
|
+
config(:as => "My Category").resource_table_name.should == '"categories"'
|
|
60
22
|
end
|
|
61
23
|
end
|
|
62
24
|
end
|
|
@@ -72,7 +34,7 @@ module ActiveAdmin
|
|
|
72
34
|
config.controller_name.should == "Admin::CategoriesController"
|
|
73
35
|
end
|
|
74
36
|
context "when non namespaced controller" do
|
|
75
|
-
let(:namespace){ ActiveAdmin::Namespace.new(:root) }
|
|
37
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :root) }
|
|
76
38
|
it "should return a non namespaced controller name" do
|
|
77
39
|
config.controller_name.should == "CategoriesController"
|
|
78
40
|
end
|
|
@@ -80,7 +42,7 @@ module ActiveAdmin
|
|
|
80
42
|
end
|
|
81
43
|
|
|
82
44
|
describe "#include_in_menu?" do
|
|
83
|
-
let(:namespace){ ActiveAdmin::Namespace.new(:admin) }
|
|
45
|
+
let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) }
|
|
84
46
|
subject{ resource }
|
|
85
47
|
|
|
86
48
|
context "when regular resource" do
|
|
@@ -121,9 +83,30 @@ module ActiveAdmin
|
|
|
121
83
|
end.parent_menu_item_name.should == "Blog"
|
|
122
84
|
end
|
|
123
85
|
end
|
|
86
|
+
|
|
87
|
+
describe "menu item priority" do
|
|
88
|
+
it "should be 10 when not set" do
|
|
89
|
+
config.menu_item_priority.should == 10
|
|
90
|
+
end
|
|
91
|
+
it "should be settable" do
|
|
92
|
+
config.menu :priority => 2
|
|
93
|
+
config.menu_item_priority.should == 2
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "menu item display if" do
|
|
98
|
+
it "should be a proc always returning true if not set" do
|
|
99
|
+
config.menu_item_display_if.should be_instance_of(Proc)
|
|
100
|
+
config.menu_item_display_if.call.should == true
|
|
101
|
+
end
|
|
102
|
+
it "should be settable" do
|
|
103
|
+
config.menu :if => proc { false }
|
|
104
|
+
config.menu_item_display_if.call.should == false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
124
107
|
|
|
125
108
|
describe "route names" do
|
|
126
|
-
let(:config){
|
|
109
|
+
let(:config){ application.register Category }
|
|
127
110
|
it "should return the route prefix" do
|
|
128
111
|
config.route_prefix.should == "admin"
|
|
129
112
|
end
|
|
@@ -132,11 +115,20 @@ module ActiveAdmin
|
|
|
132
115
|
end
|
|
133
116
|
|
|
134
117
|
context "when in the root namespace" do
|
|
135
|
-
let(:config){
|
|
118
|
+
let(:config){ application.register Category, :namespace => false}
|
|
136
119
|
it "should have a nil route_prefix" do
|
|
137
120
|
config.route_prefix.should == nil
|
|
138
121
|
end
|
|
139
122
|
end
|
|
123
|
+
|
|
124
|
+
context "when registering a plural resource" do
|
|
125
|
+
class ::News; def self.has_many(*); end end
|
|
126
|
+
|
|
127
|
+
let(:config){ application.register News }
|
|
128
|
+
it "should return the plurali route with _index" do
|
|
129
|
+
config.route_collection_path.should == :admin_news_index_path
|
|
130
|
+
end
|
|
131
|
+
end
|
|
140
132
|
end
|
|
141
133
|
|
|
142
134
|
describe "page configs" do
|
|
@@ -152,43 +144,43 @@ module ActiveAdmin
|
|
|
152
144
|
end
|
|
153
145
|
|
|
154
146
|
describe "scoping" do
|
|
155
|
-
let(:controller){ Admin::CategoriesController.new }
|
|
156
|
-
let(:begin_of_association_chain){ controller.send(:begin_of_association_chain) }
|
|
157
|
-
|
|
158
147
|
context "when using a block" do
|
|
159
148
|
before do
|
|
160
|
-
|
|
149
|
+
@resource = application.register Category do
|
|
161
150
|
scope_to do
|
|
162
151
|
"scoped"
|
|
163
152
|
end
|
|
164
153
|
end
|
|
165
154
|
end
|
|
166
155
|
it "should call the proc for the begin of association chain" do
|
|
156
|
+
begin_of_association_chain = @resource.controller.new.send(:begin_of_association_chain)
|
|
167
157
|
begin_of_association_chain.should == "scoped"
|
|
168
158
|
end
|
|
169
159
|
end
|
|
170
160
|
|
|
171
161
|
context "when using a symbol" do
|
|
172
162
|
before do
|
|
173
|
-
|
|
163
|
+
@resource = application.register Category do
|
|
174
164
|
scope_to :current_user
|
|
175
165
|
end
|
|
176
166
|
end
|
|
177
167
|
it "should call the method for the begin of association chain" do
|
|
168
|
+
controller = @resource.controller.new
|
|
178
169
|
controller.should_receive(:current_user).and_return(true)
|
|
170
|
+
begin_of_association_chain = controller.send(:begin_of_association_chain)
|
|
179
171
|
begin_of_association_chain.should == true
|
|
180
172
|
end
|
|
181
173
|
end
|
|
182
174
|
|
|
183
175
|
context "when not using a block or symbol" do
|
|
184
176
|
before do
|
|
185
|
-
|
|
177
|
+
@resource = application.register Category do
|
|
186
178
|
scope_to "Some string"
|
|
187
179
|
end
|
|
188
180
|
end
|
|
189
181
|
it "should raise and exception" do
|
|
190
182
|
lambda {
|
|
191
|
-
begin_of_association_chain
|
|
183
|
+
@resource.controller.new.send(:begin_of_association_chain)
|
|
192
184
|
}.should raise_error(ArgumentError)
|
|
193
185
|
end
|
|
194
186
|
end
|
|
@@ -196,22 +188,22 @@ module ActiveAdmin
|
|
|
196
188
|
describe "getting the method for the association chain" do
|
|
197
189
|
context "when a simple registration" do
|
|
198
190
|
before do
|
|
199
|
-
|
|
191
|
+
@resource = application.register Category do
|
|
200
192
|
scope_to :current_user
|
|
201
193
|
end
|
|
202
194
|
end
|
|
203
195
|
it "should return the pluralized collection name" do
|
|
204
|
-
controller.send(:method_for_association_chain).should == :categories
|
|
196
|
+
@resource.controller.new.send(:method_for_association_chain).should == :categories
|
|
205
197
|
end
|
|
206
198
|
end
|
|
207
199
|
context "when passing in the method as an option" do
|
|
208
200
|
before do
|
|
209
|
-
|
|
201
|
+
@resource = application.register Category do
|
|
210
202
|
scope_to :current_user, :association_method => :blog_categories
|
|
211
203
|
end
|
|
212
204
|
end
|
|
213
205
|
it "should return the method from the option" do
|
|
214
|
-
controller.send(:method_for_association_chain).should == :blog_categories
|
|
206
|
+
@resource.controller.new.send(:method_for_association_chain).should == :blog_categories
|
|
215
207
|
end
|
|
216
208
|
end
|
|
217
209
|
end
|
|
@@ -219,20 +211,29 @@ module ActiveAdmin
|
|
|
219
211
|
|
|
220
212
|
|
|
221
213
|
describe "sort order" do
|
|
222
|
-
subject { resource_config.sort_order }
|
|
223
214
|
|
|
224
|
-
context "
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
215
|
+
context "when resource class responds to primary_key" do
|
|
216
|
+
it "should sort by primary key desc by default" do
|
|
217
|
+
mock_resource = mock
|
|
218
|
+
mock_resource.should_receive(:primary_key).and_return("pk")
|
|
219
|
+
config = Resource.new(namespace, mock_resource)
|
|
220
|
+
config.sort_order.should == "pk_desc"
|
|
221
|
+
end
|
|
228
222
|
end
|
|
229
223
|
|
|
230
|
-
context "when
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
context "when resource class does not respond to primary_key" do
|
|
225
|
+
it "should default to id" do
|
|
226
|
+
mock_resource = mock
|
|
227
|
+
config = Resource.new(namespace, mock_resource)
|
|
228
|
+
config.sort_order.should == "id_desc"
|
|
229
|
+
end
|
|
230
|
+
end
|
|
233
231
|
|
|
234
|
-
|
|
232
|
+
it "should be set-able" do
|
|
233
|
+
config.sort_order = "task_id_desc"
|
|
234
|
+
config.sort_order.should == "task_id_desc"
|
|
235
235
|
end
|
|
236
|
+
|
|
236
237
|
end
|
|
237
238
|
|
|
238
239
|
describe "adding a scope" do
|
|
@@ -248,36 +249,19 @@ module ActiveAdmin
|
|
|
248
249
|
config.get_scope_by_id(:published).name.should == "Published"
|
|
249
250
|
end
|
|
250
251
|
end
|
|
251
|
-
|
|
252
|
-
describe "
|
|
253
|
-
context "when
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
ActiveAdmin.admin_notes = true
|
|
257
|
-
end
|
|
258
|
-
it "should default to true" do
|
|
259
|
-
config.admin_notes?.should be_true
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
context "when global is false" do
|
|
263
|
-
before(:each) do
|
|
264
|
-
ActiveAdmin.admin_notes = false
|
|
265
|
-
end
|
|
266
|
-
it "should default to false" do
|
|
267
|
-
config.admin_notes?.should be_false
|
|
268
|
-
end
|
|
252
|
+
|
|
253
|
+
describe "#csv_builder" do
|
|
254
|
+
context "when no csv builder set" do
|
|
255
|
+
it "should return a default column builder with id and content columns" do
|
|
256
|
+
config.csv_builder.columns.size.should == Category.content_columns.size + 1
|
|
269
257
|
end
|
|
270
258
|
end
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
config.
|
|
276
|
-
|
|
277
|
-
it "should be set to the local value false" do
|
|
278
|
-
ActiveAdmin.admin_notes = true
|
|
279
|
-
config.admin_notes = false
|
|
280
|
-
config.admin_notes?.should be_false
|
|
259
|
+
|
|
260
|
+
context "when csv builder set" do
|
|
261
|
+
it "shuld return the csv_builder we set" do
|
|
262
|
+
csv_builder = CSVBuilder.new
|
|
263
|
+
config.csv_builder = csv_builder
|
|
264
|
+
config.csv_builder.should == csv_builder
|
|
281
265
|
end
|
|
282
266
|
end
|
|
283
267
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ActiveAdmin::Sass::Helpers do
|
|
4
|
+
|
|
5
|
+
include ActiveAdmin::Sass::Helpers
|
|
6
|
+
|
|
7
|
+
context "when not using the asset pipeline" do
|
|
8
|
+
|
|
9
|
+
before(:all)do
|
|
10
|
+
@actual_rails_version = Rails::VERSION::MINOR
|
|
11
|
+
silence_warnings { Rails::VERSION::MINOR = 0 }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
after(:all) do
|
|
15
|
+
silence_warnings { Rails::VERSION::MINOR = @actual_rails_version }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should generate an image asset path to /images/active_admin" do
|
|
19
|
+
active_admin_image_path(Sass::Script::String.new('test.jpg')).should ==
|
|
20
|
+
Sass::Script::String.new("/images/active_admin/test.jpg", true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "when using the asset pipeline" do
|
|
26
|
+
before(:all)do
|
|
27
|
+
@actual_rails_version = Rails::VERSION::MINOR
|
|
28
|
+
silence_warnings { Rails::VERSION::MINOR = 1 }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
after(:all) do
|
|
32
|
+
silence_warnings { Rails::VERSION::MINOR = @actual_rails_version }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
assets = mock(:enabled => true)
|
|
37
|
+
Rails.application.config.stub!(:assets => assets)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should call the sass-rails asset helper" do
|
|
41
|
+
self.should_receive(:asset_path).with(Sass::Script::String.new("active_admin/test.jpg"), Sass::Script::String.new('image'))
|
|
42
|
+
active_admin_image_path(::Sass::Script::String.new('test.jpg'))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/spec/unit/scope_spec.rb
CHANGED
|
@@ -12,6 +12,16 @@ describe ActiveAdmin::Scope do
|
|
|
12
12
|
its(:scope_method) { should == :published }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
context "when scope method is :all" do
|
|
16
|
+
let(:scope) { ActiveAdmin::Scope.new :all }
|
|
17
|
+
its(:name) { should == "All"}
|
|
18
|
+
its(:id) { should == "all"}
|
|
19
|
+
# :all does not return a chain but an array of active record
|
|
20
|
+
# instances. We set the scope_method to nil then.
|
|
21
|
+
its(:scope_method) { should == nil }
|
|
22
|
+
its(:scope_block) { should == nil }
|
|
23
|
+
end
|
|
24
|
+
|
|
15
25
|
context "when a name and scope method" do
|
|
16
26
|
let(:scope) { ActiveAdmin::Scope.new "My Scope", :scope_method }
|
|
17
27
|
its(:name) { should == "My Scope"}
|
|
@@ -26,6 +36,6 @@ describe ActiveAdmin::Scope do
|
|
|
26
36
|
its(:scope_method) { should == nil }
|
|
27
37
|
its(:scope_block) { should be_a(Proc)}
|
|
28
38
|
end
|
|
29
|
-
end
|
|
39
|
+
end # describe "creating a scope"
|
|
30
40
|
|
|
31
41
|
end
|
|
@@ -8,9 +8,12 @@ end
|
|
|
8
8
|
|
|
9
9
|
describe ActiveAdmin::ViewFactory do
|
|
10
10
|
|
|
11
|
-
it_should_have_view :global_navigation, ActiveAdmin::Views::
|
|
11
|
+
it_should_have_view :global_navigation, ActiveAdmin::Views::TabbedNavigation
|
|
12
12
|
it_should_have_view :action_items, ActiveAdmin::Views::ActionItems
|
|
13
13
|
it_should_have_view :header, ActiveAdmin::Views::HeaderRenderer
|
|
14
|
+
it_should_have_view :blank_slate, ActiveAdmin::Views::BlankSlate
|
|
15
|
+
|
|
14
16
|
it_should_have_view :dashboard_page, ActiveAdmin::Views::Pages::Dashboard
|
|
17
|
+
it_should_have_view :layout, ActiveAdmin::Views::Pages::Layout
|
|
15
18
|
|
|
16
19
|
end
|