]> git.openstreetmap.org Git - rails.git/commitdiff
The test train rolls ever onwards...
authorTom Hughes <tom@compton.nu>
Sun, 1 Mar 2015 17:04:39 +0000 (17:04 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 1 Mar 2015 17:04:39 +0000 (17:04 +0000)
25 files changed:
app/controllers/trace_controller.rb
app/models/trace.rb
test/controllers/trace_controller_test.rb
test/controllers/user_preference_controller_test.rb
test/fixtures/gpx_files.yml
test/fixtures/user_preferences.yml
test/models/trace_test.rb
test/models/user_preference_test.rb
test/traces/1.gif [new file with mode: 0644]
test/traces/10.gpx [new file with mode: 0644]
test/traces/1_icon.gif [new file with mode: 0644]
test/traces/2.gif [new file with mode: 0644]
test/traces/2_icon.gif [new file with mode: 0644]
test/traces/3.gif [new file with mode: 0644]
test/traces/3_icon.gif [new file with mode: 0644]
test/traces/4.gif [new file with mode: 0644]
test/traces/4_icon.gif [new file with mode: 0644]
test/traces/6.gif [new file with mode: 0644]
test/traces/6_icon.gif [new file with mode: 0644]
test/traces/7.gif [new file with mode: 0644]
test/traces/7_icon.gif [new file with mode: 0644]
test/traces/8.gif [new file with mode: 0644]
test/traces/8_icon.gif [new file with mode: 0644]
test/traces/9.gif [new file with mode: 0644]
test/traces/9_icon.gif [new file with mode: 0644]

index 64ecd5a7fa53e0ccaa81837eb1ecb06476e95a67..07a6fe21023b4c34c46cde7fa130bdaaa07d1b60 100644 (file)
@@ -117,7 +117,6 @@ class TraceController < ApplicationController
         end
 
         if @trace.id
-          logger.info("id is #{@trace.id}")
           flash[:notice] = t "trace.create.trace_uploaded"
 
           if @user.traces.where(:inserted => false).count > 4
@@ -219,7 +218,7 @@ class TraceController < ApplicationController
   def picture
     trace = Trace.find(params[:id])
 
-    if trace.inserted?
+    if trace.visible? && trace.inserted?
       if trace.public? || (@user && @user == trace.user)
         expires_in 7.days, :private => !trace.public?, :public => trace.public?
         send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline")
@@ -236,7 +235,7 @@ class TraceController < ApplicationController
   def icon
     trace = Trace.find(params[:id])
 
-    if trace.inserted?
+    if  trace.visible? && trace.inserted?
       if trace.public? || (@user && @user == trace.user)
         expires_in 7.days, :private => !trace.public?, :public => trace.public?
         send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline")
@@ -295,11 +294,13 @@ class TraceController < ApplicationController
   end
 
   def api_data
-    trace = Trace.find(params[:id])
+    trace = Trace.visible.find(params[:id])
 
     if trace.public? || trace.user == @user
-      if request.format == Mime::XML || request.format == Mime::GPX
+      if request.format == Mime::XML
         send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
+      elsif request.format == Mime::GPX
+        send_file(trace.xml_file, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
       else
         send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
       end
index 601a4506f7197019e393f449abda9c74aeb7021d..b13ce84d23b5addf216a9f363fb06f1d1905dc63 100644 (file)
@@ -70,16 +70,13 @@ class Trace < ActiveRecord::Base
 
   def large_picture
     f = File.new(large_picture_name, "rb")
-    logger.info "large picture file: '#{f.path}', bytes: #{File.size(f.path)}"
     data = f.sysread(File.size(f.path))
-    logger.info "have read data, bytes: '#{data.length}'"
     f.close
     data
   end
 
   def icon_picture
     f = File.new(icon_picture_name, "rb")
-    logger.info "icon picture file: '#{f.path}'"
     data = f.sysread(File.size(f.path))
     f.close
     data
index a61a470244252725a959c81add137e27165ca230..f9bcd13375a78f5fd6cbec8f0f79c843d4d05e81 100644 (file)
@@ -1,17 +1,23 @@
 require "test_helper"
 
 class TraceControllerTest < ActionController::TestCase
-  fixtures :users, :gpx_files
+  fixtures :users, :user_preferences, :gpx_files
   set_fixture_class :gpx_files => Trace
 
   def setup
     @gpx_trace_dir = Object.send("remove_const", "GPX_TRACE_DIR")
     Object.const_set("GPX_TRACE_DIR", File.dirname(__FILE__) + "/../traces")
+
+    @gpx_image_dir = Object.send("remove_const", "GPX_IMAGE_DIR")
+    Object.const_set("GPX_IMAGE_DIR", File.dirname(__FILE__) + "/../traces")
   end
 
   def teardown
     Object.send("remove_const", "GPX_TRACE_DIR")
     Object.const_set("GPX_TRACE_DIR", @gpx_trace_dir)
+
+    Object.send("remove_const", "GPX_IMAGE_DIR")
+    Object.const_set("GPX_IMAGE_DIR", @gpx_image_dir)
   end
 
   ##
@@ -162,11 +168,21 @@ class TraceControllerTest < ActionController::TestCase
 
   # Check that the list of changesets is displayed
   def test_list
+    # First with the public list
     get :list
     check_trace_list Trace.visible_to_all
 
+    # Restrict traces to those with a given tag
     get :list, :tag => "London"
     check_trace_list Trace.tagged("London").visible_to_all
+
+    # Should see more when we are logged in
+    get :list, {}, { :user => users(:public_user).id }
+    check_trace_list Trace.visible_to(users(:public_user).id)
+
+    # Again, we should see more when we are logged in
+    get :list, { :tag => "London" }, { :user => users(:public_user).id }
+    check_trace_list Trace.tagged("London").visible_to(users(:public_user).id)
   end
 
   # Check that I can get mine
@@ -205,19 +221,28 @@ class TraceControllerTest < ActionController::TestCase
     # Should only see traces with the correct tag when a tag is specified
     get :list, { :display_name => users(:public_user).display_name, :tag => "London" }, { :user => users(:public_user).id }
     check_trace_list users(:public_user).traces.tagged("London")
+
+    # Should get an error if the user does not exist
+    get :list, { :display_name => "UnknownUser" }
+    assert_response :not_found
+    assert_template "user/no_such_user"
   end
 
   # Check that the rss loads
   def test_rss
+    # First with the public feed
     get :georss, :format => :rss
     check_trace_feed Trace.visible_to_all
 
+    # Restrict traces to those with a given tag
     get :georss, :tag => "London", :format => :rss
     check_trace_feed Trace.tagged("London").visible_to_all
 
+    # Restrict traces to those for a given user
     get :georss, :display_name => users(:public_user).display_name, :format => :rss
     check_trace_feed users(:public_user).traces.visible_to_all
 
+    # Restrict traces to those for a given user with a tiven tag
     get :georss, :display_name => users(:public_user).display_name, :tag => "Birmingham", :format => :rss
     check_trace_feed users(:public_user).traces.tagged("Birmingham").visible_to_all
   end
@@ -308,7 +333,7 @@ class TraceControllerTest < ActionController::TestCase
     get :data, :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id
     assert_response :not_found
 
-    # Now with some other user, which should work since the trace is anon
+    # Now with some other user, which shouldn't work since the trace is anon
     get :data, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }, { :user => users(:normal_user).id }
     assert_response :not_found
 
@@ -319,19 +344,161 @@ class TraceControllerTest < ActionController::TestCase
 
   # Test downloading a trace that doesn't exist
   def test_data_not_found
-    # First with no auth, which should work since the trace is public
+    # First with no auth and a trace that has never existed
     get :data, :display_name => users(:public_user).display_name, :id => 0
     assert_response :not_found
 
-    # Now with some other user, which should work since the trace is public
+    # Now with a trace that has never existed
     get :data, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
     assert_response :not_found
 
-    # And finally we should be able to do it with the owner of the trace
+    # Now with a trace that has been deleted
     get :data, { :display_name => users(:public_user).display_name, :id => 5 }, { :user => users(:public_user).id }
     assert_response :not_found
   end
 
+  # Test downloading the picture for a trace
+  def test_picture
+    # First with no auth, which should work since the trace is public
+    get :picture, :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id
+    check_trace_picture gpx_files(:public_trace_file)
+
+    # Now with some other user, which should work since the trace is public
+    get :picture, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }, { :user => users(:public_user).id }
+    check_trace_picture gpx_files(:public_trace_file)
+
+    # And finally we should be able to do it with the owner of the trace
+    get :picture, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }, { :user => users(:normal_user).id }
+    check_trace_picture gpx_files(:public_trace_file)
+  end
+
+  # Check the picture for an anonymous trace can't be downloaded by another user
+  def test_picture_anon
+    # First with no auth
+    get :picture, :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id
+    assert_response :forbidden
+
+    # Now with some other user, which shouldn't work since the trace is anon
+    get :picture, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }, { :user => users(:normal_user).id }
+    assert_response :forbidden
+
+    # And finally we should be able to do it with the owner of the trace
+    get :picture, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }, { :user => users(:public_user).id }
+    check_trace_picture gpx_files(:anon_trace_file)
+  end
+
+  # Test downloading the picture for a trace that doesn't exist
+  def test_picture_not_found
+    # First with no auth, which should work since the trace is public
+    get :picture, :display_name => users(:public_user).display_name, :id => 0
+    assert_response :not_found
+
+    # Now with some other user, which should work since the trace is public
+    get :picture, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+    assert_response :not_found
+
+    # And finally we should be able to do it with the owner of the trace
+    get :picture, { :display_name => users(:public_user).display_name, :id => 5 }, { :user => users(:public_user).id }
+    assert_response :not_found
+  end
+
+  # Test downloading the icon for a trace
+  def test_icon
+    # First with no auth, which should work since the trace is public
+    get :icon, :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id
+    check_trace_icon gpx_files(:public_trace_file)
+
+    # Now with some other user, which should work since the trace is public
+    get :icon, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }, { :user => users(:public_user).id }
+    check_trace_icon gpx_files(:public_trace_file)
+
+    # And finally we should be able to do it with the owner of the trace
+    get :icon, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }, { :user => users(:normal_user).id }
+    check_trace_icon gpx_files(:public_trace_file)
+  end
+
+  # Check the icon for an anonymous trace can't be downloaded by another user
+  def test_icon_anon
+    # First with no auth
+    get :icon, :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id
+    assert_response :forbidden
+
+    # Now with some other user, which shouldn't work since the trace is anon
+    get :icon, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }, { :user => users(:normal_user).id }
+    assert_response :forbidden
+
+    # And finally we should be able to do it with the owner of the trace
+    get :icon, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }, { :user => users(:public_user).id }
+    check_trace_icon gpx_files(:anon_trace_file)
+  end
+
+  # Test downloading the icon for a trace that doesn't exist
+  def test_icon_not_found
+    # First with no auth, which should work since the trace is public
+    get :icon, :display_name => users(:public_user).display_name, :id => 0
+    assert_response :not_found
+
+    # Now with some other user, which should work since the trace is public
+    get :icon, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+    assert_response :not_found
+
+    # And finally we should be able to do it with the owner of the trace
+    get :icon, { :display_name => users(:public_user).display_name, :id => 5 }, { :user => users(:public_user).id }
+    assert_response :not_found
+  end
+
+  # Test fetching the create page
+  def test_create_get
+    # First with no auth
+    get :create
+    assert_response :redirect
+    assert_redirected_to :controller => :user, :action => :login, :referer => trace_create_path
+
+    # Now authenticated as a user with gps.trace.visibility set
+    get :create, {}, { :user => users(:public_user).id }
+    assert_response :success
+    assert_template :create
+    assert_select "select#trace_visibility option[value=identifiable][selected]", 1
+
+    # Now authenticated as a user with gps.trace.public set
+    get :create, {}, { :user => users(:second_public_user).id }
+    assert_response :success
+    assert_template :create
+    assert_select "select#trace_visibility option[value=public][selected]", 1
+
+    # Now authenticated as a user with no preferences
+    get :create, {}, { :user => users(:normal_user).id }
+    assert_response :success
+    assert_template :create
+    assert_select "select#trace_visibility option[value=private][selected]", 1
+  end
+
+  # Test creating a trace
+  def test_create_post
+    # Get file to use
+    file = Rack::Test::UploadedFile.new(gpx_files(:public_trace_file).trace_name, "application/gpx+xml")
+
+    # First with no auth
+    post :create, { :trace => { :gpx_file => file, :description => "New Trace", :tagstring => "new,trace", :visibility => "trackable" } }
+    assert_response :forbidden
+
+    # Now authenticated
+    assert_not_equal "trackable", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+    post :create, { :trace => { :gpx_file => file, :description => "New Trace", :tagstring => "new,trace", :visibility => "trackable" } }, { :user => users(:public_user).id }
+    assert_response :redirect
+    assert_redirected_to :action => :list, :display_name => users(:public_user).display_name
+    assert_match /file has been uploaded/, flash[:notice]
+    trace = Trace.order(:id => :desc).first
+    assert_equal "1.gpx", trace.name
+    assert_equal "New Trace", trace.description
+    assert_equal "new, trace", trace.tagstring
+    assert_equal "trackable", trace.visibility
+    assert_equal false, trace.inserted
+    assert_equal File.new(gpx_files(:public_trace_file).trace_name).read, File.new(trace.trace_name).read
+    trace.destroy
+    assert_equal "trackable", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+  end
+
   # Test fetching the edit page for a trace
   def test_edit_get
     # First with no auth
