Return empty list if no "links" supplied in api response. Add tests.
[arvados.git] / apps / workbench / test / integration_helper.rb
1 require 'test_helper'
2 require 'capybara/rails'
3 require 'capybara/poltergeist'
4 require 'uri'
5 require 'yaml'
6
7 class ActionDispatch::IntegrationTest
8   # Make the Capybara DSL available in all integration tests
9   include Capybara::DSL
10   include ApiFixtureLoader
11
12   @@API_AUTHS = self.api_fixture('api_client_authorizations')
13
14   def page_with_token(token, path='/')
15     # Generate a page path with an embedded API token.
16     # Typical usage: visit page_with_token('token_name', page)
17     # The token can be specified by the name of an api_client_authorizations
18     # fixture, or passed as a raw string.
19     api_token = ((@@API_AUTHS.include? token) ?
20                  @@API_AUTHS[token]['api_token'] : token)
21     sep = (path.include? '?') ? '&' : '?'
22     q_string = URI.encode_www_form('api_token' => api_token)
23     "#{path}#{sep}#{q_string}"
24   end
25 end