@@ -262,12 +262,14 private | |||
|
262 | 262 | end |
|
263 | 263 | |
|
264 | 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 | 268 | if (issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])).present? |
|
266 | 269 | @issue = Issue.find(issue_id) |
|
267 | @project = @issue.project | |
|
268 | elsif (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present? | |
|
269 | @project = Project.find(project_id) | |
|
270 | else | |
|
270 | @project ||= @issue.project | |
|
271 | end | |
|
272 | if @project.nil? | |
|
271 | 273 | render_404 |
|
272 | 274 | return false |
|
273 | 275 | end |
@@ -209,6 +209,20 class TimelogControllerTest < ActionController::TestCase | |||
|
209 | 209 | assert_equal 1, time_entry.project_id |
|
210 | 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 | 226 | def test_create_without_project_should_deny_without_permission |
|
213 | 227 | @request.session[:user_id] = 2 |
|
214 | 228 | Project.find(3).disable_module!(:time_tracking) |
General Comments 0
You need to be logged in to leave comments.
Login now