middleman-core 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/cli_init.feature +18 -8
- data/features/helpers_select_tag.feature +1 -1
- data/features/layouts_dir.feature +8 -0
- data/features/markdown_redcarpet.feature +2 -2
- data/fixtures/asciidoc-app/source/layouts/default.erb +0 -1
- data/fixtures/capture-html-app/source/capture_html_haml.html.haml +1 -1
- data/fixtures/content-for-app/source/content_for_haml.html.haml +1 -1
- data/fixtures/frontmatter-settings-app/source/layouts/override.erb +1 -2
- data/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb +1 -2
- data/fixtures/layouts-dir-app/source/ambiguous.html.erb +5 -0
- data/fixtures/layouts-dir-app/source/layouts/other.erb +3 -0
- data/fixtures/layouts-dir-app/source/other.erb +3 -0
- data/fixtures/link-to-app/source/link_to_haml.html.haml +1 -1
- data/fixtures/link-to-app/source/link_to_slim.html.slim +1 -1
- data/fixtures/nested-layout-app/source/layouts/inner_haml.haml +1 -1
- data/fixtures/nested-layout-app/source/layouts/inner_slim.slim +1 -1
- data/fixtures/nested-layout-app/source/layouts/outer_haml.haml +1 -1
- data/fixtures/nested-layout-app/source/layouts/outer_slim.slim +1 -1
- data/lib/middleman-core/application.rb +12 -3
- data/lib/middleman-core/cli/build.rb +5 -3
- data/lib/middleman-core/cli/console.rb +1 -1
- data/lib/middleman-core/cli/init.rb +1 -1
- data/lib/middleman-core/core_extensions.rb +0 -1
- data/lib/middleman-core/core_extensions/file_watcher.rb +11 -11
- data/lib/middleman-core/core_extensions/rendering.rb +40 -66
- data/lib/middleman-core/extension.rb +167 -0
- data/lib/middleman-core/extensions.rb +2 -151
- data/lib/middleman-core/logger.rb +2 -2
- data/lib/middleman-core/meta_pages/assets/config.css +13 -0
- data/lib/middleman-core/meta_pages/assets/meta.css +19 -3
- data/lib/middleman-core/meta_pages/assets/sitemap.css +18 -1
- data/lib/middleman-core/meta_pages/config_setting.rb +7 -9
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +24 -15
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +5 -1
- data/lib/middleman-core/meta_pages/templates/config.html.erb +2 -2
- data/lib/middleman-core/meta_pages/templates/index.html.erb +18 -8
- data/lib/middleman-core/meta_pages/templates/sitemap.html.erb +4 -5
- data/lib/middleman-core/preview_server.rb +6 -3
- data/lib/middleman-core/renderers/erb.rb +12 -14
- data/lib/middleman-core/renderers/haml.rb +10 -0
- data/lib/middleman-core/renderers/markdown.rb +5 -1
- data/lib/middleman-core/renderers/sass.rb +0 -4
- data/lib/middleman-core/renderers/slim.rb +16 -3
- data/lib/middleman-core/sitemap/resource.rb +1 -1
- data/lib/middleman-core/step_definitions.rb +2 -1
- data/lib/middleman-core/templates.rb +3 -1
- data/lib/middleman-core/templates/shared/Gemfile.tt +4 -1
- data/lib/middleman-core/templates/shared/config.tt +3 -1
- data/lib/middleman-core/templates/shared/gitignore +2 -1
- data/lib/middleman-core/util.rb +22 -16
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-more/core_extensions/compass.rb +3 -3
- data/lib/middleman-more/core_extensions/default_helpers.rb +18 -15
- data/lib/middleman-more/extensions/asset_hash.rb +1 -0
- data/middleman-core.gemspec +9 -6
- metadata +69 -227
- data/features/sass_cache_path.feature +0 -22
- data/fixtures/sass-cache-path-custom-app/config.rb +0 -3
- data/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass +0 -4
- data/fixtures/sass-cache-path-default-app/config.rb +0 -3
- data/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass +0 -4
- data/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile +0 -9
- data/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile +0 -3
- data/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc +0 -107
- data/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile +0 -12
- data/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec +0 -22
- data/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb +0 -109
- data/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +0 -33
- data/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb +0 -141
- data/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb +0 -55
- data/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb +0 -10
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/.document +0 -5
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/.gitignore +0 -22
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/.yardopts +0 -1
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/LICENSE.txt +0 -20
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/README.rdoc +0 -294
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/Rakefile +0 -5
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/bin/padrino +0 -9
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core.rb +0 -200
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application.rb +0 -297
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/flash.rb +0 -229
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering.rb +0 -317
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/erubis.rb +0 -64
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/haml.rb +0 -28
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb +0 -14
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/routing.rb +0 -1077
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/showexceptions.rb +0 -21
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/caller.rb +0 -53
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/adapter.rb +0 -24
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/base.rb +0 -159
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/console.rb +0 -20
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake.rb +0 -47
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake_tasks.rb +0 -52
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/command.rb +0 -38
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/404.png +0 -0
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/500.png +0 -0
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/loader.rb +0 -224
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/cs.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/da.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/de.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/en.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/es.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/fr.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/hu.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/it.yml +0 -39
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ja.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/lv.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/nl.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/no.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pl.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pt_br.yml +0 -39
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ro.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ru.yml +0 -34
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/sv.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/tr.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/uk.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_cn.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_tw.yml +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/logger.rb +0 -438
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/module.rb +0 -58
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/mounter.rb +0 -234
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb +0 -341
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/router.rb +0 -95
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb +0 -77
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite.rb +0 -260
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/tasks.rb +0 -21
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/version.rb +0 -20
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/padrino-core.gemspec +0 -43
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/Gemfile +0 -4
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app/app.rb +0 -3
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app_gem.gemspec +0 -17
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem.rb +0 -7
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem/version.rb +0 -3
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.components +0 -6
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.gitignore +0 -7
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/complex.rb +0 -32
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/simple.rb +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/a.rb +0 -9
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/b.rb +0 -4
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/c.rb +0 -1
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/e.rb +0 -13
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/f.rb +0 -2
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/g.rb +0 -2
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/d.rb +0 -4
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/helper.rb +0 -83
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/mini_shoulda.rb +0 -45
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_application.rb +0 -125
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_core.rb +0 -77
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb +0 -80
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_dependencies.rb +0 -44
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_filters.rb +0 -348
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_flash.rb +0 -168
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_locale.rb +0 -21
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_logger.rb +0 -210
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_mounter.rb +0 -199
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_complex.rb +0 -75
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_simple.rb +0 -98
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering.rb +0 -545
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering_extensions.rb +0 -14
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_restful_routing.rb +0 -33
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_router.rb +0 -146
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_routing.rb +0 -1927
- data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_support_lite.rb +0 -56
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.document +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.gitignore +0 -21
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.yardopts +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/LICENSE.txt +0 -20
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/README.rdoc +0 -239
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/Rakefile +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers.rb +0 -57
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/asset_tag_helpers.rb +0 -401
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/breadcrumb_helpers.rb +0 -183
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -317
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -40
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_helpers.rb +0 -919
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/format_helpers.rb +0 -372
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/cs.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/da.yml +0 -91
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/de.yml +0 -81
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/en.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/es.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/fr.yml +0 -79
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/hu.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/it.yml +0 -89
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ja.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/lv.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/nl.yml +0 -82
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/no.yml +0 -91
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pl.yml +0 -95
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pt_br.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ro.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ru.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/sv.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/tr.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/uk.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_cn.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_tw.yml +0 -103
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/number_helpers.rb +0 -283
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers.rb +0 -207
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -96
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -78
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -63
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -78
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/render_helpers.rb +0 -59
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/tag_helpers.rb +0 -292
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/translation_helpers.rb +0 -36
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/padrino-helpers.gemspec +0 -27
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/app.rb +0 -84
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.erb +0 -8
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.haml +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.slim +0 -6
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.erb +0 -14
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.haml +0 -12
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.slim +0 -12
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.erb +0 -14
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.haml +0 -12
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.slim +0 -12
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.erb +0 -11
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.haml +0 -9
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.slim +0 -9
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.erb +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.haml +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.slim +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.erb +0 -20
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml +0 -15
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.slim +0 -15
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.erb +0 -72
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.haml +0 -59
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.slim +0 -59
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.erb +0 -95
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.haml +0 -78
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.slim +0 -79
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.erb +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.haml +0 -4
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.slim +0 -4
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.erb +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.haml +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.slim +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.erb +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.haml +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.slim +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.erb +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.haml +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/app.rb +0 -58
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engine.haml +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb +0 -3
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml +0 -2
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim +0 -2
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/erb/test.erb +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/explicit_engine.haml +0 -5
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/haml/test.haml +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/_user.haml +0 -7
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/haml_template.haml +0 -1
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/some_template.haml +0 -2
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/helper.rb +0 -67
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_asset_tag_helpers.rb +0 -359
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_breadcrumb_helpers.rb +0 -134
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_builder.rb +0 -1178
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_helpers.rb +0 -1030
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_format_helpers.rb +0 -241
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_locale.rb +0 -20
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_number_helpers.rb +0 -143
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_output_helpers.rb +0 -154
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_render_helpers.rb +0 -94
- data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_tag_helpers.rb +0 -117
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
|
2
|
-
|
|
3
|
-
describe "BreadcrumbHelpers" do
|
|
4
|
-
include Padrino::Helpers::Breadcrumbs
|
|
5
|
-
|
|
6
|
-
def breadcrumb
|
|
7
|
-
@breadcrumb ||= Padrino::Helpers::Breadcrumb.new
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
before(:each) { breadcrumb.reset! }
|
|
11
|
-
|
|
12
|
-
context "for Breadcrumbs#breadcrumbs method" do
|
|
13
|
-
should "support breadcrumbs which is Padrino::Helpers::Breadcrumbs instance." do
|
|
14
|
-
breadcrumb.add "foo", "/foo", "foo link"
|
|
15
|
-
assert_has_tag(:a, :content => "Foo link", :href => "/foo") { breadcrumbs(breadcrumb) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
should "support bootstrap" do
|
|
19
|
-
breadcrumb.add "foo", "/foo", "foo link"
|
|
20
|
-
assert_has_tag(:span, :content => "/", :class => "divider") { breadcrumbs(breadcrumb, true) }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
should "support active" do
|
|
24
|
-
breadcrumb.add "foo", "/foo", "foo link"
|
|
25
|
-
assert_has_tag(:li, :class => "custom-active") { breadcrumbs(breadcrumb, nil, "custom-active") }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
should "support options" do
|
|
29
|
-
assert_has_tag(:ul, :class => "breadcrumbs-class breadcrumb", :id => "breadcrumbs-id") do
|
|
30
|
-
breadcrumbs(breadcrumb, nil, nil, :id => "breadcrumbs-id", :class => "breadcrumbs-class")
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "for #add method" do
|
|
36
|
-
should "support name of string and symbol type" do
|
|
37
|
-
breadcrumb.add "foo", "/foo", "Foo Link"
|
|
38
|
-
breadcrumb.add :bar, "/bar", "Bar Link"
|
|
39
|
-
|
|
40
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
41
|
-
assert_has_tag(:a, :content => "Foo link", :href => "/foo") { actual_html }
|
|
42
|
-
assert_has_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
should "support url" do
|
|
46
|
-
breadcrumb.add :foo, "/foo", "Foo Link"
|
|
47
|
-
assert_has_tag(:a, :href => "/foo") { breadcrumbs(breadcrumb) }
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
should "support caption" do
|
|
51
|
-
breadcrumb.add :foo, "/foo", "Foo Link"
|
|
52
|
-
assert_has_tag(:a, :content => "Foo link") { breadcrumbs(breadcrumb) }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
should "support options" do
|
|
56
|
-
breadcrumb.add :foo, "/foo", "Foo Link", :id => "foo-id", :class => "foo-class"
|
|
57
|
-
breadcrumb.add :bar, "/bar", "Bar Link", :id => "bar-id", :class => "bar-class"
|
|
58
|
-
|
|
59
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
60
|
-
assert_has_tag(:li, :class => "foo-class", :id => "foo-id") { actual_html }
|
|
61
|
-
assert_has_tag(:li, :class => "bar-class active", :id => "bar-id") { actual_html }
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context "for #del method" do
|
|
66
|
-
should "support name of string type" do
|
|
67
|
-
breadcrumb.add "foo", "/foo", "Foo Link"
|
|
68
|
-
breadcrumb.add :bar, "/bar", "Bar Link"
|
|
69
|
-
|
|
70
|
-
breadcrumb.del "foo"
|
|
71
|
-
breadcrumb.del "bar"
|
|
72
|
-
|
|
73
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
74
|
-
assert_has_no_tag(:a, :content => "Foo link", :href => "/foo") { actual_html }
|
|
75
|
-
assert_has_no_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
should "support name of symbol type" do
|
|
79
|
-
breadcrumb.add "foo", "/foo", "Foo Link"
|
|
80
|
-
breadcrumb.add :bar, "/bar", "Bar Link"
|
|
81
|
-
|
|
82
|
-
breadcrumb.del :foo
|
|
83
|
-
breadcrumb.del :bar
|
|
84
|
-
|
|
85
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
86
|
-
assert_has_no_tag(:a, :content => "Foo link", :href => "/foo") { actual_html }
|
|
87
|
-
assert_has_no_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context "for #set_home method" do
|
|
92
|
-
should "modified home item elements." do
|
|
93
|
-
breadcrumb.set_home("/custom", "Custom Home Page")
|
|
94
|
-
assert_has_tag(:a, :content => "Custom home page", :href => "/custom") { breadcrumbs(breadcrumb) }
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
should "support options" do
|
|
98
|
-
breadcrumb.set_home("/custom", "Custom Home Page", :id => "home-id")
|
|
99
|
-
|
|
100
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
101
|
-
assert_has_tag(:li, :id => "home-id") { actual_html }
|
|
102
|
-
assert_has_tag(:a, :content => "Custom home page", :href => "/custom") { actual_html }
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context "for #reset method" do
|
|
107
|
-
should "be #items which contains only home item." do
|
|
108
|
-
breadcrumb.set_home("/custom", "Custom Home Page")
|
|
109
|
-
breadcrumb.add "foo", "/foo", "Foo Link"
|
|
110
|
-
breadcrumb.add :bar, "/bar", "Bar Link"
|
|
111
|
-
|
|
112
|
-
breadcrumb.reset
|
|
113
|
-
|
|
114
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
115
|
-
assert_has_tag(:a, :content => "Custom home page", :href => "/custom") { actual_html }
|
|
116
|
-
assert_has_no_tag(:a, :content => "Foo link", :href => "/foo") { actual_html }
|
|
117
|
-
assert_has_no_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context "for #reset! method" do
|
|
122
|
-
should "be #items which contains only default home item." do
|
|
123
|
-
breadcrumb.add "foo", "/foo", "foo link"
|
|
124
|
-
breadcrumb.add :bar, "/bar", "Bar Link"
|
|
125
|
-
|
|
126
|
-
breadcrumb.reset!
|
|
127
|
-
|
|
128
|
-
actual_html = breadcrumbs(breadcrumb)
|
|
129
|
-
assert_has_tag(:a, :content => "Home Page", :href => "/") { actual_html }
|
|
130
|
-
assert_has_no_tag(:a, :content => "Foo link", :href => "/foo") { actual_html }
|
|
131
|
-
assert_has_no_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
@@ -1,1178 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
|
|
3
|
-
|
|
4
|
-
describe "FormBuilder" do
|
|
5
|
-
include Padrino::Helpers::FormHelpers
|
|
6
|
-
|
|
7
|
-
def app
|
|
8
|
-
MarkupDemo
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Dummy form builder for testing
|
|
12
|
-
module Padrino::Helpers::FormBuilder
|
|
13
|
-
class FakeFormBuilder < AbstractFormBuilder
|
|
14
|
-
def foo_field; @template.content_tag(:span, "bar"); end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def setup
|
|
19
|
-
role_types = [mock_model('Role', :name => "Admin", :id => 1),
|
|
20
|
-
mock_model('Role', :name => 'Moderate', :id => 2), mock_model('Role', :name => 'Limited', :id => 3)]
|
|
21
|
-
@user = mock_model("User", :first_name => "Joe", :email => '', :session_id => 54)
|
|
22
|
-
@user.stubs(:errors => {:a => "must be present", :b => "must be valid", :email => "Must be valid", :first_name => []})
|
|
23
|
-
@user.stubs(:role_types => role_types, :role => "1", :roles => [1,3])
|
|
24
|
-
@user_none = mock_model("User")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def standard_builder(object=@user)
|
|
28
|
-
Padrino::Helpers::FormBuilder::StandardFormBuilder.new(self, object)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'for #form_for method' do
|
|
32
|
-
should "display correct form html" do
|
|
33
|
-
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { "Demo" }
|
|
34
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
|
|
35
|
-
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
should "display correct form html with fake object" do
|
|
39
|
-
actual_html = form_for(:markup_user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
|
40
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post') { actual_html }
|
|
41
|
-
assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
|
|
42
|
-
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
should "display correct form html for namespaced object" do
|
|
46
|
-
actual_html = form_for(Outer::UserAccount.new, '/register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
|
47
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
|
48
|
-
assert_has_tag('form input', :type => 'text', :name => 'outer_user_account[username]') { actual_html }
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
should "display form specifying default builder setting" do
|
|
52
|
-
self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder', :protect_from_csrf => false)).at_least_once
|
|
53
|
-
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
|
|
54
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
|
55
|
-
assert_has_tag('span', :content => "bar") { actual_html }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
should "display correct form html with remote option" do
|
|
59
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true) { "Demo" }
|
|
60
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
should "display correct form html with namespace option" do
|
|
64
|
-
actual_html = form_for(@user, '/update', :namespace => 'foo') do |f|
|
|
65
|
-
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
assert_has_no_tag(:form, :namespace => 'foo') { actual_html }
|
|
69
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'foo_user_first_name') { actual_html }
|
|
70
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name') { actual_html }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
should "display correct form html with remote option and method put" do
|
|
74
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
|
|
75
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html }
|
|
76
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
should "display correct form html with method :put" do
|
|
80
|
-
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :method => 'put') { "Demo" }
|
|
81
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post') { actual_html }
|
|
82
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
should "display correct form html with method :delete" do
|
|
86
|
-
actual_html = form_for(@user, '/destroy', :"accept-charset" => "UTF-8", :method => 'delete') { "Demo" }
|
|
87
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post') { actual_html }
|
|
88
|
-
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
should "display correct form html with multipart" do
|
|
92
|
-
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
|
|
93
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
should "support changing form builder type" do
|
|
97
|
-
form_html = proc { form_for(@user, '/register', :"accept-charset" => "UTF-8", :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
|
|
98
|
-
assert_raises(NoMethodError) { form_html.call }
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
should "support using default standard builder" do
|
|
102
|
-
actual_html = form_for(@user, '/register') { |f| f.text_field_block(:name) }
|
|
103
|
-
assert_has_tag('form p input[type=text]') { actual_html }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
should "display fail for form with nil object" do
|
|
107
|
-
assert_raises(RuntimeError) { form_for(@not_real, '/register', :id => 'register', :method => 'post') { "Demo" } }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
should "display correct form in haml" do
|
|
111
|
-
visit '/haml/form_for'
|
|
112
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
|
113
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
|
114
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
|
115
|
-
assert_have_selector :input, :name => 'authenticity_token'
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
should "display correct form in erb" do
|
|
119
|
-
visit '/erb/form_for'
|
|
120
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
|
121
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
|
122
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
|
123
|
-
assert_have_selector :input, :name => 'authenticity_token'
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
should "display correct form in slim" do
|
|
127
|
-
visit '/slim/form_for'
|
|
128
|
-
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
|
129
|
-
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
|
130
|
-
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
|
131
|
-
assert_have_selector :input, :name => 'authenticity_token'
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
should "have a class of 'invalid' for fields with errors" do
|
|
135
|
-
actual_html = form_for(@user, '/register') {|f| f.text_field(:email) }
|
|
136
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
should "not have a class of 'invalid' for fields with no errors" do
|
|
140
|
-
actual_html = form_for(@user, '/register') {|f| f.text_field(:first_name) }
|
|
141
|
-
assert_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context 'for #fields_for method' do
|
|
146
|
-
should 'display correct fields html' do
|
|
147
|
-
actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
|
|
148
|
-
assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
should 'display correct fields html with symbol object' do
|
|
152
|
-
actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
|
|
153
|
-
assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
should "display fail for nil object" do
|
|
157
|
-
assert_raises(RuntimeError) { fields_for(@not_real) { |f| "Demo" } }
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
should 'display correct simple fields in haml' do
|
|
161
|
-
visit '/haml/fields_for'
|
|
162
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
|
163
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
|
164
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
|
165
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
should "display correct simple fields in erb" do
|
|
169
|
-
visit '/erb/fields_for'
|
|
170
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
|
171
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
|
172
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
|
173
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
should "display correct simple fields in slim" do
|
|
177
|
-
visit '/slim/fields_for'
|
|
178
|
-
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
|
179
|
-
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
|
180
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
|
181
|
-
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# ===========================
|
|
186
|
-
# AbstractFormBuilder
|
|
187
|
-
# ===========================
|
|
188
|
-
|
|
189
|
-
context 'for #error_messages method' do
|
|
190
|
-
should "display correct form html with no record" do
|
|
191
|
-
actual_html = standard_builder(@user_none).error_messages(:header_message => "Demo form cannot be saved")
|
|
192
|
-
assert actual_html.blank?
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
should "display correct form html with valid record" do
|
|
196
|
-
actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
|
|
197
|
-
assert_has_tag('#field-errors h2', :content => "Demo form cannot be saved") { actual_html }
|
|
198
|
-
assert_has_tag('#field-errors ul li', :content => "B must be valid") { actual_html }
|
|
199
|
-
assert_has_tag('#field-errors ul li', :content => "A must be present") { actual_html }
|
|
200
|
-
assert_has_tag('#field-errors', :style => "foo:bar") { actual_html }
|
|
201
|
-
assert_has_tag('#field-errors', :class => "mine") { actual_html }
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
should "display correct form in haml" do
|
|
205
|
-
visit '/haml/form_for'
|
|
206
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
207
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
|
208
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
|
209
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
|
210
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
211
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
|
212
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
|
213
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
|
214
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
should "display correct form in erb" do
|
|
218
|
-
visit '/erb/form_for'
|
|
219
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
220
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
|
221
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
|
222
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
|
223
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
224
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
|
225
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
|
226
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
|
227
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
should "display correct form in slim" do
|
|
231
|
-
visit '/slim/form_for'
|
|
232
|
-
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
233
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
|
234
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
|
|
235
|
-
assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
|
|
236
|
-
assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
|
237
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
|
238
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
|
|
239
|
-
assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
|
240
|
-
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
context 'for #error_message_on method' do
|
|
245
|
-
should "display correct form html with no record" do
|
|
246
|
-
actual_html = standard_builder(@user_none).error_message_on(:name)
|
|
247
|
-
assert actual_html.blank?
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
should "display error for specified invalid object" do
|
|
251
|
-
actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
|
|
252
|
-
assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
should "display error for specified invalid object not matching class name" do
|
|
256
|
-
@bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
|
|
257
|
-
actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
|
|
258
|
-
assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
|
|
259
|
-
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
context 'for #label method' do
|
|
263
|
-
should "display correct label html" do
|
|
264
|
-
actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
|
|
265
|
-
assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
should "set specific content inside the label if a block was provided" do
|
|
269
|
-
actual_html = standard_builder.label(:admin, :class => 'large') { input_tag :checkbox }
|
|
270
|
-
assert_has_tag('label', :class => 'large', :for => 'user_admin', :content => "Admin: ") { actual_html }
|
|
271
|
-
assert_has_tag('label input[type=checkbox]') { actual_html }
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
should "display correct label in haml" do
|
|
275
|
-
visit '/haml/form_for'
|
|
276
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
|
277
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
|
278
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
should "display correct label in erb" do
|
|
282
|
-
visit '/erb/form_for'
|
|
283
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
|
284
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
|
285
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
should "display correct label in slim" do
|
|
289
|
-
visit '/slim/form_for'
|
|
290
|
-
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
|
291
|
-
assert_have_selector '#demo label', :content => "About Me: "
|
|
292
|
-
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
context 'for #hidden_field method' do
|
|
297
|
-
should "display correct hidden field html" do
|
|
298
|
-
actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
|
|
299
|
-
assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
should "display correct hidden field in haml" do
|
|
303
|
-
visit '/haml/form_for'
|
|
304
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
|
305
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
should "display correct hidden field in erb" do
|
|
309
|
-
visit '/erb/form_for'
|
|
310
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
|
311
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
should "display correct hidden field in slim" do
|
|
315
|
-
visit '/slim/form_for'
|
|
316
|
-
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
|
317
|
-
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
context 'for #text_field method' do
|
|
322
|
-
should "display correct text field html" do
|
|
323
|
-
actual_html = standard_builder.text_field(:first_name, :class => 'large')
|
|
324
|
-
assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
should "display correct text field in haml" do
|
|
328
|
-
visit '/haml/form_for'
|
|
329
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
|
330
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
should "display correct text field in erb" do
|
|
334
|
-
visit '/erb/form_for'
|
|
335
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
|
336
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
|
337
|
-
end
|
|
338
|
-
|
|
339
|
-
should "display correct text field in slim" do
|
|
340
|
-
visit '/slim/form_for'
|
|
341
|
-
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
|
342
|
-
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
context 'for #number_field method' do
|
|
347
|
-
should "display correct number field html" do
|
|
348
|
-
actual_html = standard_builder.number_field(:age, :class => 'numeric')
|
|
349
|
-
assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
should "display correct number field in haml" do
|
|
353
|
-
visit '/haml/form_for'
|
|
354
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
should "display correct number field in erb" do
|
|
358
|
-
visit '/erb/form_for'
|
|
359
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
should "display correct number field in slim" do
|
|
363
|
-
visit '/slim/form_for'
|
|
364
|
-
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
|
365
|
-
end
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
context 'for #telephone_field method' do
|
|
369
|
-
should "display correct telephone field html" do
|
|
370
|
-
actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
|
|
371
|
-
assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
should "display correct telephone field in haml" do
|
|
375
|
-
visit '/haml/form_for'
|
|
376
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
should "display correct telephone field in erb" do
|
|
380
|
-
visit '/erb/form_for'
|
|
381
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
|
382
|
-
end
|
|
383
|
-
|
|
384
|
-
should "display correct telephone field in slim" do
|
|
385
|
-
visit '/slim/form_for'
|
|
386
|
-
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
context 'for #search_field method' do
|
|
391
|
-
should "display correct search field html" do
|
|
392
|
-
actual_html = standard_builder.search_field(:search, :class => 'string')
|
|
393
|
-
assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
should "display correct search field in haml" do
|
|
397
|
-
visit '/haml/form_for'
|
|
398
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
should "display correct search field in erb" do
|
|
402
|
-
visit '/erb/form_for'
|
|
403
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
|
404
|
-
end
|
|
405
|
-
|
|
406
|
-
should "display correct search field in slim" do
|
|
407
|
-
visit '/slim/form_for'
|
|
408
|
-
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
context 'for #email_field method' do
|
|
413
|
-
should "display correct email field html" do
|
|
414
|
-
actual_html = standard_builder.email_field(:email, :class => 'string')
|
|
415
|
-
assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
|
|
416
|
-
end
|
|
417
|
-
|
|
418
|
-
should "display correct email field in haml" do
|
|
419
|
-
visit '/haml/form_for'
|
|
420
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
should "display correct email field in erb" do
|
|
424
|
-
visit '/erb/form_for'
|
|
425
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
should "display correct email field in slim" do
|
|
429
|
-
visit '/slim/form_for'
|
|
430
|
-
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
|
431
|
-
end
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
context 'for #url_field method' do
|
|
435
|
-
should "display correct url field html" do
|
|
436
|
-
actual_html = standard_builder.url_field(:webpage, :class => 'string')
|
|
437
|
-
assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
should "display correct url field in haml" do
|
|
441
|
-
visit '/haml/form_for'
|
|
442
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
|
443
|
-
end
|
|
444
|
-
|
|
445
|
-
should "display correct url field in erb" do
|
|
446
|
-
visit '/erb/form_for'
|
|
447
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
|
448
|
-
end
|
|
449
|
-
|
|
450
|
-
should "display correct url field in slim" do
|
|
451
|
-
visit '/slim/form_for'
|
|
452
|
-
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
|
453
|
-
end
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
context 'for #check_box method' do
|
|
457
|
-
should "display correct checkbox html" do
|
|
458
|
-
actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
|
|
459
|
-
assert_has_tag('input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]') { actual_html }
|
|
460
|
-
assert_has_tag('input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0') { actual_html }
|
|
461
|
-
end
|
|
462
|
-
|
|
463
|
-
should "display correct checkbox html when checked" do
|
|
464
|
-
actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
|
|
465
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
should "display correct checkbox html as checked when object value matches" do
|
|
469
|
-
@user.stubs(:show_favorites => 'human')
|
|
470
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
|
471
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
|
472
|
-
end
|
|
473
|
-
|
|
474
|
-
should "display correct checkbox html as checked when object value is true" do
|
|
475
|
-
@user.stubs(:show_favorites => true)
|
|
476
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
|
477
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
|
478
|
-
end
|
|
479
|
-
|
|
480
|
-
should "display correct checkbox html as unchecked when object value doesn't match" do
|
|
481
|
-
@user.stubs(:show_favorites => 'alien')
|
|
482
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
|
483
|
-
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
|
484
|
-
end
|
|
485
|
-
|
|
486
|
-
should "display correct checkbox html as unchecked when object value is false" do
|
|
487
|
-
@user.stubs(:show_favorites => false)
|
|
488
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
|
489
|
-
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
|
490
|
-
end
|
|
491
|
-
|
|
492
|
-
should "display correct unchecked hidden field when specified" do
|
|
493
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
|
|
494
|
-
assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
should "display correct checkbox in haml" do
|
|
498
|
-
visit '/haml/form_for'
|
|
499
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
should "display correct checkbox in erb" do
|
|
503
|
-
visit '/erb/form_for'
|
|
504
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
should "display correct checkbox in slim" do
|
|
508
|
-
visit '/slim/form_for'
|
|
509
|
-
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
context 'for #check_box_group and #radio_button_group methods' do
|
|
514
|
-
should 'display checkbox group html' do
|
|
515
|
-
checkboxes = standard_builder.check_box_group(:role, :collection => @user.role_types, :fields => [:name, :id], :selected => [2,3])
|
|
516
|
-
assert_has_tag('input[type=checkbox]', :value => '1') { checkboxes }
|
|
517
|
-
assert_has_no_tag('input[type=checkbox][checked]', :value => '1') { checkboxes }
|
|
518
|
-
assert_has_tag('input[type=checkbox]', :checked => 'checked', :value => '2') { checkboxes }
|
|
519
|
-
assert_has_tag('label[for=user_role_3] input[name="user[role][]"][value="3"][checked]') { checkboxes }
|
|
520
|
-
end
|
|
521
|
-
|
|
522
|
-
should 'display checkbox group html and extract selected values from the object' do
|
|
523
|
-
checkboxes = standard_builder.check_box_group(:roles, :collection => @user.role_types, :fields => [:name, :id])
|
|
524
|
-
assert_has_tag('input[type=checkbox][name="user[roles][]"][value="1"][checked]') { checkboxes }
|
|
525
|
-
assert_has_tag('input[type=checkbox][name="user[roles][]"][value="3"][checked]') { checkboxes }
|
|
526
|
-
assert_has_no_tag('input[type=checkbox][name="user[roles][]"][value="2"][checked]') { checkboxes }
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
should 'display radio group html' do
|
|
530
|
-
radios = standard_builder.radio_button_group(:role, :options => %W(red yellow blue), :selected => 'yellow')
|
|
531
|
-
assert_has_tag('input[type=radio]', :value => 'red') { radios }
|
|
532
|
-
assert_has_no_tag('input[type=radio][checked]', :value => 'red') { radios }
|
|
533
|
-
assert_has_tag('input[type=radio]', :checked => 'checked', :value => 'yellow') { radios }
|
|
534
|
-
assert_has_tag('label[for=user_role_blue] input[name="user[role]"][value=blue]') { radios }
|
|
535
|
-
end
|
|
536
|
-
|
|
537
|
-
should 'display radio group html and extract selected value from the object' do
|
|
538
|
-
radios = standard_builder.radio_button_group(:role, :collection => @user.role_types)
|
|
539
|
-
assert_has_tag('input[type=radio][value="1"][checked]') { radios }
|
|
540
|
-
assert_has_no_tag('input[type=radio][value="2"][checked]') { radios }
|
|
541
|
-
end
|
|
542
|
-
end
|
|
543
|
-
|
|
544
|
-
context 'for #radio_button method' do
|
|
545
|
-
should "display correct radio button html" do
|
|
546
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
|
|
547
|
-
assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
|
|
548
|
-
end
|
|
549
|
-
|
|
550
|
-
should "display correct radio button html when checked" do
|
|
551
|
-
actual_html = standard_builder.radio_button(:gender, :checked => true)
|
|
552
|
-
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
|
553
|
-
end
|
|
554
|
-
|
|
555
|
-
should "display correct radio button html as checked when object value matches" do
|
|
556
|
-
@user.stubs(:gender => 'male')
|
|
557
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'male')
|
|
558
|
-
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
|
559
|
-
end
|
|
560
|
-
|
|
561
|
-
should "display correct radio button html as unchecked when object value doesn't match" do
|
|
562
|
-
@user.stubs(:gender => 'male')
|
|
563
|
-
actual_html = standard_builder.radio_button(:gender, :value => 'female')
|
|
564
|
-
assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
|
|
565
|
-
end
|
|
566
|
-
|
|
567
|
-
should "display correct radio button in haml" do
|
|
568
|
-
visit '/haml/form_for'
|
|
569
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
|
570
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
|
571
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
|
572
|
-
end
|
|
573
|
-
|
|
574
|
-
should "display correct radio button in erb" do
|
|
575
|
-
visit '/erb/form_for'
|
|
576
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
|
577
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
|
578
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
should "display correct radio button in slim" do
|
|
582
|
-
visit '/slim/form_for'
|
|
583
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
|
584
|
-
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
|
585
|
-
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
|
586
|
-
end
|
|
587
|
-
end
|
|
588
|
-
|
|
589
|
-
context 'for #text_area method' do
|
|
590
|
-
should "display correct text_area html" do
|
|
591
|
-
actual_html = standard_builder.text_area(:about, :class => 'large')
|
|
592
|
-
assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
should "display correct text_area html and content" do
|
|
596
|
-
actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
|
|
597
|
-
assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
|
|
598
|
-
end
|
|
599
|
-
|
|
600
|
-
should "display correct text_area in haml" do
|
|
601
|
-
visit '/haml/form_for'
|
|
602
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
603
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
should "display correct text_area in erb" do
|
|
607
|
-
visit '/erb/form_for'
|
|
608
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
609
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
610
|
-
end
|
|
611
|
-
|
|
612
|
-
should "display correct text_area in slim" do
|
|
613
|
-
visit '/slim/form_for'
|
|
614
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
615
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
616
|
-
end
|
|
617
|
-
end
|
|
618
|
-
|
|
619
|
-
context 'for #password_field method' do
|
|
620
|
-
should "display correct password_field html" do
|
|
621
|
-
actual_html = standard_builder.password_field(:code, :class => 'large')
|
|
622
|
-
assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
|
|
623
|
-
end
|
|
624
|
-
|
|
625
|
-
should "display correct password_field in haml" do
|
|
626
|
-
visit '/haml/form_for'
|
|
627
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
|
628
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
should "display correct password_field in erb" do
|
|
632
|
-
visit '/erb/form_for'
|
|
633
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
|
634
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
|
635
|
-
end
|
|
636
|
-
|
|
637
|
-
should "display correct password_field in slim" do
|
|
638
|
-
visit '/slim/form_for'
|
|
639
|
-
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
|
640
|
-
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
|
641
|
-
end
|
|
642
|
-
end
|
|
643
|
-
|
|
644
|
-
context 'for #file_field method' do
|
|
645
|
-
should "display correct file_field html" do
|
|
646
|
-
actual_html = standard_builder.file_field(:photo, :class => 'large')
|
|
647
|
-
assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
|
648
|
-
end
|
|
649
|
-
|
|
650
|
-
should "display correct file_field in haml" do
|
|
651
|
-
visit '/haml/form_for'
|
|
652
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
653
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
654
|
-
end
|
|
655
|
-
|
|
656
|
-
should "display correct file_field in erb" do
|
|
657
|
-
visit '/erb/form_for'
|
|
658
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
659
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
660
|
-
end
|
|
661
|
-
|
|
662
|
-
should "display correct file_field in slim" do
|
|
663
|
-
visit '/slim/form_for'
|
|
664
|
-
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
665
|
-
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
666
|
-
end
|
|
667
|
-
|
|
668
|
-
should "display correct form html with multipart, even if no 'multipart' option is specified" do
|
|
669
|
-
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8") { |f| f.file_field :photo }
|
|
670
|
-
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
|
671
|
-
end
|
|
672
|
-
|
|
673
|
-
should "display correct form html without multipart, if 'multipart' option is specified 'false'" do
|
|
674
|
-
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => false) { |f| f.file_field :photo }
|
|
675
|
-
assert_has_no_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
|
676
|
-
end
|
|
677
|
-
|
|
678
|
-
end
|
|
679
|
-
|
|
680
|
-
context 'for #select method' do
|
|
681
|
-
should "display correct select html" do
|
|
682
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
|
|
683
|
-
assert_has_tag('select.selecty', :id => 'user_state', :name => 'user[state]') { actual_html }
|
|
684
|
-
assert_has_tag('select.selecty option', :count => 3) { actual_html }
|
|
685
|
-
assert_has_tag('select.selecty option', :value => 'California', :content => 'California') { actual_html }
|
|
686
|
-
assert_has_tag('select.selecty option', :value => 'Texas', :content => 'Texas') { actual_html }
|
|
687
|
-
assert_has_tag('select.selecty option', :value => 'Wyoming', :content => 'Wyoming') { actual_html }
|
|
688
|
-
end
|
|
689
|
-
|
|
690
|
-
should "display correct select html with selected item if it matches value" do
|
|
691
|
-
@user.stubs(:state => 'California')
|
|
692
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
|
|
693
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
|
694
|
-
assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
|
|
695
|
-
assert_has_tag('select option', :value => 'California', :selected => 'selected') { actual_html }
|
|
696
|
-
end
|
|
697
|
-
|
|
698
|
-
should "display correct select html with selected item if it matches full value" do
|
|
699
|
-
@user.stubs(:state => 'Cali')
|
|
700
|
-
actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
|
|
701
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
|
702
|
-
assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
|
|
703
|
-
assert_has_tag('select option', :value => 'Cali', :selected => 'selected') { actual_html }
|
|
704
|
-
assert_has_tag('select option', :value => 'California') { actual_html }
|
|
705
|
-
end
|
|
706
|
-
|
|
707
|
-
should "display correct select html with multiple selected items" do
|
|
708
|
-
@user.stubs(:pickles => ['foo', 'bar'])
|
|
709
|
-
actual_html = standard_builder.select(
|
|
710
|
-
:pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
|
|
711
|
-
)
|
|
712
|
-
assert_has_tag('option', :value => 'foo', :content => 'Foo', :selected => 'selected') { actual_html }
|
|
713
|
-
assert_has_tag('option', :value => 'bar', :content => 'Bar', :selected => 'selected') { actual_html }
|
|
714
|
-
assert_has_tag('option', :value => 'baz', :content => 'Baz') { actual_html }
|
|
715
|
-
assert_has_tag('option', :value => 'bar buz', :content => 'Bar Buz') { actual_html }
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
should "display correct select html with include_blank" do
|
|
719
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
|
|
720
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
|
721
|
-
assert_has_tag('select option', :count => 4) { actual_html }
|
|
722
|
-
assert_has_tag('select option:first-child', :content => '') { actual_html }
|
|
723
|
-
assert_has_tag('select option:first-child', :value => '') { actual_html }
|
|
724
|
-
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
|
|
725
|
-
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
|
726
|
-
assert_has_tag('select option', :count => 4) { actual_html }
|
|
727
|
-
assert_has_tag('select option:first-child', :content => 'Select') { actual_html }
|
|
728
|
-
assert_has_tag('select option:first-child', :value => '') { actual_html }
|
|
729
|
-
end
|
|
730
|
-
|
|
731
|
-
should "display correct select html with collection passed in" do
|
|
732
|
-
actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
|
|
733
|
-
assert_has_tag('select', :id => 'user_role', :name => 'user[role]') { actual_html }
|
|
734
|
-
assert_has_tag('select option', :count => 3) { actual_html }
|
|
735
|
-
assert_has_tag('select option', :value => '1', :content => 'Admin', :selected => 'selected') { actual_html }
|
|
736
|
-
assert_has_tag('select option', :value => '2', :content => 'Moderate') { actual_html }
|
|
737
|
-
assert_has_tag('select option', :value => '3', :content => 'Limited') { actual_html }
|
|
738
|
-
end
|
|
739
|
-
|
|
740
|
-
should "display correct select in haml" do
|
|
741
|
-
visit '/haml/form_for'
|
|
742
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
743
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
744
|
-
end
|
|
745
|
-
|
|
746
|
-
should "display correct select in erb" do
|
|
747
|
-
visit '/erb/form_for'
|
|
748
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
749
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
750
|
-
end
|
|
751
|
-
|
|
752
|
-
should "display correct select in slim" do
|
|
753
|
-
visit '/slim/form_for'
|
|
754
|
-
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
|
755
|
-
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
|
756
|
-
end
|
|
757
|
-
end
|
|
758
|
-
|
|
759
|
-
context 'for #submit method' do
|
|
760
|
-
should "display correct submit button html with no options" do
|
|
761
|
-
actual_html = standard_builder.submit
|
|
762
|
-
assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
|
|
763
|
-
end
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
should "display correct submit button html with no caption" do
|
|
767
|
-
actual_html = standard_builder.submit(:class => 'btn')
|
|
768
|
-
assert_has_tag('input.btn[type=submit]', :value => "Submit") { actual_html }
|
|
769
|
-
end
|
|
770
|
-
|
|
771
|
-
should "display correct submit button html with nil caption" do
|
|
772
|
-
actual_html = standard_builder.submit(nil, :class => 'btn')
|
|
773
|
-
assert_has_tag('input.btn[type=submit]') { actual_html }
|
|
774
|
-
assert actual_html !~ %r{ value \* = }x
|
|
775
|
-
end
|
|
776
|
-
|
|
777
|
-
should "display correct submit button html" do
|
|
778
|
-
actual_html = standard_builder.submit("Commit", :class => 'large')
|
|
779
|
-
assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
|
|
780
|
-
end
|
|
781
|
-
|
|
782
|
-
should "display correct submit button in haml" do
|
|
783
|
-
visit '/haml/form_for'
|
|
784
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
|
785
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
|
786
|
-
end
|
|
787
|
-
|
|
788
|
-
should "display correct submit button in erb" do
|
|
789
|
-
visit '/erb/form_for'
|
|
790
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
|
791
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
|
792
|
-
end
|
|
793
|
-
|
|
794
|
-
should "display correct submit button in slim" do
|
|
795
|
-
visit '/slim/form_for'
|
|
796
|
-
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
|
797
|
-
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
|
798
|
-
end
|
|
799
|
-
end
|
|
800
|
-
|
|
801
|
-
context 'for #image_submit method' do
|
|
802
|
-
setup do
|
|
803
|
-
@stamp = stop_time_for_test.to_i
|
|
804
|
-
end
|
|
805
|
-
|
|
806
|
-
should "display correct image submit button html with no options" do
|
|
807
|
-
actual_html = standard_builder.image_submit('buttons/ok.png')
|
|
808
|
-
assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
|
809
|
-
end
|
|
810
|
-
|
|
811
|
-
should "display correct image submit button html" do
|
|
812
|
-
actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
|
|
813
|
-
assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
|
|
814
|
-
end
|
|
815
|
-
|
|
816
|
-
should "display correct image submit button in haml" do
|
|
817
|
-
visit '/haml/form_for'
|
|
818
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
|
819
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
|
820
|
-
end
|
|
821
|
-
|
|
822
|
-
should "display correct image submit button in erb" do
|
|
823
|
-
visit '/erb/form_for'
|
|
824
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
|
825
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
|
826
|
-
end
|
|
827
|
-
|
|
828
|
-
should "display correct image submit button in slim" do
|
|
829
|
-
visit '/slim/form_for'
|
|
830
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
|
831
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
|
832
|
-
end
|
|
833
|
-
end
|
|
834
|
-
|
|
835
|
-
context 'for #fields_for method' do
|
|
836
|
-
setup do
|
|
837
|
-
@telephone = mock_model("Telephone", :number => "4568769876")
|
|
838
|
-
@user.stubs(:telephone).returns(@telephone)
|
|
839
|
-
@businesses = [ mock_model("Business", :name => "Silver", :new_record? => false, :id => 20) ]
|
|
840
|
-
@businesses << mock_model("Business", :name => "Gold", :new_record? => true)
|
|
841
|
-
@addresses = [ mock_model("Address", :name => "Foo", :new_record? => false, :id => 20, :businesses => @businesses) ]
|
|
842
|
-
@addresses << mock_model("Address", :name => "Bar", :new_record? => true, :businesses => @businesses)
|
|
843
|
-
@user.stubs(:addresses).returns(@addresses)
|
|
844
|
-
end
|
|
845
|
-
|
|
846
|
-
should "display nested children fields one-to-one within form" do
|
|
847
|
-
actual_html = standard_builder.fields_for :telephone do |child_form|
|
|
848
|
-
child_form.label(:number) +
|
|
849
|
-
child_form.text_field(:number) +
|
|
850
|
-
child_form.check_box('_destroy')
|
|
851
|
-
end
|
|
852
|
-
assert_has_tag('label', :for => 'user_telephone_attributes_number') { actual_html }
|
|
853
|
-
assert_has_tag('input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876") { actual_html }
|
|
854
|
-
assert_has_tag('input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0') { actual_html }
|
|
855
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1') { actual_html }
|
|
856
|
-
end
|
|
857
|
-
|
|
858
|
-
should "display nested children fields one-to-many within form" do
|
|
859
|
-
actual_html = standard_builder.fields_for(:addresses) do |child_form|
|
|
860
|
-
html = child_form.label(:name)
|
|
861
|
-
html << child_form.check_box('_destroy') unless child_form.object.new_record?
|
|
862
|
-
html << child_form.text_field(:name)
|
|
863
|
-
end
|
|
864
|
-
# Address 1 (Saved)
|
|
865
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
|
|
866
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
|
867
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]') { actual_html }
|
|
868
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
|
|
869
|
-
# Address 2 (New)
|
|
870
|
-
assert_has_no_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_1_id') { actual_html }
|
|
871
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_1_name', :content => 'Name') { actual_html }
|
|
872
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]') { actual_html }
|
|
873
|
-
assert_has_no_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy') { actual_html }
|
|
874
|
-
end
|
|
875
|
-
|
|
876
|
-
should "display fields for explicit instance object" do
|
|
877
|
-
address = mock_model("Address", :name => "Page", :new_record? => false, :id => 40)
|
|
878
|
-
actual_html = standard_builder.fields_for(:addresses, address) do |child_form|
|
|
879
|
-
html = child_form.label(:name)
|
|
880
|
-
html << child_form.text_field(:name)
|
|
881
|
-
html << child_form.check_box('_destroy')
|
|
882
|
-
end
|
|
883
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40') { actual_html }
|
|
884
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
|
885
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page") { actual_html }
|
|
886
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1') { actual_html }
|
|
887
|
-
end
|
|
888
|
-
|
|
889
|
-
should "display fields for collection object" do
|
|
890
|
-
addresses = @addresses + [mock_model("Address", :name => "Walter", :new_record? => false, :id => 50)]
|
|
891
|
-
actual_html = standard_builder.fields_for(:addresses, addresses) do |child_form|
|
|
892
|
-
child_form.label(:name) +
|
|
893
|
-
child_form.text_field(:name) +
|
|
894
|
-
child_form.check_box('_destroy')
|
|
895
|
-
end
|
|
896
|
-
# Address 1
|
|
897
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
|
|
898
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
|
|
899
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo") { actual_html }
|
|
900
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
|
|
901
|
-
# Address 3
|
|
902
|
-
assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50') { actual_html }
|
|
903
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_2_name', :content => 'Name') { actual_html }
|
|
904
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter") { actual_html }
|
|
905
|
-
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy') { actual_html }
|
|
906
|
-
end
|
|
907
|
-
|
|
908
|
-
should "display fields for arbitrarily deep nested forms" do
|
|
909
|
-
actual_html = standard_builder.fields_for :addresses do |child_form|
|
|
910
|
-
child_form.fields_for(:businesses) do |second_child_form|
|
|
911
|
-
second_child_form.label(:name) +
|
|
912
|
-
second_child_form.text_field(:name) +
|
|
913
|
-
second_child_form.check_box('_destroy')
|
|
914
|
-
end
|
|
915
|
-
end
|
|
916
|
-
assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name') { actual_html }
|
|
917
|
-
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
|
|
918
|
-
end
|
|
919
|
-
|
|
920
|
-
should "display nested children fields in erb" do
|
|
921
|
-
visit '/erb/fields_for'
|
|
922
|
-
# Telephone
|
|
923
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
|
924
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
|
925
|
-
# Address 1 (Saved)
|
|
926
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
|
927
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
|
928
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
|
929
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
|
930
|
-
# Address 2 (New)
|
|
931
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
|
932
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
|
933
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
|
934
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
should "display nested children fields in haml" do
|
|
938
|
-
visit '/haml/fields_for'
|
|
939
|
-
# Telephone
|
|
940
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
|
941
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
|
942
|
-
# Address 1 (Saved)
|
|
943
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
|
944
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
|
945
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
|
946
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
|
947
|
-
# Address 2 (New)
|
|
948
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
|
949
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
|
950
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
|
951
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
|
952
|
-
end
|
|
953
|
-
|
|
954
|
-
should "display nested children fields in slim" do
|
|
955
|
-
visit '/slim/fields_for'
|
|
956
|
-
# Telephone
|
|
957
|
-
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
|
958
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
|
959
|
-
# Address 1 (Saved)
|
|
960
|
-
assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
|
961
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
|
962
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
|
963
|
-
assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
|
964
|
-
# Address 2 (New)
|
|
965
|
-
assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
|
966
|
-
assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
|
967
|
-
assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
|
968
|
-
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
|
969
|
-
end
|
|
970
|
-
end
|
|
971
|
-
|
|
972
|
-
# ===========================
|
|
973
|
-
# StandardFormBuilder
|
|
974
|
-
# ===========================
|
|
975
|
-
|
|
976
|
-
context 'for #text_field_block method' do
|
|
977
|
-
should "display correct text field block html" do
|
|
978
|
-
actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
|
|
979
|
-
assert_has_tag('p label', :for => 'user_first_name', :content => "FName") { actual_html }
|
|
980
|
-
assert_has_tag('p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
|
981
|
-
end
|
|
982
|
-
|
|
983
|
-
should "display correct text field block in haml" do
|
|
984
|
-
visit '/haml/form_for'
|
|
985
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
|
986
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
|
987
|
-
end
|
|
988
|
-
|
|
989
|
-
should "display correct text field block in erb" do
|
|
990
|
-
visit '/erb/form_for'
|
|
991
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
|
992
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
|
993
|
-
end
|
|
994
|
-
|
|
995
|
-
should "display correct text field block in slim" do
|
|
996
|
-
visit '/slim/form_for'
|
|
997
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
|
998
|
-
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
|
999
|
-
end
|
|
1000
|
-
end
|
|
1001
|
-
|
|
1002
|
-
context 'for #text_area_block method' do
|
|
1003
|
-
should "display correct text area block html" do
|
|
1004
|
-
actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
|
|
1005
|
-
assert_has_tag('p label', :for => 'user_about', :content => "About Me") { actual_html }
|
|
1006
|
-
assert_has_tag('p textarea', :id => 'user_about', :name => 'user[about]') { actual_html }
|
|
1007
|
-
end
|
|
1008
|
-
|
|
1009
|
-
should "display correct text area block in haml" do
|
|
1010
|
-
visit '/haml/form_for'
|
|
1011
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
|
1012
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
|
1013
|
-
end
|
|
1014
|
-
|
|
1015
|
-
should "display correct text area block in erb" do
|
|
1016
|
-
visit '/erb/form_for'
|
|
1017
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
|
1018
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
|
1019
|
-
end
|
|
1020
|
-
|
|
1021
|
-
should "display correct text area block in slim" do
|
|
1022
|
-
visit '/slim/form_for'
|
|
1023
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
|
1024
|
-
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
|
1025
|
-
end
|
|
1026
|
-
end
|
|
1027
|
-
|
|
1028
|
-
context 'for #password_field_block method' do
|
|
1029
|
-
should "display correct password field block html" do
|
|
1030
|
-
actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
|
|
1031
|
-
assert_has_tag('p label', :for => 'user_keycode', :content => "Code: ") { actual_html }
|
|
1032
|
-
assert_has_tag('p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]') { actual_html }
|
|
1033
|
-
end
|
|
1034
|
-
|
|
1035
|
-
should "display correct password field block in haml" do
|
|
1036
|
-
visit '/haml/form_for'
|
|
1037
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
|
1038
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
|
1039
|
-
end
|
|
1040
|
-
|
|
1041
|
-
should "display correct password field block in erb" do
|
|
1042
|
-
visit '/erb/form_for'
|
|
1043
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
|
1044
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
|
1045
|
-
end
|
|
1046
|
-
|
|
1047
|
-
should "display correct password field block in slim" do
|
|
1048
|
-
visit '/slim/form_for'
|
|
1049
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
|
1050
|
-
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
|
1051
|
-
end
|
|
1052
|
-
end
|
|
1053
|
-
|
|
1054
|
-
context 'for #file_field_block method' do
|
|
1055
|
-
should "display correct file field block html" do
|
|
1056
|
-
actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
|
|
1057
|
-
assert_has_tag('p label', :for => 'user_photo', :content => "Photo: ") { actual_html }
|
|
1058
|
-
assert_has_tag('p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
|
1059
|
-
end
|
|
1060
|
-
|
|
1061
|
-
should "display correct file field block in haml" do
|
|
1062
|
-
visit '/haml/form_for'
|
|
1063
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
|
1064
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
1065
|
-
end
|
|
1066
|
-
|
|
1067
|
-
should "display correct file field block in erb" do
|
|
1068
|
-
visit '/erb/form_for'
|
|
1069
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
|
1070
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
1071
|
-
end
|
|
1072
|
-
|
|
1073
|
-
should "display correct file field block in slim" do
|
|
1074
|
-
visit '/slim/form_for'
|
|
1075
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
|
1076
|
-
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
|
1077
|
-
end
|
|
1078
|
-
end
|
|
1079
|
-
|
|
1080
|
-
context 'for #check_box_block method' do
|
|
1081
|
-
should "display correct check box block html" do
|
|
1082
|
-
actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
|
|
1083
|
-
assert_has_tag('p label', :for => 'user_remember_me', :content => "Remember session?") { actual_html }
|
|
1084
|
-
assert_has_tag('p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]') { actual_html }
|
|
1085
|
-
end
|
|
1086
|
-
|
|
1087
|
-
should "display correct check box block in haml" do
|
|
1088
|
-
visit '/haml/form_for'
|
|
1089
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
|
1090
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
|
1091
|
-
end
|
|
1092
|
-
|
|
1093
|
-
should "display correct check box block in erb" do
|
|
1094
|
-
visit '/erb/form_for'
|
|
1095
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
|
1096
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
|
1097
|
-
end
|
|
1098
|
-
|
|
1099
|
-
should "display correct check box block in slim" do
|
|
1100
|
-
visit '/slim/form_for'
|
|
1101
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
|
1102
|
-
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
|
1103
|
-
end
|
|
1104
|
-
end
|
|
1105
|
-
|
|
1106
|
-
context 'for #select_block method' do
|
|
1107
|
-
should "display correct select_block block html" do
|
|
1108
|
-
actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
|
|
1109
|
-
assert_has_tag('p label', :for => 'user_country', :content => "Your country") { actual_html }
|
|
1110
|
-
assert_has_tag('p select', :id => 'user_country', :name => 'user[country]') { actual_html }
|
|
1111
|
-
assert_has_tag('p select option', :content => 'USA') { actual_html }
|
|
1112
|
-
assert_has_tag('p select option', :content => 'Canada') { actual_html }
|
|
1113
|
-
end
|
|
1114
|
-
|
|
1115
|
-
should "display correct select_block block in haml" do
|
|
1116
|
-
visit '/haml/form_for'
|
|
1117
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
|
1118
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
|
1119
|
-
assert_have_selector '#demo2 p select option', :content => 'California'
|
|
1120
|
-
assert_have_selector '#demo2 p select option', :content => 'Texas'
|
|
1121
|
-
end
|
|
1122
|
-
|
|
1123
|
-
should "display correct select_block block in erb" do
|
|
1124
|
-
visit '/erb/form_for'
|
|
1125
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
|
1126
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
|
1127
|
-
end
|
|
1128
|
-
|
|
1129
|
-
should "display correct select_block block in slim" do
|
|
1130
|
-
visit '/slim/form_for'
|
|
1131
|
-
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
|
1132
|
-
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
|
1133
|
-
end
|
|
1134
|
-
end
|
|
1135
|
-
|
|
1136
|
-
context 'for #submit_block method' do
|
|
1137
|
-
should "display correct submit block html" do
|
|
1138
|
-
actual_html = standard_builder.submit_block("Update", :class => 'large')
|
|
1139
|
-
assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
|
|
1140
|
-
end
|
|
1141
|
-
|
|
1142
|
-
should "display correct submit block in haml" do
|
|
1143
|
-
visit '/haml/form_for'
|
|
1144
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
|
1145
|
-
end
|
|
1146
|
-
|
|
1147
|
-
should "display correct submit block in erb" do
|
|
1148
|
-
visit '/erb/form_for'
|
|
1149
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
|
1150
|
-
end
|
|
1151
|
-
|
|
1152
|
-
should "display correct submit block in slim" do
|
|
1153
|
-
visit '/slim/form_for'
|
|
1154
|
-
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
|
1155
|
-
end
|
|
1156
|
-
end
|
|
1157
|
-
|
|
1158
|
-
context 'for #image_submit_block method' do
|
|
1159
|
-
setup do
|
|
1160
|
-
@stamp = stop_time_for_test.to_i
|
|
1161
|
-
end
|
|
1162
|
-
|
|
1163
|
-
should "display correct image submit block html" do
|
|
1164
|
-
actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
|
|
1165
|
-
assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
|
1166
|
-
end
|
|
1167
|
-
|
|
1168
|
-
should "display correct image submit block in haml" do
|
|
1169
|
-
visit '/haml/form_for'
|
|
1170
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
|
1171
|
-
end
|
|
1172
|
-
|
|
1173
|
-
should "display correct image submit block in slim" do
|
|
1174
|
-
visit '/slim/form_for'
|
|
1175
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
|
1176
|
-
end
|
|
1177
|
-
end
|
|
1178
|
-
end
|