4 class PermissionsControllerTest < ActionController::TestCase
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/permissions", :method => :get },
10 { :controller => "api/permissions", :action => "show" }
14 def test_permissions_anonymous
16 assert_response :success
17 assert_select "osm > permissions", :count => 1 do
18 assert_select "permission", :count => 0
22 def test_permissions_basic_auth
23 basic_authorization create(:user).email, "test"
25 assert_response :success
26 assert_select "osm > permissions", :count => 1 do
27 assert_select "permission", :count => ClientApplication.all_permissions.size
28 ClientApplication.all_permissions.each do |p|
29 assert_select "permission[name='#{p}']", :count => 1
34 def test_permissions_oauth
35 @request.env["oauth.token"] = AccessToken.new do |token|
37 token.allow_read_prefs = true
38 token.allow_write_api = true
39 token.allow_read_gpx = false
42 assert_response :success
43 assert_select "osm > permissions", :count => 1 do
44 assert_select "permission", :count => 2
45 assert_select "permission[name='allow_read_prefs']", :count => 1
46 assert_select "permission[name='allow_write_api']", :count => 1
47 assert_select "permission[name='allow_read_gpx']", :count => 0