X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/76ab57bbe5363cce5ecc2585f9ad5a4bcff21e0d..d843787b4ece9952597d7814cbf10fb383c72625:/apps/workbench/test/integration_helper.rb diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb index f430e842eb..39fdf4b260 100644 --- a/apps/workbench/test/integration_helper.rb +++ b/apps/workbench/test/integration_helper.rb @@ -4,12 +4,19 @@ require 'capybara/poltergeist' require 'uri' require 'yaml' +POLTERGEIST_OPTS = { + window_size: [1200, 800], + phantomjs_options: ['--ignore-ssl-errors=true'], + inspector: true, +} + Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new app, { - window_size: [1200, 800], - phantomjs_options: ['--ignore-ssl-errors=true'], - inspector: true, - } + Capybara::Poltergeist::Driver.new app, POLTERGEIST_OPTS +end + +Capybara.register_driver :poltergeist_without_file_api do |app| + js = File.expand_path '../support/remove_file_api.js', __FILE__ + Capybara::Poltergeist::Driver.new app, POLTERGEIST_OPTS.merge(extensions: [js]) end module WaitForAjax @@ -29,15 +36,15 @@ module AssertDomEvent # Yield the supplied block, then wait for an event to arrive at a # DOM element. def assert_triggers_dom_event events, target='body' - magic = 'RXC0lObcVwEXwSvA' + magic = 'received-dom-event-' + rand(2**30).to_s(36) page.evaluate_script <'); + $('body').addClass('#{magic}'); }); eos yield - assert_selector "##{magic}" - page.evaluate_script "$('##{magic}').remove();"; + assert_selector "body.#{magic}" + page.evaluate_script "$('body').removeClass('#{magic}');"; end end @@ -98,9 +105,11 @@ class ActionDispatch::IntegrationTest # fixture, or passed as a raw string. api_token = ((@@API_AUTHS.include? token) ? @@API_AUTHS[token]['api_token'] : token) - sep = (path.include? '?') ? '&' : '?' + path_parts = path.partition("#") + sep = (path_parts.first.include? '?') ? '&' : '?' q_string = URI.encode_www_form('api_token' => api_token) - "#{path}#{sep}#{q_string}" + path_parts.insert(1, "#{sep}#{q_string}") + path_parts.join("") end # Find a page element, but return false instead of raising an