@@ -464,6 +631,118 @@ class TraceControllerTest < ActionController::TestCase
     assert_response :not_found
   end
 
+  # Test downloading a trace through the api
+  def test_api_data
+    # First with no auth
+    get :api_data, :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id
+    assert_response :unauthorized
+
+    # Now with some other user, which should work since the trace is public
+    basic_authorization(users(:public_user).display_name, "test")
+    get :api_data, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }
+    check_trace_data gpx_files(:public_trace_file)
+
+    # And finally we should be able to do it with the owner of the trace
+    basic_authorization(users(:normal_user).display_name, "test")
+    get :api_data, { :display_name => users(:normal_user).display_name, :id => gpx_files(:public_trace_file).id }
+    check_trace_data gpx_files(:public_trace_file)
+  end
+
+  # Test downloading a compressed trace through the api
+  def test_api_data_compressed
+    # Authenticate as the owner of the trace we will be using
+    basic_authorization(users(:public_user).display_name, "test")
+
+    # First get the data as is
+    get :api_data, :display_name => users(:public_user).display_name, :id => gpx_files(:identifiable_trace_file).id
+    check_trace_data gpx_files(:identifiable_trace_file), "application/x-gzip", "gpx.gz"
+
+    # Now ask explicitly for XML format
+    get :api_data, :display_name => users(:public_user).display_name, :id => gpx_files(:identifiable_trace_file).id, :format => "xml"
+    check_trace_data gpx_files(:identifiable_trace_file), "application/xml", "xml"
+
+    # Now ask explicitly for GPX format
+    get :api_data, :display_name => users(:public_user).display_name, :id => gpx_files(:identifiable_trace_file).id, :format => "gpx"
+    check_trace_data gpx_files(:identifiable_trace_file)
+  end
+
+  # Check an anonymous trace can't be downloaded by another user through the api
+  def test_api_data_anon
+    # First with no auth
+    get :api_data, :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id
+    assert_response :unauthorized
+
+    # Now with some other user, which shouldn't work since the trace is anon
+    basic_authorization(users(:normal_user).display_name, "test")
+    get :api_data, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }
+    assert_response :forbidden
+
+    # And finally we should be able to do it with the owner of the trace
+    basic_authorization(users(:public_user).display_name, "test")
+    get :api_data, { :display_name => users(:public_user).display_name, :id => gpx_files(:anon_trace_file).id }
+    check_trace_data gpx_files(:anon_trace_file)
+  end
+
+  # Test downloading a trace that doesn't exist through the api
+  def test_api_data_not_found
+    # First with no auth
+    get :api_data, :display_name => users(:public_user).display_name, :id => 0
+    assert_response :unauthorized
+
+    # Now with a trace that has never existed
+    basic_authorization(users(:public_user).display_name, "test")
+    get :api_data, { :display_name => users(:public_user).display_name, :id => 0 }
+    assert_response :not_found
+
+    # Now with a trace that has been deleted
+    basic_authorization(users(:public_user).display_name, "test")
+    get :api_data, { :display_name => users(:public_user).display_name, :id => 5 }
+    assert_response :not_found
+  end
+
+  # Test creating a trace through the api
+  def test_api_create
+    # Get file to use
+    file = Rack::Test::UploadedFile.new(gpx_files(:public_trace_file).trace_name, "application/gpx+xml")
+
+    # First with no auth
+    post :api_create, { :file => file, :description => "New Trace", :tags => "new,trace", :visibility => "trackable" }
+    assert_response :unauthorized
+
+    # Now authenticated
+    assert_not_equal "trackable", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+    basic_authorization(users(:public_user).display_name, "test")
+    post :api_create, { :file => file, :description => "New Trace", :tags => "new,trace", :visibility => "trackable" }
+    assert_response :success
+    trace = Trace.find(response.body.to_i)
+    assert_equal "1.gpx", trace.name
+    assert_equal "New Trace", trace.description
+    assert_equal "new, trace", trace.tagstring
+    assert_equal "trackable", trace.visibility
+    assert_equal false, trace.inserted
+    assert_equal File.new(gpx_files(:public_trace_file).trace_name).read, File.new(trace.trace_name).read
+    trace.destroy
+    assert_equal "trackable", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+
+    # Rewind the file
+    file.rewind
+
+    # Now authenticated, with the legacy public flag
+    assert_not_equal "private", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+    basic_authorization(users(:public_user).display_name, "test")
+    post :api_create, { :file => file, :description => "New Trace", :tags => "new,trace", :public => 0 }
+    assert_response :success
+    trace = Trace.find(response.body.to_i)
+    assert_equal "1.gpx", trace.name
+    assert_equal "New Trace", trace.description
+    assert_equal "new, trace", trace.tagstring
+    assert_equal "private", trace.visibility
+    assert_equal false, trace.inserted
+    assert_equal File.new(gpx_files(:public_trace_file).trace_name).read, File.new(trace.trace_name).read
+    trace.destroy
+    assert_equal "private", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+  end
+
   # Check updating a trace through the api
   def test_api_update
     # First with no auth
