post :create, :params => { :trace => { :gpx_file => file, :description => "New Trace", :tagstring => "new,trace", :visibility => "trackable" } }
assert_response :forbidden
+ # Rewind the file
+ file.rewind
+
# Now authenticated
create(:user_preference, :user => user, :k => "gps.trace.visibility", :v => "identifiable")
assert_not_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v
post :delete, :params => { :display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file.id }, :session => { :user => deleted_trace_file.user }
assert_response :not_found
- # Finally with a trace that we are allowed to delete
+ # Now with a trace that we are allowed to delete
post :delete, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => public_trace_file.user }
assert_response :redirect
assert_redirected_to :action => :list, :display_name => public_trace_file.user.display_name
trace = Trace.find(public_trace_file.id)
assert_equal false, trace.visible
+
+ # Finally with a trace that is deleted by an admin
+ public_trace_file = create(:trace, :visibility => "public")
+ admin = create(:administrator_user)
+
+ post :delete, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => admin }
+ assert_response :redirect
+ assert_redirected_to :action => :list, :display_name => public_trace_file.user.display_name
+ trace = Trace.find(public_trace_file.id)
+ assert_equal false, trace.visible
end
# Check getting a specific trace through the api
post :api_create, :params => { :file => file, :description => "New Trace", :tags => "new,trace", :visibility => "trackable" }
assert_response :unauthorized
+ # Rewind the file
+ file.rewind
+
# Now authenticated
create(:user_preference, :user => user, :k => "gps.trace.visibility", :v => "identifiable")
assert_not_equal "trackable", user.preferences.where(:k => "gps.trace.visibility").first.v