@@ -0,0 +1,10 | |||||
|
1 | api.array :issue_statuses do | |||
|
2 | @issue_statuses.each do |status| | |||
|
3 | api.issue_status do | |||
|
4 | api.id status.id | |||
|
5 | api.name status.name | |||
|
6 | api.is_default status.is_default | |||
|
7 | api.is_closed status.is_closed | |||
|
8 | end | |||
|
9 | end | |||
|
10 | end |
@@ -0,0 +1,51 | |||||
|
1 | # Redmine - project management software | |||
|
2 | # Copyright (C) 2006-2011 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 ApiTest::IssueStatusesTest < ActionController::IntegrationTest | |||
|
21 | fixtures :issue_statuses | |||
|
22 | ||||
|
23 | def setup | |||
|
24 | Setting.rest_api_enabled = '1' | |||
|
25 | end | |||
|
26 | ||||
|
27 | context "/issue_statuses" do | |||
|
28 | context "GET" do | |||
|
29 | ||||
|
30 | should "return issue statuses" do | |||
|
31 | get '/issue_statuses.xml' | |||
|
32 | ||||
|
33 | assert_response :success | |||
|
34 | assert_equal 'application/xml', @response.content_type | |||
|
35 | assert_tag :tag => 'issue_statuses', | |||
|
36 | :attributes => {:type => 'array'}, | |||
|
37 | :child => { | |||
|
38 | :tag => 'issue_status', | |||
|
39 | :child => { | |||
|
40 | :tag => 'id', | |||
|
41 | :content => '2', | |||
|
42 | :sibling => { | |||
|
43 | :tag => 'name', | |||
|
44 | :content => 'Assigned' | |||
|
45 | } | |||
|
46 | } | |||
|
47 | } | |||
|
48 | end | |||
|
49 | end | |||
|
50 | end | |||
|
51 | end |
@@ -18,14 +18,23 | |||||
18 | class IssueStatusesController < ApplicationController |
|
18 | class IssueStatusesController < ApplicationController | |
19 | layout 'admin' |
|
19 | layout 'admin' | |
20 |
|
20 | |||
21 | before_filter :require_admin |
|
21 | before_filter :require_admin, :except => :index | |
|
22 | before_filter :require_admin_or_api_request, :only => :index | |||
|
23 | accept_api_auth :index | |||
22 |
|
24 | |||
23 | verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ], |
|
25 | verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ], | |
24 | :redirect_to => { :action => :index } |
|
26 | :redirect_to => { :action => :index } | |
25 |
|
27 | |||
26 | def index |
|
28 | def index | |
27 | @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position" |
|
29 | respond_to do |format| | |
28 | render :action => "index", :layout => false if request.xhr? |
|
30 | format.html { | |
|
31 | @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position" | |||
|
32 | render :action => "index", :layout => false if request.xhr? | |||
|
33 | } | |||
|
34 | format.api { | |||
|
35 | @issue_statuses = IssueStatus.all(:order => 'position') | |||
|
36 | } | |||
|
37 | end | |||
29 | end |
|
38 | end | |
30 |
|
39 | |||
31 | def new |
|
40 | def new |
@@ -228,6 +228,7 ActionController::Routing::Routes.draw do |map| | |||||
228 |
|
228 | |||
229 | #left old routes at the bottom for backwards compat |
|
229 | #left old routes at the bottom for backwards compat | |
230 | map.connect 'trackers.:format', :controller => 'trackers', :action => 'index' |
|
230 | map.connect 'trackers.:format', :controller => 'trackers', :action => 'index' | |
|
231 | map.connect 'issue_statuses.:format', :controller => 'issue_statuses', :action => 'index' | |||
231 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
232 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' | |
232 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
|
233 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' | |
233 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
234 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
@@ -21,6 +21,18 class IssueStatusesControllerTest < ActionController::TestCase | |||||
21 | assert_response :success |
|
21 | assert_response :success | |
22 | assert_template 'index' |
|
22 | assert_template 'index' | |
23 | end |
|
23 | end | |
|
24 | ||||
|
25 | def test_index_by_anonymous_should_redirect_to_login_form | |||
|
26 | @request.session[:user_id] = nil | |||
|
27 | get :index | |||
|
28 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fissue_statuses' | |||
|
29 | end | |||
|
30 | ||||
|
31 | def test_index_by_user_should_respond_with_406 | |||
|
32 | @request.session[:user_id] = 2 | |||
|
33 | get :index | |||
|
34 | assert_response 406 | |||
|
35 | end | |||
24 |
|
36 | |||
25 | def test_new |
|
37 | def test_new | |
26 | get :new |
|
38 | get :new |
General Comments 0
You need to be logged in to leave comments.
Login now