|
419 | 419 | end
|
420 | 420 |
|
421 | 421 | context "when multiple users are commenting on a workpackage" do
|
422 |
| - current_user { admin } |
423 |
| - let(:work_package) { create(:work_package, project:, author: admin) } |
| 422 | + context "when the user has permissions to see restricted comments" do |
| 423 | + current_user { admin } |
| 424 | + let(:work_package) { create(:work_package, project:, author: admin) } |
424 | 425 |
|
425 |
| - before do |
426 |
| - # set WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS to 1000 |
427 |
| - # to speed up the polling interval for test duration |
428 |
| - ENV["WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS"] = "1000" |
| 426 | + before do |
| 427 | + # set WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS to 1000 |
| 428 | + # to speed up the polling interval for test duration |
| 429 | + ENV["WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS"] = "1000" |
429 | 430 |
|
430 |
| - # for some reason the journal is set to the "Anonymous" |
431 |
| - # although the work_package is created by the admin |
432 |
| - # so we need to update the journal to the admin manually to simulate the real world case |
433 |
| - work_package.journals.first.update!(user: admin) |
| 431 | + # for some reason the journal is set to the "Anonymous" |
| 432 | + # although the work_package is created by the admin |
| 433 | + # so we need to update the journal to the admin manually to simulate the real world case |
| 434 | + work_package.journals.first.update!(user: admin) |
434 | 435 |
|
435 |
| - wp_page.visit! |
436 |
| - wp_page.wait_for_activity_tab |
437 |
| - end |
| 436 | + wp_page.visit! |
| 437 | + wp_page.wait_for_activity_tab |
| 438 | + end |
438 | 439 |
|
439 |
| - after do |
440 |
| - ENV.delete("WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS") |
| 440 | + after do |
| 441 | + ENV.delete("WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS") |
| 442 | + end |
| 443 | + |
| 444 | + it "shows the comment of another user without browser reload" do |
| 445 | + # simulate member creating a comment |
| 446 | + first_journal = create(:work_package_journal, |
| 447 | + user: member, |
| 448 | + notes: "First comment by member", |
| 449 | + journable: work_package, |
| 450 | + version: 2) |
| 451 | + |
| 452 | + # the comment is shown without browser reload |
| 453 | + activity_tab.expect_journal_notes(text: "First comment by member") |
| 454 | + |
| 455 | + # simulate comments made within the polling interval |
| 456 | + create(:work_package_journal, user: member, notes: "Second comment by member", journable: work_package, version: 3) |
| 457 | + create(:work_package_journal, user: member, notes: "Third comment by member", journable: work_package, version: 4) |
| 458 | + |
| 459 | + activity_tab.add_comment(text: "First comment by admin") |
| 460 | + |
| 461 | + activity_tab.expect_comments_order( |
| 462 | + [ |
| 463 | + "First comment by member", |
| 464 | + "Second comment by member", |
| 465 | + "Third comment by member", |
| 466 | + "First comment by admin" |
| 467 | + ] |
| 468 | + ) |
| 469 | + |
| 470 | + first_journal.update!(notes: "First comment by member updated") |
| 471 | + |
| 472 | + # properly updates the comment when the comment is updated |
| 473 | + activity_tab.expect_journal_notes(text: "First comment by member updated") |
| 474 | + end |
441 | 475 | end
|
442 | 476 |
|
443 |
| - it "shows the comment of another user without browser reload" do |
444 |
| - # simulate member creating a comment |
445 |
| - first_journal = create(:work_package_journal, |
446 |
| - user: member, |
447 |
| - notes: "First comment by member", |
448 |
| - journable: work_package, |
449 |
| - version: 2) |
| 477 | + context "when the user does not have permissions to see restricted comments" do |
| 478 | + current_user { member } |
| 479 | + let(:work_package) { create(:work_package, project:, author: admin) } |
450 | 480 |
|
451 |
| - # the comment is shown without browser reload |
452 |
| - activity_tab.expect_journal_notes(text: "First comment by member") |
| 481 | + before do |
| 482 | + # set WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS to 1000 |
| 483 | + # to speed up the polling interval for test duration |
| 484 | + ENV["WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS"] = "1000" |
453 | 485 |
|
454 |
| - # simulate comments made within the polling interval |
455 |
| - create(:work_package_journal, user: member, notes: "Second comment by member", journable: work_package, version: 3) |
456 |
| - create(:work_package_journal, user: member, notes: "Third comment by member", journable: work_package, version: 4) |
| 486 | + # for some reason the journal is set to the "Anonymous" |
| 487 | + # although the work_package is created by the admin |
| 488 | + # so we need to update the journal to the admin manually to simulate the real world case |
| 489 | + work_package.journals.first.update!(user: admin) |
457 | 490 |
|
458 |
| - activity_tab.add_comment(text: "First comment by admin") |
| 491 | + wp_page.visit! |
| 492 | + wp_page.wait_for_activity_tab |
| 493 | + end |
459 | 494 |
|
460 |
| - activity_tab.expect_comments_order( |
461 |
| - [ |
462 |
| - "First comment by member", |
463 |
| - "Second comment by member", |
464 |
| - "Third comment by member", |
465 |
| - "First comment by admin" |
466 |
| - ] |
467 |
| - ) |
| 495 | + after do |
| 496 | + ENV.delete("WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS") |
| 497 | + end |
468 | 498 |
|
469 |
| - first_journal.update!(notes: "First comment by member updated") |
| 499 | + it "does not show the comment of another user if they don't have permissions to see it" do |
| 500 | + # simulate member creating a comment |
| 501 | + create(:work_package_journal, |
| 502 | + user: admin, |
| 503 | + notes: "First comment by admin", |
| 504 | + journable: work_package, |
| 505 | + version: 2) |
| 506 | + |
| 507 | + # the comment is shown without browser reload |
| 508 | + activity_tab.expect_journal_notes(text: "First comment by admin") |
| 509 | + |
| 510 | + # simulate comments made within the polling interval |
| 511 | + create(:work_package_journal, |
| 512 | + user: admin, |
| 513 | + notes: "Second comment by admin", |
| 514 | + restricted: true, |
| 515 | + journable: work_package, |
| 516 | + version: 3) |
| 517 | + create(:work_package_journal, |
| 518 | + user: admin, |
| 519 | + notes: "Third comment by admin", |
| 520 | + restricted: true, |
| 521 | + journable: work_package, |
| 522 | + version: 4) |
| 523 | + |
| 524 | + activity_tab.add_comment(text: "First comment by member") |
470 | 525 |
|
471 |
| - # properly updates the comment when the comment is updated |
472 |
| - activity_tab.expect_journal_notes(text: "First comment by member updated") |
| 526 | + activity_tab.expect_comments_order( |
| 527 | + [ |
| 528 | + "First comment by admin", |
| 529 | + "First comment by member" |
| 530 | + ] |
| 531 | + ) |
| 532 | + end |
473 | 533 | end
|
474 | 534 | end
|
475 | 535 |
|
|
0 commit comments