CMS content on home page

This commit is contained in:
Rohan Mitchell
2012-10-11 16:21:33 +11:00
parent 015b7f88b0
commit cab61ddb7c
4 changed files with 63 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
Spree::OrdersController.class_eval do
before_filter :populate_order_distributor, :only => :populate
after_filter :populate_variant_attributes, :only => :populate
before_filter :populate_order_distributor, :only => :populate
after_filter :populate_variant_attributes, :only => :populate
def populate_order_distributor
@distributor = params[:distributor_id].present? ? Spree::Distributor.find(params[:distributor_id]) : nil

View File

@@ -1,3 +1,5 @@
= cms_page_content(:content, Cms::Page.find_by_full_path('/'))
- if @products
#products= render 'spree/shared/products', :products => @products, :taxon => @taxon
- else

View File

@@ -76,3 +76,39 @@ FactoryGirl.modify do
country { Spree::Country.find_by_name 'Australia' || Spree::Country.first }
end
end
# -- CMS
FactoryGirl.define do
factory :cms_site, :class => Cms::Site do
identifier 'site'
label 'site'
hostname 'localhost'
end
factory :cms_layout, :class => Cms::Layout do
site { Cms::Site.first || create(:cms_site) }
label 'layout'
identifier 'layout'
content '{{ cms:page:content:text }}'
end
factory :cms_page, :class => Cms::Page do
site { Cms::Site.first || create(:cms_site) }
label 'page'
slug 'page'
layout { Cms::Layout.first || create(:cms_layout) }
# Pass content through to block, where it is stored
after(:create) do |cms_page, evaluator|
cms_page.blocks.first.update_attribute(:content, evaluator.content)
cms_page.save! # set_cached_content
end
end
factory :cms_block, :class => Cms::Block do
page { Cms::Page.first || create(:cms_page) }
identifier 'block'
content 'hello, block'
end
end

View File

@@ -0,0 +1,23 @@
require 'spec_helper'
feature %q{
In order to learn about food
As a user of the site
I want to see static content pages
} do
include AuthenticationWorkflow
include WebHelper
scenario "viewing the home page" do
# Given a CMS home page
cms_page = create(:cms_page, content: 'Home page content')
# When I visit the home page
visit spree.root_path
# Then I should see my content
page.should have_content 'Home page content'
end
end