typus 3.0.12 → 3.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -16
- data/README.md +7 -10
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/blank.gif +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_close.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_loading.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_nav_left.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_nav_right.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_e.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_n.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_ne.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_nw.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_s.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_se.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_sw.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_w.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_left.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_main.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_over.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_right.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox-x.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox-y.png +0 -0
- data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox.png +0 -0
- data/app/assets/javascripts/typus/application.js +7 -0
- data/app/assets/{vendor/typus/javascripts/application.js → javascripts/typus/custom.js} +0 -0
- data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.application.js +6 -8
- data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.rails.autocomplete.js +0 -0
- data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.searchField.js +0 -0
- data/app/assets/stylesheets/typus/application.css +7 -0
- data/app/assets/{vendor/typus/stylesheets/application.css → stylesheets/typus/custom.css} +0 -0
- data/app/assets/stylesheets/typus/pagination.css +17 -0
- data/app/assets/{vendor/typus/stylesheets → stylesheets/typus}/reset.css +0 -0
- data/app/assets/{vendor/typus/stylesheets → stylesheets/typus}/screen.css +2 -27
- data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input-facebook.css +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input-mac.css +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input.css +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/js/jquery.tokeninput.js +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/jquery-ui-1.8.12.custom.css +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/index.html +0 -0
- data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/js/jquery-ui-1.8.12.custom.min.js +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/blank.gif +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_close.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_loading.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_nav_left.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_nav_right.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_e.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_n.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_ne.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_nw.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_s.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_se.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_sw.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_w.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_left.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_main.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_over.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_right.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox-x.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox-y.png +0 -0
- data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox.png +0 -0
- data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.easing-1.3.pack.js +0 -0
- data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.css +0 -0
- data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.js +0 -0
- data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.pack.js +0 -0
- data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.mousewheel-3.0.4.pack.js +0 -0
- data/app/controllers/admin/base_controller.rb +5 -3
- data/app/controllers/admin/resources_controller.rb +3 -7
- data/app/controllers/admin/session_controller.rb +2 -5
- data/app/helpers/admin/base_helper.rb +1 -1
- data/app/helpers/admin/display_helper.rb +0 -2
- data/app/helpers/admin/file_preview_helper.rb +10 -10
- data/app/helpers/admin/filters_helper.rb +1 -1
- data/app/helpers/admin/relationships_helper.rb +20 -21
- data/app/helpers/admin/sidebar_helper.rb +1 -8
- data/app/helpers/admin/table_helper.rb +8 -8
- data/app/views/admin/dashboard/_applications.html.erb +1 -1
- data/app/views/admin/helpers/base/_apps.html.erb +2 -7
- data/app/views/admin/helpers/base/_header.html.erb +1 -1
- data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +4 -4
- data/app/views/admin/shared/_head.html.erb +2 -17
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +1 -1
- data/app/views/admin/templates/_has_n.html.erb +3 -3
- data/app/views/admin/templates/_has_one.html.erb +2 -2
- data/app/views/admin/templates/_selector.html.erb +7 -2
- data/config/locales/typus.ca.yml +1 -1
- data/config/locales/typus.de.models.yml +5 -6
- data/config/locales/typus.de.yml +36 -39
- data/config/locales/typus.el.yml +1 -1
- data/config/locales/typus.es.yml +1 -1
- data/config/locales/typus.fr.yml +1 -2
- data/config/locales/typus.hu.yml +1 -1
- data/config/locales/typus.locale.yml.template +1 -1
- data/config/locales/typus.pt-BR.yml +1 -1
- data/config/locales/typus.ru.yml +1 -1
- data/config/locales/typus.zh-CN.yml +1 -1
- data/config/routes.rb +2 -2
- data/lib/generators/templates/config/initializers/typus.rb +1 -3
- data/lib/generators/templates/config/typus/README +0 -1
- data/lib/generators/typus/migration_generator.rb +0 -3
- data/lib/support/active_record.rb +7 -9
- data/lib/typus.rb +7 -8
- data/lib/typus/authentication/session.rb +3 -2
- data/lib/typus/controller/associations.rb +2 -2
- data/lib/typus/controller/format.rb +3 -3
- data/lib/typus/engine.rb +2 -6
- data/lib/typus/i18n.rb +4 -0
- data/lib/typus/orm/active_record/admin_user_v1.rb +13 -12
- data/lib/typus/orm/active_record/admin_user_v2.rb +31 -1
- data/lib/typus/orm/active_record/class_methods.rb +1 -0
- data/lib/typus/orm/base.rb +0 -4
- data/lib/typus/regex.rb +2 -0
- data/lib/typus/version.rb +1 -1
- data/test/app/controllers/admin/account_controller_test.rb +94 -0
- data/test/app/controllers/admin/assets_controller_test.rb +156 -0
- data/test/app/controllers/admin/base_controller_test.rb +25 -0
- data/test/app/controllers/admin/birds_controller_test.rb +33 -0
- data/test/app/controllers/admin/cases_controller_test.rb +20 -0
- data/test/app/controllers/admin/categories_controller_test.rb +134 -0
- data/test/app/controllers/admin/comments_controller_test.rb +71 -0
- data/test/app/controllers/admin/dashboard_controller_test.rb +150 -0
- data/test/app/controllers/admin/image_holders_controller_test.rb +74 -0
- data/test/app/controllers/admin/invoices_controller_test.rb +77 -0
- data/test/app/controllers/admin/orders_controller_test.rb +17 -0
- data/test/app/controllers/admin/pages_controller_test.rb +33 -0
- data/test/app/controllers/admin/posts_controller_test.rb +764 -0
- data/test/app/controllers/admin/projects_controller_test.rb +48 -0
- data/test/app/controllers/admin/session_controller_test.rb +91 -0
- data/test/app/controllers/admin/status_controller_test.rb +33 -0
- data/test/app/controllers/admin/typus_users_controller_test.rb +154 -0
- data/test/app/controllers/admin/users_controller_test.rb +101 -0
- data/test/app/controllers/admin/views_controller_test.rb +36 -0
- data/test/app/helpers/admin/base_helper_test.rb +75 -0
- data/test/app/helpers/admin/dashboard_helper_test.rb +28 -0
- data/test/app/helpers/admin/file_preview_helper_test.rb +90 -0
- data/test/app/helpers/admin/filters_helper_test.rb +166 -0
- data/test/app/helpers/admin/form_helper_test.rb +126 -0
- data/test/app/helpers/admin/list_helper_test.rb +76 -0
- data/test/app/helpers/admin/relationships_helper_test.rb +19 -0
- data/test/app/helpers/admin/resources_helper_test.rb +46 -0
- data/test/app/helpers/admin/search_helper_test.rb +56 -0
- data/test/app/helpers/admin/sidebar_helper_test.rb +20 -0
- data/test/app/helpers/admin/table_helper_test.rb +245 -0
- data/test/app/mailers/admin/mailer_test.rb +20 -0
- data/test/app/models/admin_user_test.rb +22 -0
- data/test/app/models/typus_user_roles_test.rb +125 -0
- data/test/app/models/typus_user_test.rb +145 -0
- data/test/app/models/user_test.rb +38 -0
- data/test/config/routes_test.rb +30 -0
- data/test/factories.rb +134 -0
- data/test/fixtures/config/broken/application.yml +68 -0
- data/test/fixtures/config/broken/application_roles.yml +20 -0
- data/test/fixtures/config/broken/empty.yml +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/fixtures/config/broken/undefined.yml +3 -0
- data/test/fixtures/config/broken/undefined_roles.yml +6 -0
- data/test/fixtures/config/default/typus.yml +13 -0
- data/test/fixtures/config/default/typus_roles.yml +2 -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/fixtures/config/locales/es.yml +10 -0
- data/test/fixtures/config/namespaced/application.yml +5 -0
- data/test/fixtures/config/namespaced/application_roles.yml +2 -0
- data/test/fixtures/config/ordered/001_roles.yml +2 -0
- data/test/fixtures/config/ordered/002_roles.yml +2 -0
- data/test/fixtures/config/unordered/app_one_roles.yml +2 -0
- data/test/fixtures/config/unordered/app_two_roles.yml +2 -0
- data/test/fixtures/rails_app/.gitignore +4 -0
- data/test/fixtures/rails_app/Capfile +7 -0
- data/test/fixtures/rails_app/README +256 -0
- data/test/fixtures/rails_app/Rakefile +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/admin_users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/animals_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/article/entries_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +51 -0
- data/test/fixtures/rails_app/app/controllers/admin/birds_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/cases_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/dogs_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/hits_controller.rb +37 -0
- data/test/fixtures/rails_app/app/controllers/admin/image_holders_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/invoices_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/orders_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/project_collaborators_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/projects_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/users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/views_controller.rb +8 -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 +3 -0
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/rails_app/app/helpers/form_helper.rb +3 -0
- data/test/fixtures/rails_app/app/models/admin_user.rb +7 -0
- data/test/fixtures/rails_app/app/models/animal.rb +21 -0
- data/test/fixtures/rails_app/app/models/article.rb +10 -0
- data/test/fixtures/rails_app/app/models/article/entry.rb +2 -0
- data/test/fixtures/rails_app/app/models/asset.rb +45 -0
- data/test/fixtures/rails_app/app/models/bird.rb +2 -0
- data/test/fixtures/rails_app/app/models/case.rb +2 -0
- data/test/fixtures/rails_app/app/models/category.rb +31 -0
- data/test/fixtures/rails_app/app/models/comment.rb +17 -0
- data/test/fixtures/rails_app/app/models/delayed/task.rb +5 -0
- data/test/fixtures/rails_app/app/models/dog.rb +2 -0
- data/test/fixtures/rails_app/app/models/entry.rb +23 -0
- data/test/fixtures/rails_app/app/models/hit.rb +27 -0
- data/test/fixtures/rails_app/app/models/image_holder.rb +21 -0
- data/test/fixtures/rails_app/app/models/invoice.rb +10 -0
- data/test/fixtures/rails_app/app/models/order.rb +9 -0
- data/test/fixtures/rails_app/app/models/page.rb +24 -0
- data/test/fixtures/rails_app/app/models/post.rb +32 -0
- data/test/fixtures/rails_app/app/models/project.rb +17 -0
- data/test/fixtures/rails_app/app/models/project_collaborator.rb +16 -0
- data/test/fixtures/rails_app/app/models/site.rb +16 -0
- data/test/fixtures/rails_app/app/models/typus_user.rb +15 -0
- data/test/fixtures/rails_app/app/models/user.rb +16 -0
- data/test/fixtures/rails_app/app/models/view.rb +19 -0
- data/test/fixtures/rails_app/app/views/admin/assets/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/cases/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/categories/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +11 -0
- data/test/fixtures/rails_app/app/views/admin/entries/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb +7 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/hits/index.html.erb +28 -0
- data/test/fixtures/rails_app/app/views/admin/pages/_index.html.erb +3 -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 +5 -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/resources/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +9 -0
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/watch_dog/index.html.erb +9 -0
- data/test/fixtures/rails_app/config.ru +4 -0
- data/test/fixtures/rails_app/config/application.rb +55 -0
- data/test/fixtures/rails_app/config/boot.rb +6 -0
- data/test/fixtures/rails_app/config/database.yml +42 -0
- data/test/fixtures/rails_app/config/deploy.rb +36 -0
- data/test/fixtures/rails_app/config/environment.rb +5 -0
- data/test/fixtures/rails_app/config/environments/development.rb +38 -0
- data/test/fixtures/rails_app/config/environments/production.rb +57 -0
- data/test/fixtures/rails_app/config/environments/test.rb +44 -0
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/dragonfly.rb +1 -0
- data/test/fixtures/rails_app/config/initializers/inflections.rb +11 -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/wrap_parameters.rb +12 -0
- data/test/fixtures/rails_app/config/locales/en.yml +5 -0
- data/test/fixtures/rails_app/config/mongoid.yml +20 -0
- data/test/fixtures/rails_app/config/routes.rb +61 -0
- data/test/fixtures/rails_app/config/typus/README +68 -0
- data/test/fixtures/rails_app/config/typus/admin.yml +16 -0
- data/test/fixtures/rails_app/config/typus/admin_roles.yml +3 -0
- data/test/fixtures/rails_app/config/typus/crud_basic.yml +10 -0
- data/test/fixtures/rails_app/config/typus/crud_basic_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/crud_extended.yml +66 -0
- data/test/fixtures/rails_app/config/typus/crud_extended_roles.yml +18 -0
- data/test/fixtures/rails_app/config/typus/crud_namespaced.yml +10 -0
- data/test/fixtures/rails_app/config/typus/crud_namespaced_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/has_many.yml +0 -0
- data/test/fixtures/rails_app/config/typus/has_many_roles.yml +0 -0
- data/test/fixtures/rails_app/config/typus/has_many_through.yml +23 -0
- data/test/fixtures/rails_app/config/typus/has_many_through_roles.yml +4 -0
- data/test/fixtures/rails_app/config/typus/has_one.yml +12 -0
- data/test/fixtures/rails_app/config/typus/has_one_roles.yml +3 -0
- data/test/fixtures/rails_app/config/typus/mongo_db.yml +4 -0
- data/test/fixtures/rails_app/config/typus/mongo_db_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/polymorphic.yml +17 -0
- data/test/fixtures/rails_app/config/typus/polymorphic_roles.yml +5 -0
- data/test/fixtures/rails_app/config/typus/resource_roles.yml +7 -0
- data/test/fixtures/rails_app/config/typus/sti.yml +5 -0
- data/test/fixtures/rails_app/config/typus/sti_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/unknown.yml +3 -0
- data/test/fixtures/rails_app/config/typus/unknown_roles.yml +5 -0
- data/test/fixtures/rails_app/db/.gitkeep +0 -0
- data/test/fixtures/rails_app/db/schema.rb +209 -0
- data/test/fixtures/rails_app/db/seeds.rb +58 -0
- data/test/fixtures/rails_app/db/seeds/assets/000.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/001.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/002.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/003.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/004.jpg +0 -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/robots.txt +5 -0
- data/test/fixtures/rails_app/public/stylesheets/.gitkeep +0 -0
- data/test/fixtures/rails_app/script/rails +6 -0
- data/test/lib/support/active_record_test.rb +139 -0
- data/test/lib/support/fake_user_test.rb +63 -0
- data/test/lib/support/hash_test.rb +25 -0
- data/test/lib/support/object_test.rb +10 -0
- data/test/lib/support/string_test.rb +80 -0
- data/test/lib/typus/configuration_test.rb +48 -0
- data/test/lib/typus/controller/actions_test.rb +141 -0
- data/test/lib/typus/controller/associations_test.rb +7 -0
- data/test/lib/typus/controller/autocomplete_test.rb +7 -0
- data/test/lib/typus/controller/filters_test.rb +73 -0
- data/test/lib/typus/controller/format_test.rb +7 -0
- data/test/lib/typus/i18n_test.rb +13 -0
- data/test/lib/typus/orm/active_record/class_methods_test.rb +381 -0
- data/test/lib/typus/orm/active_record/search_test.rb +328 -0
- data/test/lib/typus/regex_test.rb +62 -0
- data/test/lib/typus/resources_test.rb +41 -0
- data/test/lib/typus_test.rb +132 -0
- data/test/test_helper.rb +41 -0
- data/typus.gemspec +3 -10
- metadata +525 -137
- data/.gitmodules +0 -3
- data/app/assets/vendor/typus/javascripts/jquery.rails.js +0 -158
- data/app/assets/vendor/typus/vendor/jquery-ui-1.8.12.custom/js/jquery-1.5.1.min.js +0 -16
- data/app/views/admin/templates/_text_with_ckeditor.html.erb +0 -13
- data/config/locales/typus.pt-PT.models.yml +0 -17
- data/config/locales/typus.pt-PT.yml +0 -83
@@ -0,0 +1,328 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ActiveRecordTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
context "build_search_conditions" do
|
6
|
+
|
7
|
+
should "work for Post (title)" do
|
8
|
+
output = Post.build_search_conditions("search", "bacon")
|
9
|
+
|
10
|
+
expected = case ENV["DB"]
|
11
|
+
when "postgresql"
|
12
|
+
"LOWER(TEXT(posts.title)) LIKE '%bacon%'"
|
13
|
+
else
|
14
|
+
"posts.title LIKE '%bacon%'"
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_equal expected, output
|
18
|
+
end
|
19
|
+
|
20
|
+
should "work for Comment (email, body)" do
|
21
|
+
output = Comment.build_search_conditions("search", "bacon")
|
22
|
+
|
23
|
+
expected = case ENV["DB"]
|
24
|
+
when "postgresql"
|
25
|
+
["LOWER(TEXT(comments.body)) LIKE '%bacon%'",
|
26
|
+
"LOWER(TEXT(comments.email)) LIKE '%bacon%'"]
|
27
|
+
else
|
28
|
+
["comments.body LIKE '%bacon%'",
|
29
|
+
"comments.email LIKE '%bacon%'"]
|
30
|
+
end
|
31
|
+
|
32
|
+
expected.each { |e| assert_match e, output }
|
33
|
+
assert_match /OR/, output
|
34
|
+
end
|
35
|
+
|
36
|
+
should "generate conditions for id" do
|
37
|
+
Post.expects(:typus_defaults_for).with(:search).returns(["id"])
|
38
|
+
|
39
|
+
expected = case ENV["DB"]
|
40
|
+
when "postgresql"
|
41
|
+
"LOWER(TEXT(posts.id)) LIKE '%1%'"
|
42
|
+
else
|
43
|
+
"posts.id LIKE '%1%'"
|
44
|
+
end
|
45
|
+
output = Post.build_search_conditions("search", "1")
|
46
|
+
|
47
|
+
assert_equal expected, output
|
48
|
+
end
|
49
|
+
|
50
|
+
should "generate conditions for fields starting with equal" do
|
51
|
+
Post.expects(:typus_defaults_for).with(:search).returns(["=id"])
|
52
|
+
|
53
|
+
expected = case ENV["DB"]
|
54
|
+
when "postgresql"
|
55
|
+
"LOWER(TEXT(posts.id)) LIKE '1'"
|
56
|
+
else
|
57
|
+
"posts.id LIKE '1'"
|
58
|
+
end
|
59
|
+
output = Post.build_search_conditions("search", "1")
|
60
|
+
|
61
|
+
assert_equal expected, output
|
62
|
+
end
|
63
|
+
|
64
|
+
should "generate conditions for fields starting with ^" do
|
65
|
+
Post.expects(:typus_defaults_for).with(:search).returns(["^id"])
|
66
|
+
|
67
|
+
expected = case ENV["DB"]
|
68
|
+
when "postgresql"
|
69
|
+
"LOWER(TEXT(posts.id)) LIKE '1%'"
|
70
|
+
else
|
71
|
+
"posts.id LIKE '1%'"
|
72
|
+
end
|
73
|
+
output = Post.build_search_conditions("search", "1")
|
74
|
+
|
75
|
+
assert_equal expected, output
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
context "build_boolean_conditions" do
|
81
|
+
|
82
|
+
should "return true" do
|
83
|
+
expected = {'status'=>true}
|
84
|
+
output = Page.build_boolean_conditions('status', 'true')
|
85
|
+
assert_equal expected, output
|
86
|
+
end
|
87
|
+
|
88
|
+
should "return false" do
|
89
|
+
expected = {'status'=>false}
|
90
|
+
output = Page.build_boolean_conditions('status', 'false')
|
91
|
+
assert_equal expected, output
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
context "build_datetime_conditions" do
|
97
|
+
|
98
|
+
setup do
|
99
|
+
@tomorrow = Time.zone.now.beginning_of_day.tomorrow.to_s(:db)
|
100
|
+
end
|
101
|
+
|
102
|
+
[["today", 0.days.ago.beginning_of_day.to_s(:db)],
|
103
|
+
["last_few_days", 3.days.ago.beginning_of_day.to_s(:db)],
|
104
|
+
["last_7_days", 6.days.ago.beginning_of_day.to_s(:db)],
|
105
|
+
["last_30_days", 30.days.ago.beginning_of_day.to_s(:db)]].each do |interval|
|
106
|
+
|
107
|
+
should "generate the condition for #{interval.first}" do
|
108
|
+
output = Article.build_datetime_conditions('created_at', interval.first).first
|
109
|
+
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
110
|
+
end
|
111
|
+
|
112
|
+
should "work for #{interval.first}" do
|
113
|
+
expected = [interval.last, @tomorrow]
|
114
|
+
output = Article.build_datetime_conditions('created_at', interval.first)[1..-1]
|
115
|
+
assert_equal expected, output
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
context "build_date_conditions" do
|
123
|
+
|
124
|
+
setup do
|
125
|
+
@tomorrow = Date.tomorrow.to_s(:db)
|
126
|
+
end
|
127
|
+
|
128
|
+
should "generate the condition for today (which is an special case)" do
|
129
|
+
output = Article.build_date_conditions('created_at', "today").first
|
130
|
+
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
131
|
+
end
|
132
|
+
|
133
|
+
should "work for today (which is an special case)" do
|
134
|
+
expected = [0.days.ago.to_date.to_s(:db), 0.days.ago.tomorrow.to_date.to_s(:db)]
|
135
|
+
output = Article.build_date_conditions('created_at', "today")[1..-1]
|
136
|
+
assert_equal expected, output
|
137
|
+
end
|
138
|
+
|
139
|
+
[["last_few_days", 3.days.ago.to_date.to_s(:db)],
|
140
|
+
["last_7_days", 6.days.ago.to_date.to_s(:db)],
|
141
|
+
["last_30_days", 30.days.ago.to_date.to_s(:db)]].each do |interval|
|
142
|
+
|
143
|
+
should "generate the condition for #{interval.first}" do
|
144
|
+
output = Article.build_date_conditions('created_at', interval.first).first
|
145
|
+
assert_equal "articles.created_at BETWEEN ? AND ?", output
|
146
|
+
end
|
147
|
+
|
148
|
+
should "work for #{interval.first}" do
|
149
|
+
expected = [interval.last, @tomorrow]
|
150
|
+
output = Article.build_date_conditions('created_at', interval.first)[1..-1]
|
151
|
+
assert_equal expected, output
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
context "build_string_conditions" do
|
159
|
+
|
160
|
+
should "work" do
|
161
|
+
expected = {'test'=>'true'}
|
162
|
+
output = Page.build_string_conditions('test', 'true')
|
163
|
+
assert_equal expected, output
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
context "build_has_many_conditions" do
|
169
|
+
|
170
|
+
should "work" do
|
171
|
+
expected = ["projects.id = ?", "1"]
|
172
|
+
output = User.build_has_many_conditions('projects', '1')
|
173
|
+
assert_equal expected, output
|
174
|
+
end
|
175
|
+
|
176
|
+
should_eventually "work for non standard primary keys"
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
context "build_conditions" do
|
181
|
+
|
182
|
+
should "return an array" do
|
183
|
+
params = { :search => '1' }
|
184
|
+
assert Post.build_conditions(params).is_a?(Array)
|
185
|
+
end
|
186
|
+
|
187
|
+
should "return_sql_conditions_on_search_for_typus_user" do
|
188
|
+
expected = case ENV["DB"]
|
189
|
+
when "postgresql"
|
190
|
+
["LOWER(TEXT(typus_users.first_name)) LIKE '%francesc%'",
|
191
|
+
"LOWER(TEXT(typus_users.last_name)) LIKE '%francesc%'",
|
192
|
+
"LOWER(TEXT(typus_users.email)) LIKE '%francesc%'",
|
193
|
+
"LOWER(TEXT(typus_users.role)) LIKE '%francesc%'"]
|
194
|
+
else
|
195
|
+
["typus_users.first_name LIKE '%francesc%'",
|
196
|
+
"typus_users.last_name LIKE '%francesc%'",
|
197
|
+
"typus_users.email LIKE '%francesc%'",
|
198
|
+
"typus_users.role LIKE '%francesc%'"]
|
199
|
+
end
|
200
|
+
|
201
|
+
[{:search =>"francesc"}, {:search => "Francesc"}].each do |params|
|
202
|
+
expected.each do |expect|
|
203
|
+
assert_match expect, TypusUser.build_conditions(params).first
|
204
|
+
end
|
205
|
+
assert_no_match /AND/, TypusUser.build_conditions(params).first
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
should "return_sql_conditions_on_search_and_filter_for_typus_user" do
|
210
|
+
expected = case ENV["DB"]
|
211
|
+
when "postgresql"
|
212
|
+
["LOWER(TEXT(typus_users.role)) LIKE '%francesc%'",
|
213
|
+
"LOWER(TEXT(typus_users.last_name)) LIKE '%francesc%'",
|
214
|
+
"LOWER(TEXT(typus_users.email)) LIKE '%francesc%'",
|
215
|
+
"LOWER(TEXT(typus_users.first_name)) LIKE '%francesc%'"]
|
216
|
+
else
|
217
|
+
["typus_users.first_name LIKE '%francesc%'",
|
218
|
+
"typus_users.last_name LIKE '%francesc%'",
|
219
|
+
"typus_users.email LIKE '%francesc%'",
|
220
|
+
"typus_users.role LIKE '%francesc%'"]
|
221
|
+
end
|
222
|
+
|
223
|
+
params = { :search => "francesc", :status => "true" }
|
224
|
+
|
225
|
+
Factory(:typus_user, :email => "francesc.one@example.com")
|
226
|
+
Factory(:typus_user, :email => "francesc.dos@example.com", :status => false)
|
227
|
+
|
228
|
+
resource = TypusUser
|
229
|
+
resource.build_conditions(params).each do |condition|
|
230
|
+
resource = resource.where(condition)
|
231
|
+
end
|
232
|
+
|
233
|
+
assert_equal ["francesc.one@example.com"], resource.map(&:email)
|
234
|
+
end
|
235
|
+
|
236
|
+
should "return_sql_conditions_on_filtering_typus_users_by_status true" do
|
237
|
+
params = { :status => "true" }
|
238
|
+
expected = { :status => true }
|
239
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
240
|
+
end
|
241
|
+
|
242
|
+
should "return_sql_conditions_on_filtering_typus_users_by_status false" do
|
243
|
+
params = { :status => "false" }
|
244
|
+
expected = { :status => false }
|
245
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
246
|
+
end
|
247
|
+
|
248
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at today" do
|
249
|
+
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
250
|
+
Time.zone.now.beginning_of_day.to_s(:db),
|
251
|
+
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
252
|
+
params = { :created_at => "today" }
|
253
|
+
|
254
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
255
|
+
end
|
256
|
+
|
257
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_few_days" do
|
258
|
+
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
259
|
+
3.days.ago.beginning_of_day.to_s(:db),
|
260
|
+
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
261
|
+
params = { :created_at => "last_few_days" }
|
262
|
+
|
263
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
264
|
+
end
|
265
|
+
|
266
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_7_days" do
|
267
|
+
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
268
|
+
6.days.ago.beginning_of_day.to_s(:db),
|
269
|
+
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
270
|
+
params = { :created_at => "last_7_days" }
|
271
|
+
|
272
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
273
|
+
end
|
274
|
+
|
275
|
+
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_30_days" do
|
276
|
+
expected = ["typus_users.created_at BETWEEN ? AND ?",
|
277
|
+
30.days.ago.beginning_of_day.to_s(:db),
|
278
|
+
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
279
|
+
params = { :created_at => "last_30_days" }
|
280
|
+
|
281
|
+
assert_equal expected, TypusUser.build_conditions(params).first
|
282
|
+
end
|
283
|
+
|
284
|
+
should "return_sql_conditions_on_filtering_posts_by_published_at today" do
|
285
|
+
expected = ["posts.published_at BETWEEN ? AND ?",
|
286
|
+
Time.zone.now.beginning_of_day.to_s(:db),
|
287
|
+
Time.zone.now.beginning_of_day.tomorrow.to_s(:db)]
|
288
|
+
params = { :published_at => "today" }
|
289
|
+
|
290
|
+
assert_equal expected, Post.build_conditions(params).first
|
291
|
+
end
|
292
|
+
|
293
|
+
should "return_sql_conditions_on_filtering_posts_by_string" do
|
294
|
+
params = { :role => "admin" }
|
295
|
+
assert_equal params, TypusUser.build_conditions(params).first
|
296
|
+
end
|
297
|
+
|
298
|
+
end
|
299
|
+
|
300
|
+
context "build_joins" do
|
301
|
+
|
302
|
+
setup do
|
303
|
+
@project = Factory(:project)
|
304
|
+
2.times { Factory(:project) }
|
305
|
+
end
|
306
|
+
|
307
|
+
should "return the expected joins" do
|
308
|
+
params = { :projects => @project.id }
|
309
|
+
assert_equal [:projects], User.build_joins(params)
|
310
|
+
end
|
311
|
+
|
312
|
+
##
|
313
|
+
# Get all user which are on project 1
|
314
|
+
#
|
315
|
+
|
316
|
+
should "work when users are filtered by projects" do
|
317
|
+
params = { :projects => @project.id }
|
318
|
+
|
319
|
+
@resource = User
|
320
|
+
@resource.build_conditions(params).each { |c| @resource = @resource.where(c) }
|
321
|
+
@resource.build_joins(params).each { |j| @resource = @resource.joins(j) }
|
322
|
+
|
323
|
+
assert_equal [@project.user.id], @resource.map(&:id)
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class RegexTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "email_regex matches valid emails" do
|
6
|
+
["john@example.com",
|
7
|
+
"john+locke@example.com",
|
8
|
+
"john.locke@example.com",
|
9
|
+
"john.locke@example.us"].each do |value|
|
10
|
+
assert_match Typus::Regex::Email, value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
test "email_regex not matches invalid emails" do
|
15
|
+
[%Q(this_is_chelm@example.com\n<script>location.href="http://spammersite.com"</script>),
|
16
|
+
"admin",
|
17
|
+
"TEST@EXAMPLE.COM",
|
18
|
+
"test@example",
|
19
|
+
"test@example.c",
|
20
|
+
"testexample.com"].each do |value|
|
21
|
+
assert_no_match Typus::Regex::Email, value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
test "domain_regex matches valid domains" do
|
26
|
+
["example.com",
|
27
|
+
"site1.example.com",
|
28
|
+
"site-with-dash.com",
|
29
|
+
"sub-domain.with-dash.com"].each do |value|
|
30
|
+
assert_match Typus::Regex::Domain, value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
test "domain_regex not matches invalid domains" do
|
35
|
+
["example",
|
36
|
+
"site1_with_underscore.com",
|
37
|
+
"site+with-non-accepted-chars.com"].each do |value|
|
38
|
+
assert_no_match Typus::Regex::Domain, value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
test "uri_regex matches valid urls" do
|
43
|
+
["http://example.com",
|
44
|
+
"http://www.example.com",
|
45
|
+
"http://www.example.es",
|
46
|
+
"http://www.example.co.uk",
|
47
|
+
"http://four.sentenc.es",
|
48
|
+
"http://www.ex-ample.com"].each do |value|
|
49
|
+
assert_match Typus::Regex::Url, value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
test "uri_regex not matches invalid urls" do
|
54
|
+
[%Q(this_is_chelm@example.com\n<script>location.href="http://spammersite.com"</script>),
|
55
|
+
"example.com",
|
56
|
+
"http://examplecom",
|
57
|
+
"http://ex+ample.com"].each do |value|
|
58
|
+
assert_no_match Typus::Regex::Url, value
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ResourcesTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "action_after_save" do
|
6
|
+
assert Typus::Resources.action_after_save.eql?('edit')
|
7
|
+
end
|
8
|
+
|
9
|
+
test "default_action_on_item" do
|
10
|
+
assert Typus::Resources.default_action_on_item.eql?('edit')
|
11
|
+
end
|
12
|
+
|
13
|
+
test "end_year" do
|
14
|
+
assert Typus::Resources.end_year.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
test "form_rows" do
|
18
|
+
assert Typus::Resources.form_rows.eql?(15)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "minute_step" do
|
22
|
+
assert Typus::Resources.minute_step.eql?(5)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "only_user_items" do
|
26
|
+
assert !Typus::Resources.only_user_items
|
27
|
+
end
|
28
|
+
|
29
|
+
test "per_page" do
|
30
|
+
assert Typus::Resources.per_page.eql?(15)
|
31
|
+
end
|
32
|
+
|
33
|
+
test "sortable" do
|
34
|
+
assert Typus::Resources.sortable
|
35
|
+
end
|
36
|
+
|
37
|
+
test "start_year" do
|
38
|
+
assert Typus::Resources.start_year.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TypusTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
should "verify default_config for autocomplete" do
|
6
|
+
assert Typus.autocomplete.nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
should "verify default_config for admin_title" do
|
10
|
+
assert Typus.admin_title.eql?('Typus')
|
11
|
+
end
|
12
|
+
|
13
|
+
should "verify default_config for admin_sub_title" do
|
14
|
+
assert Typus.admin_sub_title.is_a?(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "verify default_config for authentication" do
|
18
|
+
assert Typus.authentication.eql?(:session)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "verify default_config for mailer_sender" do
|
22
|
+
assert Typus.mailer_sender.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
should "verify default_config for username" do
|
26
|
+
assert Typus.username.eql?('admin')
|
27
|
+
end
|
28
|
+
|
29
|
+
should "verify default_config for password" do
|
30
|
+
assert Typus.password.eql?('columbia')
|
31
|
+
end
|
32
|
+
|
33
|
+
context "file management" do
|
34
|
+
|
35
|
+
context "paperclip" do
|
36
|
+
|
37
|
+
should "verify default_config for file_preview" do
|
38
|
+
assert Typus.file_preview.eql?(:medium)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "verify default_config for file_thumbnail" do
|
42
|
+
assert Typus.file_thumbnail.eql?(:thumb)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "dragonfly" do
|
48
|
+
|
49
|
+
should "verify default_config for image_preview_size" do
|
50
|
+
assert Typus.image_preview_size.eql?('x450')
|
51
|
+
end
|
52
|
+
|
53
|
+
should "verify default_config for image_thumb_size" do
|
54
|
+
assert Typus.image_thumb_size.eql?('150x150#')
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
should "verify default_config for relationship" do
|
62
|
+
assert Typus.relationship.eql?('typus_users')
|
63
|
+
end
|
64
|
+
|
65
|
+
should "verify default_config for master_role" do
|
66
|
+
assert Typus.master_role.eql?('admin')
|
67
|
+
end
|
68
|
+
|
69
|
+
should "verify config_folder is a Pathname" do
|
70
|
+
assert Typus.config_folder.is_a?(Pathname)
|
71
|
+
end
|
72
|
+
|
73
|
+
should "return applications sorted" do
|
74
|
+
expected = ["Admin", "CRUD", "CRUD Extended", "CRUD Namespaced", "HasManyThrough", "HasOne", "MongoDB", "Polymorphic", "STI"]
|
75
|
+
assert_equal expected, Typus.applications
|
76
|
+
end
|
77
|
+
|
78
|
+
should "return modules of the CRUD Extended application" do
|
79
|
+
expected = %w(Asset Category Comment Page Post)
|
80
|
+
assert Typus.application("CRUD Extended").eql?(expected)
|
81
|
+
end
|
82
|
+
|
83
|
+
should "return models and should be sorted" do
|
84
|
+
expected = ["Animal",
|
85
|
+
"Article::Entry",
|
86
|
+
"Asset",
|
87
|
+
"Bird",
|
88
|
+
"Case",
|
89
|
+
"Category",
|
90
|
+
"Comment",
|
91
|
+
"Dog",
|
92
|
+
"Entry",
|
93
|
+
"Hit",
|
94
|
+
"ImageHolder",
|
95
|
+
"Invoice",
|
96
|
+
"Order",
|
97
|
+
"Page",
|
98
|
+
"Post",
|
99
|
+
"Project",
|
100
|
+
"ProjectCollaborator",
|
101
|
+
"TypusUser",
|
102
|
+
"User",
|
103
|
+
"View"]
|
104
|
+
assert_equal expected, Typus.models
|
105
|
+
end
|
106
|
+
|
107
|
+
should "verify resources class_method" do
|
108
|
+
assert_equal %w(Git Status WatchDog), Typus.resources
|
109
|
+
end
|
110
|
+
|
111
|
+
test "user_class returns default value" do
|
112
|
+
Typus::Configuration.models_constantized!
|
113
|
+
assert_equal TypusUser, Typus.user_class
|
114
|
+
end
|
115
|
+
|
116
|
+
test "user_class_name returns default value" do
|
117
|
+
assert Typus.user_class_name.eql?("TypusUser")
|
118
|
+
end
|
119
|
+
|
120
|
+
test "user_class_name setter presence" do
|
121
|
+
assert Typus.respond_to?("user_class_name=")
|
122
|
+
end
|
123
|
+
|
124
|
+
test "user_fk returns default value" do
|
125
|
+
assert Typus.user_fk.eql?("typus_user_id")
|
126
|
+
end
|
127
|
+
|
128
|
+
test "user_fk setter presence" do
|
129
|
+
assert Typus.respond_to?("user_fk=")
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|