From 98a76339b84450999b0cadeacf528a78cff09cae Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Thu, 7 May 2009 17:57:59 +0000 Subject: [PATCH] Some more tests --- test/functional/changeset_controller_test.rb | 41 ++++++++++++++++++++ test/functional/trace_controller_test.rb | 13 +++++++ 2 files changed, 54 insertions(+) diff --git a/test/functional/changeset_controller_test.rb b/test/functional/changeset_controller_test.rb index ce739b96c..91b89cdba 100644 --- a/test/functional/changeset_controller_test.rb +++ b/test/functional/changeset_controller_test.rb @@ -95,6 +95,15 @@ class ChangesetControllerTest < ActionController::TestCase assert_select "osm>changeset[id=#{changeset_id}]", 1 end + ## + # check that a changeset that doesn't exist returns an appropriate message + def test_read_not_found + [0, -32, 233455644, "afg", "213"].each do |id| + get :read, :id => id + assert_response :not_found, "should get a not found" + end + end + ## # test that the user who opened a change can close it def test_close @@ -131,6 +140,38 @@ class ChangesetControllerTest < ActionController::TestCase assert_response :conflict assert_equal "The user doesn't own that changeset", @response.body end + + ## + # test that you can't close using another method + def test_close_method_invalid + basic_authorization users(:public_user).email, "test" + + cs_id = changesets(:public_user_first_change).id + get :close, :id => cs_id + assert_response :method_not_allowed + + post :close, :id => cs_id + assert_response :method_not_allowed + end + + ## + # check that you can't close a changeset that isn't found + def test_close_not_found + cs_ids = [0, -132, "123"] + + # First try to do it with no auth + cs_ids.each do |id| + put :close, :id => id + assert_response :unauthorized, "Shouldn't be able close the non-existant changeset #{id}, when not authorized" + end + + # Now try with auth + basic_authorization users(:public_user).email, "test" + cs_ids.each do |id| + put :close, :id => id + assert_response :not_found, "The changeset #{id} doesn't exist, so can't be closed" + end + end ## # upload something simple, but valid and check that it can diff --git a/test/functional/trace_controller_test.rb b/test/functional/trace_controller_test.rb index 475d3eb3e..f60d75679 100644 --- a/test/functional/trace_controller_test.rb +++ b/test/functional/trace_controller_test.rb @@ -12,6 +12,19 @@ class TraceControllerTest < ActionController::TestCase assert_template 'list' end + # Check that I can get mine + def test_list_mine + # First try to get it when not logged in + get :mine + assert_redirected_to :controller => 'user', :action => 'login', :referer => '/traces/mine' + + # Now try when logged in + get :mine, {}, {:user => users(:public_user).id} + assert_response :success + assert_template 'mine' + # Should really test to see which files are shown to the user + end + # Check that the rss loads def test_rss get :georss -- 2.43.2