]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/trace_controller_test.rb
last minor fixes
[rails.git] / test / controllers / trace_controller_test.rb
index d4f58c87218ced00a8c34b1418d12a5a89db7f78..2fec258af4855a2cfe0ecd8a54a3fe6f0ee647ad 100644 (file)
@@ -491,7 +491,7 @@ class TraceControllerTest < ActionController::TestCase
     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 %w(new trace), trace.tags.order(:tag).collect(&:tag)
     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
@@ -717,7 +717,7 @@ class TraceControllerTest < ActionController::TestCase
     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 %w(new trace), trace.tags.order(:tag).collect(&:tag)
     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
@@ -728,19 +728,37 @@ class TraceControllerTest < ActionController::TestCase
     file.rewind
 
     # Now authenticated, with the legacy public flag
-    assert_not_equal "private", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+    assert_not_equal "public", 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 => 1
+    assert_response :success
+    trace = Trace.find(response.body.to_i)
+    assert_equal "1.gpx", trace.name
+    assert_equal "New Trace", trace.description
+    assert_equal %w(new trace), trace.tags.order(:tag).collect(&:tag)
+    assert_equal "public", 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 "public", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
+
+    # Rewind the file
+    file.rewind
+
+    # Now authenticated, with the legacy private flag
+    assert_nil users(:second_public_user).preferences.where(:k => "gps.trace.visibility").first
+    basic_authorization(users(:second_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 %w(new trace), trace.tags.order(:tag).collect(&:tag)
     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
+    assert_equal "private", users(:second_public_user).preferences.where(:k => "gps.trace.visibility").first.v
   end
 
   # Check updating a trace through the api