summaryrefslogtreecommitdiffstats
path: root/test/system/issues_test.rb
blob: 935470e1acf7a40339afdcd6275eb71086ec413b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# frozen_string_literal: true

# Redmine - project management software
# Copyright (C) 2006-2022  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

require File.expand_path('../../application_system_test_case', __FILE__)

class IssuesSystemTest < ApplicationSystemTestCase
  fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
           :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
           :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
           :watchers, :journals, :journal_details, :versions,
           :workflows

  def test_create_issue
    log_user('jsmith', 'jsmith')
    visit '/projects/ecookbook/issues/new'
    within('form#issue-form') do
      select 'Bug', :from => 'Tracker'
      select 'Low', :from => 'Priority'
      fill_in 'Subject', :with => 'new test issue'
      fill_in 'Description', :with => 'new issue'
      select '0 %', :from => 'Done'
      fill_in 'Searchable field', :with => 'Value for field 2'
      # click_button 'Create' would match both 'Create' and 'Create and continue' buttons
      find('input[name=commit]').click
    end

    # find created issue
    issue = Issue.find_by_subject("new test issue")
    assert_kind_of Issue, issue

    # check redirection
    find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
    assert_equal issue_path(:id => issue), current_path

    # check issue attributes
    assert_equal 'jsmith', issue.author.login
    assert_equal 1, issue.project.id
    assert_equal IssueStatus.find_by_name('New'), issue.status
    assert_equal Tracker.find_by_name('Bug'), issue.tracker
    assert_equal IssuePriority.find_by_name('Low'), issue.priority
    assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
  end

  def test_create_issue_with_form_update
    field1 = IssueCustomField.create!(
      :field_format => 'string',
      :name => 'Field1',
      :is_for_all => true,
      :trackers => Tracker.where(:id => [1, 2])
    )
    field2 = IssueCustomField.create!(
      :field_format => 'string',
      :name => 'Field2',
      :is_for_all => true,
      :trackers => Tracker.where(:id => 2)
    )

    Role.non_member.add_permission! :add_issues
    Role.non_member.remove_permission! :edit_issues, :add_issue_notes

    log_user('someone', 'foo')
    visit '/projects/ecookbook/issues/new'
    assert page.has_no_content?(field2.name)
    assert page.has_content?(field1.name)

    fill_in 'Subject', :with => 'New test issue'
    fill_in 'Description', :with => 'New test issue description'
    fill_in field1.name, :with => 'CF1 value'
    select 'Low', :from => 'Priority'

    # field2 should show up when changing tracker
    select 'Feature request', :from => 'Tracker'
    assert page.has_content?(field2.name)
    assert page.has_content?(field1.name)

    fill_in field2.name, :with => 'CF2 value'
    assert_difference 'Issue.count' do
      page.first(:button, 'Create').click
    end

    issue = Issue.order('id desc').first
    assert_equal 'New test issue', issue.subject
    assert_equal 'New test issue description', issue.description
    assert_equal 'Low', issue.priority.name
    assert_equal 'CF1 value', issue.custom_field_value(field1)
    assert_equal 'CF2 value', issue.custom_field_value(field2)
  end

  def test_create_issue_with_watchers
    user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
    assert_equal 'Some Watcher', user.name
    log_user('jsmith', 'jsmith')
    visit '/projects/ecookbook/issues/new'
    fill_in 'Subject', :with => 'Issue with watchers'
    # Add a project member as watcher
    check 'Dave Lopper'
    # Search for another user
    assert page.has_no_css?('form#new-watcher-form')
    assert page.has_no_content?('Some Watcher')
    click_link 'Search for watchers to add'
    within('form#new-watcher-form') do
      fill_in 'user_search', :with => 'watch'
      assert page.has_content?('Some Watcher')
      check 'Some Watcher'
      click_button 'Add'
    end
    assert page.has_css?('form#issue-form')
    assert page.has_css?('p#watchers_form')
    using_wait_time(30) do
      within('span#watchers_inputs') do
        within("label#issue_watcher_user_ids_#{user.id}") do
          assert has_content?('Some Watcher'), "No watcher content"
        end
      end
    end
    assert_difference 'Issue.count' do
      find('input[name=commit]').click
    end

    issue = Issue.order('id desc').first
    assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
  end

  def test_create_issue_with_attachment
    set_tmp_attachments_directory
    log_user('jsmith', 'jsmith')

    issue = new_record(Issue) do
      visit '/projects/ecookbook/issues/new'
      fill_in 'Subject', :with => 'Issue with attachment'
      attach_file 'attachments[dummy][file]', Rails.root.join('test/fixtures/files/testfile.txt')
      fill_in 'attachments[1][description]', :with => 'Some description'
      click_on 'Create'
    end
    assert_equal 1, issue.attachments.count
    assert_equal 'Some description', issue.attachments.first.description
  end

  def test_create_issue_with_new_target_version
    log_user('jsmith', 'jsmith')

    assert_difference 'Issue.count' do
      assert_difference 'Version.count' do
        visit '/projects/ecookbook/issues/new'
        fill_in 'Subject', :with => 'With a new version'
        click_on 'New version'
        within '#ajax-modal' do
          fill_in 'Name', :with => '4.0'
          click_on 'Create'
        end
        click_on 'Create'
      end
    end

    issue = Issue.order('id desc').first
    assert_not_nil issue.fixed_version
    assert_equal '4.0', issue.fixed_version.name
  end

  def test_preview_issue_description
    log_user('jsmith', 'jsmith')
    visit '/projects/ecookbook/issues/new'
    within('form#issue-form') do
      fill_in 'Subject', :with => 'new issue subject'
      fill_in 'Description', :with => 'new issue description'
      click_link 'Preview'
      find 'div.wiki-preview', :visible => true, :text => 'new issue description'
    end
    assert_difference 'Issue.count' do
      click_button('Create')
    end

    issue = Issue.order('id desc').first
    assert_equal 'new issue description', issue.description
  end

  test "update issue with form update" do
    field = IssueCustomField.create!(
      :field_format => 'string',
      :name => 'Form update CF',
      :is_for_all => true,
      :trackers => Tracker.where(:name => 'Feature request')
    )

    Role.non_member.add_permission! :edit_issues, :add_issues
    Role.non_member.remove_permission! :add_issue_notes

    log_user('someone', 'foo')
    visit '/issues/1'
    assert page.has_no_content?('Form update CF')

    page.first(:link, 'Edit').click
    assert page.has_no_select?("issue_status_id")
    # the custom field should show up when changing tracker
    select 'Feature request', :from => 'Tracker'
    assert page.has_content?('Form update CF')

    fill_in 'Form update CF', :with => 'CF value'
    assert_no_difference 'Issue.count' do
      page.first(:button, 'Submit').click
    end
    assert page.has_css?('#flash_notice')
    issue = Issue.find(1)
    assert_equal 'CF value', issue.custom_field_value(field)
  end

  test "update issue status" do
    issue = Issue.generate!
    log_user('jsmith', 'jsmith')
    visit "/issues/#{issue.id}"
    page.first(:link, 'Edit').click
    assert page.has_select?("issue_status_id", selected: "New")
    page.find("#issue_status_id").select("Closed")
    assert_no_difference 'Issue.count' do
      page.first(:button, 'Submit').click
    end
    assert page.has_css?('#flash_notice')
    assert_equal 5, issue.reload.status.id
  end

  test "removing issue shows confirm dialog" do
    log_user('jsmith', 'jsmith')
    visit '/issues/1'
    page.accept_confirm /Are you sure/ do
      first('#content span.icon-actions').click
      first('#content a.icon-del').click
    end
  end

  def test_remove_issue_watcher_from_sidebar
    user = User.find(3)
    Watcher.create!(:watchable => Issue.find(1), :user => user)

    log_user('jsmith', 'jsmith')
    visit '/issues/1'
    assert page.first('#sidebar').has_content?('Watchers (1)')
    assert page.first('#sidebar').has_content?(user.name)
    assert_difference 'Watcher.count', -1 do
      page.first('ul.watchers .user-3 a.delete').click
      assert page.first('#sidebar').has_content?('Watchers (0)')
    end
    assert page.first('#sidebar').has_no_content?(user.name)
  end

  def test_watch_should_update_watchers_list
    user = User.find(2)
    log_user('jsmith', 'jsmith')
    visit '/issues/1'
    assert page.first('#sidebar').has_content?('Watchers (0)')

    page.first('a.issue-1-watcher').click
    assert page.first('#sidebar').has_content?('Watchers (1)')
    assert page.first('#sidebar').has_content?(user.name)
  end

  def test_watch_issue_via_context_menu
    log_user('jsmith', 'jsmith')
    visit '/issues'
    jsmith = User.find_by_login('jsmith')
    issue1 = Issue.find(1)
    assert_not issue1.reload.watched_by?(jsmith)
    assert page.has_css?('tr#issue-1')
    find('tr#issue-1 td.updated_on').click
    find('tr#issue-1 td.updated_on').right_click
    assert page.has_css?('#context-menu .issue-1-watcher.icon-fav-off')
    assert_difference 'Watcher.count' do
      within('#context-menu') do
        click_link 'Watch'
      end
      # wait for ajax response
      assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
      assert page.has_css?('tr#issue-1')
    end
    assert issue1.reload.watched_by?(jsmith)
  end

  def test_change_watch_or_unwatch_icon_from_sidebar
    user = User.find(2)
    log_user('jsmith', 'jsmith')
    visit '/issues/1'
    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav-off')
    # add watcher 'jsmith' from sidebar
    page.find('#watchers .contextual a', :text => 'Add').click
    page.find('#users_for_watcher label', :text => 'John Smith').click
    page.find('#new-watcher-form p.buttons input[type=submit]').click
    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav')
    # remove watcher 'jsmith' from sidebar
    page.find('#watchers ul li.user-2 a.delete').click
    assert page.has_css?('#content .contextual .issue-1-watcher.icon-fav-off')
  end

  def test_bulk_watch_issues_via_context_menu
    log_user('jsmith', 'jsmith')
    visit '/issues'
    jsmith = User.find_by_login('jsmith')
    issue1 = Issue.find(1)
    issue4 = Issue.find(4)
    assert_not issue1.reload.watched_by?(jsmith)
    assert_not issue4.reload.watched_by?(jsmith)
    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav-off')
    assert_difference 'Watcher.count', 2 do
      within('#context-menu') do
        find_link('Watch').hover.click
      end
      # wait for ajax response
      assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
      assert page.has_css?('tr#issue-1')
      assert page.has_css?('tr#issue-4')
    end
    assert issue1.reload.watched_by?(jsmith)
    assert issue4.reload.watched_by?(jsmith)
  end

  def test_bulk_update_issues
    log_user('jsmith', 'jsmith')
    visit '/issues'
    issue1 = Issue.find(1)
    issue4 = Issue.find(4)
    assert_equal 1, issue1.reload.status.id
    assert_equal 1, issue4.reload.status.id
    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    within('#context-menu') do
      click_link 'Status'
      click_link 'Closed'
    end
    assert page.has_css?('#flash_notice')
    assert_equal 5, issue1.reload.status.id
    assert_equal 5, issue4.reload.status.id
  end

  def test_bulk_edit
    log_user('jsmith', 'jsmith')
    visit '/issues'
    issue1 = Issue.find(1)
    issue4 = Issue.find(4)
    assert_equal 1, issue1.reload.status.id
    assert_equal 1, issue4.reload.status.id
    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    within('#context-menu') do
      click_link 'Bulk edit'
    end
    assert_current_path '/issues/bulk_edit', :ignore_query => true
    submit_buttons = page.all('input[type=submit]')
    assert_equal 1, submit_buttons.size
    assert_equal 'Submit', submit_buttons[0].value

    page.find('#issue_status_id').select('Assigned')
    assert_no_difference 'Issue.count' do
      submit_buttons[0].click
      # wait for ajax response
      assert page.has_css?('#flash_notice')
      assert_current_path '/issues', :ignore_query => true
    end
    assert_equal 2, issue1.reload.status.id
    assert_equal 2, issue4.reload.status.id

    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    within('#context-menu') do
      click_link 'Bulk edit'
    end
    assert_current_path '/issues/bulk_edit', :ignore_query => true
    submit_buttons = page.all('input[type=submit]')
    assert_equal 1, submit_buttons.size
    assert_equal 'Submit', submit_buttons[0].value

    page.find('#issue_project_id').select('OnlineStore')
    # wait for ajax response
    assert page.has_select?('issue_project_id', selected: 'OnlineStore')

    submit_buttons = page.all('input[type=submit]')
    assert_equal 2, submit_buttons.size
    assert_equal 'Move', submit_buttons[0].value
    assert_equal 'Move and follow', submit_buttons[1].value

    page.find('#issue_status_id').select('Feedback')
    assert_no_difference 'Issue.count' do
      submit_buttons[1].click
      # wait for ajax response
      assert page.has_css?('#flash_notice')
      assert_current_path '/projects/onlinestore/issues', :ignore_query => true
    end

    issue1.reload
    issue4.reload
    assert_equal 2, issue1.project.id
    assert_equal 4, issue1.status.id
    assert_equal 2, issue4.project.id
    assert_equal 4, issue4.status.id
  end

  def test_bulk_copy
    log_user('jsmith', 'jsmith')
    visit '/issues'
    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    within('#context-menu') do
      click_link 'Copy'
    end
    assert_current_path '/issues/bulk_edit', :ignore_query => true
    submit_buttons = page.all('input[type=submit]')
    assert_equal 'Copy', submit_buttons[0].value

    page.find('#issue_priority_id').select('Low')
    assert_difference 'Issue.count', 2 do
      submit_buttons[0].click
      # wait for ajax response
      assert page.has_css?('#flash_notice')
      assert_current_path '/issues', :ignore_query => true
    end

    copies = Issue.order('id DESC').limit(2)
    assert_equal 4, copies[0].priority.id
    assert_equal 4, copies[1].priority.id

    assert page.has_css?('tr#issue-1')
    assert page.has_css?('tr#issue-4')
    find('tr#issue-1 input[type=checkbox]').click
    find('tr#issue-4 input[type=checkbox]').click
    find('tr#issue-1 td.updated_on').right_click
    within('#context-menu') do
      click_link 'Copy'
    end
    assert_current_path '/issues/bulk_edit', :ignore_query => true
    submit_buttons = page.all('input[type=submit]')
    assert_equal 'Copy', submit_buttons[0].value

    page.find('#issue_project_id').select('OnlineStore')
    # wait for ajax response
    assert page.has_select?('issue_project_id', selected: 'OnlineStore')

    submit_buttons = page.all('input[type=submit]')
    assert_equal 2, submit_buttons.size
    assert_equal 'Copy', submit_buttons[0].value
    assert_equal 'Copy and follow', submit_buttons[1].value
    page.find('#issue_priority_id').select('High')
    assert_difference 'Issue.count', 2 do
      submit_buttons[1].click
      # wait for ajax response
      assert page.has_css?('#flash_notice')
      assert_current_path '/projects/onlinestore/issues', :ignore_query => true
    end

    copies = Issue.order('id DESC').limit(2)
    assert_equal 2, copies[0].project.id
    assert_equal 6, copies[0].priority.id
    assert_equal 2, copies[1].project.id
    assert_equal 6, copies[1].priority.id
  end

  def test_issue_list_with_default_totalable_columns
    log_user('admin', 'admin')
    with_settings :issue_list_default_totals => ['estimated_hours'] do
      visit '/projects/ecookbook/issues'
      # Check that the page shows the Estimated hours total
      assert page.has_css?('p.query-totals')
      assert page.has_css?('span.total-for-estimated-hours')
      # Open the Options of the form (necessary for having the totalable columns options clickable)
      page.all('legend')[1].click
      # Deselect the default totalable column (none should be left)
      page.first('input[name="t[]"][value="estimated_hours"]').click
      within('#query_form') do
        click_link 'Apply'
      end
      # Check that Totals are not present in the reloaded page
      assert !page.has_css?('p.query-totals')
      assert !page.has_css?('span.total-for-estimated-hours')
    end
  end

  def test_update_journal_notes_with_preview
    log_user('admin', 'admin')

    visit '/issues/1'
    assert page.first('#journal-2-notes').has_content?('Some notes with Redmine links')
    # Click on the edit button
    page.first('#change-2 a.icon-edit').click
    # Check that the textarea is displayed
    assert page.has_css?('#change-2 textarea')
    assert page.first('#change-2 textarea').has_content?('Some notes with Redmine links')
    # Update the notes
    fill_in 'Notes', :with => 'Updated notes'
    # Preview the change
    page.first('#change-2 a.tab-preview').click
    assert page.has_css?('#preview_journal_2_notes')
    assert page.first('#preview_journal_2_notes').has_content?('Updated notes')
    # Save
    click_on 'Save'

    assert page.first('#journal-2-notes').has_content?('Updated notes')
    assert_equal 'Updated notes', Journal.find(2).notes
  end

  def test_index_as_csv_should_reflect_sort
    log_user('admin', 'admin')

    visit '/issues'
    # Sort issues by subject
    click_on 'Subject'
    click_on 'CSV'
    click_on 'Export'

    csv = CSV.read(downloaded_file("issues.csv"))
    subject_index = csv.shift.index('Subject')
    subjects = csv.map {|row| row[subject_index]}
    assert_equal subjects.sort, subjects
  end

  def test_issue_trackers_description_should_select_tracker
    log_user('admin', 'admin')

    visit '/issues/1'
    page.driver.execute_script('$.fx.off = true;')
    page.first(:link, 'Edit').click
    page.click_link('View all trackers description')
    assert page.has_css?('#trackers_description')
    within('#trackers_description') do
      click_link('Feature')
    end

    assert !page.has_css?('#trackers_description')
    assert_equal "2", page.find('select#issue_tracker_id').value
  end

  def test_edit_should_allow_adding_multiple_relations_from_autocomplete
    log_user('admin', 'admin')

    visit '/issues/1'
    page.find('#relations .contextual a').click
    page.fill_in 'relation[issue_to_id]', :with => 'issue'

    within('ul.ui-autocomplete') do
      assert page.has_text? 'Bug #12: Closed issue on a locked version'
      assert page.has_text? 'Bug #11: Closed issue on a closed version'

      first('li.ui-menu-item').click
    end
    assert_equal '12, ', find('#relation_issue_to_id').value

    find('#relation_issue_to_id').click.send_keys('issue due')
    within('ul.ui-autocomplete') do
      assert page.has_text? 'Bug #7: Issue due today'

      find('li.ui-menu-item').click
    end
    assert_equal '12, 7, ', find('#relation_issue_to_id').value

    find('#relations').click_button('Add')

    within('#relations table.issues') do
      assert page.has_text? 'Related to Bug #12'
      assert page.has_text? 'Related to Bug #7'
    end
  end

  def test_update_issue_form_should_include_time_entry_form_only_for_users_with_permission
    log_user('jsmith', 'jsmith')

    visit '/issues/2'
    page.first(:link, 'Edit').click

    # assert log time form exits for user with required permissions on the current project
    assert page.has_css?('#log_time')

    # Change project to trigger an update on issue form
    page.find('#issue_project_id').select('» Private child of eCookbook')
    wait_for_ajax

    # assert log time form does not exist anymore for user without required permissions on the new project
    assert_not page.has_css?('#log_time')
  end

  def test_update_issue_form_should_include_add_notes_form_only_for_users_with_permission
    log_user('jsmith', 'jsmith')

    visit '/issues/2'
    page.first(:link, 'Edit').click

    # assert add notes form exits for user with required permissions on the current project
    assert page.has_css?('#add_notes')

    # remove add issue notes permission from Manager role
    Role.find_by_name('Manager').remove_permission! :add_issue_notes

    # Change project to trigger an update on issue form
    page.find('#issue_project_id').select('» Private child of eCookbook')
    wait_for_ajax

    # assert add notes form does not exist anymore for user without required permissions on the new project
    assert_not page.has_css?('#add_notes')
  end
end