##// 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 21 before_filter :require_admin
22 22
23 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 26 def index
27 list
28 render :action => 'list' unless request.xhr?
29 end
30
31 def list
32 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 29 end
35 30
36 31 def new
@@ -41,7 +36,7 class IssueStatusesController < ApplicationController
41 36 @issue_status = IssueStatus.new(params[:issue_status])
42 37 if @issue_status.save
43 38 flash[:notice] = l(:notice_successful_create)
44 redirect_to :action => 'list'
39 redirect_to :action => 'index'
45 40 else
46 41 render :action => 'new'
47 42 end
@@ -55,7 +50,7 class IssueStatusesController < ApplicationController
55 50 @issue_status = IssueStatus.find(params[:id])
56 51 if @issue_status.update_attributes(params[:issue_status])
57 52 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'list'
53 redirect_to :action => 'index'
59 54 else
60 55 render :action => 'edit'
61 56 end
@@ -63,10 +58,10 class IssueStatusesController < ApplicationController
63 58
64 59 def destroy
65 60 IssueStatus.find(params[:id]).destroy
66 redirect_to :action => 'list'
61 redirect_to :action => 'index'
67 62 rescue
68 63 flash[:error] = "Unable to delete issue status"
69 redirect_to :action => 'list'
64 redirect_to :action => 'index'
70 65 end
71 66
72 67 def update_issue_done_ratio
@@ -75,6 +70,6 class IssueStatusesController < ApplicationController
75 70 else
76 71 flash[:error] = l(:error_issue_done_ratios_not_updated)
77 72 end
78 redirect_to :action => 'list'
73 redirect_to :action => 'index'
79 74 end
80 75 end
1 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 17 end
18 18
19 19 def test_index
20 # TODO: unify with #list
21 20 get :index
22 21 assert_response :success
23 assert_template 'list'
22 assert_template 'index'
24 23 end
25 24
26 25 def test_new
@@ -33,7 +32,7 class IssueStatusesControllerTest < ActionController::TestCase
33 32 assert_difference 'IssueStatus.count' do
34 33 post :create, :issue_status => {:name => 'New status'}
35 34 end
36 assert_redirected_to 'issue_statuses/list'
35 assert_redirected_to :action => 'index'
37 36 status = IssueStatus.find(:first, :order => 'id DESC')
38 37 assert_equal 'New status', status.name
39 38 end
@@ -46,7 +45,7 class IssueStatusesControllerTest < ActionController::TestCase
46 45
47 46 def test_update
48 47 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
49 assert_redirected_to 'issue_statuses/list'
48 assert_redirected_to :action => 'index'
50 49 status = IssueStatus.find(3)
51 50 assert_equal 'Renamed status', status.name
52 51 end
@@ -57,7 +56,7 class IssueStatusesControllerTest < ActionController::TestCase
57 56 assert_difference 'IssueStatus.count', -1 do
58 57 post :destroy, :id => '1'
59 58 end
60 assert_redirected_to 'issue_statuses/list'
59 assert_redirected_to :action => 'index'
61 60 assert_nil IssueStatus.find_by_id(1)
62 61 end
63 62
@@ -67,7 +66,7 class IssueStatusesControllerTest < ActionController::TestCase
67 66 assert_no_difference 'IssueStatus.count' do
68 67 post :destroy, :id => '1'
69 68 end
70 assert_redirected_to 'issue_statuses/list'
69 assert_redirected_to :action => 'index'
71 70 assert_not_nil IssueStatus.find_by_id(1)
72 71 end
73 72
@@ -79,7 +78,7 class IssueStatusesControllerTest < ActionController::TestCase
79 78 end
80 79
81 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 82 end
84 83
85 84 context "with Setting.issue_done_ratio using the issue_status" do
@@ -89,7 +88,7 class IssueStatusesControllerTest < ActionController::TestCase
89 88 end
90 89
91 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 92 end
94 93 end
95 94
General Comments 0
You need to be logged in to leave comments. Login now