@@ -554,7 +833,7 @@ class TraceControllerTest < ActionController::TestCase
             assert_select item, "link", "http://test.host/user/#{trace.user.display_name}/traces/#{trace.id}"
             assert_select item, "guid", "http://test.host/user/#{trace.user.display_name}/traces/#{trace.id}"
             assert_select item, "description"
-            #            assert_select item, "dc:creator", trace.user.display_name
+            # assert_select item, "dc:creator", trace.user.display_name
             assert_select item, "pubDate", trace.timestamp.rfc822
           end
         end
@@ -570,7 +849,8 @@ class TraceControllerTest < ActionController::TestCase
       assert_select "table#trace_list tbody", :count => 1 do
         assert_select "tr", :count => traces.visible.count do |rows|
           traces.visible.order("timestamp DESC").zip(rows).each do |trace, row|
-            assert_select row, "span.trace_summary", Regexp.new(Regexp.escape("(#{trace.size} points)"))
+            assert_select row, "a", Regexp.new(Regexp.escape(trace.name))
+            assert_select row, "span.trace_summary", Regexp.new(Regexp.escape("(#{trace.size} points)")) if trace.inserted?
             assert_select row, "td", Regexp.new(Regexp.escape(trace.description))
             assert_select row, "td", Regexp.new(Regexp.escape("by #{trace.user.display_name}"))
           end
