Project

General

Profile

Defect #21579 » rm_21579_fix_cancel_edit_link_for_issues.patch

Marius BĂLTEANU, 2017-02-19 14:24

View differences:

app/views/issues/_edit.html.erb
69 69
    <%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %>
70 70
    <%= submit_tag l(:button_submit) %>
71 71
    <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %>
72
    | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %>
72
    | <%= link_to l(:button_cancel), issue_path(id: @issue.id), :onclick => params[:action] == 'show' ? "$('#update').hide(); return false;" : '' %>
73 73

  
74 74
    <%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %>
75 75
    <%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %>
test/functional/issues_controller_test.rb
4852 4852
    User.add_to_project(user, Project.find(2), Role.find_by_name('Manager'))
4853 4853
    user
4854 4854
  end
4855

  
4856
  def test_cancel_edit_link_for_issue_show_action_should_have_onclick_action
4857
    @request.session[:user_id] = 1
4858

  
4859
    get :show, :id => 1
4860
    assert_response :success
4861
    assert_select 'a[href=?][onclick=?]', "/issues/1", "$('#update').hide(); return false;", :text => 'Cancel'
4862
  end
4863

  
4864
  def test_cancel_edit_link_for_issue_edit_action_should_not_have_onclick_action
4865
    @request.session[:user_id] = 1
4866

  
4867
    get :edit, :id => 1
4868
    assert_response :success
4869
    assert_select 'a[href=?][onclick=?]', "/issues/1", "", :text => 'Cancel'
4870
  end
4855 4871
end
    (1-1/1)