@@ -0,0 +1,9 | |||
|
1 | api.role do | |
|
2 | api.id @role.id | |
|
3 | api.name @role.name | |
|
4 | api.array :permissions do | |
|
5 | @role.permissions.each do |perm| | |
|
6 | api.permission(perm.to_s) | |
|
7 | end | |
|
8 | end | |
|
9 | end |
@@ -18,10 +18,9 | |||
|
18 | 18 | class RolesController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | 20 | |
|
21 | before_filter :require_admin, :except => :index | |
|
22 | before_filter :require_admin_or_api_request, :only => :index | |
|
23 | before_filter :find_role, :only => [:edit, :update, :destroy] | |
|
24 | accept_api_auth :index | |
|
21 | before_filter :require_admin, :except => [:index, :show] | |
|
22 | before_filter :require_admin_or_api_request, :only => [:index, :show] | |
|
23 | before_filter :find_role, :only => [:show, :edit, :update, :destroy] | |
|
25 | 24 | |
|
26 | 25 | def index |
|
27 | 26 | respond_to do |format| |
@@ -35,6 +34,12 class RolesController < ApplicationController | |||
|
35 | 34 | end |
|
36 | 35 | end |
|
37 | 36 | |
|
37 | def show | |
|
38 | respond_to do |format| | |
|
39 | format.api | |
|
40 | end | |
|
41 | end | |
|
42 | ||
|
38 | 43 | def new |
|
39 | 44 | # Prefills the form with 'Non member' role permissions by default |
|
40 | 45 | @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) |
@@ -289,7 +289,7 RedmineApp::Application.routes.draw do | |||
|
289 | 289 | end |
|
290 | 290 | end |
|
291 | 291 | resources :custom_fields, :except => :show |
|
292 |
resources :roles |
|
|
292 | resources :roles do | |
|
293 | 293 | collection do |
|
294 | 294 | match 'permissions', :via => [:get, :post] |
|
295 | 295 | end |
@@ -66,4 +66,25 class ApiTest::RolesTest < ActionController::IntegrationTest | |||
|
66 | 66 | end |
|
67 | 67 | end |
|
68 | 68 | end |
|
69 | ||
|
70 | context "/roles/:id" do | |
|
71 | context "GET" do | |
|
72 | context "xml" do | |
|
73 | should "return the role" do | |
|
74 | get '/roles/1.xml' | |
|
75 | ||
|
76 | assert_response :success | |
|
77 | assert_equal 'application/xml', @response.content_type | |
|
78 | ||
|
79 | assert_select 'role' do | |
|
80 | assert_select 'name', :text => 'Manager' | |
|
81 | assert_select 'role permissions[type=array]' do | |
|
82 | assert_select 'permission', Role.find(1).permissions.size | |
|
83 | assert_select 'permission', :text => 'view_issues' | |
|
84 | end | |
|
85 | end | |
|
86 | end | |
|
87 | end | |
|
88 | end | |
|
89 | end | |
|
69 | 90 | end |
@@ -28,6 +28,10 class RoutingRolesTest < ActionController::IntegrationTest | |||
|
28 | 28 | { :controller => 'roles', :action => 'index', :format => 'xml' } |
|
29 | 29 | ) |
|
30 | 30 | assert_routing( |
|
31 | { :method => 'get', :path => "/roles/2.xml" }, | |
|
32 | { :controller => 'roles', :action => 'show', :id => '2', :format => 'xml' } | |
|
33 | ) | |
|
34 | assert_routing( | |
|
31 | 35 | { :method => 'get', :path => "/roles/new" }, |
|
32 | 36 | { :controller => 'roles', :action => 'new' } |
|
33 | 37 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now