Refactor: Merged IssueStatusesController#list and #index.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3415 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6ed690eacc
commit
c18f8d34fb
|
@ -21,16 +21,11 @@ class IssueStatusesController < ApplicationController
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
|
verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
|
||||||
:redirect_to => { :action => :list }
|
:redirect_to => { :action => :index }
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
|
||||||
render :action => 'list' unless request.xhr?
|
|
||||||
end
|
|
||||||
|
|
||||||
def list
|
|
||||||
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
|
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
|
||||||
render :action => "list", :layout => false if request.xhr?
|
render :action => "index", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -41,7 +36,7 @@ class IssueStatusesController < ApplicationController
|
||||||
@issue_status = IssueStatus.new(params[:issue_status])
|
@issue_status = IssueStatus.new(params[:issue_status])
|
||||||
if @issue_status.save
|
if @issue_status.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'index'
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
|
@ -55,7 +50,7 @@ class IssueStatusesController < ApplicationController
|
||||||
@issue_status = IssueStatus.find(params[:id])
|
@issue_status = IssueStatus.find(params[:id])
|
||||||
if @issue_status.update_attributes(params[:issue_status])
|
if @issue_status.update_attributes(params[:issue_status])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'index'
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
|
@ -63,10 +58,10 @@ class IssueStatusesController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
IssueStatus.find(params[:id]).destroy
|
IssueStatus.find(params[:id]).destroy
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'index'
|
||||||
rescue
|
rescue
|
||||||
flash[:error] = "Unable to delete issue status"
|
flash[:error] = "Unable to delete issue status"
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_issue_done_ratio
|
def update_issue_done_ratio
|
||||||
|
@ -75,6 +70,6 @@ class IssueStatusesController < ApplicationController
|
||||||
else
|
else
|
||||||
flash[:error] = l(:error_issue_done_ratios_not_updated)
|
flash[:error] = l(:error_issue_done_ratios_not_updated)
|
||||||
end
|
end
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,10 +17,9 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
# TODO: unify with #list
|
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'list'
|
assert_template 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new
|
def test_new
|
||||||
|
@ -33,7 +32,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
assert_difference 'IssueStatus.count' do
|
assert_difference 'IssueStatus.count' do
|
||||||
post :create, :issue_status => {:name => 'New status'}
|
post :create, :issue_status => {:name => 'New status'}
|
||||||
end
|
end
|
||||||
assert_redirected_to 'issue_statuses/list'
|
assert_redirected_to :action => 'index'
|
||||||
status = IssueStatus.find(:first, :order => 'id DESC')
|
status = IssueStatus.find(:first, :order => 'id DESC')
|
||||||
assert_equal 'New status', status.name
|
assert_equal 'New status', status.name
|
||||||
end
|
end
|
||||||
|
@ -46,7 +45,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_update
|
def test_update
|
||||||
post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
|
post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
|
||||||
assert_redirected_to 'issue_statuses/list'
|
assert_redirected_to :action => 'index'
|
||||||
status = IssueStatus.find(3)
|
status = IssueStatus.find(3)
|
||||||
assert_equal 'Renamed status', status.name
|
assert_equal 'Renamed status', status.name
|
||||||
end
|
end
|
||||||
|
@ -57,7 +56,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
assert_difference 'IssueStatus.count', -1 do
|
assert_difference 'IssueStatus.count', -1 do
|
||||||
post :destroy, :id => '1'
|
post :destroy, :id => '1'
|
||||||
end
|
end
|
||||||
assert_redirected_to 'issue_statuses/list'
|
assert_redirected_to :action => 'index'
|
||||||
assert_nil IssueStatus.find_by_id(1)
|
assert_nil IssueStatus.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
assert_no_difference 'IssueStatus.count' do
|
assert_no_difference 'IssueStatus.count' do
|
||||||
post :destroy, :id => '1'
|
post :destroy, :id => '1'
|
||||||
end
|
end
|
||||||
assert_redirected_to 'issue_statuses/list'
|
assert_redirected_to :action => 'index'
|
||||||
assert_not_nil IssueStatus.find_by_id(1)
|
assert_not_nil IssueStatus.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should_set_the_flash_to /not updated/
|
should_set_the_flash_to /not updated/
|
||||||
should_redirect_to('the list') { '/issue_statuses/list' }
|
should_redirect_to('the index') { '/issue_statuses' }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with Setting.issue_done_ratio using the issue_status" do
|
context "with Setting.issue_done_ratio using the issue_status" do
|
||||||
|
@ -89,7 +88,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should_set_the_flash_to /Issue done ratios updated/
|
should_set_the_flash_to /Issue done ratios updated/
|
||||||
should_redirect_to('the list') { '/issue_statuses/list' }
|
should_redirect_to('the index') { '/issue_statuses' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue