Skip to content

Commit

Permalink
basic implementation of getting page by controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Campbell authored and Paul Campbell committed Dec 30, 2009
1 parent ffdca2a commit 46cd9ec
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/helpers/shakespeare_helper.rb
@@ -0,0 +1,7 @@
module ShakespeareHelper

def page_content
@page_content = Page.find_by_url("#{controller_name}/#{action_name}")
end

end
2 changes: 1 addition & 1 deletion lib/shakespeare.rb
@@ -1 +1 @@
# Shakespeare
require 'helpers/shakespeare_helper'
2 changes: 1 addition & 1 deletion rails/init.rb
@@ -1 +1 @@
# Include hook code here
require 'shakespeare'
20 changes: 20 additions & 0 deletions spec/helpers/shakespeare_helper_spec.rb
@@ -0,0 +1,20 @@
require 'spec/spec_helper.rb'

describe ShakespeareHelper do

class TestController < ApplicationController
include ShakespeareHelper
end

describe "#page_content" do
before do
@page = mock_model(Page)
Page.stub!(:find_by_url).and_return(@page)
end

it "should pull the page" do
@controller = TestController.new
@controller.page_content.should == @page
end
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -37,4 +37,4 @@ def load_schema
ActiveRecord::Base.establish_connection(config[:mysql])
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../rails/init.rb'
end
end

0 comments on commit 46cd9ec

Please sign in to comment.