5     class TracesControllerTest < ActionDispatch::IntegrationTest
 
   7       # test all routes which lead to this controller
 
  10           { :path => "/api/0.6/user/gpx_files", :method => :get },
 
  11           { :controller => "api/users/traces", :action => "index" }
 
  17         trace1 = create(:trace, :user => user) do |trace|
 
  18           create(:tracetag, :trace => trace, :tag => "London")
 
  20         trace2 = create(:trace, :user => user) do |trace|
 
  21           create(:tracetag, :trace => trace, :tag => "Birmingham")
 
  24         # check that we get a response when logged in
 
  25         auth_header = bearer_authorization_header user, :scopes => %w[read_gpx]
 
  26         get api_user_traces_path, :headers => auth_header
 
  27         assert_response :success
 
  28         assert_equal "application/xml", response.media_type
 
  30         # check the data that is returned
 
  31         assert_select "gpx_file[id='#{trace1.id}']", 1 do
 
  32           assert_select "tag", "London"
 
  34         assert_select "gpx_file[id='#{trace2.id}']", 1 do
 
  35           assert_select "tag", "Birmingham"
 
  39       def test_index_anonymous
 
  40         get api_user_traces_path
 
  41         assert_response :unauthorized
 
  44       def test_index_no_scope
 
  46         bad_auth = bearer_authorization_header user, :scopes => %w[]
 
  48         get api_user_traces_path, :headers => bad_auth
 
  49         assert_response :forbidden