puffer_pages 0.1.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +3 -1
- data/.rvmrc +1 -1
- data/.travis.yml +13 -5
- data/CHANGELOG.md +130 -7
- data/Gemfile +10 -1
- data/README.md +18 -20
- data/Rakefile +1 -1
- data/app/assets/javascripts/puffer/codemirror.js +4237 -2223
- data/app/assets/javascripts/puffer/codemirror/css.js +359 -18
- data/app/assets/javascripts/puffer/codemirror/htmlmixed.js +15 -14
- data/app/assets/javascripts/puffer/codemirror/javascript.js +91 -29
- data/app/assets/javascripts/puffer/codemirror/liquid.js +185 -0
- data/app/assets/javascripts/puffer/codemirror/xml.js +99 -27
- data/app/assets/javascripts/puffer/codemirror/yaml.js +95 -0
- data/app/assets/javascripts/puffer/liquid.js +28 -12
- data/app/assets/javascripts/puffer/matchbrackets.js +63 -0
- data/app/assets/javascripts/puffer/multiplex.js +95 -0
- data/app/assets/javascripts/puffer/puffer_pages.js +140 -44
- data/app/assets/stylesheets/puffer/codemirror.css +203 -67
- data/app/assets/stylesheets/puffer/codemirror/ambiance-mobile.css +6 -0
- data/app/assets/stylesheets/puffer/codemirror/ambiance.css +76 -0
- data/app/assets/stylesheets/puffer/codemirror/blackboard.css +25 -0
- data/app/assets/stylesheets/puffer/codemirror/cobalt.css +4 -4
- data/app/assets/stylesheets/puffer/codemirror/eclipse.css +1 -1
- data/app/assets/stylesheets/puffer/codemirror/elegant.css +2 -2
- data/app/assets/stylesheets/puffer/codemirror/erlang-dark.css +21 -0
- data/app/assets/stylesheets/puffer/codemirror/lesser-dark.css +44 -0
- data/app/assets/stylesheets/puffer/codemirror/monokai.css +4 -4
- data/app/assets/stylesheets/puffer/codemirror/neat.css +3 -3
- data/app/assets/stylesheets/puffer/codemirror/night.css +4 -4
- data/app/assets/stylesheets/puffer/codemirror/rubyblue.css +5 -5
- data/app/assets/stylesheets/puffer/codemirror/solarized.css +207 -0
- data/app/assets/stylesheets/puffer/codemirror/twilight.css +26 -0
- data/app/assets/stylesheets/puffer/codemirror/vibrant-ink.css +27 -0
- data/app/assets/stylesheets/puffer/codemirror/xq-dark.css +46 -0
- data/app/assets/stylesheets/puffer/puffer_pages.css +64 -35
- data/app/components/codemirror/form.html.erb +22 -6
- data/app/components/codemirror_component.rb +1 -8
- data/app/components/handlers/form.html.erb +8 -0
- data/app/components/handlers_component.rb +8 -0
- data/app/components/page_parts/_page_part.html.erb +6 -0
- data/app/components/page_parts/form.html.erb +8 -27
- data/app/components/page_parts_component.rb +1 -3
- data/app/components/render/_tree_page.html.erb +3 -2
- data/app/controllers/admin/layouts_controller.rb +1 -1
- data/app/controllers/admin/origins_controller.rb +3 -0
- data/app/controllers/admin/pages_controller.rb +1 -1
- data/app/controllers/admin/snippets_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +3 -3
- data/app/helpers/puffer_pages_helper.rb +3 -3
- data/app/models/puffer_pages/layout.rb +2 -7
- data/app/models/puffer_pages/origin.rb +2 -0
- data/app/models/puffer_pages/page.rb +1 -117
- data/app/models/puffer_pages/page_part.rb +2 -22
- data/app/models/puffer_pages/snippet.rb +2 -5
- data/config/routes.rb +3 -0
- data/db/migrate/20120812100913_create_origins.rb +16 -0
- data/db/migrate/20120924120226_migrate_to_uuid.rb +126 -0
- data/db/migrate/20130110144030_add_handler_to_page_parts.rb +9 -0
- data/db/migrate/20130118064524_add_locales_to_pages.rb +9 -0
- data/gemfiles/Gemfile.rails-3-1 +7 -0
- data/gemfiles/Gemfile.rails-3-2 +7 -0
- data/gemfiles/Gemfile.rails-head +7 -0
- data/lib/puffer_pages.rb +43 -7
- data/lib/puffer_pages/backends.rb +16 -0
- data/{app/controllers/puffer_pages → lib/puffer_pages/backends/controllers}/layouts_base.rb +2 -5
- data/lib/puffer_pages/backends/controllers/origins_base.rb +43 -0
- data/lib/puffer_pages/backends/controllers/pages_base.rb +52 -0
- data/{app/controllers/puffer_pages → lib/puffer_pages/backends/controllers}/snippets_base.rb +2 -5
- data/lib/puffer_pages/backends/models/layout.rb +34 -0
- data/lib/puffer_pages/backends/models/mixins/importable.rb +42 -0
- data/lib/puffer_pages/backends/models/mixins/localable.rb +65 -0
- data/lib/puffer_pages/backends/models/mixins/renderable.rb +153 -0
- data/lib/puffer_pages/backends/models/mixins/translatable.rb +52 -0
- data/lib/puffer_pages/backends/models/origin.rb +59 -0
- data/lib/puffer_pages/backends/models/page.rb +221 -0
- data/lib/puffer_pages/backends/models/page_part.rb +71 -0
- data/lib/puffer_pages/backends/models/snippet.rb +34 -0
- data/lib/puffer_pages/engine.rb +13 -2
- data/lib/puffer_pages/extensions/context.rb +31 -0
- data/lib/puffer_pages/extensions/core.rb +1 -8
- data/lib/puffer_pages/extensions/pagenator.rb +69 -0
- data/lib/puffer_pages/extensions/renderer.rb +31 -0
- data/lib/puffer_pages/globalize/migrator.rb +23 -0
- data/lib/puffer_pages/handlers.rb +29 -0
- data/lib/puffer_pages/handlers/base.rb +21 -0
- data/lib/puffer_pages/handlers/yaml.rb +20 -0
- data/lib/puffer_pages/helpers.rb +14 -0
- data/lib/puffer_pages/liquid/backend.rb +16 -0
- data/lib/puffer_pages/liquid/file_system.rb +36 -12
- data/lib/puffer_pages/liquid/page_drop.rb +26 -23
- data/lib/puffer_pages/liquid/tags/array.rb +39 -0
- data/lib/puffer_pages/liquid/tags/{javascripts.rb → assets.rb} +13 -4
- data/lib/puffer_pages/liquid/tags/helper.rb +15 -0
- data/lib/puffer_pages/liquid/tags/include.rb +32 -0
- data/lib/puffer_pages/liquid/tags/javascript.rb +15 -0
- data/lib/puffer_pages/liquid/tags/partials.rb +22 -0
- data/lib/puffer_pages/liquid/tags/render.rb +28 -0
- data/lib/puffer_pages/liquid/tags/scope.rb +31 -0
- data/lib/puffer_pages/liquid/tags/super.rb +36 -0
- data/lib/puffer_pages/liquid/tags/translate.rb +56 -0
- data/lib/puffer_pages/liquid/tags/url.rb +53 -0
- data/lib/puffer_pages/liquid/tags/yield.rb +3 -1
- data/lib/puffer_pages/log_subscriber.rb +29 -0
- data/lib/puffer_pages/migrations.rb +31 -0
- data/lib/puffer_pages/renderer.rb +25 -0
- data/lib/puffer_pages/rspec/matchers.rb +27 -0
- data/lib/puffer_pages/rspec/matchers/render_page.rb +90 -0
- data/lib/puffer_pages/version.rb +1 -1
- data/puffer_pages.gemspec +18 -18
- data/spec/controllers/pages_controller_spec.rb +44 -0
- data/spec/controllers/puffer_pages_controller_spec.rb +194 -0
- data/spec/data/broken.json +8 -0
- data/spec/data/import.json +55 -0
- data/spec/data/localized.json +106 -0
- data/spec/data/unlocalized.json +82 -0
- data/spec/dummy/.rvmrc +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +6 -0
- data/spec/dummy/app/views/layouts/sample.en.erb +1 -0
- data/spec/dummy/app/views/layouts/sample.ru.erb +1 -0
- data/spec/dummy/app/views/shared/_first.html.erb +1 -0
- data/spec/dummy/config/application.rb +21 -2
- data/spec/dummy/config/boot.rb +0 -2
- data/spec/dummy/config/database.yml +7 -1
- data/spec/dummy/config/environments/development.rb +11 -2
- data/spec/dummy/config/environments/pg_test.rb +6 -6
- data/spec/dummy/config/environments/production.rb +19 -3
- data/spec/dummy/config/environments/test.rb +6 -6
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/puffer_pages.rb +4 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +5 -3
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/db/migrate/{20090422092419_create_pages.rb → 20130118071511_create_pages.rb} +1 -0
- data/spec/dummy/db/migrate/{20090504132337_create_page_parts.rb → 20130118071512_create_page_parts.rb} +1 -0
- data/spec/dummy/db/migrate/{20090506102004_create_layouts.rb → 20130118071513_create_layouts.rb} +1 -0
- data/spec/dummy/db/migrate/{20090510121824_create_snippets.rb → 20130118071514_create_snippets.rb} +1 -0
- data/spec/dummy/db/migrate/20130118071515_create_origins.rb +17 -0
- data/spec/dummy/db/migrate/20130118071516_migrate_to_uuid.rb +127 -0
- data/spec/dummy/db/migrate/20130118071517_add_handler_to_page_parts.rb +10 -0
- data/spec/dummy/db/migrate/20130118071518_add_locales_to_pages.rb +10 -0
- data/spec/dummy/db/migrate/20130118071519_add_translations.rb +9 -0
- data/spec/dummy/db/schema.rb +65 -17
- data/spec/fabricators/articles_fabricator.rb +2 -2
- data/spec/fabricators/layouts_fabricator.rb +24 -3
- data/spec/fabricators/origin_fabricator.rb +5 -0
- data/spec/fabricators/page_parts_fabricator.rb +17 -2
- data/spec/fabricators/pages_fabricator.rb +20 -5
- data/spec/fabricators/snippets_fabricator.rb +14 -3
- data/spec/lib/handlers/base_spec.rb +10 -0
- data/spec/lib/handlers/yaml_spec.rb +34 -0
- data/spec/lib/handlers_spec.rb +36 -0
- data/spec/lib/liquid/backend_spec.rb +20 -0
- data/spec/lib/liquid/interpolation_spec.rb +25 -0
- data/spec/lib/liquid/tags/include_spec.rb +38 -0
- data/spec/lib/liquid/tags/partials_spec.rb +39 -0
- data/spec/lib/liquid/tags/scope_spec.rb +18 -0
- data/spec/lib/liquid/tags/translate_spec.rb +107 -0
- data/spec/lib/liquid/tags_spec.rb +81 -0
- data/spec/lib/page_drop_spec.rb +65 -0
- data/spec/lib/pagenator_spec.rb +176 -0
- data/spec/lib/rspec/matchers/render_page_spec.rb +107 -0
- data/spec/models/puffer_pages/layout_spec.rb +15 -0
- data/spec/models/puffer_pages/localable_spec.rb +62 -0
- data/spec/models/puffer_pages/origin_spec.rb +112 -0
- data/spec/models/puffer_pages/page_part_spec.rb +14 -0
- data/spec/models/puffer_pages/page_spec.rb +307 -0
- data/spec/models/puffer_pages/renderable_spec.rb +84 -0
- data/spec/models/puffer_pages/snippet_spec.rb +15 -0
- data/spec/requests/origins_requests_spec.rb +37 -0
- data/spec/spec_helper.rb +7 -6
- metadata +349 -87
- data/Gemfile.lock +0 -176
- data/app/assets/javascripts/puffer/overlay.js +0 -51
- data/app/controllers/puffer_pages/pages_base.rb +0 -38
- data/app/models/layout.rb +0 -2
- data/app/models/page.rb +0 -2
- data/app/models/page_part.rb +0 -2
- data/app/models/snippet.rb +0 -2
- data/app/views/layouts/puffer_pages_layout.html.erb +0 -2
- data/config/puffer_routes.rb +0 -3
- data/gemfiles/Gemfile-rails-3.1 +0 -5
- data/gemfiles/Gemfile-rails-3.1.lock +0 -173
- data/gemfiles/Gemfile-rails-3.2 +0 -5
- data/gemfiles/Gemfile-rails-3.2.lock +0 -171
- data/lib/puffer_pages/extensions/controller.rb +0 -30
- data/lib/puffer_pages/extensions/mapper.rb +0 -23
- data/lib/puffer_pages/liquid/tags/page_attribute.rb +0 -39
- data/lib/puffer_pages/liquid/tags/stylesheets.rb +0 -38
- data/spec/controllers/articles_controller_spec.rb +0 -65
- data/spec/dummy/app/controllers/articles_controller.rb +0 -9
- data/spec/integration/navigation_spec.rb +0 -9
- data/spec/lib/drops_spec.rb +0 -55
- data/spec/lib/tags_spec.rb +0 -98
- data/spec/models/page_spec.rb +0 -235
- data/spec/puffer_pages_spec.rb +0 -7
@@ -0,0 +1,27 @@
|
|
1
|
+
module PufferPages
|
2
|
+
module Rspec
|
3
|
+
module Matchers
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'puffer_pages/rspec/matchers/render_page'
|
10
|
+
|
11
|
+
RSpec::Rails::ControllerExampleGroup.class_eval do
|
12
|
+
def puffer_pages_render
|
13
|
+
@puffer_pages_render
|
14
|
+
end
|
15
|
+
|
16
|
+
included do
|
17
|
+
around(:each) do |example|
|
18
|
+
@puffer_pages_render = {}
|
19
|
+
ActiveSupport::Notifications.subscribe('render_page.puffer_pages') do |name, start, finish, id, payload|
|
20
|
+
@puffer_pages_render[payload[:subject]] ||= []
|
21
|
+
@puffer_pages_render[payload[:subject]].push payload
|
22
|
+
end
|
23
|
+
example.run
|
24
|
+
ActiveSupport::Notifications.unsubscribe('render_page.puffer_pages')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module PufferPages
|
2
|
+
module Rspec
|
3
|
+
module Matchers
|
4
|
+
class RenderPage < ::RSpec::Matchers::BuiltIn::BaseMatcher
|
5
|
+
attr_reader :scope, :page, :drops
|
6
|
+
|
7
|
+
def initialize scope, page = nil
|
8
|
+
@scope = scope
|
9
|
+
@page = page
|
10
|
+
@page = PufferPages::Page.find_page(page) if page.is_a?(String)
|
11
|
+
@drops ||= { values: {}, names: [], manual: [] }
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches? controller_or_request
|
15
|
+
scope.get :index if controller_or_request.is_a?(ActionController::Base)
|
16
|
+
|
17
|
+
rendered_page && (!with_page? || page_conformity) && (!with_drops? || drops_conformity)
|
18
|
+
end
|
19
|
+
|
20
|
+
def with_drops *drops, &block
|
21
|
+
@drops[:values].merge! drops.extract_options!
|
22
|
+
@drops[:names].concat(drops.flatten).uniq!
|
23
|
+
@drops[:manual].push block if block
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def failure_message_for_should
|
28
|
+
message = ''
|
29
|
+
message << "expected action to render #{page_message}\n"
|
30
|
+
message << "with drops #{drops_message}\n" if with_drops?
|
31
|
+
if with_drops? && !drops_conformity
|
32
|
+
rendered_drops = scope.puffer_pages_render[rendered_page].first[:drops]
|
33
|
+
message << "but available drops are: #{PP.pp rendered_drops, ''}"
|
34
|
+
else
|
35
|
+
message << "but #{rendered_page ? "`/#{rendered_page.location}`" : 'nothing'} was rendered"
|
36
|
+
end
|
37
|
+
message
|
38
|
+
end
|
39
|
+
|
40
|
+
def failure_message_for_should_not
|
41
|
+
"expected action not to render #{page_message} but `/#{rendered_page.location}` was rendered"
|
42
|
+
end
|
43
|
+
|
44
|
+
def description
|
45
|
+
"render page #{page_message}"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def page_message
|
51
|
+
page ? "page `/#{page.location}`" : 'any page'
|
52
|
+
end
|
53
|
+
|
54
|
+
def drops_message
|
55
|
+
[drops[:names], drops[:values]].delete_if(&:blank?).map(&:inspect).join ?,
|
56
|
+
end
|
57
|
+
|
58
|
+
def rendered_page
|
59
|
+
@rendered_page ||= scope.puffer_pages_render.keys.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def with_page?
|
63
|
+
!!page
|
64
|
+
end
|
65
|
+
|
66
|
+
def page_conformity
|
67
|
+
scope.puffer_pages_render[rendered_page] &&
|
68
|
+
scope.puffer_pages_render[rendered_page].count == 1 &&
|
69
|
+
rendered_page == page
|
70
|
+
end
|
71
|
+
|
72
|
+
def with_drops?
|
73
|
+
drops.values.any?(&:present?)
|
74
|
+
end
|
75
|
+
|
76
|
+
def drops_conformity
|
77
|
+
rendered_drops = scope.puffer_pages_render[rendered_page].first[:drops]
|
78
|
+
|
79
|
+
rendered_drops.keys | drops[:names] == rendered_drops.keys &&
|
80
|
+
drops[:values].all? { |(name, value)| rendered_drops[name] == value } &&
|
81
|
+
drops[:manual].all? { |block| block.call(rendered_drops) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def render_page page = nil
|
86
|
+
RenderPage.new self, page
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/puffer_pages/version.rb
CHANGED
data/puffer_pages.gemspec
CHANGED
@@ -19,23 +19,23 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
|
-
s.add_runtime_dependency
|
23
|
-
s.add_runtime_dependency
|
24
|
-
s.add_runtime_dependency
|
25
|
-
s.add_runtime_dependency
|
22
|
+
s.add_runtime_dependency "rails", ">= 3.1"
|
23
|
+
s.add_runtime_dependency "puffer"
|
24
|
+
s.add_runtime_dependency "liquid"
|
25
|
+
s.add_runtime_dependency "nested_set"
|
26
|
+
s.add_runtime_dependency "activeuuid", ">= 0.4.0"
|
27
|
+
s.add_runtime_dependency "contextuality"
|
26
28
|
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
34
|
-
s.add_development_dependency
|
35
|
-
s.add_development_dependency
|
36
|
-
|
37
|
-
s.add_development_dependency
|
38
|
-
s.add_development_dependency
|
39
|
-
s.add_development_dependency(%q<libnotify>, [">= 0"])
|
40
|
-
s.add_development_dependency(%q<rb-inotify>, [">= 0"])
|
29
|
+
s.add_development_dependency "bcrypt-ruby"
|
30
|
+
s.add_development_dependency "sqlite3"
|
31
|
+
s.add_development_dependency "pg"
|
32
|
+
s.add_development_dependency "mysql2"
|
33
|
+
s.add_development_dependency "globalize3"
|
34
|
+
s.add_development_dependency "rspec-rails"
|
35
|
+
s.add_development_dependency "shoulda"
|
36
|
+
s.add_development_dependency "database_cleaner"
|
37
|
+
s.add_development_dependency "forgery"
|
38
|
+
s.add_development_dependency "fabrication"
|
39
|
+
s.add_development_dependency "fakeweb"
|
40
|
+
s.add_development_dependency "timecop"
|
41
41
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PagesController do
|
4
|
+
|
5
|
+
before { @routes = PufferPages::Engine.routes }
|
6
|
+
|
7
|
+
describe "GET index" do
|
8
|
+
let!(:layout) { Fabricate :application }
|
9
|
+
let!(:root) { Fabricate :root }
|
10
|
+
let!(:first) { Fabricate :page, slug: 'first', parent: root }
|
11
|
+
let!(:second) { Fabricate :page, slug: 'second.css', parent: first }
|
12
|
+
|
13
|
+
describe "proper page rendering" do
|
14
|
+
it { should render_page root }
|
15
|
+
specify do
|
16
|
+
get :index, path: 'first'
|
17
|
+
response.should render_page first
|
18
|
+
response.should be_ok
|
19
|
+
end
|
20
|
+
specify do
|
21
|
+
get :index, path: 'first/second.css'
|
22
|
+
response.should render_page second
|
23
|
+
response.content_type.should == 'text/css'
|
24
|
+
response.should be_ok
|
25
|
+
end
|
26
|
+
specify do
|
27
|
+
expect { get :index, path: 'first/second' }.to raise_error ActiveRecord::RecordNotFound
|
28
|
+
response.should_not render_page
|
29
|
+
response.should_not be_not_found
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "layout loaded from filesystem" do
|
34
|
+
let!(:root) { Fabricate :root, layout_name: 'sample' }
|
35
|
+
|
36
|
+
context do
|
37
|
+
specify do
|
38
|
+
get :index
|
39
|
+
response.should render_template 'layouts/sample'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'PufferPagesController' do
|
4
|
+
let!(:layout) { Fabricate :application }
|
5
|
+
let!(:root) { Fabricate :root }
|
6
|
+
let!(:anonymous) { Fabricate :page, slug: 'anonymous', parent: root }
|
7
|
+
let!(:first) { Fabricate :page, slug: 'first', parent: root }
|
8
|
+
let!(:second) { Fabricate :page, slug: 'second', parent: first }
|
9
|
+
|
10
|
+
context '`:puffer_page` render option' do
|
11
|
+
context do
|
12
|
+
controller do
|
13
|
+
def index
|
14
|
+
render puffer_page: ''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# aaaammmm wooot? should be root
|
18
|
+
it { should render_page anonymous }
|
19
|
+
end
|
20
|
+
|
21
|
+
context do
|
22
|
+
controller do
|
23
|
+
def index
|
24
|
+
render puffer_page: '/'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it { should render_page root }
|
29
|
+
end
|
30
|
+
|
31
|
+
context do
|
32
|
+
controller do
|
33
|
+
def index
|
34
|
+
render puffer_page: 'first'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it { should render_page first }
|
39
|
+
end
|
40
|
+
|
41
|
+
context do
|
42
|
+
controller do
|
43
|
+
def index
|
44
|
+
render puffer_page: '/first'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it { should render_page first }
|
49
|
+
end
|
50
|
+
|
51
|
+
context do
|
52
|
+
controller do
|
53
|
+
def index
|
54
|
+
render puffer_page: '/first/second'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it { should render_page second }
|
59
|
+
end
|
60
|
+
|
61
|
+
context do
|
62
|
+
controller do
|
63
|
+
def index
|
64
|
+
@page = PufferPages::Page.find_page('first')
|
65
|
+
render puffer_page: @page
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it { should render_page first }
|
70
|
+
end
|
71
|
+
|
72
|
+
context do
|
73
|
+
controller do
|
74
|
+
def index
|
75
|
+
@page = PufferPages::Page.find_page('first/second')
|
76
|
+
render @page
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
specify { expect { get :index }.to raise_error(ActionView::MissingTemplate) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context '`puffer_pages` controller class method' do
|
85
|
+
context do
|
86
|
+
controller do
|
87
|
+
puffer_pages
|
88
|
+
|
89
|
+
def index
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it { should render_page anonymous }
|
94
|
+
end
|
95
|
+
|
96
|
+
context do
|
97
|
+
controller do
|
98
|
+
puffer_pages
|
99
|
+
|
100
|
+
def index
|
101
|
+
render nothing: true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it { should render_page anonymous }
|
106
|
+
end
|
107
|
+
|
108
|
+
context do
|
109
|
+
controller do
|
110
|
+
puffer_pages except: :index
|
111
|
+
|
112
|
+
def index
|
113
|
+
render nothing: true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it { should_not render_page }
|
118
|
+
end
|
119
|
+
|
120
|
+
context do
|
121
|
+
controller do
|
122
|
+
puffer_pages only: :show
|
123
|
+
|
124
|
+
def index
|
125
|
+
render nothing: true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it { should_not render_page }
|
130
|
+
end
|
131
|
+
|
132
|
+
context do
|
133
|
+
controller do
|
134
|
+
puffer_pages
|
135
|
+
|
136
|
+
def index
|
137
|
+
render puffer_page: 'first'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it { should render_page first }
|
142
|
+
end
|
143
|
+
|
144
|
+
context do
|
145
|
+
controller do
|
146
|
+
puffer_pages
|
147
|
+
|
148
|
+
def index
|
149
|
+
render 'first/second'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it { should render_page second }
|
154
|
+
end
|
155
|
+
|
156
|
+
context do
|
157
|
+
controller do
|
158
|
+
puffer_pages
|
159
|
+
|
160
|
+
def index
|
161
|
+
@page = PufferPages::Page.find_page('first')
|
162
|
+
render @page
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it { should render_page first }
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'controller assigns drops' do
|
171
|
+
context do
|
172
|
+
controller do
|
173
|
+
def index
|
174
|
+
@page = PufferPages::Page.root
|
175
|
+
render puffer_page: @page
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
it { should render_page.with_drops('self') }
|
180
|
+
end
|
181
|
+
|
182
|
+
context do
|
183
|
+
controller do
|
184
|
+
def index
|
185
|
+
@count = 42
|
186
|
+
@page = PufferPages::Page.root
|
187
|
+
render puffer_page: @page
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
it { should render_page.with_drops('count' => 42) }
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
{
|
2
|
+
"layouts": [
|
3
|
+
{
|
4
|
+
"body":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
|
5
|
+
"created_at":"2012-10-10T12:30:09Z",
|
6
|
+
"id":"2822BCAA21D24B3187C76C6C41E685F2",
|
7
|
+
"name":"layout",
|
8
|
+
"updated_at":"2012-10-10T12:30:09Z"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"body":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
|
12
|
+
"created_at":"2012-10-10T12:30:09Z","id":"520ACC91563B4F75816770C99038D67D",
|
13
|
+
"name":"layout1","updated_at":"2012-10-10T12:30:09Z"
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"snippets": [
|
17
|
+
{
|
18
|
+
"body":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
|
19
|
+
"created_at":"2012-10-10T12:30:09Z",
|
20
|
+
"id":"64AE0A360FD14E70AA0F9FB33C66D75B",
|
21
|
+
"name":"lorem",
|
22
|
+
"updated_at":"2012-10-10T12:30:09Z"
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"pages": [
|
26
|
+
{
|
27
|
+
"created_at":"2012-10-10T12:30:09Z",
|
28
|
+
"id":"A080B50AF20B4F59B7008977201F1C1F",
|
29
|
+
"layout_name":"layout",
|
30
|
+
"name":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
|
31
|
+
"parent_id":null,
|
32
|
+
"slug":null,
|
33
|
+
"status":"published",
|
34
|
+
"updated_at":"2012-10-10T12:30:09Z",
|
35
|
+
"page_parts":[
|
36
|
+
{
|
37
|
+
"body":null,
|
38
|
+
"created_at":"2012-10-10T12:30:09Z",
|
39
|
+
"id":"4B3086FFEBD4491F9D2401F324D49CBF",
|
40
|
+
"name":"body",
|
41
|
+
"page_id":"A080B50AF20B4F59B7008977201F1C1F",
|
42
|
+
"updated_at":"2012-10-10T12:30:09Z"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"body":null,
|
46
|
+
"created_at":"2012-10-10T12:30:09Z",
|
47
|
+
"id":"F6423DC0AD074C9B979F6E90293817E4",
|
48
|
+
"name":"main",
|
49
|
+
"page_id":"A080B50AF20B4F59B7008977201F1C1F",
|
50
|
+
"updated_at":"2012-10-10T12:30:09Z"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|