nesta 0.9.11 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -11
- data/.gitmodules +6 -0
- data/.hound.yml +2 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/.travis.yml +11 -0
- data/CHANGES +250 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +89 -33
- data/Guardfile +7 -0
- data/LICENSE +1 -1
- data/README.md +38 -6
- data/RELEASING.md +21 -0
- data/Rakefile +20 -4
- data/bin/nesta +131 -14
- data/config.ru +3 -0
- data/lib/nesta.rb +9 -1
- data/lib/nesta/app.rb +21 -107
- data/lib/nesta/commands.rb +5 -256
- data/lib/nesta/commands/command.rb +57 -0
- data/lib/nesta/commands/demo.rb +1 -0
- data/lib/nesta/commands/demo/content.rb +56 -0
- data/lib/nesta/commands/edit.rb +21 -0
- data/lib/nesta/commands/new.rb +57 -0
- data/lib/nesta/commands/plugin.rb +1 -0
- data/lib/nesta/commands/plugin/create.rb +82 -0
- data/lib/nesta/commands/theme.rb +3 -0
- data/lib/nesta/commands/theme/create.rb +36 -0
- data/lib/nesta/commands/theme/enable.rb +22 -0
- data/lib/nesta/commands/theme/install.rb +31 -0
- data/lib/nesta/config.rb +51 -22
- data/lib/nesta/helpers.rb +115 -0
- data/lib/nesta/models.rb +111 -70
- data/lib/nesta/navigation.rb +36 -12
- data/lib/nesta/overrides.rb +10 -5
- data/lib/nesta/plugin.rb +10 -8
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +14 -13
- data/templates/Gemfile +6 -3
- data/templates/config.ru +3 -0
- data/templates/config/config.yml +14 -14
- data/templates/config/deploy.rb +2 -2
- data/templates/index.haml +2 -0
- data/templates/plugins/Gemfile +4 -0
- data/templates/plugins/README.md +13 -0
- data/templates/plugins/Rakefile +58 -0
- data/templates/plugins/gitignore +3 -0
- data/templates/plugins/lib/init.rb +13 -0
- data/templates/plugins/lib/required.rb +3 -0
- data/templates/plugins/lib/version.rb +5 -0
- data/templates/plugins/plugin.gemspec +28 -0
- data/templates/themes/README.md +1 -1
- data/templates/themes/app.rb +1 -1
- data/templates/themes/views/layout.haml +7 -0
- data/templates/themes/views/master.sass +3 -0
- data/templates/themes/views/page.haml +1 -0
- data/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
- data/test/integration/atom_feed_test.rb +178 -0
- data/test/integration/commands/demo/content_test.rb +31 -0
- data/test/integration/commands/edit_test.rb +21 -0
- data/test/integration/commands/new_test.rb +120 -0
- data/test/integration/commands/plugin/create_test.rb +128 -0
- data/test/integration/commands/theme/create_test.rb +35 -0
- data/test/integration/commands/theme/enable_test.rb +22 -0
- data/test/integration/commands/theme/install_test.rb +62 -0
- data/test/integration/default_theme_test.rb +220 -0
- data/test/integration/overrides_test.rb +118 -0
- data/test/integration/route_handlers_test.rb +96 -0
- data/test/integration/sitemap_test.rb +85 -0
- data/test/integration_test_helper.rb +61 -0
- data/test/support/model_factory.rb +169 -0
- data/test/support/silence_commands_during_tests.rb +5 -0
- data/test/support/temporary_files.rb +33 -0
- data/test/support/test_configuration.rb +19 -0
- data/test/test_helper.rb +26 -0
- data/test/unit/commands_test.rb +23 -0
- data/test/unit/config_test.rb +138 -0
- data/test/unit/file_model_test.rb +71 -0
- data/test/unit/menu_test.rb +82 -0
- data/test/unit/page_test.rb +571 -0
- data/test/unit/path_test.rb +41 -0
- data/test/unit/plugin_test.rb +47 -0
- data/views/analytics.haml +9 -10
- data/views/atom.haml +4 -4
- data/views/comments.haml +1 -1
- data/views/error.haml +1 -1
- data/views/feed.haml +1 -1
- data/views/layout.haml +6 -3
- data/views/master.sass +144 -134
- data/views/mixins.sass +53 -28
- data/views/normalize.scss +396 -0
- data/views/page_meta.haml +2 -2
- data/views/sitemap.haml +2 -2
- data/views/summaries.haml +2 -2
- metadata +258 -232
- data/lib/nesta/cache.rb +0 -139
- data/lib/nesta/nesta.rb +0 -7
- data/spec/atom_spec.rb +0 -138
- data/spec/commands_spec.rb +0 -364
- data/spec/config_spec.rb +0 -67
- data/spec/model_factory.rb +0 -92
- data/spec/models_spec.rb +0 -588
- data/spec/overrides_spec.rb +0 -132
- data/spec/page_spec.rb +0 -498
- data/spec/path_spec.rb +0 -28
- data/spec/plugin_spec.rb +0 -51
- data/spec/sitemap_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -76
data/spec/overrides_spec.rb
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('model_factory', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "Rendering" do
|
5
|
-
include ModelFactory
|
6
|
-
include RequestSpecHelper
|
7
|
-
|
8
|
-
def create_fixture(type, name, content)
|
9
|
-
base_path = {
|
10
|
-
:local => Nesta::Path.local,
|
11
|
-
:theme => Nesta::Path.themes(@theme)
|
12
|
-
}[type]
|
13
|
-
path = File.join(base_path, name)
|
14
|
-
@fixtures << path
|
15
|
-
FileUtils.mkdir_p(File.dirname(path))
|
16
|
-
open(path, 'w') { |file| file.write(content) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_template(type, name, content)
|
20
|
-
create_fixture(type, File.join('views', 'layout.haml'), '= yield')
|
21
|
-
create_fixture(type, File.join('views', name), content)
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_app_file(type)
|
25
|
-
create_fixture(type, 'app.rb', "DEFINED_IN_#{type.to_s.upcase}_FILE = true")
|
26
|
-
end
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
@app_root = Nesta::App.root
|
30
|
-
Nesta::App.root = temp_path('root')
|
31
|
-
@theme = 'my-theme'
|
32
|
-
@fixtures = []
|
33
|
-
stub_configuration
|
34
|
-
end
|
35
|
-
|
36
|
-
after(:each) do
|
37
|
-
@fixtures.each { |path| FileUtils.rm(path) if File.exist?(path) }
|
38
|
-
Nesta::App.root = @app_root
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "when rendering stylesheets" do
|
42
|
-
it "should render Sass stylesheets" do
|
43
|
-
create_template(:local, 'master.sass', "body\n width: 10px * 2")
|
44
|
-
get "/css/master.css"
|
45
|
-
body.should match(/width: 20px;/)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should render SCSS stylesheets" do
|
49
|
-
create_template(:local, 'master.scss', "body {\n width: 10px * 2;\n}")
|
50
|
-
get "/css/master.css"
|
51
|
-
body.should match(/width: 20px;/)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should render the Gem's stylesheet if no other's found" do
|
55
|
-
get "/css/master.css"
|
56
|
-
last_response.should be_ok
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "when local files exist" do
|
61
|
-
before(:each) do
|
62
|
-
create_template(:local, 'page.haml', '%p Local template')
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should use local application files" do
|
66
|
-
create_app_file(:local)
|
67
|
-
Nesta::Overrides.load_local_app
|
68
|
-
Object.const_get(:DEFINED_IN_LOCAL_FILE).should be_true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should use local template in place of default" do
|
72
|
-
get create_category.abspath
|
73
|
-
body.should have_tag("p", "Local template")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "when theme installed" do
|
78
|
-
before(:each) do
|
79
|
-
create_template(:theme, 'page.haml', '%p Theme template')
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should not require theme application file automatically" do
|
83
|
-
create_app_file(:theme)
|
84
|
-
lambda {
|
85
|
-
Object.const_get(:DEFINED_IN_THEME_FILE)
|
86
|
-
}.should raise_error(NameError)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should not use theme templates automatically" do
|
90
|
-
get create_category.abspath
|
91
|
-
body.should_not have_tag("p", "Theme template")
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "and configured" do
|
95
|
-
before(:each) do
|
96
|
-
stub_config_key("theme", @theme)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should require theme application file" do
|
100
|
-
create_app_file(:theme)
|
101
|
-
Nesta::Overrides.load_theme_app
|
102
|
-
Object.const_get(:DEFINED_IN_THEME_FILE).should be_true
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should use theme's template in place of default" do
|
106
|
-
get create_category.abspath
|
107
|
-
body.should have_tag("p", "Theme template")
|
108
|
-
end
|
109
|
-
|
110
|
-
context "and local files exist" do
|
111
|
-
before(:each) do
|
112
|
-
create_template(:local, "page.haml", "%p Local template")
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should require local and theme application files" do
|
116
|
-
create_app_file(:local)
|
117
|
-
create_app_file(:theme)
|
118
|
-
Nesta::Overrides.load_theme_app
|
119
|
-
Nesta::Overrides.load_local_app
|
120
|
-
Object.const_get(:DEFINED_IN_LOCAL_FILE).should be_true
|
121
|
-
Object.const_get(:DEFINED_IN_THEME_FILE).should be_true
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should use local template" do
|
125
|
-
get create_category.abspath
|
126
|
-
body.should_not have_tag("p", "Theme template")
|
127
|
-
body.should have_tag("p", "Local template")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
data/spec/page_spec.rb
DELETED
@@ -1,498 +0,0 @@
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('model_factory', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "page with keyword and description", :shared => true do
|
5
|
-
it "should set the keywords meta tag" do
|
6
|
-
do_get
|
7
|
-
body.should have_tag("meta[@name=keywords][@content='#{@keywords}']")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should set description meta tag" do
|
11
|
-
do_get
|
12
|
-
body.should have_tag("meta[@name=description][@content='#{@description}']")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "page that can display menus", :shared => true do
|
17
|
-
it "should not display menu by default" do
|
18
|
-
do_get
|
19
|
-
body.should_not have_tag("#sidebar ul.menu")
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "and simple menu configured" do
|
23
|
-
before(:each) do
|
24
|
-
create_menu(@category.path)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should link to top level menu items" do
|
28
|
-
do_get
|
29
|
-
body.should have_tag(
|
30
|
-
"ul.menu a[@href=#{@category.abspath}]", Regexp.new(@category.heading))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "and nested menu configured" do
|
35
|
-
before(:each) do
|
36
|
-
@level2 = create_category(:path => "level-2", :heading => "Level 2")
|
37
|
-
@level3 = create_category(:path => "level-3", :heading => "Level 3")
|
38
|
-
text = <<-EOF
|
39
|
-
#{@category.abspath}
|
40
|
-
#{@level2.abspath}
|
41
|
-
#{@level3.abspath}
|
42
|
-
EOF
|
43
|
-
create_menu(text)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should display first level of nested sub menus" do
|
47
|
-
do_get
|
48
|
-
body.should have_tag("ul.menu li ul li a", Regexp.new(@level2.heading))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should not display nested menus to arbitrary depth" do
|
52
|
-
do_get
|
53
|
-
body.should_not have_tag("ul.menu li ul li ul")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "The layout" do
|
59
|
-
include ModelFactory
|
60
|
-
include RequestSpecHelper
|
61
|
-
|
62
|
-
it "should not include GA JavaScript by default" do
|
63
|
-
stub_configuration
|
64
|
-
get "/"
|
65
|
-
body.should_not have_tag("script", /'_setAccount', 'UA-1234'/)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should include GA JavaScript if configured" do
|
69
|
-
stub_config_key('google_analytics_code', 'UA-1234', :rack_env => true)
|
70
|
-
stub_configuration
|
71
|
-
get '/'
|
72
|
-
body.should have_tag('script', /'_setAccount', 'UA-1234'/)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "The home page" do
|
77
|
-
include ModelFactory
|
78
|
-
include RequestSpecHelper
|
79
|
-
|
80
|
-
before(:each) do
|
81
|
-
stub_configuration
|
82
|
-
template_path = File.expand_path(
|
83
|
-
'templates', File.dirname(File.dirname(__FILE__)))
|
84
|
-
create_category(
|
85
|
-
:path => 'index',
|
86
|
-
:ext => :haml,
|
87
|
-
:heading => 'Home',
|
88
|
-
:content => File.read(File.join(template_path, 'index.haml'))
|
89
|
-
)
|
90
|
-
create_category
|
91
|
-
end
|
92
|
-
|
93
|
-
after(:each) do
|
94
|
-
remove_temp_directory
|
95
|
-
Nesta::FileModel.purge_cache
|
96
|
-
end
|
97
|
-
|
98
|
-
def do_get
|
99
|
-
get "/"
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "when categories exist" do
|
103
|
-
before(:each) do
|
104
|
-
@category = create_category
|
105
|
-
end
|
106
|
-
|
107
|
-
it_should_behave_like "page that can display menus"
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should render successfully" do
|
111
|
-
do_get
|
112
|
-
last_response.should be_ok
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should display site title in hgroup tag" do
|
116
|
-
pending "Hpricot doesn't support HTML5"
|
117
|
-
body.should have_tag('hgroup h1', /My blog/)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should display site subtitle in hgroup tag" do
|
121
|
-
pending "Hpricot doesn't support HTML5"
|
122
|
-
do_get
|
123
|
-
body.should have_tag('hgroup h2', /about stuff/)
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "when articles have no summary" do
|
127
|
-
before(:each) do
|
128
|
-
create_article
|
129
|
-
do_get
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should display full content of article" do
|
133
|
-
body.should have_tag("p", "Content goes here")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should not display read more link" do
|
137
|
-
body.should_not have_tag("a", /continue/i)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "when articles have metadata" do
|
142
|
-
before(:each) do
|
143
|
-
@summary = 'Multiline\n\nsummary'
|
144
|
-
@read_more = "Continue at your leisure"
|
145
|
-
@article = create_article(:metadata => {
|
146
|
-
"summary" => @summary,
|
147
|
-
"read more" => @read_more
|
148
|
-
})
|
149
|
-
do_get
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should display link to article in h2 tag" do
|
153
|
-
body.should have_tag(
|
154
|
-
"h1 a[@href=#{@article.abspath}]", /^\s*#{@article.heading}$/)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should display article summary if available" do
|
158
|
-
body.should have_tag('p', @summary.split('\n\n').first)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should display read more link" do
|
162
|
-
body.should have_tag("a[@href=#{@article.abspath}]", @read_more)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe "An article" do
|
168
|
-
include ModelFactory
|
169
|
-
include RequestSpecHelper
|
170
|
-
|
171
|
-
before(:each) do
|
172
|
-
stub_configuration
|
173
|
-
@date = '07 September 2009'
|
174
|
-
@keywords = 'things, stuff'
|
175
|
-
@description = 'Page about stuff'
|
176
|
-
@summary = 'Multiline\n\nsummary'
|
177
|
-
@article = create_article(:metadata => {
|
178
|
-
'date' => @date.gsub('September', 'Sep'),
|
179
|
-
'description' => @description,
|
180
|
-
'keywords' => @keywords,
|
181
|
-
'summary' => @summary
|
182
|
-
})
|
183
|
-
end
|
184
|
-
|
185
|
-
after(:each) do
|
186
|
-
remove_temp_directory
|
187
|
-
Nesta::FileModel.purge_cache
|
188
|
-
end
|
189
|
-
|
190
|
-
def do_get
|
191
|
-
get @article.abspath
|
192
|
-
end
|
193
|
-
|
194
|
-
it_should_behave_like "page with keyword and description"
|
195
|
-
|
196
|
-
describe "when categories exist" do
|
197
|
-
before(:each) do
|
198
|
-
@category = create_category
|
199
|
-
end
|
200
|
-
|
201
|
-
it_should_behave_like "page that can display menus"
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should render successfully" do
|
205
|
-
do_get
|
206
|
-
last_response.should be_ok
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should display the heading" do
|
210
|
-
do_get
|
211
|
-
body.should have_tag('h1', 'My article')
|
212
|
-
end
|
213
|
-
|
214
|
-
it "should use heading for title tag" do
|
215
|
-
do_get
|
216
|
-
body.should have_tag('title', 'My article - My blog')
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should display the date" do
|
220
|
-
do_get
|
221
|
-
body.should have_tag('time', @date)
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should display the content" do
|
225
|
-
do_get
|
226
|
-
body.should have_tag('p', 'Content goes here')
|
227
|
-
end
|
228
|
-
|
229
|
-
describe "that is assigned to categories" do
|
230
|
-
before(:each) do
|
231
|
-
create_category(:heading => 'Apple', :path => 'the-apple')
|
232
|
-
@category = create_category(:heading => 'Banana', :path => 'banana')
|
233
|
-
@article = create_article(
|
234
|
-
:path => "#{@category.path}/article",
|
235
|
-
:metadata => { 'categories' => 'banana, the-apple' }
|
236
|
-
)
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should render successfully" do
|
240
|
-
do_get
|
241
|
-
last_response.should be_ok
|
242
|
-
end
|
243
|
-
|
244
|
-
it "should link to each category" do
|
245
|
-
pending "Hpricot doesn't support HTML5"
|
246
|
-
do_get
|
247
|
-
body.should have_tag("nav.categories") do |categories|
|
248
|
-
categories.should have_tag("a[@href=/banana]", "Banana")
|
249
|
-
categories.should have_tag("a[@href=/the-apple]", "Apple")
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should link to a category in breadcrumb" do
|
254
|
-
pending "Hpricot doesn't support HTML5"
|
255
|
-
do_get
|
256
|
-
body.should have_tag(
|
257
|
-
"nav.breadcrumb/a[@href=#{@category.abspath}]", @category.heading)
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should contain category name in page title" do
|
261
|
-
do_get
|
262
|
-
body.should_not have_tag("title", /My blog/)
|
263
|
-
body.should have_tag("title", /- #{@category.heading}$/)
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
describe "A page" do
|
269
|
-
include ModelFactory
|
270
|
-
include RequestSpecHelper
|
271
|
-
|
272
|
-
before(:each) do
|
273
|
-
stub_configuration
|
274
|
-
end
|
275
|
-
|
276
|
-
after(:each) do
|
277
|
-
remove_temp_directory
|
278
|
-
Nesta::FileModel.purge_cache
|
279
|
-
end
|
280
|
-
|
281
|
-
def do_get
|
282
|
-
get @category.abspath
|
283
|
-
end
|
284
|
-
|
285
|
-
describe "that doesn't exist" do
|
286
|
-
it "should render the 404 page" do
|
287
|
-
get "/no-such-page"
|
288
|
-
last_response.should_not be_ok
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe "that has meta data" do
|
293
|
-
before(:each) do
|
294
|
-
@title = 'Different title'
|
295
|
-
@content = "Page content"
|
296
|
-
@description = "Page about stuff"
|
297
|
-
@keywords = "things, stuff"
|
298
|
-
@articles_heading = "Posts about this stuff"
|
299
|
-
@category = create_category(
|
300
|
-
:content => "# My category\n\n#{@content}",
|
301
|
-
:metadata => {
|
302
|
-
'title' => @title,
|
303
|
-
'description' => @description,
|
304
|
-
'keywords' => @keywords,
|
305
|
-
'articles heading' => @articles_heading
|
306
|
-
}
|
307
|
-
)
|
308
|
-
end
|
309
|
-
|
310
|
-
it_should_behave_like "page with keyword and description"
|
311
|
-
it_should_behave_like "page that can display menus"
|
312
|
-
|
313
|
-
describe "whose URL ends in /" do
|
314
|
-
it "should be redirected, removing the slash" do
|
315
|
-
get @category.abspath + '/'
|
316
|
-
last_response.should be_redirect
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
it "should render successfully" do
|
321
|
-
do_get
|
322
|
-
last_response.should be_ok
|
323
|
-
end
|
324
|
-
|
325
|
-
it "should display the heading" do
|
326
|
-
do_get
|
327
|
-
body.should have_tag('h1', @category.heading)
|
328
|
-
end
|
329
|
-
|
330
|
-
it "should use title metadata to set heading" do
|
331
|
-
do_get
|
332
|
-
body.should have_tag('title', @title)
|
333
|
-
end
|
334
|
-
|
335
|
-
it "should display the content" do
|
336
|
-
do_get
|
337
|
-
body.should have_tag("p", @content)
|
338
|
-
end
|
339
|
-
|
340
|
-
describe "with associated pages" do
|
341
|
-
before(:each) do
|
342
|
-
@category1 = create_category(
|
343
|
-
:path => 'category1',
|
344
|
-
:heading => 'Category 1',
|
345
|
-
:metadata => {
|
346
|
-
'categories' => 'category-prefix/my-category:-1'
|
347
|
-
}
|
348
|
-
)
|
349
|
-
@category2 = create_category(
|
350
|
-
:path => 'category2',
|
351
|
-
:heading => 'Category 2',
|
352
|
-
:metadata => {
|
353
|
-
'categories' => 'category-prefix/my-category:1'
|
354
|
-
}
|
355
|
-
)
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should list highest priority pages at the top" do
|
359
|
-
do_get
|
360
|
-
body.should have_tag('li:nth-child(1) h1 a', 'Category 2')
|
361
|
-
body.should have_tag('li:nth-child(2) h1 a', 'Category 1')
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
describe "with associated articles" do
|
366
|
-
before(:each) do
|
367
|
-
@article = create_article(
|
368
|
-
:path => "another-page",
|
369
|
-
:heading => "Categorised",
|
370
|
-
:metadata => { :categories => @category.path },
|
371
|
-
:content => "Article content"
|
372
|
-
)
|
373
|
-
@article2 = create_article(
|
374
|
-
:path => "second-article", :heading => "Second article")
|
375
|
-
end
|
376
|
-
|
377
|
-
it "should display links to articles" do
|
378
|
-
do_get
|
379
|
-
body.should have_tag(
|
380
|
-
"h1 a[@href='#{@article.abspath}']", /^\s*#{@article.heading}$/)
|
381
|
-
body.should_not have_tag("h3", @article2.heading)
|
382
|
-
end
|
383
|
-
|
384
|
-
it "should display the article heading" do
|
385
|
-
do_get
|
386
|
-
body.should have_tag('h1', @articles_heading)
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
it "should not include Disqus comments by default" do
|
391
|
-
do_get
|
392
|
-
body.should_not have_tag('#disqus_thread')
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
describe "that is configured to show Disqus comments" do
|
397
|
-
before(:each) do
|
398
|
-
stub_config_key("disqus_short_name", "mysite")
|
399
|
-
@category = create_category
|
400
|
-
end
|
401
|
-
|
402
|
-
it "should display Disqus comments" do
|
403
|
-
do_get
|
404
|
-
body.should have_tag('#disqus_thread')
|
405
|
-
body.should have_tag('script[@src*="mysite.disqus.com/embed.js"]')
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
describe "A Haml page" do
|
411
|
-
include ModelFactory
|
412
|
-
include RequestSpecHelper
|
413
|
-
|
414
|
-
before(:each) do
|
415
|
-
stub_configuration
|
416
|
-
end
|
417
|
-
|
418
|
-
after(:each) do
|
419
|
-
remove_temp_directory
|
420
|
-
Nesta::FileModel.purge_cache
|
421
|
-
end
|
422
|
-
|
423
|
-
it "should be able to access helper methods" do
|
424
|
-
create_page(
|
425
|
-
:path => "a-page",
|
426
|
-
:ext => :haml,
|
427
|
-
:content => "%div= format_date(Date.new(2010, 11, 23))"
|
428
|
-
)
|
429
|
-
get "/a-page"
|
430
|
-
body.should have_tag("div", "23 November 2010")
|
431
|
-
end
|
432
|
-
|
433
|
-
it "should access helpers when rendering articles on a category page" do
|
434
|
-
category = create_page(
|
435
|
-
:path => "a-page",
|
436
|
-
:heading => "First heading",
|
437
|
-
:content => "Blah blah"
|
438
|
-
)
|
439
|
-
create_article(
|
440
|
-
:path => "an-article",
|
441
|
-
:ext => :haml,
|
442
|
-
:heading => "First heading",
|
443
|
-
:metadata => { :categories => category.path },
|
444
|
-
:content => "%h1 Second heading\n\n%div= format_date(Date.new(2010, 11, 23))"
|
445
|
-
)
|
446
|
-
get "/a-page"
|
447
|
-
body.should have_tag("div", "23 November 2010")
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
describe "attachments" do
|
452
|
-
include ModelFactory
|
453
|
-
include RequestSpecHelper
|
454
|
-
|
455
|
-
before(:each) do
|
456
|
-
stub_configuration
|
457
|
-
create_content_directories
|
458
|
-
end
|
459
|
-
|
460
|
-
after(:each) do
|
461
|
-
remove_temp_directory
|
462
|
-
Nesta::FileModel.purge_cache
|
463
|
-
end
|
464
|
-
|
465
|
-
describe "in the attachments folder" do
|
466
|
-
before(:each) do
|
467
|
-
path = File.join(Nesta::Config.attachment_path, 'test.txt')
|
468
|
-
File.open(path, 'w') { |file| file.write("I'm a test attachment") }
|
469
|
-
end
|
470
|
-
|
471
|
-
it "should be served successfully" do
|
472
|
-
get "/attachments/test.txt"
|
473
|
-
last_response.should be_ok
|
474
|
-
end
|
475
|
-
|
476
|
-
it "should be sent to the client" do
|
477
|
-
get "/attachments/test.txt"
|
478
|
-
body.should include("I'm a test attachment")
|
479
|
-
end
|
480
|
-
|
481
|
-
it "should set the appropriate MIME type" do
|
482
|
-
get "/attachments/test.txt"
|
483
|
-
last_response.headers["Content-Type"].should =~ Regexp.new("^text/plain")
|
484
|
-
end
|
485
|
-
end
|
486
|
-
|
487
|
-
describe "outside the attachments folder" do
|
488
|
-
before(:each) do
|
489
|
-
path = File.join(Nesta::Config.page_path, 'index.haml')
|
490
|
-
File.open(path, 'w') { |file| file.write('%h1 Test page') }
|
491
|
-
end
|
492
|
-
|
493
|
-
it "should be directory traversal free" do
|
494
|
-
get '/attachments/../pages/index.haml'
|
495
|
-
last_response.should_not be_ok
|
496
|
-
end
|
497
|
-
end
|
498
|
-
end
|