@@ -594,7 +874,19 @@ class TraceControllerTest < ActionController::TestCase
 
   def check_trace_data(trace, content_type = "application/gpx+xml", extension = "gpx")
     assert_response :success
-    assert_equal content_type, @response.content_type
+    assert_equal content_type, response.content_type
     assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"", @response.header["Content-Disposition"]
   end
+
+  def check_trace_picture(trace)
+    assert_response :success
+    assert_equal "image/gif", response.content_type
+    assert_equal trace.large_picture, response.body
+  end
+
+  def check_trace_icon(trace)
+    assert_response :success
+    assert_equal "image/gif", response.content_type
+    assert_equal trace.icon_picture, response.body
+  end
 end
index 3c36b29d1025ff55731e5a9e058865c53414ddfe..752ec56cb33b6d6a8dfdd2a75e9a67a825e24792 100644 (file)
@@ -36,7 +36,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :unauthorized, "should be authenticated"
 
     # authenticate as a user with no preferences
-    basic_authorization("test@example.com", "test")
+    basic_authorization("moderator@example.com", "test")
 
     # try the read again
     get :read
index 4f4a82d98be8be0eed0850f6a63760a3be7f051d..4af266cf2058d7e0b4a1371c17693ca6ae6ba431 100644 (file)
@@ -114,3 +114,16 @@ tar_bzip_trace_file:
   visibility: "private"
   description: This is a bzipped tarred trace
   inserted: true
