X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dae3dcf87edcfc0648cd0b93b069b0eee67d3ab7..1a1d924ae060f82567599b25b090a729d5c721e9:/test/controllers/oauth_clients_controller_test.rb?ds=sidebyside diff --git a/test/controllers/oauth_clients_controller_test.rb b/test/controllers/oauth_clients_controller_test.rb index 6bafa62cc..76f366e3d 100644 --- a/test/controllers/oauth_clients_controller_test.rb +++ b/test/controllers/oauth_clients_controller_test.rb @@ -1,8 +1,6 @@ require "test_helper" class OauthClientsControllerTest < ActionController::TestCase - fixtures :users, :client_applications - ## # test all routes which lead to this controller def test_routes @@ -37,7 +35,8 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_index - user = users(:public_user) + user = create(:user) + create_list(:client_application, 2, :user => user) get :index, :display_name => user.display_name assert_response :redirect @@ -50,7 +49,7 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_new - user = users(:public_user) + user = create(:user) get :new, :display_name => user.display_name assert_response :redirect @@ -71,7 +70,7 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_create - user = users(:public_user) + user = create(:user) assert_difference "ClientApplication.count", 0 do post :create, :display_name => user.display_name @@ -99,18 +98,19 @@ class OauthClientsControllerTest < ActionController::TestCase }, { :user => user } end assert_response :redirect - assert_redirected_to oauth_client_path(:id => ClientApplication.find_by_name("Test Application").id) + assert_redirected_to oauth_client_path(:id => ClientApplication.find_by(:name => "Test Application").id) end def test_show - user = users(:public_user) - client = client_applications(:oauth_web_app) + user = create(:user) + client = create(:client_application, :user => user) + other_client = create(:client_application) get :show, :display_name => user.display_name, :id => client.id assert_response :redirect assert_redirected_to login_path(:referer => oauth_client_path(:display_name => user.display_name, :id => client.id)) - get :show, { :display_name => user.display_name, :id => client_applications(:normal_user_app).id }, { :user => user } + get :show, { :display_name => user.display_name, :id => other_client.id }, { :user => user } assert_response :not_found assert_template "not_found" @@ -120,14 +120,15 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_edit - user = users(:public_user) - client = client_applications(:oauth_web_app) + user = create(:user) + client = create(:client_application, :user => user) + other_client = create(:client_application) get :edit, :display_name => user.display_name, :id => client.id assert_response :redirect assert_redirected_to login_path(:referer => edit_oauth_client_path(:display_name => user.display_name, :id => client.id)) - get :edit, { :display_name => user.display_name, :id => client_applications(:normal_user_app).id }, { :user => user } + get :edit, { :display_name => user.display_name, :id => other_client.id }, { :user => user } assert_response :not_found assert_template "not_found" @@ -146,13 +147,14 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_update - user = users(:public_user) - client = client_applications(:oauth_web_app) + user = create(:user) + client = create(:client_application, :user => user) + other_client = create(:client_application) put :update, :display_name => user.display_name, :id => client.id assert_response :forbidden - put :update, { :display_name => user.display_name, :id => client_applications(:normal_user_app).id }, { :user => user } + put :update, { :display_name => user.display_name, :id => other_client.id }, { :user => user } assert_response :not_found assert_template "not_found" @@ -180,8 +182,9 @@ class OauthClientsControllerTest < ActionController::TestCase end def test_destroy - user = users(:public_user) - client = client_applications(:oauth_web_app) + user = create(:user) + client = create(:client_application, :user => user) + other_client = create(:client_application) assert_difference "ClientApplication.count", 0 do delete :destroy, :display_name => user.display_name, :id => client.id @@ -189,7 +192,7 @@ class OauthClientsControllerTest < ActionController::TestCase assert_response :forbidden assert_difference "ClientApplication.count", 0 do - delete :destroy, { :display_name => user.display_name, :id => client_applications(:normal_user_app).id }, { :user => user } + delete :destroy, { :display_name => user.display_name, :id => other_client.id }, { :user => user } end assert_response :not_found assert_template "not_found"