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.
Files changed (197) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +3 -1
  3. data/.rvmrc +1 -1
  4. data/.travis.yml +13 -5
  5. data/CHANGELOG.md +130 -7
  6. data/Gemfile +10 -1
  7. data/README.md +18 -20
  8. data/Rakefile +1 -1
  9. data/app/assets/javascripts/puffer/codemirror.js +4237 -2223
  10. data/app/assets/javascripts/puffer/codemirror/css.js +359 -18
  11. data/app/assets/javascripts/puffer/codemirror/htmlmixed.js +15 -14
  12. data/app/assets/javascripts/puffer/codemirror/javascript.js +91 -29
  13. data/app/assets/javascripts/puffer/codemirror/liquid.js +185 -0
  14. data/app/assets/javascripts/puffer/codemirror/xml.js +99 -27
  15. data/app/assets/javascripts/puffer/codemirror/yaml.js +95 -0
  16. data/app/assets/javascripts/puffer/liquid.js +28 -12
  17. data/app/assets/javascripts/puffer/matchbrackets.js +63 -0
  18. data/app/assets/javascripts/puffer/multiplex.js +95 -0
  19. data/app/assets/javascripts/puffer/puffer_pages.js +140 -44
  20. data/app/assets/stylesheets/puffer/codemirror.css +203 -67
  21. data/app/assets/stylesheets/puffer/codemirror/ambiance-mobile.css +6 -0
  22. data/app/assets/stylesheets/puffer/codemirror/ambiance.css +76 -0
  23. data/app/assets/stylesheets/puffer/codemirror/blackboard.css +25 -0
  24. data/app/assets/stylesheets/puffer/codemirror/cobalt.css +4 -4
  25. data/app/assets/stylesheets/puffer/codemirror/eclipse.css +1 -1
  26. data/app/assets/stylesheets/puffer/codemirror/elegant.css +2 -2
  27. data/app/assets/stylesheets/puffer/codemirror/erlang-dark.css +21 -0
  28. data/app/assets/stylesheets/puffer/codemirror/lesser-dark.css +44 -0
  29. data/app/assets/stylesheets/puffer/codemirror/monokai.css +4 -4
  30. data/app/assets/stylesheets/puffer/codemirror/neat.css +3 -3
  31. data/app/assets/stylesheets/puffer/codemirror/night.css +4 -4
  32. data/app/assets/stylesheets/puffer/codemirror/rubyblue.css +5 -5
  33. data/app/assets/stylesheets/puffer/codemirror/solarized.css +207 -0
  34. data/app/assets/stylesheets/puffer/codemirror/twilight.css +26 -0
  35. data/app/assets/stylesheets/puffer/codemirror/vibrant-ink.css +27 -0
  36. data/app/assets/stylesheets/puffer/codemirror/xq-dark.css +46 -0
  37. data/app/assets/stylesheets/puffer/puffer_pages.css +64 -35
  38. data/app/components/codemirror/form.html.erb +22 -6
  39. data/app/components/codemirror_component.rb +1 -8
  40. data/app/components/handlers/form.html.erb +8 -0
  41. data/app/components/handlers_component.rb +8 -0
  42. data/app/components/page_parts/_page_part.html.erb +6 -0
  43. data/app/components/page_parts/form.html.erb +8 -27
  44. data/app/components/page_parts_component.rb +1 -3
  45. data/app/components/render/_tree_page.html.erb +3 -2
  46. data/app/controllers/admin/layouts_controller.rb +1 -1
  47. data/app/controllers/admin/origins_controller.rb +3 -0
  48. data/app/controllers/admin/pages_controller.rb +1 -1
  49. data/app/controllers/admin/snippets_controller.rb +1 -1
  50. data/app/controllers/pages_controller.rb +3 -3
  51. data/app/helpers/puffer_pages_helper.rb +3 -3
  52. data/app/models/puffer_pages/layout.rb +2 -7
  53. data/app/models/puffer_pages/origin.rb +2 -0
  54. data/app/models/puffer_pages/page.rb +1 -117
  55. data/app/models/puffer_pages/page_part.rb +2 -22
  56. data/app/models/puffer_pages/snippet.rb +2 -5
  57. data/config/routes.rb +3 -0
  58. data/db/migrate/20120812100913_create_origins.rb +16 -0
  59. data/db/migrate/20120924120226_migrate_to_uuid.rb +126 -0
  60. data/db/migrate/20130110144030_add_handler_to_page_parts.rb +9 -0
  61. data/db/migrate/20130118064524_add_locales_to_pages.rb +9 -0
  62. data/gemfiles/Gemfile.rails-3-1 +7 -0
  63. data/gemfiles/Gemfile.rails-3-2 +7 -0
  64. data/gemfiles/Gemfile.rails-head +7 -0
  65. data/lib/puffer_pages.rb +43 -7
  66. data/lib/puffer_pages/backends.rb +16 -0
  67. data/{app/controllers/puffer_pages → lib/puffer_pages/backends/controllers}/layouts_base.rb +2 -5
  68. data/lib/puffer_pages/backends/controllers/origins_base.rb +43 -0
  69. data/lib/puffer_pages/backends/controllers/pages_base.rb +52 -0
  70. data/{app/controllers/puffer_pages → lib/puffer_pages/backends/controllers}/snippets_base.rb +2 -5
  71. data/lib/puffer_pages/backends/models/layout.rb +34 -0
  72. data/lib/puffer_pages/backends/models/mixins/importable.rb +42 -0
  73. data/lib/puffer_pages/backends/models/mixins/localable.rb +65 -0
  74. data/lib/puffer_pages/backends/models/mixins/renderable.rb +153 -0
  75. data/lib/puffer_pages/backends/models/mixins/translatable.rb +52 -0
  76. data/lib/puffer_pages/backends/models/origin.rb +59 -0
  77. data/lib/puffer_pages/backends/models/page.rb +221 -0
  78. data/lib/puffer_pages/backends/models/page_part.rb +71 -0
  79. data/lib/puffer_pages/backends/models/snippet.rb +34 -0
  80. data/lib/puffer_pages/engine.rb +13 -2
  81. data/lib/puffer_pages/extensions/context.rb +31 -0
  82. data/lib/puffer_pages/extensions/core.rb +1 -8
  83. data/lib/puffer_pages/extensions/pagenator.rb +69 -0
  84. data/lib/puffer_pages/extensions/renderer.rb +31 -0
  85. data/lib/puffer_pages/globalize/migrator.rb +23 -0
  86. data/lib/puffer_pages/handlers.rb +29 -0
  87. data/lib/puffer_pages/handlers/base.rb +21 -0
  88. data/lib/puffer_pages/handlers/yaml.rb +20 -0
  89. data/lib/puffer_pages/helpers.rb +14 -0
  90. data/lib/puffer_pages/liquid/backend.rb +16 -0
  91. data/lib/puffer_pages/liquid/file_system.rb +36 -12
  92. data/lib/puffer_pages/liquid/page_drop.rb +26 -23
  93. data/lib/puffer_pages/liquid/tags/array.rb +39 -0
  94. data/lib/puffer_pages/liquid/tags/{javascripts.rb → assets.rb} +13 -4
  95. data/lib/puffer_pages/liquid/tags/helper.rb +15 -0
  96. data/lib/puffer_pages/liquid/tags/include.rb +32 -0
  97. data/lib/puffer_pages/liquid/tags/javascript.rb +15 -0
  98. data/lib/puffer_pages/liquid/tags/partials.rb +22 -0
  99. data/lib/puffer_pages/liquid/tags/render.rb +28 -0
  100. data/lib/puffer_pages/liquid/tags/scope.rb +31 -0
  101. data/lib/puffer_pages/liquid/tags/super.rb +36 -0
  102. data/lib/puffer_pages/liquid/tags/translate.rb +56 -0
  103. data/lib/puffer_pages/liquid/tags/url.rb +53 -0
  104. data/lib/puffer_pages/liquid/tags/yield.rb +3 -1
  105. data/lib/puffer_pages/log_subscriber.rb +29 -0
  106. data/lib/puffer_pages/migrations.rb +31 -0
  107. data/lib/puffer_pages/renderer.rb +25 -0
  108. data/lib/puffer_pages/rspec/matchers.rb +27 -0
  109. data/lib/puffer_pages/rspec/matchers/render_page.rb +90 -0
  110. data/lib/puffer_pages/version.rb +1 -1
  111. data/puffer_pages.gemspec +18 -18
  112. data/spec/controllers/pages_controller_spec.rb +44 -0
  113. data/spec/controllers/puffer_pages_controller_spec.rb +194 -0
  114. data/spec/data/broken.json +8 -0
  115. data/spec/data/import.json +55 -0
  116. data/spec/data/localized.json +106 -0
  117. data/spec/data/unlocalized.json +82 -0
  118. data/spec/dummy/.rvmrc +1 -0
  119. data/spec/dummy/app/controllers/application_controller.rb +6 -0
  120. data/spec/dummy/app/views/layouts/sample.en.erb +1 -0
  121. data/spec/dummy/app/views/layouts/sample.ru.erb +1 -0
  122. data/spec/dummy/app/views/shared/_first.html.erb +1 -0
  123. data/spec/dummy/config/application.rb +21 -2
  124. data/spec/dummy/config/boot.rb +0 -2
  125. data/spec/dummy/config/database.yml +7 -1
  126. data/spec/dummy/config/environments/development.rb +11 -2
  127. data/spec/dummy/config/environments/pg_test.rb +6 -6
  128. data/spec/dummy/config/environments/production.rb +19 -3
  129. data/spec/dummy/config/environments/test.rb +6 -6
  130. data/spec/dummy/config/initializers/inflections.rb +5 -0
  131. data/spec/dummy/config/initializers/puffer_pages.rb +4 -0
  132. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  133. data/spec/dummy/config/initializers/wrap_parameters.rb +5 -3
  134. data/spec/dummy/config/routes.rb +2 -1
  135. data/spec/dummy/db/migrate/{20090422092419_create_pages.rb → 20130118071511_create_pages.rb} +1 -0
  136. data/spec/dummy/db/migrate/{20090504132337_create_page_parts.rb → 20130118071512_create_page_parts.rb} +1 -0
  137. data/spec/dummy/db/migrate/{20090506102004_create_layouts.rb → 20130118071513_create_layouts.rb} +1 -0
  138. data/spec/dummy/db/migrate/{20090510121824_create_snippets.rb → 20130118071514_create_snippets.rb} +1 -0
  139. data/spec/dummy/db/migrate/20130118071515_create_origins.rb +17 -0
  140. data/spec/dummy/db/migrate/20130118071516_migrate_to_uuid.rb +127 -0
  141. data/spec/dummy/db/migrate/20130118071517_add_handler_to_page_parts.rb +10 -0
  142. data/spec/dummy/db/migrate/20130118071518_add_locales_to_pages.rb +10 -0
  143. data/spec/dummy/db/migrate/20130118071519_add_translations.rb +9 -0
  144. data/spec/dummy/db/schema.rb +65 -17
  145. data/spec/fabricators/articles_fabricator.rb +2 -2
  146. data/spec/fabricators/layouts_fabricator.rb +24 -3
  147. data/spec/fabricators/origin_fabricator.rb +5 -0
  148. data/spec/fabricators/page_parts_fabricator.rb +17 -2
  149. data/spec/fabricators/pages_fabricator.rb +20 -5
  150. data/spec/fabricators/snippets_fabricator.rb +14 -3
  151. data/spec/lib/handlers/base_spec.rb +10 -0
  152. data/spec/lib/handlers/yaml_spec.rb +34 -0
  153. data/spec/lib/handlers_spec.rb +36 -0
  154. data/spec/lib/liquid/backend_spec.rb +20 -0
  155. data/spec/lib/liquid/interpolation_spec.rb +25 -0
  156. data/spec/lib/liquid/tags/include_spec.rb +38 -0
  157. data/spec/lib/liquid/tags/partials_spec.rb +39 -0
  158. data/spec/lib/liquid/tags/scope_spec.rb +18 -0
  159. data/spec/lib/liquid/tags/translate_spec.rb +107 -0
  160. data/spec/lib/liquid/tags_spec.rb +81 -0
  161. data/spec/lib/page_drop_spec.rb +65 -0
  162. data/spec/lib/pagenator_spec.rb +176 -0
  163. data/spec/lib/rspec/matchers/render_page_spec.rb +107 -0
  164. data/spec/models/puffer_pages/layout_spec.rb +15 -0
  165. data/spec/models/puffer_pages/localable_spec.rb +62 -0
  166. data/spec/models/puffer_pages/origin_spec.rb +112 -0
  167. data/spec/models/puffer_pages/page_part_spec.rb +14 -0
  168. data/spec/models/puffer_pages/page_spec.rb +307 -0
  169. data/spec/models/puffer_pages/renderable_spec.rb +84 -0
  170. data/spec/models/puffer_pages/snippet_spec.rb +15 -0
  171. data/spec/requests/origins_requests_spec.rb +37 -0
  172. data/spec/spec_helper.rb +7 -6
  173. metadata +349 -87
  174. data/Gemfile.lock +0 -176
  175. data/app/assets/javascripts/puffer/overlay.js +0 -51
  176. data/app/controllers/puffer_pages/pages_base.rb +0 -38
  177. data/app/models/layout.rb +0 -2
  178. data/app/models/page.rb +0 -2
  179. data/app/models/page_part.rb +0 -2
  180. data/app/models/snippet.rb +0 -2
  181. data/app/views/layouts/puffer_pages_layout.html.erb +0 -2
  182. data/config/puffer_routes.rb +0 -3
  183. data/gemfiles/Gemfile-rails-3.1 +0 -5
  184. data/gemfiles/Gemfile-rails-3.1.lock +0 -173
  185. data/gemfiles/Gemfile-rails-3.2 +0 -5
  186. data/gemfiles/Gemfile-rails-3.2.lock +0 -171
  187. data/lib/puffer_pages/extensions/controller.rb +0 -30
  188. data/lib/puffer_pages/extensions/mapper.rb +0 -23
  189. data/lib/puffer_pages/liquid/tags/page_attribute.rb +0 -39
  190. data/lib/puffer_pages/liquid/tags/stylesheets.rb +0 -38
  191. data/spec/controllers/articles_controller_spec.rb +0 -65
  192. data/spec/dummy/app/controllers/articles_controller.rb +0 -9
  193. data/spec/integration/navigation_spec.rb +0 -9
  194. data/spec/lib/drops_spec.rb +0 -55
  195. data/spec/lib/tags_spec.rb +0 -98
  196. data/spec/models/page_spec.rb +0 -235
  197. data/spec/puffer_pages_spec.rb +0 -7
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Tags' do
4
-
5
- def render_page(page, drops = {})
6
- page.render({'self' => PufferPages::Liquid::PageDrop.new(page)}.merge(drops))
7
- end
8
-
9
- describe 'include page part' do
10
-
11
- before :each do
12
- @page = Fabricate :page, :layout_name => 'foo_layout'
13
- @main = Fabricate :page_part, :name => PufferPages.primary_page_part_name, :body => 'foo'
14
- @sidebar = Fabricate :page_part, :name => 'sidebar', :body => 'bar'
15
- @page.page_parts = [@main, @sidebar]
16
- end
17
-
18
- it 'should include page_part with string param' do
19
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include '#{PufferPages.primary_page_part_name}' %}"
20
- render_page(@page).should == @main.body
21
- end
22
-
23
- it 'should include page_part with variable param' do
24
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sb = 'sidebar' %}{% include sb %}"
25
- render_page(@page).should == @sidebar.body
26
- end
27
-
28
- end
29
-
30
- describe 'include snippet' do
31
-
32
- before :each do
33
- @page = Fabricate :page, :layout_name => 'foo_layout'
34
- @snippet = Fabricate :snippet, :name => 'snip', :body => 'snippet body'
35
- end
36
-
37
- it 'should include snippet with string param' do
38
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include 'snippets/snip' %}"
39
- render_page(@page).should == @snippet.body
40
- end
41
-
42
- it 'should include snippet with variable param' do
43
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sn = 'snippets/snip' %}{% include sn %}"
44
- render_page(@page).should == @snippet.body
45
- end
46
-
47
- it 'should include snippet with proper object name' do
48
- @snippet = Fabricate :snippet, :name => 'var', :body => '{{ var }}'
49
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sn = 'snippets/var' %}{% include sn with var:'hello' %}"
50
- render_page(@page).should == 'hello'
51
- end
52
-
53
- end
54
-
55
- describe 'stylesheets' do
56
-
57
- it 'should render stylesheets with proper params' do
58
- @page = Fabricate :page, :layout_name => 'foo_layout'
59
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign st = 'styles' %}{% stylesheets 'reset', st %}"
60
- render_page(@page).should == "<%= stylesheet_link_tag 'reset', 'styles' %>"
61
- end
62
-
63
- end
64
-
65
- describe 'javascripts' do
66
-
67
- it 'should render javascripts with proper params' do
68
- @page = Fabricate :page, :layout_name => 'foo_layout'
69
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign ctrl = 'controls' %}{% javascripts 'prototype', ctrl %}"
70
- render_page(@page).should == "<%= javascript_include_tag 'prototype', 'controls' %>"
71
- end
72
-
73
- end
74
-
75
- describe 'attributes: name, title, keywords, description' do
76
-
77
- it 'should render self title without params' do
78
- @page = Fabricate :page, :layout_name => 'foo_layout', :name => 'hello', :title => '{{self.name}}',
79
- :page_parts => [Fabricate(:page_part, :name => PufferPages.primary_page_part_name, :body => '{% title %}')]
80
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include '#{PufferPages.primary_page_part_name}' %}"
81
-
82
- render_page(@page).should == "hello"
83
- end
84
-
85
- it 'should render page title with param and should get page drop as self internally' do
86
- @root = Fabricate :page, :layout_name => 'foo_layout', :name => 'hello', :title => '{{self.name}}',
87
- :page_parts => [Fabricate(:page_part, :name => PufferPages.primary_page_part_name, :body => '{% title page %}')]
88
- @page = Fabricate :page, :parent => @root, :slug => 'foo', :name => 'world', :title => '{{self.name}}'
89
-
90
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include '#{PufferPages.primary_page_part_name}' %}"
91
-
92
- render_page(@root, 'page' => PufferPages::Liquid::PageDrop.new(@page)).should == "world"
93
- end
94
-
95
- end
96
-
97
-
98
- end
@@ -1,235 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe Page do
5
-
6
- it 'should have only one root' do
7
- pending 'rails validation bug'
8
- @root = Fabricate :page, :layout_name => 'foo_layout'
9
- @root2 = Fabricate.build :page, :layout_name => 'foo_layout'
10
- @root2.save
11
-
12
- Page.roots.should == [@root]
13
- end
14
-
15
- describe 'attributes' do
16
-
17
- before :each do
18
- @root = Fabricate :page, :layout_name => 'foo_layout'
19
- end
20
-
21
- it 'should have nil slug location if root' do
22
- @root.slug.should == nil
23
- @root.location.should == nil
24
- end
25
-
26
- it 'should generate proper location' do
27
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
28
- @bar = Fabricate :page, :slug => 'bar', :parent => @foo
29
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar
30
- @foo.location.should == 'foo'
31
- @bar.location.should == 'foo/bar'
32
- @baz.location.should == 'foo/bar/baz'
33
- end
34
-
35
- it 'should check slug uniqueness' do
36
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
37
- @bar = Fabricate :page, :slug => 'foo', :parent => @foo
38
- @baz = Fabricate.build :page, :slug => 'foo', :parent => @root
39
- @foo.should be_valid
40
- @bar.should be_valid
41
- @baz.should_not be_valid
42
- end
43
-
44
- it 'should update descendants locations' do
45
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
46
- @bar = Fabricate :page, :slug => 'bar', :parent => @foo
47
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar
48
-
49
- @foo.update_attributes :slug => 'moo'
50
-
51
- @foo.reload.location.should == 'moo'
52
- @bar.reload.location.should == 'moo/bar'
53
- @baz.reload.location.should == 'moo/bar/baz'
54
-
55
- @bar.update_attributes :slug => 'fuu'
56
-
57
- @foo.reload.location.should == 'moo'
58
- @bar.reload.location.should == 'moo/fuu'
59
- @baz.reload.location.should == 'moo/fuu/baz'
60
- end
61
-
62
- end
63
-
64
- describe 'page parts' do
65
-
66
- before :each do
67
- @root = Fabricate :page, :layout_name => 'foo_layout'
68
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
69
- @bar = Fabricate :page, :slug => 'bar', :parent => @foo, :page_parts => [Fabricate(:page_part, :name => PufferPages.primary_page_part_name, :body => '4')]
70
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar, :page_parts => [Fabricate(:page_part, :name => 'sidebar', :body => '5'), Fabricate(:page_part, :name => 'additional', :body => '3')]
71
- @foo.page_parts = [Fabricate(:page_part, :name => 'sidebar', :body => '2')]
72
- end
73
-
74
- it 'should receive proper inherited page parts' do
75
- @root.inherited_page_parts.map(&:body).should == [nil]
76
- @foo.inherited_page_parts.map(&:body).should == [nil, '2']
77
- @bar.inherited_page_parts.map(&:body).should == ['4', '2']
78
- @baz.inherited_page_parts.map(&:body).should == ['4', '3', '5']
79
- end
80
-
81
- end
82
-
83
- describe 'root page parts' do
84
-
85
- it 'should build default `main` part for root page on initialization' do
86
- root = Fabricate.build :page, :layout_name => 'foo_layout'
87
- root.page_parts.map(&:name).should == [PufferPages.primary_page_part_name]
88
- end
89
-
90
- it 'should create default `main` part for root page' do
91
- root = Fabricate :page, :layout_name => 'foo_layout'
92
- root.page_parts.map(&:name).should == [PufferPages.primary_page_part_name]
93
- end
94
-
95
- it 'should not create `main` part for root page if it exists' do
96
- root = Fabricate :page, :layout_name => 'foo_layout', :page_parts => [Fabricate.build(:page_part, :name => PufferPages.primary_page_part_name, :body => 'haha')]
97
- root.page_parts.map(&:name).should == [PufferPages.primary_page_part_name]
98
- root.page_parts.map(&:body).should == ['haha']
99
- end
100
-
101
- end
102
-
103
- describe 'layout' do
104
-
105
- before :each do
106
- @layout = Fabricate :layout, :name => 'bar_layout'
107
- @root = Fabricate :page, :layout_name => 'foo_layout'
108
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
109
- @bar = Fabricate :page, :slug => 'bar', :parent => @foo, :layout_name => 'bar_layout'
110
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar
111
- end
112
-
113
- it 'should receive proper layout name' do
114
- @root.inherited_layout_name.should == 'foo_layout'
115
- @foo.inherited_layout_name.should == 'foo_layout'
116
- @bar.inherited_layout_name.should == 'bar_layout'
117
- @baz.inherited_layout_name.should == 'bar_layout'
118
- end
119
-
120
- it 'should return proper layout for render' do
121
- @root.render_layout.should == 'foo_layout'
122
- @foo.render_layout.should == 'foo_layout'
123
- @bar.render_layout.should == false
124
- @baz.render_layout.should == false
125
- end
126
-
127
- end
128
-
129
- describe 'rendering' do
130
-
131
- before :each do
132
- @root = Fabricate :page, :layout_name => 'foo_layout'
133
- @main = Fabricate :page_part, :name => PufferPages.primary_page_part_name, :body => '{{ self.title }}'
134
- @sidebar = Fabricate :page_part, :name => 'sidebar', :body => '{{ self.name }}'
135
- @root.page_parts = [@main, @sidebar]
136
- end
137
-
138
- it 'should render content_for blocks if rails layout used' do
139
- result = @root.render 'self' => PufferPages::Liquid::PageDrop.new(@root)
140
- result.should == "<% content_for :'sidebar' do %>#{@root.name}<% end %>#{@root.title}"
141
- end
142
-
143
- it 'should render layout' do
144
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include 'body' %} {% include 'sidebar' %}"
145
- result = @root.render 'self' => PufferPages::Liquid::PageDrop.new(@root)
146
- result.should == "#{@root.title} #{@root.name}"
147
- end
148
-
149
- it 'should receive proper content type' do
150
- @root.content_type.should == 'text/html'
151
- page = Fabricate :page, :slug => 'style.css', :parent => @root
152
- page.content_type.should == 'text/css'
153
- end
154
-
155
- end
156
-
157
- describe 'find_page' do
158
-
159
- def single_section_page_path
160
- PufferPages.single_section_page_path = true
161
- yield
162
- PufferPages.single_section_page_path = false
163
- end
164
-
165
- before :each do
166
- @root = Fabricate :page, :layout_name => 'foo_layout'
167
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
168
- @bar = Fabricate :page, :slug => 'bar', :parent => @foo
169
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar, :status => 'draft'
170
- end
171
-
172
- it 'root page' do
173
- Page.find_page(nil).should == @root
174
- end
175
-
176
- it 'not root page' do
177
- Page.find_page('foo/bar').should == @bar
178
- end
179
-
180
- it 'not existent page' do
181
- expect {Page.find_page('foo/baz') }.to raise_error(ActiveRecord::RecordNotFound)
182
- end
183
-
184
- it 'draft page' do
185
- expect {Page.find_page('foo/bar/baz') }.to raise_error(PufferPages::DraftPage)
186
- end
187
-
188
- it 'single section root page' do
189
- single_section_page_path do
190
- Page.find_page(nil).should == @root
191
- end
192
- end
193
-
194
- it 'single section not root page' do
195
- single_section_page_path do
196
- Page.find_page('foo').should == @foo
197
- Page.find_page('bar').should == @bar
198
- end
199
- end
200
-
201
- end
202
-
203
- describe 'find_layout_page' do
204
-
205
- before :each do
206
- @root = Fabricate :page, :layout_name => 'foo_layout'
207
- @foo = Fabricate :page, :slug => 'foo', :parent => @root
208
- @bar = Fabricate :page, :slug => '%', :parent => @foo
209
- @baz = Fabricate :page, :slug => 'baz', :parent => @bar
210
- end
211
-
212
- it 'root page' do
213
- Page.find_layout_page('/').should == @root
214
- end
215
-
216
- it 'not root page' do
217
- Page.find_layout_page('/foo').should == @foo
218
- Page.find_layout_page('/foo/bar').should == @bar
219
- Page.find_layout_page('/foo/baz').should == @bar
220
- Page.find_layout_page('/foo/bar/baz').should == @baz
221
- Page.find_layout_page('/foo/moo/baz').should == @baz
222
- end
223
-
224
- it 'not existent page' do
225
- expect {Page.find_layout_page('/bar')}.to raise_error(PufferPages::LayoutMissed)
226
- end
227
-
228
- it 'draft page' do
229
- @bar.update_attributes(:status => 'draft')
230
- expect {Page.find_layout_page('/foo/bar')}.to raise_error(PufferPages::LayoutMissed)
231
- end
232
-
233
- end
234
-
235
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PufferPages do
4
- it "should be valid" do
5
- PufferPages.should be_a(Module)
6
- end
7
- end