]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/user_preferences_controller_test.rb
Merge branch 'pull/3164'
[rails.git] / test / controllers / api / user_preferences_controller_test.rb
index 7cfc875efb6f98b543f243a8120a7ffee04cce0a..3d3f7971201e6951967e53ea54512c8785ed403a 100644 (file)
@@ -9,6 +9,10 @@ module Api
         { :path => "/api/0.6/user/preferences", :method => :get },
         { :controller => "api/user_preferences", :action => "index" }
       )
+      assert_routing(
+        { :path => "/api/0.6/user/preferences.json", :method => :get },
+        { :controller => "api/user_preferences", :action => "index", :format => "json" }
+      )
       assert_routing(
         { :path => "/api/0.6/user/preferences", :method => :put },
         { :controller => "api/user_preferences", :action => "update_all" }
@@ -62,6 +66,16 @@ module Api
           assert_select "preference[k=\"#{user_preference2.k}\"][v=\"#{user_preference2.v}\"]", :count => 1
         end
       end
+
+      # Test json
+      get user_preferences_path(:format => "json"), :headers => auth_header
+      assert_response :success
+      assert_equal "application/json", @response.media_type
+
+      js = ActiveSupport::JSON.decode(@response.body)
+      assert_not_nil js
+      assert_equal 2, js["preferences"].count
+      assert_equal user_preference.v, js["preferences"][user_preference.k]
     end
 
     ##