Project

General

Profile

Defect #41465 » import_time_entry.patch

Kenta Kumojima, 2024-10-10 10:48

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) && user.allowed_to?(:log_time, nil, :global => true)
35 36
    user.allowed_to?(:import_time_entries, nil, :global => true)
36 37
  end
37 38

  
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
- 
(1-1/4)