Commit 2b0420faf2e20fa59d0a5e16b6d6340dab53ed27
Committed by
Victor Costa
1 parent
23a10a5f
Exists in
tasks_keep_filter_params
Added new method that keep all params filters after perform a task
Showing
2 changed files
with
23 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
@@ -65,7 +65,7 @@ class TasksController < MyProfileController | @@ -65,7 +65,7 @@ class TasksController < MyProfileController | ||
65 | session[:notice] = _("Some decisions couldn't be applied.") | 65 | session[:notice] = _("Some decisions couldn't be applied.") |
66 | url[:failed] = failed | 66 | url[:failed] = failed |
67 | end | 67 | end |
68 | - redirect_to url | 68 | + redirect_with_filters url |
69 | end | 69 | end |
70 | 70 | ||
71 | def new | 71 | def new |
@@ -76,7 +76,8 @@ class TasksController < MyProfileController | @@ -76,7 +76,8 @@ class TasksController < MyProfileController | ||
76 | @ticket.requestor = profile | 76 | @ticket.requestor = profile |
77 | if request.post? | 77 | if request.post? |
78 | if @ticket.save | 78 | if @ticket.save |
79 | - redirect_to :action => 'index' | 79 | + url = {:action => 'index'} |
80 | + redirect_to url | ||
80 | end | 81 | end |
81 | end | 82 | end |
82 | end | 83 | end |
@@ -89,4 +90,11 @@ class TasksController < MyProfileController | @@ -89,4 +90,11 @@ class TasksController < MyProfileController | ||
89 | @ticket = Ticket.find(:first, :conditions => ['(requestor_id = ? or target_id = ?) and id = ?', profile.id, profile.id, params[:id]]) | 90 | @ticket = Ticket.find(:first, :conditions => ['(requestor_id = ? or target_id = ?) and id = ?', profile.id, profile.id, params[:id]]) |
90 | end | 91 | end |
91 | 92 | ||
93 | + protected | ||
94 | + | ||
95 | + def redirect_with_filters(url_data) | ||
96 | + | ||
97 | + filter_params = params.select {|p| p =~ /filter_/} | ||
98 | + redirect_to url_data.merge(filter_params) | ||
99 | + end | ||
92 | end | 100 | end |
test/functional/tasks_controller_test.rb
@@ -76,6 +76,17 @@ class TasksControllerTest < ActionController::TestCase | @@ -76,6 +76,17 @@ class TasksControllerTest < ActionController::TestCase | ||
76 | ok('task should be finished') { t.status == Task::Status::FINISHED } | 76 | ok('task should be finished') { t.status == Task::Status::FINISHED } |
77 | end | 77 | end |
78 | 78 | ||
79 | + should 'keep filters after close a task' do | ||
80 | + t = profile.tasks.build; t.save! | ||
81 | + | ||
82 | + post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}}, :filter_type => t.type | ||
83 | + assert_redirected_to :action => 'index', :filter_type => t.type | ||
84 | + assert_equal @controller.params[:filter_type], t.type | ||
85 | + | ||
86 | + t.reload | ||
87 | + ok('task should be finished') { t.status == Task::Status::FINISHED } | ||
88 | + end | ||
89 | + | ||
79 | should 'be able to cancel a task' do | 90 | should 'be able to cancel a task' do |
80 | t = profile.tasks.build; t.save! | 91 | t = profile.tasks.build; t.save! |
81 | 92 | ||
@@ -149,7 +160,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -149,7 +160,7 @@ class TasksControllerTest < ActionController::TestCase | ||
149 | 160 | ||
150 | should 'create a ticket with profile requestor' do | 161 | should 'create a ticket with profile requestor' do |
151 | post :new, :profile => profile.identifier, :ticket => {:name => 'new task'} | 162 | post :new, :profile => profile.identifier, :ticket => {:name => 'new task'} |
152 | - | 163 | + |
153 | assert_equal profile, assigns(:ticket).requestor | 164 | assert_equal profile, assigns(:ticket).requestor |
154 | end | 165 | end |
155 | 166 | ||
@@ -628,7 +639,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -628,7 +639,7 @@ class TasksControllerTest < ActionController::TestCase | ||
628 | 639 | ||
629 | assert_select ".task_responsible select", 0 | 640 | assert_select ".task_responsible select", 0 |
630 | assert_select ".task_responsible .value" | 641 | assert_select ".task_responsible .value" |
631 | - end | 642 | + end |
632 | 643 | ||
633 | should 'store the person who closes a task' do | 644 | should 'store the person who closes a task' do |
634 | t = profile.tasks.build; t.save! | 645 | t = profile.tasks.build; t.save! |