]> git.openstreetmap.org Git - rails.git/blobdiff - test/integration/oauth_test.rb
Remove deprecated get_via_direct and post_via_redirect methods
[rails.git] / test / integration / oauth_test.rb
index ceee95892f966d672a4508e11d0a18692cf2c361..91bad005a3f66556e759e8cbbe343f960c8246e2 100644 (file)
@@ -1,9 +1,6 @@
 require "test_helper"
 
 class OAuthTest < ActionDispatch::IntegrationTest
-  fixtures :users, :gpx_files
-  set_fixture_class :gpx_files => Trace
-
   include OAuth::Helper
 
   def setup
@@ -11,9 +8,11 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10_web_app
-    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
-    post_via_redirect "/login", :username => client.user.email, :password => "test"
+    post "/login", :username => client.user.email, :password => "test"
+    follow_redirect!
+    follow_redirect!
     assert_response :success
 
     oauth10_without_callback(client)
@@ -22,9 +21,11 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10_desktop_app
-    client = create(:client_application, :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
-    post_via_redirect "/login", :username => client.user.email, :password => "test"
+    post "/login", :username => client.user.email, :password => "test"
+    follow_redirect!
+    follow_redirect!
     assert_response :success
 
     oauth10_without_callback(client)
@@ -32,9 +33,11 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10a_web_app
-    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :callback_url => "http://some.web.app.example.org/callback", :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
-    post_via_redirect "/login", :username => client.user.email, :password => "test"
+    post "/login", :username => client.user.email, :password => "test"
+    follow_redirect!
+    follow_redirect!
     assert_response :success
 
     oauth10a_without_callback(client)
@@ -43,9 +46,11 @@ class OAuthTest < ActionDispatch::IntegrationTest
   end
 
   def test_oauth10a_desktop_app
-    client = create(:client_application, :user => users(:public_user), :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
+    client = create(:client_application, :allow_read_prefs => true, :allow_write_api => true, :allow_read_gpx => true)
 
-    post_via_redirect "/login", :username => client.user.email, :password => "test"
+    post "/login", :username => client.user.email, :password => "test"
+    follow_redirect!
+    follow_redirect!
     assert_response :success
 
     oauth10a_without_callback(client)
@@ -168,7 +173,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success
 
     signed_get "/api/0.6/user/details", :consumer => client, :token => token
@@ -230,7 +236,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
     assert_response :success
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :forbidden
 
     post "/oauth/revoke", :token => token.token
@@ -278,7 +285,8 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    signed_get "/api/0.6/gpx/2", :consumer => client, :token => token
+    trace = create(:trace, :user => client.user)
+    signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success
 
     signed_get "/api/0.6/user/details", :consumer => client, :token => token