trusty-layouts-extension 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/MIT-LICENSE +98 -0
  2. data/README.md +115 -0
  3. data/Rakefile +144 -0
  4. data/VERSION +1 -0
  5. data/app/models/haml_filter.rb +5 -0
  6. data/app/models/rails_page.rb +39 -0
  7. data/app/views/layouts/trusty.html.haml +1 -0
  8. data/config/initializers/trusty_config.rb +1 -0
  9. data/config/routes.rb +0 -0
  10. data/layouts_extension.rb +21 -0
  11. data/lib/haml_layouts/models/layout.rb +33 -0
  12. data/lib/haml_layouts/models/page.rb +33 -0
  13. data/lib/layouts/engine.rb +5 -0
  14. data/lib/nested_layouts/tags/core.rb +150 -0
  15. data/lib/share_layouts/controllers/action_controller.rb +26 -0
  16. data/lib/share_layouts/helpers/action_view.rb +48 -0
  17. data/lib/tasks/layouts_extension_tasks.rake +55 -0
  18. data/lib/trusty-layouts-extension.rb +1 -0
  19. data/spec/controllers/share_controller_spec.rb +119 -0
  20. data/spec/datasets/layouts_layouts.rb +36 -0
  21. data/spec/datasets/layouts_pages.rb +43 -0
  22. data/spec/lib/haml_layouts/haml_layouts_extension_spec.rb +22 -0
  23. data/spec/lib/haml_layouts/models/layout_spec.rb +36 -0
  24. data/spec/lib/haml_layouts/models/page_spec.rb +40 -0
  25. data/spec/lib/nested_layouts/nested_layouts_extension_spec.rb +16 -0
  26. data/spec/lib/nested_layouts/tags/core_spec.rb +147 -0
  27. data/spec/lib/share_layouts/controllers/action_controller_spec.rb +44 -0
  28. data/spec/lib/share_layouts/helpers/action_view_spec.rb +171 -0
  29. data/spec/lib/share_layouts/share_layouts_extension_spec.rb +22 -0
  30. data/spec/models/haml_filter_spec.rb +0 -0
  31. data/spec/models/rails_page_spec.rb +63 -0
  32. data/spec/spec.opts +3 -0
  33. data/spec/spec_helper.rb +22 -0
  34. data/trusty-layouts-extension.gemspec +31 -0
  35. data/vendor/plugins/rails_upgrade/MIT-LICENSE +20 -0
  36. data/vendor/plugins/rails_upgrade/README.rdoc +26 -0
  37. data/vendor/plugins/rails_upgrade/Rakefile +22 -0
  38. data/vendor/plugins/rails_upgrade/init.rb +2 -0
  39. data/vendor/plugins/rails_upgrade/install.rb +38 -0
  40. data/vendor/plugins/rails_upgrade/lib/application_checker.rb +506 -0
  41. data/vendor/plugins/rails_upgrade/lib/gemfile_generator.rb +95 -0
  42. data/vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb +59 -0
  43. data/vendor/plugins/rails_upgrade/lib/rails_upgrade.rb +0 -0
  44. data/vendor/plugins/rails_upgrade/lib/routes_upgrader.rb +344 -0
  45. data/vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake +79 -0
  46. data/vendor/plugins/rails_upgrade/test/application_checker_test.rb +344 -0
  47. data/vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb +72 -0
  48. data/vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb +63 -0
  49. data/vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb +218 -0
  50. data/vendor/plugins/rails_upgrade/test/test_helper.rb +5 -0
  51. data/vendor/plugins/rails_upgrade/uninstall.rb +1 -0
  52. metadata +134 -0
