Project

General

Profile

Defect #41465 » import_issue_and_time_entry.patch

Kenta Kumojima, 2024-10-11 16:55

View differences:

app/models/time_entry_import.rb
32 32
  end
33 33

  
34 34
  def self.authorized?(user)
35
    user.allowed_to?(:import_time_entries, nil, :global => true)
35
    user.allowed_to?(:import_time_entries, nil, :global => true) && user.allowed_to?(:log_time, nil, :global => true)
36 36
  end
37 37

  
38 38
  # Returns the objects that were imported
app/views/timelog/index.html.erb
3 3
            _new_time_entry_path(@project, @query.filtered_issue_id),
4 4
            :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
5 5
<%= actions_dropdown do %>
6
  <% if User.current.allowed_to?(:import_time_entries, @project, :global => true) %>
6
  <% if User.current.allowed_to?(:import_time_entries, @project, :global => true) && User.current.allowed_to?(:log_time, @project, :global => true) %>
7 7
    <%= link_to icon_with_label('import', l(:button_import)), new_time_entries_import_path(:project_id => @project), :class => 'icon icon-import' %>
8 8
  <% end %>
9 9

  
test/functional/imports_controller_test.rb
52 52
    assert_select 'input[name=?][type=?][value=?]', 'project_id', 'hidden', 'subproject1'
53 53
  end
54 54

  
55
  def test_new_time_entry_import_without_log_time_permission
56
    Role.all.map { |role| role.remove_permission! :log_time }
57
    get(:new, :params => {:type => 'TimeEntryImport', :project_id => 'subproject1'})
58
    assert_response :forbidden
59
  end
60

  
55 61
  def test_create_should_save_the_file
56 62
    import = new_record(Import) do
57 63
      post(
58
- 
app/models/issue_import.rb
50 50
  end
51 51

  
52 52
  def self.authorized?(user)
53
    user.allowed_to?(:import_issues, nil, :global => true)
53
    user.allowed_to?(:import_issues, nil, :global => true) && user.allowed_to?(:add_issues, nil, :global => true)
54 54
  end
55 55

  
56 56
  # Returns the objects that were imported
app/views/issues/index.html.erb
7 7
      <%= link_to icon_with_label('summary', l(:field_summary)), project_issues_report_path(@project), :class => 'icon icon-stats' %>
8 8
    <% end %>
9 9

  
10
    <% if User.current.allowed_to?(:import_issues, @project, :global => true) %>
10
    <% if User.current.allowed_to?(:import_issues, @project, :global => true) && User.current.allowed_to?(:add_issues, @project, :global => true) %>
11 11
      <%= link_to icon_with_label('import', l(:button_import)), new_issues_import_path(:project_id => @project), :class => 'icon icon-import' %>
12 12
    <% end %>
13 13

  
test/functional/imports_controller_test.rb
52 52
    assert_select 'input[name=?][type=?][value=?]', 'project_id', 'hidden', 'subproject1'
53 53
  end
54 54

  
55
  def test_new_issue_import_without_add_issues_permission
56
    Role.all.map { |role| role.remove_permission! :add_issues }
57
    get(:new, :params => {:type => 'IssueImport', :project_id => 'subproject1'})
58
    assert_response :forbidden
59
  end
60

  
55 61
  def test_new_time_entry_import_without_log_time_permission
56 62
    Role.all.map { |role| role.remove_permission! :log_time }
57 63
    get(:new, :params => {:type => 'TimeEntryImport', :project_id => 'subproject1'})
58
- 
(3-3/4)