-
-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "banners/new", type: :view do | ||
context "when new banner is marked as inactive" do | ||
it "does not warn that current active banner will be deactivated" do | ||
user = build_stubbed(:casa_admin) | ||
current_organization = user.casa_org | ||
current_organization_banner = build(:banner, active: true, casa_org: current_organization) | ||
|
||
allow(view).to receive(:current_user).and_return(user) | ||
allow(view).to receive(:current_organization).and_return(current_organization) | ||
|
||
assign :banners, [current_organization_banner] | ||
assign :banner, Banner.new(active: false) | ||
assign :has_alternate_active_banner, true | ||
|
||
render template: "banners/new" | ||
|
||
expect(rendered).not_to have_checked_field("banner_active") | ||
expect(rendered).to have_css("span.d-none", text: "Warning: This will replace your current active banner") | ||
end | ||
end | ||
|
||
context "when organization has an active banner" do | ||
context "when new banner is marked as active" do | ||
it "warns that current active banner will be deactivated" do | ||
user = build_stubbed(:casa_admin) | ||
current_organization = user.casa_org | ||
current_organization_banner = build(:banner, active: true, casa_org: current_organization) | ||
|
||
allow(view).to receive(:current_user).and_return(user) | ||
allow(view).to receive(:current_organization).and_return(current_organization) | ||
|
||
assign :banners, [current_organization_banner] | ||
assign :banner, Banner.new(active: true) | ||
assign :has_alternate_active_banner, true | ||
|
||
render template: "banners/new" | ||
|
||
expect(rendered).to have_checked_field("banner_active") | ||
expect(rendered).not_to have_css("span.d-none", text: "Warning: This will replace your current active banner") | ||
end | ||
end | ||
end | ||
|
||
context "when organization has no active banner" do | ||
context "when new banner is marked as active" do | ||
it "does not warn that current active banner will be deactivated" do | ||
user = build_stubbed(:casa_admin) | ||
current_organization = user.casa_org | ||
|
||
allow(view).to receive(:current_user).and_return(user) | ||
allow(view).to receive(:current_organization).and_return(current_organization) | ||
|
||
assign :banners, [] | ||
assign :banner, Banner.new(active: true) | ||
assign :has_alternate_active_banner, false | ||
|
||
render template: "banners/new" | ||
|
||
expect(rendered).to have_checked_field("banner_active") | ||
expect(rendered).to have_css("span.d-none", text: "Warning: This will replace your current active banner") | ||
end | ||
end | ||
end | ||
end |