before_filter :require_admin_or_api_request, :only => :index
accept_api_auth :index
- verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
- :redirect_to => { :action => :index }
-
def index
respond_to do |format|
format.html {
def create
@issue_status = IssueStatus.new(params[:issue_status])
- if @issue_status.save
+ if request.post? && @issue_status.save
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index'
else
def update
@issue_status = IssueStatus.find(params[:id])
- if @issue_status.update_attributes(params[:issue_status])
+ if request.put? && @issue_status.update_attributes(params[:issue_status])
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index'
else
end
end
+ verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
def destroy
IssueStatus.find(params[:id]).destroy
redirect_to :action => 'index'
end
def update_issue_done_ratio
- if IssueStatus.update_issue_done_ratios
+ if request.post? && IssueStatus.update_issue_done_ratios
flash[:notice] = l(:notice_issue_done_ratios_updated)
else
flash[:error] = l(:error_issue_done_ratios_not_updated)
<%= error_messages_for 'issue_status' %>
-<div class="box">
-<!--[form:issue_status]-->
-<p><label for="issue_status_name"><%=l(:field_name)%><span class="required"> *</span></label>
-<%= text_field 'issue_status', 'name' %></p>
-
+<div class="box tabular">
+<p><%= f.text_field :name, :required => true %></p>
<% if Issue.use_status_for_done_ratio? %>
-<p><label for="issue_done_ratio"><%=l(:field_done_ratio)%></label>
-<%= select 'issue_status', :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true %></p>
+ <p><%= f.select :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true, :label => :field_done_ratio %></p>
<% end %>
-
-<p><label for="issue_status_is_closed"><%=l(:field_is_closed)%></label>
-<%= check_box 'issue_status', 'is_closed' %></p>
-
-<p><label for="issue_status_is_default"><%=l(:field_is_default)%></label>
-<%= check_box 'issue_status', 'is_default' %></p>
+<p><%= f.check_box :is_closed %></p>
+<p><%= f.check_box :is_default %></p>
<%= call_hook(:view_issue_statuses_form, :issue_status => @issue_status) %>
-
-<!--[eoform:issue_status]-->
</div>
-<h2><%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses', :action => 'index' %> » <%=h @issue_status %></h2>
+<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> » <%=h @issue_status %></h2>
-<% form_tag({:action => 'update', :id => @issue_status}, :class => "tabular") do %>
- <%= render :partial => 'form' %>
+<% form_for @issue_status, :builder => TabularFormBuilder do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_save) %>
<% end %>
<div class="contextual">
-<%= link_to l(:label_issue_status_new), {:action => 'new'}, :class => 'icon icon-add' %>
-<%= link_to(l(:label_update_issue_done_ratios), {:action => 'update_issue_done_ratio'}, :class => 'icon icon-multiple', :method => 'post', :confirm => l(:text_are_you_sure)) if Issue.use_status_for_done_ratio? %>
+<%= link_to l(:label_issue_status_new), new_issue_status_path, :class => 'icon icon-add' %>
+<%= link_to(l(:label_update_issue_done_ratios), update_issue_done_ratio_issue_statuses_path, :class => 'icon icon-multiple', :method => 'post', :confirm => l(:text_are_you_sure)) if Issue.use_status_for_done_ratio? %>
</div>
<h2><%=l(:label_issue_status_plural)%></h2>
<tbody>
<% for status in @issue_statuses %>
<tr class="<%= cycle("odd", "even") %>">
- <td><%= link_to h(status.name), :action => 'edit', :id => status %></td>
+ <td><%= link_to h(status.name), edit_issue_status_path(status) %></td>
<% if Issue.use_status_for_done_ratio? %>
<td align="center"><%= h status.default_done_ratio %></td>
<% end %>
<td align="center"><%= checked_image status.is_default? %></td>
<td align="center"><%= checked_image status.is_closed? %></td>
- <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
+ <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}, :put) %></td>
<td class="buttons">
- <%= link_to(l(:button_delete), { :action => 'destroy', :id => status },
- :method => :post,
+ <%= link_to(l(:button_delete), issue_status_path(status),
+ :method => :delete,
:confirm => l(:text_are_you_sure),
:class => 'icon icon-del') %>
</td>
-<h2><%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses', :action => 'index' %> » <%=l(:label_issue_status_new)%></h2>
+<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> » <%=l(:label_issue_status_new)%></h2>
-<% form_tag({:action => 'create'}, :class => "tabular") do %>
- <%= render :partial => 'form' %>
+<% form_for @issue_status, :builder => TabularFormBuilder do |f| %>
+ <%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
<% end %>
map.resources :groups
map.resources :trackers, :except => :show
+ map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
#left old routes at the bottom for backwards compat
- map.connect 'issue_statuses.:format', :controller => 'issue_statuses', :action => 'index'
map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
end
def test_update
- post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
+ put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
assert_redirected_to :action => 'index'
status = IssueStatus.find(3)
assert_equal 'Renamed status', status.name
Issue.delete_all("status_id = 1")
assert_difference 'IssueStatus.count', -1 do
- post :destroy, :id => '1'
+ delete :destroy, :id => '1'
end
assert_redirected_to :action => 'index'
assert_nil IssueStatus.find_by_id(1)
assert_not_nil Issue.find_by_status_id(1)
assert_no_difference 'IssueStatus.count' do
- post :destroy, :id => '1'
+ delete :destroy, :id => '1'
end
assert_redirected_to :action => 'index'
assert_not_nil IssueStatus.find_by_id(1)