1 require File.dirname(__FILE__) + '/../test_helper'
3 class UserPreferenceControllerTest < ActionController::TestCase
4 fixtures :users, :user_preferences
7 # test all routes which lead to this controller
10 { :path => "/api/0.6/user/preferences", :method => :get },
11 { :controller => "user_preference", :action => "read" }
14 { :path => "/api/0.6/user/preferences", :method => :put },
15 { :controller => "user_preference", :action => "update" }
18 { :path => "/api/0.6/user/preferences/key", :method => :get },
19 { :controller => "user_preference", :action => "read_one", :preference_key => "key" }
22 { :path => "/api/0.6/user/preferences/key", :method => :put },
23 { :controller => "user_preference", :action => "update_one", :preference_key => "key" }
26 { :path => "/api/0.6/user/preferences/key", :method => :delete },
27 { :controller => "user_preference", :action => "delete_one", :preference_key => "key" }
32 # first try without auth
34 assert_response :unauthorized, "should be authenticated"
37 basic_authorization("test@openstreetmap.org", "test")
40 assert_response :success
41 assert_select "osm" do
42 assert_select "preferences", :count => 1 do
43 assert_select "preference", :count => 2
44 assert_select "preference[k=\"#{user_preferences(:a).k}\"][v=\"#{user_preferences(:a).v}\"]", :count => 1
45 assert_select "preference[k=\"#{user_preferences(:two).k}\"][v=\"#{user_preferences(:two).v}\"]", :count => 1