]> 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 8971b7a2b3b12984aa0ee980c73a91c9f5e42768..91bad005a3f66556e759e8cbbe343f960c8246e2 100644 (file)
@@ -1,8 +1,6 @@
 require "test_helper"
 
 class OAuthTest < ActionDispatch::IntegrationTest
-  fixtures :users
-
   include OAuth::Helper
 
   def setup
@@ -10,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)
@@ -21,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)
@@ -31,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)
@@ -42,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)
@@ -167,7 +173,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    trace = create(:trace, :user => users(:public_user))
+    trace = create(:trace, :user => client.user)
     signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success
 
@@ -230,7 +236,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
     signed_get "/api/0.6/user/preferences", :consumer => client, :token => token
     assert_response :success
 
-    trace = create(:trace, :user => users(:public_user))
+    trace = create(:trace, :user => client.user)
     signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :forbidden
 
@@ -279,7 +285,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
     assert_nil token.invalidated_at
     assert_allowed token, [:allow_write_api, :allow_read_gpx]
 
-    trace = create(:trace, :user => users(:public_user))
+    trace = create(:trace, :user => client.user)
     signed_get "/api/0.6/gpx/#{trace.id}", :consumer => client, :token => token
     assert_response :success