Project

General

Profile

Defect #7099 » fix_time_entry_404.diff

Adam Soltys, 2010-12-13 07:41

View differences:

app/controllers/timelog_controller.rb
200 200
  end
201 201

  
202 202
  def find_project
203
    if issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id])
203
    issue_id = (params[:issue_id] || params[:time_entry] && params[:time_entry][:issue_id]).to_i
204
    project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])
205

  
206
    if issue_id > 0
204 207
      @issue = Issue.find(issue_id)
205 208
      @project = @issue.project
206
    elsif project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])
209
    elsif project_id
207 210
      @project = Project.find(project_id)
208 211
    else
209 212
      render_404
test/functional/timelog_controller_test.rb
94 94
    assert_equal i, t.issue
95 95
    assert_equal i.project, t.project
96 96
  end
97

  
98
  def test_post_create_with_blank_issue
99
    # TODO: should POST to issues’ time log instead of project. change form
100
    # and routing
101
    @request.session[:user_id] = 3
102
    post :create, :project_id => 1,
103
                :time_entry => {:comments => 'Some work on TimelogControllerTest',
104
                                # Not the default activity
105
                                :activity_id => '11',
106
                                :spent_on => '2008-03-14',
107
                                :hours => '7.3'}
108
    assert_redirected_to :action => 'index', :project_id => 'ecookbook'
109
    
110
    i = Issue.find(1)
111
    t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
112
    assert_not_nil t
113
    assert_equal 11, t.activity_id
114
    assert_equal 7.3, t.hours
115
    assert_equal 3, t.user_id
116
    assert_equal i, t.issue
117
    assert_equal i.project, t.project
118
  end
97 119
  
98 120
  def test_update
99 121
    entry = TimeEntry.find(1)
......
109 131
    
110 132
    assert_equal 8, entry.hours
111 133
    assert_equal 2, entry.issue_id
112
    assert_equal 2, entry.user_id
134
    assert_equal 1, entry.user_id
113 135
  end
114 136
  
115 137
  def test_destroy
(1-1/2)