summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-10-15 11:17:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-10-15 11:17:33 +0000
commit9e16fcf3f3d4f20f90e4f09f3b93103bc28a8039 (patch)
tree34cea62a2925770ebb0bdc2d908d3e89fedba74b
parent41198e55902482f1227ad63e95313e85288259fb (diff)
downloadredmine-9e16fcf3f3d4f20f90e4f09f3b93103bc28a8039.tar.gz
redmine-9e16fcf3f3d4f20f90e4f09f3b93103bc28a8039.zip
Merged r16924 and r16925 (#26520).
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@16989 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/time_entry_query.rb7
-rw-r--r--app/views/timelog/index.html.erb2
-rw-r--r--test/functional/timelog_controller_test.rb8
3 files changed, 16 insertions, 1 deletions
diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb
index ee15699f4..d73a0e6b5 100644
--- a/app/models/time_entry_query.rb
+++ b/app/models/time_entry_query.rb
@@ -112,6 +112,13 @@ class TimeEntryQuery < Query
[['spent_on', 'desc']]
end
+ # If a filter against a single issue is set, returns its id, otherwise nil.
+ def filtered_issue_id
+ if value_for('issue_id').to_s =~ /\A(\d+)\z/
+ $1
+ end
+ end
+
def base_scope
TimeEntry.visible.
joins(:project, :user).
diff --git a/app/views/timelog/index.html.erb b/app/views/timelog/index.html.erb
index 0932c58ae..f777dac30 100644
--- a/app/views/timelog/index.html.erb
+++ b/app/views/timelog/index.html.erb
@@ -1,6 +1,6 @@
<div class="contextual">
<%= link_to l(:button_log_time),
- _new_time_entry_path(@project, @issue),
+ _new_time_entry_path(@project, @query.filtered_issue_id),
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
</div>
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 89b1ccfcf..8d3804e5e 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -725,6 +725,8 @@ class TimelogControllerTest < Redmine::ControllerTest
end
def test_index_at_project_level
+ @request.session[:user_id] = 2
+
get :index, :params => {:project_id => 'ecookbook', :c => ['project']}
assert_response :success
@@ -736,6 +738,9 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_select '.total-for-hours', :text => 'Hours: 162.90'
assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
+
+ # 'Log time' shoudl link to log time on the filtered issue
+ assert_select 'a[href=?]', "/projects/ecookbook/time_entries/new"
end
def test_index_with_display_subprojects_issues_to_false_should_not_include_subproject_entries
@@ -770,6 +775,9 @@ class TimelogControllerTest < Redmine::ControllerTest
get :index, :params => {:project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1}
assert_select '.total-for-hours', :text => 'Hours: 7.00'
+
+ # 'Log time' shoudl link to log time on the filtered issue
+ assert_select 'a[href=?]', "/issues/#{issue.id}/time_entries/new"
end
def test_index_at_project_level_with_issue_fixed_version_id_short_filter