Project

General

Profile

Feature #34857 » 34857-test.patch

Takenori TAKAKI, 2021-04-28 08:10

View differences:

test/integration/api_test/issues_test.rb
141 141
    assert_select 'issues>issue>is_private', :text => 'false'
142 142
  end
143 143

  
144
  def test_index_should_include_spent_hours
145
    Issue.delete_all
146
    parent = Issue.generate!(:estimated_hours => 2.0)
147
    child = Issue.generate!(:parent_id => parent.id, :estimated_hours => 3.0)
148
    TimeEntry.create!(:project => parent.project, :issue => parent, :user => parent.author, :spent_on => parent.author.today,
149
                      :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id)
150
    TimeEntry.create!(:project => child.project, :issue => child, :user => child.author, :spent_on => child.author.today,
151
                      :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id)
152

  
153
    get '/issues.xml'
154

  
155
    assert_select 'issues issue', 2
156
    assert_select 'issues>issue>spent_hours', '2.5'
157
    assert_select 'issues>issue>total_spent_hours', '5.0'
158
  end
159

  
160
  def test_index_should_not_include_spent_hours
161
    r = Role.anonymous
162
    r.permissions.delete(:view_time_entries)
163
    r.permissions_will_change!
164
    r.save
165

  
166
    get '/issues.xml'
167

  
168
    assert_select 'issues>issue>spent_hours', false
169
    assert_select 'issues>issue>total_spent_hours', false
170
  end
171

  
144 172
  def test_index_should_allow_timestamp_filtering
145 173
    Issue.delete_all
146 174
    Issue.generate!(:subject => '1').update_column(:updated_on, Time.parse("2014-01-02T10:25:00Z"))
(2-2/2)