diff options
-rw-r--r-- | app/controllers/timelog_controller.rb | 5 | ||||
-rw-r--r-- | test/integration/api_test/time_entries_test.rb | 23 |
2 files changed, 23 insertions, 5 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index c01e949d6..6379c4511 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -279,8 +279,9 @@ class TimelogController < ApplicationController end def find_optional_issue - if params[:issue_id].present? - @issue = Issue.find(params[:issue_id]) + if params[:issue_id].present? || params[:time_entry].present? && params[:time_entry][:issue_id].present? + issue_id = params[:issue_id] || params[:time_entry][:issue_id] + @issue = Issue.find(issue_id) @project = @issue.project authorize else diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb index 6dd8119c5..dbdf15d89 100644 --- a/test/integration/api_test/time_entries_test.rb +++ b/test/integration/api_test/time_entries_test.rb @@ -144,7 +144,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base assert_select 'errors error', :text => "Hours cannot be blank" end - test "POST /time_entries.xml for other user" do + test "POST /time_entries.xml with :project_id for other user" do Role.find_by_name('Manager').add_permission! :log_time_for_other_users assert_difference 'TimeEntry.count' do @@ -155,10 +155,27 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base {:project_id => '1', :spent_on => '2010-12-02', :user_id => '3', :hours => '3.5', :activity_id => '11'}}, :headers => credentials('jsmith')) + assert_response :created end - assert_response :created - assert_equal 'application/xml', @response.content_type + entry = TimeEntry.order('id DESC').first + assert_equal 3, entry.user_id + assert_equal 2, entry.author_id + end + + test "POST /time_entries.xml with :issue_id for other user" do + Role.find_by_name('Manager').add_permission! :log_time_for_other_users + + assert_difference 'TimeEntry.count' do + post( + '/time_entries.xml', + :params => + {:time_entry => + {:issue_id => '1', :spent_on => '2010-12-02', :user_id => '3', + :hours => '3.5', :activity_id => '11'}}, + :headers => credentials('jsmith')) + assert_response :created + end entry = TimeEntry.order('id DESC').first assert_equal 3, entry.user_id |