Index: app/controllers/timelog_controller.rb =================================================================== --- app/controllers/timelog_controller.rb (revision 12406) +++ app/controllers/timelog_controller.rb (working copy) @@ -17,6 +17,7 @@ class TimelogController < ApplicationController menu_item :issues + default_search_scope :time_entries before_filter :find_project_for_new_time_entry, :only => [:create] before_filter :find_time_entry, :only => [:show, :edit, :update] Index: app/models/time_entry.rb =================================================================== --- app/models/time_entry.rb (revision 12406) +++ app/models/time_entry.rb (working copy) @@ -32,7 +32,7 @@ :author => :user, :group => :issue, :description => :comments - + acts_as_searchable :columns => 'comments' acts_as_activity_provider :timestamp => "#{table_name}.created_on", :author_key => :user_id, :find_options => {:include => :project} Index: app/views/custom_fields/_form.html.erb =================================================================== --- app/views/custom_fields/_form.html.erb (revision 12406) +++ app/views/custom_fields/_form.html.erb (working copy) @@ -78,6 +78,9 @@ <% when "TimeEntryCustomField" %>
<%= f.check_box :is_required %>
<%= f.check_box :is_filter %>
+ <% if @custom_field.format.searchable_supported %> +<%= f.check_box :searchable %>
+ <% end %> <% else %><%= f.check_box :is_required %>
Index: lib/redmine.rb =================================================================== --- lib/redmine.rb (revision 12406) +++ lib/redmine.rb (working copy) @@ -261,6 +261,7 @@ search.register :changesets search.register :wiki_pages search.register :messages + search.register :time_entries search.register :projects end Index: test/fixtures/custom_fields.yml =================================================================== --- test/fixtures/custom_fields.yml (revision 12406) +++ test/fixtures/custom_fields.yml (working copy) @@ -145,3 +145,17 @@ SGXDqWzDp2prc2Tigqw2NTTDuQ== - Other value field_format: list +custom_fields_012: + name: Searchable time entry field + regexp: "" + is_for_all: false + is_filter: false + type: TimeEntryCustomField + possible_values: "" + id: 12 + is_required: false + field_format: string + searchable: true + default_value: "" + editable: true + position: 2 Index: test/fixtures/custom_values.yml =================================================================== --- test/fixtures/custom_values.yml (revision 12406) +++ test/fixtures/custom_values.yml (working copy) @@ -101,3 +101,9 @@ customized_id: 1 id: 17 value: '2009-12-01' +custom_values_018: + customized_type: TimeEntry + custom_field_id: 12 + customized_id: 2 + id: 18 + value: "stringfortimeentry custom field search" Index: test/functional/search_controller_test.rb =================================================================== --- test/functional/search_controller_test.rb (revision 12406) +++ test/functional/search_controller_test.rb (working copy) @@ -21,7 +21,8 @@ fixtures :projects, :enabled_modules, :roles, :users, :members, :member_roles, :issues, :trackers, :issue_statuses, :enumerations, :custom_fields, :custom_values, - :repositories, :changesets + :repositories, :changesets, + :time_entries def setup User.current = nil @@ -43,12 +44,12 @@ assert_response :success assert_template 'index' - assert assigns(:results).include?(Issue.find(2)) + assert assigns(:results).include?(Issue.find(3)) assert assigns(:results).include?(Issue.find(5)) assert assigns(:results).include?(Changeset.find(101)) assert_tag :dt, :attributes => { :class => /issue/ }, - :child => { :tag => 'a', :content => /Add ingredients categories/ }, - :sibling => { :tag => 'dd', :content => /should be classified by categories/ } + :child => { :tag => 'a', :content => /Error 281 when updating a/ }, + :sibling => { :tag => 'dd', :content => /Error 281 is encountered when/ } assert assigns(:results_by_type).is_a?(Hash) assert_equal 5, assigns(:results_by_type)['changesets'] @@ -101,6 +102,48 @@ assert_not_include Issue.find(2), assigns(:results) end + def test_search_time_entries_on_project + get :index, :id => 1, :q => 'hours' + assert_response :success + assert_template 'index' + + results = assigns(:results) + assert_not_nil results + assert_equal 1, results.size + + assert assigns(:results).include?(TimeEntry.find(1)) + assert_tag :dt, :attributes => { :class => /time-entry/ }, + :child => { :tag => 'a', :content => /\(Bug #1 \(New\): Can't print recipes\)/ }, + :sibling => { :tag => 'dd', :content => /My/ } + end + + def test_search_time_entries_on_project_with_subprojects_scope + get :index, :id => 1, :q => 'time spent', :scope => 'subprojects', :time_entries => 1 + assert_response :success + assert_template 'index' + + results = assigns(:results) + assert_not_nil results + assert_equal 1, results.size + + assert assigns(:results).include?(TimeEntry.find(4)) + assert_tag :dt, :attributes => { :class => /time-entry/ }, + :child => { :tag => 'a', :content => /\(Project: eCookbook Subproject 1\)/ }, + :sibling => { :tag => 'dd', :content => /on a subproject/ } + end + + def test_search_time_entries_on_all_projects + get :index, :q => 'recipe subproject commit', :all_words => '' + assert_response :success + assert_template 'index' + + assert assigns(:results).include?(TimeEntry.find(4)) + assert_tag :dt, :attributes => { :class => /time-entry/ }, + :child => { :tag => 'a', :content => /7.65 hours/ }, + :sibling => { :tag => 'dd', :content => /Time spent on a/ } + assert_equal 1, assigns(:results_by_type)['time_entries'] + end + def test_search_all_projects_with_scope_param get :index, :q => 'issue', :scope => 'all' assert_response :success @@ -155,6 +198,15 @@ assert results.include?(Issue.find(7)) end + def test_search_time_entries_with_searchable_custom_fields + get :index, :id => 1, :q => "stringfortimeentry", :time_entries => 1 + assert_response :success + results = assigns(:results) + assert_not_nil results + assert_equal 1, results.size + assert results.include?(TimeEntry.find(2)) + end + def test_search_all_words # 'all words' is on by default get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1' Index: test/functional/timelog_controller_test.rb =================================================================== --- test/functional/timelog_controller_test.rb (revision 12406) +++ test/functional/timelog_controller_test.rb (working copy) @@ -660,4 +660,12 @@ assert_response :success assert_equal 'text/csv; header=present', response.content_type end + + def test_default_search_scope + get :index + + assert_select 'div#quick-search form' do + assert_select 'input[name=time_entries][value=1][type=hidden]' + end + end end