-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #968 from gamecat2d/967-displaying-navbar
967: displaying the navbar conditionnaly
- Loading branch information
Showing
10 changed files
with
52 additions
and
37 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module NavbarVisibility | ||
NAVBAR_HIDEABLE = { | ||
'announcements' => ['new', 'create'], | ||
'asks' => ['new', 'create'], | ||
'community_ressources' => ['new', 'show'], | ||
'offers' => ['new', 'create'], | ||
'public_pages' => ['about', 'contributions', 'landing_page', 'version'], | ||
'thank_you' => ['show'] | ||
} | ||
|
||
def self.shown?(controller, action, display_navbar) | ||
display_navbar || !hidden?(controller, action) | ||
end | ||
|
||
def self.hidden?(controller, action) | ||
NAVBAR_HIDEABLE[controller]&.include?(action) | ||
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
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe NavbarVisibility do | ||
context "when the settings are 'on' to displaying the navbar" do | ||
let(:display_navbar) { true } | ||
|
||
it "should return true for the pages where the navbar can be hidden" do | ||
subject::NAVBAR_HIDEABLE.each do |controller, actions| | ||
actions.each { |action| expect(subject.shown?(controller, action, display_navbar)).to eq(true) } | ||
end | ||
end | ||
|
||
it "should return true for the pages not concerned by the displaying option" do | ||
expect(subject.shown?('always_displayed_controller', 'index', display_navbar)) | ||
end | ||
end | ||
|
||
context "when the settings are 'off' to displaying the navbar" do | ||
let(:display_navbar) { false } | ||
|
||
it "should return false for the pages where the navbar can be hidden" do | ||
subject::NAVBAR_HIDEABLE.each do |controller, actions| | ||
actions.each { |action| expect(subject.shown?(controller, action, display_navbar)).to eq(false) } | ||
end | ||
end | ||
|
||
it "should return true for the pages not concerned by the displaying option" do | ||
expect(subject.shown?('always_displayed_controller', 'index', display_navbar)) | ||
end | ||
end | ||
end |