+
+pending_trace_file:
+  id: 10
+  user_id: 2
+  visible: true
+  name: Pending Trace.gpx
+  size: 123
+  latitude: 51.3
+  longitude: -0.56
+  timestamp: "2009-05-06 13:34:34"
+  visibility: "public"
+  description: This is a pending trace
+  inserted: false
index 59ebd0542bd9cdcf672414c30a1ec8d91c43497d..03065a9ebac43373ab8ad50871013e559c810e3d 100644 (file)
@@ -9,3 +9,13 @@ two:
   user_id: 1
   k: "some_key"
   v: "some_value"
+
+u2_trace:
+  user_id: 2
+  k: "gps.trace.visibility"
+  v: "identifiable"
+
+u3_trace:
+  user_id: 4
+  k: "gps.trace.public"
+  v: "default"
index 4be160959c26d8c9e98a421cd484cdf7fdcd0a3d..85b25875809c781f5dbe65def04df211ac8e70f9 100644 (file)
@@ -15,33 +15,34 @@ class TraceTest < ActiveSupport::TestCase
   end
 
   def test_trace_count
-    assert_equal 9, Trace.count
+    assert_equal 10, Trace.count
   end
 
   def test_visible
     check_query(Trace.visible, [
       :public_trace_file, :anon_trace_file, :trackable_trace_file,
       :identifiable_trace_file, :zipped_trace_file, :tar_trace_file,
-      :tar_gzip_trace_file, :tar_bzip_trace_file
+      :tar_gzip_trace_file, :tar_bzip_trace_file, :pending_trace_file
     ])
   end
 
   def test_visible_to
     check_query(Trace.visible_to(1), [
-      :public_trace_file, :identifiable_trace_file
+      :public_trace_file, :identifiable_trace_file, :pending_trace_file
     ])
     check_query(Trace.visible_to(2), [
       :public_trace_file, :anon_trace_file, :trackable_trace_file,
-      :identifiable_trace_file
+      :identifiable_trace_file, :pending_trace_file
     ])
     check_query(Trace.visible_to(3), [
-      :public_trace_file, :identifiable_trace_file
+      :public_trace_file, :identifiable_trace_file, :pending_trace_file
     ])
   end
 
   def test_visible_to_all
     check_query(Trace.visible_to_all, [
-      :public_trace_file, :identifiable_trace_file, :deleted_trace_file
+      :public_trace_file, :identifiable_trace_file,
+      :deleted_trace_file, :pending_trace_file
     ])
   end
 
