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
data/config/locales/typus.el.yml
CHANGED
@@ -75,7 +75,7 @@ el:
|
|
75
75
|
"You can't change your role": "Δεν έχετε την δυνατότητα να αλλάξετε τον ρόλο σας"
|
76
76
|
"You can't toggle your status": "Δεν επιτρέπεται η αλλαγή της κατάστασής σας"
|
77
77
|
|
78
|
-
"%{errors}
|
78
|
+
"%{errors} prohibited this page from being saved:":
|
79
79
|
"%{model} successfully created": "Το μοντέλο %{model} δημιουργήθηκε επιτυχώς"
|
80
80
|
"%{model} successfully removed": "Το μοντέλο %{model} απομακρύνθηκε επιτυχώς"
|
81
81
|
"%{model} successfully updated": "Το μοντέλο %{model} ανανεώθηκε επιτυχώς"
|
data/config/locales/typus.es.yml
CHANGED
@@ -76,7 +76,7 @@ es:
|
|
76
76
|
"View all %{attribute}":
|
77
77
|
"View site": "Ver web"
|
78
78
|
|
79
|
-
"%{errors}
|
79
|
+
"%{errors} prohibited this page from being saved:":
|
80
80
|
"%{model} successfully created": "%{model} satisfactoriamente creado."
|
81
81
|
"%{model} successfully removed": "%{model} satisfactoriamente eliminado."
|
82
82
|
"%{model} successfully updated": "%{model} satisfactoriamente actualizado."
|
data/config/locales/typus.fr.yml
CHANGED
@@ -22,7 +22,6 @@ fr:
|
|
22
22
|
"Edit": "Éditer"
|
23
23
|
"Edit %{resource}": "Éditer %{resource}"
|
24
24
|
"Enter your email below to create the first user": "Entrez votre adresse email pour créer le premier utilisateur"
|
25
|
-
"Export as %{mime}": "Exporter en %{mime}"
|
26
25
|
|
27
26
|
"False": "Faux"
|
28
27
|
"Filter": "Filtrer"
|
@@ -81,7 +80,7 @@ fr:
|
|
81
80
|
"You can't change your role": "Vous ne pouvez pas changer votre propre rôle."
|
82
81
|
"You can't toggle your status": "Vous ne pouvez pas basculer votre statut"
|
83
82
|
|
84
|
-
"%{errors}
|
83
|
+
"%{errors} prohibited this page from being saved:":
|
85
84
|
"%{model} successfully created": "%{model} correctement créé(e)."
|
86
85
|
"%{model} successfully removed": "%{model} correctement supprimé(e)."
|
87
86
|
"%{model} successfully updated": "%{model} correctement mis(e)-à-jour."
|
data/config/locales/typus.hu.yml
CHANGED
@@ -74,7 +74,7 @@ hu:
|
|
74
74
|
"You can't change your role": "Nincsen jogod megváltoztatni a jogosultsági szintedet"
|
75
75
|
"You can't toggle your status": "Nincs jogod változtatni a státuszodat"
|
76
76
|
|
77
|
-
"%{errors}
|
77
|
+
"%{errors} prohibited this page from being saved:":
|
78
78
|
"%{model} successfully created": "%{model} sikeresen létrehozva"
|
79
79
|
"%{model} successfully removed": "%{model} sikeresen törölve"
|
80
80
|
"%{model} successfully updated": "%{model} sikereseb frissítve"
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"You can't change your role":
|
76
76
|
"You can't toggle your status":
|
77
77
|
|
78
|
-
"%{errors}
|
78
|
+
"%{errors} prohibited this page from being saved:":
|
79
79
|
"%{model} successfully created":
|
80
80
|
"%{model} successfully removed":
|
81
81
|
"%{model} successfully updated":
|
@@ -74,7 +74,7 @@ pt-BR:
|
|
74
74
|
"You can update your password at": "Você pode atualizar sua senha em"
|
75
75
|
"You can't change your role": "Você não pode mudar sua própria função no sistema."
|
76
76
|
|
77
|
-
"%{errors}
|
77
|
+
"%{errors} prohibited this page from being saved:":
|
78
78
|
"%{model} successfully created": "%{model} criado com sucesso."
|
79
79
|
"%{model} successfully removed": "%{model} removido com sucesso."
|
80
80
|
"%{model} successfully updated": "%{model} atualizado com sucesso."
|
data/config/locales/typus.ru.yml
CHANGED
@@ -74,7 +74,7 @@ ru:
|
|
74
74
|
"You can't change your role": "Вы не можете менять свою собственную роль"
|
75
75
|
"You can't toggle your status": "Вы не можете менять свой статус"
|
76
76
|
|
77
|
-
"%{errors}
|
77
|
+
"%{errors} prohibited this page from being saved:":
|
78
78
|
"%{model} successfully created": "%{model} создан"
|
79
79
|
"%{model} successfully removed": "%{model} удален"
|
80
80
|
"%{model} successfully updated": "%{model} успешно обновлен"
|
@@ -73,7 +73,7 @@ zh-CN:
|
|
73
73
|
"You can't change your role": "你不能修改你的角色"
|
74
74
|
"You can't toggle your status": "你不能修改自己的状态"
|
75
75
|
|
76
|
-
"%{errors}
|
76
|
+
"%{errors} prohibited this page from being saved:":
|
77
77
|
"%{model} successfully created": "%{model} 创建成功"
|
78
78
|
"%{model} successfully removed": "%{model} 删除成功"
|
79
79
|
"%{model} successfully updated": "%{model} 更新成功"
|
data/config/routes.rb
CHANGED
@@ -19,11 +19,11 @@ Rails.application.routes.draw do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
Typus.models.map { |i| i.to_resource }.each do |resource|
|
22
|
-
match "#{resource}(/:action(/:id(.:format)
|
22
|
+
match "#{resource}(/:action(/:id))(.:format)", :controller => resource
|
23
23
|
end
|
24
24
|
|
25
25
|
Typus.resources.map { |i| i.underscore }.each do |resource|
|
26
|
-
match "#{resource}(/:action(/:id(.:format)
|
26
|
+
match "#{resource}(/:action(/:id))(.:format)", :controller => resource
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -20,9 +20,7 @@ Typus.setup do |config|
|
|
20
20
|
# config.username = "admin"
|
21
21
|
# config.password = "columbia"
|
22
22
|
|
23
|
-
# Pagination options:
|
24
|
-
# These options are passed to `will_paginate`. You can see the available
|
25
|
-
# options in the plugin source. (https://github.com/mislav/will_paginate/blob/rails3/lib/will_paginate/view_helpers.rb)
|
23
|
+
# Pagination options: These options are passed to `kaminari`.
|
26
24
|
# config.pagination = { :previous_label => "← " + Typus::I18n.t("Previous"),
|
27
25
|
# :next_label => Typus::I18n.t("Next") + " →" }
|
28
26
|
|
@@ -25,7 +25,13 @@ class ActiveRecord::Base
|
|
25
25
|
# => "Publicado"
|
26
26
|
#++
|
27
27
|
def mapping(attribute)
|
28
|
-
|
28
|
+
klass = self.class
|
29
|
+
values = if klass.const_defined?(attribute.upcase)
|
30
|
+
klass::const_get(attribute.upcase)
|
31
|
+
else
|
32
|
+
klass.send(attribute)
|
33
|
+
end
|
34
|
+
|
29
35
|
array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
|
30
36
|
|
31
37
|
value = array.rassoc(send(attribute))
|
@@ -40,12 +46,4 @@ class ActiveRecord::Base
|
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
|
-
def self.namespaced?
|
44
|
-
name.match(/::/)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.namespace
|
48
|
-
name.split("::").first if self.namespaced?
|
49
|
-
end
|
50
|
-
|
51
49
|
end
|
data/lib/typus.rb
CHANGED
@@ -11,8 +11,7 @@ require "typus/orm/active_record"
|
|
11
11
|
require "typus/regex"
|
12
12
|
require "typus/version"
|
13
13
|
|
14
|
-
require "
|
15
|
-
require "will_paginate"
|
14
|
+
require "kaminari"
|
16
15
|
|
17
16
|
autoload :FakeUser, "support/fake_user"
|
18
17
|
|
@@ -46,7 +45,7 @@ module Typus
|
|
46
45
|
|
47
46
|
mattr_accessor :admin_sub_title
|
48
47
|
@@admin_sub_title = <<-CODE
|
49
|
-
<a href="http://core.typuscms.com/">
|
48
|
+
<a href="http://core.typuscms.com/">core.typuscms.com</a>
|
50
49
|
CODE
|
51
50
|
|
52
51
|
##
|
@@ -66,10 +65,11 @@ module Typus
|
|
66
65
|
@@username = "admin"
|
67
66
|
|
68
67
|
##
|
69
|
-
# Pagination options
|
68
|
+
# Pagination options passed to Kaminari helper.
|
70
69
|
#
|
71
70
|
mattr_accessor :pagination
|
72
|
-
@@pagination = { :
|
71
|
+
@@pagination = { :window => 0,
|
72
|
+
:previous_label => "← " + Typus::I18n.t("Previous"),
|
73
73
|
:next_label => Typus::I18n.t("Next") + " →" }
|
74
74
|
|
75
75
|
##
|
@@ -137,7 +137,7 @@ module Typus
|
|
137
137
|
|
138
138
|
# Lists modules of an application.
|
139
139
|
def application(name)
|
140
|
-
Typus::Configuration.config.map { |i| i.first if i.last["application"] == name }.compact.uniq
|
140
|
+
Typus::Configuration.config.map { |i| i.first if i.last["application"] == name }.compact.uniq.sort
|
141
141
|
end
|
142
142
|
|
143
143
|
# Lists models from the configuration file.
|
@@ -175,8 +175,7 @@ module Typus
|
|
175
175
|
"Français" => "fr",
|
176
176
|
"Magyar" => "hu",
|
177
177
|
"Italiano" => "It",
|
178
|
-
"Portuguese" => "pt-
|
179
|
-
"Brazilian Portuguese" => "pt-BR",
|
178
|
+
"Portuguese" => "pt-BR",
|
180
179
|
"Russian" => "ru",
|
181
180
|
"中文" => "zh-CN" }
|
182
181
|
end
|
@@ -10,8 +10,9 @@ module Typus
|
|
10
10
|
if session[:typus_user_id]
|
11
11
|
admin_user
|
12
12
|
else
|
13
|
-
back_to = request.env['PATH_INFO'] unless [
|
14
|
-
redirect_to
|
13
|
+
# back_to = request.env['PATH_INFO'] unless [root_path].include?(request.env['PATH_INFO'])
|
14
|
+
# redirect_to new_session_path(:back_to => back_to)
|
15
|
+
redirect_to new_admin_session_path
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -62,7 +62,7 @@ module Typus
|
|
62
62
|
if worked
|
63
63
|
notice = Typus::I18n.t("%{model} successfully updated.", :model => item_class.model_name.human)
|
64
64
|
else
|
65
|
-
alert = item.
|
65
|
+
alert = item.error.full_messages
|
66
66
|
end
|
67
67
|
|
68
68
|
redirect_to :back, :notice => notice, :alert => alert
|
@@ -126,7 +126,7 @@ module Typus
|
|
126
126
|
#
|
127
127
|
def set_belongs_to_association(item_class, options)
|
128
128
|
association_name = item_class.model_name.tableize.to_sym
|
129
|
-
foreign_key = @resource.reflect_on_association(association_name).
|
129
|
+
foreign_key = @resource.reflect_on_association(association_name).foreign_key
|
130
130
|
|
131
131
|
if params[:resource_id]
|
132
132
|
item = item_class.find(params[:resource_id])
|
@@ -1,8 +1,8 @@
|
|
1
1
|
if RUBY_VERSION >= '1.9'
|
2
2
|
require 'csv'
|
3
|
-
FasterCSV = CSV
|
4
3
|
else
|
5
4
|
require 'fastercsv'
|
5
|
+
CSV = FasterCSV
|
6
6
|
end
|
7
7
|
|
8
8
|
module Typus
|
@@ -13,7 +13,7 @@ module Typus
|
|
13
13
|
|
14
14
|
def generate_html
|
15
15
|
items_per_page = @resource.typus_options_for(:per_page)
|
16
|
-
@items = @resource.
|
16
|
+
@items = @resource.page(params[:page]).per(items_per_page)
|
17
17
|
end
|
18
18
|
|
19
19
|
#--
|
@@ -28,7 +28,7 @@ module Typus
|
|
28
28
|
|
29
29
|
options = { :conditions => @conditions, :batch_size => 1000 }
|
30
30
|
|
31
|
-
::
|
31
|
+
::CSV.open(filename, 'w', :col_sep => ';') do |csv|
|
32
32
|
csv << fields.keys
|
33
33
|
@resource.find_in_batches(options) do |records|
|
34
34
|
records.each do |record|
|
data/lib/typus/engine.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
module
|
1
|
+
module Admin
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
|
4
|
-
|
5
|
-
if app.config.serve_static_assets
|
6
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/app/assets"
|
7
|
-
end
|
8
|
-
end
|
4
|
+
# isolate_namespace Admin
|
9
5
|
|
10
6
|
end
|
11
7
|
end
|
data/lib/typus/i18n.rb
CHANGED
@@ -12,10 +12,7 @@ module Typus
|
|
12
12
|
attr_accessor :password
|
13
13
|
attr_protected :status
|
14
14
|
|
15
|
-
validates :email,
|
16
|
-
:presence => true,
|
17
|
-
:uniqueness => true,
|
18
|
-
:format => { :with => Typus::Regex::Email }
|
15
|
+
validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
|
19
16
|
|
20
17
|
validates :password,
|
21
18
|
:confirmation => { :if => :password_required? },
|
@@ -25,7 +22,7 @@ module Typus
|
|
25
22
|
|
26
23
|
validates :role, :presence => true
|
27
24
|
|
28
|
-
before_save :initialize_salt, :encrypt_password, :
|
25
|
+
before_save :initialize_salt, :encrypt_password, :set_token
|
29
26
|
|
30
27
|
serialize :preferences
|
31
28
|
|
@@ -36,11 +33,19 @@ module Typus
|
|
36
33
|
|
37
34
|
def generate(*args)
|
38
35
|
options = args.extract_options!
|
39
|
-
options[:password] ||=
|
36
|
+
options[:password] ||= Typus.password
|
40
37
|
options[:role] ||= Typus.master_role
|
41
38
|
new :email => options[:email], :password => options[:password], :role => options[:role]
|
42
39
|
end
|
43
40
|
|
41
|
+
def role
|
42
|
+
Typus::Configuration.roles.keys.sort
|
43
|
+
end
|
44
|
+
|
45
|
+
def locale
|
46
|
+
Typus.locales
|
47
|
+
end
|
48
|
+
|
44
49
|
include InstanceMethods
|
45
50
|
include Typus::Orm::ActiveRecord::User::InstanceMethods
|
46
51
|
|
@@ -73,12 +78,8 @@ module Typus
|
|
73
78
|
self.salt = generate_hash("--#{Time.zone.now.to_s(:number)}--#{email}--") if new_record?
|
74
79
|
end
|
75
80
|
|
76
|
-
def
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def generate_token
|
81
|
-
self.token = encrypt("--#{Time.zone.now.to_s(:number)}--#{password}--").first(12)
|
81
|
+
def set_token
|
82
|
+
self.token = "#{ActiveSupport::SecureRandom.hex(3)}-#{ActiveSupport::SecureRandom.hex(3)}"
|
82
83
|
end
|
83
84
|
|
84
85
|
def password_required?
|
@@ -12,14 +12,34 @@ module Typus
|
|
12
12
|
|
13
13
|
attr_reader :password
|
14
14
|
attr_accessor :password_confirmation
|
15
|
+
attr_protected :status
|
15
16
|
|
16
17
|
validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
|
17
|
-
validates :password, :confirmation => true
|
18
|
+
validates :password, :confirmation => true
|
18
19
|
validates :password_digest, :presence => true
|
19
20
|
|
21
|
+
validate :password_must_be_strong
|
22
|
+
|
20
23
|
include InstanceMethodsOnActivation
|
21
24
|
include Typus::Orm::ActiveRecord::User::InstanceMethods
|
22
25
|
|
26
|
+
serialize :preferences
|
27
|
+
|
28
|
+
before_save :set_token
|
29
|
+
|
30
|
+
def self.role
|
31
|
+
Typus::Configuration.roles.keys.sort
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.locale
|
35
|
+
Typus.locales
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.authenticate(email, password)
|
39
|
+
user = find_by_email_and_status(email, true)
|
40
|
+
user && user.authenticate(password) ? user : nil
|
41
|
+
end
|
42
|
+
|
23
43
|
end
|
24
44
|
|
25
45
|
end
|
@@ -41,6 +61,16 @@ module Typus
|
|
41
61
|
self.password_digest = BCrypt::Password.create(unencrypted_password)
|
42
62
|
end
|
43
63
|
|
64
|
+
def set_token
|
65
|
+
self.token = "#{ActiveSupport::SecureRandom.hex(6)}-#{ActiveSupport::SecureRandom.hex(6)}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def password_must_be_strong
|
69
|
+
if password.present?
|
70
|
+
errors.add(:password, :too_short, :count => 7) unless password.size > 6
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
44
74
|
end
|
45
75
|
|
46
76
|
end
|
data/lib/typus/orm/base.rb
CHANGED
@@ -79,10 +79,6 @@ module Typus
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
def typus_export_formats
|
83
|
-
read_model_config['export'].try(:extract_settings) || []
|
84
|
-
end
|
85
|
-
|
86
82
|
def typus_order_by
|
87
83
|
typus_defaults_for(:order_by).map do |field|
|
88
84
|
field.include?('-') ? "#{table_name}.#{field.delete('-')} DESC" : "#{table_name}.#{field} ASC"
|
data/lib/typus/regex.rb
CHANGED
data/lib/typus/version.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
What's being tested here?
|
6
|
+
|
7
|
+
- Create first user. (/admin/account/new)
|
8
|
+
- Stuff that happens when there are already users.
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
class Admin::AccountControllerTest < ActionController::TestCase
|
13
|
+
|
14
|
+
context "No users" do
|
15
|
+
|
16
|
+
should "render new when there are not admin users" do
|
17
|
+
get :new
|
18
|
+
|
19
|
+
assert_response :success
|
20
|
+
assert_template "new"
|
21
|
+
assert_template "layouts/admin/session"
|
22
|
+
assert_equal "Enter your email below to create the first user.", flash[:notice]
|
23
|
+
end
|
24
|
+
|
25
|
+
should "verify forgot_password redirects to new when there are no admin users" do
|
26
|
+
get :forgot_password
|
27
|
+
assert_response :redirect
|
28
|
+
assert_redirected_to new_admin_account_path
|
29
|
+
end
|
30
|
+
|
31
|
+
should "verify send_password redirects to new when there are no admin users"
|
32
|
+
|
33
|
+
should "not sign_up invalid emails" do
|
34
|
+
post :create, :typus_user => { :email => "example.com" }
|
35
|
+
assert_response :redirect
|
36
|
+
assert_redirected_to :action => :new
|
37
|
+
assert flash.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
should "sign_up a valid email" do
|
41
|
+
assert_difference('TypusUser.count') { post :create, :typus_user => { :email => "john@example.com" } }
|
42
|
+
assert_response :redirect
|
43
|
+
assert_redirected_to :action => "show", :id => TypusUser.find_by_email("john@example.com").token
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "There are users" do
|
49
|
+
|
50
|
+
setup do
|
51
|
+
@typus_user = Factory(:typus_user)
|
52
|
+
end
|
53
|
+
|
54
|
+
should "new redirect new admin session when there are admin users" do
|
55
|
+
get :new
|
56
|
+
assert_response :redirect
|
57
|
+
assert_redirected_to new_admin_session_path
|
58
|
+
end
|
59
|
+
|
60
|
+
should "verify forgot_password is rendered when there are admin users" do
|
61
|
+
get :forgot_password
|
62
|
+
assert_response :success
|
63
|
+
assert_template "forgot_password"
|
64
|
+
end
|
65
|
+
|
66
|
+
should "not_send_recovery_password_link_to_unexisting_user" do
|
67
|
+
post :send_password, :typus_user => { :email => "unexisting" }
|
68
|
+
assert_response :success
|
69
|
+
assert flash.empty?
|
70
|
+
end
|
71
|
+
|
72
|
+
should "test_should_send_recovery_password_link_to_existing_user" do
|
73
|
+
post :send_password, :typus_user => { :email => @typus_user.email }
|
74
|
+
assert_response :redirect
|
75
|
+
assert_redirected_to new_admin_session_path
|
76
|
+
assert_equal "Password recovery link sent to your email.", flash[:notice]
|
77
|
+
end
|
78
|
+
|
79
|
+
should "test_should_create_admin_user_session_and_redirect_user_to_its_details" do
|
80
|
+
get :show, :id => @typus_user.token
|
81
|
+
assert_equal @typus_user.id, @request.session[:typus_user_id]
|
82
|
+
assert_response :redirect
|
83
|
+
assert_redirected_to :controller => "/admin/typus_users", :action => "edit", :id => @typus_user.id
|
84
|
+
end
|
85
|
+
|
86
|
+
should "test_should_return_404_on_reset_passsword_if_token_is_not_valid" do
|
87
|
+
assert_raises ActiveRecord::RecordNotFound do
|
88
|
+
get :show, :id => "unexisting"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|