Defect #7099 » fix_time_entry_404.diff
| app/controllers/timelog_controller.rb | ||
|---|---|---|
|
end
|
||
|
def find_project
|
||
|
if issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])
|
||
|
issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id]).to_i
|
||
|
project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])
|
||
|
if issue_id > 0
|
||
|
@issue = Issue.find(issue_id)
|
||
|
@project = @issue.project
|
||
|
elsif project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])
|
||
|
elsif project_id
|
||
|
@project = Project.find(project_id)
|
||
|
else
|
||
|
render_404
|
||
| test/functional/timelog_controller_test.rb | ||
|---|---|---|
|
assert_equal i, t.issue
|
||
|
assert_equal i.project, t.project
|
||
|
end
|
||
|
def test_post_create_with_blank_issue
|
||
|
# TODO: should POST to issues’ time log instead of project. change form
|
||
|
# and routing
|
||
|
@request.session[:user_id] = 3
|
||
|
post :create, :project_id => 1,
|
||
|
:time_entry => {:comments => 'Some work on TimelogControllerTest',
|
||
|
# Not the default activity
|
||
|
:activity_id => '11',
|
||
|
:issue_id => '',
|
||
|
:spent_on => '2008-03-14',
|
||
|
:hours => '7.3'}
|
||
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
||
|
|
||
|
t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
|
||
|
assert_not_nil t
|
||
|
assert_equal 11, t.activity_id
|
||
|
assert_equal 7.3, t.hours
|
||
|
assert_equal 3, t.user_id
|
||
|
end
|
||
|
|
||
|
def test_update
|
||
|
entry = TimeEntry.find(1)
|
||
| ... | ... | |
|
|
||
|
assert_equal 8, entry.hours
|
||
|
assert_equal 2, entry.issue_id
|
||
|
assert_equal 2, entry.user_id
|
||
|
assert_equal 1, entry.user_id
|
||
|
end
|
||
|
|
||
|
def test_destroy
|
||
- « Previous
- 1
- 2
- Next »