typus 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +20 -9
- data/Gemfile.lock +93 -65
- data/MIT-LICENSE +1 -1
- data/README.md +61 -0
- data/Rakefile +5 -0
- data/app/controllers/admin/account_controller.rb +7 -10
- data/app/controllers/admin/base_controller.rb +16 -1
- data/app/controllers/admin/resources_controller.rb +270 -159
- data/app/controllers/admin/session_controller.rb +8 -9
- data/app/helpers/admin/base_helper.rb +13 -28
- data/app/helpers/admin/dashboard_helper.rb +4 -10
- data/app/helpers/admin/file_preview_helper.rb +70 -0
- data/app/helpers/admin/filters_helper.rb +64 -45
- data/app/helpers/admin/form_helper.rb +37 -62
- data/app/helpers/admin/relationships_helper.rb +63 -78
- data/app/helpers/admin/resources_helper.rb +10 -31
- data/app/helpers/admin/search_helper.rb +6 -9
- data/app/helpers/admin/sidebar_helper.rb +15 -20
- data/app/helpers/admin/table_helper.rb +79 -170
- data/app/mailers/admin/mailer.rb +1 -1
- data/app/views/admin/account/forgot_password.html.erb +2 -2
- data/app/views/admin/account/new.html.erb +8 -4
- data/app/views/admin/base/user_guide.html.erb +85 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +3 -1
- data/app/views/admin/dashboard/show.html.erb +2 -2
- data/app/views/admin/dashboard/styles.html.erb +2 -2
- data/app/views/admin/helpers/_apps.html.erb +5 -4
- data/app/views/admin/helpers/_file_preview.html.erb +3 -0
- data/app/views/admin/helpers/_header.html.erb +3 -3
- data/app/views/admin/helpers/_login_info.html.erb +2 -2
- data/app/views/admin/helpers/dashboard/_applications.html.erb +6 -9
- data/app/views/admin/helpers/dashboard/_resources.html.erb +2 -3
- data/app/views/admin/helpers/filters/_filters.html.erb +1 -1
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
- data/app/views/admin/helpers/resources/_errors.html.erb +10 -0
- data/app/views/admin/helpers/search/_search.html.erb +1 -1
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +6 -3
- data/app/views/admin/helpers/table/_table.html.erb +17 -5
- data/app/views/admin/mailer/reset_password_link.text.erb +2 -2
- data/app/views/admin/resources/_form.html.erb +3 -12
- data/app/views/admin/resources/edit.html.erb +7 -5
- data/app/views/admin/resources/index.html.erb +13 -18
- data/app/views/admin/resources/new.html.erb +4 -4
- data/app/views/admin/resources/show.html.erb +9 -13
- data/app/views/admin/session/new.html.erb +8 -4
- data/app/views/admin/templates/_belongs_to.html.erb +1 -1
- data/app/views/admin/templates/_boolean.html.erb +2 -2
- data/app/views/admin/templates/_date.html.erb +2 -2
- data/app/views/admin/templates/_datetime.html.erb +2 -2
- data/app/views/admin/templates/_file.html.erb +3 -19
- data/app/views/admin/templates/_has_n.html.erb +4 -4
- data/app/views/admin/templates/_has_one.html.erb +14 -0
- data/app/views/admin/templates/_password.html.erb +2 -2
- data/app/views/admin/templates/_profile_sidebar.html.erb +3 -0
- data/app/views/admin/templates/_relate_form.html.erb +2 -1
- data/app/views/admin/templates/_selector.html.erb +1 -1
- data/app/views/admin/templates/_string.html.erb +6 -6
- data/app/views/admin/templates/_text.html.erb +11 -4
- data/app/views/admin/templates/_time.html.erb +2 -2
- data/app/views/admin/templates/_tree.html.erb +1 -1
- data/app/views/layouts/admin/base.html.erb +7 -6
- data/app/views/layouts/admin/session.html.erb +4 -14
- data/config/{available_locales/ca_models.yml → locales/typus.ca.models.yml} +5 -4
- data/config/locales/typus.ca.yml +81 -0
- data/config/{available_locales/de_models.yml → locales/typus.de.models.yml} +6 -2
- data/config/locales/typus.de.yml +80 -0
- data/config/locales/typus.el.models.yml +17 -0
- data/config/locales/typus.el.yml +82 -0
- data/config/{available_locales/es_models.yml → locales/typus.es.models.yml} +9 -4
- data/config/locales/typus.es.yml +82 -0
- data/config/{available_locales/fr_models.yml → locales/typus.fr.models.yml} +8 -3
- data/config/locales/typus.fr.yml +87 -0
- data/config/{available_locales/hu_models.yml → locales/typus.hu.models.yml} +6 -2
- data/config/locales/typus.hu.yml +80 -0
- data/config/{available_locales/it_models.yml → locales/typus.it.models.yml} +7 -4
- data/config/locales/typus.it.yml +89 -0
- data/config/{available_locales/language_models.yml.template → locales/typus.locale.models.yml.template} +8 -4
- data/config/locales/typus.locale.yml.template +81 -0
- data/config/{available_locales/pt-BR_models.yml → locales/typus.pt-BR.models.yml} +6 -2
- data/config/locales/typus.pt-BR.yml +80 -0
- data/config/{available_locales/ru_models.yml → locales/typus.ru.models.yml} +6 -2
- data/config/locales/typus.ru.yml +80 -0
- data/config/locales/typus.zh-CN.models.yml +17 -0
- data/config/locales/typus.zh-CN.yml +79 -0
- data/config/routes.rb +11 -7
- data/lib/generators/templates/config/initializers/typus.rb +8 -5
- data/lib/generators/templates/config/initializers/typus_resources.rb +0 -3
- data/lib/generators/templates/config/typus/README +6 -6
- data/lib/generators/templates/config/typus/typus.yml +5 -5
- data/lib/generators/templates/controller.rb +1 -1
- data/lib/generators/templates/migration.rb +1 -0
- data/lib/generators/templates/public/admin/javascripts/application.js +0 -4
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +167 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.application.js +16 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +50 -22
- data/lib/generators/templates/public/admin/stylesheets/screen.css +43 -34
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +32 -32
- data/lib/generators/templates/public/admin/vendor/fancybox/{jquery.fancybox-1.3.1.css → jquery.fancybox-1.3.4.css} +359 -363
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +1156 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
- data/lib/generators/typus/assets_generator.rb +23 -0
- data/lib/generators/typus/controller_generator.rb +29 -0
- data/lib/generators/typus/migration_generator.rb +39 -20
- data/lib/generators/typus/typus_generator.rb +17 -57
- data/lib/generators/typus/views_generator.rb +2 -6
- data/lib/support/active_record.rb +8 -20
- data/lib/support/fake_user.rb +6 -1
- data/lib/support/hash.rb +1 -2
- data/lib/support/object.rb +4 -17
- data/lib/support/string.rb +34 -3
- data/lib/tasks/typus.rake +1 -1
- data/lib/typus.rb +60 -48
- data/lib/typus/actions.rb +27 -0
- data/lib/typus/authentication/base.rb +3 -4
- data/lib/typus/authentication/http_basic.rb +1 -1
- data/lib/typus/authentication/none.rb +1 -1
- data/lib/typus/authentication/session.rb +53 -108
- data/lib/typus/configuration.rb +13 -11
- data/lib/typus/filters.rb +12 -0
- data/lib/typus/format.rb +9 -13
- data/lib/typus/i18n.rb +30 -0
- data/lib/typus/orm/active_record.rb +97 -194
- data/lib/typus/orm/active_record/search.rb +91 -0
- data/lib/typus/resources.rb +6 -10
- data/lib/typus/user.rb +20 -40
- data/lib/typus/version.rb +1 -1
- metadata +77 -231
- data/CHANGELOG +0 -102
- data/README.rdoc +0 -48
- data/app/helpers/admin/preview_helper.rb +0 -46
- data/app/views/admin/helpers/_preview.html.erb +0 -13
- data/app/views/admin/templates/_has_many.html.erb +0 -22
- data/config/available_locales/ca.yml +0 -122
- data/config/available_locales/de.yml +0 -122
- data/config/available_locales/es.yml +0 -122
- data/config/available_locales/fr.yml +0 -127
- data/config/available_locales/hu.yml +0 -122
- data/config/available_locales/it.yml +0 -132
- data/config/available_locales/language.yml.template +0 -120
- data/config/available_locales/pt-BR.yml +0 -122
- data/config/available_locales/ru.yml +0 -122
- data/lib/generators/templates/functional_test.rb +0 -10
- data/lib/generators/templates/model.rb +0 -8
- data/lib/generators/templates/public/admin/images/ui-icons.png +0 -0
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +0 -154
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +0 -1077
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +0 -13
- data/lib/typus/pagination.rb +0 -18
- data/test/factories.rb +0 -43
- data/test/fixtures/config/broken/application.yml +0 -68
- data/test/fixtures/config/broken/application_roles.yml +0 -20
- 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 +0 -3
- data/test/fixtures/config/broken/undefined_roles.yml +0 -6
- data/test/fixtures/config/default/typus.yml +0 -13
- data/test/fixtures/config/default/typus_roles.yml +0 -2
- 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 +0 -10
- data/test/fixtures/config/namespaced/application.yml +0 -5
- data/test/fixtures/config/namespaced/application_roles.yml +0 -2
- data/test/fixtures/config/ordered/001_roles.yml +0 -2
- data/test/fixtures/config/ordered/002_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
- data/test/fixtures/config/working/application.yml +0 -73
- data/test/fixtures/config/working/application_roles.yml +0 -24
- data/test/fixtures/config/working/typus.yml +0 -13
- data/test/fixtures/config/working/typus_roles.yml +0 -2
- data/test/fixtures/rails_app/Rakefile +0 -7
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -3
- data/test/fixtures/rails_app/app/models/asset.rb +0 -5
- data/test/fixtures/rails_app/app/models/category.rb +0 -11
- data/test/fixtures/rails_app/app/models/comment.rb +0 -6
- data/test/fixtures/rails_app/app/models/custom_user.rb +0 -2
- data/test/fixtures/rails_app/app/models/delayed/task.rb +0 -5
- data/test/fixtures/rails_app/app/models/page.rb +0 -5
- data/test/fixtures/rails_app/app/models/picture.rb +0 -6
- data/test/fixtures/rails_app/app/models/post.rb +0 -21
- data/test/fixtures/rails_app/app/models/typus_user.rb +0 -8
- data/test/fixtures/rails_app/app/models/view.rb +0 -5
- data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +0 -6
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +0 -1
- data/test/fixtures/rails_app/config.ru +0 -4
- data/test/fixtures/rails_app/config/application.rb +0 -53
- data/test/fixtures/rails_app/config/boot.rb +0 -13
- data/test/fixtures/rails_app/config/database.yml +0 -14
- data/test/fixtures/rails_app/config/environment.rb +0 -5
- data/test/fixtures/rails_app/config/environments/test.rb +0 -34
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +0 -7
- data/test/fixtures/rails_app/config/initializers/session_store.rb +0 -8
- data/test/fixtures/rails_app/config/initializers/typus.rb +0 -6
- data/test/fixtures/rails_app/config/routes.rb +0 -5
- data/test/fixtures/rails_app/config/typus/application.yml +0 -79
- data/test/fixtures/rails_app/config/typus/application_roles.yml +0 -25
- data/test/fixtures/rails_app/config/typus/typus.yml +0 -12
- data/test/fixtures/rails_app/config/typus/typus_roles.yml +0 -2
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +0 -2
- data/test/functional/admin/account_controller_test.rb +0 -90
- data/test/functional/admin/assets_controller_test.rb +0 -55
- data/test/functional/admin/categories_controller_test.rb +0 -62
- data/test/functional/admin/comments_controller_test.rb +0 -21
- data/test/functional/admin/dashboard_controller_test.rb +0 -138
- data/test/functional/admin/posts_controller_test.rb +0 -548
- data/test/functional/admin/session_controller_test.rb +0 -85
- data/test/functional/admin/status_controller_test.rb +0 -46
- data/test/functional/admin/typus_users_controller_test.rb +0 -159
- data/test/helpers/admin/base_helper_test.rb +0 -67
- data/test/helpers/admin/dashboard_helper_test.rb +0 -19
- data/test/helpers/admin/form_helper_test.rb +0 -117
- data/test/helpers/admin/resources_helper_test.rb +0 -64
- data/test/helpers/admin/sidebar_helper_test.rb +0 -274
- data/test/helpers/admin/table_helper_test.rb +0 -219
- data/test/integration/login_test.rb +0 -13
- data/test/integration_test_helper.rb +0 -21
- data/test/lib/support/active_record_test.rb +0 -86
- data/test/lib/support/array_test.rb +0 -11
- data/test/lib/support/hash_test.rb +0 -11
- data/test/lib/support/string_test.rb +0 -39
- data/test/lib/typus/active_record_test.rb +0 -451
- data/test/lib/typus/configuration_test.rb +0 -52
- data/test/lib/typus/resource_test.rb +0 -17
- data/test/lib/typus/routes_test.rb +0 -29
- data/test/lib/typus_test.rb +0 -107
- data/test/schema.rb +0 -100
- data/test/test_helper.rb +0 -16
- data/test/unit/admin/mailer_test.rb +0 -32
- data/test/unit/typus_user_roles_test.rb +0 -105
- data/test/unit/typus_user_test.rb +0 -142
- data/typus.gemspec +0 -25
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'capybara/rails'
|
3
|
-
|
4
|
-
module ActionController
|
5
|
-
|
6
|
-
class IntegrationTest
|
7
|
-
include Capybara
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
module Shoulda
|
13
|
-
|
14
|
-
module ClassMethods
|
15
|
-
|
16
|
-
alias :feature :context
|
17
|
-
alias :scenario :should
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ActiveRecordTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
context "mapping" do
|
6
|
-
|
7
|
-
context "with an array" do
|
8
|
-
|
9
|
-
setup do
|
10
|
-
Post.send(:remove_const, :STATUS)
|
11
|
-
Post::STATUS = %w(pending published unpublished)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "verify" do
|
15
|
-
post = Factory(:post)
|
16
|
-
assert_equal "published", post.mapping(:status)
|
17
|
-
post = Factory(:post, :status => "unpublished")
|
18
|
-
assert_equal "unpublished", post.mapping(:status)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with a two dimension array" do
|
24
|
-
|
25
|
-
setup do
|
26
|
-
Post.send(:remove_const, :STATUS)
|
27
|
-
Post::STATUS = [["Publicado", "published"], ["Pendiente", "pending"], ["No publicado", "unpublished"]]
|
28
|
-
end
|
29
|
-
|
30
|
-
should "verify" do
|
31
|
-
post = Factory(:post)
|
32
|
-
assert_equal "Publicado", post.mapping(:status)
|
33
|
-
post = Factory(:post, :status => "unpublished")
|
34
|
-
assert_equal "No publicado", post.mapping(:status)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
context "with a hash" do
|
40
|
-
|
41
|
-
setup do
|
42
|
-
Post.send(:remove_const, :STATUS)
|
43
|
-
Post::STATUS = { "Pending - Hash" => "pending", "Published - Hash" => "published", "Not Published - Hash" => "unpublished" }
|
44
|
-
end
|
45
|
-
|
46
|
-
should "verify" do
|
47
|
-
page = Factory(:post)
|
48
|
-
assert_equal "Published - Hash", page.mapping(:status)
|
49
|
-
page = Factory(:post, :status => "unpublished")
|
50
|
-
assert_equal "Not Published - Hash", page.mapping(:status)
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
context "to_label" do
|
58
|
-
|
59
|
-
should "return email as is an alias for to_label on TypusUser" do
|
60
|
-
assert_equal "admin@example.com", Factory(:typus_user).to_label
|
61
|
-
end
|
62
|
-
|
63
|
-
should "return name for Category" do
|
64
|
-
category = Factory(:category)
|
65
|
-
assert_match category.name, category.to_label
|
66
|
-
end
|
67
|
-
|
68
|
-
should "return default Model#id" do
|
69
|
-
assert_match /Post#/, Factory(:post).to_label
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
context "to_resource" do
|
75
|
-
|
76
|
-
should "work for models" do
|
77
|
-
assert_equal "typus_users", TypusUser.to_resource
|
78
|
-
end
|
79
|
-
|
80
|
-
should "work for namespaced models" do
|
81
|
-
assert_equal "delayed/tasks", Delayed::Task.to_resource
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ArrayTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
should "verify to_hash_with" do
|
6
|
-
keys, values = %w(a b c), %w(1 2 3)
|
7
|
-
expected = { "a" => "1", "b" => "2", "c" => "3" }
|
8
|
-
assert_equal expected, keys.to_hash_with(values)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class StringTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
should "extract_settings" do
|
6
|
-
assert_equal %w( a b c ), "a, b, c".extract_settings
|
7
|
-
assert_equal %w( a b c ), " a , b, c ".extract_settings
|
8
|
-
end
|
9
|
-
|
10
|
-
context "remove_prefix" do
|
11
|
-
|
12
|
-
should "remove admin by default" do
|
13
|
-
assert_equal "posts", "admin/posts".remove_prefix
|
14
|
-
assert_equal "typus_users", "admin/typus_users".remove_prefix
|
15
|
-
assert_equal "delayed/jobs", "admin/delayed/jobs".remove_prefix
|
16
|
-
end
|
17
|
-
|
18
|
-
should "remove what we want to" do
|
19
|
-
assert_equal "posts", "typus/posts".remove_prefix("typus/")
|
20
|
-
assert_equal "typus_users", "typus/typus_users".remove_prefix("typus/")
|
21
|
-
assert_equal "delayed/tasks", "typus/delayed/tasks".remove_prefix("typus/")
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
context "extract_class" do
|
27
|
-
|
28
|
-
should "work for models" do
|
29
|
-
assert_equal Post, "admin/posts".extract_class
|
30
|
-
assert_equal TypusUser, "admin/typus_users".extract_class
|
31
|
-
end
|
32
|
-
|
33
|
-
should "work for namespaced models" do
|
34
|
-
assert_equal Delayed::Task, "admin/delayed/tasks".extract_class
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,451 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ActiveRecordTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
context "model_fields" do
|
6
|
-
|
7
|
-
should "be an ActiveSupport::OrderedHash" do
|
8
|
-
assert TypusUser.model_fields.instance_of?(ActiveSupport::OrderedHash)
|
9
|
-
end
|
10
|
-
|
11
|
-
should "verify TypusUser model_fields" do
|
12
|
-
expected_fields = [[:id, :integer],
|
13
|
-
[:first_name, :string],
|
14
|
-
[:last_name, :string],
|
15
|
-
[:role, :string],
|
16
|
-
[:email, :string],
|
17
|
-
[:status, :boolean],
|
18
|
-
[:token, :string],
|
19
|
-
[:salt, :string],
|
20
|
-
[:crypted_password, :string],
|
21
|
-
[:preferences, :string],
|
22
|
-
[:created_at, :datetime],
|
23
|
-
[:updated_at, :datetime]]
|
24
|
-
assert_equal expected_fields.map { |i| i.first }, TypusUser.model_fields.keys
|
25
|
-
assert_equal expected_fields.map { |i| i.last }, TypusUser.model_fields.values
|
26
|
-
end
|
27
|
-
|
28
|
-
should "verify Post model_fields" do
|
29
|
-
expected_fields = [[:id, :integer],
|
30
|
-
[:title, :string],
|
31
|
-
[:body, :text],
|
32
|
-
[:status, :string],
|
33
|
-
[:favorite_comment_id, :integer],
|
34
|
-
[:created_at, :datetime],
|
35
|
-
[:updated_at, :datetime],
|
36
|
-
[:published_at, :datetime],
|
37
|
-
[:typus_user_id, :integer]]
|
38
|
-
assert_equal expected_fields.map { |i| i.first }, Post.model_fields.keys
|
39
|
-
assert_equal expected_fields.map { |i| i.last }, Post.model_fields.values
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
context "model_relationships" do
|
45
|
-
|
46
|
-
should "be an ActiveSupport::OrderedHash" do
|
47
|
-
assert TypusUser.model_relationships.instance_of?(ActiveSupport::OrderedHash)
|
48
|
-
end
|
49
|
-
|
50
|
-
should "verify Post model_relationships" do
|
51
|
-
expected = [[:comments, :has_many],
|
52
|
-
[:categories, :has_and_belongs_to_many],
|
53
|
-
[:user, nil],
|
54
|
-
[:assets, :has_many]]
|
55
|
-
expected.each do |i|
|
56
|
-
assert_equal i.last, Post.model_relationships[i.first]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
context "typus_description" do
|
63
|
-
|
64
|
-
should "return the description of a model" do
|
65
|
-
assert_equal "System Users Administration", TypusUser.typus_description
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
context "typus_fields_for" do
|
71
|
-
|
72
|
-
should "accept strings" do
|
73
|
-
assert_equal %w( email role status ), TypusUser.typus_fields_for("list").keys
|
74
|
-
end
|
75
|
-
|
76
|
-
should "accept symbols" do
|
77
|
-
assert_equal %w( email role status ), TypusUser.typus_fields_for(:list).keys
|
78
|
-
end
|
79
|
-
|
80
|
-
should "return list fields for TypusUser" do
|
81
|
-
expected_fields = [["email", :string],
|
82
|
-
["role", :selector],
|
83
|
-
["status", :boolean]]
|
84
|
-
assert_equal expected_fields.map { |i| i.first }, TypusUser.typus_fields_for(:list).keys
|
85
|
-
assert_equal expected_fields.map { |i| i.last }, TypusUser.typus_fields_for(:list).values
|
86
|
-
end
|
87
|
-
|
88
|
-
should "return form fields for TypusUser" do
|
89
|
-
expected_fields = [["first_name", :string],
|
90
|
-
["last_name", :string],
|
91
|
-
["role", :selector],
|
92
|
-
["email", :string],
|
93
|
-
["password", :password],
|
94
|
-
["password_confirmation", :password],
|
95
|
-
["language", :selector]]
|
96
|
-
assert_equal expected_fields.map { |i| i.first }, TypusUser.typus_fields_for(:form).keys
|
97
|
-
assert_equal expected_fields.map { |i| i.last }, TypusUser.typus_fields_for(:form).values
|
98
|
-
end
|
99
|
-
|
100
|
-
should "return form fields for Picture" do
|
101
|
-
expected_fields = [["title", :string],
|
102
|
-
["picture", :file]]
|
103
|
-
assert_equal expected_fields.map { |i| i.first }, Picture.typus_fields_for(:form).keys
|
104
|
-
assert_equal expected_fields.map { |i| i.last }, Picture.typus_fields_for(:form).values
|
105
|
-
end
|
106
|
-
|
107
|
-
should "return form fields for a Model without configuration" do
|
108
|
-
assert Class.new(ActiveRecord::Base).typus_fields_for(:form).empty?
|
109
|
-
end
|
110
|
-
|
111
|
-
should "return relationship fields for TypusUser" do
|
112
|
-
assert_equal %w( first_name last_name role email language), TypusUser.typus_fields_for(:relationship).keys
|
113
|
-
end
|
114
|
-
|
115
|
-
should "return undefined fields for TypusUser" do
|
116
|
-
assert_equal %w( first_name last_name role email language), TypusUser.typus_fields_for(:undefined).keys
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
context "typus_filters" do
|
122
|
-
|
123
|
-
should "return filters for TypusUser" do
|
124
|
-
expected = [["status", :boolean], ["role", :string]]
|
125
|
-
|
126
|
-
assert_equal expected.map { |i| i.first }.join(", "), Typus::Configuration.config["TypusUser"]["filters"]
|
127
|
-
assert_equal expected.map { |i| i.first }, TypusUser.typus_filters.keys
|
128
|
-
assert_equal expected.map { |i| i.last }, TypusUser.typus_filters.values
|
129
|
-
end
|
130
|
-
|
131
|
-
should "return filters for Post" do
|
132
|
-
expected = [["status", :string], ["created_at", :datetime]]
|
133
|
-
assert_equal expected.map { |i| i.first }.join(", "), Typus::Configuration.config["Post"]["filters"]
|
134
|
-
assert_equal expected.map { |i| i.first }, Post.typus_filters.keys
|
135
|
-
assert_equal expected.map { |i| i.last }, Post.typus_filters.values
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
context "typus_actions_on" do
|
141
|
-
|
142
|
-
should "accept strings" do
|
143
|
-
assert_equal %w( cleanup ), Post.typus_actions_on("index")
|
144
|
-
end
|
145
|
-
|
146
|
-
should "accept symbols" do
|
147
|
-
assert_equal %w( cleanup ), Post.typus_actions_on(:index)
|
148
|
-
end
|
149
|
-
|
150
|
-
should "return actions on list for TypusUser" do
|
151
|
-
assert TypusUser.typus_actions_on(:list).empty?
|
152
|
-
end
|
153
|
-
|
154
|
-
should "return actions on edit for Post" do
|
155
|
-
assert_equal %w( send_as_newsletter preview ), Post.typus_actions_on(:edit)
|
156
|
-
end
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
context "typus_options_for" do
|
161
|
-
|
162
|
-
should "accept strings" do
|
163
|
-
assert_equal 15, Post.typus_options_for("form_rows")
|
164
|
-
end
|
165
|
-
|
166
|
-
should "accept symbols" do
|
167
|
-
assert_equal 15, Post.typus_options_for(:form_rows)
|
168
|
-
end
|
169
|
-
|
170
|
-
should "return nil when options do not exist" do
|
171
|
-
assert_nil TypusUser.typus_options_for(:unexisting)
|
172
|
-
end
|
173
|
-
|
174
|
-
should "return options for Post" do
|
175
|
-
assert_equal 15, Post.typus_options_for(:form_rows)
|
176
|
-
end
|
177
|
-
|
178
|
-
should "return options for Page" do
|
179
|
-
assert_equal 25, Page.typus_options_for(:form_rows)
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
context "typus_application" do
|
185
|
-
|
186
|
-
should "return application for Post" do
|
187
|
-
assert_equal "Blog", Post.typus_application
|
188
|
-
end
|
189
|
-
|
190
|
-
should "return application for View" do
|
191
|
-
assert_equal "Unknown", View.typus_application
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
context "typus_field_options_for" do
|
197
|
-
|
198
|
-
should "verify on models" do
|
199
|
-
assert_equal [ :status ], Post.typus_field_options_for(:selectors)
|
200
|
-
assert_equal [ :permalink ], Post.typus_field_options_for(:read_only)
|
201
|
-
assert_equal [ :created_at ], Post.typus_field_options_for(:auto_generated)
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
context "typus_boolean" do
|
207
|
-
|
208
|
-
should "accept strings" do
|
209
|
-
expected = {"Inactive"=>"false", "Active"=>"true"}
|
210
|
-
assert_equal expected, TypusUser.typus_boolean("status")
|
211
|
-
end
|
212
|
-
|
213
|
-
should "accept symbols" do
|
214
|
-
expected = {"Inactive"=>"false", "Active"=>"true"}
|
215
|
-
assert_equal expected, TypusUser.typus_boolean(:status)
|
216
|
-
end
|
217
|
-
|
218
|
-
should "return booleans for TypusUser" do
|
219
|
-
expected = {"Active" => "true", "Inactive" => "false"}
|
220
|
-
assert_equal expected, TypusUser.typus_boolean(:status)
|
221
|
-
end
|
222
|
-
|
223
|
-
should "return booleans for Post" do
|
224
|
-
expected = {"True" => "true", "False" => "false"}
|
225
|
-
assert_equal expected, Post.typus_boolean(:status)
|
226
|
-
end
|
227
|
-
|
228
|
-
end
|
229
|
-
|
230
|
-
context "typus_date_format" do
|
231
|
-
|
232
|
-
should "accept strings" do
|
233
|
-
assert_equal :db, Post.typus_date_format("unknown")
|
234
|
-
end
|
235
|
-
|
236
|
-
should "accept symbols" do
|
237
|
-
assert_equal :db, Post.typus_date_format(:unknown)
|
238
|
-
end
|
239
|
-
|
240
|
-
should "return date_format for Post" do
|
241
|
-
assert_equal :db, Post.typus_date_format
|
242
|
-
assert_equal :post_short, Post.typus_date_format(:created_at)
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|
246
|
-
|
247
|
-
context "typus_template" do
|
248
|
-
|
249
|
-
should "accept strings" do
|
250
|
-
assert_equal "datepicker", Post.typus_template("published_at")
|
251
|
-
end
|
252
|
-
|
253
|
-
should "accept symbols" do
|
254
|
-
assert_equal "datepicker", Post.typus_template(:published_at)
|
255
|
-
end
|
256
|
-
|
257
|
-
should "return nil if template does not exist" do
|
258
|
-
assert_nil Post.typus_template(:created_at)
|
259
|
-
end
|
260
|
-
|
261
|
-
end
|
262
|
-
|
263
|
-
context "typus_defaults_for" do
|
264
|
-
|
265
|
-
should "accept strings" do
|
266
|
-
assert_equal %w( title ), Post.typus_defaults_for("search")
|
267
|
-
end
|
268
|
-
|
269
|
-
should "accepts symbols" do
|
270
|
-
assert_equal %w( title ), Post.typus_defaults_for(:search)
|
271
|
-
end
|
272
|
-
|
273
|
-
should "return default_for relationships on Post" do
|
274
|
-
assert_equal %w( assets categories comments views ), Post.typus_defaults_for(:relationships)
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
context "typus_search_fields" do
|
280
|
-
|
281
|
-
should "return a hash with the search modifiers" do
|
282
|
-
search = ["=id", "^title", "body"]
|
283
|
-
Post.stubs(:typus_defaults_for).with(:search).returns(search)
|
284
|
-
expected = {"body"=>"@", "title"=>"^", "id"=>"="}
|
285
|
-
assert_equal expected, Post.typus_search_fields
|
286
|
-
end
|
287
|
-
|
288
|
-
should "return and empty hash" do
|
289
|
-
search = []
|
290
|
-
Post.stubs(:typus_defaults_for).with(:search).returns(search)
|
291
|
-
expected = {}
|
292
|
-
assert_equal expected, Post.typus_search_fields
|
293
|
-
end
|
294
|
-
|
295
|
-
end
|
296
|
-
|
297
|
-
context "typus_export_formats" do
|
298
|
-
|
299
|
-
should "return post formats" do
|
300
|
-
assert_equal ["csv", "xml"], Post.typus_export_formats
|
301
|
-
end
|
302
|
-
|
303
|
-
should "return picture formats" do
|
304
|
-
assert_equal [], Picture.typus_export_formats
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
|
309
|
-
context "typus_order_by" do
|
310
|
-
|
311
|
-
should "return defaults_for order_by on Post" do
|
312
|
-
assert_equal "posts.title ASC, posts.created_at DESC", Post.typus_order_by
|
313
|
-
assert_equal %w( title -created_at ), Post.typus_defaults_for(:order_by)
|
314
|
-
end
|
315
|
-
|
316
|
-
end
|
317
|
-
|
318
|
-
context "build_conditions" do
|
319
|
-
|
320
|
-
should "generate conditions for id" do
|
321
|
-
Post.stubs(:typus_defaults_for).with(:search).returns(["id"])
|
322
|
-
|
323
|
-
params = { :search => '1' }
|
324
|
-
expected = "(id LIKE '%1%')"
|
325
|
-
|
326
|
-
assert_equal expected, Post.build_conditions(params).first
|
327
|
-
end
|
328
|
-
|
329
|
-
should "generate conditions for fields starting with equal" do
|
330
|
-
Post.stubs(:typus_defaults_for).with(:search).returns(["=id"])
|
331
|
-
|
332
|
-
params = { :search => '1' }
|
333
|
-
expected = "(id LIKE '1')"
|
334
|
-
|
335
|
-
assert_equal expected, Post.build_conditions(params).first
|
336
|
-
end
|
337
|
-
|
338
|
-
should "generate conditions for fields starting with ^" do
|
339
|
-
Post.stubs(:typus_defaults_for).with(:search).returns(["^id"])
|
340
|
-
|
341
|
-
params = { :search => '1' }
|
342
|
-
expected = "(id LIKE '1%')"
|
343
|
-
|
344
|
-
assert_equal expected, Post.build_conditions(params).first
|
345
|
-
end
|
346
|
-
|
347
|
-
should "return_sql_conditions_on_search_for_typus_user" do
|
348
|
-
expected = case ENV["DB"]
|
349
|
-
when /postgresql/
|
350
|
-
"(TEXT(role) LIKE '%francesc%' OR TEXT(last_name) LIKE '%francesc%' OR TEXT(email) LIKE '%francesc%' OR TEXT(first_name) LIKE '%francesc%')"
|
351
|
-
else
|
352
|
-
"(role LIKE '%francesc%' OR last_name LIKE '%francesc%' OR email LIKE '%francesc%' OR first_name LIKE '%francesc%')"
|
353
|
-
end
|
354
|
-
|
355
|
-
params = { :search => "francesc" }
|
356
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
357
|
-
params = { :search => "Francesc" }
|
358
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
359
|
-
end
|
360
|
-
|
361
|
-
should "return_sql_conditions_on_search_and_filter_for_typus_user" do
|
362
|
-
case ENV["DB"]
|
363
|
-
when /mysql/
|
364
|
-
boolean_true = "(`typus_users`.`status` = 1)"
|
365
|
-
boolean_false = "(`typus_users`.`status` = 0)"
|
366
|
-
else
|
367
|
-
boolean_true = "(\"typus_users\".\"status\" = 't')"
|
368
|
-
boolean_false = "(\"typus_users\".\"status\" = 'f')"
|
369
|
-
end
|
370
|
-
|
371
|
-
expected = "((role LIKE '%francesc%' OR last_name LIKE '%francesc%' OR email LIKE '%francesc%' OR first_name LIKE '%francesc%')) AND #{boolean_true}"
|
372
|
-
|
373
|
-
params = { :search => "francesc", :status => "true" }
|
374
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
375
|
-
params = { :search => "francesc", :status => "false" }
|
376
|
-
assert_match /#{boolean_false}/, TypusUser.build_conditions(params).first
|
377
|
-
end
|
378
|
-
|
379
|
-
should "return_sql_conditions_on_filtering_typus_users_by_status" do
|
380
|
-
case ENV["DB"]
|
381
|
-
when /mysql/
|
382
|
-
boolean_true = "(`typus_users`.`status` = 1)"
|
383
|
-
boolean_false = "(`typus_users`.`status` = 0)"
|
384
|
-
else
|
385
|
-
boolean_true = "(\"typus_users\".\"status\" = 't')"
|
386
|
-
boolean_false = "(\"typus_users\".\"status\" = 'f')"
|
387
|
-
end
|
388
|
-
|
389
|
-
params = { :status => "true" }
|
390
|
-
assert_equal boolean_true, TypusUser.build_conditions(params).first
|
391
|
-
params = { :status => "false" }
|
392
|
-
assert_equal boolean_false, TypusUser.build_conditions(params).first
|
393
|
-
end
|
394
|
-
|
395
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at today" do
|
396
|
-
expected = "(created_at BETWEEN '#{Time.zone.now.beginning_of_day.to_s(:db)}' AND '#{Time.zone.now.beginning_of_day.tomorrow.to_s(:db)}')"
|
397
|
-
params = { :created_at => "today" }
|
398
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
399
|
-
end
|
400
|
-
|
401
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_few_days" do
|
402
|
-
expected = "(created_at BETWEEN '#{3.days.ago.beginning_of_day.to_s(:db)}' AND '#{Time.zone.now.beginning_of_day.tomorrow.to_s(:db)}')"
|
403
|
-
params = { :created_at => "last_few_days" }
|
404
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
405
|
-
end
|
406
|
-
|
407
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_7_days" do
|
408
|
-
expected = "(created_at BETWEEN '#{6.days.ago.beginning_of_day.to_s(:db)}' AND '#{Time.zone.now.beginning_of_day.tomorrow.to_s(:db)}')"
|
409
|
-
params = { :created_at => "last_7_days" }
|
410
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
411
|
-
end
|
412
|
-
|
413
|
-
should "return_sql_conditions_on_filtering_typus_users_by_created_at last_30_days" do
|
414
|
-
expected = "(created_at BETWEEN '#{Time.zone.now.beginning_of_day.prev_month.to_s(:db)}' AND '#{Time.zone.now.beginning_of_day.tomorrow.to_s(:db)}')"
|
415
|
-
params = { :created_at => "last_30_days" }
|
416
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
417
|
-
end
|
418
|
-
|
419
|
-
should "return_sql_conditions_on_filtering_posts_by_published_at today" do
|
420
|
-
expected = "(published_at BETWEEN '#{Time.zone.now.beginning_of_day.to_s(:db)}' AND '#{Time.zone.now.beginning_of_day.tomorrow.to_s(:db)}')"
|
421
|
-
params = { :published_at => "today" }
|
422
|
-
assert_equal expected, Post.build_conditions(params).first
|
423
|
-
end
|
424
|
-
|
425
|
-
should "return_sql_conditions_on_filtering_posts_by_string" do
|
426
|
-
expected = case ENV["DB"]
|
427
|
-
when /mysql/
|
428
|
-
"(`typus_users`.`role` = 'admin')"
|
429
|
-
else
|
430
|
-
"(\"typus_users\".\"role\" = 'admin')"
|
431
|
-
end
|
432
|
-
|
433
|
-
params = { :role => "admin" }
|
434
|
-
assert_equal expected, TypusUser.build_conditions(params).first
|
435
|
-
end
|
436
|
-
|
437
|
-
end
|
438
|
-
|
439
|
-
context "class_methods" do
|
440
|
-
|
441
|
-
should "verify typus_user_id exists on Post" do
|
442
|
-
assert Post.typus_user_id?
|
443
|
-
end
|
444
|
-
|
445
|
-
should "verify typus_user_id does not exist on Post" do
|
446
|
-
assert !TypusUser.typus_user_id?
|
447
|
-
end
|
448
|
-
|
449
|
-
end
|
450
|
-
|
451
|
-
end
|