Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tweak tests and README

  • Loading branch information...
commit 64d5311e2bbc3fa83d51643931d554fa93c8de56 1 parent 9a99bc6
@matthewfallshaw matthewfallshaw authored
View
5 README
@@ -1,3 +1,8 @@
= Page Preview
An extension to preview editing a page in it's enclosing layout to give the author an idea of what the output will be like.
+
+== Installation
+
+ git clone git://github.com/tricycle/radiant-page-preview-extension.git vendor/extensions/page_preview
+ rake radiant:extensions:page_preview:update
View
11 app/controllers/preview_controller.rb
@@ -1,11 +1,12 @@
class PreviewController < ApplicationController
- skip_before_filter :verify_authenticity_token
layout false
def show
Page.transaction do # what a horrible way to achieve readonly-ness :(
- construct_page.process(request,response)
- @performed_render = true
- raise "Don't you dare save any changes"
+ PagePart.transaction do
+ construct_page.process(request,response)
+ @performed_render = true
+ raise "Don't you dare save any changes"
+ end
end
rescue => exception
render :text => exception.message unless @performed_render
@@ -37,4 +38,4 @@ def construct_page
end
return page
end
-end
+end
View
2  public/javascripts/page_preview.js
@@ -4,7 +4,7 @@ function write_to_iframe(text) {
$('page-preview').parentNode.removeChild($('page-preview'));
var iframe = document.createElement('iframe');
iframe.id = 'page-preview';
- iframe.setAttribute('style','width:100%;height:40em;display:none;border:1px solid black;')
+ iframe.setAttribute('style','width:100%;height:40em;display:none;border:1px solid black;margin-top:0.3em')
iframe.setAttribute('frameborder','0');
$('preview_container').appendChild(iframe);
var doc = $('page-preview').contentDocument;
View
34 spec/controllers/preview_controller_spec.rb
@@ -4,7 +4,7 @@ class TestPage < Page
end
describe PreviewController do
- scenario :users
+ scenario :users, :home_page
before(:each) do
login_as :admin
end
@@ -19,14 +19,22 @@ class TestPage < Page
PreviewController.class_eval { public :construct_page }
end
before(:each) do
- controller.stub!(:params).and_return({:page => {:class_name => 'page'}.with_indifferent_access}.with_indifferent_access)
+ controller.stub!(:params).
+ and_return({:page => {:class_name => 'page'}.with_indifferent_access}.with_indifferent_access)
end
+ describe 'any page', :shared => true do
+ it 'should not save any changes'
+ it 'should contain parts created'
+ it 'should contain new parts contents'
+ end
+
describe 'new child' do
before do
Page.stub!(:find).and_return Page.new(:id => 1)
request.stub!(:referer).and_return('/admin/pages/1/child/new')
controller.stub!(:request).and_return(request)
end
+ it_should_behave_like "any page"
it 'should get the referrer' do
request.should_receive(:referer).at_least(:once)
controller.construct_page
@@ -49,12 +57,20 @@ class TestPage < Page
Page.stub!(:find).and_return parent
controller.construct_page.parent.should == parent
end
+ it 'should not save' do
+ debugger
+ end
+ end
+ describe 'edit existing page' do
+ before do
+
+ end
+ it_should_behave_like "any page"
+ it 'should have the original pages children'
+ it 'should have the original pages parent'
+ it 'should not contain parts deleted'
+ it 'should complain if page class has changed on page edit'
+ it 'should have params attributes, not the existing page attributes'
end
end
- it 'should not save any changes'
- it 'should have the original pages children'
- it 'should have the original pages parent'
- it 'should not contain parts deleted'
- it 'should contain parts created'
- it 'should contain new parts contents'
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.