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")
23 # check that nothing is returned when not logged in
24 get api_user_traces_path
25 assert_response :unauthorized
27 # check that we get a response when logged in
28 auth_header = bearer_authorization_header user
29 get api_user_traces_path, :headers => auth_header
30 assert_response :success
31 assert_equal "application/xml", response.media_type
33 # check the data that is returned
34 assert_select "gpx_file[id='#{trace1.id}']", 1 do
35 assert_select "tag", "London"
37 assert_select "gpx_file[id='#{trace2.id}']", 1 do
38 assert_select "tag", "Birmingham"