Feature #3058 » 0004-add-time-entries-tab-to-issue-history-tabs.patch
app/controllers/issues_controller.rb | ||
---|---|---|
104 | 104 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
105 | 105 |
@priorities = IssuePriority.active |
106 | 106 |
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
107 |
@time_entries = @issue.time_entries.visible.preload(:activity, :user) |
|
107 | 108 |
@relation = IssueRelation.new |
108 | 109 |
retrieve_previous_and_next_issue_ids |
109 | 110 |
render :template => 'issues/show' |
app/helpers/issues_helper.rb | ||
---|---|---|
557 | 557 |
tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any? |
558 | 558 |
tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any? |
559 | 559 |
end |
560 |
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 |
|
560 | 561 |
tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present? |
561 | 562 |
tabs |
562 | 563 |
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 | ||
---|---|---|
2515 | 2515 | |
2516 | 2516 |
def test_show_display_changesets_tab_for_issue_with_changesets |
2517 | 2517 |
project = Project.find(2) |
2518 |
issue = Issue.find(3)
|
|
2518 |
issue = Issue.find(9)
|
|
2519 | 2519 |
issue.changeset_ids = [102] |
2520 | 2520 |
issue.save! |
2521 | 2521 | |
2522 | 2522 |
@request.session[:user_id] = 2 |
2523 |
get :show, :params => {:id => 3}
|
|
2523 |
get :show, :params => {:id => issue.id}
|
|
2524 | 2524 | |
2525 | 2525 |
assert_select '#history' do |
2526 | 2526 |
assert_select 'div.tabs ul a', 1 |
... | ... | |
2528 | 2528 |
end |
2529 | 2529 |
end |
2530 | 2530 | |
2531 |
def test_show_should_display_spent_time_tab_for_issue_with_time_entries |
|
2532 |
@request.session[:user_id] = 1 |
|
2533 |
get :show, :params => {:id => 3} |
|
2534 |
assert_response :success |
|
2535 | ||
2536 |
assert_select '#history' do |
|
2537 |
assert_select 'div.tabs ul a', 1 |
|
2538 |
assert_select 'div.tabs a[id=?]', 'tab-time_entries', :text => 'Spent time' |
|
2539 |
end |
|
2540 | ||
2541 |
assert_select 'div[id=?]', 'time-entry-3' do |
|
2542 |
assert_select 'a[title=?][href=?]', 'Edit', '/time_entries/3/edit' |
|
2543 |
assert_select 'a[title=?][href=?]', 'Delete', '/time_entries/3' |
|
2544 | ||
2545 |
assert_select 'ul[class=?]', 'details', :text => /1.00 h/ |
|
2546 |
end |
|
2547 |
end |
|
2548 | ||
2531 | 2549 |
def test_get_new |
2532 | 2550 |
@request.session[:user_id] = 2 |
2533 | 2551 |
get :new, :params => { |