]> git.openstreetmap.org Git - rails.git/commitdiff
Update for API change in CPK 7.x
authorTom Hughes <tom@compton.nu>
Tue, 27 May 2014 23:44:26 +0000 (00:44 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 4 Jul 2014 18:24:25 +0000 (19:24 +0100)
app/controllers/user_preference_controller.rb
test/controllers/user_preference_controller_test.rb

index 059f00bbe38b5a6656ba2d4d5f277bc6498aa872..a3face30d4d42af71750d4bf9ac77a038e3c2526 100644 (file)
@@ -26,7 +26,7 @@ class UserPreferenceController < ApplicationController
   ##
   # return the value for a single preference
   def read_one
-    pref = UserPreference.find(@user.id, params[:preference_key])
+    pref = UserPreference.find([@user.id, params[:preference_key]])
 
     render :text => pref.v.to_s, :content_type => "text/plain"
   end
@@ -69,7 +69,7 @@ class UserPreferenceController < ApplicationController
   # update the value of a single preference
   def update_one
     begin
-      pref = UserPreference.find(@user.id, params[:preference_key])
+      pref = UserPreference.find([@user.id, params[:preference_key]])
     rescue ActiveRecord::RecordNotFound 
       pref = UserPreference.new
       pref.user = @user
@@ -85,7 +85,7 @@ class UserPreferenceController < ApplicationController
   ##
   # delete a single preference
   def delete_one
-    UserPreference.find(@user.id, params[:preference_key]).delete
+    UserPreference.find([@user.id, params[:preference_key]]).delete
 
     render :text => "", :content_type => "text/plain"
   end
index f8cafe6a9279a46ed3b7e942b951f3a480055cc5..4966ae7485051fdeb6a02a7a4f04b31d94823caf 100644 (file)
@@ -92,10 +92,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
       put :update
     end
     assert_response :unauthorized, "should be authenticated"
-    assert_equal "value", UserPreference.find(1, "key").v
-    assert_equal "some_value", UserPreference.find(1, "some_key").v
+    assert_equal "value", UserPreference.find([1, "key"]).v
+    assert_equal "some_value", UserPreference.find([1, "some_key"]).v
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "new_key")
+      UserPreference.find([1, "new_key"])
     end
 
     # authenticate as a user with preferences
@@ -109,10 +109,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "new_value", UserPreference.find(1, "key").v
-    assert_equal "value", UserPreference.find(1, "new_key").v
+    assert_equal "new_value", UserPreference.find([1, "key"]).v
+    assert_equal "value", UserPreference.find([1, "new_key"]).v
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "some_key")
+      UserPreference.find([1, "some_key"])
     end
 
     # try a put with duplicate keys
@@ -123,7 +123,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :bad_request
     assert_equal "text/plain", @response.content_type
     assert_equal "Duplicate preferences with key key", @response.body
-    assert_equal "new_value", UserPreference.find(1, "key").v
+    assert_equal "new_value", UserPreference.find([1, "key"]).v
 
     # try a put with invalid content
     assert_no_difference "UserPreference.count" do
@@ -143,7 +143,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     end
     assert_response :unauthorized, "should be authenticated"
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "new_key")
+      UserPreference.find([1, "new_key"])
     end
 
     # authenticate as a user with preferences
@@ -157,7 +157,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "new_value", UserPreference.find(1, "new_key").v
+    assert_equal "new_value", UserPreference.find([1, "new_key"]).v
 
     # try changing the value of a preference
     assert_no_difference "UserPreference.count" do
@@ -167,7 +167,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "newer_value", UserPreference.find(1, "new_key").v
+    assert_equal "newer_value", UserPreference.find([1, "new_key"]).v
   end
 
   ##
@@ -178,7 +178,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
       delete :delete_one, :preference_key => "key"
     end
     assert_response :unauthorized, "should be authenticated"
-    assert_equal "value", UserPreference.find(1, "key").v
+    assert_equal "value", UserPreference.find([1, "key"]).v
 
     # authenticate as a user with preferences
     basic_authorization("test@openstreetmap.org", "test")
@@ -191,7 +191,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "key")
+      UserPreference.find([1, "key"])
     end
 
     # try the delete again for the same key
@@ -200,7 +200,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     end
     assert_response :not_found
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "key")
+      UserPreference.find([1, "key"])
     end
   end
 end