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
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ActiveRecordTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "verify model fields is an instance of active support ordered hash" do
|
|
6
|
+
assert TypusUser.model_fields.instance_of?(ActiveSupport::OrderedHash)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
should "return model fields for TypusUser" do
|
|
10
|
+
expected_fields = [[:id, :integer],
|
|
11
|
+
[:first_name, :string],
|
|
12
|
+
[:last_name, :string],
|
|
13
|
+
[:role, :string],
|
|
14
|
+
[:email, :string],
|
|
15
|
+
[:status, :boolean],
|
|
16
|
+
[:token, :string],
|
|
17
|
+
[:salt, :string],
|
|
18
|
+
[:crypted_password, :string],
|
|
19
|
+
[:preferences, :string],
|
|
20
|
+
[:created_at, :datetime],
|
|
21
|
+
[:updated_at, :datetime]]
|
|
22
|
+
assert_equal expected_fields.map { |i| i.first }, TypusUser.model_fields.keys
|
|
23
|
+
assert_equal expected_fields.map { |i| i.last }, TypusUser.model_fields.values
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "return model fields for post" do
|
|
27
|
+
expected_fields = [[:id, :integer],
|
|
28
|
+
[:title, :string],
|
|
29
|
+
[:body, :text],
|
|
30
|
+
[:status, :string],
|
|
31
|
+
[:favorite_comment_id, :integer],
|
|
32
|
+
[:created_at, :datetime],
|
|
33
|
+
[:updated_at, :datetime],
|
|
34
|
+
[:published_at, :datetime],
|
|
35
|
+
[:typus_user_id, :integer]]
|
|
36
|
+
assert_equal expected_fields.map { |i| i.first }, Post.model_fields.keys
|
|
37
|
+
assert_equal expected_fields.map { |i| i.last }, Post.model_fields.values
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
should "verify_model_relationships_is_an_instance_of_active_support_ordered_hash" do
|
|
41
|
+
assert TypusUser.model_relationships.instance_of?(ActiveSupport::OrderedHash)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
should "return_model_relationships_for_post" do
|
|
45
|
+
expected = [[:comments, :has_many],
|
|
46
|
+
[:categories, :has_and_belongs_to_many],
|
|
47
|
+
[:user, nil],
|
|
48
|
+
[:assets, :has_many]]
|
|
49
|
+
expected.each do |i|
|
|
50
|
+
assert_equal i.last, Post.model_relationships[i.first]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should "return_description_of_a_model" do
|
|
55
|
+
assert_equal "System Users Administration", TypusUser.typus_description
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "Typus fields for" do
|
|
59
|
+
|
|
60
|
+
should "verify typus_fields_for accepts strings" do
|
|
61
|
+
assert_equal %w( email role status ), TypusUser.typus_fields_for("list").keys
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
should "verify typus_fields_for accepts symbols" do
|
|
65
|
+
assert_equal %w( email role status ), TypusUser.typus_fields_for(:list).keys
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
should "return_typus_fields_for_list_for_typus_user" do
|
|
69
|
+
expected_fields = [["email", :string],
|
|
70
|
+
["role", :selector],
|
|
71
|
+
["status", :boolean]]
|
|
72
|
+
assert_equal expected_fields.map { |i| i.first }, TypusUser.typus_fields_for(:list).keys
|
|
73
|
+
assert_equal expected_fields.map { |i| i.last }, TypusUser.typus_fields_for(:list).values
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
should "return_typus_fields_for_form_for_typus_user" do
|
|
77
|
+
expected_fields = [["first_name", :string],
|
|
78
|
+
["last_name", :string],
|
|
79
|
+
["role", :selector],
|
|
80
|
+
["email", :string],
|
|
81
|
+
["password", :password],
|
|
82
|
+
["password_confirmation", :password],
|
|
83
|
+
["language", :selector]]
|
|
84
|
+
assert_equal expected_fields.map { |i| i.first }, TypusUser.typus_fields_for(:form).keys
|
|
85
|
+
assert_equal expected_fields.map { |i| i.last }, TypusUser.typus_fields_for(:form).values
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
should "return_typus_fields_for_form_for_picture" do
|
|
89
|
+
expected_fields = [["title", :string],
|
|
90
|
+
["picture", :file]]
|
|
91
|
+
assert_equal expected_fields.map { |i| i.first }, Picture.typus_fields_for(:form).keys
|
|
92
|
+
assert_equal expected_fields.map { |i| i.last }, Picture.typus_fields_for(:form).values
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
should "return_typus_fields_for_a_model_without_configuration" do
|
|
96
|
+
assert Class.new(ActiveRecord::Base).typus_fields_for(:form).empty?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
should "return_typus_fields_for_relationship_for_typus_user" do
|
|
100
|
+
assert_equal %w( first_name last_name role email language), TypusUser.typus_fields_for(:relationship).keys
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
should "return_all_fields_for_undefined_field_type_on_typus_user" do
|
|
104
|
+
assert_equal %w( first_name last_name role email language), TypusUser.typus_fields_for(:undefined).keys
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context "Typus filters" do
|
|
110
|
+
|
|
111
|
+
should "return_filters_for_typus_user" do
|
|
112
|
+
expected = [["status", :boolean], ["role", :string]]
|
|
113
|
+
|
|
114
|
+
assert_equal expected.map { |i| i.first }.join(", "), Typus::Configuration.config["TypusUser"]["filters"]
|
|
115
|
+
assert_equal expected.map { |i| i.first }, TypusUser.typus_filters.keys
|
|
116
|
+
assert_equal expected.map { |i| i.last }, TypusUser.typus_filters.values
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
should "return_post_typus_filters" do
|
|
120
|
+
expected = [["status", :string], ["created_at", :datetime]]
|
|
121
|
+
assert_equal expected.map { |i| i.first }.join(", "), Typus::Configuration.config["Post"]["filters"]
|
|
122
|
+
assert_equal expected.map { |i| i.first }, Post.typus_filters.keys
|
|
123
|
+
assert_equal expected.map { |i| i.last }, Post.typus_filters.values
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
context "Typus actions on" do
|
|
129
|
+
|
|
130
|
+
should "verify typus_actions_on accepts strings" do
|
|
131
|
+
assert_equal %w( cleanup ), Post.typus_actions_on("index")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
should "verify typus_actions_on accepts symbols" do
|
|
135
|
+
assert_equal %w( cleanup ), Post.typus_actions_on(:index)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
should "return_actions_on_list_for_typus_user" do
|
|
139
|
+
assert TypusUser.typus_actions_on(:list).empty?
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
should "return Post actions on edit" do
|
|
143
|
+
assert_equal %w( send_as_newsletter preview ), Post.typus_actions_on(:edit)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
should "return Post actions" do
|
|
147
|
+
assert_equal %w( cleanup preview send_as_newsletter ), Post.typus_actions.sort
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
context "Typus options for" do
|
|
153
|
+
|
|
154
|
+
should "verify typus_options_for accepts strings" do
|
|
155
|
+
assert_equal 15, Post.typus_options_for("form_rows")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
should "verify typus_options_for accepts symbols" do
|
|
159
|
+
assert_equal 15, Post.typus_options_for(:form_rows)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
should "verify typus_options_for returns nil when options doesnt exist" do
|
|
163
|
+
assert TypusUser.typus_options_for(:unexisting).nil?
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
should "return options for post and page" do
|
|
167
|
+
assert_equal 15, Post.typus_options_for(:form_rows)
|
|
168
|
+
assert_equal 25, Page.typus_options_for(:form_rows)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context "Typus field options for" do
|
|
174
|
+
|
|
175
|
+
should "verify on models" do
|
|
176
|
+
assert_equal [ :status ], Post.typus_field_options_for(:selectors)
|
|
177
|
+
assert_equal [ :permalink ], Post.typus_field_options_for(:read_only)
|
|
178
|
+
assert_equal [ :created_at ], Post.typus_field_options_for(:auto_generated)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context "Typus boolean" do
|
|
184
|
+
|
|
185
|
+
should "verify_typus_boolean_is_an_instance_of_active_support_ordered_hash" do
|
|
186
|
+
assert TypusUser.typus_boolean("status").instance_of?(ActiveSupport::OrderedHash)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
should "verify typus_boolean accepts strings" do
|
|
190
|
+
assert_equal [ :true, :false ], TypusUser.typus_boolean("status").keys
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
should "verify typus_boolean accepts symbols" do
|
|
194
|
+
assert_equal [ :true, :false ], TypusUser.typus_boolean(:status).keys
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
should "return_booleans_for_typus_users" do
|
|
198
|
+
assert_equal [ :true, :false ], TypusUser.typus_boolean(:status).keys
|
|
199
|
+
assert_equal [ "Active", "Inactive" ], TypusUser.typus_boolean(:status).values
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
should "return_booleans_for_post" do
|
|
203
|
+
assert_equal [ :true, :false ], Post.typus_boolean(:status).keys
|
|
204
|
+
assert_equal [ "True", "False" ], Post.typus_boolean(:status).values
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
context "Typus date format" do
|
|
210
|
+
|
|
211
|
+
should "verify typus_date_format accepts strings and symbols" do
|
|
212
|
+
assert_equal :db, Post.typus_date_format("unknown")
|
|
213
|
+
assert_equal :db, Post.typus_date_format(:unknown)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
should "return typus_date_formats for Post" do
|
|
217
|
+
assert_equal :db, Post.typus_date_format
|
|
218
|
+
assert_equal :post_short, Post.typus_date_format("created_at")
|
|
219
|
+
assert_equal :post_short, Post.typus_date_format(:created_at)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
context "Typus defaults for" do
|
|
225
|
+
|
|
226
|
+
should "verify typus_defaults_for on Model accepts strings and symbols" do
|
|
227
|
+
assert_equal %w( title ), Post.typus_defaults_for("search")
|
|
228
|
+
assert_equal %w( title ), Post.typus_defaults_for(:search)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
should "return defaults_for search on Post" do
|
|
232
|
+
assert_equal %w( title ), Post.typus_defaults_for(:search)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
should "return default_for relationships on Post" do
|
|
236
|
+
assert_equal %w( assets categories comments views ), Post.typus_defaults_for(:relationships)
|
|
237
|
+
assert !Post.typus_defaults_for(:relationships).empty?
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
context "Typus order by" do
|
|
243
|
+
|
|
244
|
+
should "return defaults_for order_by on Post" do
|
|
245
|
+
assert_equal "posts.title ASC, posts.created_at DESC", Post.typus_order_by
|
|
246
|
+
assert_equal %w( title -created_at ), Post.typus_defaults_for(:order_by)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
context "Build conditions" do
|
|
252
|
+
|
|
253
|
+
should "return_sql_conditions_on_search_for_typus_user" do
|
|
254
|
+
expected = "(role LIKE '%francesc%' OR last_name LIKE '%francesc%' OR email LIKE '%francesc%' OR first_name LIKE '%francesc%')"
|
|
255
|
+
params = { :search => "francesc" }
|
|
256
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
257
|
+
params = { :search => "Francesc" }
|
|
258
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
should "return_sql_conditions_on_search_and_filter_for_typus_user" do
|
|
262
|
+
|
|
263
|
+
case ENV["DB"]
|
|
264
|
+
when /mysql/
|
|
265
|
+
boolean_true = "(`typus_users`.`status` = 1)"
|
|
266
|
+
boolean_false = "(`typus_users`.`status` = 0)"
|
|
267
|
+
else
|
|
268
|
+
boolean_true = "(\"typus_users\".\"status\" = 't')"
|
|
269
|
+
boolean_false = "(\"typus_users\".\"status\" = 'f')"
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
expected = "((role LIKE '%francesc%' OR last_name LIKE '%francesc%' OR email LIKE '%francesc%' OR first_name LIKE '%francesc%')) AND #{boolean_true}"
|
|
273
|
+
params = { :search => "francesc", :status => "true" }
|
|
274
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
275
|
+
params = { :search => "francesc", :status => "false" }
|
|
276
|
+
assert_match /#{boolean_false}/, TypusUser.build_conditions(params).first
|
|
277
|
+
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
should "return_sql_conditions_on_filtering_typus_users_by_status" do
|
|
281
|
+
|
|
282
|
+
case ENV["DB"]
|
|
283
|
+
when /mysql/
|
|
284
|
+
boolean_true = "(`typus_users`.`status` = 1)"
|
|
285
|
+
boolean_false = "(`typus_users`.`status` = 0)"
|
|
286
|
+
else
|
|
287
|
+
boolean_true = "(\"typus_users\".\"status\" = 't')"
|
|
288
|
+
boolean_false = "(\"typus_users\".\"status\" = 'f')"
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
params = { :status => "true" }
|
|
292
|
+
assert_equal boolean_true, TypusUser.build_conditions(params).first
|
|
293
|
+
params = { :status => "false" }
|
|
294
|
+
assert_equal boolean_false, TypusUser.build_conditions(params).first
|
|
295
|
+
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at today" do
|
|
299
|
+
expected = case ENV["DB"]
|
|
300
|
+
when /postgresql/
|
|
301
|
+
"(created_at BETWEEN E'#{Time.new.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
302
|
+
else
|
|
303
|
+
"(created_at BETWEEN '#{Time.new.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
304
|
+
end
|
|
305
|
+
params = { :created_at => "today" }
|
|
306
|
+
|
|
307
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_few_days" do
|
|
311
|
+
expected = case ENV["DB"]
|
|
312
|
+
when /postgresql/
|
|
313
|
+
"(created_at BETWEEN E'#{3.days.ago.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
314
|
+
else
|
|
315
|
+
"(created_at BETWEEN '#{3.days.ago.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
params = { :created_at => "last_few_days" }
|
|
319
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_7_days" do
|
|
323
|
+
expected = case ENV["DB"]
|
|
324
|
+
when /postgresql/
|
|
325
|
+
"(created_at BETWEEN E'#{6.days.ago.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
326
|
+
else
|
|
327
|
+
"(created_at BETWEEN '#{6.days.ago.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
params = { :created_at => "last_7_days" }
|
|
331
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_30_days" do
|
|
335
|
+
expected = case ENV["DB"]
|
|
336
|
+
when /postgresql/
|
|
337
|
+
"(created_at BETWEEN E'#{Time.new.midnight.prev_month.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
338
|
+
else
|
|
339
|
+
"(created_at BETWEEN '#{Time.new.midnight.prev_month.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
340
|
+
end
|
|
341
|
+
params = { :created_at => "last_30_days" }
|
|
342
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
should "return_sql_conditions_on_filtering_posts_by_published_at today" do
|
|
346
|
+
expected = case ENV["DB"]
|
|
347
|
+
when /postgresql/
|
|
348
|
+
"(published_at BETWEEN E'#{Time.new.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
349
|
+
else
|
|
350
|
+
"(published_at BETWEEN '#{Time.new.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
params = { :published_at => "today" }
|
|
354
|
+
assert_equal expected, Post.build_conditions(params).first
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
should "return_sql_conditions_on_filtering_posts_by_string" do
|
|
358
|
+
expected = case ENV["DB"]
|
|
359
|
+
when /postgresql/
|
|
360
|
+
"(\"typus_users\".\"role\" = E'admin')"
|
|
361
|
+
when /mysql/
|
|
362
|
+
"(`typus_users`.`role` = 'admin')"
|
|
363
|
+
else
|
|
364
|
+
"(\"typus_users\".\"role\" = 'admin')"
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
params = { :role => "admin" }
|
|
368
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
context "Class methods" do
|
|
374
|
+
|
|
375
|
+
should "verify typus_user_id exists on Post" do
|
|
376
|
+
assert Post.typus_user_id?
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
should "verify typus_user_id does not exist on Post" do
|
|
380
|
+
assert !TypusUser.typus_user_id?
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ConfigurationTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "verify typus roles is loaded" do
|
|
6
|
+
assert Typus::Configuration.respond_to?(:roles!)
|
|
7
|
+
assert Typus::Configuration.roles!.kind_of?(Hash)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should "verify typus config file is loaded" do
|
|
11
|
+
assert Typus::Configuration.respond_to?(:config!)
|
|
12
|
+
assert Typus::Configuration.config!.kind_of?(Hash)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "load configuration files from config broken" do
|
|
16
|
+
Typus.expects(:config_folder).at_least_once.returns("../config/broken")
|
|
17
|
+
assert_not_equal Hash.new, Typus::Configuration.roles!
|
|
18
|
+
assert_not_equal Hash.new, Typus::Configuration.config!
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
should "load configuration files from config empty" do
|
|
22
|
+
Typus.expects(:config_folder).at_least_once.returns("../config/empty")
|
|
23
|
+
assert_equal Hash.new, Typus::Configuration.roles!
|
|
24
|
+
assert_equal Hash.new, Typus::Configuration.config!
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
should "load configuration files from config ordered" do
|
|
28
|
+
Typus.expects(:config_folder).at_least_once.returns("../config/ordered")
|
|
29
|
+
files = Dir[Rails.root.join(Typus.config_folder, "*_roles.yml")]
|
|
30
|
+
expected = files.collect { |file| File.basename(file) }.sort
|
|
31
|
+
assert_equal expected, ["001_roles.yml", "002_roles.yml"]
|
|
32
|
+
expected = { "admin" => { "categories" => "read" } }
|
|
33
|
+
assert_equal expected, Typus::Configuration.roles!
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "load configuration files from config unordered" do
|
|
37
|
+
Typus.expects(:config_folder).at_least_once.returns("../config/unordered")
|
|
38
|
+
files = Dir[Rails.root.join(Typus.config_folder, "*_roles.yml")]
|
|
39
|
+
expected = files.collect { |file| File.basename(file) }
|
|
40
|
+
assert_equal expected, ["app_one_roles.yml", "app_two_roles.yml"]
|
|
41
|
+
expected = { "admin" => { "categories" => "read, update" } }
|
|
42
|
+
assert_equal expected, Typus::Configuration.roles!
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should "load configuration files from config default" do
|
|
46
|
+
Typus.expects(:config_folder).at_least_once.returns("../config/default")
|
|
47
|
+
assert_not_equal Hash.new, Typus::Configuration.roles!
|
|
48
|
+
assert_not_equal Hash.new, Typus::Configuration.config!
|
|
49
|
+
assert Typus.resources.empty?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class ResourceTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
should "verify default resource configuration options" do
|
|
6
|
+
assert_equal "edit", Typus::Resources.default_action_on_item
|
|
7
|
+
assert Typus::Resources.end_year.nil?
|
|
8
|
+
assert_equal 15, Typus::Resources.form_rows
|
|
9
|
+
assert_equal "edit", Typus::Resources.action_after_save
|
|
10
|
+
assert_equal 5, Typus::Resources.minute_step
|
|
11
|
+
assert_equal "nil", Typus::Resources.human_nil
|
|
12
|
+
assert !Typus::Resources.only_user_items
|
|
13
|
+
assert_equal 15, Typus::Resources.per_page
|
|
14
|
+
assert Typus::Resources.start_year.nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class RoutesTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
setup do
|
|
6
|
+
@routes = Rails.application.routes.routes.map(&:name)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
should "verify admin routes" do
|
|
10
|
+
expected = %w(admin)
|
|
11
|
+
expected.each { |r| assert @routes.include?(r) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "verify admin dashboard routes" do
|
|
15
|
+
expected = %w(admin_dashboard)
|
|
16
|
+
expected.each { |r| assert @routes.include?(r) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should "verify admin account named routes" do
|
|
20
|
+
expected = %w(forgot_password_admin_account_index admin_account_index new_admin_account admin_account)
|
|
21
|
+
expected.each { |r| assert @routes.include?(r) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
should "verify admin session named routes" do
|
|
25
|
+
expected = %w(new_admin_session admin_session)
|
|
26
|
+
expected.each { |r| assert @routes.include?(r) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
data/test/lib/typus_test.rb
CHANGED
|
@@ -1,72 +1,104 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class TypusTest < ActiveSupport::TestCase
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
assert Typus.
|
|
5
|
+
should "verify_default_config" do
|
|
6
|
+
assert_equal "Typus", Typus.admin_title
|
|
7
|
+
assert Typus.admin_sub_title.kind_of?(String)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
should "verify_default_config for authentication" do
|
|
11
|
+
assert_equal :session, Typus.authentication
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "verify_default_config for mailer_sender" do
|
|
15
|
+
assert Typus.mailer_sender.nil?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "verify_default_config for username" do
|
|
19
|
+
assert_equal "admin", Typus.username
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should "verify_default_config for password" do
|
|
23
|
+
assert_equal "columbia", Typus.password
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "verify_default_config for file_preview" do
|
|
27
|
+
assert_equal :medium, Typus.file_preview
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should "verify_default_config for file_thumbnail" do
|
|
31
|
+
assert_equal :thumb, Typus.file_thumbnail
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
should "verify_default_config for relationship" do
|
|
35
|
+
assert_equal "typus_users", Typus.relationship
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "verify_default_config for master_role" do
|
|
39
|
+
assert_equal "admin", Typus.master_role
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "verify_default_config for user_class_name" do
|
|
43
|
+
assert_equal "TypusUser", Typus.user_class_name
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "verify_default_config for typus_user_id" do
|
|
47
|
+
assert_equal "typus_user_id", Typus.user_fk
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
should "verify_default_config for available_locales" do
|
|
51
|
+
assert_equal [:en], Typus.available_locales
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should "verify_config_folder_class" do
|
|
55
|
+
assert Typus.config_folder.kind_of?(Pathname)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
should "return_root" do
|
|
59
|
+
expected = "."
|
|
60
|
+
assert Typus.root.kind_of?(String)
|
|
12
61
|
assert_equal expected, Typus.root
|
|
13
62
|
end
|
|
14
63
|
|
|
15
|
-
|
|
64
|
+
should "return_applications_and_should_be_sorted" do
|
|
16
65
|
assert Typus.respond_to?(:applications)
|
|
17
66
|
assert Typus.applications.kind_of?(Array)
|
|
18
|
-
assert_equal %w(
|
|
67
|
+
assert_equal %w(Blog Site Typus), Typus.applications
|
|
19
68
|
end
|
|
20
69
|
|
|
21
|
-
|
|
70
|
+
should "return_modules_of_an_application" do
|
|
22
71
|
assert Typus.respond_to?(:application)
|
|
23
|
-
assert_equal %w(
|
|
72
|
+
assert_equal %w(Comment Picture Post), Typus.application("Blog")
|
|
24
73
|
end
|
|
25
74
|
|
|
26
|
-
|
|
75
|
+
should "return_models_and_should_be_sorted" do
|
|
27
76
|
assert Typus.respond_to?(:models)
|
|
28
77
|
assert Typus.models.kind_of?(Array)
|
|
29
|
-
assert_equal %w(
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_should_return_an_array_of_models_on_header
|
|
33
|
-
assert Typus.models_on_header.kind_of?(Array)
|
|
34
|
-
assert_equal ["Page"], Typus.models_on_header
|
|
78
|
+
assert_equal %w(Asset Category Comment CustomUser Page Picture Post TypusUser View), Typus.models
|
|
35
79
|
end
|
|
36
80
|
|
|
37
|
-
|
|
81
|
+
should "verify_resources_class_method" do
|
|
38
82
|
assert Typus.respond_to?(:resources)
|
|
39
|
-
assert_equal %w(
|
|
83
|
+
assert_equal %w(Git Order Status WatchDog), Typus.resources
|
|
40
84
|
end
|
|
41
85
|
|
|
42
|
-
|
|
86
|
+
should "return_user_class" do
|
|
43
87
|
assert_equal TypusUser, Typus.user_class
|
|
44
88
|
end
|
|
45
89
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Typus::Configuration.stubs(:options).returns(options)
|
|
90
|
+
should "return_overwritted_user_class" do
|
|
91
|
+
Typus.expects(:user_class_name).returns("CustomUser")
|
|
49
92
|
assert_equal CustomUser, Typus.user_class
|
|
50
93
|
end
|
|
51
94
|
|
|
52
|
-
|
|
53
|
-
assert_equal
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_should_return_overwritted_user_fk
|
|
57
|
-
options = { :user_fk => 'my_user_fk' }
|
|
58
|
-
Typus::Configuration.stubs(:options).returns(options)
|
|
59
|
-
assert_equal 'my_user_fk', Typus.user_fk
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_should_return_relationship
|
|
63
|
-
assert_equal 'typus_users', Typus.relationship
|
|
95
|
+
should "return_user_fk" do
|
|
96
|
+
assert_equal "typus_user_id", Typus.user_fk
|
|
64
97
|
end
|
|
65
98
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Typus
|
|
69
|
-
assert_equal 'my_typus_users', Typus.relationship
|
|
99
|
+
should "return_overwritted_user_fk" do
|
|
100
|
+
Typus.expects(:user_fk).returns("my_user_fk")
|
|
101
|
+
assert_equal "my_user_fk", Typus.user_fk
|
|
70
102
|
end
|
|
71
103
|
|
|
72
|
-
end
|
|
104
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "test_helper"
|
|
2
2
|
|
|
3
3
|
class PaginatorTest < ActiveSupport::TestCase
|
|
4
4
|
|
|
@@ -21,12 +21,15 @@ class PaginatorTest < ActiveSupport::TestCase
|
|
|
21
21
|
assert_equal @pager.last, @pager.page(2).last
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
=begin
|
|
25
|
+
|
|
26
|
+
# FIXME: Problem with paginator.rb.
|
|
25
27
|
def test_can_get_first_page_from_page_object
|
|
26
|
-
return
|
|
27
28
|
assert_equal @pager.first, @pager.page(2).first
|
|
28
29
|
end
|
|
29
30
|
|
|
31
|
+
=end
|
|
32
|
+
|
|
30
33
|
def test_does_not_exceed_per_page
|
|
31
34
|
@pager.each do |page|
|
|
32
35
|
assert page.items.size <= PER_PAGE
|
|
@@ -70,7 +73,7 @@ class PaginatorTest < ActiveSupport::TestCase
|
|
|
70
73
|
page.each_with_index do |item, index|
|
|
71
74
|
assert_equal page.items[index], item
|
|
72
75
|
end
|
|
73
|
-
assert_equal page.items, page.inject([]) {|list, item| list << item }
|
|
76
|
+
assert_equal page.items, page.inject([]) { |list, item| list << item }
|
|
74
77
|
end
|
|
75
78
|
end
|
|
76
79
|
|