diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 88e1796f34..5422e3f273 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -28,6 +28,8 @@ class TimeEntry < ActiveRecord::Base belongs_to :activity, :class_name => 'TimeEntryActivity' acts_as_customizable + acts_as_searchable :columns => ['comments'], + :preload => [:project, :issue] acts_as_event( :title => Proc.new do |o| diff --git a/lib/redmine/preparation.rb b/lib/redmine/preparation.rb index 4c6b3afe6e..08b6c33fd9 100644 --- a/lib/redmine/preparation.rb +++ b/lib/redmine/preparation.rb @@ -383,6 +383,7 @@ module Redmine Search.map do |search| search.register :issues + search.register :time_entries search.register :news search.register :documents search.register :changesets diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 8b004cbcf4..64b01fb6d7 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -26,7 +26,8 @@ class SearchControllerTest < Redmine::ControllerTest :workflows, :custom_fields, :custom_values, :custom_fields_projects, :custom_fields_trackers, - :repositories, :changesets + :repositories, :changesets, + :time_entries def setup User.current = nil @@ -68,7 +69,13 @@ class SearchControllerTest < Redmine::ControllerTest end def test_search_all_projects - with_settings :default_language => 'en' do + time_entry = TimeEntry.find(5) + time_entry.project_id = 3 + time_entry.issue_id = 5 + time_entry.comments = 'Time spent on a subproject of eCookbook' + time_entry.save! + + with_settings :default_language => 'en', :search_results_per_page => '25', :timespan_format => 'decimal' do get :index, :params => {:q => 'recipe subproject commit', :all_words => ''} end assert_response :success @@ -80,10 +87,16 @@ class SearchControllerTest < Redmine::ControllerTest assert_select 'dt.issue a', :text => /Add ingredients categories/ assert_select 'dd', :text => /should be classified by categories/ + + assert_select 'dt.time-entry:nth-of-type(1)' do + assert_select 'a', text: /7.65 hours \(Bug #5/ + assert_select '+ dd', text: /Time spent on a subproject of eCookbook/ + end end assert_select '#search-results-counts' do - assert_select 'a', :text => 'Changesets (5)' + assert_select 'a[href*=?]', 'changesets=1', :text => 'Changesets (5)' + assert_select 'a[href*=?]', 'time_entries=1', :text => 'Spent time (2)' end end