]> git.openstreetmap.org Git - rails.git/commitdiff
Added test for user prefs JSON response
authorMichal Migurski <migurski@fb.com>
Fri, 9 Apr 2021 21:06:53 +0000 (14:06 -0700)
committerMichal Migurski <migurski@fb.com>
Fri, 9 Apr 2021 21:28:13 +0000 (14:28 -0700)
test/controllers/api/user_preferences_controller_test.rb

index 7cfc875efb6f98b543f243a8120a7ffee04cce0a..bf36c5d4461ef26c1ecf5bc2c1e4eed5b2e17f33 100644 (file)
@@ -62,6 +62,15 @@ 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
     end
 
     ##