Project

General

Profile

Defect #34641 » 0002-Update-log-time-and-add-notes-blocks-when-updating-t.patch

Marius BĂLTEANU, 2021-02-24 19:53

View differences:

app/views/issues/_edit.html.erb
9 9
        </div>
10 10
        </fieldset>
11 11
    <% end %>
12
    <% if User.current.allowed_to?(:log_time, @project) %>
13
        <fieldset class="tabular"><legend><%= l(:button_log_time) %></legend>
12
    <% if User.current.allowed_to?(:log_time, @issue.project) %>
13
        <fieldset class="tabular" id="log_time"><legend><%= l(:button_log_time) %></legend>
14 14
        <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
15 15
        <div class="splitcontent">
16 16
        <div class="splitcontentleft">
......
28 28
    </fieldset>
29 29
    <% end %>
30 30
    <% if @issue.notes_addable? %>
31
      <fieldset><legend><%= l(:field_notes) %></legend>
31
      <fieldset id="add_notes"><legend><%= l(:field_notes) %></legend>
32 32
      <%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
33 33
            :data => {
34 34
                :auto_complete => true
......
43 43
      <%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
44 44
      </fieldset>
45 45

  
46
      <fieldset><legend><%= l(:label_attachment_plural) %></legend>
46
      <fieldset id="add_attachments"'><legend><%= l(:label_attachment_plural) %></legend>
47 47
        <% if @issue.attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %>
48 48
        <div class="contextual"><%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %></div>
49 49
        <div id="existing-attachments" style="<%= @issue.deleted_attachment_ids.blank? ? 'display:none;' : '' %>">
app/views/issues/edit.js.erb
1
replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
2

  
3
<% if User.current.allowed_to?(:log_time, @issue.project) %>
4
  $('#log_time').show();
5
<% else %>
6
  $('#log_time').hide();
7
<% end %>
1
replaceIssueFormWith('<%= escape_javascript(render :partial => 'edit') %>');
public/javascripts/application.js
585 585
      replacement.find('#'+object_id).val($(this).val());
586 586
    }
587 587
  });
588
  $('#all_attributes').empty();
589
  $('#all_attributes').prepend(replacement);
588

  
589
  if ($('form.new_issue').length > 0) {
590
    $('#all_attributes').empty();
591
    $('#all_attributes').prepend(replacement);
592
  } else {
593
    $('#issue-form').replaceWith(replacement);
594
  }
590 595
}
591 596

  
592 597
function updateBulkEditFrom(url) {
test/application_system_test_case.rb
81 81
    assert_equal '/my/page', current_path
82 82
  end
83 83

  
84
  def wait_for_ajax
85
    Timeout.timeout(Capybara.default_max_wait_time) do
86
      loop until page.evaluate_script("jQuery.active").zero?
87
    end
88
  end
89

  
84 90
  def clear_downloaded_files
85 91
    FileUtils.rm downloaded_files
86 92
  end
test/system/issues_test.rb
571 571
      assert page.has_text? 'Related to Bug #7'
572 572
    end
573 573
  end
574

  
575
  def test_update_issue_form_should_include_time_entry_form_only_for_users_with_permission
576
    log_user('jsmith', 'jsmith')
577

  
578
    visit '/issues/2'
579
    page.first(:link, 'Edit').click
580

  
581
    # assert log time form exits for user with required permissions on the current project
582
    assert page.has_css?('#log_time')
583

  
584
    # Change project to trigger an update on issue form
585
    page.find('#issue_project_id').select('» Private child of eCookbook')
586
    wait_for_ajax
587

  
588
    # assert log time form does not exist anymore for user without required permissions on the new project
589
    assert_not page.has_css?('#log_time')
590
  end
591

  
592
  def test_update_issue_form_should_include_add_notes_form_only_for_users_with_permission
593
    log_user('jsmith', 'jsmith')
594

  
595
    visit '/issues/2'
596
    page.first(:link, 'Edit').click
597

  
598
    # assert add notes form exits for user with required permissions on the current project
599
    assert page.has_css?('#add_notes')
600

  
601
    # remove add issue notes permission from Manager role
602
    Role.find_by_name('Manager').remove_permission! :add_issue_notes
603

  
604
    # Change project to trigger an update on issue form
605
    page.find('#issue_project_id').select('» Private child of eCookbook')
606
    wait_for_ajax
607

  
608
    # assert add notes form does not exist anymore for user without required permissions on the new project
609
    assert_not page.has_css?('#add_notes')
610
  end
574 611
end
(5-5/5)