##// END OF EJS Templates
Refactor: Merged IssueStatusesController#list and #index....
Eric Davis -
r3301:c18f8d34fb3d
parent child
Show More
@@ -21,16 +21,11 class IssueStatusesController < ApplicationController
21 before_filter :require_admin
21 before_filter :require_admin
22
22
23 verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
23 verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
24 :redirect_to => { :action => :list }
24 :redirect_to => { :action => :index }
25
25
26 def index
26 def index
27 list
28 render :action => 'list' unless request.xhr?
29 end
30
31 def list
32 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
27 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
33 render :action => "list", :layout => false if request.xhr?
28 render :action => "index", :layout => false if request.xhr?
34 end
29 end
35
30
36 def new
31 def new
@@ -41,7 +36,7 class IssueStatusesController < ApplicationController
41 @issue_status = IssueStatus.new(params[:issue_status])
36 @issue_status = IssueStatus.new(params[:issue_status])
42 if @issue_status.save
37 if @issue_status.save
43 flash[:notice] = l(:notice_successful_create)
38 flash[:notice] = l(:notice_successful_create)
44 redirect_to :action => 'list'
39 redirect_to :action => 'index'
45 else
40 else
46 render :action => 'new'
41 render :action => 'new'
47 end
42 end
@@ -55,7 +50,7 class IssueStatusesController < ApplicationController
55 @issue_status = IssueStatus.find(params[:id])
50 @issue_status = IssueStatus.find(params[:id])
56 if @issue_status.update_attributes(params[:issue_status])
51 if @issue_status.update_attributes(params[:issue_status])
57 flash[:notice] = l(:notice_successful_update)
52 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'list'
53 redirect_to :action => 'index'
59 else
54 else
60 render :action => 'edit'
55 render :action => 'edit'
61 end
56 end
@@ -63,10 +58,10 class IssueStatusesController < ApplicationController
63
58
64 def destroy
59 def destroy
65 IssueStatus.find(params[:id]).destroy
60 IssueStatus.find(params[:id]).destroy
66 redirect_to :action => 'list'
61 redirect_to :action => 'index'
67 rescue
62 rescue
68 flash[:error] = "Unable to delete issue status"
63 flash[:error] = "Unable to delete issue status"
69 redirect_to :action => 'list'
64 redirect_to :action => 'index'
70 end
65 end
71
66
72 def update_issue_done_ratio
67 def update_issue_done_ratio
@@ -75,6 +70,6 class IssueStatusesController < ApplicationController
75 else
70 else
76 flash[:error] = l(:error_issue_done_ratios_not_updated)
71 flash[:error] = l(:error_issue_done_ratios_not_updated)
77 end
72 end
78 redirect_to :action => 'list'
73 redirect_to :action => 'index'
79 end
74 end
80 end
75 end
1 NO CONTENT: file renamed from app/views/issue_statuses/list.rhtml to app/views/issue_statuses/index.html.erb
NO CONTENT: file renamed from app/views/issue_statuses/list.rhtml to app/views/issue_statuses/index.html.erb
@@ -17,10 +17,9 class IssueStatusesControllerTest < ActionController::TestCase
17 end
17 end
18
18
19 def test_index
19 def test_index
20 # TODO: unify with #list
21 get :index
20 get :index
22 assert_response :success
21 assert_response :success
23 assert_template 'list'
22 assert_template 'index'
24 end
23 end
25
24
26 def test_new
25 def test_new
@@ -33,7 +32,7 class IssueStatusesControllerTest < ActionController::TestCase
33 assert_difference 'IssueStatus.count' do
32 assert_difference 'IssueStatus.count' do
34 post :create, :issue_status => {:name => 'New status'}
33 post :create, :issue_status => {:name => 'New status'}
35 end
34 end
36 assert_redirected_to 'issue_statuses/list'
35 assert_redirected_to :action => 'index'
37 status = IssueStatus.find(:first, :order => 'id DESC')
36 status = IssueStatus.find(:first, :order => 'id DESC')
38 assert_equal 'New status', status.name
37 assert_equal 'New status', status.name
39 end
38 end
@@ -46,7 +45,7 class IssueStatusesControllerTest < ActionController::TestCase
46
45
47 def test_update
46 def test_update
48 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
47 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
49 assert_redirected_to 'issue_statuses/list'
48 assert_redirected_to :action => 'index'
50 status = IssueStatus.find(3)
49 status = IssueStatus.find(3)
51 assert_equal 'Renamed status', status.name
50 assert_equal 'Renamed status', status.name
52 end
51 end
@@ -57,7 +56,7 class IssueStatusesControllerTest < ActionController::TestCase
57 assert_difference 'IssueStatus.count', -1 do
56 assert_difference 'IssueStatus.count', -1 do
58 post :destroy, :id => '1'
57 post :destroy, :id => '1'
59 end
58 end
60 assert_redirected_to 'issue_statuses/list'
59 assert_redirected_to :action => 'index'
61 assert_nil IssueStatus.find_by_id(1)
60 assert_nil IssueStatus.find_by_id(1)
62 end
61 end
63
62
@@ -67,7 +66,7 class IssueStatusesControllerTest < ActionController::TestCase
67 assert_no_difference 'IssueStatus.count' do
66 assert_no_difference 'IssueStatus.count' do
68 post :destroy, :id => '1'
67 post :destroy, :id => '1'
69 end
68 end
70 assert_redirected_to 'issue_statuses/list'
69 assert_redirected_to :action => 'index'
71 assert_not_nil IssueStatus.find_by_id(1)
70 assert_not_nil IssueStatus.find_by_id(1)
72 end
71 end
73
72
@@ -79,7 +78,7 class IssueStatusesControllerTest < ActionController::TestCase
79 end
78 end
80
79
81 should_set_the_flash_to /not updated/
80 should_set_the_flash_to /not updated/
82 should_redirect_to('the list') { '/issue_statuses/list' }
81 should_redirect_to('the index') { '/issue_statuses' }
83 end
82 end
84
83
85 context "with Setting.issue_done_ratio using the issue_status" do
84 context "with Setting.issue_done_ratio using the issue_status" do
@@ -89,7 +88,7 class IssueStatusesControllerTest < ActionController::TestCase
89 end
88 end
90
89
91 should_set_the_flash_to /Issue done ratios updated/
90 should_set_the_flash_to /Issue done ratios updated/
92 should_redirect_to('the list') { '/issue_statuses/list' }
91 should_redirect_to('the index') { '/issue_statuses' }
93 end
92 end
94 end
93 end
95
94
General Comments 0
You need to be logged in to leave comments. Login now