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,24 +1,26 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
4
4
|
|
|
5
5
|
include Admin::TableHelper
|
|
6
6
|
|
|
7
7
|
include ActionView::Helpers::UrlHelper
|
|
8
|
-
include ActionController::UrlWriter
|
|
9
8
|
include ActionView::Helpers::TagHelper
|
|
10
9
|
include ActionView::Helpers::TextHelper
|
|
11
10
|
|
|
12
|
-
def
|
|
13
|
-
|
|
11
|
+
def render(*args); args; end
|
|
12
|
+
def raw(*args); args; end
|
|
13
|
+
|
|
14
|
+
setup do
|
|
15
|
+
default_url_options[:host] = "test.host"
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
def test_build_typus_table
|
|
18
|
+
=begin
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
# FIXME
|
|
21
|
+
def test_build_table
|
|
20
22
|
|
|
21
|
-
@current_user =
|
|
23
|
+
@current_user = Factory(:typus_user)
|
|
22
24
|
|
|
23
25
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
|
24
26
|
self.expects(:params).at_least_once.returns(params)
|
|
@@ -26,246 +28,236 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
|
26
28
|
fields = TypusUser.typus_fields_for(:list)
|
|
27
29
|
items = TypusUser.find(:all)
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
HTML
|
|
31
|
+
expects(:render).once.with('admin/helpers/table_header',
|
|
32
|
+
{ :headers => [
|
|
33
|
+
'<a href="http://test.host/admin/typus_users?order_by=email">Email </a>',
|
|
34
|
+
'<a href="http://test.host/admin/typus_users?order_by=role">Role </a>',
|
|
35
|
+
'<a href="http://test.host/admin/typus_users?order_by=status">Status </a>',
|
|
36
|
+
' ',
|
|
37
|
+
' '
|
|
38
|
+
]})
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
build_table(TypusUser, fields, items)
|
|
40
41
|
|
|
41
42
|
end
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
=end
|
|
45
|
+
|
|
46
|
+
=begin
|
|
47
|
+
|
|
48
|
+
def test_table_header
|
|
44
49
|
|
|
45
50
|
@current_user = mock()
|
|
46
|
-
@current_user.expects(:
|
|
51
|
+
@current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
|
47
52
|
|
|
48
53
|
fields = TypusUser.typus_fields_for(:list)
|
|
49
54
|
|
|
50
|
-
params = { :controller =>
|
|
55
|
+
params = { :controller => "admin/typus_users", :action => "index" }
|
|
51
56
|
self.expects(:params).at_least_once.returns(params)
|
|
52
57
|
|
|
53
|
-
output =
|
|
54
|
-
expected =
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
<th> </th>
|
|
60
|
-
</tr>
|
|
61
|
-
HTML
|
|
58
|
+
output = table_header(TypusUser, fields)
|
|
59
|
+
expected = [ "admin/helpers/table_header",
|
|
60
|
+
{ :headers=> [ %(<a href="http://test.host/admin/typus_users?order_by=email">Email</a>),
|
|
61
|
+
%(<a href="http://test.host/admin/typus_users?order_by=role">Role</a>),
|
|
62
|
+
%(<a href="http://test.host/admin/typus_users?order_by=status">Status</a>),
|
|
63
|
+
" "] } ]
|
|
62
64
|
|
|
63
65
|
assert_equal expected, output
|
|
64
66
|
|
|
65
67
|
end
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
=end
|
|
70
|
+
|
|
71
|
+
=begin
|
|
72
|
+
|
|
73
|
+
def test_table_header_with_params
|
|
68
74
|
|
|
69
75
|
@current_user = mock()
|
|
70
|
-
@current_user.expects(:
|
|
76
|
+
@current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
|
71
77
|
|
|
72
78
|
fields = TypusUser.typus_fields_for(:list)
|
|
73
79
|
|
|
74
|
-
params = { :controller =>
|
|
80
|
+
params = { :controller => "admin/typus_users", :action => "index", :search => "admin" }
|
|
75
81
|
self.expects(:params).at_least_once.returns(params)
|
|
76
82
|
|
|
77
|
-
output =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
</tr>
|
|
85
|
-
HTML
|
|
83
|
+
output = table_header(TypusUser, fields)
|
|
84
|
+
|
|
85
|
+
expected = [ "admin/helpers/table_header",
|
|
86
|
+
{ :headers => [ %(<a href="http://test.host/admin/typus_users?order_by=email&search=admin">Email</a>),
|
|
87
|
+
%(<a href="http://test.host/admin/typus_users?order_by=role&search=admin">Role</a>),
|
|
88
|
+
%(<a href="http://test.host/admin/typus_users?order_by=status&search=admin">Status</a>),
|
|
89
|
+
%( ) ] } ]
|
|
86
90
|
|
|
87
91
|
assert_equal expected, output
|
|
88
92
|
|
|
89
93
|
end
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
=end
|
|
96
|
+
|
|
97
|
+
=begin
|
|
98
|
+
|
|
99
|
+
def test_table_header_when_user_cannot_delete_items
|
|
92
100
|
|
|
93
101
|
@current_user = mock()
|
|
94
|
-
@current_user.expects(:
|
|
102
|
+
@current_user.expects(:can?).with("delete", TypusUser).returns(false)
|
|
95
103
|
|
|
96
104
|
fields = TypusUser.typus_fields_for(:list)
|
|
97
105
|
|
|
98
|
-
params = { :controller =>
|
|
106
|
+
params = { :controller => "admin/typus_users", :action => "index" }
|
|
99
107
|
self.expects(:params).at_least_once.returns(params)
|
|
100
108
|
|
|
101
|
-
output =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
</tr>
|
|
108
|
-
HTML
|
|
109
|
+
output = table_header(TypusUser, fields)
|
|
110
|
+
|
|
111
|
+
expected = [ "admin/helpers/table_header",
|
|
112
|
+
{ :headers => [ %(<a href="http://test.host/admin/typus_users?order_by=email">Email</a>),
|
|
113
|
+
%(<a href="http://test.host/admin/typus_users?order_by=role">Role</a>),
|
|
114
|
+
%(<a href="http://test.host/admin/typus_users?order_by=status">Status</a>) ] } ]
|
|
109
115
|
|
|
110
116
|
assert_equal expected, output
|
|
111
117
|
|
|
112
118
|
end
|
|
113
119
|
|
|
114
|
-
|
|
120
|
+
=end
|
|
121
|
+
|
|
122
|
+
=begin
|
|
123
|
+
|
|
124
|
+
def test_table_header_when_user_cannot_delete_items_with_params
|
|
115
125
|
|
|
116
126
|
@current_user = mock()
|
|
117
|
-
@current_user.expects(:
|
|
127
|
+
@current_user.expects(:can?).with("delete", TypusUser).returns(false)
|
|
118
128
|
|
|
119
129
|
fields = TypusUser.typus_fields_for(:list)
|
|
120
130
|
|
|
121
|
-
params = { :controller =>
|
|
131
|
+
params = { :controller => "admin/typus_users", :action => "index", :search => "admin" }
|
|
122
132
|
self.expects(:params).at_least_once.returns(params)
|
|
123
133
|
|
|
124
|
-
output =
|
|
125
|
-
expected = <<-HTML
|
|
126
|
-
<tr>
|
|
127
|
-
<th><a href="http://test.host/admin/typus_users?order_by=email&search=admin">Email </a></th>
|
|
128
|
-
<th><a href="http://test.host/admin/typus_users?order_by=role&search=admin">Role </a></th>
|
|
129
|
-
<th><a href="http://test.host/admin/typus_users?order_by=status&search=admin">Status </a></th>
|
|
130
|
-
</tr>
|
|
131
|
-
HTML
|
|
134
|
+
output = table_header(TypusUser, fields)
|
|
132
135
|
|
|
136
|
+
expected = [ "admin/helpers/table_header",
|
|
137
|
+
{ :headers => [ %(<a href="http://test.host/admin/typus_users?order_by=email&search=admin">Email</a>),
|
|
138
|
+
%(<a href="http://test.host/admin/typus_users?order_by=role&search=admin">Role</a>),
|
|
139
|
+
%(<a href="http://test.host/admin/typus_users?order_by=status&search=admin">Status</a>) ] } ]
|
|
133
140
|
assert_equal expected, output
|
|
134
141
|
|
|
135
142
|
end
|
|
136
143
|
|
|
144
|
+
=end
|
|
137
145
|
|
|
138
|
-
|
|
146
|
+
=begin
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
def test_table_belongs_to_field
|
|
149
|
+
|
|
150
|
+
@current_user = Factory(:typus_user)
|
|
141
151
|
|
|
142
152
|
comment = comments(:without_post_id)
|
|
143
|
-
output =
|
|
144
|
-
expected =
|
|
145
|
-
<td></td>
|
|
146
|
-
HTML
|
|
153
|
+
output = table_belongs_to_field("post", comment)
|
|
154
|
+
expected = "<td></td>"
|
|
147
155
|
|
|
148
156
|
assert_equal expected, output
|
|
149
|
-
default_url_options[:host] =
|
|
157
|
+
default_url_options[:host] = "test.host"
|
|
150
158
|
|
|
151
159
|
comment = comments(:with_post_id)
|
|
152
|
-
output =
|
|
153
|
-
expected =
|
|
154
|
-
<td><a href="http://test.host/admin/posts/edit/1">Post#1</a></td>
|
|
155
|
-
HTML
|
|
160
|
+
output = table_belongs_to_field("post", comment)
|
|
161
|
+
expected = %(<td><a href="http://test.host/admin/posts/edit/1">Post#1</a></td>)
|
|
156
162
|
|
|
157
|
-
assert_equal expected, output
|
|
163
|
+
assert_equal expected.strip, output
|
|
158
164
|
|
|
159
165
|
end
|
|
160
166
|
|
|
161
|
-
|
|
167
|
+
=end
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
=begin
|
|
164
170
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<td>John<br />Me<br />Me</td>
|
|
168
|
-
HTML
|
|
171
|
+
def test_table_has_and_belongs_to_many_field
|
|
172
|
+
post = Factory(:post)
|
|
169
173
|
|
|
170
|
-
|
|
174
|
+
output = table_has_and_belongs_to_many_field("comments", post)
|
|
175
|
+
expected = %(<td>John, Me, Me</td>)
|
|
171
176
|
|
|
177
|
+
assert_equal expected.strip, output
|
|
172
178
|
end
|
|
173
179
|
|
|
174
|
-
|
|
180
|
+
=end
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
expected = <<-HTML
|
|
179
|
-
<td class="title">#{post.title}</td>
|
|
180
|
-
HTML
|
|
182
|
+
should "test_table_string_field" do
|
|
183
|
+
post = Factory(:post)
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
output = table_string_field(:title, post, :created_at)
|
|
186
|
+
expected = %(<td class="title">#{post.title}</td>)
|
|
183
187
|
|
|
188
|
+
assert_equal expected.strip, output
|
|
184
189
|
end
|
|
185
190
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
post = posts(:published)
|
|
189
|
-
output = typus_table_string_field(:title, post, :title)
|
|
190
|
-
expected = <<-HTML
|
|
191
|
-
<td class="title">#{post.title}</td>
|
|
192
|
-
HTML
|
|
191
|
+
should "test_table_string_field_with_link" do
|
|
192
|
+
post = Factory(:post)
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
output = table_string_field(:title, post, :title)
|
|
195
|
+
expected = %(<td class="title">#{post.title}</td>)
|
|
195
196
|
|
|
197
|
+
assert_equal expected.strip, output
|
|
196
198
|
end
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
should "table_tree_field_when_displays_a_parent" do
|
|
201
|
+
page = Factory(:page)
|
|
199
202
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
page = pages(:published)
|
|
203
|
-
output = typus_table_tree_field('test', page)
|
|
204
|
-
expected = <<-HTML
|
|
205
|
-
<td></td>
|
|
206
|
-
HTML
|
|
203
|
+
output = table_tree_field("test", page)
|
|
204
|
+
expected = "<td>—</td>"
|
|
207
205
|
|
|
208
206
|
assert_equal expected, output
|
|
209
|
-
|
|
210
|
-
page = pages(:unpublished)
|
|
211
|
-
output = typus_table_tree_field('test', page)
|
|
212
|
-
expected = <<-HTML
|
|
213
|
-
<td>Page#1</td>
|
|
214
|
-
HTML
|
|
215
|
-
|
|
216
|
-
assert_equal expected, output
|
|
217
|
-
|
|
218
207
|
end
|
|
219
208
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
post = posts(:published)
|
|
223
|
-
Time::DATE_FORMATS[:post_short] = '%m/%y'
|
|
209
|
+
should "table_tree_field_when_displays_a_children" do
|
|
210
|
+
page = Factory(:page, :status => "unpublished")
|
|
224
211
|
|
|
225
|
-
output =
|
|
226
|
-
expected =
|
|
227
|
-
<td>#{post.created_at.strftime('%m/%y')}</td>
|
|
228
|
-
HTML
|
|
212
|
+
output = table_tree_field("test", page)
|
|
213
|
+
expected = "<td>—</td>"
|
|
229
214
|
|
|
230
215
|
assert_equal expected, output
|
|
231
|
-
|
|
232
216
|
end
|
|
233
217
|
|
|
234
|
-
|
|
218
|
+
should "test_table_datetime_field" do
|
|
219
|
+
post = Factory(:post)
|
|
220
|
+
Time::DATE_FORMATS[:post_short] = "%m/%y"
|
|
235
221
|
|
|
236
|
-
|
|
237
|
-
|
|
222
|
+
output = table_datetime_field(:created_at, post)
|
|
223
|
+
expected = %(<td>#{post.created_at.strftime("%m/%y")}</td>)
|
|
238
224
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
<td>#{post.created_at.strftime('%m/%y')}</td>
|
|
242
|
-
HTML
|
|
225
|
+
assert_equal expected.strip, output
|
|
226
|
+
end
|
|
243
227
|
|
|
244
|
-
|
|
228
|
+
should "test_table_datetime_field_with_link" do
|
|
229
|
+
post = Factory(:post)
|
|
230
|
+
Time::DATE_FORMATS[:post_short] = "%m/%y"
|
|
231
|
+
|
|
232
|
+
output = table_datetime_field(:created_at, post, :created_at)
|
|
233
|
+
expected = %(<td>#{post.created_at.strftime("%m/%y")}</td>)
|
|
245
234
|
|
|
235
|
+
assert_equal expected.strip, output
|
|
246
236
|
end
|
|
247
237
|
|
|
248
|
-
|
|
238
|
+
=begin
|
|
249
239
|
|
|
250
|
-
|
|
251
|
-
|
|
240
|
+
# FIXME: NameError: undefined local variable or method `controller' for
|
|
241
|
+
def test_table_boolean_field
|
|
252
242
|
|
|
253
|
-
post =
|
|
254
|
-
output =
|
|
243
|
+
post = Factory(:typus_user)
|
|
244
|
+
output = table_boolean_field("status", post)
|
|
255
245
|
expected = <<-HTML
|
|
256
|
-
<td
|
|
246
|
+
<td><a href="http://test.host/admin/typus_users/toggle/1?field=status" onclick="return confirm('Change status?');">Active</a></td>
|
|
257
247
|
HTML
|
|
258
248
|
|
|
259
|
-
assert_equal expected, output
|
|
249
|
+
assert_equal expected.strip, output
|
|
260
250
|
|
|
261
|
-
post =
|
|
262
|
-
output =
|
|
251
|
+
post = Factory(:typus_user, :status => false)
|
|
252
|
+
output = table_boolean_field("status", post)
|
|
263
253
|
expected = <<-HTML
|
|
264
|
-
<td
|
|
254
|
+
<td><a href="http://test.host/admin/typus_users/toggle/3?field=status" onclick="return confirm('Change status?');">Inactive</a></td>
|
|
265
255
|
HTML
|
|
266
256
|
|
|
267
|
-
assert_equal expected, output
|
|
257
|
+
assert_equal expected.strip, output
|
|
268
258
|
|
|
269
259
|
end
|
|
270
260
|
|
|
271
|
-
end
|
|
261
|
+
=end
|
|
262
|
+
|
|
263
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class AdminHelperTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
include AdminHelper
|
|
6
|
+
|
|
7
|
+
include ActionView::Helpers::UrlHelper
|
|
8
|
+
include ActionView::Helpers::TextHelper
|
|
9
|
+
|
|
10
|
+
def render(*args); args; end
|
|
11
|
+
|
|
12
|
+
=begin
|
|
13
|
+
|
|
14
|
+
def test_header_with_root_path
|
|
15
|
+
|
|
16
|
+
# ActionView::Helpers::UrlHelper does not support strings, which are returned by named routes
|
|
17
|
+
# link root_path
|
|
18
|
+
self.stubs(:link_to).returns(%(<a href="/">View site</a>))
|
|
19
|
+
self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
|
|
20
|
+
|
|
21
|
+
output = header
|
|
22
|
+
|
|
23
|
+
partial = "admin/helpers/header"
|
|
24
|
+
options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
|
|
25
|
+
%(<a href="/admin/dashboard">Dashboard</a>),
|
|
26
|
+
%(<a href="/">View site</a>) ] }
|
|
27
|
+
|
|
28
|
+
assert_equal [ partial, options ], output
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
=end
|
|
33
|
+
|
|
34
|
+
=begin
|
|
35
|
+
|
|
36
|
+
def test_header_without_root_path
|
|
37
|
+
|
|
38
|
+
Rails.application.routes.named_routes.routes.reject! { |key, route| key == :root }
|
|
39
|
+
|
|
40
|
+
self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
|
|
41
|
+
|
|
42
|
+
output = header
|
|
43
|
+
partial = "admin/helpers/header"
|
|
44
|
+
options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
|
|
45
|
+
%(<a href="/admin/dashboard">Dashboard</a>) ] }
|
|
46
|
+
|
|
47
|
+
assert_equal [ partial, options ], output
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
=end
|
|
52
|
+
|
|
53
|
+
should "display_flash_message" do
|
|
54
|
+
message = { :test => "This is the message." }
|
|
55
|
+
output = display_flash_message(message)
|
|
56
|
+
|
|
57
|
+
partial = "admin/helpers/flash_message"
|
|
58
|
+
options = { :flash_type => :test,
|
|
59
|
+
:message => { :test => "This is the message." } }
|
|
60
|
+
|
|
61
|
+
assert_equal partial, output.first
|
|
62
|
+
assert_equal options, output.last
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
should "not display_flash_message with empty message" do
|
|
66
|
+
assert display_flash_message(Hash.new).nil?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ActiveRecordTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "verify mapping instace method with an array" do
|
|
6
|
+
post = Factory(:post)
|
|
7
|
+
assert_equal "published", post.mapping(:status)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should "verify mapping instace method with an array when status if unpublished" do
|
|
11
|
+
post = Factory(:post, :status => "unpublished")
|
|
12
|
+
assert_equal "unpublished", post.mapping(:status)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "verify mapping instace method with a hash" do
|
|
16
|
+
page = Factory(:page)
|
|
17
|
+
assert_equal "Published", page.mapping(:status)
|
|
18
|
+
page = Factory(:page, :status => "unpublished")
|
|
19
|
+
assert_equal "Not Published", page.mapping(:status)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should "verify to_label instace method" do
|
|
23
|
+
assert_equal "admin@example.com", Factory(:typus_user).to_label
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "verify to_label instace method for post" do
|
|
27
|
+
assert_match /Post#/, Factory(:post).to_label
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should "verify to_resource instance method" do
|
|
31
|
+
assert_equal "typus_users", TypusUser.to_resource
|
|
32
|
+
assert_equal "delayed/tasks", Delayed::Task.to_resource
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ArrayTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "verify Array#to_hash_with" do
|
|
6
|
+
keys, values = %w(a b c), %w(1 2 3)
|
|
7
|
+
expected = { "a" => "1", "b" => "2", "c" => "3" }
|
|
8
|
+
|
|
9
|
+
hash = keys.to_hash_with(values)
|
|
10
|
+
|
|
11
|
+
assert hash.kind_of?(Hash)
|
|
12
|
+
assert_equal expected, hash
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class StringTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "extract_settings" do
|
|
6
|
+
assert_equal %w( a b c ), "a, b, c".extract_settings
|
|
7
|
+
assert_equal %w( a b c ), " a , b, c ".extract_settings
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should "remove prefix" do
|
|
11
|
+
assert_equal "posts", "admin/posts".remove_prefix
|
|
12
|
+
assert_equal "typus_users", "admin/typus_users".remove_prefix
|
|
13
|
+
assert_equal "delayed/jobs", "admin/delayed/jobs".remove_prefix
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
should "remove prefix with params" do
|
|
17
|
+
assert_equal "posts", "typus/posts".remove_prefix("typus/")
|
|
18
|
+
assert_equal "typus_users", "typus/typus_users".remove_prefix("typus/")
|
|
19
|
+
assert_equal "delayed/tasks", "typus/delayed/tasks".remove_prefix("typus/")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should "extract_resource" do
|
|
23
|
+
assert_equal "posts", "admin/posts".extract_resource
|
|
24
|
+
assert_equal "typus_users", "admin/typus_users".extract_resource
|
|
25
|
+
assert_equal "delayed/tasks", "admin/delayed/tasks".extract_resource
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should "extract_class" do
|
|
29
|
+
assert_equal Post, "admin/posts".extract_class
|
|
30
|
+
assert_equal TypusUser, "admin/typus_users".extract_class
|
|
31
|
+
assert_equal Delayed::Task, "admin/delayed/tasks".extract_class
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
should "extract_human_name" do
|
|
35
|
+
assert_equal "Post", "admin/posts".extract_human_name
|
|
36
|
+
assert_equal "Typus user", "admin/typus_users".extract_human_name
|
|
37
|
+
assert_equal "Task", "admin/delayed/tasks".extract_human_name
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
should "verify String#typus_actions_on" do
|
|
41
|
+
assert_equal %w(cleanup), "Post".typus_actions_on("index")
|
|
42
|
+
assert_equal %w(cleanup), "Post".typus_actions_on(:index)
|
|
43
|
+
assert_equal %w(send_as_newsletter preview), "Post".typus_actions_on(:edit)
|
|
44
|
+
assert "TypusUser".typus_actions_on(:unexisting).empty?
|
|
45
|
+
assert "Post".typus_actions_on(:index).kind_of?(Array)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|