@issues = []
q = (params[:q] || params[:term]).to_s.strip
if q.present?
- scope = (params[:scope] == "all" ? Issue : @project.issues).visible
+ scope = (params[:scope] == "all" || @project.nil? ? Issue : @project.issues).visible
if q.match(/^\d+$/)
@issues << scope.find_by_id(q.to_i)
end
private
def find_project
- @project = Project.find(params[:project_id])
+ if params[:project_id].present?
+ @project = Project.find(params[:project_id])
+ end
rescue ActiveRecord::RecordNotFound
render_404
end
<% end %>
<%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
</div>
+
+<%= javascript_tag "observeAutocompleteField('time_entry_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (@project ? nil : 'all'))}')" %>
assert assigns(:issues).include?(Issue.find(13))
end
+ def test_auto_complete_without_project_should_search_all_projects
+ get :issues, :q => '13'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert assigns(:issues).include?(Issue.find(13))
+ end
+
def test_auto_complete_without_scope_all_should_not_search_other_projects
get :issues, :project_id => 'ecookbook', :q => '13'
assert_response :success