Feature #3058 » 0004-add-time-entries-tab-to-issue-history-tabs.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
| 102 | 102 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
| 103 | 103 |
@priorities = IssuePriority.active |
| 104 | 104 |
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
| 105 |
@time_entries = @issue.time_entries.visible.preload(:activity, :user) |
|
| 105 | 106 |
@relation = IssueRelation.new |
| 106 | 107 |
retrieve_previous_and_next_issue_ids |
| 107 | 108 |
render :template => 'issues/show' |
| app/helpers/issues_helper.rb | ||
|---|---|---|
| 554 | 554 |
tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
|
| 555 | 555 |
tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
|
| 556 | 556 |
end |
| 557 |
tabs << {:name => 'time_entries', :label => :label_time_entry_plural, :partial => 'issues/tabs/time_entries', :locals => {:time_entries => @time_entries}} if User.current.allowed_to?(:view_time_entries, @project) && @issue.spent_hours > 0
|
|
| 557 | 558 |
tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present?
|
| 558 | 559 |
tabs |
| 559 | 560 |
end |
| app/views/issues/tabs/_time_entries.html.erb | ||
|---|---|---|
| 1 |
<% for time_entry in tab[:locals][:time_entries] %> |
|
| 2 |
<div id="time-entry-<%= time_entry.id %>" class="time_entry journal"> |
|
| 3 |
<% if time_entry.editable_by?(User.current) -%> |
|
| 4 |
<div class="contextual"> |
|
| 5 |
<%= link_to l(:button_edit), edit_time_entry_path(time_entry), |
|
| 6 |
:title => l(:button_edit), |
|
| 7 |
:class => 'icon-only icon-edit' %> |
|
| 8 |
<%= link_to l(:button_delete), time_entry_path(time_entry), |
|
| 9 |
:data => {:confirm => l(:text_are_you_sure)},
|
|
| 10 |
:method => :delete, |
|
| 11 |
:title => l(:button_delete), |
|
| 12 |
:class => 'icon-only icon-del' %> |
|
| 13 |
</div> |
|
| 14 |
<% end -%> |
|
| 15 |
<h4> |
|
| 16 |
<%= avatar(time_entry.user, :size => "24") %> |
|
| 17 |
<%= authoring time_entry.created_on, time_entry.user, :label => :label_added_time_by %> |
|
| 18 |
</h4> |
|
| 19 |
<ul class="details"> |
|
| 20 |
<li> |
|
| 21 |
<strong><%= l(:label_time_entry_plural) %></strong>: |
|
| 22 |
<%= l_hours_short time_entry.hours %> |
|
| 23 |
</li> |
|
| 24 |
</ul> |
|
| 25 |
<p><%= time_entry.comments %></p> |
|
| 26 |
</div> |
|
| 27 |
<%= call_hook(:view_issues_history_time_entry_bottom, { :time_entry => time_entry }) %>
|
|
| 28 |
<% end %> |
|
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 2480 | 2480 | |
| 2481 | 2481 |
def test_show_display_changesets_tab_for_issue_with_changesets |
| 2482 | 2482 |
project = Project.find(2) |
| 2483 |
issue = Issue.find(3)
|
|
| 2483 |
issue = Issue.find(9)
|
|
| 2484 | 2484 |
issue.changeset_ids = [102] |
| 2485 | 2485 |
issue.save! |
| 2486 | 2486 | |
| 2487 | 2487 |
@request.session[:user_id] = 2 |
| 2488 |
get :show, :params => {:id => 3}
|
|
| 2488 |
get :show, :params => {:id => issue.id}
|
|
| 2489 | 2489 | |
| 2490 | 2490 |
assert_select '#history' do |
| 2491 | 2491 |
assert_select 'div.tabs ul a', 1 |
| ... | ... | |
| 2493 | 2493 |
end |
| 2494 | 2494 |
end |
| 2495 | 2495 | |
| 2496 |
def test_show_should_display_spent_time_tab_for_issue_with_time_entries |
|
| 2497 |
@request.session[:user_id] = 1 |
|
| 2498 |
get :show, :params => {:id => 3}
|
|
| 2499 |
assert_response :success |
|
| 2500 | ||
| 2501 |
assert_select '#history' do |
|
| 2502 |
assert_select 'div.tabs ul a', 1 |
|
| 2503 |
assert_select 'div.tabs a[id=?]', 'tab-time_entries', :text => 'Spent time' |
|
| 2504 |
end |
|
| 2505 | ||
| 2506 |
assert_select 'div[id=?]', 'time-entry-3' do |
|
| 2507 |
assert_select 'a[title=?][href=?]', 'Edit', '/time_entries/3/edit' |
|
| 2508 |
assert_select 'a[title=?][href=?]', 'Delete', '/time_entries/3' |
|
| 2509 | ||
| 2510 |
assert_select 'ul[class=?]', 'details', :text => /1.00 h/ |
|
| 2511 |
end |
|
| 2512 |
end |
|
| 2513 | ||
| 2496 | 2514 |
def test_get_new |
| 2497 | 2515 |
@request.session[:user_id] = 2 |
| 2498 | 2516 |
get :new, :params => {
|