typus 0.9.39 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +104 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +96 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +45 -0
- data/Rakefile +19 -48
- data/app/controllers/admin/account_controller.rb +54 -0
- data/app/controllers/admin/dashboard_controller.rb +7 -0
- data/app/controllers/admin/resource_controller.rb +8 -0
- data/app/controllers/admin/resources_controller.rb +307 -0
- data/app/controllers/admin/session_controller.rb +38 -0
- data/app/controllers/admin_controller.rb +26 -0
- data/app/helpers/admin/dashboard_helper.rb +38 -0
- data/app/helpers/admin/filters_helper.rb +81 -0
- data/app/helpers/admin/form_helper.rb +68 -261
- data/app/helpers/admin/preview_helper.rb +48 -0
- data/app/helpers/admin/relationships_helper.rb +192 -0
- data/app/helpers/admin/resources_helper.rb +80 -0
- data/app/helpers/admin/search_helper.rb +19 -0
- data/app/helpers/admin/sidebar_helper.rb +32 -210
- data/app/helpers/admin/table_helper.rb +207 -200
- data/app/helpers/admin_helper.rb +56 -0
- data/app/mailers/admin/mailer.rb +13 -0
- data/app/models/admin/fake_user.rb +38 -0
- data/app/views/admin/account/forgot_password.html.erb +21 -0
- data/app/views/admin/account/new.html.erb +21 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +3 -3
- data/app/views/admin/dashboard/show.html.erb +16 -0
- data/app/views/admin/dashboard/styles.html.erb +154 -0
- data/app/views/admin/helpers/_apps.html.erb +6 -0
- data/app/views/admin/helpers/_flash_message.html.erb +3 -0
- data/app/views/admin/helpers/_header.html.erb +7 -0
- data/app/views/admin/helpers/_login_info.html.erb +4 -0
- data/app/views/admin/helpers/_preview.html.erb +13 -0
- data/app/views/admin/helpers/dashboard/_applications.html.erb +32 -0
- data/app/views/admin/helpers/dashboard/_resources.html.erb +16 -0
- data/app/views/admin/helpers/filters/_filters.html.erb +31 -0
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +3 -0
- data/app/views/admin/helpers/resources/_pagination.html.erb +28 -0
- data/app/views/admin/helpers/search/_search.html.erb +12 -0
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +17 -0
- data/app/views/admin/helpers/table/_table.html.erb +22 -0
- data/app/views/{typus_mailer/reset_password_link.erb → admin/mailer/reset_password_link.text.erb} +2 -2
- data/{test/config/broken/empty.yml → app/views/admin/resources/_edit.html.erb} +0 -0
- data/app/views/admin/resources/_form.html.erb +26 -0
- data/{test/config/broken/empty_roles.yml → app/views/admin/resources/_index.html.erb} +0 -0
- data/{test/config/empty/empty_01.yml → app/views/admin/resources/_new.html.erb} +0 -0
- data/{test/config/empty/empty_01_roles.yml → app/views/admin/resources/_show.html.erb} +0 -0
- data/app/views/admin/resources/edit.html.erb +23 -21
- data/app/views/admin/resources/index.html.erb +31 -18
- data/app/views/admin/resources/new.html.erb +20 -18
- data/app/views/admin/resources/show.html.erb +29 -20
- data/app/views/admin/session/new.html.erb +26 -0
- data/app/views/admin/templates/_belongs_to.html.erb +4 -0
- data/app/views/admin/templates/_boolean.html.erb +4 -8
- data/app/views/admin/templates/_date.html.erb +9 -2
- data/app/views/admin/templates/_datetime.html.erb +9 -2
- data/app/views/admin/templates/_file.html.erb +20 -5
- data/app/views/admin/templates/_has_many.html.erb +24 -0
- data/app/views/admin/templates/_has_n.html.erb +17 -0
- data/{test/config/empty/empty_02.yml → app/views/admin/templates/_has_one.html.erb} +0 -0
- data/app/views/admin/templates/_password.html.erb +4 -2
- data/app/views/admin/templates/_relate_form.html.erb +4 -0
- data/app/views/admin/templates/_selector.html.erb +6 -18
- data/app/views/admin/templates/_string.html.erb +11 -10
- data/app/views/admin/templates/_text.html.erb +9 -2
- data/app/views/admin/templates/_time.html.erb +9 -2
- data/app/views/admin/templates/_tree.html.erb +4 -0
- data/app/views/layouts/admin/session.html.erb +44 -0
- data/app/views/layouts/admin.html.erb +45 -39
- data/config/available_locales/ca.yml +124 -0
- data/config/available_locales/ca_models.yml +16 -0
- data/config/{locales → available_locales}/de.yml +108 -89
- data/config/available_locales/de_models.yml +13 -0
- data/config/available_locales/es.yml +124 -0
- data/config/available_locales/es_models.yml +13 -0
- data/config/available_locales/fr.yml +124 -0
- data/config/available_locales/fr_models.yml +13 -0
- data/config/available_locales/hu.yml +124 -0
- data/config/available_locales/hu_models.yml +13 -0
- data/config/available_locales/it.yml +136 -0
- data/config/available_locales/it_models.yml +15 -0
- data/config/available_locales/language.yml.template +122 -0
- data/config/available_locales/language_models.yml.template +13 -0
- data/config/{locales → available_locales}/pt-BR.yml +97 -74
- data/config/available_locales/pt-BR_models.yml +13 -0
- data/config/{locales → available_locales}/ru.yml +107 -85
- data/config/available_locales/ru_models.yml +13 -0
- data/config/routes.rb +18 -11
- data/lib/generators/templates/config/initializers/typus.rb +26 -0
- data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
- data/lib/generators/templates/config/initializers/typus_resources.rb +30 -0
- data/{generators/typus → lib/generators}/templates/config/typus/README +34 -16
- data/lib/generators/templates/config/typus/application.yml +5 -0
- data/lib/generators/templates/config/typus/application_roles.yml +6 -0
- data/lib/generators/templates/config/typus/typus.yml +17 -0
- data/lib/generators/templates/config/typus/typus_roles.yml +6 -0
- data/lib/generators/templates/controller.rb +4 -0
- data/lib/generators/templates/functional_test.rb +21 -0
- data/{generators/typus/templates/db/create_typus_users.rb → lib/generators/templates/migration.rb} +4 -4
- data/lib/generators/templates/model.rb +8 -0
- data/lib/generators/templates/model.yml +10 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/images}/ui-icons.png +0 -0
- data/lib/generators/templates/public/admin/javascripts/application.js +6 -0
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +126 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.searchField.js +91 -0
- data/lib/generators/templates/public/admin/stylesheets/application.css +11 -0
- data/lib/generators/templates/public/admin/stylesheets/screen.css +356 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/blank.gif +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_close.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_e.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_n.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_ne.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_nw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_s.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_se.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_sw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_w.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_main.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_over.png +0 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/vendor}/fancybox/fancy_title_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-x.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-y.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +72 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +1077 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
- data/lib/generators/templates/view.html.erb +9 -0
- data/lib/generators/typus/migration_generator.rb +85 -0
- data/lib/generators/typus/typus_generator.rb +190 -0
- data/lib/generators/typus/views_generator.rb +27 -0
- data/lib/support/active_record.rb +60 -0
- data/lib/support/array.rb +13 -0
- data/lib/{typus → support}/hash.rb +2 -2
- data/lib/{typus → support}/object.rb +2 -2
- data/lib/support/string.rb +47 -0
- data/lib/tasks/typus.rake +19 -0
- data/lib/typus/authentication.rb +146 -40
- data/lib/typus/configuration.rb +14 -49
- data/lib/typus/engine.rb +6 -0
- data/lib/typus/format.rb +41 -18
- data/lib/typus/orm/active_record.rb +378 -0
- data/lib/typus/resources.rb +57 -0
- data/lib/typus/user.rb +54 -37
- data/lib/typus/version.rb +3 -0
- data/lib/typus.rb +118 -80
- data/lib/vendor/paginator.rb +2 -2
- data/test/factories/assets.rb +5 -0
- data/test/factories/categories.rb +3 -0
- data/test/factories/comments.rb +6 -0
- data/test/factories/pages.rb +5 -0
- data/test/factories/pictures.rb +7 -0
- data/test/factories/posts.rb +6 -0
- data/test/factories/typus_users.rb +8 -0
- data/test/{config → fixtures/config}/broken/application.yml +0 -0
- data/test/{config → fixtures/config}/broken/application_roles.yml +0 -0
- data/test/{config/empty/empty_02_roles.yml → fixtures/config/broken/empty.yml} +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined_roles.yml +0 -0
- data/test/{config → fixtures/config}/default/typus.yml +2 -1
- data/{generators/typus/templates/config/typus → test/fixtures/config/default}/typus_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/{config → fixtures/config}/locales/es.yml +0 -0
- data/test/fixtures/config/namespaced/application.yml +5 -0
- data/test/fixtures/config/namespaced/application_roles.yml +2 -0
- data/test/{config → fixtures/config}/ordered/001_roles.yml +0 -0
- data/test/{config → fixtures/config}/ordered/002_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_one_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_two_roles.yml +0 -0
- data/test/fixtures/config/working/application.yml +73 -0
- data/test/fixtures/config/working/application_roles.yml +24 -0
- data/{generators/typus/templates/config/typus → test/fixtures/config/working}/typus.yml +2 -1
- data/test/{config/default → fixtures/config/working}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/README +244 -0
- data/test/fixtures/rails_app/Rakefile +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +4 -0
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/{app → rails_app/app}/models/asset.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/category.rb +2 -2
- data/test/fixtures/{app → rails_app/app}/models/comment.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/custom_user.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/delayed/task.rb +2 -2
- data/test/fixtures/rails_app/app/models/page.rb +9 -0
- data/test/fixtures/rails_app/app/models/picture.rb +6 -0
- data/test/fixtures/{app → rails_app/app}/models/post.rb +6 -6
- data/test/fixtures/rails_app/app/models/typus_user.rb +8 -0
- data/test/fixtures/{app → rails_app/app}/models/view.rb +1 -1
- data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +6 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/fixtures/rails_app/config/application.rb +50 -0
- data/test/fixtures/rails_app/config/boot.rb +13 -0
- data/test/fixtures/rails_app/config/database.yml +22 -0
- data/test/fixtures/rails_app/config/environment.rb +5 -0
- data/test/fixtures/rails_app/config/environments/development.rb +19 -0
- data/test/fixtures/rails_app/config/environments/production.rb +42 -0
- data/test/fixtures/rails_app/config/environments/test.rb +34 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +258 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +98 -0
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/inflections.rb +10 -0
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
- data/test/fixtures/rails_app/config/initializers/typus.rb +6 -0
- data/test/fixtures/rails_app/config/locales/en.yml +5 -0
- data/test/fixtures/rails_app/config/routes.rb +8 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/application.yml +11 -9
- data/test/{config/working → fixtures/rails_app/config/typus}/application_roles.yml +0 -0
- data/{generators/typus_update_schema_to_01/templates/config → test/fixtures/rails_app/config/typus}/typus.yml +0 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/config.ru +4 -0
- data/test/fixtures/rails_app/db/seeds.rb +7 -0
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/log/test.log +4268 -0
- data/test/fixtures/rails_app/public/404.html +26 -0
- data/test/fixtures/rails_app/public/422.html +26 -0
- data/test/fixtures/rails_app/public/500.html +26 -0
- data/test/fixtures/rails_app/public/favicon.ico +0 -0
- data/test/fixtures/rails_app/public/images/rails.png +0 -0
- data/test/fixtures/rails_app/public/index.html +279 -0
- data/test/fixtures/rails_app/public/javascripts/application.js +2 -0
- data/test/fixtures/rails_app/public/javascripts/controls.js +965 -0
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/fixtures/rails_app/public/javascripts/effects.js +1123 -0
- data/test/fixtures/rails_app/public/javascripts/prototype.js +4874 -0
- data/test/fixtures/rails_app/public/javascripts/rails.js +118 -0
- data/test/fixtures/rails_app/public/robots.txt +5 -0
- data/test/fixtures/rails_app/script/rails +9 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120447.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120700.csv +2 -0
- data/test/functional/admin/account_controller_test.rb +90 -0
- data/test/functional/admin/dashboard_controller_http_basic_test.rb +24 -0
- data/test/functional/admin/dashboard_controller_none_test.rb +18 -0
- data/test/functional/admin/dashboard_controller_test.rb +106 -0
- data/test/functional/admin/resources_controller_assets_relationships.rb +59 -0
- data/test/functional/admin/resources_controller_categories_before_test.rb +10 -0
- data/test/functional/admin/resources_controller_categories_lists_test.rb +44 -0
- data/test/functional/admin/resources_controller_categories_views_test.rb +10 -0
- data/test/functional/admin/resources_controller_comments_toggle_test.rb +21 -0
- data/test/functional/admin/{master_controller_posts_before_test.rb → resources_controller_posts_before_test.rb} +3 -3
- data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +27 -0
- data/test/functional/admin/resources_controller_posts_crud_test.rb +44 -0
- data/test/functional/admin/resources_controller_posts_formats_test.rb +39 -0
- data/test/functional/admin/resources_controller_posts_forms_test.rb +58 -0
- data/test/functional/admin/resources_controller_posts_permissions_test.rb +100 -0
- data/test/functional/admin/{master_controller_posts_relationships_test.rb → resources_controller_posts_relationships_test.rb} +25 -20
- data/test/functional/admin/resources_controller_posts_roles.rb +52 -0
- data/test/functional/admin/resources_controller_posts_views_test.rb +143 -0
- data/test/functional/admin/resources_controller_tableless_resource_test.rb +51 -0
- data/test/functional/admin/resources_controller_typus_users_test.rb +159 -0
- data/test/functional/admin/session_controller_test.rb +85 -0
- data/test/helpers/admin/dashboard_helper_test.rb +42 -0
- data/test/helpers/admin/form_helper_test.rb +52 -276
- data/test/helpers/admin/resources_helper_test.rb +52 -0
- data/test/helpers/admin/sidebar_helper_test.rb +133 -224
- data/test/helpers/admin/table_helper_test.rb +136 -144
- data/test/helpers/admin_helper_test.rb +69 -0
- data/test/lib/support/active_record_test.rb +35 -0
- data/test/lib/support/array_test.rb +15 -0
- data/test/lib/support/hash_test.rb +11 -0
- data/test/lib/support/string_test.rb +48 -0
- data/test/lib/typus/active_record_test.rb +385 -0
- data/test/lib/typus/configuration_test.rb +52 -0
- data/test/lib/typus/resource_test.rb +17 -0
- data/test/lib/typus/routes_test.rb +29 -0
- data/test/lib/typus_test.rb +72 -40
- data/test/{vendor → lib/vendor}/paginator_test.rb +7 -4
- data/test/schema.rb +28 -3
- data/test/test_helper.rb +29 -0
- data/test/unit/admin/mailer_test.rb +32 -0
- data/test/unit/typus_user_roles_test.rb +69 -61
- data/test/unit/typus_user_test.rb +56 -143
- data/typus.gemspec +18 -276
- metadata +305 -231
- data/.gitignore +0 -1
- data/AUTHORS.md +0 -34
- data/CHANGES +0 -3
- data/README.md +0 -75
- data/VERSION +0 -1
- data/app/controllers/admin/master_controller.rb +0 -394
- data/app/controllers/typus_controller.rb +0 -152
- data/app/helpers/admin/master_helper.rb +0 -104
- data/app/helpers/admin/public_helper.rb +0 -27
- data/app/helpers/typus_helper.rb +0 -181
- data/app/models/typus_mailer.rb +0 -14
- data/app/models/typus_user.rb +0 -5
- data/app/views/admin/shared/_feedback.html.erb +0 -6
- data/app/views/admin/shared/_footer.html.erb +0 -2
- data/app/views/admin/shared/_pagination.html.erb +0 -28
- data/app/views/admin/templates/_tiny_mce.html.erb +0 -2
- data/app/views/layouts/typus.html.erb +0 -29
- data/app/views/typus/dashboard.html.erb +0 -9
- data/app/views/typus/recover_password.html.erb +0 -7
- data/app/views/typus/reset_password.html.erb +0 -15
- data/app/views/typus/sign_in.html.erb +0 -9
- data/app/views/typus/sign_up.html.erb +0 -7
- data/config/locales/es.yml +0 -105
- data/config/locales/fr.yml +0 -98
- data/config/locales/language.yml.template +0 -106
- data/generators/typus/templates/auto/index.html.erb +0 -11
- data/generators/typus/templates/auto/resource_controller.rb.erb +0 -15
- data/generators/typus/templates/auto/resource_controller_test.rb.erb +0 -11
- data/generators/typus/templates/auto/resources_controller.rb.erb +0 -37
- data/generators/typus/templates/config/initializers/typus.rb +0 -34
- data/generators/typus/templates/config/typus/application.yml +0 -6
- data/generators/typus/templates/config/typus/application_roles.yml +0 -23
- data/generators/typus/templates/lib/tasks/typus_tasks.rake +0 -32
- data/generators/typus/templates/public/images/admin/fancybox/fancy_closebox.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_progress.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_right.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_e.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_n.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_s.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_se.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_w.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_main.png +0 -0
- data/generators/typus/templates/public/javascripts/admin/application.js +0 -14
- data/generators/typus/templates/public/javascripts/admin/jquery-1.3.2.min.js +0 -19
- data/generators/typus/templates/public/javascripts/admin/jquery.fancybox-1.2.1.min.js +0 -9
- data/generators/typus/templates/public/stylesheets/admin/jquery.fancybox.css +0 -315
- data/generators/typus/templates/public/stylesheets/admin/reset.css +0 -68
- data/generators/typus/templates/public/stylesheets/admin/screen.css +0 -361
- data/generators/typus/typus_generator.rb +0 -191
- data/generators/typus_update_schema_to_01/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb +0 -19
- data/generators/typus_update_schema_to_02/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb +0 -11
- data/lib/typus/active_record.rb +0 -323
- data/lib/typus/extensions/routes.rb +0 -15
- data/lib/typus/extensions/routes_hack.rb +0 -15
- data/lib/typus/preferences.rb +0 -11
- data/lib/typus/preview.rb +0 -76
- data/lib/typus/quick_edit.rb +0 -40
- data/lib/typus/reloader.rb +0 -14
- data/lib/typus/string.rb +0 -27
- data/lib/vendor/active_record.rb +0 -15
- data/lib/vendor/rss_parser.rb +0 -20
- data/rails/init.rb +0 -3
- data/tasks/typus_tasks.rake +0 -32
- data/test/config/working/typus.yml +0 -12
- data/test/fixtures/app/controllers/admin/assets_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/categories_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/comments_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/pages_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/posts_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/status_controller.rb +0 -6
- data/test/fixtures/app/controllers/admin/typus_users_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/watch_dog_controller.rb +0 -6
- data/test/fixtures/app/models/page.rb +0 -5
- data/test/fixtures/app/views/admin/dashboard/_content.html.erb +0 -1
- data/test/fixtures/app/views/admin/dashboard/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_edit.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_index.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_new.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_show.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/resources/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/shared/_footer.html.erb +0 -1
- data/test/fixtures/app/views/admin/status/index.html.erb +0 -1
- data/test/fixtures/app/views/admin/templates/_datepicker.html.erb +0 -1
- data/test/fixtures/assets.yml +0 -11
- data/test/fixtures/categories.yml +0 -14
- data/test/fixtures/comments.yml +0 -27
- data/test/fixtures/pages.yml +0 -41
- data/test/fixtures/posts.yml +0 -37
- data/test/fixtures/typus_users.yml +0 -59
- data/test/functional/admin/master_controller_assets_relationships.rb +0 -66
- data/test/functional/admin/master_controller_categories_lists_test.rb +0 -64
- data/test/functional/admin/master_controller_posts_crud_test.rb +0 -97
- data/test/functional/admin/master_controller_posts_formats_test.rb +0 -53
- data/test/functional/admin/master_controller_posts_permissions_test.rb +0 -127
- data/test/functional/admin/master_controller_posts_roles.rb +0 -50
- data/test/functional/admin/master_controller_posts_toggle_test.rb +0 -35
- data/test/functional/admin/master_controller_posts_views_test.rb +0 -209
- data/test/functional/admin/master_controller_tableless_resource_test.rb +0 -36
- data/test/functional/admin/master_controller_typus_users_test.rb +0 -211
- data/test/functional/typus_controller_test.rb +0 -342
- data/test/helper.rb +0 -51
- data/test/helpers/admin/master_helper_test.rb +0 -70
- data/test/helpers/admin/public_helper_test.rb +0 -26
- data/test/helpers/typus_helper_test.rb +0 -96
- data/test/lib/active_record_test.rb +0 -377
- data/test/lib/configuration_test.rb +0 -95
- data/test/lib/hash_test.rb +0 -11
- data/test/lib/routes_test.rb +0 -71
- data/test/lib/string_test.rb +0 -55
- data/test/unit/typus_mailer_test.rb +0 -29
- data/test/unit/typus_test.rb +0 -17
- data/test/vendor/active_record_test.rb +0 -18
@@ -0,0 +1,58 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
# Here we test everything related to forms.
|
4
|
+
|
5
|
+
class Admin::PostsControllerTest < ActionController::TestCase
|
6
|
+
|
7
|
+
# Our model definition is:
|
8
|
+
#
|
9
|
+
# Post:
|
10
|
+
# fields:
|
11
|
+
# form: title, body, created_at, status, published_at
|
12
|
+
#
|
13
|
+
should "verify forms" do
|
14
|
+
|
15
|
+
get :new
|
16
|
+
assert_template :new
|
17
|
+
|
18
|
+
assert_select "form"
|
19
|
+
|
20
|
+
# We have 3 inputs: 1 hidden which is the UTF8 stuff, one which is the
|
21
|
+
# Post#title and finally the submit button.
|
22
|
+
|
23
|
+
assert_select "form input", 3
|
24
|
+
|
25
|
+
# Post#title: Input
|
26
|
+
assert_select 'label[for="post_title"]'
|
27
|
+
assert_select 'input#post_title[type="text"]'
|
28
|
+
|
29
|
+
# We have 1 textarea
|
30
|
+
assert_select "form textarea", 1
|
31
|
+
|
32
|
+
# Post#body: Text Area
|
33
|
+
assert_select 'label[for="post_body"]'
|
34
|
+
assert_select 'textarea#post_body'
|
35
|
+
|
36
|
+
# We have 6 selectors
|
37
|
+
assert_select "form select", 6
|
38
|
+
|
39
|
+
# Post#created_at: Datetime
|
40
|
+
assert_select 'label[for="post_created_at"]'
|
41
|
+
assert_select 'select#post_created_at_1i'
|
42
|
+
assert_select 'select#post_created_at_2i'
|
43
|
+
assert_select 'select#post_created_at_3i'
|
44
|
+
assert_select 'select#post_created_at_4i'
|
45
|
+
assert_select 'select#post_created_at_5i'
|
46
|
+
|
47
|
+
# Post#status: Selector
|
48
|
+
assert_select 'label[for="post_status"]'
|
49
|
+
assert_select 'select#post_status'
|
50
|
+
|
51
|
+
# We have 1 template
|
52
|
+
|
53
|
+
# Post#published_at: Datetime
|
54
|
+
assert_match "templates#datepicker_template_published_at", @response.body
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "Root" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
9
|
+
@post = Factory(:post, :typus_user => editor)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "verify_root_can_edit_any_record" do
|
13
|
+
Post.all.each do |post|
|
14
|
+
get :edit, { :id => post.id }
|
15
|
+
assert_response :success
|
16
|
+
assert_template 'edit'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should "verify_admin_updating_an_item_does_not_change_typus_user_id_if_not_defined" do
|
21
|
+
post :update, { :id => @post.id, :post => { :title => 'Updated by admin' } }
|
22
|
+
post_updated = Post.find(@post.id)
|
23
|
+
assert_equal @post.typus_user_id, post_updated.typus_user_id
|
24
|
+
end
|
25
|
+
|
26
|
+
should "verify_admin_updating_an_item_does_change_typus_user_id_to_whatever_admin_wants" do
|
27
|
+
post :update, { :id => @post.id, :post => { :title => 'Updated', :typus_user_id => 108 } }
|
28
|
+
post_updated = Post.find(@post.id)
|
29
|
+
assert_equal 108, post_updated.typus_user_id
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "No root" do
|
35
|
+
|
36
|
+
setup do
|
37
|
+
@typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
38
|
+
@request.session[:typus_user_id] = @typus_user.id
|
39
|
+
assert @typus_user.is_not_root?
|
40
|
+
@request.env['HTTP_REFERER'] = '/admin/posts'
|
41
|
+
end
|
42
|
+
|
43
|
+
should "verify_editor_can_show_any_record" do
|
44
|
+
Post.all.each do |post|
|
45
|
+
get :show, { :id => post.id }
|
46
|
+
assert_response :success
|
47
|
+
assert_template 'show'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
should "verify_editor_tried_to_edit_a_post_owned_by_himself" do
|
52
|
+
_post = Factory(:post, :typus_user => @typus_user)
|
53
|
+
get :edit, { :id => _post.id }
|
54
|
+
assert_response :success
|
55
|
+
end
|
56
|
+
|
57
|
+
should "verify_editor_tries_to_edit_a_post_owned_by_the_admin" do
|
58
|
+
get :edit, { :id => Factory(:post).id }
|
59
|
+
|
60
|
+
assert_response :redirect
|
61
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
62
|
+
assert_equal "You don't have permission to access this item.", flash[:alert]
|
63
|
+
end
|
64
|
+
|
65
|
+
should "verify_editor_tries_to_show_a_post_owned_by_the_admin" do
|
66
|
+
get :show, { :id => Factory(:post).id }
|
67
|
+
assert_response :success
|
68
|
+
end
|
69
|
+
|
70
|
+
should "verify_editor_tries_to_show_a_post_owned_by_the_admin whe only user items" do
|
71
|
+
|
72
|
+
Typus::Resources.expects(:only_user_items).returns(true)
|
73
|
+
post = Factory(:post)
|
74
|
+
get :show, { :id => post.id }
|
75
|
+
|
76
|
+
assert_response :redirect
|
77
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
78
|
+
assert_equal "You don't have permission to access this item.", flash[:alert]
|
79
|
+
end
|
80
|
+
|
81
|
+
should "verify_typus_user_id_of_item_when_creating_record" do
|
82
|
+
post :create, { :post => { :title => "Chunky Bacon", :body => "Lorem ipsum ..." } }
|
83
|
+
post_ = Post.find_by_title("Chunky Bacon")
|
84
|
+
|
85
|
+
assert_equal @request.session[:typus_user_id], post_.typus_user_id
|
86
|
+
end
|
87
|
+
|
88
|
+
should "verify_editor_updating_an_item_does_not_change_typus_user_id" do
|
89
|
+
|
90
|
+
[ 108, nil ].each do |typus_user_id|
|
91
|
+
_post = Factory(:post, :typus_user => @typus_user)
|
92
|
+
post :update, { :id => _post.id, :post => { :title => 'Updated', :typus_user_id => @typus_user.id } }
|
93
|
+
post_updated = Post.find(_post.id)
|
94
|
+
assert_equal @request.session[:typus_user_id], post_updated.typus_user_id
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class Admin::PostsControllerTest < ActionController::TestCase
|
4
4
|
|
@@ -6,29 +6,29 @@ class Admin::PostsControllerTest < ActionController::TestCase
|
|
6
6
|
# Post => has_many :comments
|
7
7
|
##
|
8
8
|
|
9
|
-
|
9
|
+
should "relate_comment_with_post_and_then_unrelate" do
|
10
10
|
|
11
|
-
comment =
|
12
|
-
post_ =
|
11
|
+
comment = Factory(:comment, :post => nil)
|
12
|
+
post_ = Factory(:post)
|
13
13
|
@request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#comments"
|
14
14
|
|
15
15
|
assert_difference('post_.comments.count') do
|
16
|
-
post :relate, { :id => post_.id,
|
16
|
+
post :relate, { :id => post_.id,
|
17
17
|
:related => { :model => 'Comment', :id => comment.id } }
|
18
18
|
end
|
19
19
|
|
20
20
|
assert_response :redirect
|
21
21
|
assert_redirected_to @request.env['HTTP_REFERER']
|
22
|
-
assert_equal "Comment related to Post
|
22
|
+
assert_equal "Comment related to Post", flash[:notice]
|
23
23
|
|
24
24
|
assert_difference('post_.comments.count', -1) do
|
25
|
-
post :unrelate, { :id => post_.id,
|
25
|
+
post :unrelate, { :id => post_.id,
|
26
26
|
:resource => 'Comment', :resource_id => comment.id }
|
27
27
|
end
|
28
28
|
|
29
29
|
assert_response :redirect
|
30
30
|
assert_redirected_to @request.env['HTTP_REFERER']
|
31
|
-
assert_equal "Comment unrelated from Post
|
31
|
+
assert_equal "Comment unrelated from Post", flash[:notice]
|
32
32
|
|
33
33
|
end
|
34
34
|
|
@@ -36,51 +36,56 @@ class Admin::PostsControllerTest < ActionController::TestCase
|
|
36
36
|
# Post => has_and_belongs_to_many :categories
|
37
37
|
##
|
38
38
|
|
39
|
-
|
39
|
+
should "relate_category_with_post_and_then_unrelate" do
|
40
40
|
|
41
|
-
category =
|
42
|
-
post_ =
|
41
|
+
category = Factory(:category)
|
42
|
+
post_ = Factory(:post)
|
43
43
|
@request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#categories"
|
44
44
|
|
45
45
|
assert_difference('category.posts.count') do
|
46
|
-
post :relate, { :id => post_.id,
|
46
|
+
post :relate, { :id => post_.id,
|
47
47
|
:related => { :model => 'Category', :id => category.id } }
|
48
48
|
end
|
49
49
|
|
50
50
|
assert_response :redirect
|
51
51
|
assert_redirected_to @request.env['HTTP_REFERER']
|
52
|
-
assert_equal "Category related to Post
|
52
|
+
assert_equal "Category related to Post", flash[:notice]
|
53
53
|
|
54
54
|
assert_difference('category.posts.count', -1) do
|
55
|
-
post :unrelate, { :id => post_.id,
|
55
|
+
post :unrelate, { :id => post_.id,
|
56
56
|
:resource => 'Category', :resource_id => category.id }
|
57
57
|
end
|
58
58
|
|
59
59
|
assert_response :redirect
|
60
60
|
assert_redirected_to @request.env['HTTP_REFERER']
|
61
|
-
assert_equal "Category unrelated from Post
|
61
|
+
assert_equal "Category unrelated from Post", flash[:notice]
|
62
62
|
|
63
63
|
end
|
64
64
|
|
65
|
+
=begin
|
66
|
+
|
65
67
|
##
|
66
68
|
# Post => has_many :assets, :as => resource (Polimorphic)
|
67
69
|
##
|
68
70
|
|
69
|
-
|
71
|
+
# FIXME: ActiveRecord::UnknownAttributeError: unknown attribute: post
|
72
|
+
should "relate_asset_with_post_and_then_unrelate"
|
70
73
|
|
71
|
-
post_ =
|
74
|
+
post_ = Factory(:post)
|
72
75
|
|
73
76
|
@request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#assets"
|
74
77
|
|
75
78
|
assert_difference('post_.assets.count', -1) do
|
76
|
-
get :unrelate, { :id => post_.id,
|
79
|
+
get :unrelate, { :id => post_.id,
|
77
80
|
:resource => 'Asset', :resource_id => post_.assets.first.id }
|
78
81
|
end
|
79
82
|
|
80
83
|
assert_response :redirect
|
81
84
|
assert_redirected_to @request.env['HTTP_REFERER']
|
82
|
-
assert_equal "Asset unrelated from Post.", flash[:
|
85
|
+
assert_equal "Asset unrelated from Post.", flash[:notice]
|
83
86
|
|
84
87
|
end
|
85
88
|
|
86
|
-
end
|
89
|
+
=end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "Admin" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@admin = Factory(:typus_user)
|
9
|
+
@request.session[:typus_user_id] = @admin.id
|
10
|
+
end
|
11
|
+
|
12
|
+
should "add a category" do
|
13
|
+
assert @admin.can?("create", "Post")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "destroy a post" do
|
17
|
+
get :destroy, { :id => Factory(:post).id, :method => :delete }
|
18
|
+
|
19
|
+
assert_response :redirect
|
20
|
+
assert_equal "Post successfully removed.", flash[:notice]
|
21
|
+
assert_redirected_to :action => :index
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "Designer" do
|
27
|
+
|
28
|
+
setup do
|
29
|
+
@designer = Factory(:typus_user, :role => "designer")
|
30
|
+
@request.session[:typus_user_id] = @designer.id
|
31
|
+
end
|
32
|
+
|
33
|
+
should "not_allow_designer_to_add_a_post" do
|
34
|
+
get :new
|
35
|
+
|
36
|
+
assert_response :redirect
|
37
|
+
assert_equal "Designer can't perform action. (new)", flash[:notice]
|
38
|
+
assert_redirected_to :action => :index
|
39
|
+
end
|
40
|
+
|
41
|
+
should "not_allow_designer_to_destroy_a_post" do
|
42
|
+
get :destroy, { :id => Factory(:post).id, :method => :delete }
|
43
|
+
|
44
|
+
assert_response :redirect
|
45
|
+
assert_equal "Designer can't delete this item.", flash[:notice]
|
46
|
+
assert_redirected_to :action => :index
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "Index" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
get :index
|
9
|
+
end
|
10
|
+
|
11
|
+
should "render index and validates_presence_of_custom_partials" do
|
12
|
+
assert_match "posts#_index.html.erb", @response.body
|
13
|
+
end
|
14
|
+
|
15
|
+
should "render_index_and_verify_page_title" do
|
16
|
+
assert_select "title", "Posts"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "render index_and_show_add_entry_link" do
|
20
|
+
assert_select "#sidebar ul" do
|
21
|
+
assert_select "li", "Add new"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
should "render_index_and_show_trash_item_image" do
|
26
|
+
assert_response :success
|
27
|
+
assert_select '.trash', 'Trash'
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
context "New" do
|
33
|
+
|
34
|
+
setup do
|
35
|
+
get :new
|
36
|
+
end
|
37
|
+
|
38
|
+
should "render new and partials_on_new" do
|
39
|
+
assert_match "posts#_new.html.erb", @response.body
|
40
|
+
end
|
41
|
+
|
42
|
+
should "render new and verify page title" do
|
43
|
+
assert_select "title", "New Post"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "Edit" do
|
49
|
+
|
50
|
+
setup do
|
51
|
+
get :edit, { :id => Factory(:post).id }
|
52
|
+
end
|
53
|
+
|
54
|
+
should "render_edit_and_verify_presence_of_custom_partials" do
|
55
|
+
assert_match "posts#_edit.html.erb", @response.body
|
56
|
+
end
|
57
|
+
|
58
|
+
should "render_edit_and_verify_page_title" do
|
59
|
+
assert_select "title", "Edit Post"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
context "Show" do
|
65
|
+
|
66
|
+
setup do
|
67
|
+
get :show, { :id => Factory(:post).id }
|
68
|
+
end
|
69
|
+
|
70
|
+
should "render_show_and_verify_presence_of_custom_partials" do
|
71
|
+
assert_match "posts#_show.html.erb", @response.body
|
72
|
+
end
|
73
|
+
|
74
|
+
should "render_show_and_verify_page_title" do
|
75
|
+
assert_select "title", "Show Post"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
should "get_index_and_render_edit_or_show_links" do
|
81
|
+
%w(edit show).each do |action|
|
82
|
+
Typus::Resources.expects(:default_action_on_item).at_least_once.returns(action)
|
83
|
+
get :index
|
84
|
+
Post.all.each do |post|
|
85
|
+
assert_match "/posts/#{action}/#{post.id}", @response.body
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "Designer" do
|
91
|
+
|
92
|
+
setup do
|
93
|
+
@typus_user = Factory(:typus_user, :email => "designer@example.com", :role => "designer")
|
94
|
+
@request.session[:typus_user_id] = @typus_user.id
|
95
|
+
end
|
96
|
+
|
97
|
+
should "render_index_and_not_show_add_entry_link" do
|
98
|
+
get :index
|
99
|
+
assert_response :success
|
100
|
+
assert_no_match /Add Post/, @response.body
|
101
|
+
end
|
102
|
+
|
103
|
+
should "render_index_and_not_show_trash_image" do
|
104
|
+
get :index
|
105
|
+
assert_response :success
|
106
|
+
assert_select ".trash", false
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
context "Editor" do
|
112
|
+
|
113
|
+
setup do
|
114
|
+
@typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
115
|
+
@request.session[:typus_user_id] = @typus_user.id
|
116
|
+
end
|
117
|
+
|
118
|
+
should "get_index_and_render_edit_or_show_links_on_owned_records" do
|
119
|
+
get :index
|
120
|
+
Post.all.each do |post|
|
121
|
+
action = post.owned_by?(@typus_user) ? "edit" : "show"
|
122
|
+
assert_match "/posts/#{action}/#{post.id}", @response.body
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
should "get_index_and_render_edit_or_show_on_only_user_items" do
|
127
|
+
%w(edit show).each do |action|
|
128
|
+
Typus::Resources.stubs(:only_user_items).returns(true)
|
129
|
+
Typus::Resources.stubs(:default_action_on_item).returns(action)
|
130
|
+
get :index
|
131
|
+
Post.all.each do |post|
|
132
|
+
if post.owned_by?(@typus_user)
|
133
|
+
assert_match "/posts/#{action}/#{post.id}", @response.body
|
134
|
+
else
|
135
|
+
assert_no_match /\/posts\/#{action}\/#{post.id}/, @response.body
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::StatusControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "Admin" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@request.session[:typus_user_id] = Factory(:typus_user).id
|
9
|
+
end
|
10
|
+
|
11
|
+
should "render index" do
|
12
|
+
get :index
|
13
|
+
assert_response :success
|
14
|
+
assert_template 'index'
|
15
|
+
end
|
16
|
+
|
17
|
+
should "not render show" do
|
18
|
+
get :show
|
19
|
+
assert_response :unprocessable_entity
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "Editor" do
|
25
|
+
|
26
|
+
setup do
|
27
|
+
@request.session[:typus_user_id] = Factory(:typus_user, :role => "editor").id
|
28
|
+
end
|
29
|
+
|
30
|
+
should "not render index" do
|
31
|
+
get :index
|
32
|
+
assert_response :unprocessable_entity
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
context "Not logged user" do
|
38
|
+
|
39
|
+
setup do
|
40
|
+
@request.session[:typus_user_id] = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
should "not render index and redirect to new_admin_session_path with back_to" do
|
44
|
+
get :index
|
45
|
+
assert_response :redirect
|
46
|
+
assert_redirected_to new_admin_session_path(:back_to => '/admin/status')
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Admin::TypusUsersControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "Master role" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
Typus.master_role = 'admin'
|
9
|
+
@typus_user = Factory(:typus_user)
|
10
|
+
@typus_user_editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
11
|
+
@request.session[:typus_user_id] = @typus_user.id
|
12
|
+
@request.env['HTTP_REFERER'] = '/admin/typus_users'
|
13
|
+
end
|
14
|
+
|
15
|
+
should "allow_admin_to_create_typus_users" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
should "not allow admin to toogle her status" do
|
21
|
+
get :toggle, { :id => @typus_user.id, :field => 'status' }
|
22
|
+
|
23
|
+
assert_response :redirect
|
24
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
25
|
+
assert_equal "You can't toggle your status.", flash[:notice]
|
26
|
+
end
|
27
|
+
|
28
|
+
should "allow_admin_to_toggle_other_users_status" do
|
29
|
+
|
30
|
+
get :toggle, { :id => @typus_user_editor.id, :field => 'status' }
|
31
|
+
|
32
|
+
assert_response :redirect
|
33
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
34
|
+
assert_equal "Typus user status changed.", flash[:notice]
|
35
|
+
end
|
36
|
+
|
37
|
+
should "not be able to destroy herself" do
|
38
|
+
assert_difference('TypusUser.count', 0) do
|
39
|
+
delete :destroy, :id => @typus_user.id
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_response :redirect
|
43
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
44
|
+
assert_equal "You can't remove yourself.", flash[:notice]
|
45
|
+
end
|
46
|
+
|
47
|
+
should "verify_admin_can_destroy_others" do
|
48
|
+
assert_difference('TypusUser.count', -1) do
|
49
|
+
delete :destroy, :id => @typus_user_editor.id
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_response :redirect
|
53
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
54
|
+
assert_equal "Typus user successfully removed.", flash[:notice]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "No master role" do
|
60
|
+
|
61
|
+
setup do
|
62
|
+
@typus_user = Factory(:typus_user, :role => "editor")
|
63
|
+
@request.session[:typus_user_id] = @typus_user.id
|
64
|
+
@request.env['HTTP_REFERER'] = '/admin/typus_users'
|
65
|
+
end
|
66
|
+
|
67
|
+
should "not_allow_non_root_typus_user_to_toggle_status" do
|
68
|
+
get :toggle, { :id => @typus_user.id, :field => 'status' }
|
69
|
+
|
70
|
+
assert_response :redirect
|
71
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
72
|
+
assert_equal "You're not allowed to toggle status.", flash[:notice]
|
73
|
+
end
|
74
|
+
|
75
|
+
should "not_allow_editor_to_create_typus_users" do
|
76
|
+
get :new
|
77
|
+
|
78
|
+
assert_response :redirect
|
79
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
80
|
+
assert_equal "Editor can't perform action. (new)", flash[:notice].to_s
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context "Editor" do
|
86
|
+
|
87
|
+
setup do
|
88
|
+
@request.env['HTTP_REFERER'] = '/admin/typus_users'
|
89
|
+
@typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
90
|
+
@request.session[:typus_user_id] = @typus_user.id
|
91
|
+
end
|
92
|
+
|
93
|
+
should "allow_editor_to_update_himself" do
|
94
|
+
post :update, { :id => @typus_user.id, :typus_user => { :role => 'editor' } }
|
95
|
+
|
96
|
+
assert_response :redirect
|
97
|
+
assert_redirected_to "/admin/typus_users/edit/#{@typus_user.id}"
|
98
|
+
assert_equal "Typus user successfully updated.", flash[:notice]
|
99
|
+
end
|
100
|
+
|
101
|
+
should "not_allow_editor_to_update_himself_to_become_admin" do
|
102
|
+
post :update, { :id => @typus_user.id, :typus_user => { :role => 'admin' } }
|
103
|
+
|
104
|
+
assert_response :redirect
|
105
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
106
|
+
assert_equal "You can't change your role.", flash[:notice]
|
107
|
+
end
|
108
|
+
|
109
|
+
should "not_allow_editor_to_edit_other_users_profiles" do
|
110
|
+
get :edit, { :id => Factory(:typus_user).id }
|
111
|
+
|
112
|
+
assert_response :redirect
|
113
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
114
|
+
assert_equal "As you're not the admin or the owner of this record you cannot edit it.", flash[:notice]
|
115
|
+
end
|
116
|
+
|
117
|
+
should "not_allow_editor_to_destroy_users" do
|
118
|
+
delete :destroy, :id => Factory(:typus_user).id
|
119
|
+
|
120
|
+
assert_response :redirect
|
121
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
122
|
+
assert_equal "You're not allowed to remove Typus Users.", flash[:notice]
|
123
|
+
end
|
124
|
+
|
125
|
+
should "not_allow_editor_to_destroy_herself" do
|
126
|
+
delete :destroy, :id => @typus_user.id
|
127
|
+
|
128
|
+
assert_response :redirect
|
129
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
130
|
+
assert_equal "You're not allowed to remove Typus Users.", flash[:notice]
|
131
|
+
end
|
132
|
+
|
133
|
+
should "change_root_to_editor_so_editor_can_edit_others_content" do
|
134
|
+
Typus.expects(:master_role).at_least_once.returns("editor")
|
135
|
+
get :edit, { :id => Factory(:typus_user).id }
|
136
|
+
assert_response :success
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
context "Designer" do
|
142
|
+
|
143
|
+
setup do
|
144
|
+
@request.env['HTTP_REFERER'] = '/admin'
|
145
|
+
@typus_user = Factory(:typus_user, :role => "designer")
|
146
|
+
@request.session[:typus_user_id] = @typus_user.id
|
147
|
+
end
|
148
|
+
|
149
|
+
should "redirect_to_admin_dashboard_if_user_does_not_have_privileges" do
|
150
|
+
get :index
|
151
|
+
|
152
|
+
assert_response :redirect
|
153
|
+
assert_redirected_to @request.env['HTTP_REFERER']
|
154
|
+
assert_equal "Designer can't display items.", flash[:notice]
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|