Project

General

Profile

Defect #36059 » 36059.patch

Yuichi HARADA, 2022-02-10 02:42

View differences:

app/models/time_entry.rb
28 28
  belongs_to :activity, :class_name => 'TimeEntryActivity'
29 29

  
30 30
  acts_as_customizable
31
  acts_as_searchable :columns => ['comments'],
32
                     :preload => [:project, :issue]
31 33
  acts_as_event(
32 34
    :title =>
33 35
      Proc.new do |o|
lib/redmine/preparation.rb
383 383

  
384 384
      Search.map do |search|
385 385
        search.register :issues
386
        search.register :time_entries
386 387
        search.register :news
387 388
        search.register :documents
388 389
        search.register :changesets
test/functional/search_controller_test.rb
26 26
           :workflows,
27 27
           :custom_fields, :custom_values,
28 28
           :custom_fields_projects, :custom_fields_trackers,
29
           :repositories, :changesets
29
           :repositories, :changesets,
30
           :time_entries
30 31

  
31 32
  def setup
32 33
    User.current = nil
......
68 69
  end
69 70

  
70 71
  def test_search_all_projects
71
    with_settings :default_language => 'en' do
72
    time_entry = TimeEntry.find(5)
73
    time_entry.project_id = 3
74
    time_entry.issue_id = 5
75
    time_entry.comments = 'Time spent on a subproject of eCookbook'
76
    time_entry.save!
77

  
78
    with_settings :default_language => 'en', :search_results_per_page => '25', :timespan_format => 'decimal' do
72 79
      get :index, :params => {:q => 'recipe subproject commit', :all_words => ''}
73 80
    end
74 81
    assert_response :success
......
80 87

  
81 88
      assert_select 'dt.issue a', :text => /Add ingredients categories/
82 89
      assert_select 'dd', :text => /should be classified by categories/
90

  
91
      assert_select 'dt.time-entry:nth-of-type(1)' do
92
        assert_select 'a', text: /7.65 hours \(Bug #5/
93
        assert_select '+ dd', text: /Time spent on a subproject of eCookbook/
94
      end
83 95
    end
84 96

  
85 97
    assert_select '#search-results-counts' do
86
      assert_select 'a', :text => 'Changesets (5)'
98
      assert_select 'a[href*=?]', 'changesets=1', :text => 'Changesets (5)'
99
      assert_select 'a[href*=?]', 'time_entries=1', :text => 'Spent time (2)'
87 100
    end
88 101
  end
89 102

  
(2-2/2)