-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5428 Banner Dismissed Forever Bug fix
- Loading branch information
Sam Williams
committed
Jan 6, 2024
1 parent
0bc5b9f
commit 39f80ae
Showing
7 changed files
with
111 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
<% banner = current_organization.banners.active.first %> | ||
<% if banner %> | ||
<% cookie_id = "banner_#{banner.id}" %> | ||
<% if !cookies["dismiss_#{cookie_id}"] %> | ||
<div class="bg-secondary-100 text-xl p-5 d-flex" data-controller="dismiss" data-dismiss-target="element"> | ||
<div class=""> | ||
<%= banner.content %> | ||
</div> | ||
<div class="ms-auto"> | ||
<a href="#" data-action="click->dismiss#dismiss" data-dismiss-id-param="<%= cookie_id %>">Dismiss</a> | ||
</div> | ||
<% if @active_banner %> | ||
<div class="bg-secondary-100 text-xl p-5 d-flex" data-controller="dismiss" data-dismiss-target="element" data-dismiss-url-value="<%= dismiss_banner_path(@active_banner) %>"> | ||
<div class=""> | ||
<%= @active_banner.content %> | ||
</div> | ||
<% end %> | ||
<div class="ms-auto"> | ||
<a href="#" data-action="click->dismiss#dismiss">Dismiss</a> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Banners", type: :request do | ||
let!(:casa_org) { create(:casa_org) } | ||
let!(:active_banner) { create(:banner, casa_org: casa_org) } | ||
let(:volunteer) { create(:volunteer, casa_org: casa_org) } | ||
|
||
context "when user dismisses a banner" do | ||
subject do | ||
get dismiss_banner_path(active_banner) | ||
end | ||
|
||
it "sets session variable" do | ||
sign_in volunteer | ||
subject | ||
expect(session[:dismissed_banner]).to eq active_banner.id | ||
end | ||
|
||
it "does not display banner on page reloads" do | ||
sign_in volunteer | ||
get casa_cases_path | ||
expect(response.body).to include "Please fill out this survey" | ||
|
||
subject | ||
get casa_cases_path | ||
expect(response.body).not_to include "Please fill out this survey" | ||
end | ||
|
||
context "when user logs out and back in" do | ||
it "nils out session variable" do | ||
sign_in volunteer | ||
subject | ||
get destroy_user_session_path | ||
sign_in volunteer | ||
|
||
expect(session[:dismissed_banner]).to be_nil | ||
end | ||
|
||
it "displays banner" do | ||
sign_in volunteer | ||
subject | ||
get destroy_user_session_path | ||
sign_in volunteer | ||
|
||
get casa_cases_path | ||
expect(response.body).to include "Please fill out this survey" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "banners/dismiss", type: :system, js: true do | ||
let!(:casa_org) { create(:casa_org) } | ||
let!(:active_banner) { create(:banner, casa_org: casa_org) } | ||
let(:volunteer) { create(:volunteer, casa_org: casa_org) } | ||
|
||
context "when user dismisses a banner" do | ||
it "hides banner" do | ||
sign_in volunteer | ||
|
||
visit root_path | ||
expect(page).to have_text("Please fill out this survey") | ||
|
||
click_on "Dismiss" | ||
expect(page).not_to have_text("Please fill out this survey") | ||
end | ||
end | ||
end |