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,156 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- Asset management like attach (edit) and detach (update).
|
8
|
+
- Assets runnings with a custom template.
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
class Admin::AssetsControllerTest < ActionController::TestCase
|
13
|
+
|
14
|
+
setup do
|
15
|
+
@request.session[:typus_user_id] = Factory(:typus_user).id
|
16
|
+
@post = Factory(:post)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "edit" do
|
20
|
+
|
21
|
+
setup do
|
22
|
+
@asset = Factory(:asset)
|
23
|
+
@request.env['HTTP_REFERER'] = "/admin/assets/edit/#{@asset.id}"
|
24
|
+
end
|
25
|
+
|
26
|
+
should "verify there is a file link" do
|
27
|
+
get :edit, :id => @asset.id
|
28
|
+
assert_match /media/, @response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
should "verify dragonfly can be removed" do
|
32
|
+
get :edit, :id => @asset.id
|
33
|
+
assert_match /Remove/, @response.body
|
34
|
+
|
35
|
+
assert @asset.dragonfly_uid.present?
|
36
|
+
|
37
|
+
get :update, :id => @asset.id, :attribute => "dragonfly"
|
38
|
+
assert_response :redirect
|
39
|
+
assert_redirected_to "/admin/assets/edit/#{@asset.id}"
|
40
|
+
assert_equal "Asset successfully updated.", flash[:notice]
|
41
|
+
|
42
|
+
@asset.reload
|
43
|
+
assert @asset.dragonfly_uid.blank?
|
44
|
+
end
|
45
|
+
|
46
|
+
should "verify dragonfly_required can not removed" do
|
47
|
+
get :edit, :id => @asset.id
|
48
|
+
assert_no_match /Remove required file/, @response.body
|
49
|
+
|
50
|
+
get :update, :id => @asset.id, :attribute => "dragonfly_required"
|
51
|
+
assert_response :success
|
52
|
+
|
53
|
+
@asset.reload
|
54
|
+
assert @asset.dragonfly_required.present?
|
55
|
+
end
|
56
|
+
|
57
|
+
should "verify message on polymorphic relationship" do
|
58
|
+
asset = Factory(:asset)
|
59
|
+
get :edit, :id => asset.id, :resource => @post.class.name, :resource_id => @post.id
|
60
|
+
assert_select 'body div#flash', "Cancel adding a new asset?"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "Headless" do
|
66
|
+
|
67
|
+
should "render index with a custom layout" do
|
68
|
+
get :index, :layout => "admin/headless"
|
69
|
+
assert_response :success
|
70
|
+
assert_template "admin/headless"
|
71
|
+
end
|
72
|
+
|
73
|
+
should "render new with a custom layout" do
|
74
|
+
get :new, :layout => "admin/headless"
|
75
|
+
assert_response :success
|
76
|
+
assert_template "admin/headless"
|
77
|
+
end
|
78
|
+
|
79
|
+
should "render edit with a custom layout" do
|
80
|
+
asset = Factory(:asset)
|
81
|
+
get :edit, :id => asset.id, :layout => "admin/headless"
|
82
|
+
assert_response :success
|
83
|
+
assert_template "admin/headless"
|
84
|
+
end
|
85
|
+
|
86
|
+
context "create" do
|
87
|
+
|
88
|
+
setup do
|
89
|
+
@asset = { :caption => "My Caption",
|
90
|
+
:dragonfly_required => File.new("#{Rails.root}/public/images/rails.png"),
|
91
|
+
:paperclip_required => File.new("#{Rails.root}/public/images/rails.png") }
|
92
|
+
end
|
93
|
+
|
94
|
+
should "redirect to edit with custom layout" do
|
95
|
+
assert_difference('Asset.count') do
|
96
|
+
post :create, :asset => @asset, :layout => "admin/headless"
|
97
|
+
end
|
98
|
+
|
99
|
+
assert_response :redirect
|
100
|
+
assert_redirected_to :action => "edit", :id => Asset.last.id, :layout => "admin/headless"
|
101
|
+
end
|
102
|
+
|
103
|
+
should "redirect to index with custom layout" do
|
104
|
+
Typus::Resources.expects(:action_after_save).returns("index")
|
105
|
+
|
106
|
+
assert_difference('Asset.count') do
|
107
|
+
post :create, :asset => @asset, :layout => "admin/headless"
|
108
|
+
end
|
109
|
+
|
110
|
+
assert_response :redirect
|
111
|
+
assert_redirected_to :action => "index", :layout => "admin/headless"
|
112
|
+
end
|
113
|
+
|
114
|
+
should "render new with custom layout after an error" do
|
115
|
+
post :create, :asset => {}, :layout => "admin/headless"
|
116
|
+
assert_response :success
|
117
|
+
assert_template "new"
|
118
|
+
assert_template "admin/headless"
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
context "update" do
|
124
|
+
|
125
|
+
setup do
|
126
|
+
@asset = Factory(:asset)
|
127
|
+
end
|
128
|
+
|
129
|
+
should "redirect to edit with custom layout" do
|
130
|
+
asset = {:caption => "My Caption", :dragonfly_required => File.new("#{Rails.root}/public/images/rails.png")}
|
131
|
+
post :update, :id => @asset.id, :asset => asset, :layout => "admin/headless"
|
132
|
+
assert_response :redirect
|
133
|
+
assert_redirected_to :action => "edit", :id => @asset.id, :layout => "admin/headless"
|
134
|
+
end
|
135
|
+
|
136
|
+
should "render update with custom layout after an error" do
|
137
|
+
post :update, :id => @asset.id, :asset => { :dragonfly_required => nil }, :layout => "admin/headless"
|
138
|
+
assert_response :success
|
139
|
+
assert_template "admin/helpers/resources/_errors"
|
140
|
+
assert_template "admin/resources/edit"
|
141
|
+
assert_template "admin/headless"
|
142
|
+
end
|
143
|
+
|
144
|
+
should "redirect to index with custom layout" do
|
145
|
+
Typus::Resources.expects(:action_after_save).returns("index")
|
146
|
+
asset = {:caption => "My Caption", :dragonfly_required => File.new("#{Rails.root}/public/images/rails.png")}
|
147
|
+
post :update, :id => @asset.id, :asset => asset, :layout => "admin/headless"
|
148
|
+
assert_response :redirect
|
149
|
+
assert_redirected_to :action => "index", :layout => "admin/headless"
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- Access to user_guide.
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
class Admin::BaseControllerTest < ActionController::TestCase
|
12
|
+
|
13
|
+
test "user_guide is not displayed when user is not logged in" do
|
14
|
+
get :user_guide
|
15
|
+
assert_response :redirect
|
16
|
+
assert_redirected_to new_admin_session_path # (:back_to => '/admin/user_guide')
|
17
|
+
end
|
18
|
+
|
19
|
+
test "user_guide display" do
|
20
|
+
admin_sign_in
|
21
|
+
get :user_guide
|
22
|
+
assert_response :success
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- Polymorphic associations.
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
class Admin::BirdsControllerTest < ActionController::TestCase
|
12
|
+
|
13
|
+
setup do
|
14
|
+
admin_sign_in
|
15
|
+
@bird = Factory(:bird)
|
16
|
+
@image_holder = Factory(:image_holder)
|
17
|
+
@request.env['HTTP_REFERER'] = "/admin/birds/edit/#{@bird.id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
test "relate polymorphic associations" do
|
21
|
+
assert_difference('@bird.image_holders.count') do
|
22
|
+
post :relate, :id => @bird.id,
|
23
|
+
:related => { :model => 'ImageHolder',
|
24
|
+
:id => @image_holder.id,
|
25
|
+
:association_name => 'image_holders' }
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_response :redirect
|
29
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
30
|
+
assert_equal "Bird successfully updated.", flash[:notice]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- Single Table Inheritance Stuff
|
8
|
+
- Relate objects.
|
9
|
+
- Unrelate objects.
|
10
|
+
- Create (and relate objects).
|
11
|
+
|
12
|
+
=end
|
13
|
+
|
14
|
+
class Admin::CasesControllerTest < ActionController::TestCase
|
15
|
+
|
16
|
+
setup do
|
17
|
+
admin_sign_in
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- ActsAsList.
|
8
|
+
- Template Override (TODO: Centralize this!!!)
|
9
|
+
- Unrelate (Post#categories) (has_and_belongs_to_many)
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
class Admin::CategoriesControllerTest < ActionController::TestCase
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@request.session[:typus_user_id] = Factory(:typus_user).id
|
17
|
+
@request.env['HTTP_REFERER'] = '/admin/categories'
|
18
|
+
end
|
19
|
+
|
20
|
+
context "Categories Views" do
|
21
|
+
|
22
|
+
should_eventually "verify form partial can overrided by model" do
|
23
|
+
get :new
|
24
|
+
assert_match "categories#_form.html.erb", @response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
context "Categories List" do
|
30
|
+
|
31
|
+
setup do
|
32
|
+
@first_category = Factory(:category, :position => 1)
|
33
|
+
@second_category = Factory(:category, :position => 2)
|
34
|
+
|
35
|
+
@second_category.name = nil
|
36
|
+
@second_category.save(:validate => false)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "verify referer" do
|
40
|
+
get :position, :id => @first_category.id, :go => 'move_lower'
|
41
|
+
assert_response :redirect
|
42
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
43
|
+
end
|
44
|
+
|
45
|
+
should "position item one step down" do
|
46
|
+
get :position, :id => @first_category.id, :go => 'move_lower'
|
47
|
+
assert_equal "Category successfully updated.", flash[:notice]
|
48
|
+
assert assigns(:item).position.eql?(2)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "position item one step up" do
|
52
|
+
get :position, :id => @second_category.id, :go => 'move_higher'
|
53
|
+
assert assigns(:item).position.eql?(1)
|
54
|
+
end
|
55
|
+
|
56
|
+
should "position top item to bottom" do
|
57
|
+
get :position, :id => @first_category.id, :go => 'move_to_bottom'
|
58
|
+
assert assigns(:item).position.eql?(2)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "position bottom item to top" do
|
62
|
+
get :position, :id => @second_category.id, :go => 'move_to_top'
|
63
|
+
assert assigns(:item).position.eql?(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context "Unrelate (has_and_belongs_to_many)" do
|
69
|
+
|
70
|
+
##
|
71
|
+
# We are in:
|
72
|
+
#
|
73
|
+
# /admin/posts/edit/1
|
74
|
+
#
|
75
|
+
# And we see a list of comments under it:
|
76
|
+
#
|
77
|
+
# /admin/categories/unrelate/1?resource=Post&resource_id=1
|
78
|
+
# /admin/categories/unrelate/2?resource=Post&resource_id=1
|
79
|
+
##
|
80
|
+
|
81
|
+
setup do
|
82
|
+
@category = Factory(:category)
|
83
|
+
@category.posts << Factory(:post)
|
84
|
+
@request.env['HTTP_REFERER'] = "/admin/dashboard"
|
85
|
+
end
|
86
|
+
|
87
|
+
should "unrelate category from post" do
|
88
|
+
assert_difference('@category.posts.count', -1) do
|
89
|
+
post :unrelate, :id => @category.id, :resource => 'Post', :resource_id => @category.posts.first
|
90
|
+
end
|
91
|
+
|
92
|
+
assert_response :redirect
|
93
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
94
|
+
assert_equal "Post successfully updated.", flash[:notice]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Basically we verify Admin::ResourcesController#create_with_back_to works
|
101
|
+
# as expected for STI models.
|
102
|
+
#
|
103
|
+
# We are editing a Case (which is an STI model). And we click on "Add New"
|
104
|
+
# to add a new category. Once create, we will be redirected and the new
|
105
|
+
# category will be assigned to the current case. Easy right?
|
106
|
+
#
|
107
|
+
# /admin/categories/new?back_to=%2Fadmin%2Fcases%2Fedit%1F2&resource=Case&resource_id=2
|
108
|
+
#
|
109
|
+
context "Relate using Add New on STI models" do
|
110
|
+
|
111
|
+
setup do
|
112
|
+
@category = { :name => "Category Name" }
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when editing an item" do
|
116
|
+
|
117
|
+
setup do
|
118
|
+
@case = Factory(:case)
|
119
|
+
end
|
120
|
+
|
121
|
+
should "create new category and redirect to case" do
|
122
|
+
assert_difference('@case.categories.count') do
|
123
|
+
post :create, { :category => @category,
|
124
|
+
:resource => "Case", :resource_id => @case.id }
|
125
|
+
end
|
126
|
+
assert_response :redirect
|
127
|
+
assert_redirected_to "/admin/cases/edit/#{@case.id}"
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
##
|
4
|
+
# What's being tested here?
|
5
|
+
#
|
6
|
+
# - Unrelate "Comment" from "Post" (Post#comments)
|
7
|
+
# - Search by "Posts.title" (Post#comments)
|
8
|
+
#
|
9
|
+
class Admin::CommentsControllerTest < ActionController::TestCase
|
10
|
+
|
11
|
+
setup do
|
12
|
+
@request.session[:typus_user_id] = Factory(:typus_user).id
|
13
|
+
@request.env['HTTP_REFERER'] = '/admin/categories'
|
14
|
+
end
|
15
|
+
|
16
|
+
context "Unrelate" do
|
17
|
+
|
18
|
+
##
|
19
|
+
# We are in:
|
20
|
+
#
|
21
|
+
# /admin/posts/edit/1
|
22
|
+
#
|
23
|
+
# And we see a list of comments under it:
|
24
|
+
#
|
25
|
+
# /admin/comments/unrelate/1?resource=Post&resource_id=1
|
26
|
+
# /admin/comments/unrelate/2?resource=Post&resource_id=1
|
27
|
+
#
|
28
|
+
# Notice that unrelating an item doesn't remove it from database unless
|
29
|
+
# defined on the model.
|
30
|
+
#
|
31
|
+
should "unrelate comment from post" do
|
32
|
+
comment = Factory(:comment)
|
33
|
+
@post = comment.post
|
34
|
+
|
35
|
+
assert_difference('@post.comments.count', -1) do
|
36
|
+
post :unrelate, :id => comment.id, :resource => 'Post', :resource_id => @post.id
|
37
|
+
end
|
38
|
+
|
39
|
+
assert comment.reload.post.nil?
|
40
|
+
|
41
|
+
assert_response :redirect
|
42
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
43
|
+
assert_equal "Post successfully updated.", flash[:notice]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "Search" do
|
49
|
+
|
50
|
+
##
|
51
|
+
# We are in:
|
52
|
+
#
|
53
|
+
# /admin/posts
|
54
|
+
#
|
55
|
+
# And we can search by "posts.title" because "Comment" is belongs_to :post
|
56
|
+
#
|
57
|
+
should "search in Posts.title from Comments list" do
|
58
|
+
post_1 = Factory(:post, :title => "A title with_keyword")
|
59
|
+
comment_1 = Factory(:comment, :post => post_1)
|
60
|
+
|
61
|
+
post_2 = Factory(:post, :title => "A title without_keyword")
|
62
|
+
comment_2 = Factory(:comment, :post => post_2)
|
63
|
+
|
64
|
+
post :index, {:search => "with_keyword" }
|
65
|
+
assert_equal [comment_1], assigns(:items)
|
66
|
+
assert_not_equal [comment_2], assigns(:items)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::DashboardControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "When authentication is http_basic" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
Admin::DashboardController.send :include, Typus::Authentication::HttpBasic
|
9
|
+
end
|
10
|
+
|
11
|
+
should "return a 401 message when no credentials sent" do
|
12
|
+
get :show
|
13
|
+
assert_response :unauthorized
|
14
|
+
end
|
15
|
+
|
16
|
+
should "authenticate user with valid password" do
|
17
|
+
@request.env['HTTP_AUTHORIZATION'] = 'Basic ' + Base64::encode64("admin:columbia")
|
18
|
+
get :show
|
19
|
+
assert_response :success
|
20
|
+
end
|
21
|
+
|
22
|
+
should "not authenticate user with invalid password" do
|
23
|
+
@request.env['HTTP_AUTHORIZATION'] = 'Basic ' + Base64::encode64("admin:admin")
|
24
|
+
get :show
|
25
|
+
assert_response :unauthorized
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "When authentication is none" do
|
31
|
+
|
32
|
+
setup do
|
33
|
+
Admin::DashboardController.send :include, Typus::Authentication::None
|
34
|
+
end
|
35
|
+
|
36
|
+
should "render dashboard" do
|
37
|
+
get :show
|
38
|
+
assert_response :success
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
context "Not logged" do
|
44
|
+
|
45
|
+
setup do
|
46
|
+
reset_session
|
47
|
+
end
|
48
|
+
|
49
|
+
should "redirect to sign in when not signed in" do
|
50
|
+
get :show
|
51
|
+
assert_response :redirect
|
52
|
+
assert_redirected_to new_admin_session_path
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
should "verify_a_removed_role_cannot_sign_in" do
|
58
|
+
typus_user = Factory(:typus_user, :role => "removed")
|
59
|
+
@request.session[:typus_user_id] = typus_user.id
|
60
|
+
|
61
|
+
get :show
|
62
|
+
|
63
|
+
assert_response :redirect
|
64
|
+
assert_redirected_to new_admin_session_path
|
65
|
+
assert_nil @request.session[:typus_user_id]
|
66
|
+
end
|
67
|
+
|
68
|
+
context "Admin is logged and gets dashboard" do
|
69
|
+
|
70
|
+
setup do
|
71
|
+
admin_sign_in
|
72
|
+
get :show
|
73
|
+
end
|
74
|
+
|
75
|
+
teardown do
|
76
|
+
TypusUser.delete_all
|
77
|
+
end
|
78
|
+
|
79
|
+
should "render dashboard" do
|
80
|
+
assert_response :success
|
81
|
+
assert_template "show"
|
82
|
+
end
|
83
|
+
|
84
|
+
should "render admin layout" do
|
85
|
+
assert_template "layouts/admin/base"
|
86
|
+
end
|
87
|
+
|
88
|
+
should "verify title" do
|
89
|
+
assert_select "title", "Typus — Dashboard"
|
90
|
+
end
|
91
|
+
|
92
|
+
should "verify link to session sign out" do
|
93
|
+
link = %(href="/admin/session")
|
94
|
+
assert_match link, @response.body
|
95
|
+
end
|
96
|
+
|
97
|
+
should "verify link to edit user" do
|
98
|
+
link = %(href="/admin/typus_users/edit/#{@request.session[:typus_user_id]})
|
99
|
+
assert_match link, @response.body
|
100
|
+
end
|
101
|
+
|
102
|
+
should "verify we can set our own partials" do
|
103
|
+
partials = %w( _sidebar.html.erb )
|
104
|
+
partials.each { |p| assert_match p, @response.body }
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context "Security" do
|
110
|
+
|
111
|
+
setup do
|
112
|
+
admin_sign_in
|
113
|
+
end
|
114
|
+
|
115
|
+
teardown do
|
116
|
+
TypusUser.delete_all
|
117
|
+
end
|
118
|
+
|
119
|
+
should "block users_on_the_fly" do
|
120
|
+
@typus_user.status = false
|
121
|
+
@typus_user.save
|
122
|
+
|
123
|
+
get :show
|
124
|
+
|
125
|
+
assert_response :redirect
|
126
|
+
assert_redirected_to new_admin_session_path
|
127
|
+
assert_nil @request.session[:typus_user_id]
|
128
|
+
end
|
129
|
+
|
130
|
+
should "sign out user when role does not longer exist" do
|
131
|
+
@typus_user.role = 'unexisting'
|
132
|
+
@typus_user.save
|
133
|
+
|
134
|
+
get :show
|
135
|
+
|
136
|
+
assert_response :redirect
|
137
|
+
assert_redirected_to new_admin_session_path
|
138
|
+
assert_nil @request.session[:typus_user_id]
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
test "designer should not see links to unallowed resources" do
|
144
|
+
designer_sign_in
|
145
|
+
get :show
|
146
|
+
assert_no_match /\/admin\/posts\/new/, @response.body
|
147
|
+
assert_no_match /\/admin\/typus_users\/new/, @response.body
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|