|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | RSpec.describe "notifications/index", type: :view do |
4 | | - let(:base_time) { Date.new(2025, 1, 2) } |
5 | 4 | let(:notification_1_hour_ago) { create(:notification, :followup_with_note) } |
6 | 5 | let(:notification_1_day_ago) { create(:notification, :emancipation_checklist_reminder) } |
7 | 6 | let(:notification_2_days_ago) { create(:notification, :youth_birthday) } |
|
15 | 14 | let(:patch_note_2) { create(:patch_note, note: "Patch Note B", patch_note_type: patch_note_type_b) } |
16 | 15 |
|
17 | 16 | before do |
18 | | - assign(:notifications, Noticed::Notification.all) |
| 17 | + assign(:notifications, Noticed::Notification.all.newest_first) |
19 | 18 | assign(:patch_notes, PatchNote.all) |
20 | 19 | assign(:deploy_time, deploy_time) |
21 | 20 | end |
22 | 21 |
|
23 | 22 | context "when there is a deploy date" do |
24 | | - let(:deploy_time) { base_time - 2.days } |
| 23 | + let(:deploy_time) { 2.days.ago } |
25 | 24 |
|
26 | 25 | before do |
27 | 26 | Health.instance.update_attribute(:latest_deploy_time, deploy_time) |
28 | 27 | end |
29 | 28 |
|
30 | 29 | context "when there are notifications" do |
31 | 30 | before do |
32 | | - notification_1_hour_ago.update_attribute(:created_at, base_time - 1.hour) |
33 | | - notification_1_day_ago.update_attribute(:created_at, base_time - 1.day) |
34 | | - notification_2_days_ago.update_attribute(:created_at, base_time - 2.days) |
35 | | - notification_3_days_ago.update_attribute(:created_at, base_time - 3.days) |
| 31 | + notification_1_hour_ago.update!(created_at: 1.hour.ago) |
| 32 | + notification_1_day_ago.update!(created_at: 1.day.ago) |
| 33 | + notification_2_days_ago.update!(created_at: 2.days.ago) |
| 34 | + notification_3_days_ago.update!(created_at: 3.days.ago) |
36 | 35 |
|
37 | | - patch_note_1.update_attribute(:patch_note_group, patch_note_group_all_users) |
| 36 | + patch_note_1.update!(patch_note_group: patch_note_group_all_users) |
38 | 37 | end |
39 | 38 |
|
40 | 39 | it "has all notifications created after and including the deploy date above the patch note" do |
|
0 commit comments