##// END OF EJS Templates
Refactor: convert many of the custom Issue routes to REST resources....
Eric Davis -
r3927:56e984b5e740
parent child
Show More
@@ -32,8 +32,11 class CalendarsController < ApplicationController
32 @calendar.events = events
32 @calendar.events = events
33 end
33 end
34
34
35 render :layout => false if request.xhr?
35 render :action => 'show', :layout => false if request.xhr?
36 end
36 end
37
37
38 def update
39 show
40 end
38
41
39 end
42 end
@@ -43,4 +43,8 class GanttsController < ApplicationController
43 end
43 end
44 end
44 end
45
45
46 def update
47 show
48 end
49
46 end
50 end
@@ -1,6 +1,7
1 <h2><%= l(:label_calendar) %></h2>
1 <h2><%= l(:label_calendar) %></h2>
2
2
3 <% form_tag({}, :id => 'query_form') do %>
3 <% form_tag(calendar_path, :method => :put, :id => 'query_form') do %>
4 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
4 <fieldset id="filters" class="collapsible">
5 <fieldset id="filters" class="collapsible">
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <div>
7 <div>
@@ -1,6 +1,7
1 <h2><%= l(:label_gantt) %></h2>
1 <h2><%= l(:label_gantt) %></h2>
2
2
3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
3 <% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
4 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
4 <fieldset id="filters" class="collapsible">
5 <fieldset id="filters" class="collapsible">
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <div>
7 <div>
@@ -104,58 +104,39 ActionController::Routing::Routes.draw do |map|
104 end
104 end
105
105
106 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
106 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
107
108 # Misc issue routes. TODO: move into resources
107 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
109 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
108 # TODO: would look nicer as /issues/:id/preview
110 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
109 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue'
110 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
111 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
111 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
112 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
112
113 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
113 map.with_options :controller => 'issues' do |issues_routes|
114 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
114 issues_routes.with_options :conditions => {:method => :get} do |issues_views|
115 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
115 issues_views.connect 'issues', :action => 'index'
116 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
116 issues_views.connect 'issues.:format', :action => 'index'
117
117 issues_views.connect 'projects/:project_id/issues', :action => 'index'
118 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
118 issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
119 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
119 issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
120 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
120 issues_views.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
121 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
121 issues_views.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
122
122 issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
123 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
123 issues_views.connect 'issues/:id', :action => 'show', :id => /\d+/
124 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
124 issues_views.connect 'issues/:id.:format', :action => 'show', :id => /\d+/
125 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
125 issues_views.connect 'issues/:id/edit', :action => 'edit', :id => /\d+/
126 end
127 issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
128 issues_actions.connect 'issues', :action => 'index'
129 issues_actions.connect 'projects/:project_id/issues', :action => 'create'
130 issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
131 issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
132 issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/
133 issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/
134 issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
135 issues_actions.connect 'issues/bulk_edit', :action => 'bulk_update'
136 end
137 issues_routes.with_options :conditions => {:method => :put} do |issues_actions|
138 issues_actions.connect 'issues/:id/edit', :action => 'update', :id => /\d+/
139 issues_actions.connect 'issues/:id.:format', :action => 'update', :id => /\d+/, :format => /xml/
140 end
141 issues_routes.with_options :conditions => {:method => :delete} do |issues_actions|
142 issues_actions.connect 'issues/:id.:format', :action => 'destroy', :id => /\d+/, :format => /xml/
143 end
144 issues_routes.connect 'issues/gantt', :controller => 'gantts', :action => 'show'
145 issues_routes.connect 'issues/calendar', :controller => 'calendars', :action => 'show'
146 issues_routes.connect 'issues/:action'
147 end
126 end
148
127
128 # Following two routes conflict with the resources because #index allows POST
129 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
130 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
131
132 map.resources :issues, :member => { :edit => :post }, :collection => {}
133 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post }
134
149 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
135 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
150 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
136 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
151 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
137 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
152 end
138 end
153
139
154 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
155 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
156 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
157 end
158
159 map.with_options :controller => 'news' do |news_routes|
140 map.with_options :controller => 'news' do |news_routes|
160 news_routes.with_options :conditions => {:method => :get} do |news_views|
141 news_routes.with_options :conditions => {:method => :get} do |news_views|
161 news_views.connect 'news', :action => 'index'
142 news_views.connect 'news', :action => 'index'
@@ -203,6 +184,7 ActionController::Routing::Routes.draw do |map|
203 project_views.connect 'projects/:id/files', :action => 'list_files'
184 project_views.connect 'projects/:id/files', :action => 'list_files'
204 project_views.connect 'projects/:id/files/new', :action => 'add_file'
185 project_views.connect 'projects/:id/files/new', :action => 'add_file'
205 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
186 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
187 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
206 end
188 end
207
189
208 projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
190 projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
@@ -137,11 +137,11 Redmine::AccessControl.map do |map|
137 end
137 end
138
138
139 map.project_module :calendar do |map|
139 map.project_module :calendar do |map|
140 map.permission :view_calendar, :calendars => :show
140 map.permission :view_calendar, :calendars => [:show, :update]
141 end
141 end
142
142
143 map.project_module :gantt do |map|
143 map.project_module :gantt do |map|
144 map.permission :view_gantt, :gantts => :show
144 map.permission :view_gantt, :gantts => [:show, :update]
145 end
145 end
146 end
146 end
147
147
@@ -12,7 +12,7 class ContextMenusControllerTest < ActionController::TestCase
12 :attributes => { :href => '/issues/1/edit',
12 :attributes => { :href => '/issues/1/edit',
13 :class => 'icon-edit' }
13 :class => 'icon-edit' }
14 assert_tag :tag => 'a', :content => 'Closed',
14 assert_tag :tag => 'a', :content => 'Closed',
15 :attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
15 :attributes => { :href => '/issues/1?issue%5Bstatus_id%5D=5',
16 :class => '' }
16 :class => '' }
17 assert_tag :tag => 'a', :content => 'Immediate',
17 assert_tag :tag => 'a', :content => 'Immediate',
18 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;issue%5Bpriority_id%5D=8',
18 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;issue%5Bpriority_id%5D=8',
@@ -69,7 +69,7 class IssuesTest < ActionController::IntegrationTest
69 log_user('jsmith', 'jsmith')
69 log_user('jsmith', 'jsmith')
70 set_tmp_attachments_directory
70 set_tmp_attachments_directory
71
71
72 put 'issues/1/edit',
72 put 'issues/1',
73 :notes => 'Some notes',
73 :notes => 'Some notes',
74 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
74 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
75 assert_redirected_to "issues/1"
75 assert_redirected_to "issues/1"
@@ -91,14 +91,14 class RoutingTest < ActionController::IntegrationTest
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
92
92
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 should_route :post, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
97
97
98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 should_route :post, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 should_route :post, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
102
102
103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104
104
General Comments 0
You need to be logged in to leave comments. Login now