index da6cd7666a5641363940ef09f1544358e97ed716..ee2dbf2d8ca0b66ba6873c2d1ec6a0bb4427fb2a 100644 (file)
@@ -9,7 +9,7 @@ class UserPreferenceTest < ActiveSupport::TestCase
   # This test needs to be updated for every addition/deletion from
   # the fixture file
   def test_check_count
-    assert_equal 2, UserPreference.count
+    assert_equal 4, UserPreference.count
   end
 
   # Checks that you cannot add a new preference, that is a duplicate
diff --git a/test/traces/1.gif b/test/traces/1.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/1.gif differ
diff --git a/test/traces/10.gpx b/test/traces/10.gpx
new file mode 100644 (file)
index 0000000..4471398
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx
+  version="1.0"
+  creator="GPSBabel - http://www.gpsbabel.org"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns="http://www.topografix.com/GPX/1/0"
+  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+<time>2009-05-06T13:34:34.000Z</time>
+<bounds minlat="51.3" minlon="-0.56" maxlat="51.3" maxlon="-0.56"/>
+<trk>
+<trkseg>
+<trkpt lat="51.3" lon="-0.56">
+  <time>2009-05-06T13:34:34.000Z</time>
+  <course>112.430000</course>
+  <speed>0.072022</speed>
+  <fix>3d</fix>
+  <sat>4</sat>
+  <hdop>2.400000</hdop>
+  <vdop>2.600000</vdop>
+  <pdop>3.600000</pdop>
+</trkpt>
+</trkseg>
+</trk>
+</gpx>
diff --git a/test/traces/1_icon.gif b/test/traces/1_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/1_icon.gif differ
diff --git a/test/traces/2.gif b/test/traces/2.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/2.gif differ
diff --git a/test/traces/2_icon.gif b/test/traces/2_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/2_icon.gif differ
diff --git a/test/traces/3.gif b/test/traces/3.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/3.gif differ
diff --git a/test/traces/3_icon.gif b/test/traces/3_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/3_icon.gif differ
diff --git a/test/traces/4.gif b/test/traces/4.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/4.gif differ
diff --git a/test/traces/4_icon.gif b/test/traces/4_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/4_icon.gif differ
diff --git a/test/traces/6.gif b/test/traces/6.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/6.gif differ
diff --git a/test/traces/6_icon.gif b/test/traces/6_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/6_icon.gif differ
diff --git a/test/traces/7.gif b/test/traces/7.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/7.gif differ
diff --git a/test/traces/7_icon.gif b/test/traces/7_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/7_icon.gif differ
diff --git a/test/traces/8.gif b/test/traces/8.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/8.gif differ
diff --git a/test/traces/8_icon.gif b/test/traces/8_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/8_icon.gif differ
diff --git a/test/traces/9.gif b/test/traces/9.gif
new file mode 100644 (file)
index 0000000..da7254d
Binary files /dev/null and b/test/traces/9.gif differ
diff --git a/test/traces/9_icon.gif b/test/traces/9_icon.gif
new file mode 100644 (file)
index 0000000..a92900b
Binary files /dev/null and b/test/traces/9_icon.gif differ