Skip to content

Commit 494b71b

Browse files
committed
Add test
1 parent 9acbbc6 commit 494b71b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

spec/controllers/hub/user_notifications_controller_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,35 @@
157157
end
158158
end
159159
end
160+
161+
context "when there are notifications before the product year" do
162+
let(:before_product_year) { DateTime.new(Rails.configuration.product_year) - 1.month }
163+
let!(:old_notification) { create :user_notification, user: user, read: false, created_at: before_product_year }
164+
165+
context "app_time is before the start of the current product year" do
166+
it "shows notifications from the last 7 days" do
167+
Timecop.freeze(before_product_year) do
168+
get :index
169+
170+
expect(response).to be_ok
171+
expect(assigns(:user_notifications)).to include old_notification
172+
expect(assigns(:user_notifications)).to include notification_first
173+
end
174+
end
175+
end
176+
177+
context "app_time is after the start of the product year" do
178+
it "shows notifications from the beginning of the year" do
179+
Timecop.freeze(DateTime.new(Rails.configuration.product_year) + 5.month) do
180+
get :index
181+
182+
expect(response).to be_ok
183+
expect(assigns(:user_notifications)).not_to include old_notification
184+
expect(assigns(:user_notifications)).to include notification_first
185+
end
186+
end
187+
end
188+
end
160189
end
161190
end
162191

0 commit comments

Comments
 (0)