Permalink
Browse files

RC2

* Fix bug where named PageRoutes couldn't be referenced in portlet views
* Fixed issue where page routes couldn't be created in
  • Loading branch information...
1 parent e6f1076 commit 39c7d8cd44c51936b1ae4f7cc24fbd8383a65634 @peakpg peakpg committed May 22, 2012
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- browsercms (3.5.0.rc1)
+ browsercms (3.5.0.rc2)
ancestry (~> 1.2.4)
ckeditor_rails (~> 3.6.2.2)
jquery-rails (~> 2.0)
@@ -109,7 +109,7 @@ GEM
multi_json (1.3.5)
mysql2 (0.3.11)
nokogiri (1.5.2)
- paperclip (3.0.3)
+ paperclip (3.0.4)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
@@ -21,8 +21,8 @@ class Cms::PageRoute < ActiveRecord::Base
has_many :conditions, :class_name => 'Cms::PageRouteCondition'
has_many :requirements, :class_name => 'Cms::PageRouteRequirement'
- include Cms::DefaultAccessible
-
+ attr_accessible :name, :pattern, :code, :page_id, :page
+
validates_presence_of :pattern, :page_id
validates_uniqueness_of :pattern
@@ -29,6 +29,9 @@ def initialize(controller, attributes_to_assign)
# Make all Route helpers available in the view, i.e. cms_xyz_path and cms_xyz_url
self.class.send(:include, Cms::Engine.routes.url_helpers)
+ # Need to add Cms::PageRoute helpers to the view
+ self.class.send(:include, Rails.application.routes.url_helpers)
+
# See what values are getting copied into template
# Rails.logger.warn "Assigned these variables: #{attributes_to_assign}"
@@ -63,6 +63,12 @@ Feature: Manage Content Blocks
And I click on "next_page_link"
Then I should see the second page of content
+ Scenario: Custom Page Routes
+ Given there is a page route for viewing a product
+ And I am a guest
+ When I view a page that lists products
+ Then I should be able to click on a link to see a product
+
@@ -27,4 +27,25 @@
page = FactoryGirl.create(:public_page)
page.add_content(@subject)
page.publish!
+end
+
+Given /^there is a page route for viewing a product$/ do
+ page = FactoryGirl.create(:public_page, :name=>"View Product", :path=>"/products/view")
+ route = page.page_routes.build(:name=>"Product", :pattern=>"/products/view/:id", :code=>"# Non-blank code")
+ route.save!
+
+ portlet_page = FactoryGirl.create(:public_page, :name=>"Product Catalog", :path=>"/products/list")
+ portlet_page.add_content(ProductCatalogPortlet.create!(:name=>"Catalog"))
+ portlet_page.publish!
+
+ product = Product.create!(:name => "A Widget", :publish_on_save=>true)
+
+end
+
+When /^I view a page that lists products$/ do
+ visit "/products/list"
+end
+
+Then /^I should be able to click on a link to see a product$/ do
+ assert page.has_content?("A Widget")
end
View
@@ -2,7 +2,7 @@
# Allows the precise version of BrowserCMS to be determined programatically.
#
module Cms
- VERSION = "3.5.0.rc1"
+ VERSION = "3.5.0.rc2"
# Return the current version of the CMS.
def self.version
@@ -0,0 +1,10 @@
+class ProductCatalogPortlet < Cms::Portlet
+
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
+ enable_template_editor false
+
+ def render
+ # Your Code Goes Here
+ end
+
+end
@@ -0,0 +1,2 @@
+<%= f.cms_text_field :name %>
+<%= f.cms_template_editor :template %>
@@ -0,0 +1,6 @@
+<b>Product Catalog</b>
+
+We have: <%= Product.all.size %> products. <br>
+<% Product.all.each do |p| %>
+ <%= link_to "View #{p.name}", product_path(:id => p.id) %> <br />
+<% end %>
@@ -5,6 +5,9 @@ def setup
@route = Cms::PageRoute.new(:pattern=>"/:some/:pattern", :name=>"My Name")
end
+ test "mass assignment" do
+ route = Cms::PageRoute.new(:pattern=>"/:some/:pattern", :name=>"My Name", :code=>"# Do somethings")
+ end
def test_create
page = create(:page, :path => "/things/overview")

0 comments on commit 39c7d8c

Please sign in to comment.