radiant-layouts-extension 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/MIT-LICENSE +27 -0
- data/README.md +81 -0
- data/Rakefile +125 -0
- data/VERSION +1 -0
- data/app/models/rails_page.rb +39 -0
- data/app/views/layouts/radiant.html.haml +1 -0
- data/layouts_extension.rb +16 -0
- data/lib/nested_layouts.rb +2 -0
- data/lib/nested_layouts/tags.rb +127 -0
- data/lib/share_layouts.rb +2 -0
- data/lib/share_layouts/helper.rb +39 -0
- data/lib/share_layouts/radiant_layouts.rb +21 -0
- data/lib/tasks/layouts_extension_tasks.rake +34 -0
- data/radiant-layouts-extension.gemspec +94 -0
- data/spec/controllers/nested_layouts_spec.rb +45 -0
- data/spec/controllers/share_layouts_spec.rb +119 -0
- data/spec/datasets/nested_layouts_dataset.rb +38 -0
- data/spec/datasets/share_layouts_dataset.rb +38 -0
- data/spec/helpers/share_layouts_helper_spec.rb +168 -0
- data/spec/lib/nested_layouts/tags_spec.rb +91 -0
- data/spec/lib/share_layouts_extension_spec.rb +25 -0
- data/spec/models/rails_page_spec.rb +63 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +22 -0
- metadata +211 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe NestedLayouts::Tags do
|
4
|
+
dataset :pages
|
5
|
+
dataset :nested_layouts
|
6
|
+
|
7
|
+
describe '<r:inside_layout>, <r:layout> 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
|
+
<html>
|
13
|
+
<body class="parent">
|
14
|
+
<h1>Hi</h1>
|
15
|
+
</body>
|
16
|
+
</html>
|
17
|
+
CONTENT
|
18
|
+
pages(:parent_layout).should render(tag).as(expected)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should output tag within the body of class name for a child_layout' do
|
22
|
+
tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
|
23
|
+
expected = <<-CONTENT
|
24
|
+
<html>
|
25
|
+
<body class="child">
|
26
|
+
<h1>Hi</h1>
|
27
|
+
</body>
|
28
|
+
</html>
|
29
|
+
CONTENT
|
30
|
+
pages(:child_layout).should render(tag).as(expected)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '<r:if_layout>' do
|
36
|
+
|
37
|
+
it 'it should render the contents if true' do
|
38
|
+
tag = %{<r:inside_layout name='parent'><r:if_layout name='parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
39
|
+
expected = <<-CONTENT
|
40
|
+
<html>
|
41
|
+
<body class="parent">
|
42
|
+
<h1>Hi</h1>
|
43
|
+
</body>
|
44
|
+
</html>
|
45
|
+
CONTENT
|
46
|
+
pages(:parent_layout).should render(tag).as(expected)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'it should not render the contents if false' do
|
50
|
+
tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
|
51
|
+
expected = <<-CONTENT
|
52
|
+
<html>
|
53
|
+
<body class="parent">
|
54
|
+
|
55
|
+
</body>
|
56
|
+
</html>
|
57
|
+
CONTENT
|
58
|
+
pages(:parent_layout).should render(tag).as(expected)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '<r:unless_layout>' do
|
64
|
+
|
65
|
+
it 'it should not render the contents if true' do
|
66
|
+
tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
67
|
+
expected = <<-CONTENT
|
68
|
+
<html>
|
69
|
+
<body class="parent">
|
70
|
+
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
CONTENT
|
74
|
+
pages(:parent_layout).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:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
|
79
|
+
expected = <<-CONTENT
|
80
|
+
<html>
|
81
|
+
<body class="parent">
|
82
|
+
<h1>Hi</h1>
|
83
|
+
</body>
|
84
|
+
</html>
|
85
|
+
CONTENT
|
86
|
+
pages(:parent_layout).should render(tag).as(expected)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe LayoutsExtension do
|
4
|
+
|
5
|
+
context 'activate' do
|
6
|
+
|
7
|
+
it 'should have a RailsPage class to call' do
|
8
|
+
RailsPage.should_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should extend ActionController base methods' do
|
12
|
+
ActionController::Base.included_modules.include?(ShareLayouts::RadiantLayouts).should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should extend ActionView helper methods' do
|
16
|
+
ActionView::Base.included_modules.include?(ShareLayouts::Helper).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should extend Page base methods' do
|
20
|
+
Page.included_modules.include?(NestedLayouts::Tags).should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe RailsPage do
|
5
|
+
test_helper :render, :page
|
6
|
+
dataset :share_layouts, :pages
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@page = RailsPage.new(page_params(:class_name => "RailsPage"))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should redefine_breadcrumbs_tag" do
|
13
|
+
@page.should respond_to("tag:old_breadcrumbs")
|
14
|
+
@page.should respond_to("tag:breadcrumbs")
|
15
|
+
|
16
|
+
@page.breadcrumbs = "some breadcrumbs"
|
17
|
+
@page.should render("<r:breadcrumbs />").as("some breadcrumbs")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should use_old_breadcrumbs_tag_if_breadcrumbs_attr_is_nil" do
|
21
|
+
@page = pages(:rails_page)
|
22
|
+
@page.breadcrumbs = nil
|
23
|
+
@page.should render("<r:breadcrumbs nolinks='true' />").as("Homepage > App page")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should build_parts_from_hash" do
|
27
|
+
hash = {:body => "body", :sidebar => "sidebar"}
|
28
|
+
@page.build_parts_from_hash!(hash)
|
29
|
+
@page.parts.size.should == hash.keys.size
|
30
|
+
# Make sure we don't save them to the DB
|
31
|
+
@page.parts.all?(&:new_record?).should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should find_rails_page_for_sub_urls_that_do_not_match_an_existing_page" do
|
35
|
+
Page.find_by_url('/app/').should == pages(:rails_page)
|
36
|
+
Page.find_by_url('/app/some-other-url/').should == pages(:rails_page)
|
37
|
+
Page.find_by_url('/app/some-other-url/sub-url/').should == pages(:rails_page)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should find_page_if_sub_url_matches_one" do
|
41
|
+
Page.find_by_url('/app/child-page/').should == pages(:rails_page_child)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should find_page_for_non_sub_urls" do
|
45
|
+
Page.find_by_url('/other/').should == pages(:other)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should defer_to_default_url_when_not_initialized" do
|
49
|
+
pages(:rails_page).url.should == '/app/'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should modify_existing_parts_but_not_save_them" do
|
53
|
+
@page = pages(:rails_page)
|
54
|
+
@page.parts.create(:name => "sidebar", :content => "This is the sidebar.")
|
55
|
+
|
56
|
+
@page.build_parts_from_hash!(:body => "This is the body")
|
57
|
+
@page.part(:sidebar).content.should == 'This is the sidebar.'
|
58
|
+
|
59
|
+
@page.build_parts_from_hash!(:sidebar => "OVERRIDE")
|
60
|
+
@page.part(:sidebar).content.should == 'OVERRIDE'
|
61
|
+
@page.part(:sidebar).reload.content.should == 'This is the sidebar.'
|
62
|
+
end
|
63
|
+
end
|
data/spec/rcov.opts
ADDED
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
|
16
|
+
if File.directory?(File.dirname(__FILE__) + "/matchers")
|
17
|
+
Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
|
18
|
+
end
|
19
|
+
|
20
|
+
Spec::Runner.configure do |config|
|
21
|
+
config.mock_with :rr
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-layouts-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dirk Kelly
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-30 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
- 0
|
34
|
+
version: 1.3.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec-rails
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 31
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 3
|
49
|
+
- 2
|
50
|
+
version: 1.3.2
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: cucumber
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 53
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 8
|
65
|
+
- 5
|
66
|
+
version: 0.8.5
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber-rails
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 23
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 3
|
81
|
+
- 2
|
82
|
+
version: 0.3.2
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: database_cleaner
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 9
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 4
|
97
|
+
- 3
|
98
|
+
version: 0.4.3
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: ruby-debug
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 49
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
- 10
|
113
|
+
- 3
|
114
|
+
version: 0.10.3
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: webrat
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 49
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
- 10
|
129
|
+
- 3
|
130
|
+
version: 0.10.3
|
131
|
+
type: :development
|
132
|
+
version_requirements: *id007
|
133
|
+
description: Provides extensions to standard layouts, including nesting of layouts within each other and sharing radiant layouts with rails controllers
|
134
|
+
email: dk@squaretalent.com
|
135
|
+
executables: []
|
136
|
+
|
137
|
+
extensions: []
|
138
|
+
|
139
|
+
extra_rdoc_files:
|
140
|
+
- README.md
|
141
|
+
files:
|
142
|
+
- .gitignore
|
143
|
+
- MIT-LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- VERSION
|
147
|
+
- app/models/rails_page.rb
|
148
|
+
- app/views/layouts/radiant.html.haml
|
149
|
+
- layouts_extension.rb
|
150
|
+
- lib/nested_layouts.rb
|
151
|
+
- lib/nested_layouts/tags.rb
|
152
|
+
- lib/share_layouts.rb
|
153
|
+
- lib/share_layouts/helper.rb
|
154
|
+
- lib/share_layouts/radiant_layouts.rb
|
155
|
+
- lib/tasks/layouts_extension_tasks.rake
|
156
|
+
- radiant-layouts-extension.gemspec
|
157
|
+
- spec/controllers/nested_layouts_spec.rb
|
158
|
+
- spec/controllers/share_layouts_spec.rb
|
159
|
+
- spec/datasets/nested_layouts_dataset.rb
|
160
|
+
- spec/datasets/share_layouts_dataset.rb
|
161
|
+
- spec/helpers/share_layouts_helper_spec.rb
|
162
|
+
- spec/lib/nested_layouts/tags_spec.rb
|
163
|
+
- spec/lib/share_layouts_extension_spec.rb
|
164
|
+
- spec/models/rails_page_spec.rb
|
165
|
+
- spec/rcov.opts
|
166
|
+
- spec/spec.opts
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
has_rdoc: true
|
169
|
+
homepage: http://github.com/squaretalent/radiant-layouts-extension
|
170
|
+
licenses: []
|
171
|
+
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options:
|
174
|
+
- --charset=UTF-8
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
hash: 3
|
183
|
+
segments:
|
184
|
+
- 0
|
185
|
+
version: "0"
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: 3
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
version: "0"
|
195
|
+
requirements: []
|
196
|
+
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 1.3.7
|
199
|
+
signing_key:
|
200
|
+
specification_version: 3
|
201
|
+
summary: Provides extensions to standard layouts, including nesting and sharing
|
202
|
+
test_files:
|
203
|
+
- spec/controllers/nested_layouts_spec.rb
|
204
|
+
- spec/controllers/share_layouts_spec.rb
|
205
|
+
- spec/datasets/nested_layouts_dataset.rb
|
206
|
+
- spec/datasets/share_layouts_dataset.rb
|
207
|
+
- spec/helpers/share_layouts_helper_spec.rb
|
208
|
+
- spec/lib/nested_layouts/tags_spec.rb
|
209
|
+
- spec/lib/share_layouts_extension_spec.rb
|
210
|
+
- spec/models/rails_page_spec.rb
|
211
|
+
- spec/spec_helper.rb
|