mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Display CMS pages in menu
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
before_filter :load_data_for_menu
|
||||
before_filter :load_data_for_sidebar
|
||||
|
||||
private
|
||||
def load_data_for_menu
|
||||
@cms_site = Cms::Site.where(:identifier => 'open-food-web').first
|
||||
end
|
||||
|
||||
|
||||
def load_data_for_sidebar
|
||||
@suppliers = Spree::Supplier.all
|
||||
@distributors = Spree::Distributor.with_active_products_on_hand.by_name
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
%li#home-link{'data-hook' => ''}
|
||||
= link_to t(:home), root_path
|
||||
|
||||
- if @cms_site
|
||||
- @cms_site.pages.root.children.published.each do |page|
|
||||
%li= link_to page.label, page.full_path
|
||||
|
||||
%li#link-to-cart{'data-hook' => ''}
|
||||
= link_to_cart
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ end
|
||||
# -- CMS
|
||||
FactoryGirl.define do
|
||||
factory :cms_site, :class => Cms::Site do
|
||||
identifier 'site'
|
||||
label 'site'
|
||||
identifier 'open-food-web'
|
||||
label 'Open Food Web'
|
||||
hostname 'localhost'
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ FactoryGirl.define do
|
||||
factory :cms_page, :class => Cms::Page do
|
||||
site { Cms::Site.first || create(:cms_site) }
|
||||
label 'page'
|
||||
slug 'page'
|
||||
sequence(:slug) { |n| "page-#{n}" }
|
||||
layout { Cms::Layout.first || create(:cms_layout) }
|
||||
|
||||
# Pass content through to block, where it is stored
|
||||
|
||||
@@ -11,7 +11,7 @@ feature %q{
|
||||
|
||||
scenario "viewing the home page" do
|
||||
# Given a CMS home page
|
||||
cms_page = create(:cms_page, content: 'Home page content')
|
||||
create(:cms_page, content: 'Home page content')
|
||||
|
||||
# When I visit the home page
|
||||
visit spree.root_path
|
||||
@@ -20,4 +20,20 @@ feature %q{
|
||||
page.should have_content 'Home page content'
|
||||
end
|
||||
|
||||
scenario "viewing the menu of CMS pages" do
|
||||
# Given some CMS pages
|
||||
home_page = create(:cms_page, content: 'Home')
|
||||
create(:cms_page, parent: home_page, label: 'One')
|
||||
create(:cms_page, parent: home_page, label: 'Two')
|
||||
create(:cms_page, parent: home_page, label: 'Three')
|
||||
|
||||
# When I visit the home page
|
||||
visit spree.root_path
|
||||
|
||||
# Then I should see a menu with these pages
|
||||
page.should have_selector 'ul#main-nav-bar li', :text => 'One'
|
||||
page.should have_selector 'ul#main-nav-bar li', :text => 'Two'
|
||||
page.should have_selector 'ul#main-nav-bar li', :text => 'Three'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user