##// END OF EJS Templates
Adds API response to /issue_statuses to get the list of all available statuses (#7180)....
Jean-Philippe Lang -
r7758:248b7258751c
parent child
Show More
@@ -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
@@ -1,75 +1,84
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
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
32 @issue_status = IssueStatus.new
41 @issue_status = IssueStatus.new
33 end
42 end
34
43
35 def create
44 def create
36 @issue_status = IssueStatus.new(params[:issue_status])
45 @issue_status = IssueStatus.new(params[:issue_status])
37 if @issue_status.save
46 if @issue_status.save
38 flash[:notice] = l(:notice_successful_create)
47 flash[:notice] = l(:notice_successful_create)
39 redirect_to :action => 'index'
48 redirect_to :action => 'index'
40 else
49 else
41 render :action => 'new'
50 render :action => 'new'
42 end
51 end
43 end
52 end
44
53
45 def edit
54 def edit
46 @issue_status = IssueStatus.find(params[:id])
55 @issue_status = IssueStatus.find(params[:id])
47 end
56 end
48
57
49 def update
58 def update
50 @issue_status = IssueStatus.find(params[:id])
59 @issue_status = IssueStatus.find(params[:id])
51 if @issue_status.update_attributes(params[:issue_status])
60 if @issue_status.update_attributes(params[:issue_status])
52 flash[:notice] = l(:notice_successful_update)
61 flash[:notice] = l(:notice_successful_update)
53 redirect_to :action => 'index'
62 redirect_to :action => 'index'
54 else
63 else
55 render :action => 'edit'
64 render :action => 'edit'
56 end
65 end
57 end
66 end
58
67
59 def destroy
68 def destroy
60 IssueStatus.find(params[:id]).destroy
69 IssueStatus.find(params[:id]).destroy
61 redirect_to :action => 'index'
70 redirect_to :action => 'index'
62 rescue
71 rescue
63 flash[:error] = l(:error_unable_delete_issue_status)
72 flash[:error] = l(:error_unable_delete_issue_status)
64 redirect_to :action => 'index'
73 redirect_to :action => 'index'
65 end
74 end
66
75
67 def update_issue_done_ratio
76 def update_issue_done_ratio
68 if IssueStatus.update_issue_done_ratios
77 if IssueStatus.update_issue_done_ratios
69 flash[:notice] = l(:notice_issue_done_ratios_updated)
78 flash[:notice] = l(:notice_issue_done_ratios_updated)
70 else
79 else
71 flash[:error] = l(:error_issue_done_ratios_not_updated)
80 flash[:error] = l(:error_issue_done_ratios_not_updated)
72 end
81 end
73 redirect_to :action => 'index'
82 redirect_to :action => 'index'
74 end
83 end
75 end
84 end
@@ -1,257 +1,258
1 ActionController::Routing::Routes.draw do |map|
1 ActionController::Routing::Routes.draw do |map|
2 # Add your own custom routes here.
2 # Add your own custom routes here.
3 # The priority is based upon order of creation: first created -> highest priority.
3 # The priority is based upon order of creation: first created -> highest priority.
4
4
5 # Here's a sample route:
5 # Here's a sample route:
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 # Keep in mind you can assign values other than :controller and :action
7 # Keep in mind you can assign values other than :controller and :action
8
8
9 map.home '', :controller => 'welcome'
9 map.home '', :controller => 'welcome'
10
10
11 map.signin 'login', :controller => 'account', :action => 'login'
11 map.signin 'login', :controller => 'account', :action => 'login'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
13
13
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
16
16
17 map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report|
17 map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report|
18 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report'
18 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report'
19 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format'
19 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format'
20 time_report.connect 'projects/:project_id/time_entries/report'
20 time_report.connect 'projects/:project_id/time_entries/report'
21 time_report.connect 'projects/:project_id/time_entries/report.:format'
21 time_report.connect 'projects/:project_id/time_entries/report.:format'
22 time_report.connect 'time_entries/report'
22 time_report.connect 'time_entries/report'
23 time_report.connect 'time_entries/report.:format'
23 time_report.connect 'time_entries/report.:format'
24 end
24 end
25
25
26 map.bulk_edit_time_entry 'time_entries/bulk_edit',
26 map.bulk_edit_time_entry 'time_entries/bulk_edit',
27 :controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get }
27 :controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get }
28 map.bulk_update_time_entry 'time_entries/bulk_edit',
28 map.bulk_update_time_entry 'time_entries/bulk_edit',
29 :controller => 'timelog', :action => 'bulk_update', :conditions => { :method => :post }
29 :controller => 'timelog', :action => 'bulk_update', :conditions => { :method => :post }
30 map.time_entries_context_menu '/time_entries/context_menu',
30 map.time_entries_context_menu '/time_entries/context_menu',
31 :controller => 'context_menus', :action => 'time_entries'
31 :controller => 'context_menus', :action => 'time_entries'
32 # TODO: wasteful since this is also nested under issues, projects, and projects/issues
32 # TODO: wasteful since this is also nested under issues, projects, and projects/issues
33 map.resources :time_entries, :controller => 'timelog'
33 map.resources :time_entries, :controller => 'timelog'
34
34
35 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
35 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
36 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
36 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
37 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
37 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
38
38
39 map.with_options :controller => 'messages' do |messages_routes|
39 map.with_options :controller => 'messages' do |messages_routes|
40 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
40 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
41 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
41 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
42 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
42 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
43 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
43 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
44 end
44 end
45 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
45 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
46 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
46 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
47 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
47 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
48 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
48 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
49 end
49 end
50 end
50 end
51
51
52 map.with_options :controller => 'boards' do |board_routes|
52 map.with_options :controller => 'boards' do |board_routes|
53 board_routes.with_options :conditions => {:method => :get} do |board_views|
53 board_routes.with_options :conditions => {:method => :get} do |board_views|
54 board_views.connect 'projects/:project_id/boards', :action => 'index'
54 board_views.connect 'projects/:project_id/boards', :action => 'index'
55 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
55 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
56 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
56 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
57 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
57 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
58 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
58 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
59 end
59 end
60 board_routes.with_options :conditions => {:method => :post} do |board_actions|
60 board_routes.with_options :conditions => {:method => :post} do |board_actions|
61 board_actions.connect 'projects/:project_id/boards', :action => 'new'
61 board_actions.connect 'projects/:project_id/boards', :action => 'new'
62 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
62 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
63 end
63 end
64 end
64 end
65
65
66 map.with_options :controller => 'documents' do |document_routes|
66 map.with_options :controller => 'documents' do |document_routes|
67 document_routes.with_options :conditions => {:method => :get} do |document_views|
67 document_routes.with_options :conditions => {:method => :get} do |document_views|
68 document_views.connect 'projects/:project_id/documents', :action => 'index'
68 document_views.connect 'projects/:project_id/documents', :action => 'index'
69 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
69 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
70 document_views.connect 'documents/:id', :action => 'show'
70 document_views.connect 'documents/:id', :action => 'show'
71 document_views.connect 'documents/:id/edit', :action => 'edit'
71 document_views.connect 'documents/:id/edit', :action => 'edit'
72 end
72 end
73 document_routes.with_options :conditions => {:method => :post} do |document_actions|
73 document_routes.with_options :conditions => {:method => :post} do |document_actions|
74 document_actions.connect 'projects/:project_id/documents', :action => 'new'
74 document_actions.connect 'projects/:project_id/documents', :action => 'new'
75 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
75 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
76 end
76 end
77 end
77 end
78
78
79 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
79 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
80 map.resources :queries, :except => [:show]
80 map.resources :queries, :except => [:show]
81
81
82 # Misc issue routes. TODO: move into resources
82 # Misc issue routes. TODO: move into resources
83 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
83 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
84 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
84 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
85 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
85 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
86 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
86 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
87 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
87 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
88 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
88 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
89 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
89 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
90 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
90 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
91
91
92 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
92 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
93 gantts_routes.connect '/projects/:project_id/issues/gantt'
93 gantts_routes.connect '/projects/:project_id/issues/gantt'
94 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
94 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
95 gantts_routes.connect '/issues/gantt.:format'
95 gantts_routes.connect '/issues/gantt.:format'
96 end
96 end
97
97
98 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
98 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
99 calendars_routes.connect '/projects/:project_id/issues/calendar'
99 calendars_routes.connect '/projects/:project_id/issues/calendar'
100 calendars_routes.connect '/issues/calendar'
100 calendars_routes.connect '/issues/calendar'
101 end
101 end
102
102
103 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
103 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
104 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
104 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
105 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
105 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
106 end
106 end
107
107
108 # Following two routes conflict with the resources because #index allows POST
108 # Following two routes conflict with the resources because #index allows POST
109 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
109 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
110 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
110 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
111
111
112 map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues|
112 map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues|
113 issues.resources :time_entries, :controller => 'timelog'
113 issues.resources :time_entries, :controller => 'timelog'
114 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
114 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
115 end
115 end
116
116
117 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues|
117 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues|
118 issues.resources :time_entries, :controller => 'timelog'
118 issues.resources :time_entries, :controller => 'timelog'
119 end
119 end
120
120
121 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
121 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
122
122
123 map.with_options :controller => 'users' do |users|
123 map.with_options :controller => 'users' do |users|
124 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
124 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
125
125
126 users.with_options :conditions => {:method => :post} do |user_actions|
126 users.with_options :conditions => {:method => :post} do |user_actions|
127 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
127 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
128 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
128 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
129 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
129 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
130 end
130 end
131 end
131 end
132
132
133 map.resources :users, :member => {
133 map.resources :users, :member => {
134 :edit_membership => :post,
134 :edit_membership => :post,
135 :destroy_membership => :post
135 :destroy_membership => :post
136 }
136 }
137
137
138 # For nice "roadmap" in the url for the index action
138 # For nice "roadmap" in the url for the index action
139 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
139 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
140
140
141 map.all_news 'news', :controller => 'news', :action => 'index'
141 map.all_news 'news', :controller => 'news', :action => 'index'
142 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
142 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
143 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
143 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
144 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
144 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
145 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
145 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
146
146
147 map.resources :projects, :member => {
147 map.resources :projects, :member => {
148 :copy => [:get, :post],
148 :copy => [:get, :post],
149 :settings => :get,
149 :settings => :get,
150 :modules => :post,
150 :modules => :post,
151 :archive => :post,
151 :archive => :post,
152 :unarchive => :post
152 :unarchive => :post
153 } do |project|
153 } do |project|
154 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
154 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
155 project.resources :files, :only => [:index, :new, :create]
155 project.resources :files, :only => [:index, :new, :create]
156 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
156 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
157 project.resources :news, :shallow => true
157 project.resources :news, :shallow => true
158 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
158 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
159 project.resources :queries, :only => [:new, :create]
159 project.resources :queries, :only => [:new, :create]
160
160
161 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
161 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
162 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
162 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
163 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
163 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
164 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
164 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
165 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
165 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
166 project.resources :wiki, :except => [:new, :create], :member => {
166 project.resources :wiki, :except => [:new, :create], :member => {
167 :rename => [:get, :post],
167 :rename => [:get, :post],
168 :history => :get,
168 :history => :get,
169 :preview => :any,
169 :preview => :any,
170 :protect => :post,
170 :protect => :post,
171 :add_attachment => :post
171 :add_attachment => :post
172 }, :collection => {
172 }, :collection => {
173 :export => :get,
173 :export => :get,
174 :date_index => :get
174 :date_index => :get
175 }
175 }
176
176
177 end
177 end
178
178
179 # Destroy uses a get request to prompt the user before the actual DELETE request
179 # Destroy uses a get request to prompt the user before the actual DELETE request
180 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
180 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
181
181
182 # TODO: port to be part of the resources route(s)
182 # TODO: port to be part of the resources route(s)
183 map.with_options :controller => 'projects' do |project_mapper|
183 map.with_options :controller => 'projects' do |project_mapper|
184 project_mapper.with_options :conditions => {:method => :get} do |project_views|
184 project_mapper.with_options :conditions => {:method => :get} do |project_views|
185 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
185 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
186 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
186 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
187 end
187 end
188 end
188 end
189
189
190 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
190 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
191 activity.connect 'projects/:id/activity'
191 activity.connect 'projects/:id/activity'
192 activity.connect 'projects/:id/activity.:format'
192 activity.connect 'projects/:id/activity.:format'
193 activity.connect 'activity', :id => nil
193 activity.connect 'activity', :id => nil
194 activity.connect 'activity.:format', :id => nil
194 activity.connect 'activity.:format', :id => nil
195 end
195 end
196
196
197 map.with_options :controller => 'issue_categories' do |categories|
197 map.with_options :controller => 'issue_categories' do |categories|
198 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
198 categories.connect 'projects/:project_id/issue_categories/new', :action => 'new'
199 end
199 end
200
200
201 map.with_options :controller => 'repositories' do |repositories|
201 map.with_options :controller => 'repositories' do |repositories|
202 repositories.with_options :conditions => {:method => :get} do |repository_views|
202 repositories.with_options :conditions => {:method => :get} do |repository_views|
203 repository_views.connect 'projects/:id/repository', :action => 'show'
203 repository_views.connect 'projects/:id/repository', :action => 'show'
204 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
204 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
205 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
205 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
206 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
206 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
207 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
207 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
208 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
208 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
209 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
209 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
210 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
210 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
211 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
211 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
212 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
212 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
213 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
213 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
214 # TODO: why the following route is required?
214 # TODO: why the following route is required?
215 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
215 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
216 repository_views.connect 'projects/:id/repository/:action/*path'
216 repository_views.connect 'projects/:id/repository/:action/*path'
217 end
217 end
218
218
219 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
219 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
220 end
220 end
221
221
222 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
222 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
223 map.connect 'attachments/:id.:format', :controller => 'attachments', :action => 'show', :id => /\d+/
223 map.connect 'attachments/:id.:format', :controller => 'attachments', :action => 'show', :id => /\d+/
224 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
224 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
225 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
225 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
226
226
227 map.resources :groups
227 map.resources :groups
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'
234 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
235 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
235 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
236 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
236 map.connect 'projects/:project_id/news/:action', :controller => 'news'
237 map.connect 'projects/:project_id/news/:action', :controller => 'news'
237 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
238 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
238 map.with_options :controller => 'repositories' do |omap|
239 map.with_options :controller => 'repositories' do |omap|
239 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
240 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
240 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
241 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
241 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
242 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
242 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
243 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
243 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
244 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
244 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
245 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
245 end
246 end
246
247
247 map.with_options :controller => 'sys' do |sys|
248 map.with_options :controller => 'sys' do |sys|
248 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
249 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
249 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
250 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
250 end
251 end
251
252
252 # Install the default route as the lowest priority.
253 # Install the default route as the lowest priority.
253 map.connect ':controller/:action/:id'
254 map.connect ':controller/:action/:id'
254 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
255 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
255 # Used for OpenID
256 # Used for OpenID
256 map.root :controller => 'account', :action => 'login'
257 map.root :controller => 'account', :action => 'login'
257 end
258 end
@@ -1,95 +1,107
1 require File.expand_path('../../test_helper', __FILE__)
1 require File.expand_path('../../test_helper', __FILE__)
2 require 'issue_statuses_controller'
2 require 'issue_statuses_controller'
3
3
4 # Re-raise errors caught by the controller.
4 # Re-raise errors caught by the controller.
5 class IssueStatusesController; def rescue_action(e) raise e end; end
5 class IssueStatusesController; def rescue_action(e) raise e end; end
6
6
7
7
8 class IssueStatusesControllerTest < ActionController::TestCase
8 class IssueStatusesControllerTest < ActionController::TestCase
9 fixtures :issue_statuses, :issues
9 fixtures :issue_statuses, :issues
10
10
11 def setup
11 def setup
12 @controller = IssueStatusesController.new
12 @controller = IssueStatusesController.new
13 @request = ActionController::TestRequest.new
13 @request = ActionController::TestRequest.new
14 @response = ActionController::TestResponse.new
14 @response = ActionController::TestResponse.new
15 User.current = nil
15 User.current = nil
16 @request.session[:user_id] = 1 # admin
16 @request.session[:user_id] = 1 # admin
17 end
17 end
18
18
19 def test_index
19 def test_index
20 get :index
20 get :index
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
27 assert_response :success
39 assert_response :success
28 assert_template 'new'
40 assert_template 'new'
29 end
41 end
30
42
31 def test_create
43 def test_create
32 assert_difference 'IssueStatus.count' do
44 assert_difference 'IssueStatus.count' do
33 post :create, :issue_status => {:name => 'New status'}
45 post :create, :issue_status => {:name => 'New status'}
34 end
46 end
35 assert_redirected_to :action => 'index'
47 assert_redirected_to :action => 'index'
36 status = IssueStatus.find(:first, :order => 'id DESC')
48 status = IssueStatus.find(:first, :order => 'id DESC')
37 assert_equal 'New status', status.name
49 assert_equal 'New status', status.name
38 end
50 end
39
51
40 def test_edit
52 def test_edit
41 get :edit, :id => '3'
53 get :edit, :id => '3'
42 assert_response :success
54 assert_response :success
43 assert_template 'edit'
55 assert_template 'edit'
44 end
56 end
45
57
46 def test_update
58 def test_update
47 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
59 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
48 assert_redirected_to :action => 'index'
60 assert_redirected_to :action => 'index'
49 status = IssueStatus.find(3)
61 status = IssueStatus.find(3)
50 assert_equal 'Renamed status', status.name
62 assert_equal 'Renamed status', status.name
51 end
63 end
52
64
53 def test_destroy
65 def test_destroy
54 Issue.delete_all("status_id = 1")
66 Issue.delete_all("status_id = 1")
55
67
56 assert_difference 'IssueStatus.count', -1 do
68 assert_difference 'IssueStatus.count', -1 do
57 post :destroy, :id => '1'
69 post :destroy, :id => '1'
58 end
70 end
59 assert_redirected_to :action => 'index'
71 assert_redirected_to :action => 'index'
60 assert_nil IssueStatus.find_by_id(1)
72 assert_nil IssueStatus.find_by_id(1)
61 end
73 end
62
74
63 def test_destroy_should_block_if_status_in_use
75 def test_destroy_should_block_if_status_in_use
64 assert_not_nil Issue.find_by_status_id(1)
76 assert_not_nil Issue.find_by_status_id(1)
65
77
66 assert_no_difference 'IssueStatus.count' do
78 assert_no_difference 'IssueStatus.count' do
67 post :destroy, :id => '1'
79 post :destroy, :id => '1'
68 end
80 end
69 assert_redirected_to :action => 'index'
81 assert_redirected_to :action => 'index'
70 assert_not_nil IssueStatus.find_by_id(1)
82 assert_not_nil IssueStatus.find_by_id(1)
71 end
83 end
72
84
73 context "on POST to :update_issue_done_ratio" do
85 context "on POST to :update_issue_done_ratio" do
74 context "with Setting.issue_done_ratio using the issue_field" do
86 context "with Setting.issue_done_ratio using the issue_field" do
75 setup do
87 setup do
76 Setting.issue_done_ratio = 'issue_field'
88 Setting.issue_done_ratio = 'issue_field'
77 post :update_issue_done_ratio
89 post :update_issue_done_ratio
78 end
90 end
79
91
80 should_set_the_flash_to /not updated/
92 should_set_the_flash_to /not updated/
81 should_redirect_to('the index') { '/issue_statuses' }
93 should_redirect_to('the index') { '/issue_statuses' }
82 end
94 end
83
95
84 context "with Setting.issue_done_ratio using the issue_status" do
96 context "with Setting.issue_done_ratio using the issue_status" do
85 setup do
97 setup do
86 Setting.issue_done_ratio = 'issue_status'
98 Setting.issue_done_ratio = 'issue_status'
87 post :update_issue_done_ratio
99 post :update_issue_done_ratio
88 end
100 end
89
101
90 should_set_the_flash_to /Issue done ratios updated/
102 should_set_the_flash_to /Issue done ratios updated/
91 should_redirect_to('the index') { '/issue_statuses' }
103 should_redirect_to('the index') { '/issue_statuses' }
92 end
104 end
93 end
105 end
94
106
95 end
107 end
General Comments 0
You need to be logged in to leave comments. Login now