comparison .svn/pristine/a6/a6ae8d4e019a56b1c1694cce112ce20ab4d1bb3c.svn-base @ 1494:e248c7af89ec redmine-2.4

Update to Redmine SVN revision 12979 on 2.4-stable branch
author Chris Cannam
date Mon, 17 Mar 2014 08:54:02 +0000
parents
children
comparison
equal deleted inserted replaced
1464:261b3d9a4903 1494:e248c7af89ec
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../../test_helper', __FILE__)
19
20 class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
21 fixtures :roles
22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 test "GET /roles.xml should return the roles" do
28 get '/roles.xml'
29
30 assert_response :success
31 assert_equal 'application/xml', @response.content_type
32 assert_equal 3, assigns(:roles).size
33
34 assert_tag :tag => 'roles',
35 :attributes => {:type => 'array'},
36 :child => {
37 :tag => 'role',
38 :child => {
39 :tag => 'id',
40 :content => '2',
41 :sibling => {
42 :tag => 'name',
43 :content => 'Developer'
44 }
45 }
46 }
47 end
48
49 test "GET /roles.json should return the roles" do
50 get '/roles.json'
51
52 assert_response :success
53 assert_equal 'application/json', @response.content_type
54 assert_equal 3, assigns(:roles).size
55
56 json = ActiveSupport::JSON.decode(response.body)
57 assert_kind_of Hash, json
58 assert_kind_of Array, json['roles']
59 assert_include({'id' => 2, 'name' => 'Developer'}, json['roles'])
60 end
61
62 test "GET /roles/:id.xml should return the role" do
63 get '/roles/1.xml'
64
65 assert_response :success
66 assert_equal 'application/xml', @response.content_type
67
68 assert_select 'role' do
69 assert_select 'name', :text => 'Manager'
70 assert_select 'role permissions[type=array]' do
71 assert_select 'permission', Role.find(1).permissions.size
72 assert_select 'permission', :text => 'view_issues'
73 end
74 end
75 end
76 end