##// END OF EJS Templates
Fixed that project is ignored when entering an issue id on /time_entries/new form (#10020)....
Jean-Philippe Lang -
r8573:13f28858baf5
parent child
Show More
@@ -262,12 +262,14 private
262 end
262 end
263
263
264 def find_project
264 def find_project
265 if (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
266 @project = Project.find(project_id)
267 end
265 if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
268 if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present?
266 @issue = Issue.find(issue_id)
269 @issue = Issue.find(issue_id)
267 @project = @issue.project
270 @project ||= @issue.project
268 elsif (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
271 end
269 @project = Project.find(project_id)
272 if @project.nil?
270 else
271 render_404
273 render_404
272 return false
274 return false
273 end
275 end
@@ -209,6 +209,20 class TimelogControllerTest < ActionController::TestCase
209 assert_equal 1, time_entry.project_id
209 assert_equal 1, time_entry.project_id
210 end
210 end
211
211
212 def test_create_without_project_should_fail_with_issue_not_inside_project
213 @request.session[:user_id] = 2
214 assert_no_difference 'TimeEntry.count' do
215 post :create, :time_entry => {:project_id => '1',
216 :activity_id => '11',
217 :issue_id => '5',
218 :spent_on => '2008-03-14',
219 :hours => '7.3'}
220 end
221
222 assert_response :success
223 assert assigns(:time_entry).errors[:issue_id].present?
224 end
225
212 def test_create_without_project_should_deny_without_permission
226 def test_create_without_project_should_deny_without_permission
213 @request.session[:user_id] = 2
227 @request.session[:user_id] = 2
214 Project.find(3).disable_module!(:time_tracking)
228 Project.find(3).disable_module!(:time_tracking)
General Comments 0
You need to be logged in to leave comments. Login now