- def test_gpx_files
- user = create(:user)
- trace1 = create(:trace, :user => user) do |trace|
- create(:tracetag, :trace => trace, :tag => "London")
- end
- trace2 = create(:trace, :user => user) do |trace|
- create(:tracetag, :trace => trace, :tag => "Birmingham")
- end
- # check that nothing is returned when not logged in
- get user_gpx_files_path
- assert_response :unauthorized
-
- # check that we get a response when logged in
- auth_header = basic_authorization_header user.email, "test"
- get user_gpx_files_path, :headers => auth_header
- assert_response :success
- assert_equal "application/xml", response.media_type
-
- # check the data that is returned
- assert_select "gpx_file[id='#{trace1.id}']", 1 do
- assert_select "tag", "London"
- end
- assert_select "gpx_file[id='#{trace2.id}']", 1 do
- assert_select "tag", "Birmingham"
- end
- end
-