X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f11221f05bcdd05edd7a9f97d6d57e7baaeb4921..aaf56003427cfcbd89fda0847726fd0baa34050c:/test/controllers/user_preferences_controller_test.rb
diff --git a/test/controllers/user_preferences_controller_test.rb b/test/controllers/user_preferences_controller_test.rb
index 1a51779ed..ddd7e2a40 100644
--- a/test/controllers/user_preferences_controller_test.rb
+++ b/test/controllers/user_preferences_controller_test.rb
@@ -35,7 +35,6 @@ class UserPreferencesControllerTest < ActionController::TestCase
# authenticate as a user with no preferences
basic_authorization create(:user).email, "test"
- grant_oauth_token :allow_read_prefs
# try the read again
get :read
@@ -76,7 +75,6 @@ class UserPreferencesControllerTest < ActionController::TestCase
# authenticate as a user with preferences
basic_authorization user.email, "test"
- grant_oauth_token :allow_read_prefs
# try the read again
get :read_one, :params => { :preference_key => "key" }
@@ -98,8 +96,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
# try a put without auth
assert_no_difference "UserPreference.count" do
- content ""
- put :update
+ put :update, :body => ""
end
assert_response :unauthorized, "should be authenticated"
assert_equal "value", UserPreference.find([user.id, "key"]).v
@@ -110,12 +107,10 @@ class UserPreferencesControllerTest < ActionController::TestCase
# authenticate as a user with preferences
basic_authorization user.email, "test"
- grant_oauth_token :allow_write_prefs
# try the put again
assert_no_difference "UserPreference.count" do
- content ""
- put :update
+ put :update, :body => ""
end
assert_response :success
assert_equal "text/plain", @response.content_type
@@ -128,8 +123,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
# try a put with duplicate keys
assert_no_difference "UserPreference.count" do
- content ""
- put :update
+ put :update, :body => ""
end
assert_response :bad_request
assert_equal "text/plain", @response.content_type
@@ -138,8 +132,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
# try a put with invalid content
assert_no_difference "UserPreference.count" do
- content "nonsense"
- put :update
+ put :update, :body => "nonsense"
end
assert_response :bad_request
end
@@ -152,8 +145,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
# try a put without auth
assert_no_difference "UserPreference.count" do
- content "new_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
end
assert_response :unauthorized, "should be authenticated"
assert_raises ActiveRecord::RecordNotFound do
@@ -162,12 +154,10 @@ class UserPreferencesControllerTest < ActionController::TestCase
# authenticate as a user with preferences
basic_authorization user.email, "test"
- grant_oauth_token :allow_write_prefs
# try adding a new preference
assert_difference "UserPreference.count", 1 do
- content "new_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
end
assert_response :success
assert_equal "text/plain", @response.content_type
@@ -176,8 +166,7 @@ class UserPreferencesControllerTest < ActionController::TestCase
# try changing the value of a preference
assert_no_difference "UserPreference.count" do
- content "newer_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "newer_value"
end
assert_response :success
assert_equal "text/plain", @response.content_type
@@ -200,7 +189,6 @@ class UserPreferencesControllerTest < ActionController::TestCase
# authenticate as a user with preferences
basic_authorization user.email, "test"
- grant_oauth_token :allow_write_prefs
# try the delete again
assert_difference "UserPreference.count", -1 do