@@ -0,0 +1,43 @@
1
+ class LayoutsPagesDataset < Dataset::Base
2
+
3
+ uses :layouts_layouts
4
+
5
+ def load
6
+ create_record :page, :parent,
7
+ :title => 'Parent',
8
+ :layout_id => layouts(:parent).id,
9
+ :breadcrumb => 'parent',
10
+ :slug => '/',
11
+ :status_id => 100
12
+
13
+ create_record :page, :child,
14
+ :title => 'Child',
15
+ :layout_id => layouts(:child).id,
16
+ :parent_id => pages(:parent).id,
17
+ :breadcrumb => 'child',
18
+ :slug => '/child',
19
+ :status_id => 100
20
+
21
+ create_record :page, :rails,
22
+ :title => 'App page',
23
+ :breadcrumb => 'App page',
24
+ :slug => 'app',
25
+ :class_name => 'RailsPage',
26
+ :status_id => 100,
27
+ :parent_id => pages(:parent).id
28
+
29
+ create_record :page, :rails_child,
30
+ :title => 'Child',
31
+ :breadcrumb => 'Child',
32
+ :slug => 'child-page',
33
+ :status_id => 100,
34
+ :parent_id => pages(:rails).id
35
+
36
+ create_record :page, :other,
37
+ :title => 'Other',
38
+ :breadcrumb => 'Other',
39
+ :slug => 'other',
40
+ :status_id => 100,
41
+ :parent_id => pages(:parent).id
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec/spec_helper'
2
+
3
+ # Ensures that the Extension initializes correctly
4
+ describe LayoutsExtension do
5
+
6
+ context 'activate' do
7
+
8
+ describe 'haml layouts' do
9
+ it 'should have a HamlFilter class to call' do
10
+ HamlFilter.should_not be_nil
11
+ end
12
+ it 'should extend Layout base methods' do
13
+ Layout.included_modules.include?(HamlLayouts::Models::Layout).should be_true
14
+ end
15
+ it 'should extend Page base methods' do
16
+ Page.included_modules.include?(HamlLayouts::Models::Page).should be_true
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe HamlLayouts::Models::Layout do
4
+
5
+ dataset :layouts_layouts, :layouts_pages
6
+
7
+ describe 'content' do
8
+ context 'a haml layout' do
9
+ it 'should return html rendered' do
10
+ expected = <<-CONTENT
11
+ <r:inside_layout name='parent'>
12
+ <h1 data-layout="<r:find url='find'><r:layout/></r:find>" id='<r:layout/>'>
13
+ <r:layout></r:layout>
14
+ </h1>
15
+ </r:inside_layout>
16
+ CONTENT
17
+ layouts(:haml).rendered_content.should === expected
18
+ end
19
+ end
20
+ end
21
+
22
+ describe 'is_haml?' do
23
+ context 'layout has a content type of haml' do
24
+ it 'should return true' do
25
+ layouts(:haml).is_haml?.should be_true
26
+ end
27
+ end
28
+
29
+ context 'layout does not have a content type of haml' do
30
+ it 'should return false' do
31
+ layouts(:child).is_haml?.should be_false
32
+ end
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe HamlLayouts::Models::Page do
4
+
5
+ dataset :layouts_layouts, :layouts_pages
6
+
7
+ describe 'parse_object' do
8
+ context 'haml filter type' do
9
+ it 'should render haml radius tags' do
10
+ @part = PagePart.new({
11
+ :content => '%r:title',
12
+ :filter_id => 'Haml'
13
+ })
14
+ @page = pages(:parent)
15
+
16
+ @page.parse_object(@part).should === "#{@page.title}\n"
17
+ end
18
+
19
+ it 'should render textile radius tags' do
20
+ @part = PagePart.new({
21
+ :content => 'h1. <r:title />',
22
+ :filter_id => 'Textile'
23
+ })
24
+ @page = pages(:parent)
25
+
26
+ @page.parse_object(@part).should === "<h1>#{@page.title}</h1>"
27
+ end
28
+
29
+ it 'should render non filtered tags' do
30
+ @part = PagePart.new({
31
+ :content => '<r:title />'
32
+ })
33
+ @page = pages(:parent)
34
+
35
+ @page.parse_object(@part).should === @page.title
36
+ end
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec/spec_helper'
2
+
3
+ # Ensures that the Extension initializes correctly
4
+ describe LayoutsExtension do
5
+
6
+ context 'activate' do
7
+
8
+ describe 'nested layouts' do
9
+ it 'should extend Page base methods' do
10
+ Page.included_modules.include?(NestedLayouts::Tags::Core).should be_true
11
+ end
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,147 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe NestedLayouts::Tags::Core do
4
+
5
+ dataset :layouts_pages, :layouts_layouts
6
+
7
+ describe '<r:inside_layout>, <r:layout>, <r:body /> and <r:content_for_layout>' do
8
+
9
+ it 'should output tag within the body of class name for parent layout' do
10
+ tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
11
+ expected = <<-CONTENT
12
+ <!DOCTYPE html>
13
+ <html>
14
+ <head>
15
+ <title>Title</title>
16
+ </head>
17
+ <body id="" class="parent site">
18
+ <h1>Hi</h1>
19
+ </body>
20
+ </html>
21
+ CONTENT
22
+ pages(:parent).should render(tag).as(expected)
23
+ end
24
+
25
+ it 'should output tag within the body of class name for a child_layout' do
26
+ tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
27
+ expected = <<-CONTENT
28
+ <!DOCTYPE html>
29
+ <html>
30
+ <head>
31
+ <title>Title</title>
32
+ </head>
33
+ <body id="child" class="child site">
34
+ <h1>Hi</h1>
35
+ </body>
36
+ </html>
37
+ CONTENT
38
+ pages(:child).should render(tag).as(expected)
39
+ end
40
+
41
+ end
42
+
43
+ describe '<r:if_layout>' do
44
+
45
+ it 'it should render the contents if true' do
46
+ tag = %{<r:inside_layout name='parent'><r:if_layout name='parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
47
+ expected = <<-CONTENT
48
+ <!DOCTYPE html>
49
+ <html>
50
+ <head>
51
+ <title>Title</title>
52
+ </head>
53
+ <body id="" class="parent site">
54
+ <h1>Hi</h1>
55
+ </body>
56
+ </html>
57
+ CONTENT
58
+ pages(:parent).should render(tag).as(expected)
59
+ end
60
+
61
+ it 'it should support regex' do
62
+ tag = %{<r:inside_layout name='parent'><r:if_layout name='(parent|child)'><h1>Hi</h1></r:if_layout></r:inside_layout>}
63
+ expected = <<-CONTENT
64
+ <!DOCTYPE html>
65
+ <html>
66
+ <head>
67
+ <title>Title</title>
68
+ </head>
69
+ <body id="" class="parent site">
70
+ <h1>Hi</h1>
71
+ </body>
72
+ </html>
73
+ CONTENT
74
+ pages(:parent).should render(tag).as(expected)
75
+ end
76
+
77
+ it 'it should not render the contents if false' do
78
+ tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
79
+ expected = <<-CONTENT
80
+ <!DOCTYPE html>
81
+ <html>
82
+ <head>
83
+ <title>Title</title>
84
+ </head>
85
+ <body id="" class="parent site">
86
+
87
+ </body>
88
+ </html>
89
+ CONTENT
90
+ pages(:parent).should render(tag).as(expected)
91
+ end
92
+
93
+ end
94
+
95
+ describe '<r:unless_layout>' do
96
+
97
+ it 'it should not render the contents if false' do
98
+ tag = %{<r:inside_layout name='parent'><r:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
99
+ expected = <<-CONTENT
100
+ <!DOCTYPE html>
101
+ <html>
102
+ <head>
103
+ <title>Title</title>
104
+ </head>
105
+ <body id="" class="parent site">
106
+ <h1>Hi</h1>
107
+ </body>
108
+ </html>
109
+ CONTENT
110
+ pages(:parent).should render(tag).as(expected)
111
+ end
112
+
113
+ it 'it should support regex' do
114
+ tag = %{<r:inside_layout name='parent'><r:unless_layout name='(not_parent|not_child)'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
115
+ expected = <<-CONTENT
116
+ <!DOCTYPE html>
117
+ <html>
118
+ <head>
119
+ <title>Title</title>
120
+ </head>
121
+ <body id="" class="parent site">
122
+ <h1>Hi</h1>
123
+ </body>
124
+ </html>
125
+ CONTENT
126
+ pages(:parent).should render(tag).as(expected)
127
+ end
128
+
129
+ it 'it should not render the contents if true' do
130
+ tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
131
+ expected = <<-CONTENT
132
+ <!DOCTYPE html>
133
+ <html>
134
+ <head>
135
+ <title>Title</title>
136
+ </head>
137
+ <body id="" class="parent site">
138
+
139
+ </body>
140
+ </html>
141
+ CONTENT
142
+ pages(:parent).should render(tag).as(expected)
143
+ end
144
+
145
+ end
146
+
147
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec/spec_helper'
2
+
3
+ class ControllerWithRadiantLayout < ApplicationController
4
+ radiant_layout 'main'
5
+ end
6
+
7
+ class ControllerWithRadiantLayoutBlock < ApplicationController
8
+ radiant_layout {|c| c.action_name == "index" ? "main" : "utf8"}
9
+ end
10
+
11
+ describe ControllerWithRadiantLayout do
12
+ dataset :layouts
13
+
14
+ before(:each) do
15
+ layouts(:main)
16
+ end
17
+
18
+ it "should have radiant layout attribute" do
19
+ ControllerWithRadiantLayout.read_inheritable_attribute('radiant_layout').should == 'main'
20
+ # This doesn't seem to work anymore, but calling "active_layout" on an instance still correctly returns "layouts/radiant.rhtml"
21
+ #ControllerWithRadiantLayout.read_inheritable_attribute('layout').should == 'radiant'
22
+ end
23
+
24
+ it "should return 'radiant' when read_inheritable_attribute('layout') is called"
25
+
26
+ end
27
+
28
+ describe ControllerWithRadiantLayoutBlock do
29
+ dataset :layouts
30
+
31
+ before(:each) do
32
+ layouts(:main)
33
+ end
34
+
35
+ it "should have radiant layout block" do
36
+ ControllerWithRadiantLayoutBlock.read_inheritable_attribute('radiant_layout').should be_kind_of(Proc)
37
+ # This doesn't seem to work anymore, but calling "active_layout" on an instance still correctly returns "layouts/radiant.rhtml"
38
+ #ControllerWithRadiantLayoutBlock.read_inheritable_attribute('layout').should == 'radiant'
39
+ end
40
+
41
+ it "should return 'radiant' when read_inheritable_attribute('layout') is called"
42
+
43
+ end
44
+
@@ -0,0 +1,171 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe ShareLayouts::Helpers::ActionView do
4
+ include ShareLayouts::Helpers::ActionView
5
+
6
+ dataset :layouts_layouts, :layouts_pages
7
+ test_helper :page
8
+ attr_accessor :request, :response
9
+
10
+ MAIN_RESULT = <<-TEXT
11
+ <!DOCTYPE html>
12
+ <html>
13
+ <head>
14
+ <title>Title</title>
15
+ </head>
16
+ <body id="page" class="parent site">
17
+ something
18
+ </body>
19
+ </html>
20
+ TEXT
21
+
22
+ before(:each) do
23
+ @page = RailsPage.new(page_params(:class_name => "RailsPage"))
24
+ @content_for_layout = "something"
25
+ @radiant_layout = layouts(:parent).name
26
+ @request = OpenStruct.new(:path => "/some/page/")
27
+ end
28
+
29
+ it "should extract_content_captures_as_hash" do
30
+ extract_captures.should == {:body => "something"}
31
+ @content_for_sidebar = "sidebar"
32
+ extract_captures.should == {:body => "something", :sidebar => "sidebar"}
33
+ end
34
+
35
+ # testing assignment of layout
36
+ it "should assign_layout_of_page" do
37
+ assign_attributes!(@page)
38
+ @page.layout.should == layouts(:parent)
39
+ end
40
+
41
+ it "should assign_layout_of_page_when_missing" do
42
+ previous_layout = @page.layout
43
+ @radiant_layout = ''
44
+ assign_attributes!(@page)
45
+ previous_layout.should == @page.layout
46
+ end
47
+
48
+ # testing assignment of page.title
49
+ it "should assign_page_title_from_instance_var" do
50
+ @title = "My title"
51
+ assign_attributes!(@page)
52
+ @page.title.should == "My title"
53
+ end
54
+
55
+ it "should assign_page_title_from_capture" do
56
+ @content_for_title = "My title"
57
+ assign_attributes!(@page)
58
+ @page.title.should == "My title"
59
+ end
60
+
61
+ it "should assign_title_from_existing_page_title_when_not_specified" do
62
+ assign_attributes!(@page)
63
+ @page.title.should =~ /New Page/ # was 'New Page' before. I assume this changed in Radiant 0.8
64
+ end
65
+
66
+ it "should assign_empty_title_if_missing" do
67
+ @page.title = nil
68
+ @title.should be_nil
69
+ @content_for_title.should be_nil
70
+ @page.title.should be_nil
71
+ assign_attributes!(@page)
72
+ @page.title.should == ''
73
+ end
74
+
75
+ #testing assignment of page.breadcrumb
76
+ it "should assign_page_breadcrumb_from_instance_var" do
77
+ @breadcrumb = "My breadcrumb"
78
+ assign_attributes!(@page)
79
+ @page.breadcrumb.should == "My breadcrumb"
80
+ end
81
+
82
+ it "should assign_page_breadcrumb_from_capture" do
83
+ @content_for_breadcrumb = "My breadcrumb"
84
+ assign_attributes!(@page)
85
+ @page.breadcrumb.should == "My breadcrumb"
86
+ end
87
+
88
+ it "should assign_breadcrumb_from_existing_breadcrumb_when_not_specified" do
89
+ @page.breadcrumb = "existing breadcrumb"
90
+ assign_attributes!(@page)
91
+ @page.breadcrumb.should == 'existing breadcrumb'
92
+ end
93
+
94
+ it "should assign_breadcrumb_from_title_if_missing" do
95
+ @page.title = "Title into BC"
96
+ @page.breadcrumb = nil
97
+ @breadcrumb.should be_nil
98
+ @content_for_breadcrumb.should be_nil
99
+ @page.breadcrumb.should be_nil
100
+ assign_attributes!(@page)
101
+ @page.breadcrumb.should == 'Title into BC'
102
+ end
103
+
104
+ it "should assign_empty_breadcrumb_if_title_missing_too" do
105
+ @page.title = nil
106
+ @title.should be_nil
107
+ @content_for_title.should be_nil
108
+ @page.title.should be_nil
109
+ @page.breadcrumb = nil
110
+ @breadcrumb.should be_nil
111
+ @content_for_breadcrumb.should be_nil
112
+ @page.breadcrumb.should be_nil
113
+ assign_attributes!(@page)
114
+ @page.breadcrumb.should == ''
115
+ end
116
+
117
+ # testing assignment of page.breadcrumbs
118
+ it "should assign_breadcrumbs_from_instance_var" do
119
+ @breadcrumbs = "bc"
120
+ assign_attributes!(@page)
121
+ @page.breadcrumbs.should == 'bc'
122
+ end
123
+
124
+ it "should assign_breadcrumbs_from_capture" do
125
+ @content_for_breadcrumbs = "bc"
126
+ assign_attributes!(@page)
127
+ @page.breadcrumbs.should == 'bc'
128
+ end
129
+
130
+ it "should leave_breadcrumbs_nil_if_missing" do
131
+ @page.breadcrumbs = nil
132
+ @breadcrumbs.should be_nil
133
+ @content_for_breadcrumbs.should be_nil
134
+ @page.breadcrumbs.should be_nil
135
+ assign_attributes!(@page)
136
+ @page.breadcrumbs.should be_nil
137
+ end
138
+
139
+ # testing assigment of page.url
140
+ it "should assign_url_from_request_path" do
141
+ assign_attributes!(@page)
142
+ @page.url.should == '/some/page/'
143
+ end
144
+
145
+ # testing assigment of page.slug
146
+ it "should assign_slug_from_request_path" do
147
+ assign_attributes!(@page)
148
+ @page.slug.should == 'page'
149
+ end
150
+
151
+ # testing assignment of page.published_at
152
+ it "should assign_published_at" do
153
+ assign_attributes!(@page)
154
+ @page.published_at.should_not be_nil
155
+ end
156
+
157
+ it "should render_page" do
158
+ @title = "My Title"
159
+ radiant_layout.strip.should == MAIN_RESULT.strip
160
+ end
161
+
162
+ it "should find_page" do
163
+ @request.path = "/app/something/"
164
+ find_page.should == pages(:rails)
165
+ find_page.should be_a_kind_of(RailsPage)
166
+ @request.path = "/some-other/url/"
167
+ find_page.should_not == pages(:rails)
168
+ find_page.should be_a_kind_of(RailsPage)
169
+ end
170
+
171
+ end