Spec-Zone.ru › Ruby on Rails 5.0

модуль ActionDispatch::Integration::RequestHelpers

Публичные методы экземпляров

delete(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 38
def delete(path, *args)
  process_with_kwargs(:delete, path, *args)
end

Выполняет запрос DELETE с заданными параметрами. Подробнее см. #process.

delete_via_redirect(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 125
def delete_via_redirect(path, *args)
  ActiveSupport::Deprecation.warn('`delete_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  request_via_redirect(:delete, path, *args)
end

Выполняет запрос DELETE, следуя за всеми последующими редиректами. Дополнительная информация в request_via_redirect.

follow_redirect!() Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 71
def follow_redirect!
  raise "not a redirect! #{status} #{status_message}" unless redirect?
  get(response.location)
  status
end

Следует за одним редиректом ответа. Если последний ответ не был редиректом, будет вызвано исключение. В противном случае, редирект выполняется по заголовку расположения.

get(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 14
def get(path, *args)
  process_with_kwargs(:get, path, *args)
end
get_via_redirect(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 97
def get_via_redirect(path, *args)
  ActiveSupport::Deprecation.warn('`get_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  request_via_redirect(:get, path, *args)
end

Выполняет запрос GET, следуя за всеми последующими редиректами. Дополнительная информация в request_via_redirect.

head(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 44
def head(path, *args)
  process_with_kwargs(:head, path, *args)
end

Выполняет запрос HEAD с заданными параметрами. Дополнительная информация в #process.

patch(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 26
def patch(path, *args)
  process_with_kwargs(:patch, path, *args)
end

Выполняет запрос PATCH с заданными параметрами. Дополнительная информация в #process.

patch_via_redirect(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 111
def patch_via_redirect(path, *args)
  ActiveSupport::Deprecation.warn('`patch_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  request_via_redirect(:patch, path, *args)
end

Выполняет запрос PATCH, следуя за всеми последующими редиректами. Дополнительная информация в request_via_redirect.

post(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 20
def post(path, *args)
  process_with_kwargs(:post, path, *args)
end

Выполняет запрос POST с заданными параметрами. Дополнительная информация в #process.

post_via_redirect(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 104
def post_via_redirect(path, *args)
  ActiveSupport::Deprecation.warn('`post_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  request_via_redirect(:post, path, *args)
end

Выполняет запрос POST, следуя за всеми последующими редиректами. Дополнительная информация в request_via_redirect.

put(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 32
def put(path, *args)
  process_with_kwargs(:put, path, *args)
end

Выполняет запрос PUT с заданными параметрами. Дополнительная информация в #process.

put_via_redirect(path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 118
def put_via_redirect(path, *args)
  ActiveSupport::Deprecation.warn('`put_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  request_via_redirect(:put, path, *args)
end

Выполняет запрос PUT, следуя за всеми последующими редиректами. Дополнительная информация в request_via_redirect.

request_via_redirect(http_method, path, *args) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 87
def request_via_redirect(http_method, path, *args)
  ActiveSupport::Deprecation.warn('`request_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.')
  process_with_kwargs(http_method, path, *args)

  follow_redirect! while redirect?
  status
end

Выполняет запрос указанным методом, следуя за всеми последующими редиректами. Обратите внимание, что редиректы следуют до тех пор, пока ответ не является редиректом — это означает, что вы можете столкнуться с бесконечным циклом, если редирект циклично возвращается к себе.

Пример:

request_via_redirect :post, '/welcome',
  params: { ref_id: 14 },
  headers: { "X-Test-Header" => "testvalue" }
xhr(request_method, path, parameters = nil, headers_or_env = nil)
Псевдоним для: xml_http_request
xml_http_request(request_method, path, parameters = nil, headers_or_env = nil) Показать исходный код
# File actionpack/lib/action_dispatch/testing/integration.rb, line 58
      def xml_http_request(request_method, path, parameters = nil, headers_or_env = nil)
        ActiveSupport::Deprecation.warn("          `xhr` and `xml_http_request` are deprecated and will be removed in Rails 5.1.
          Switch to e.g. `post comments_path, params: { comment: { body: 'Honey bunny' } }, xhr: true`.
".strip_heredoc)

        process(request_method, path, params: parameters, headers: headers_or_env, xhr: true)
      end

Выполняет запрос XMLHttpRequest с заданными параметрами, имитируя запрос AJAX, отправленный из JavaScript.

request_method может быть :get, :post, :patch, :put, :delete или :head; параметры — nil, хэш или закодированная или multipart-строка; заголовки — хэш.

Пример:

xhr :get, '/feed', since: 201501011400
Также алиас для: xhr

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API