You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
12 months ago
|
require "rails_helper"
|
||
|
require_relative "form/helpers"
|
||
|
|
||
3 months ago
|
RSpec.describe "Notifications Features" do
|
||
12 months ago
|
include Helpers
|
||
|
|
||
|
context "when there are notifications" do
|
||
|
let!(:user) { FactoryBot.create(:user) }
|
||
|
|
||
|
context "when the notifications are currently active" do
|
||
|
before do
|
||
3 months ago
|
create(:notification, start_date: Time.zone.yesterday, title: "Notification title 1")
|
||
|
create(:notification, start_date: Time.zone.yesterday, end_date: Time.zone.tomorrow, title: "Notification title 2")
|
||
12 months ago
|
sign_in user
|
||
3 months ago
|
visit(root_path)
|
||
12 months ago
|
end
|
||
|
|
||
3 months ago
|
it "shows the notification banner" do
|
||
|
expect(page).to have_content("Notification 1 of")
|
||
|
expect(page).to have_link("Dismiss")
|
||
12 months ago
|
end
|
||
|
end
|
||
|
|
||
|
context "when the notifications are not currently active" do
|
||
|
before do
|
||
3 months ago
|
create(:notification, start_date: Time.zone.yesterday, end_date: Time.zone.yesterday, title: "Notification title 1")
|
||
12 months ago
|
create(:notification, start_date: Time.zone.tomorrow, title: "Notification title 2")
|
||
3 months ago
|
create(:notification, start_date: nil, title: "Notification title 3")
|
||
12 months ago
|
sign_in user
|
||
3 months ago
|
visit(root_path)
|
||
12 months ago
|
end
|
||
|
|
||
|
it "does not show the notifications banner" do
|
||
|
expect(page).not_to have_content("Notification 1 of")
|
||
|
expect(page).not_to have_link("Dismiss")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|