Skip to content

Commit 9acbbc6

Browse files
committed
Show notifications from 7 days before or after product year
1 parent 85e2ba5 commit 9acbbc6

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/controllers/hub/user_notifications_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ class UserNotificationsController < Hub::BaseController
55

66
def index
77
@page_title = I18n.t("hub.clients.navigation.notifications")
8-
@user_notifications = current_user.notifications.where('created_at >= ?', Date.new(Rails.configuration.product_year)).order(created_at: :desc).page(params[:page])
8+
cutoff = [
9+
app_time - 7.days,
10+
Date.new(Rails.configuration.product_year)
11+
].min
12+
@user_notifications = current_user.notifications
13+
.where('created_at >= ?', cutoff)
14+
.order(created_at: :desc).page(params[:page])
915
end
1016

1117
def mark_all_notifications_read

spec/features/hub/bulk_actions_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727

2828
click_on "Change organization"
2929

30-
expect(page).to have_text "You’ve selected Change Organization for 2 clients"
30+
page_change_check("You’ve selected Change Organization for 2 clients")
3131
select "Orange Organization", from: "New organization"
3232
fill_in "Send message (English)", with: "Orange is your best bet"
3333
fill_in "Send message (Spanish)", with: "Naranja es la mejor"
3434
fill_in "Add an internal note", with: "Moved!"
3535
click_on "Submit"
3636

37-
expect(current_path).to eq hub_user_notifications_path
37+
page_change_check(hub_user_notifications_path, path: true)
3838
perform_enqueued_jobs
3939
visit page.current_path
4040
expect(page).to have_text "You successfully moved 2 clients to Orange Organization."
@@ -51,12 +51,12 @@
5151
click_on "Nombre"
5252
end
5353
click_on "Notes"
54-
expect(page).to have_text "Moved!"
54+
page_change_check("Moved!")
5555

5656
perform_enqueued_jobs
5757

5858
click_on "Messages"
59-
expect(page).to have_text "Naranja es la mejor"
59+
page_change_check("Naranja es la mejor")
6060

6161
visit hub_user_notifications_path
6262
within ".in-progress" do
@@ -86,12 +86,12 @@
8686

8787
click_on "Send a message"
8888

89-
expect(page).to have_text "You’ve selected Send a Message for 2 clients"
89+
page_change_check("You’ve selected Send a Message for 2 clients")
9090
fill_in "Send message (English)", with: "Orange is your best bet"
9191
fill_in "Send message (Spanish)", with: "Naranja es la mejor"
9292
click_on "Submit"
9393

94-
expect(current_path).to eq hub_user_notifications_path
94+
page_change_check(hub_user_notifications_path, path: true)
9595
perform_enqueued_jobs
9696
visit page.current_path
9797
expect(page).to have_text "Bulk Send a Message In Progress"
@@ -106,7 +106,7 @@
106106
click_on "Nombre"
107107
end
108108
click_on "Messages"
109-
expect(page).to have_text "Naranja es la mejor"
109+
page_change_check("Naranja es la mejor")
110110

111111
visit hub_user_notifications_path
112112
within ".in-progress" do
@@ -117,7 +117,7 @@
117117
click_on "Name"
118118
end
119119
click_on "Messages"
120-
expect(page).to have_text "Orange is your best bet"
120+
page_change_check("Orange is your best bet")
121121
end
122122

123123
scenario "bulk changing assignee and/or status", js: true do

0 commit comments

Comments
 (0)