@@ -191,7 +191,7 class IssuesController < ApplicationController | |||||
191 | flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
|
191 | flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? | |
192 |
|
192 | |||
193 | respond_to do |format| |
|
193 | respond_to do |format| | |
194 | format.html { redirect_back_or_default issue_path(@issue) } |
|
194 | format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) } | |
195 | format.api { render_api_ok } |
|
195 | format.api { render_api_ok } | |
196 | end |
|
196 | end | |
197 | else |
|
197 | else | |
@@ -354,6 +354,12 class IssuesController < ApplicationController | |||||
354 | private |
|
354 | private | |
355 |
|
355 | |||
356 | def retrieve_previous_and_next_issue_ids |
|
356 | def retrieve_previous_and_next_issue_ids | |
|
357 | if params[:prev_issue_id].present? || params[:next_issue_id].present? | |||
|
358 | @prev_issue_id = params[:prev_issue_id].presence.try(:to_i) | |||
|
359 | @next_issue_id = params[:next_issue_id].presence.try(:to_i) | |||
|
360 | @issue_position = params[:issue_position].presence.try(:to_i) | |||
|
361 | @issue_count = params[:issue_count].presence.try(:to_i) | |||
|
362 | else | |||
357 | retrieve_query_from_session |
|
363 | retrieve_query_from_session | |
358 | if @query |
|
364 | if @query | |
359 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
|
365 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) | |
@@ -370,6 +376,16 class IssuesController < ApplicationController | |||||
370 | end |
|
376 | end | |
371 | end |
|
377 | end | |
372 | end |
|
378 | end | |
|
379 | end | |||
|
380 | ||||
|
381 | def previous_and_next_issue_ids_params | |||
|
382 | { | |||
|
383 | :prev_issue_id => params[:prev_issue_id], | |||
|
384 | :next_issue_id => params[:next_issue_id], | |||
|
385 | :issue_position => params[:issue_position], | |||
|
386 | :issue_count => params[:issue_count] | |||
|
387 | }.reject {|k,v| k.blank?} | |||
|
388 | end | |||
373 |
|
389 | |||
374 | # Used by #edit and #update to set some common instance variables |
|
390 | # Used by #edit and #update to set some common instance variables | |
375 | # from the params |
|
391 | # from the params |
@@ -49,6 +49,11 | |||||
49 | <%= submit_tag l(:button_submit) %> |
|
49 | <%= submit_tag l(:button_submit) %> | |
50 | <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> |
|
50 | <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> | |
51 | | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %> |
|
51 | | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %> | |
|
52 | ||||
|
53 | <%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %> | |||
|
54 | <%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %> | |||
|
55 | <%= hidden_field_tag 'issue_position', @issue_position if @issue_position %> | |||
|
56 | <%= hidden_field_tag 'issue_count', @issue_count if @issue_count %> | |||
52 | <% end %> |
|
57 | <% end %> | |
53 |
|
58 | |||
54 | <div id="preview" class="wiki"></div> |
|
59 | <div id="preview" class="wiki"></div> |
@@ -1423,6 +1423,17 class IssuesControllerTest < ActionController::TestCase | |||||
1423 | end |
|
1423 | end | |
1424 | end |
|
1424 | end | |
1425 |
|
1425 | |||
|
1426 | def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params | |||
|
1427 | get :show, :id => 1, :prev_issue_id => 1, :next_issue_id => 3, :issue_position => 2, :issue_count => 4 | |||
|
1428 | assert_response :success | |||
|
1429 | ||||
|
1430 | assert_select 'div.next-prev-links' do | |||
|
1431 | assert_select 'a[href="/issues/1"]', :text => /Previous/ | |||
|
1432 | assert_select 'a[href="/issues/3"]', :text => /Next/ | |||
|
1433 | assert_select 'span.position', :text => "2 of 4" | |||
|
1434 | end | |||
|
1435 | end | |||
|
1436 | ||||
1426 | def test_show_should_display_category_field_if_categories_are_defined |
|
1437 | def test_show_should_display_category_field_if_categories_are_defined | |
1427 | Issue.update_all :category_id => nil |
|
1438 | Issue.update_all :category_id => nil | |
1428 |
|
1439 | |||
@@ -3682,6 +3693,19 class IssuesControllerTest < ActionController::TestCase | |||||
3682 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id |
|
3693 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id | |
3683 | end |
|
3694 | end | |
3684 |
|
3695 | |||
|
3696 | def test_put_update_should_redirect_with_previous_and_next_issue_ids_params | |||
|
3697 | @request.session[:user_id] = 2 | |||
|
3698 | ||||
|
3699 | put :update, :id => 11, | |||
|
3700 | :issue => {:status_id => 6, :notes => 'Notes'}, | |||
|
3701 | :prev_issue_id => 8, | |||
|
3702 | :next_issue_id => 12, | |||
|
3703 | :issue_position => 2, | |||
|
3704 | :issue_count => 3 | |||
|
3705 | ||||
|
3706 | assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8' | |||
|
3707 | end | |||
|
3708 | ||||
3685 | def test_get_bulk_edit |
|
3709 | def test_get_bulk_edit | |
3686 | @request.session[:user_id] = 2 |
|
3710 | @request.session[:user_id] = 2 | |
3687 | get :bulk_edit, :ids => [1, 3] |
|
3711 | get :bulk_edit, :ids => [1, 3] |
General Comments 0
You need to be logged in to leave comments.
Login now