typus 0.9.39 → 1.0.0.pre
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/CHANGELOG +104 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +96 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +45 -0
- data/Rakefile +19 -48
- data/app/controllers/admin/account_controller.rb +54 -0
- data/app/controllers/admin/dashboard_controller.rb +7 -0
- data/app/controllers/admin/resource_controller.rb +8 -0
- data/app/controllers/admin/resources_controller.rb +307 -0
- data/app/controllers/admin/session_controller.rb +38 -0
- data/app/controllers/admin_controller.rb +26 -0
- data/app/helpers/admin/dashboard_helper.rb +38 -0
- data/app/helpers/admin/filters_helper.rb +81 -0
- data/app/helpers/admin/form_helper.rb +68 -261
- data/app/helpers/admin/preview_helper.rb +48 -0
- data/app/helpers/admin/relationships_helper.rb +192 -0
- data/app/helpers/admin/resources_helper.rb +80 -0
- data/app/helpers/admin/search_helper.rb +19 -0
- data/app/helpers/admin/sidebar_helper.rb +32 -210
- data/app/helpers/admin/table_helper.rb +207 -200
- data/app/helpers/admin_helper.rb +56 -0
- data/app/mailers/admin/mailer.rb +13 -0
- data/app/models/admin/fake_user.rb +38 -0
- data/app/views/admin/account/forgot_password.html.erb +21 -0
- data/app/views/admin/account/new.html.erb +21 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +3 -3
- data/app/views/admin/dashboard/show.html.erb +16 -0
- data/app/views/admin/dashboard/styles.html.erb +154 -0
- data/app/views/admin/helpers/_apps.html.erb +6 -0
- data/app/views/admin/helpers/_flash_message.html.erb +3 -0
- data/app/views/admin/helpers/_header.html.erb +7 -0
- data/app/views/admin/helpers/_login_info.html.erb +4 -0
- data/app/views/admin/helpers/_preview.html.erb +13 -0
- data/app/views/admin/helpers/dashboard/_applications.html.erb +32 -0
- data/app/views/admin/helpers/dashboard/_resources.html.erb +16 -0
- data/app/views/admin/helpers/filters/_filters.html.erb +31 -0
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +3 -0
- data/app/views/admin/helpers/resources/_pagination.html.erb +28 -0
- data/app/views/admin/helpers/search/_search.html.erb +12 -0
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +17 -0
- data/app/views/admin/helpers/table/_table.html.erb +22 -0
- data/app/views/{typus_mailer/reset_password_link.erb → admin/mailer/reset_password_link.text.erb} +2 -2
- data/{test/config/broken/empty.yml → app/views/admin/resources/_edit.html.erb} +0 -0
- data/app/views/admin/resources/_form.html.erb +26 -0
- data/{test/config/broken/empty_roles.yml → app/views/admin/resources/_index.html.erb} +0 -0
- data/{test/config/empty/empty_01.yml → app/views/admin/resources/_new.html.erb} +0 -0
- data/{test/config/empty/empty_01_roles.yml → app/views/admin/resources/_show.html.erb} +0 -0
- data/app/views/admin/resources/edit.html.erb +23 -21
- data/app/views/admin/resources/index.html.erb +31 -18
- data/app/views/admin/resources/new.html.erb +20 -18
- data/app/views/admin/resources/show.html.erb +29 -20
- data/app/views/admin/session/new.html.erb +26 -0
- data/app/views/admin/templates/_belongs_to.html.erb +4 -0
- data/app/views/admin/templates/_boolean.html.erb +4 -8
- data/app/views/admin/templates/_date.html.erb +9 -2
- data/app/views/admin/templates/_datetime.html.erb +9 -2
- data/app/views/admin/templates/_file.html.erb +20 -5
- data/app/views/admin/templates/_has_many.html.erb +24 -0
- data/app/views/admin/templates/_has_n.html.erb +17 -0
- data/{test/config/empty/empty_02.yml → app/views/admin/templates/_has_one.html.erb} +0 -0
- data/app/views/admin/templates/_password.html.erb +4 -2
- data/app/views/admin/templates/_relate_form.html.erb +4 -0
- data/app/views/admin/templates/_selector.html.erb +6 -18
- data/app/views/admin/templates/_string.html.erb +11 -10
- data/app/views/admin/templates/_text.html.erb +9 -2
- data/app/views/admin/templates/_time.html.erb +9 -2
- data/app/views/admin/templates/_tree.html.erb +4 -0
- data/app/views/layouts/admin/session.html.erb +44 -0
- data/app/views/layouts/admin.html.erb +45 -39
- data/config/available_locales/ca.yml +124 -0
- data/config/available_locales/ca_models.yml +16 -0
- data/config/{locales → available_locales}/de.yml +108 -89
- data/config/available_locales/de_models.yml +13 -0
- data/config/available_locales/es.yml +124 -0
- data/config/available_locales/es_models.yml +13 -0
- data/config/available_locales/fr.yml +124 -0
- data/config/available_locales/fr_models.yml +13 -0
- data/config/available_locales/hu.yml +124 -0
- data/config/available_locales/hu_models.yml +13 -0
- data/config/available_locales/it.yml +136 -0
- data/config/available_locales/it_models.yml +15 -0
- data/config/available_locales/language.yml.template +122 -0
- data/config/available_locales/language_models.yml.template +13 -0
- data/config/{locales → available_locales}/pt-BR.yml +97 -74
- data/config/available_locales/pt-BR_models.yml +13 -0
- data/config/{locales → available_locales}/ru.yml +107 -85
- data/config/available_locales/ru_models.yml +13 -0
- data/config/routes.rb +18 -11
- data/lib/generators/templates/config/initializers/typus.rb +26 -0
- data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
- data/lib/generators/templates/config/initializers/typus_resources.rb +30 -0
- data/{generators/typus → lib/generators}/templates/config/typus/README +34 -16
- data/lib/generators/templates/config/typus/application.yml +5 -0
- data/lib/generators/templates/config/typus/application_roles.yml +6 -0
- data/lib/generators/templates/config/typus/typus.yml +17 -0
- data/lib/generators/templates/config/typus/typus_roles.yml +6 -0
- data/lib/generators/templates/controller.rb +4 -0
- data/lib/generators/templates/functional_test.rb +21 -0
- data/{generators/typus/templates/db/create_typus_users.rb → lib/generators/templates/migration.rb} +4 -4
- data/lib/generators/templates/model.rb +8 -0
- data/lib/generators/templates/model.yml +10 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/images}/ui-icons.png +0 -0
- data/lib/generators/templates/public/admin/javascripts/application.js +6 -0
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +126 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.searchField.js +91 -0
- data/lib/generators/templates/public/admin/stylesheets/application.css +11 -0
- data/lib/generators/templates/public/admin/stylesheets/screen.css +356 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/blank.gif +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_close.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_e.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_n.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_ne.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_nw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_s.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_se.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_sw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_w.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_main.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_over.png +0 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/vendor}/fancybox/fancy_title_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-x.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-y.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +72 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +1077 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
- data/lib/generators/templates/view.html.erb +9 -0
- data/lib/generators/typus/migration_generator.rb +85 -0
- data/lib/generators/typus/typus_generator.rb +190 -0
- data/lib/generators/typus/views_generator.rb +27 -0
- data/lib/support/active_record.rb +60 -0
- data/lib/support/array.rb +13 -0
- data/lib/{typus → support}/hash.rb +2 -2
- data/lib/{typus → support}/object.rb +2 -2
- data/lib/support/string.rb +47 -0
- data/lib/tasks/typus.rake +19 -0
- data/lib/typus/authentication.rb +146 -40
- data/lib/typus/configuration.rb +14 -49
- data/lib/typus/engine.rb +6 -0
- data/lib/typus/format.rb +41 -18
- data/lib/typus/orm/active_record.rb +378 -0
- data/lib/typus/resources.rb +57 -0
- data/lib/typus/user.rb +54 -37
- data/lib/typus/version.rb +3 -0
- data/lib/typus.rb +118 -80
- data/lib/vendor/paginator.rb +2 -2
- data/test/factories/assets.rb +5 -0
- data/test/factories/categories.rb +3 -0
- data/test/factories/comments.rb +6 -0
- data/test/factories/pages.rb +5 -0
- data/test/factories/pictures.rb +7 -0
- data/test/factories/posts.rb +6 -0
- data/test/factories/typus_users.rb +8 -0
- data/test/{config → fixtures/config}/broken/application.yml +0 -0
- data/test/{config → fixtures/config}/broken/application_roles.yml +0 -0
- data/test/{config/empty/empty_02_roles.yml → fixtures/config/broken/empty.yml} +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined_roles.yml +0 -0
- data/test/{config → fixtures/config}/default/typus.yml +2 -1
- data/{generators/typus/templates/config/typus → test/fixtures/config/default}/typus_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/{config → fixtures/config}/locales/es.yml +0 -0
- data/test/fixtures/config/namespaced/application.yml +5 -0
- data/test/fixtures/config/namespaced/application_roles.yml +2 -0
- data/test/{config → fixtures/config}/ordered/001_roles.yml +0 -0
- data/test/{config → fixtures/config}/ordered/002_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_one_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_two_roles.yml +0 -0
- data/test/fixtures/config/working/application.yml +73 -0
- data/test/fixtures/config/working/application_roles.yml +24 -0
- data/{generators/typus/templates/config/typus → test/fixtures/config/working}/typus.yml +2 -1
- data/test/{config/default → fixtures/config/working}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/README +244 -0
- data/test/fixtures/rails_app/Rakefile +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +4 -0
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/{app → rails_app/app}/models/asset.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/category.rb +2 -2
- data/test/fixtures/{app → rails_app/app}/models/comment.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/custom_user.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/delayed/task.rb +2 -2
- data/test/fixtures/rails_app/app/models/page.rb +9 -0
- data/test/fixtures/rails_app/app/models/picture.rb +6 -0
- data/test/fixtures/{app → rails_app/app}/models/post.rb +6 -6
- data/test/fixtures/rails_app/app/models/typus_user.rb +8 -0
- data/test/fixtures/{app → rails_app/app}/models/view.rb +1 -1
- data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +6 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/fixtures/rails_app/config/application.rb +50 -0
- data/test/fixtures/rails_app/config/boot.rb +13 -0
- data/test/fixtures/rails_app/config/database.yml +22 -0
- data/test/fixtures/rails_app/config/environment.rb +5 -0
- data/test/fixtures/rails_app/config/environments/development.rb +19 -0
- data/test/fixtures/rails_app/config/environments/production.rb +42 -0
- data/test/fixtures/rails_app/config/environments/test.rb +34 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +258 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +98 -0
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/inflections.rb +10 -0
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
- data/test/fixtures/rails_app/config/initializers/typus.rb +6 -0
- data/test/fixtures/rails_app/config/locales/en.yml +5 -0
- data/test/fixtures/rails_app/config/routes.rb +8 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/application.yml +11 -9
- data/test/{config/working → fixtures/rails_app/config/typus}/application_roles.yml +0 -0
- data/{generators/typus_update_schema_to_01/templates/config → test/fixtures/rails_app/config/typus}/typus.yml +0 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/config.ru +4 -0
- data/test/fixtures/rails_app/db/seeds.rb +7 -0
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/log/test.log +4268 -0
- data/test/fixtures/rails_app/public/404.html +26 -0
- data/test/fixtures/rails_app/public/422.html +26 -0
- data/test/fixtures/rails_app/public/500.html +26 -0
- data/test/fixtures/rails_app/public/favicon.ico +0 -0
- data/test/fixtures/rails_app/public/images/rails.png +0 -0
- data/test/fixtures/rails_app/public/index.html +279 -0
- data/test/fixtures/rails_app/public/javascripts/application.js +2 -0
- data/test/fixtures/rails_app/public/javascripts/controls.js +965 -0
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/fixtures/rails_app/public/javascripts/effects.js +1123 -0
- data/test/fixtures/rails_app/public/javascripts/prototype.js +4874 -0
- data/test/fixtures/rails_app/public/javascripts/rails.js +118 -0
- data/test/fixtures/rails_app/public/robots.txt +5 -0
- data/test/fixtures/rails_app/script/rails +9 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120447.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120700.csv +2 -0
- data/test/functional/admin/account_controller_test.rb +90 -0
- data/test/functional/admin/dashboard_controller_http_basic_test.rb +24 -0
- data/test/functional/admin/dashboard_controller_none_test.rb +18 -0
- data/test/functional/admin/dashboard_controller_test.rb +106 -0
- data/test/functional/admin/resources_controller_assets_relationships.rb +59 -0
- data/test/functional/admin/resources_controller_categories_before_test.rb +10 -0
- data/test/functional/admin/resources_controller_categories_lists_test.rb +44 -0
- data/test/functional/admin/resources_controller_categories_views_test.rb +10 -0
- data/test/functional/admin/resources_controller_comments_toggle_test.rb +21 -0
- data/test/functional/admin/{master_controller_posts_before_test.rb → resources_controller_posts_before_test.rb} +3 -3
- data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +27 -0
- data/test/functional/admin/resources_controller_posts_crud_test.rb +44 -0
- data/test/functional/admin/resources_controller_posts_formats_test.rb +39 -0
- data/test/functional/admin/resources_controller_posts_forms_test.rb +58 -0
- data/test/functional/admin/resources_controller_posts_permissions_test.rb +100 -0
- data/test/functional/admin/{master_controller_posts_relationships_test.rb → resources_controller_posts_relationships_test.rb} +25 -20
- data/test/functional/admin/resources_controller_posts_roles.rb +52 -0
- data/test/functional/admin/resources_controller_posts_views_test.rb +143 -0
- data/test/functional/admin/resources_controller_tableless_resource_test.rb +51 -0
- data/test/functional/admin/resources_controller_typus_users_test.rb +159 -0
- data/test/functional/admin/session_controller_test.rb +85 -0
- data/test/helpers/admin/dashboard_helper_test.rb +42 -0
- data/test/helpers/admin/form_helper_test.rb +52 -276
- data/test/helpers/admin/resources_helper_test.rb +52 -0
- data/test/helpers/admin/sidebar_helper_test.rb +133 -224
- data/test/helpers/admin/table_helper_test.rb +136 -144
- data/test/helpers/admin_helper_test.rb +69 -0
- data/test/lib/support/active_record_test.rb +35 -0
- data/test/lib/support/array_test.rb +15 -0
- data/test/lib/support/hash_test.rb +11 -0
- data/test/lib/support/string_test.rb +48 -0
- data/test/lib/typus/active_record_test.rb +385 -0
- data/test/lib/typus/configuration_test.rb +52 -0
- data/test/lib/typus/resource_test.rb +17 -0
- data/test/lib/typus/routes_test.rb +29 -0
- data/test/lib/typus_test.rb +72 -40
- data/test/{vendor → lib/vendor}/paginator_test.rb +7 -4
- data/test/schema.rb +28 -3
- data/test/test_helper.rb +29 -0
- data/test/unit/admin/mailer_test.rb +32 -0
- data/test/unit/typus_user_roles_test.rb +69 -61
- data/test/unit/typus_user_test.rb +56 -143
- data/typus.gemspec +18 -276
- metadata +305 -231
- data/.gitignore +0 -1
- data/AUTHORS.md +0 -34
- data/CHANGES +0 -3
- data/README.md +0 -75
- data/VERSION +0 -1
- data/app/controllers/admin/master_controller.rb +0 -394
- data/app/controllers/typus_controller.rb +0 -152
- data/app/helpers/admin/master_helper.rb +0 -104
- data/app/helpers/admin/public_helper.rb +0 -27
- data/app/helpers/typus_helper.rb +0 -181
- data/app/models/typus_mailer.rb +0 -14
- data/app/models/typus_user.rb +0 -5
- data/app/views/admin/shared/_feedback.html.erb +0 -6
- data/app/views/admin/shared/_footer.html.erb +0 -2
- data/app/views/admin/shared/_pagination.html.erb +0 -28
- data/app/views/admin/templates/_tiny_mce.html.erb +0 -2
- data/app/views/layouts/typus.html.erb +0 -29
- data/app/views/typus/dashboard.html.erb +0 -9
- data/app/views/typus/recover_password.html.erb +0 -7
- data/app/views/typus/reset_password.html.erb +0 -15
- data/app/views/typus/sign_in.html.erb +0 -9
- data/app/views/typus/sign_up.html.erb +0 -7
- data/config/locales/es.yml +0 -105
- data/config/locales/fr.yml +0 -98
- data/config/locales/language.yml.template +0 -106
- data/generators/typus/templates/auto/index.html.erb +0 -11
- data/generators/typus/templates/auto/resource_controller.rb.erb +0 -15
- data/generators/typus/templates/auto/resource_controller_test.rb.erb +0 -11
- data/generators/typus/templates/auto/resources_controller.rb.erb +0 -37
- data/generators/typus/templates/config/initializers/typus.rb +0 -34
- data/generators/typus/templates/config/typus/application.yml +0 -6
- data/generators/typus/templates/config/typus/application_roles.yml +0 -23
- data/generators/typus/templates/lib/tasks/typus_tasks.rake +0 -32
- data/generators/typus/templates/public/images/admin/fancybox/fancy_closebox.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_progress.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_right.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_e.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_n.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_s.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_se.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_w.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_main.png +0 -0
- data/generators/typus/templates/public/javascripts/admin/application.js +0 -14
- data/generators/typus/templates/public/javascripts/admin/jquery-1.3.2.min.js +0 -19
- data/generators/typus/templates/public/javascripts/admin/jquery.fancybox-1.2.1.min.js +0 -9
- data/generators/typus/templates/public/stylesheets/admin/jquery.fancybox.css +0 -315
- data/generators/typus/templates/public/stylesheets/admin/reset.css +0 -68
- data/generators/typus/templates/public/stylesheets/admin/screen.css +0 -361
- data/generators/typus/typus_generator.rb +0 -191
- data/generators/typus_update_schema_to_01/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb +0 -19
- data/generators/typus_update_schema_to_02/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb +0 -11
- data/lib/typus/active_record.rb +0 -323
- data/lib/typus/extensions/routes.rb +0 -15
- data/lib/typus/extensions/routes_hack.rb +0 -15
- data/lib/typus/preferences.rb +0 -11
- data/lib/typus/preview.rb +0 -76
- data/lib/typus/quick_edit.rb +0 -40
- data/lib/typus/reloader.rb +0 -14
- data/lib/typus/string.rb +0 -27
- data/lib/vendor/active_record.rb +0 -15
- data/lib/vendor/rss_parser.rb +0 -20
- data/rails/init.rb +0 -3
- data/tasks/typus_tasks.rake +0 -32
- data/test/config/working/typus.yml +0 -12
- data/test/fixtures/app/controllers/admin/assets_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/categories_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/comments_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/pages_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/posts_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/status_controller.rb +0 -6
- data/test/fixtures/app/controllers/admin/typus_users_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/watch_dog_controller.rb +0 -6
- data/test/fixtures/app/models/page.rb +0 -5
- data/test/fixtures/app/views/admin/dashboard/_content.html.erb +0 -1
- data/test/fixtures/app/views/admin/dashboard/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_edit.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_index.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_new.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_show.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/resources/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/shared/_footer.html.erb +0 -1
- data/test/fixtures/app/views/admin/status/index.html.erb +0 -1
- data/test/fixtures/app/views/admin/templates/_datepicker.html.erb +0 -1
- data/test/fixtures/assets.yml +0 -11
- data/test/fixtures/categories.yml +0 -14
- data/test/fixtures/comments.yml +0 -27
- data/test/fixtures/pages.yml +0 -41
- data/test/fixtures/posts.yml +0 -37
- data/test/fixtures/typus_users.yml +0 -59
- data/test/functional/admin/master_controller_assets_relationships.rb +0 -66
- data/test/functional/admin/master_controller_categories_lists_test.rb +0 -64
- data/test/functional/admin/master_controller_posts_crud_test.rb +0 -97
- data/test/functional/admin/master_controller_posts_formats_test.rb +0 -53
- data/test/functional/admin/master_controller_posts_permissions_test.rb +0 -127
- data/test/functional/admin/master_controller_posts_roles.rb +0 -50
- data/test/functional/admin/master_controller_posts_toggle_test.rb +0 -35
- data/test/functional/admin/master_controller_posts_views_test.rb +0 -209
- data/test/functional/admin/master_controller_tableless_resource_test.rb +0 -36
- data/test/functional/admin/master_controller_typus_users_test.rb +0 -211
- data/test/functional/typus_controller_test.rb +0 -342
- data/test/helper.rb +0 -51
- data/test/helpers/admin/master_helper_test.rb +0 -70
- data/test/helpers/admin/public_helper_test.rb +0 -26
- data/test/helpers/typus_helper_test.rb +0 -96
- data/test/lib/active_record_test.rb +0 -377
- data/test/lib/configuration_test.rb +0 -95
- data/test/lib/hash_test.rb +0 -11
- data/test/lib/routes_test.rb +0 -71
- data/test/lib/string_test.rb +0 -55
- data/test/unit/typus_mailer_test.rb +0 -29
- data/test/unit/typus_test.rb +0 -17
- data/test/vendor/active_record_test.rb +0 -18
|
@@ -1,73 +1,38 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "test_helper"
|
|
4
4
|
|
|
5
5
|
class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
6
6
|
|
|
7
7
|
include Admin::SidebarHelper
|
|
8
8
|
|
|
9
9
|
include ActionView::Helpers::UrlHelper
|
|
10
|
-
include ActionController::UrlWriter
|
|
11
10
|
include ActionView::Helpers::TagHelper
|
|
12
11
|
include ActionView::Helpers::FormTagHelper
|
|
13
12
|
|
|
14
|
-
def
|
|
13
|
+
def render(*args); args; end
|
|
14
|
+
|
|
15
|
+
setup do
|
|
15
16
|
default_url_options[:host] = 'test.host'
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
def test_actions
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
self.expects(:default_actions).returns(['action1', 'action2'])
|
|
24
|
-
self.expects(:previous_and_next).returns(['previous', 'next'])
|
|
25
|
-
self.expects(:export).returns(['csv', 'pdf'])
|
|
26
|
-
|
|
27
|
-
output = actions
|
|
28
|
-
expected = <<-HTML
|
|
29
|
-
<h2>Actions</h2>
|
|
30
|
-
<ul>
|
|
31
|
-
<li>action1</li>
|
|
32
|
-
<li>action2</li>
|
|
33
|
-
</ul>
|
|
34
|
-
|
|
35
|
-
<h2>Go to</h2>
|
|
36
|
-
<ul>
|
|
37
|
-
<li>previous</li>
|
|
38
|
-
<li>next</li>
|
|
39
|
-
</ul>
|
|
40
|
-
|
|
41
|
-
<h2>Export</h2>
|
|
42
|
-
<ul>
|
|
43
|
-
<li>csv</li>
|
|
44
|
-
<li>pdf</li>
|
|
45
|
-
</ul>
|
|
46
|
-
|
|
47
|
-
HTML
|
|
48
|
-
|
|
49
|
-
assert_equal expected, output
|
|
19
|
+
=begin
|
|
50
20
|
|
|
21
|
+
def test_actions
|
|
51
22
|
end
|
|
52
23
|
|
|
53
24
|
def test_export
|
|
54
|
-
|
|
55
|
-
@resource = { :class => Post }
|
|
25
|
+
@resource = Post
|
|
56
26
|
|
|
57
27
|
params = { :controller => 'admin/posts', :action => 'index' }
|
|
58
28
|
self.expects(:params).at_least_once.returns(params)
|
|
59
|
-
|
|
60
29
|
output = export
|
|
61
|
-
expected =
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<li><a href=\"http://test.host/admin/posts?format=xml\">XML</a></li>
|
|
66
|
-
</ul>
|
|
67
|
-
HTML
|
|
30
|
+
expected = [ "admin/helpers/list", { :items => [ %(<a href="http://test.host/admin/posts?format=csv">CSV</a>),
|
|
31
|
+
%(<a href="http://test.host/admin/posts?format=xml">XML</a>) ],
|
|
32
|
+
:header => "Export",
|
|
33
|
+
:options => { :header => "export" } } ]
|
|
68
34
|
|
|
69
35
|
assert_equal expected, output
|
|
70
|
-
|
|
71
36
|
end
|
|
72
37
|
|
|
73
38
|
def test_build_typus_list_with_empty_content_and_empty_header
|
|
@@ -78,190 +43,107 @@ HTML
|
|
|
78
43
|
def test_build_typus_list_with_content_and_header
|
|
79
44
|
output = build_typus_list(['item1', 'item2'], :header => "Chunky Bacon")
|
|
80
45
|
assert !output.empty?
|
|
81
|
-
assert_match /Chunky bacon/, output
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_build_typus_list_with_content_without_header
|
|
85
|
-
output = build_typus_list(['item1', 'item2'])
|
|
86
|
-
assert !output.empty?
|
|
87
|
-
assert_no_match /h2/, output
|
|
88
|
-
assert_no_match /\/h2/, output
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def test_previous_and_next_when_edit
|
|
92
|
-
|
|
93
|
-
@resource = { :class => TypusUser }
|
|
94
|
-
@current_user = typus_users(:admin)
|
|
95
|
-
|
|
96
|
-
# Test when there are no records.
|
|
97
46
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
params = { :controller => 'admin/typus_users', :action => 'edit', :id => typus_user.id }
|
|
102
|
-
self.expects(:params).at_least_once.returns(params)
|
|
103
|
-
|
|
104
|
-
assert previous_and_next.empty?
|
|
105
|
-
|
|
106
|
-
# Test when we are on the first item.
|
|
107
|
-
|
|
108
|
-
typus_user = TypusUser.first
|
|
109
|
-
@previous, @next = typus_user.previous_and_next
|
|
110
|
-
|
|
111
|
-
expected = <<-HTML
|
|
112
|
-
<h2>Go to</h2>
|
|
113
|
-
<ul>
|
|
114
|
-
<li><a href="http://test.host/admin/typus_users/edit/2">Next</a></li>
|
|
115
|
-
</ul>
|
|
116
|
-
HTML
|
|
117
|
-
assert_equal expected, previous_and_next
|
|
118
|
-
|
|
119
|
-
# Test when we are on the last item.
|
|
120
|
-
|
|
121
|
-
typus_user = TypusUser.last
|
|
122
|
-
@previous, @next = typus_user.previous_and_next
|
|
123
|
-
|
|
124
|
-
expected = <<-HTML
|
|
125
|
-
<h2>Go to</h2>
|
|
126
|
-
<ul>
|
|
127
|
-
<li><a href="http://test.host/admin/typus_users/edit/4">Previous</a></li>
|
|
128
|
-
</ul>
|
|
129
|
-
HTML
|
|
130
|
-
|
|
131
|
-
assert_equal expected, previous_and_next
|
|
132
|
-
|
|
133
|
-
# Test when we are on the middle.
|
|
134
|
-
|
|
135
|
-
typus_user = TypusUser.find(3)
|
|
136
|
-
@previous, @next = typus_user.previous_and_next
|
|
137
|
-
|
|
138
|
-
expected = <<-HTML
|
|
139
|
-
<h2>Go to</h2>
|
|
140
|
-
<ul>
|
|
141
|
-
<li><a href="http://test.host/admin/typus_users/edit/4">Next</a></li>
|
|
142
|
-
<li><a href="http://test.host/admin/typus_users/edit/2">Previous</a></li>
|
|
143
|
-
</ul>
|
|
144
|
-
HTML
|
|
145
|
-
assert_equal expected, previous_and_next
|
|
146
|
-
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def test_previous_and_next_when_show
|
|
150
|
-
|
|
151
|
-
@resource = { :class => TypusUser }
|
|
152
|
-
@current_user = typus_users(:admin)
|
|
153
|
-
|
|
154
|
-
typus_user = TypusUser.find(3)
|
|
155
|
-
params = { :controller => 'admin/typus_users', :action => 'show', :id => typus_user.id }
|
|
156
|
-
self.expects(:params).at_least_once.returns(params)
|
|
157
|
-
|
|
158
|
-
@previous, @next = typus_user.previous_and_next
|
|
159
|
-
|
|
160
|
-
output = previous_and_next
|
|
161
|
-
expected = <<-HTML
|
|
162
|
-
<h2>Go to</h2>
|
|
163
|
-
<ul>
|
|
164
|
-
<li><a href="http://test.host/admin/typus_users/show/4">Next</a></li>
|
|
165
|
-
<li><a href="http://test.host/admin/typus_users/show/2">Previous</a></li>
|
|
166
|
-
</ul>
|
|
167
|
-
HTML
|
|
47
|
+
expected = [ "admin/helpers/list", { :header=>"Chunky bacon",
|
|
48
|
+
:options => { :header => "Chunky Bacon" },
|
|
49
|
+
:items => [ "item1", "item2" ] } ]
|
|
168
50
|
|
|
169
51
|
assert_equal expected, output
|
|
170
|
-
|
|
171
52
|
end
|
|
172
53
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
54
|
+
def test_build_typus_list_with_content_without_header
|
|
55
|
+
output = build_typus_list(['item1', 'item2'])
|
|
56
|
+
expected = [ "admin/helpers/list", { :header => nil,
|
|
57
|
+
:options => {},
|
|
58
|
+
:items=>["item1", "item2"] } ]
|
|
59
|
+
assert_equal expected, output
|
|
176
60
|
end
|
|
177
61
|
|
|
178
62
|
def test_search
|
|
179
63
|
|
|
180
|
-
@resource =
|
|
64
|
+
@resource = TypusUser
|
|
181
65
|
|
|
182
66
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
183
67
|
self.expects(:params).at_least_once.returns(params)
|
|
184
68
|
|
|
185
69
|
output = search
|
|
186
|
-
expected = <<-HTML
|
|
187
|
-
<h2>Search</h2>
|
|
188
|
-
<form action="/#{params[:controller]}" method="get">
|
|
189
|
-
<p><input id="search" name="search" type="text" value=""/></p>
|
|
190
|
-
<input id="action" name="action" type="hidden" value="index" />
|
|
191
|
-
<input id="controller" name="controller" type="hidden" value="admin/typus_users" />
|
|
192
|
-
</form>
|
|
193
|
-
<p class="tip">Search by first name, last name, email, and role.</p>
|
|
194
|
-
HTML
|
|
195
70
|
|
|
196
|
-
|
|
71
|
+
partial = "admin/helpers/search"
|
|
72
|
+
options = { :hidden_params => [ %(<input id="action" name="action" type="hidden" value="index" />),
|
|
73
|
+
%(<input id="controller" name="controller" type="hidden" value="admin/typus_users" />) ],
|
|
74
|
+
:search_by => "First name, Last name, Email, and Role" }
|
|
197
75
|
|
|
198
|
-
|
|
76
|
+
assert_equal partial, output.first
|
|
199
77
|
|
|
200
|
-
|
|
78
|
+
output.last[:hidden_params].each do |o|
|
|
79
|
+
assert options[:hidden_params].include?(o)
|
|
80
|
+
end
|
|
81
|
+
assert options[:search_by].eql?(output.last[:search_by])
|
|
201
82
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
@resource[:class].expects(:typus_filters).returns(Array.new)
|
|
83
|
+
end
|
|
205
84
|
|
|
85
|
+
def test_filters
|
|
86
|
+
@resource = TypusUser
|
|
87
|
+
@resource.expects(:typus_filters).returns(Array.new)
|
|
206
88
|
output = filters
|
|
207
89
|
assert output.nil?
|
|
208
|
-
|
|
209
90
|
end
|
|
210
91
|
|
|
211
|
-
# TODO: Test filters when @resource[:class].typus_filters returns filters.
|
|
212
|
-
#
|
|
213
|
-
# Yes, I know, it's an ugly name for a test, but don't know how to
|
|
214
|
-
# name this test. Suggestions are welcome. ;)
|
|
215
|
-
#
|
|
216
|
-
# FIXME
|
|
217
92
|
def test_filters_with_filters
|
|
218
|
-
return
|
|
219
93
|
end
|
|
220
94
|
|
|
221
|
-
# FIXME
|
|
222
95
|
def test_relationship_filter
|
|
223
|
-
return
|
|
224
96
|
end
|
|
225
97
|
|
|
226
|
-
def
|
|
98
|
+
def test_date_filter
|
|
227
99
|
|
|
228
|
-
|
|
100
|
+
# FIXME
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
@resource = TypusUser
|
|
229
104
|
filter = 'created_at'
|
|
230
105
|
|
|
231
106
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
232
107
|
self.expects(:params).at_least_once.returns(params)
|
|
233
108
|
|
|
234
|
-
|
|
235
|
-
output = datetime_filter(request, filter)
|
|
236
|
-
expected = <<-HTML
|
|
237
|
-
<h2>Created at</h2>
|
|
238
|
-
<ul>
|
|
239
|
-
<li><a href="http://test.host/admin/typus_users?created_at=today" class="off">Today</a></li>
|
|
240
|
-
<li><a href="http://test.host/admin/typus_users?created_at=last_few_days" class="off">Last few days</a></li>
|
|
241
|
-
<li><a href="http://test.host/admin/typus_users?created_at=last_7_days" class="off">Last 7 days</a></li>
|
|
242
|
-
<li><a href="http://test.host/admin/typus_users?created_at=last_30_days" class="off">Last 30 days</a></li>
|
|
243
|
-
</ul>
|
|
244
|
-
HTML
|
|
245
|
-
assert_equal expected, output
|
|
109
|
+
# With an empty request.
|
|
246
110
|
|
|
247
|
-
request =
|
|
248
|
-
output =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
<
|
|
252
|
-
<
|
|
253
|
-
<
|
|
254
|
-
<
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
assert_equal
|
|
111
|
+
request = ""
|
|
112
|
+
output = date_filter(request, filter)
|
|
113
|
+
|
|
114
|
+
partial = "admin/helpers/list"
|
|
115
|
+
options = { :items => [ %(<a href="http://test.host/admin/typus_users?created_at=today" class="off">Today</a>),
|
|
116
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_few_days" class="off">Last few days</a>),
|
|
117
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_7_days" class="off">Last 7 days</a>),
|
|
118
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_30_days" class="off">Last 30 days</a>) ],
|
|
119
|
+
:header => "Created at",
|
|
120
|
+
:options => { :attribute => "created_at" } }
|
|
121
|
+
|
|
122
|
+
assert_equal [ partial, options ], output
|
|
123
|
+
|
|
124
|
+
# With a request.
|
|
125
|
+
|
|
126
|
+
request = "created_at=today&page=1"
|
|
127
|
+
output = date_filter(request, filter)
|
|
128
|
+
|
|
129
|
+
partial = "admin/helpers/list"
|
|
130
|
+
options = { :items => [ %(<a href="http://test.host/admin/typus_users" class="on">Today</a>),
|
|
131
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_few_days" class="off">Last few days</a>),
|
|
132
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_7_days" class="off">Last 7 days</a>),
|
|
133
|
+
%(<a href="http://test.host/admin/typus_users?created_at=last_30_days" class="off">Last 30 days</a>) ],
|
|
134
|
+
:header => "Created at",
|
|
135
|
+
:options => { :attribute => "created_at" } }
|
|
136
|
+
|
|
137
|
+
assert_equal [ partial, options ], output
|
|
259
138
|
|
|
260
139
|
end
|
|
261
140
|
|
|
262
141
|
def test_boolean_filter
|
|
263
142
|
|
|
264
|
-
|
|
143
|
+
# FIXME
|
|
144
|
+
return
|
|
145
|
+
|
|
146
|
+
@resource = TypusUser
|
|
265
147
|
filter = 'status'
|
|
266
148
|
|
|
267
149
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
@@ -269,35 +151,35 @@ HTML
|
|
|
269
151
|
|
|
270
152
|
# Status is true
|
|
271
153
|
|
|
272
|
-
request =
|
|
154
|
+
request = "status=true&page=1"
|
|
273
155
|
output = boolean_filter(request, filter)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
<
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
assert_equal
|
|
156
|
+
|
|
157
|
+
partial = "admin/helpers/list"
|
|
158
|
+
options = { :items => [ %(<a href="http://test.host/admin/typus_users" class="on">Active</a>),
|
|
159
|
+
%(<a href="http://test.host/admin/typus_users?status=false" class="off">Inactive</a>) ],
|
|
160
|
+
:header => "Status",
|
|
161
|
+
:options => { :attribute => "status" } }
|
|
162
|
+
|
|
163
|
+
assert_equal [ partial, options ], output
|
|
282
164
|
|
|
283
165
|
# Status is false
|
|
284
166
|
|
|
285
|
-
request =
|
|
167
|
+
request = "status=false&page=1"
|
|
286
168
|
output = boolean_filter(request, filter)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
<
|
|
290
|
-
<
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
assert_equal
|
|
169
|
+
|
|
170
|
+
partial = "admin/helpers/list"
|
|
171
|
+
options = { :items => [ %(<a href="http://test.host/admin/typus_users?status=true" class="off">Active</a>),
|
|
172
|
+
%(<a href="http://test.host/admin/typus_users" class="on">Inactive</a>) ],
|
|
173
|
+
:header => "Status",
|
|
174
|
+
:options => { :attribute => "status" } }
|
|
175
|
+
|
|
176
|
+
assert_equal [ partial, options ], output
|
|
295
177
|
|
|
296
178
|
end
|
|
297
179
|
|
|
298
180
|
def test_string_filter_when_values_are_strings
|
|
299
181
|
|
|
300
|
-
@resource =
|
|
182
|
+
@resource = TypusUser
|
|
301
183
|
filter = 'role'
|
|
302
184
|
|
|
303
185
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
@@ -306,8 +188,9 @@ HTML
|
|
|
306
188
|
# Roles is admin
|
|
307
189
|
|
|
308
190
|
request = 'role=admin&page=1'
|
|
309
|
-
@resource
|
|
191
|
+
# @resource.expects('role').returns(['admin', 'designer', 'editor'])
|
|
310
192
|
output = string_filter(request, filter)
|
|
193
|
+
|
|
311
194
|
expected = <<-HTML
|
|
312
195
|
<h2>Role</h2>
|
|
313
196
|
<ul>
|
|
@@ -316,13 +199,22 @@ HTML
|
|
|
316
199
|
<li><a href="http://test.host/admin/typus_users?role=editor" class="off">Editor</a></li>
|
|
317
200
|
</ul>
|
|
318
201
|
HTML
|
|
319
|
-
|
|
202
|
+
|
|
203
|
+
partial = "admin/helpers/list"
|
|
204
|
+
options = { :items => [ "<a href=\"http://test.host/admin/typus_users?role=admin\" class=\"on\">Admin</a>",
|
|
205
|
+
"<a href=\"http://test.host/admin/typus_users?role=designer\" class=\"off\">Designer</a>",
|
|
206
|
+
"<a href=\"http://test.host/admin/typus_users?role=editor\" class=\"off\">Editor</a>" ],
|
|
207
|
+
:header => "Role",
|
|
208
|
+
:options => { :attribute => "role" } }
|
|
209
|
+
|
|
210
|
+
assert_equal [ partial, options ], output
|
|
320
211
|
|
|
321
212
|
# Roles is editor
|
|
322
213
|
|
|
323
214
|
request = 'role=editor&page=1'
|
|
324
|
-
@resource
|
|
215
|
+
@resource.expects('role').returns(['admin', 'designer', 'editor'])
|
|
325
216
|
output = string_filter(request, filter)
|
|
217
|
+
|
|
326
218
|
expected = <<-HTML
|
|
327
219
|
<h2>Role</h2>
|
|
328
220
|
<ul>
|
|
@@ -331,25 +223,35 @@ HTML
|
|
|
331
223
|
<li><a href="http://test.host/admin/typus_users?role=editor" class="on">Editor</a></li>
|
|
332
224
|
</ul>
|
|
333
225
|
HTML
|
|
334
|
-
|
|
226
|
+
|
|
227
|
+
partial = "admin/helpers/list"
|
|
228
|
+
options = { :items => [ "<a href=\"http://test.host/admin/typus_users?role=admin\" class=\"off\">Admin</a>",
|
|
229
|
+
"<a href=\"http://test.host/admin/typus_users?role=designer\" class=\"off\">Designer</a>",
|
|
230
|
+
"<a href=\"http://test.host/admin/typus_users?role=editor\" class=\"on\">Editor</a>" ],
|
|
231
|
+
:header => "Role",
|
|
232
|
+
:options => { :attribute => "role" } }
|
|
233
|
+
|
|
234
|
+
assert_equal [ partial, options ], output
|
|
335
235
|
|
|
336
236
|
end
|
|
337
237
|
|
|
338
238
|
def test_string_filter_when_values_are_arrays_of_strings
|
|
339
239
|
|
|
340
|
-
@resource =
|
|
240
|
+
@resource = TypusUser
|
|
341
241
|
filter = 'role'
|
|
342
242
|
|
|
343
243
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
344
244
|
self.expects(:params).at_least_once.returns(params)
|
|
345
245
|
|
|
346
246
|
request = 'role=admin&page=1'
|
|
347
|
-
|
|
348
|
-
|
|
247
|
+
|
|
248
|
+
array = [['Administrador', 'admin'],
|
|
249
|
+
['Diseñador', 'designer'],
|
|
349
250
|
['Editor', 'editor']]
|
|
350
|
-
@resource
|
|
251
|
+
@resource.expects('role').returns(array)
|
|
351
252
|
|
|
352
253
|
output = string_filter(request, filter)
|
|
254
|
+
|
|
353
255
|
expected = <<-HTML
|
|
354
256
|
<h2>Role</h2>
|
|
355
257
|
<ul>
|
|
@@ -357,22 +259,29 @@ HTML
|
|
|
357
259
|
<li><a href="http://test.host/admin/typus_users?role=designer" class="off">Diseñador</a></li>
|
|
358
260
|
<li><a href="http://test.host/admin/typus_users?role=editor" class="off">Editor</a></li>
|
|
359
261
|
</ul>
|
|
360
|
-
|
|
262
|
+
HTML
|
|
361
263
|
|
|
362
|
-
|
|
264
|
+
partial = "admin/helpers/list"
|
|
265
|
+
options = { :items => [ "<a href=\"http://test.host/admin/typus_users?role=admin\" class=\"on\">Administrador</a>",
|
|
266
|
+
"<a href=\"http://test.host/admin/typus_users?role=designer\" class=\"off\">Diseñador</a>",
|
|
267
|
+
"<a href=\"http://test.host/admin/typus_users?role=editor\" class=\"off\">Editor</a>" ],
|
|
268
|
+
:header => "Role",
|
|
269
|
+
:options => { :attribute => "role" } }
|
|
270
|
+
|
|
271
|
+
assert_equal [ partial, options ], output
|
|
363
272
|
|
|
364
273
|
end
|
|
365
274
|
|
|
366
275
|
def test_string_filter_when_empty_values
|
|
367
|
-
|
|
368
|
-
@resource = { :class => TypusUser }
|
|
276
|
+
@resource = TypusUser
|
|
369
277
|
filter = 'role'
|
|
370
|
-
|
|
371
278
|
request = 'role=admin&page=1'
|
|
372
|
-
@resource
|
|
279
|
+
@resource.expects('role').returns([])
|
|
373
280
|
output = string_filter(request, filter)
|
|
374
|
-
assert output.empty?
|
|
375
281
|
|
|
282
|
+
assert output.empty?
|
|
376
283
|
end
|
|
377
284
|
|
|
378
|
-
end
|
|
285
|
+
=end
|
|
286
|
+
|
|
287
|
+
end
|