unpoly-rails 0.62.0 → 2.0.0.pre.rc5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +66 -1
- data/README.md +3 -11
- data/README_RAILS.md +295 -14
- data/dist/unpoly-bootstrap3.css +9 -14
- data/dist/unpoly-bootstrap3.js +4 -18
- data/dist/unpoly-bootstrap3.min.css +1 -1
- data/dist/unpoly-bootstrap3.min.js +1 -1
- data/dist/unpoly-bootstrap4.css +9 -0
- data/dist/unpoly-bootstrap4.js +16 -0
- data/dist/unpoly-bootstrap4.min.css +1 -0
- data/dist/unpoly-bootstrap4.min.js +1 -0
- data/dist/unpoly-bootstrap5.css +9 -0
- data/dist/unpoly-bootstrap5.js +14 -0
- data/dist/unpoly-bootstrap5.min.css +1 -0
- data/dist/unpoly-bootstrap5.min.js +1 -0
- data/dist/unpoly-migrate.js +1213 -0
- data/dist/unpoly-migrate.min.js +1 -0
- data/dist/unpoly.css +109 -140
- data/dist/unpoly.js +15679 -10537
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +6 -4
- data/lib/unpoly-rails.rb +9 -3
- data/lib/unpoly/rails/change.rb +372 -0
- data/lib/unpoly/rails/change/cache.rb +26 -0
- data/lib/unpoly/rails/change/context.rb +80 -0
- data/lib/unpoly/rails/change/field.rb +117 -0
- data/lib/unpoly/rails/change/field_definition.rb +74 -0
- data/lib/unpoly/rails/change/layer.rb +60 -0
- data/lib/unpoly/rails/controller.rb +47 -0
- data/lib/unpoly/rails/error.rb +5 -0
- data/lib/unpoly/rails/request_echo_headers.rb +2 -2
- data/lib/unpoly/rails/version.rb +1 -1
- data/lib/unpoly/tasks.rb +45 -0
- metadata +43 -313
- data/.gitignore +0 -10
- data/.ruby-version +0 -1
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -45
- data/Rakefile +0 -145
- data/bower.json +0 -27
- data/design/animation-ghosting.txt +0 -72
- data/design/design.txt +0 -34
- data/design/draft.html.erb +0 -48
- data/design/draft.rb +0 -9
- data/design/es6.js +0 -32
- data/design/ghost-debugging.txt +0 -118
- data/design/homepage.txt +0 -236
- data/design/ie11.txt +0 -9
- data/design/measure_import_node.js +0 -330
- data/design/measure_jquery/element_list.js +0 -41
- data/design/measure_jquery/up.on_vs_addEventListener.js +0 -56
- data/design/positioning.txt +0 -28
- data/design/query-params-in-form-actions/cases.html +0 -125
- data/design/rename.txt +0 -0
- data/design/test_rejected_promise.txt +0 -5
- data/design/unpoly errors.txt +0 -19
- data/lib/assets/javascripts/unpoly-bootstrap3.coffee +0 -2
- data/lib/assets/javascripts/unpoly-bootstrap3/feedback-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.coffee +0 -1
- data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.coffee +0 -14
- data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly.coffee +0 -28
- data/lib/assets/javascripts/unpoly/browser.coffee.erb +0 -240
- data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +0 -36
- data/lib/assets/javascripts/unpoly/classes/cache.coffee +0 -127
- data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +0 -93
- data/lib/assets/javascripts/unpoly/classes/config.coffee +0 -9
- data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +0 -118
- data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +0 -39
- data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +0 -116
- data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +0 -86
- data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +0 -111
- data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +0 -80
- data/lib/assets/javascripts/unpoly/classes/focus_follower.coffee +0 -29
- data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +0 -64
- data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +0 -46
- data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +0 -157
- data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +0 -543
- data/lib/assets/javascripts/unpoly/classes/record.coffee +0 -22
- data/lib/assets/javascripts/unpoly/classes/rect.js +0 -21
- data/lib/assets/javascripts/unpoly/classes/request.coffee +0 -246
- data/lib/assets/javascripts/unpoly/classes/response.coffee +0 -157
- data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +0 -102
- data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +0 -67
- data/lib/assets/javascripts/unpoly/classes/selector.coffee +0 -60
- data/lib/assets/javascripts/unpoly/classes/store/memory.coffee +0 -26
- data/lib/assets/javascripts/unpoly/classes/store/session.coffee +0 -59
- data/lib/assets/javascripts/unpoly/classes/tether.coffee +0 -105
- data/lib/assets/javascripts/unpoly/classes/url_set.coffee +0 -32
- data/lib/assets/javascripts/unpoly/cookie.coffee +0 -56
- data/lib/assets/javascripts/unpoly/element.coffee.erb +0 -1126
- data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -445
- data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
- data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1069
- data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -928
- data/lib/assets/javascripts/unpoly/framework.coffee +0 -67
- data/lib/assets/javascripts/unpoly/history.coffee +0 -268
- data/lib/assets/javascripts/unpoly/legacy.coffee +0 -60
- data/lib/assets/javascripts/unpoly/link.coffee.erb +0 -622
- data/lib/assets/javascripts/unpoly/log.coffee +0 -248
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -826
- data/lib/assets/javascripts/unpoly/motion.coffee.erb +0 -668
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
- data/lib/assets/javascripts/unpoly/popup.coffee.erb +0 -515
- data/lib/assets/javascripts/unpoly/protocol.coffee +0 -298
- data/lib/assets/javascripts/unpoly/proxy.coffee +0 -672
- data/lib/assets/javascripts/unpoly/radio.coffee +0 -60
- data/lib/assets/javascripts/unpoly/rails.coffee +0 -24
- data/lib/assets/javascripts/unpoly/syntax.coffee.erb +0 -477
- data/lib/assets/javascripts/unpoly/toast.coffee +0 -67
- data/lib/assets/javascripts/unpoly/tooltip.coffee +0 -276
- data/lib/assets/javascripts/unpoly/util.coffee.erb +0 -1676
- data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -830
- data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
- data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
- data/lib/assets/stylesheets/unpoly.sass +0 -1
- data/lib/assets/stylesheets/unpoly/close.sass +0 -2
- data/lib/assets/stylesheets/unpoly/dom.sass +0 -5
- data/lib/assets/stylesheets/unpoly/layout.sass +0 -2
- data/lib/assets/stylesheets/unpoly/link.sass +0 -2
- data/lib/assets/stylesheets/unpoly/modal.sass +0 -116
- data/lib/assets/stylesheets/unpoly/popup.sass +0 -7
- data/lib/assets/stylesheets/unpoly/toast.sass +0 -33
- data/lib/assets/stylesheets/unpoly/tooltip.sass +0 -62
- data/lib/unpoly/rails/inspector.rb +0 -149
- data/lib/unpoly/rails/inspector_accessor.rb +0 -30
- data/package.json +0 -38
- data/spec_app/.firefox-version +0 -1
- data/spec_app/.gitignore +0 -17
- data/spec_app/.rspec +0 -2
- data/spec_app/Gemfile +0 -30
- data/spec_app/Gemfile.lock +0 -229
- data/spec_app/README.rdoc +0 -28
- data/spec_app/Rakefile +0 -6
- data/spec_app/app/assets/images/.keep +0 -0
- data/spec_app/app/assets/images/favicon.png +0 -0
- data/spec_app/app/assets/images/grid.png +0 -0
- data/spec_app/app/assets/javascripts/bootstrap_manifest.coffee +0 -6
- data/spec_app/app/assets/javascripts/integration_test.coffee +0 -6
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +0 -6
- data/spec_app/app/assets/stylesheets/_helpers.sass +0 -5
- data/spec_app/app/assets/stylesheets/bootstrap_manifest.sass +0 -2
- data/spec_app/app/assets/stylesheets/integration_test.sass +0 -88
- data/spec_app/app/assets/stylesheets/jasmine_specs.sass +0 -20
- data/spec_app/app/controllers/application_controller.rb +0 -14
- data/spec_app/app/controllers/binding_test_controller.rb +0 -51
- data/spec_app/app/controllers/compiler_test_controller.rb +0 -5
- data/spec_app/app/controllers/css_test_controller.rb +0 -5
- data/spec_app/app/controllers/error_test_controller.rb +0 -5
- data/spec_app/app/controllers/form_test/basics_controller.rb +0 -14
- data/spec_app/app/controllers/form_test/redirects_controller.rb +0 -17
- data/spec_app/app/controllers/form_test/uploads_controller.rb +0 -15
- data/spec_app/app/controllers/hash_test_controller.rb +0 -5
- data/spec_app/app/controllers/method_test_controller.rb +0 -16
- data/spec_app/app/controllers/motion_test_controller.rb +0 -5
- data/spec_app/app/controllers/pages_controller.rb +0 -9
- data/spec_app/app/controllers/replace_test_controller.rb +0 -5
- data/spec_app/app/controllers/reveal_test_controller.rb +0 -5
- data/spec_app/app/controllers/scroll_test_controller.rb +0 -5
- data/spec_app/app/helpers/application_helper.rb +0 -2
- data/spec_app/app/mailers/.keep +0 -0
- data/spec_app/app/models/concerns/.keep +0 -0
- data/spec_app/app/views/compiler_test/timestamp.erb +0 -9
- data/spec_app/app/views/css_test/modal.erb +0 -47
- data/spec_app/app/views/css_test/modal_contents.erb +0 -5
- data/spec_app/app/views/css_test/modal_contents_wide.erb +0 -5
- data/spec_app/app/views/css_test/popup.erb +0 -81
- data/spec_app/app/views/css_test/popup_contents.erb +0 -5
- data/spec_app/app/views/css_test/tooltip.erb +0 -48
- data/spec_app/app/views/error_test/trigger.erb +0 -80
- data/spec_app/app/views/error_test/unexpected_response.erb +0 -3
- data/spec_app/app/views/form_test/basics/new.erb +0 -60
- data/spec_app/app/views/form_test/redirects/new.erb +0 -27
- data/spec_app/app/views/form_test/redirects/target.erb +0 -4
- data/spec_app/app/views/form_test/submission_result.erb +0 -30
- data/spec_app/app/views/form_test/uploads/new.erb +0 -44
- data/spec_app/app/views/hash_test/unpoly.erb +0 -30
- data/spec_app/app/views/hash_test/vanilla.erb +0 -13
- data/spec_app/app/views/layouts/integration_test.erb +0 -22
- data/spec_app/app/views/layouts/jasmine_rails/spec_runner.html.erb +0 -20
- data/spec_app/app/views/method_test/form_target.erb +0 -17
- data/spec_app/app/views/method_test/page1.erb +0 -11
- data/spec_app/app/views/method_test/page2.erb +0 -6
- data/spec_app/app/views/motion_test/animations.erb +0 -16
- data/spec_app/app/views/motion_test/transitions.erb +0 -13
- data/spec_app/app/views/pages/start.erb +0 -79
- data/spec_app/app/views/replace_test/_nav.erb +0 -6
- data/spec_app/app/views/replace_test/page1.erb +0 -14
- data/spec_app/app/views/replace_test/page2.erb +0 -14
- data/spec_app/app/views/replace_test/table.erb +0 -16
- data/spec_app/app/views/reveal_test/long1.erb +0 -17
- data/spec_app/app/views/reveal_test/long2.erb +0 -17
- data/spec_app/app/views/reveal_test/within_document_viewport.erb +0 -24
- data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +0 -28
- data/spec_app/app/views/scroll_test/long1.erb +0 -30
- data/spec_app/bin/bundle +0 -3
- data/spec_app/bin/rails +0 -8
- data/spec_app/bin/rake +0 -8
- data/spec_app/bin/setup +0 -29
- data/spec_app/bin/spring +0 -18
- data/spec_app/config.ru +0 -4
- data/spec_app/config/application.rb +0 -28
- data/spec_app/config/boot.rb +0 -3
- data/spec_app/config/database.yml +0 -25
- data/spec_app/config/environment.rb +0 -5
- data/spec_app/config/environments/development.rb +0 -41
- data/spec_app/config/environments/production.rb +0 -79
- data/spec_app/config/environments/test.rb +0 -42
- data/spec_app/config/initializers/assets.rb +0 -19
- data/spec_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec_app/config/initializers/bower_rails.rb +0 -16
- data/spec_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec_app/config/initializers/inflections.rb +0 -16
- data/spec_app/config/initializers/mime_types.rb +0 -4
- data/spec_app/config/initializers/session_store.rb +0 -3
- data/spec_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec_app/config/locales/en.yml +0 -23
- data/spec_app/config/routes.rb +0 -30
- data/spec_app/config/secrets.yml +0 -22
- data/spec_app/db/schema.rb +0 -23
- data/spec_app/db/seeds.rb +0 -7
- data/spec_app/lib/assets/.keep +0 -0
- data/spec_app/lib/tasks/.keep +0 -0
- data/spec_app/lib/tasks/cucumber.rake +0 -65
- data/spec_app/log/.keep +0 -0
- data/spec_app/public/404.html +0 -67
- data/spec_app/public/422.html +0 -67
- data/spec_app/public/500.html +0 -66
- data/spec_app/public/favicon.ico +0 -0
- data/spec_app/public/robots.txt +0 -5
- data/spec_app/script/cucumber +0 -10
- data/spec_app/spec/controllers/binding_test_controller_spec.rb +0 -248
- data/spec_app/spec/javascripts/helpers/agent_detector.coffee +0 -20
- data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +0 -103
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +0 -21
- data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/fixture.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/index.js.coffee +0 -1
- data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +0 -1
- data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -69
- data/spec_app/spec/javascripts/helpers/last_request.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +0 -24
- data/spec_app/spec/javascripts/helpers/promise_state.js +0 -18
- data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +0 -23
- data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/spec_util.coffee +0 -47
- data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_array.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_error.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_jquery.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +0 -15
- data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +0 -16
- data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -18
- data/spec_app/spec/javascripts/helpers/to_match_list.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +0 -13
- data/spec_app/spec/javascripts/helpers/to_match_url.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +0 -200
- data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +0 -5
- data/spec_app/spec/javascripts/support/jasmine.yml +0 -51
- data/spec_app/spec/javascripts/up/browser_spec.js.coffee +0 -150
- data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +0 -82
- data/spec_app/spec/javascripts/up/classes/config_spec.coffee +0 -24
- data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +0 -45
- data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +0 -34
- data/spec_app/spec/javascripts/up/classes/params_spec.coffee +0 -557
- data/spec_app/spec/javascripts/up/classes/request_spec.coffee +0 -50
- data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +0 -51
- data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +0 -70
- data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +0 -114
- data/spec_app/spec/javascripts/up/element_spec.coffee +0 -897
- data/spec_app/spec/javascripts/up/event_spec.js.coffee +0 -530
- data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +0 -401
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +0 -1527
- data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +0 -2611
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +0 -340
- data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +0 -4
- data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +0 -27
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +0 -1098
- data/spec_app/spec/javascripts/up/log_spec.js.coffee +0 -119
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +0 -918
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +0 -582
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +0 -508
- data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +0 -39
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +0 -1137
- data/spec_app/spec/javascripts/up/radio_spec.js.coffee +0 -212
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +0 -118
- data/spec_app/spec/javascripts/up/spec_spec.js.coffee +0 -9
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +0 -304
- data/spec_app/spec/javascripts/up/toast_spec.js.coffee +0 -37
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +0 -163
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +0 -1420
- data/spec_app/spec/javascripts/up/viewport_spec.js.coffee +0 -655
- data/spec_app/spec/spec_helper.rb +0 -62
- data/spec_app/test/controllers/.keep +0 -0
- data/spec_app/test/fixtures/.keep +0 -0
- data/spec_app/test/helpers/.keep +0 -0
- data/spec_app/test/integration/.keep +0 -0
- data/spec_app/test/mailers/.keep +0 -0
- data/spec_app/test/models/.keep +0 -0
- data/spec_app/test/test_helper.rb +0 -10
- data/spec_app/vendor/asset-libs/es6-promise-4.1.6/es6-promise.auto.js +0 -1159
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.bower.json +0 -43
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +0 -10
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +0 -56
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js +0 -790
- data/spec_app/vendor/assets/.keep +0 -0
- data/unpoly-rails.gemspec +0 -24
@@ -1,39 +0,0 @@
|
|
1
|
-
u = up.util
|
2
|
-
$ = jQuery
|
3
|
-
|
4
|
-
describe 'up.protocol', ->
|
5
|
-
|
6
|
-
describe 'up.protocol.csrfToken', ->
|
7
|
-
|
8
|
-
afterEach ->
|
9
|
-
@$meta?.remove()
|
10
|
-
|
11
|
-
it 'returns the [content] of a <meta name="csrf-token"> by default', ->
|
12
|
-
@$meta = $('<meta name="csrf-token" content="token-from-meta">').appendTo('head')
|
13
|
-
expect(up.protocol.csrfToken()).toEqual('token-from-meta')
|
14
|
-
|
15
|
-
it 'returns a configured token', ->
|
16
|
-
up.protocol.config.csrfToken = 'configured-token'
|
17
|
-
expect(up.protocol.csrfToken()).toEqual('configured-token')
|
18
|
-
|
19
|
-
it 'allows to configure a function that returns the token', ->
|
20
|
-
up.protocol.config.csrfToken = -> 'configured-token'
|
21
|
-
expect(up.protocol.csrfToken()).toEqual('configured-token')
|
22
|
-
|
23
|
-
describe 'up.protocol.csrfParam()', ->
|
24
|
-
|
25
|
-
afterEach ->
|
26
|
-
@$meta?.remove()
|
27
|
-
|
28
|
-
it 'returns the [content] of a <meta name="csrf-param"> by default', ->
|
29
|
-
@$meta = $('<meta name="csrf-param" content="param-from-meta">').appendTo('head')
|
30
|
-
expect(up.protocol.csrfParam()).toEqual('param-from-meta')
|
31
|
-
|
32
|
-
it 'returns a configured parameter name', ->
|
33
|
-
up.protocol.config.csrfParam = 'configured-param'
|
34
|
-
expect(up.protocol.csrfParam()).toEqual('configured-param')
|
35
|
-
|
36
|
-
it 'allows to configure a function that returns the parameter name', ->
|
37
|
-
up.protocol.config.csrfParam = -> 'configured-param'
|
38
|
-
expect(up.protocol.csrfParam()).toEqual('configured-param')
|
39
|
-
|
@@ -1,1137 +0,0 @@
|
|
1
|
-
u = up.util
|
2
|
-
$ = jQuery
|
3
|
-
|
4
|
-
describe 'up.proxy', ->
|
5
|
-
|
6
|
-
describe 'JavaScript functions', ->
|
7
|
-
|
8
|
-
describe 'up.request', ->
|
9
|
-
|
10
|
-
it 'makes a request with the given URL and params', ->
|
11
|
-
up.request('/foo', params: { key: 'value' }, method: 'post')
|
12
|
-
request = @lastRequest()
|
13
|
-
expect(request.url).toMatchUrl('/foo')
|
14
|
-
expect(request.data()).toEqual(key: ['value'])
|
15
|
-
expect(request.method).toEqual('POST')
|
16
|
-
|
17
|
-
it 'also allows to pass the URL as a { url } option instead', ->
|
18
|
-
up.request(url: '/foo', params: { key: 'value' }, method: 'post')
|
19
|
-
request = @lastRequest()
|
20
|
-
expect(request.url).toMatchUrl('/foo')
|
21
|
-
expect(request.data()).toEqual(key: ['value'])
|
22
|
-
expect(request.method).toEqual('POST')
|
23
|
-
|
24
|
-
it 'allows to pass in an up.Request instance instead of an options object', ->
|
25
|
-
requestArg = new up.Request(url: '/foo', params: { key: 'value' }, method: 'post')
|
26
|
-
up.request(requestArg)
|
27
|
-
|
28
|
-
jasmineRequest = @lastRequest()
|
29
|
-
expect(jasmineRequest.url).toMatchUrl('/foo')
|
30
|
-
expect(jasmineRequest.data()).toEqual(key: ['value'])
|
31
|
-
expect(jasmineRequest.method).toEqual('POST')
|
32
|
-
|
33
|
-
it 'submits the replacement targets as HTTP headers, so the server may choose to only frender the requested fragments', asyncSpec (next) ->
|
34
|
-
up.request(url: '/foo', target: '.target', failTarget: '.fail-target')
|
35
|
-
|
36
|
-
next =>
|
37
|
-
request = @lastRequest()
|
38
|
-
expect(request.requestHeaders['X-Up-Target']).toEqual('.target')
|
39
|
-
expect(request.requestHeaders['X-Up-Fail-Target']).toEqual('.fail-target')
|
40
|
-
|
41
|
-
it 'resolves to a Response object that contains information about the response and request', (done) ->
|
42
|
-
promise = up.request(
|
43
|
-
url: '/url'
|
44
|
-
params: { key: 'value' }
|
45
|
-
method: 'post'
|
46
|
-
target: '.target'
|
47
|
-
)
|
48
|
-
|
49
|
-
u.task =>
|
50
|
-
@respondWith(
|
51
|
-
status: 201,
|
52
|
-
responseText: 'response-text'
|
53
|
-
)
|
54
|
-
|
55
|
-
promise.then (response) ->
|
56
|
-
expect(response.request.url).toMatchUrl('/url')
|
57
|
-
expect(response.request.params).toEqual(new up.Params(key: 'value'))
|
58
|
-
expect(response.request.method).toEqual('POST')
|
59
|
-
expect(response.request.target).toEqual('.target')
|
60
|
-
expect(response.request.hash).toBeBlank()
|
61
|
-
|
62
|
-
expect(response.url).toMatchUrl('/url') # If the server signaled a redirect with X-Up-Location, this would be reflected here
|
63
|
-
expect(response.method).toEqual('POST') # If the server sent a X-Up-Method header, this would be reflected here
|
64
|
-
expect(response.text).toEqual('response-text')
|
65
|
-
expect(response.status).toEqual(201)
|
66
|
-
expect(response.xhr).toBePresent()
|
67
|
-
|
68
|
-
done()
|
69
|
-
|
70
|
-
it 'resolves to a Response that contains the response headers', (done) ->
|
71
|
-
promise = up.request(url: '/url')
|
72
|
-
|
73
|
-
u.task =>
|
74
|
-
@respondWith
|
75
|
-
responseHeaders: { 'foo': 'bar', 'baz': 'bam' }
|
76
|
-
responseText: 'hello'
|
77
|
-
|
78
|
-
promise.then (response) ->
|
79
|
-
expect(response.getHeader('foo')).toEqual('bar')
|
80
|
-
|
81
|
-
# Lookup is case-insensitive
|
82
|
-
expect(response.getHeader('BAZ')).toEqual('bam')
|
83
|
-
|
84
|
-
done()
|
85
|
-
|
86
|
-
it "preserves the URL hash in a separate { hash } property, since although it isn't sent to server, code might need it to process the response", (done) ->
|
87
|
-
promise = up.request('/url#hash')
|
88
|
-
|
89
|
-
u.task =>
|
90
|
-
request = @lastRequest()
|
91
|
-
expect(request.url).toMatchUrl('/url')
|
92
|
-
|
93
|
-
@respondWith('response-text')
|
94
|
-
|
95
|
-
promise.then (response) ->
|
96
|
-
expect(response.request.url).toMatchUrl('/url')
|
97
|
-
expect(response.request.hash).toEqual('#hash')
|
98
|
-
expect(response.url).toMatchUrl('/url')
|
99
|
-
done()
|
100
|
-
|
101
|
-
describe 'when the server responds with an X-Up-Method header', ->
|
102
|
-
|
103
|
-
it 'updates the { method } property in the response object', (done) ->
|
104
|
-
promise = up.request(
|
105
|
-
url: '/url'
|
106
|
-
params: { key: 'value' }
|
107
|
-
method: 'post'
|
108
|
-
target: '.target'
|
109
|
-
)
|
110
|
-
|
111
|
-
u.task =>
|
112
|
-
@respondWith(
|
113
|
-
responseHeaders:
|
114
|
-
'X-Up-Location': '/redirect'
|
115
|
-
'X-Up-Method': 'GET'
|
116
|
-
)
|
117
|
-
|
118
|
-
promise.then (response) ->
|
119
|
-
expect(response.request.url).toMatchUrl('/url')
|
120
|
-
expect(response.request.method).toEqual('POST')
|
121
|
-
expect(response.url).toMatchUrl('/redirect')
|
122
|
-
expect(response.method).toEqual('GET')
|
123
|
-
done()
|
124
|
-
|
125
|
-
describe 'when the server responds with an X-Up-Location header', ->
|
126
|
-
|
127
|
-
it 'sets the { url } property on the response object', (done) ->
|
128
|
-
promise = up.request('/request-url#request-hash')
|
129
|
-
|
130
|
-
u.task =>
|
131
|
-
@respondWith
|
132
|
-
responseHeaders:
|
133
|
-
'X-Up-Location': '/response-url'
|
134
|
-
|
135
|
-
promise.then (response) ->
|
136
|
-
expect(response.request.url).toMatchUrl('/request-url')
|
137
|
-
expect(response.request.hash).toEqual('#request-hash')
|
138
|
-
expect(response.url).toMatchUrl('/response-url')
|
139
|
-
done()
|
140
|
-
|
141
|
-
it 'considers a redirection URL an alias for the requested URL', asyncSpec (next) ->
|
142
|
-
up.request('/foo')
|
143
|
-
|
144
|
-
next =>
|
145
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
146
|
-
@respondWith
|
147
|
-
responseHeaders:
|
148
|
-
'X-Up-Location': '/bar'
|
149
|
-
'X-Up-Method': 'GET'
|
150
|
-
|
151
|
-
next =>
|
152
|
-
up.request('/bar')
|
153
|
-
|
154
|
-
next =>
|
155
|
-
# See that the cached alias is used and no additional requests are made
|
156
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
157
|
-
|
158
|
-
it 'does not considers a redirection URL an alias for the requested URL if the original request was never cached', asyncSpec (next) ->
|
159
|
-
up.request('/foo', method: 'post') # POST requests are not cached
|
160
|
-
|
161
|
-
next =>
|
162
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
163
|
-
@respondWith
|
164
|
-
responseHeaders:
|
165
|
-
'X-Up-Location': '/bar'
|
166
|
-
'X-Up-Method': 'GET'
|
167
|
-
|
168
|
-
next =>
|
169
|
-
up.request('/bar')
|
170
|
-
|
171
|
-
next =>
|
172
|
-
# See that an additional request was made
|
173
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
174
|
-
|
175
|
-
it 'does not considers a redirection URL an alias for the requested URL if the response returned a non-200 status code', asyncSpec (next) ->
|
176
|
-
up.request('/foo')
|
177
|
-
|
178
|
-
next =>
|
179
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
180
|
-
@respondWith
|
181
|
-
responseHeaders:
|
182
|
-
'X-Up-Location': '/bar'
|
183
|
-
'X-Up-Method': 'GET'
|
184
|
-
status: 500
|
185
|
-
|
186
|
-
next =>
|
187
|
-
up.request('/bar')
|
188
|
-
|
189
|
-
next =>
|
190
|
-
# See that an additional request was made
|
191
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
192
|
-
|
193
|
-
describeCapability 'canInspectFormData', ->
|
194
|
-
|
195
|
-
it "does not explode if the original request's { params } is a FormData object", asyncSpec (next) ->
|
196
|
-
up.request('/foo', method: 'post', params: new FormData()) # POST requests are not cached
|
197
|
-
|
198
|
-
next =>
|
199
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
200
|
-
@respondWith
|
201
|
-
responseHeaders:
|
202
|
-
'X-Up-Location': '/bar'
|
203
|
-
'X-Up-Method': 'GET'
|
204
|
-
|
205
|
-
next =>
|
206
|
-
@secondAjaxPromise = up.request('/bar')
|
207
|
-
|
208
|
-
next.await =>
|
209
|
-
promiseState(@secondAjaxPromise).then (result) ->
|
210
|
-
# See that the promise was not rejected due to an internal error.
|
211
|
-
expect(result.state).toEqual('pending')
|
212
|
-
|
213
|
-
|
214
|
-
describe 'when the XHR object has a { responseURL } property', ->
|
215
|
-
|
216
|
-
it 'sets the { url } property on the response object', (done) ->
|
217
|
-
promise = up.request('/request-url#request-hash')
|
218
|
-
|
219
|
-
u.task =>
|
220
|
-
@respondWith
|
221
|
-
responseURL: '/response-url'
|
222
|
-
|
223
|
-
promise.then (response) ->
|
224
|
-
expect(response.request.url).toMatchUrl('/request-url')
|
225
|
-
expect(response.request.hash).toEqual('#request-hash')
|
226
|
-
expect(response.url).toMatchUrl('/response-url')
|
227
|
-
done()
|
228
|
-
|
229
|
-
it 'considers a redirection URL an alias for the requested URL', asyncSpec (next) ->
|
230
|
-
up.request('/foo')
|
231
|
-
|
232
|
-
next =>
|
233
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
234
|
-
@respondWith
|
235
|
-
responseURL: '/bar'
|
236
|
-
|
237
|
-
next =>
|
238
|
-
up.request('/bar')
|
239
|
-
|
240
|
-
next =>
|
241
|
-
# See that the cached alias is used and no additional requests are made
|
242
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
243
|
-
|
244
|
-
it 'does not considers a redirection URL an alias for the requested URL if the original request was never cached', asyncSpec (next) ->
|
245
|
-
up.request('/foo', method: 'post') # POST requests are not cached
|
246
|
-
|
247
|
-
next =>
|
248
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
249
|
-
@respondWith
|
250
|
-
responseURL: '/bar'
|
251
|
-
|
252
|
-
next =>
|
253
|
-
up.request('/bar')
|
254
|
-
|
255
|
-
next =>
|
256
|
-
# See that an additional request was made
|
257
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
258
|
-
|
259
|
-
it 'does not considers a redirection URL an alias for the requested URL if the response returned a non-200 status code', asyncSpec (next) ->
|
260
|
-
up.request('/foo')
|
261
|
-
|
262
|
-
next =>
|
263
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
264
|
-
@respondWith
|
265
|
-
responseURL: '/bar'
|
266
|
-
status: 500
|
267
|
-
|
268
|
-
next =>
|
269
|
-
up.request('/bar')
|
270
|
-
|
271
|
-
|
272
|
-
describe 'CSRF', ->
|
273
|
-
|
274
|
-
beforeEach ->
|
275
|
-
up.protocol.config.csrfHeader = 'csrf-header'
|
276
|
-
up.protocol.config.csrfToken = 'csrf-token'
|
277
|
-
|
278
|
-
it 'sets a CSRF token in the header', asyncSpec (next) ->
|
279
|
-
up.request('/path', method: 'post')
|
280
|
-
next =>
|
281
|
-
headers = @lastRequest().requestHeaders
|
282
|
-
expect(headers['csrf-header']).toEqual('csrf-token')
|
283
|
-
|
284
|
-
it 'does not add a CSRF token if there is none', asyncSpec (next) ->
|
285
|
-
up.protocol.config.csrfToken = ''
|
286
|
-
up.request('/path', method: 'post')
|
287
|
-
next =>
|
288
|
-
headers = @lastRequest().requestHeaders
|
289
|
-
expect(headers['csrf-header']).toBeMissing()
|
290
|
-
|
291
|
-
it 'does not add a CSRF token for GET requests', asyncSpec (next) ->
|
292
|
-
up.request('/path', method: 'get')
|
293
|
-
next =>
|
294
|
-
headers = @lastRequest().requestHeaders
|
295
|
-
expect(headers['csrf-header']).toBeMissing()
|
296
|
-
|
297
|
-
it 'does not add a CSRF token when loading content from another domain', asyncSpec (next) ->
|
298
|
-
up.request('http://other-domain.tld/path', method: 'post')
|
299
|
-
next =>
|
300
|
-
headers = @lastRequest().requestHeaders
|
301
|
-
expect(headers['csrf-header']).toBeMissing()
|
302
|
-
|
303
|
-
describe 'X-Requested-With header', ->
|
304
|
-
|
305
|
-
it 'sets the header to "XMLHttpRequest" by default', asyncSpec (next) ->
|
306
|
-
up.request('/path', method: 'post')
|
307
|
-
next =>
|
308
|
-
headers = @lastRequest().requestHeaders
|
309
|
-
expect(headers['X-Requested-With']).toEqual('XMLHttpRequest')
|
310
|
-
|
311
|
-
it 'does not overrride an existing X-Requested-With header', asyncSpec (next) ->
|
312
|
-
up.request('/path', method: 'post', headers: { 'X-Requested-With': 'Love' })
|
313
|
-
next =>
|
314
|
-
headers = @lastRequest().requestHeaders
|
315
|
-
expect(headers['X-Requested-With']).toEqual('Love')
|
316
|
-
|
317
|
-
describe 'with { params } option', ->
|
318
|
-
|
319
|
-
it "uses the given params as a non-GET request's payload", asyncSpec (next) ->
|
320
|
-
givenParams = { 'foo-key': 'foo-value', 'bar-key': 'bar-value' }
|
321
|
-
up.request(url: '/path', method: 'put', params: givenParams)
|
322
|
-
|
323
|
-
next =>
|
324
|
-
expect(@lastRequest().data()['foo-key']).toEqual(['foo-value'])
|
325
|
-
expect(@lastRequest().data()['bar-key']).toEqual(['bar-value'])
|
326
|
-
|
327
|
-
it "encodes the given params into the URL of a GET request", (done) ->
|
328
|
-
givenParams = { 'foo-key': 'foo-value', 'bar-key': 'bar-value' }
|
329
|
-
promise = up.request(url: '/path', method: 'get', params: givenParams)
|
330
|
-
|
331
|
-
u.task =>
|
332
|
-
expect(@lastRequest().url).toMatchUrl('/path?foo-key=foo-value&bar-key=bar-value')
|
333
|
-
expect(@lastRequest().data()).toBeBlank()
|
334
|
-
|
335
|
-
@respondWith('response-text')
|
336
|
-
|
337
|
-
promise.then (response) ->
|
338
|
-
# See that the response object has been updated by moving the data options
|
339
|
-
# to the URL. This is important for up.fragment code that works on response.request.
|
340
|
-
expect(response.request.url).toMatchUrl('/path?foo-key=foo-value&bar-key=bar-value')
|
341
|
-
expect(response.request.params).toBeBlank()
|
342
|
-
done()
|
343
|
-
|
344
|
-
it 'caches server responses for the configured duration', asyncSpec (next) ->
|
345
|
-
up.proxy.config.cacheExpiry = 200 # 1 second for test
|
346
|
-
|
347
|
-
responses = []
|
348
|
-
trackResponse = (response) -> responses.push(response.text)
|
349
|
-
|
350
|
-
next =>
|
351
|
-
up.request(url: '/foo').then(trackResponse)
|
352
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
353
|
-
|
354
|
-
next.after (10), =>
|
355
|
-
# Send the same request for the same path
|
356
|
-
up.request(url: '/foo').then(trackResponse)
|
357
|
-
|
358
|
-
# See that only a single network request was triggered
|
359
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
360
|
-
expect(responses).toEqual([])
|
361
|
-
|
362
|
-
next =>
|
363
|
-
# Server responds once.
|
364
|
-
@respondWith('foo')
|
365
|
-
|
366
|
-
next =>
|
367
|
-
# See that both requests have been fulfilled
|
368
|
-
expect(responses).toEqual(['foo', 'foo'])
|
369
|
-
|
370
|
-
next.after (200), =>
|
371
|
-
# Send another request after another 3 minutes
|
372
|
-
# The clock is now a total of 6 minutes after the first request,
|
373
|
-
# exceeding the cache's retention time of 5 minutes.
|
374
|
-
up.request(url: '/foo').then(trackResponse)
|
375
|
-
|
376
|
-
# See that we have triggered a second request
|
377
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
378
|
-
|
379
|
-
next =>
|
380
|
-
@respondWith('bar')
|
381
|
-
|
382
|
-
next =>
|
383
|
-
expect(responses).toEqual(['foo', 'foo', 'bar'])
|
384
|
-
|
385
|
-
it "does not cache responses if config.cacheExpiry is 0", asyncSpec (next) ->
|
386
|
-
up.proxy.config.cacheExpiry = 0
|
387
|
-
next => up.request(url: '/foo')
|
388
|
-
next => up.request(url: '/foo')
|
389
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
390
|
-
|
391
|
-
it "does not cache responses if config.cacheSize is 0", asyncSpec (next) ->
|
392
|
-
up.proxy.config.cacheSize = 0
|
393
|
-
next => up.request(url: '/foo')
|
394
|
-
next => up.request(url: '/foo')
|
395
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
396
|
-
|
397
|
-
it 'does not limit the number of cache entries if config.cacheSize is undefined'
|
398
|
-
|
399
|
-
it 'never discards old cache entries if config.cacheExpiry is undefined'
|
400
|
-
|
401
|
-
it 'respects a config.cacheSize setting', asyncSpec (next) ->
|
402
|
-
up.proxy.config.cacheSize = 2
|
403
|
-
next => up.request(url: '/foo')
|
404
|
-
next => up.request(url: '/bar')
|
405
|
-
next => up.request(url: '/baz')
|
406
|
-
next => up.request(url: '/foo')
|
407
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(4)
|
408
|
-
|
409
|
-
it "doesn't reuse responses when asked for the same path, but different selectors", asyncSpec (next) ->
|
410
|
-
next => up.request(url: '/path', target: '.a')
|
411
|
-
next => up.request(url: '/path', target: '.b')
|
412
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
413
|
-
|
414
|
-
it "doesn't reuse responses when asked for the same path, but different params", asyncSpec (next) ->
|
415
|
-
next => up.request(url: '/path', params: { query: 'foo' })
|
416
|
-
next => up.request(url: '/path', params: { query: 'bar' })
|
417
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
418
|
-
|
419
|
-
it "reuses a response for an 'html' selector when asked for the same path and any other selector", asyncSpec (next) ->
|
420
|
-
next => up.request(url: '/path', target: 'html')
|
421
|
-
next => up.request(url: '/path', target: 'body')
|
422
|
-
next => up.request(url: '/path', target: 'p')
|
423
|
-
next => up.request(url: '/path', target: '.klass')
|
424
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(1)
|
425
|
-
|
426
|
-
it "reuses a response for a 'body' selector when asked for the same path and any other selector other than 'html'", asyncSpec (next) ->
|
427
|
-
next => up.request(url: '/path', target: 'body')
|
428
|
-
next => up.request(url: '/path', target: 'p')
|
429
|
-
next => up.request(url: '/path', target: '.klass')
|
430
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(1)
|
431
|
-
|
432
|
-
it "doesn't reuse a response for a 'body' selector when asked for the same path but an 'html' selector", asyncSpec (next) ->
|
433
|
-
next => up.request(url: '/path', target: 'body')
|
434
|
-
next => up.request(url: '/path', target: 'html')
|
435
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
436
|
-
|
437
|
-
it "doesn't reuse responses for different paths", asyncSpec (next) ->
|
438
|
-
next => up.request(url: '/foo')
|
439
|
-
next => up.request(url: '/bar')
|
440
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
441
|
-
|
442
|
-
u.each ['GET', 'HEAD', 'OPTIONS'], (method) ->
|
443
|
-
|
444
|
-
it "caches #{method} requests", asyncSpec (next) ->
|
445
|
-
next => up.request(url: '/foo', method: method)
|
446
|
-
next => up.request(url: '/foo', method: method)
|
447
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(1)
|
448
|
-
|
449
|
-
it "does not cache #{method} requests with { cache: false }", asyncSpec (next) ->
|
450
|
-
next => up.request(url: '/foo', method: method, cache: false)
|
451
|
-
next => up.request(url: '/foo', method: method, cache: false)
|
452
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
453
|
-
|
454
|
-
u.each ['POST', 'PUT', 'DELETE'], (method) ->
|
455
|
-
|
456
|
-
it "does not cache #{method} requests", asyncSpec (next) ->
|
457
|
-
next => up.request(url: '/foo', method: method)
|
458
|
-
next => up.request(url: '/foo', method: method)
|
459
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
460
|
-
|
461
|
-
it 'does not cache responses with a non-200 status code', asyncSpec (next) ->
|
462
|
-
next => up.request(url: '/foo')
|
463
|
-
next => @respondWith(status: 500, contentType: 'text/html', responseText: 'foo')
|
464
|
-
next => up.request(url: '/foo')
|
465
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
466
|
-
|
467
|
-
describe 'with config.wrapMethods set', ->
|
468
|
-
|
469
|
-
it 'should be set by default', ->
|
470
|
-
expect(up.proxy.config.wrapMethods).toBePresent()
|
471
|
-
|
472
|
-
u.each ['GET', 'POST', 'HEAD', 'OPTIONS'], (method) ->
|
473
|
-
|
474
|
-
it "does not change the method of a #{method} request", asyncSpec (next) ->
|
475
|
-
up.request(url: '/foo', method: method)
|
476
|
-
|
477
|
-
next =>
|
478
|
-
request = @lastRequest()
|
479
|
-
expect(request.method).toEqual(method)
|
480
|
-
expect(request.data()['_method']).toBeUndefined()
|
481
|
-
|
482
|
-
u.each ['PUT', 'PATCH', 'DELETE'], (method) ->
|
483
|
-
|
484
|
-
it "turns a #{method} request into a POST request and sends the actual method as a { _method } param to prevent unexpected redirect behavior (https://makandracards.com/makandra/38347)", asyncSpec (next) ->
|
485
|
-
up.request(url: '/foo', method: method)
|
486
|
-
|
487
|
-
next =>
|
488
|
-
request = @lastRequest()
|
489
|
-
expect(request.method).toEqual('POST')
|
490
|
-
expect(request.data()['_method']).toEqual([method])
|
491
|
-
# expect(request.data()['foo']).toEqual('bar')
|
492
|
-
|
493
|
-
describe 'with config.maxRequests set', ->
|
494
|
-
|
495
|
-
beforeEach ->
|
496
|
-
@oldMaxRequests = up.proxy.config.maxRequests
|
497
|
-
up.proxy.config.maxRequests = 1
|
498
|
-
|
499
|
-
afterEach ->
|
500
|
-
up.proxy.config.maxRequests = @oldMaxRequests
|
501
|
-
|
502
|
-
it 'limits the number of concurrent requests', asyncSpec (next) ->
|
503
|
-
responses = []
|
504
|
-
trackResponse = (response) -> responses.push(response.text)
|
505
|
-
|
506
|
-
next =>
|
507
|
-
up.request(url: '/foo').then(trackResponse)
|
508
|
-
up.request(url: '/bar').then(trackResponse)
|
509
|
-
|
510
|
-
next =>
|
511
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1) # only one request was made
|
512
|
-
|
513
|
-
next =>
|
514
|
-
@respondWith('first response', request: jasmine.Ajax.requests.at(0))
|
515
|
-
|
516
|
-
next =>
|
517
|
-
expect(responses).toEqual ['first response']
|
518
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2) # a second request was made
|
519
|
-
|
520
|
-
next =>
|
521
|
-
@respondWith('second response', request: jasmine.Ajax.requests.at(1))
|
522
|
-
|
523
|
-
next =>
|
524
|
-
expect(responses).toEqual ['first response', 'second response']
|
525
|
-
|
526
|
-
it 'ignores preloading for the request limit', asyncSpec (next) ->
|
527
|
-
next => up.request(url: '/foo', preload: true)
|
528
|
-
next => up.request(url: '/bar')
|
529
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
530
|
-
next => up.request(url: '/bar')
|
531
|
-
next => expect(jasmine.Ajax.requests.count()).toEqual(2)
|
532
|
-
|
533
|
-
describe 'up:proxy:load event', ->
|
534
|
-
|
535
|
-
it 'emits an up:proxy:load event before the request touches the network', asyncSpec (next) ->
|
536
|
-
listener = jasmine.createSpy('listener')
|
537
|
-
up.on 'up:proxy:load', listener
|
538
|
-
up.request('/bar')
|
539
|
-
|
540
|
-
next =>
|
541
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
542
|
-
|
543
|
-
partialRequest = jasmine.objectContaining(
|
544
|
-
method: 'GET',
|
545
|
-
url: jasmine.stringMatching('/bar')
|
546
|
-
)
|
547
|
-
partialEvent = jasmine.objectContaining(request: partialRequest)
|
548
|
-
|
549
|
-
expect(listener).toHaveBeenCalledWith(partialEvent, jasmine.anything(), jasmine.anything())
|
550
|
-
|
551
|
-
it 'allows up:proxy:load listeners to prevent the request (useful to cancel all requests when stopping a test scenario)', (done) ->
|
552
|
-
listener = jasmine.createSpy('listener').and.callFake (event) ->
|
553
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
554
|
-
event.preventDefault()
|
555
|
-
|
556
|
-
up.on 'up:proxy:load', listener
|
557
|
-
|
558
|
-
promise = up.request('/bar')
|
559
|
-
|
560
|
-
u.task ->
|
561
|
-
expect(listener).toHaveBeenCalled()
|
562
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
563
|
-
|
564
|
-
promiseState(promise).then (result) ->
|
565
|
-
expect(result.state).toEqual('rejected')
|
566
|
-
expect(result.value).toBeError(/prevented/i)
|
567
|
-
done()
|
568
|
-
|
569
|
-
it 'does not block the queue when a request was prevented', (done) ->
|
570
|
-
up.proxy.config.maxRequests = 1
|
571
|
-
|
572
|
-
listener = jasmine.createSpy('listener').and.callFake (event) ->
|
573
|
-
# only prevent the first request
|
574
|
-
if event.request.url.indexOf('/path1') >= 0
|
575
|
-
event.preventDefault()
|
576
|
-
|
577
|
-
up.on 'up:proxy:load', listener
|
578
|
-
|
579
|
-
promise1 = up.request('/path1')
|
580
|
-
promise2 = up.request('/path2')
|
581
|
-
|
582
|
-
u.task =>
|
583
|
-
expect(listener.calls.count()).toBe(2)
|
584
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
585
|
-
expect(@lastRequest().url).toMatchUrl('/path2')
|
586
|
-
done()
|
587
|
-
|
588
|
-
it 'allows up:proxy:load listeners to manipulate the request headers', (done) ->
|
589
|
-
listener = (event) ->
|
590
|
-
event.request.headers['X-From-Listener'] = 'foo'
|
591
|
-
|
592
|
-
up.on 'up:proxy:load', listener
|
593
|
-
|
594
|
-
up.request('/path1')
|
595
|
-
|
596
|
-
u.task =>
|
597
|
-
expect(@lastRequest().requestHeaders['X-From-Listener']).toEqual('foo')
|
598
|
-
done()
|
599
|
-
|
600
|
-
describe 'up:proxy:slow and up:proxy:recover events', ->
|
601
|
-
|
602
|
-
beforeEach ->
|
603
|
-
up.proxy.config.slowDelay = 0
|
604
|
-
@events = []
|
605
|
-
u.each ['up:proxy:load', 'up:proxy:loaded', 'up:proxy:slow', 'up:proxy:recover', 'up:proxy:fatal'], (eventName) =>
|
606
|
-
up.on eventName, =>
|
607
|
-
@events.push eventName
|
608
|
-
|
609
|
-
it 'emits an up:proxy:slow event if the server takes too long to respond'
|
610
|
-
|
611
|
-
it 'does not emit an up:proxy:slow event if preloading', asyncSpec (next) ->
|
612
|
-
next =>
|
613
|
-
# A request for preloading preloading purposes
|
614
|
-
# doesn't make us busy.
|
615
|
-
up.request(url: '/foo', preload: true)
|
616
|
-
|
617
|
-
next =>
|
618
|
-
expect(@events).toEqual([
|
619
|
-
'up:proxy:load'
|
620
|
-
])
|
621
|
-
expect(up.proxy.isBusy()).toBe(false)
|
622
|
-
|
623
|
-
next =>
|
624
|
-
# The same request with preloading does trigger up:proxy:slow.
|
625
|
-
up.request(url: '/foo')
|
626
|
-
|
627
|
-
next =>
|
628
|
-
expect(@events).toEqual([
|
629
|
-
'up:proxy:load',
|
630
|
-
'up:proxy:slow'
|
631
|
-
])
|
632
|
-
expect(up.proxy.isBusy()).toBe(true)
|
633
|
-
|
634
|
-
next =>
|
635
|
-
# The response resolves both promises and makes
|
636
|
-
# the proxy idle again.
|
637
|
-
jasmine.Ajax.requests.at(0).respondWith
|
638
|
-
status: 200
|
639
|
-
contentType: 'text/html'
|
640
|
-
responseText: 'foo'
|
641
|
-
|
642
|
-
next =>
|
643
|
-
expect(@events).toEqual([
|
644
|
-
'up:proxy:load',
|
645
|
-
'up:proxy:slow',
|
646
|
-
'up:proxy:loaded',
|
647
|
-
'up:proxy:recover'
|
648
|
-
])
|
649
|
-
expect(up.proxy.isBusy()).toBe(false)
|
650
|
-
|
651
|
-
it 'can delay the up:proxy:slow event to prevent flickering of spinners', asyncSpec (next) ->
|
652
|
-
next =>
|
653
|
-
up.proxy.config.slowDelay = 100
|
654
|
-
up.request(url: '/foo')
|
655
|
-
|
656
|
-
next =>
|
657
|
-
expect(@events).toEqual([
|
658
|
-
'up:proxy:load'
|
659
|
-
])
|
660
|
-
|
661
|
-
next.after 50, =>
|
662
|
-
expect(@events).toEqual([
|
663
|
-
'up:proxy:load'
|
664
|
-
])
|
665
|
-
|
666
|
-
next.after 60, =>
|
667
|
-
expect(@events).toEqual([
|
668
|
-
'up:proxy:load',
|
669
|
-
'up:proxy:slow'
|
670
|
-
])
|
671
|
-
|
672
|
-
next =>
|
673
|
-
jasmine.Ajax.requests.at(0).respondWith
|
674
|
-
status: 200
|
675
|
-
contentType: 'text/html'
|
676
|
-
responseText: 'foo'
|
677
|
-
|
678
|
-
next =>
|
679
|
-
expect(@events).toEqual([
|
680
|
-
'up:proxy:load',
|
681
|
-
'up:proxy:slow',
|
682
|
-
'up:proxy:loaded',
|
683
|
-
'up:proxy:recover'
|
684
|
-
])
|
685
|
-
|
686
|
-
it 'does not emit up:proxy:recover if a delayed up:proxy:slow was never emitted due to a fast response', asyncSpec (next) ->
|
687
|
-
next =>
|
688
|
-
up.proxy.config.slowDelay = 200
|
689
|
-
up.request(url: '/foo')
|
690
|
-
|
691
|
-
next =>
|
692
|
-
expect(@events).toEqual([
|
693
|
-
'up:proxy:load'
|
694
|
-
])
|
695
|
-
|
696
|
-
next.after 100, =>
|
697
|
-
jasmine.Ajax.requests.at(0).respondWith
|
698
|
-
status: 200
|
699
|
-
contentType: 'text/html'
|
700
|
-
responseText: 'foo'
|
701
|
-
|
702
|
-
next.after 250, =>
|
703
|
-
expect(@events).toEqual([
|
704
|
-
'up:proxy:load',
|
705
|
-
'up:proxy:loaded'
|
706
|
-
])
|
707
|
-
|
708
|
-
it 'emits up:proxy:recover if a request returned but failed with an error code', asyncSpec (next) ->
|
709
|
-
next =>
|
710
|
-
up.request(url: '/foo')
|
711
|
-
|
712
|
-
next =>
|
713
|
-
expect(@events).toEqual([
|
714
|
-
'up:proxy:load',
|
715
|
-
'up:proxy:slow'
|
716
|
-
])
|
717
|
-
|
718
|
-
next =>
|
719
|
-
jasmine.Ajax.requests.at(0).respondWith
|
720
|
-
status: 500
|
721
|
-
contentType: 'text/html'
|
722
|
-
responseText: 'something went wrong'
|
723
|
-
|
724
|
-
next =>
|
725
|
-
expect(@events).toEqual([
|
726
|
-
'up:proxy:load',
|
727
|
-
'up:proxy:slow',
|
728
|
-
'up:proxy:loaded',
|
729
|
-
'up:proxy:recover'
|
730
|
-
])
|
731
|
-
|
732
|
-
|
733
|
-
it 'emits up:proxy:recover if a request returned but failed fatally', asyncSpec (next) ->
|
734
|
-
up.proxy.config.slowDelay = 10
|
735
|
-
|
736
|
-
next =>
|
737
|
-
up.request(url: '/foo', timeout: 75)
|
738
|
-
|
739
|
-
next.after 50, =>
|
740
|
-
expect(@events).toEqual([
|
741
|
-
'up:proxy:load',
|
742
|
-
'up:proxy:slow'
|
743
|
-
])
|
744
|
-
|
745
|
-
next =>
|
746
|
-
jasmine.clock().install() # required by responseTimeout()
|
747
|
-
@lastRequest().responseTimeout()
|
748
|
-
|
749
|
-
next =>
|
750
|
-
expect(@events).toEqual([
|
751
|
-
'up:proxy:load',
|
752
|
-
'up:proxy:slow',
|
753
|
-
'up:proxy:fatal',
|
754
|
-
'up:proxy:recover'
|
755
|
-
])
|
756
|
-
|
757
|
-
|
758
|
-
describe 'up.ajax', ->
|
759
|
-
|
760
|
-
it 'fulfills to the response text in order to match the $.ajax() API as good as possible', (done) ->
|
761
|
-
promise = up.ajax('/url')
|
762
|
-
|
763
|
-
u.timer 100, =>
|
764
|
-
@respondWith('response-text')
|
765
|
-
|
766
|
-
promise.then (text) ->
|
767
|
-
expect(text).toEqual('response-text')
|
768
|
-
|
769
|
-
done()
|
770
|
-
|
771
|
-
describe 'up.proxy.preload', ->
|
772
|
-
|
773
|
-
describeCapability 'canPushState', ->
|
774
|
-
|
775
|
-
beforeEach ->
|
776
|
-
@requestTarget = => @lastRequest().requestHeaders['X-Up-Target']
|
777
|
-
|
778
|
-
it "loads and caches the given link's destination", asyncSpec (next) ->
|
779
|
-
$fixture('.target')
|
780
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
781
|
-
|
782
|
-
up.proxy.preload($link)
|
783
|
-
|
784
|
-
next =>
|
785
|
-
cachedPromise = up.proxy.get(url: '/path', target: '.target')
|
786
|
-
expect(u.isPromise(cachedPromise)).toBe(true)
|
787
|
-
|
788
|
-
it "does not load a link whose method has side-effects", (done) ->
|
789
|
-
$fixture('.target')
|
790
|
-
$link = $fixture('a[href="/path"][up-target=".target"][data-method="post"]')
|
791
|
-
preloadPromise = up.proxy.preload($link)
|
792
|
-
|
793
|
-
promiseState(preloadPromise).then (result) ->
|
794
|
-
expect(result.state).toEqual('rejected')
|
795
|
-
expect(up.proxy.get(url: '/path', target: '.target')).toBeUndefined()
|
796
|
-
done()
|
797
|
-
|
798
|
-
it 'accepts options', asyncSpec (next) ->
|
799
|
-
$fixture('.target')
|
800
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
801
|
-
up.proxy.preload($link, url: '/options-path')
|
802
|
-
|
803
|
-
next =>
|
804
|
-
cachedPromise = up.proxy.get(url: '/options-path', target: '.target')
|
805
|
-
expect(u.isPromise(cachedPromise)).toBe(true)
|
806
|
-
|
807
|
-
describe 'for an [up-target] link', ->
|
808
|
-
|
809
|
-
it 'includes the [up-target] selector as an X-Up-Target header if the targeted element is currently on the page', asyncSpec (next) ->
|
810
|
-
$fixture('.target')
|
811
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
812
|
-
up.proxy.preload($link)
|
813
|
-
next => expect(@requestTarget()).toEqual('.target')
|
814
|
-
|
815
|
-
it 'replaces the [up-target] selector as with a fallback and uses that as an X-Up-Target header if the targeted element is not currently on the page', asyncSpec (next) ->
|
816
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
817
|
-
up.proxy.preload($link)
|
818
|
-
# The default fallback would usually be `body`, but in Jasmine specs we change
|
819
|
-
# it to protect the test runner during failures.
|
820
|
-
next => expect(@requestTarget()).toEqual('.default-fallback')
|
821
|
-
|
822
|
-
it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
|
823
|
-
requestSpy = spyOn(up, 'request')
|
824
|
-
|
825
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
826
|
-
up.proxy.preload($link)
|
827
|
-
|
828
|
-
next =>
|
829
|
-
expect(requestSpy).toHaveBeenCalledWith(jasmine.objectContaining(preload: true))
|
830
|
-
|
831
|
-
describe 'for an [up-modal] link', ->
|
832
|
-
|
833
|
-
beforeEach ->
|
834
|
-
up.motion.config.enabled = false
|
835
|
-
|
836
|
-
it 'includes the [up-modal] selector as an X-Up-Target header and does not replace it with a fallback, since the modal frame always exists', asyncSpec (next) ->
|
837
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
838
|
-
up.proxy.preload($link)
|
839
|
-
next => expect(@requestTarget()).toEqual('.target')
|
840
|
-
|
841
|
-
it 'does not create a modal frame', asyncSpec (next) ->
|
842
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
843
|
-
up.proxy.preload($link)
|
844
|
-
next =>
|
845
|
-
expect('.up-modal').not.toBeAttached()
|
846
|
-
|
847
|
-
it 'does not emit an up:modal:open event', asyncSpec (next) ->
|
848
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
849
|
-
openListener = jasmine.createSpy('listener')
|
850
|
-
up.on('up:modal:open', openListener)
|
851
|
-
up.proxy.preload($link)
|
852
|
-
next =>
|
853
|
-
expect(openListener).not.toHaveBeenCalled()
|
854
|
-
|
855
|
-
it 'does not close a currently open modal', asyncSpec (next) ->
|
856
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
857
|
-
closeListener = jasmine.createSpy('listener')
|
858
|
-
up.on('up:modal:close', closeListener)
|
859
|
-
|
860
|
-
up.modal.extract('.content', '<div class="content">Modal content</div>')
|
861
|
-
|
862
|
-
next =>
|
863
|
-
expect('.up-modal .content').toBeAttached()
|
864
|
-
|
865
|
-
next =>
|
866
|
-
up.proxy.preload($link)
|
867
|
-
|
868
|
-
next =>
|
869
|
-
expect('.up-modal .content').toBeAttached()
|
870
|
-
expect(closeListener).not.toHaveBeenCalled()
|
871
|
-
|
872
|
-
next =>
|
873
|
-
up.modal.close()
|
874
|
-
|
875
|
-
next =>
|
876
|
-
expect('.up-modal .content').not.toBeAttached()
|
877
|
-
expect(closeListener).toHaveBeenCalled()
|
878
|
-
|
879
|
-
it 'does not prevent the opening of other modals while the request is still pending', asyncSpec (next) ->
|
880
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
881
|
-
up.proxy.preload($link)
|
882
|
-
|
883
|
-
next =>
|
884
|
-
up.modal.extract('.content', '<div class="content">Modal content</div>')
|
885
|
-
|
886
|
-
next =>
|
887
|
-
expect('.up-modal .content').toBeAttached()
|
888
|
-
|
889
|
-
it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
|
890
|
-
requestSpy = spyOn(up, 'request')
|
891
|
-
|
892
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
893
|
-
up.proxy.preload($link)
|
894
|
-
|
895
|
-
next =>
|
896
|
-
expect(requestSpy).toHaveBeenCalledWith(jasmine.objectContaining(preload: true))
|
897
|
-
|
898
|
-
describe 'for an [up-popup] link', ->
|
899
|
-
|
900
|
-
beforeEach ->
|
901
|
-
up.motion.config.enabled = false
|
902
|
-
|
903
|
-
it 'includes the [up-popup] selector as an X-Up-Target header and does not replace it with a fallback, since the popup frame always exists', asyncSpec (next) ->
|
904
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
905
|
-
up.proxy.preload($link)
|
906
|
-
next => expect(@requestTarget()).toEqual('.target')
|
907
|
-
|
908
|
-
|
909
|
-
it 'does not create a popup frame', asyncSpec (next) ->
|
910
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
911
|
-
up.proxy.preload($link)
|
912
|
-
next =>
|
913
|
-
expect('.up-popup').not.toBeAttached()
|
914
|
-
|
915
|
-
it 'does not emit an up:popup:open event', asyncSpec (next) ->
|
916
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
917
|
-
openListener = jasmine.createSpy('listener')
|
918
|
-
up.on('up:popup:open', openListener)
|
919
|
-
up.proxy.preload($link)
|
920
|
-
next =>
|
921
|
-
expect(openListener).not.toHaveBeenCalled()
|
922
|
-
|
923
|
-
it 'does not close a currently open popup', asyncSpec (next) ->
|
924
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
925
|
-
closeListener = jasmine.createSpy('listener')
|
926
|
-
up.on('up:popup:close', closeListener)
|
927
|
-
|
928
|
-
$existingAnchor = $fixture('.existing-anchor')
|
929
|
-
up.popup.attach($existingAnchor, target: '.content', html: '<div class="content">popup content</div>')
|
930
|
-
|
931
|
-
next =>
|
932
|
-
expect('.up-popup .content').toBeAttached()
|
933
|
-
|
934
|
-
next =>
|
935
|
-
up.proxy.preload($link)
|
936
|
-
|
937
|
-
next =>
|
938
|
-
expect('.up-popup .content').toBeAttached()
|
939
|
-
expect(closeListener).not.toHaveBeenCalled()
|
940
|
-
|
941
|
-
next =>
|
942
|
-
up.popup.close()
|
943
|
-
|
944
|
-
next =>
|
945
|
-
expect('.up-popup .content').not.toBeAttached()
|
946
|
-
expect(closeListener).toHaveBeenCalled()
|
947
|
-
|
948
|
-
it 'does not prevent the opening of other popups while the request is still pending', asyncSpec (next) ->
|
949
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
950
|
-
up.proxy.preload($link)
|
951
|
-
|
952
|
-
next =>
|
953
|
-
$anchor = $fixture('.existing-anchor')
|
954
|
-
up.popup.attach($anchor, target: '.content', html: '<div class="content">popup content</div>')
|
955
|
-
|
956
|
-
next =>
|
957
|
-
expect('.up-popup .content').toBeAttached()
|
958
|
-
|
959
|
-
it 'calls up.request() with a { preload: true } option so it bypasses the concurrency limit', asyncSpec (next) ->
|
960
|
-
requestSpy = spyOn(up, 'request')
|
961
|
-
|
962
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]')
|
963
|
-
up.proxy.preload($link)
|
964
|
-
|
965
|
-
next =>
|
966
|
-
expect(requestSpy).toHaveBeenCalledWith(jasmine.objectContaining(preload: true))
|
967
|
-
|
968
|
-
describeFallback 'canPushState', ->
|
969
|
-
|
970
|
-
it "does nothing", asyncSpec (next) ->
|
971
|
-
$fixture('.target')
|
972
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
973
|
-
up.proxy.preload($link)
|
974
|
-
next =>
|
975
|
-
expect(jasmine.Ajax.requests.count()).toBe(0)
|
976
|
-
|
977
|
-
describe 'up.proxy.get', ->
|
978
|
-
|
979
|
-
it 'returns an existing cache entry for the given request', ->
|
980
|
-
promise1 = up.request(url: '/foo', params: { key: 'value' })
|
981
|
-
promise2 = up.proxy.get(url: '/foo', params: { key: 'value' })
|
982
|
-
expect(promise1).toBe(promise2)
|
983
|
-
|
984
|
-
it 'returns undefined if the given request is not cached', ->
|
985
|
-
promise = up.proxy.get(url: '/foo', params: { key: 'value' })
|
986
|
-
expect(promise).toBeUndefined()
|
987
|
-
|
988
|
-
describeCapability 'canInspectFormData', ->
|
989
|
-
|
990
|
-
it "returns undefined if the given request's { params } is a FormData object", ->
|
991
|
-
promise = up.proxy.get(url: '/foo', params: new FormData())
|
992
|
-
expect(promise).toBeUndefined()
|
993
|
-
|
994
|
-
describe 'up.proxy.set', ->
|
995
|
-
|
996
|
-
it 'should have tests'
|
997
|
-
|
998
|
-
describe 'up.proxy.alias', ->
|
999
|
-
|
1000
|
-
it 'uses an existing cache entry for another request (used in case of redirects)'
|
1001
|
-
|
1002
|
-
describe 'up.proxy.remove', ->
|
1003
|
-
|
1004
|
-
it 'removes the cache entry for the given request'
|
1005
|
-
|
1006
|
-
it 'does nothing if the given request is not cached'
|
1007
|
-
|
1008
|
-
describeCapability 'canInspectFormData', ->
|
1009
|
-
|
1010
|
-
it 'does not crash when passed a request with FormData (bugfix)', ->
|
1011
|
-
removal = -> up.proxy.remove(url: '/path', params: new FormData())
|
1012
|
-
expect(removal).not.toThrowError()
|
1013
|
-
|
1014
|
-
describe 'up.proxy.clear', ->
|
1015
|
-
|
1016
|
-
it 'removes all cache entries'
|
1017
|
-
|
1018
|
-
describe 'unobtrusive behavior', ->
|
1019
|
-
|
1020
|
-
describe '[up-preload]', ->
|
1021
|
-
|
1022
|
-
it 'preloads the link destination when hovering, after a delay', asyncSpec (next) ->
|
1023
|
-
up.proxy.config.preloadDelay = 100
|
1024
|
-
|
1025
|
-
$fixture('.target').text('old text')
|
1026
|
-
|
1027
|
-
$link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
|
1028
|
-
up.hello($link)
|
1029
|
-
|
1030
|
-
Trigger.hoverSequence($link)
|
1031
|
-
|
1032
|
-
next.after 50, =>
|
1033
|
-
# It's still too early
|
1034
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
1035
|
-
|
1036
|
-
next.after 75, =>
|
1037
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
1038
|
-
expect(@lastRequest().url).toMatchUrl('/foo')
|
1039
|
-
expect(@lastRequest()).toHaveRequestMethod('GET')
|
1040
|
-
expect(@lastRequest().requestHeaders['X-Up-Target']).toEqual('.target')
|
1041
|
-
|
1042
|
-
@respondWith """
|
1043
|
-
<div class="target">
|
1044
|
-
new text
|
1045
|
-
</div>
|
1046
|
-
"""
|
1047
|
-
|
1048
|
-
next =>
|
1049
|
-
# We only preloaded, so the target isn't replaced yet.
|
1050
|
-
expect('.target').toHaveText('old text')
|
1051
|
-
|
1052
|
-
Trigger.clickSequence($link)
|
1053
|
-
|
1054
|
-
next =>
|
1055
|
-
# No additional request has been sent since we already preloaded
|
1056
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
1057
|
-
|
1058
|
-
# The target is replaced instantly
|
1059
|
-
expect('.target').toHaveText('new text')
|
1060
|
-
|
1061
|
-
it 'does not send a request if the user stops hovering before the delay is over', asyncSpec (next) ->
|
1062
|
-
up.proxy.config.preloadDelay = 100
|
1063
|
-
|
1064
|
-
$fixture('.target').text('old text')
|
1065
|
-
|
1066
|
-
$link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
|
1067
|
-
up.hello($link)
|
1068
|
-
|
1069
|
-
Trigger.hoverSequence($link)
|
1070
|
-
|
1071
|
-
next.after 40, =>
|
1072
|
-
# It's still too early
|
1073
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
1074
|
-
|
1075
|
-
Trigger.unhoverSequence($link)
|
1076
|
-
|
1077
|
-
next.after 90, =>
|
1078
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
1079
|
-
|
1080
|
-
it 'does not cache a failed response', asyncSpec (next) ->
|
1081
|
-
up.proxy.config.preloadDelay = 0
|
1082
|
-
|
1083
|
-
$fixture('.target').text('old text')
|
1084
|
-
|
1085
|
-
$link = $fixture('a[href="/foo"][up-target=".target"][up-preload]')
|
1086
|
-
up.hello($link)
|
1087
|
-
|
1088
|
-
Trigger.hoverSequence($link)
|
1089
|
-
|
1090
|
-
next.after 50, =>
|
1091
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
1092
|
-
|
1093
|
-
@respondWith
|
1094
|
-
status: 500
|
1095
|
-
responseText: """
|
1096
|
-
<div class="target">
|
1097
|
-
new text
|
1098
|
-
</div>
|
1099
|
-
"""
|
1100
|
-
|
1101
|
-
next =>
|
1102
|
-
# We only preloaded, so the target isn't replaced yet.
|
1103
|
-
expect('.target').toHaveText('old text')
|
1104
|
-
|
1105
|
-
Trigger.click($link)
|
1106
|
-
|
1107
|
-
next =>
|
1108
|
-
# Since the preloading failed, we send another request
|
1109
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
1110
|
-
|
1111
|
-
# Since there isn't anyone who could handle the rejection inside
|
1112
|
-
# the event handler, our handler mutes the rejection.
|
1113
|
-
expect(window).not.toHaveUnhandledRejections() if REJECTION_EVENTS_SUPPORTED
|
1114
|
-
|
1115
|
-
it 'triggers a separate AJAX request when hovered multiple times and the cache expires between hovers', asyncSpec (next) ->
|
1116
|
-
up.proxy.config.cacheExpiry = 100
|
1117
|
-
up.proxy.config.preloadDelay = 0
|
1118
|
-
|
1119
|
-
$element = $fixture('a[href="/foo"][up-preload]')
|
1120
|
-
up.hello($element)
|
1121
|
-
|
1122
|
-
Trigger.hoverSequence($element)
|
1123
|
-
|
1124
|
-
next.after 10, =>
|
1125
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
1126
|
-
|
1127
|
-
next.after 10, =>
|
1128
|
-
Trigger.hoverSequence($element)
|
1129
|
-
|
1130
|
-
next.after 10, =>
|
1131
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
1132
|
-
|
1133
|
-
next.after 150, =>
|
1134
|
-
Trigger.hoverSequence($element)
|
1135
|
-
|
1136
|
-
next.after 30, =>
|
1137
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|