nesta 0.9.9 → 0.9.10
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.
- data/.gitignore +1 -0
- data/CHANGES +18 -0
- data/Gemfile.lock +13 -17
- data/bin/nesta +13 -4
- data/lib/nesta/app.rb +5 -4
- data/lib/nesta/commands.rb +72 -1
- data/lib/nesta/models.rb +21 -3
- data/lib/nesta/overrides.rb +1 -1
- data/lib/nesta/plugin.rb +33 -0
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +3 -3
- data/spec/atom_spec.rb +1 -2
- data/spec/commands_spec.rb +79 -7
- data/spec/config_spec.rb +0 -2
- data/spec/fixtures/nesta-plugin-test/Gemfile +4 -0
- data/spec/fixtures/nesta-plugin-test/Rakefile +1 -0
- data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +3 -0
- data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +20 -0
- data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +7 -0
- data/spec/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +24 -0
- data/spec/model_factory.rb +0 -2
- data/spec/models_spec.rb +40 -18
- data/spec/overrides_spec.rb +8 -4
- data/spec/page_spec.rb +5 -11
- data/spec/plugin_spec.rb +51 -0
- data/spec/sitemap_spec.rb +2 -4
- data/spec/spec_helper.rb +35 -30
- data/views/atom.haml +1 -1
- metadata +45 -86
- data/lib/nesta/plugins.rb +0 -15
data/spec/config_spec.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Nesta
|
2
|
+
module Plugin
|
3
|
+
module Test
|
4
|
+
module Helpers
|
5
|
+
helpers do
|
6
|
+
# If your plugin needs any helper methods, add them here...
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class App
|
13
|
+
helpers Nesta::Plugin::Test::Helpers
|
14
|
+
end
|
15
|
+
|
16
|
+
class Page
|
17
|
+
def self.method_added_by_plugin
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nesta-plugin-test/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nesta-plugin-test"
|
7
|
+
s.version = Nesta::Plugin::Test::VERSION
|
8
|
+
s.authors = ["Graham Ashton"]
|
9
|
+
s.email = ["graham@effectif.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{TODO: Write a gem summary}
|
12
|
+
s.description = %q{TODO: Write a gem description}
|
13
|
+
|
14
|
+
s.rubyforge_project = "nesta-plugin-test"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/spec/model_factory.rb
CHANGED
data/spec/models_spec.rb
CHANGED
@@ -27,7 +27,6 @@ module ModelMatchers
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "Page", :shared => true do
|
30
|
-
include ConfigSpecHelper
|
31
30
|
include ModelFactory
|
32
31
|
include ModelMatchers
|
33
32
|
|
@@ -40,7 +39,7 @@ describe "Page", :shared => true do
|
|
40
39
|
end
|
41
40
|
|
42
41
|
after(:each) do
|
43
|
-
|
42
|
+
remove_temp_directory
|
44
43
|
Nesta::FileModel.purge_cache
|
45
44
|
end
|
46
45
|
|
@@ -119,7 +118,7 @@ describe "Page", :shared => true do
|
|
119
118
|
page.priority('another-page').should == 0
|
120
119
|
page.priority('and-another').should == -1
|
121
120
|
end
|
122
|
-
|
121
|
+
|
123
122
|
describe "with assigned pages" do
|
124
123
|
before(:each) do
|
125
124
|
@category = create_category
|
@@ -186,6 +185,27 @@ describe "Page", :shared => true do
|
|
186
185
|
Nesta::Page.find_articles.detect{|a| a == article}.should be_nil
|
187
186
|
end
|
188
187
|
end
|
188
|
+
|
189
|
+
describe "with pages in draft" do
|
190
|
+
before(:each) do
|
191
|
+
@category = create_category
|
192
|
+
@draft = create_page(:heading => 'Forthcoming content',
|
193
|
+
:path => 'foo/in-draft',
|
194
|
+
:metadata => {
|
195
|
+
'categories' => @category.path,
|
196
|
+
'flags' => 'draft'
|
197
|
+
})
|
198
|
+
Nesta::App.stub!(:production?).and_return(true)
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should not find assigned drafts" do
|
202
|
+
@category.pages.should_not include(@draft)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should not find drafts by path" do
|
206
|
+
Nesta::Page.find_by_path('foo/in-draft').should be_nil
|
207
|
+
end
|
208
|
+
end
|
189
209
|
|
190
210
|
describe "when finding articles" do
|
191
211
|
before(:each) do
|
@@ -337,14 +357,15 @@ describe "Page", :shared => true do
|
|
337
357
|
@read_more = 'Continue at your leisure'
|
338
358
|
@skillz = 'ruby, guitar, bowstaff'
|
339
359
|
@article = create_article(:metadata => {
|
340
|
-
'layout' => @layout,
|
341
|
-
'template' => @template,
|
342
360
|
'date' => @date.gsub('September', 'Sep'),
|
343
361
|
'description' => @description,
|
362
|
+
'flags' => 'draft, orange',
|
344
363
|
'keywords' => @keywords,
|
345
|
-
'
|
364
|
+
'layout' => @layout,
|
346
365
|
'read more' => @read_more,
|
347
|
-
'skillz' => @skillz
|
366
|
+
'skillz' => @skillz,
|
367
|
+
'summary' => @summary,
|
368
|
+
'template' => @template
|
348
369
|
})
|
349
370
|
end
|
350
371
|
|
@@ -404,9 +425,18 @@ describe "Page", :shared => true do
|
|
404
425
|
@article.summary.should match(/#{@summary.split('\n\n').last}/)
|
405
426
|
end
|
406
427
|
|
407
|
-
it "should allow
|
428
|
+
it "should allow access to metadata" do
|
408
429
|
@article.metadata('skillz').should == @skillz
|
409
430
|
end
|
431
|
+
|
432
|
+
it "should allow access to flags" do
|
433
|
+
@article.should be_flagged_as('draft')
|
434
|
+
@article.should be_flagged_as('orange')
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should know whether or not it's a draft" do
|
438
|
+
@article.should be_draft
|
439
|
+
end
|
410
440
|
end
|
411
441
|
|
412
442
|
describe "when checking last modification time" do
|
@@ -423,7 +453,6 @@ describe "Page", :shared => true do
|
|
423
453
|
end
|
424
454
|
|
425
455
|
describe "All types of page" do
|
426
|
-
include ConfigSpecHelper
|
427
456
|
include ModelFactory
|
428
457
|
|
429
458
|
before(:each) do
|
@@ -431,7 +460,7 @@ describe "All types of page" do
|
|
431
460
|
end
|
432
461
|
|
433
462
|
after(:each) do
|
434
|
-
|
463
|
+
remove_temp_directory
|
435
464
|
Nesta::FileModel.purge_cache
|
436
465
|
end
|
437
466
|
|
@@ -446,8 +475,6 @@ describe "All types of page" do
|
|
446
475
|
end
|
447
476
|
|
448
477
|
describe "Markdown page" do
|
449
|
-
include ConfigSpecHelper
|
450
|
-
|
451
478
|
before(:each) do
|
452
479
|
@extension = :mdown
|
453
480
|
end
|
@@ -467,8 +494,6 @@ describe "Markdown page" do
|
|
467
494
|
end
|
468
495
|
|
469
496
|
describe "Haml page" do
|
470
|
-
include ConfigSpecHelper
|
471
|
-
|
472
497
|
before(:each) do
|
473
498
|
@extension = :haml
|
474
499
|
end
|
@@ -486,8 +511,6 @@ describe "Haml page" do
|
|
486
511
|
end
|
487
512
|
|
488
513
|
describe "Textile page" do
|
489
|
-
include ConfigSpecHelper
|
490
|
-
|
491
514
|
before(:each) do
|
492
515
|
@extension = :textile
|
493
516
|
end
|
@@ -505,7 +528,6 @@ describe "Textile page" do
|
|
505
528
|
end
|
506
529
|
|
507
530
|
describe "Menu" do
|
508
|
-
include ConfigSpecHelper
|
509
531
|
include ModelFactory
|
510
532
|
|
511
533
|
before(:each) do
|
@@ -514,7 +536,7 @@ describe "Menu" do
|
|
514
536
|
end
|
515
537
|
|
516
538
|
after(:each) do
|
517
|
-
|
539
|
+
remove_temp_directory
|
518
540
|
Nesta::FileModel.purge_cache
|
519
541
|
end
|
520
542
|
|
data/spec/overrides_spec.rb
CHANGED
@@ -2,7 +2,6 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
2
|
require File.expand_path('model_factory', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Rendering" do
|
5
|
-
include ConfigSpecHelper
|
6
5
|
include ModelFactory
|
7
6
|
include RequestSpecHelper
|
8
7
|
|
@@ -28,7 +27,7 @@ describe "Rendering" do
|
|
28
27
|
|
29
28
|
before(:each) do
|
30
29
|
@app_root = Nesta::App.root
|
31
|
-
Nesta::App.root =
|
30
|
+
Nesta::App.root = temp_path('root')
|
32
31
|
@theme = 'my-theme'
|
33
32
|
@fixtures = []
|
34
33
|
stub_configuration
|
@@ -40,17 +39,22 @@ describe "Rendering" do
|
|
40
39
|
end
|
41
40
|
|
42
41
|
describe "when rendering stylesheets" do
|
43
|
-
it "should render
|
42
|
+
it "should render Sass stylesheets" do
|
44
43
|
create_template(:local, 'master.sass', "body\n width: 10px * 2")
|
45
44
|
get "/css/master.css"
|
46
45
|
body.should match(/width: 20px;/)
|
47
46
|
end
|
48
47
|
|
49
|
-
it "should render
|
48
|
+
it "should render SCSS stylesheets" do
|
50
49
|
create_template(:local, 'master.scss', "body {\n width: 10px * 2;\n}")
|
51
50
|
get "/css/master.css"
|
52
51
|
body.should match(/width: 20px;/)
|
53
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
|
54
58
|
end
|
55
59
|
|
56
60
|
describe "when local files exist" do
|
data/spec/page_spec.rb
CHANGED
@@ -56,7 +56,6 @@ describe "page that can display menus", :shared => true do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "The layout" do
|
59
|
-
include ConfigSpecHelper
|
60
59
|
include ModelFactory
|
61
60
|
include RequestSpecHelper
|
62
61
|
|
@@ -75,7 +74,6 @@ describe "The layout" do
|
|
75
74
|
end
|
76
75
|
|
77
76
|
describe "The home page" do
|
78
|
-
include ConfigSpecHelper
|
79
77
|
include ModelFactory
|
80
78
|
include RequestSpecHelper
|
81
79
|
|
@@ -93,7 +91,7 @@ describe "The home page" do
|
|
93
91
|
end
|
94
92
|
|
95
93
|
after(:each) do
|
96
|
-
|
94
|
+
remove_temp_directory
|
97
95
|
Nesta::FileModel.purge_cache
|
98
96
|
end
|
99
97
|
|
@@ -167,7 +165,6 @@ describe "The home page" do
|
|
167
165
|
end
|
168
166
|
|
169
167
|
describe "An article" do
|
170
|
-
include ConfigSpecHelper
|
171
168
|
include ModelFactory
|
172
169
|
include RequestSpecHelper
|
173
170
|
|
@@ -186,7 +183,7 @@ describe "An article" do
|
|
186
183
|
end
|
187
184
|
|
188
185
|
after(:each) do
|
189
|
-
|
186
|
+
remove_temp_directory
|
190
187
|
Nesta::FileModel.purge_cache
|
191
188
|
end
|
192
189
|
|
@@ -269,7 +266,6 @@ describe "An article" do
|
|
269
266
|
end
|
270
267
|
|
271
268
|
describe "A page" do
|
272
|
-
include ConfigSpecHelper
|
273
269
|
include ModelFactory
|
274
270
|
include RequestSpecHelper
|
275
271
|
|
@@ -278,7 +274,7 @@ describe "A page" do
|
|
278
274
|
end
|
279
275
|
|
280
276
|
after(:each) do
|
281
|
-
|
277
|
+
remove_temp_directory
|
282
278
|
Nesta::FileModel.purge_cache
|
283
279
|
end
|
284
280
|
|
@@ -398,7 +394,6 @@ describe "A page" do
|
|
398
394
|
end
|
399
395
|
|
400
396
|
describe "A Haml page" do
|
401
|
-
include ConfigSpecHelper
|
402
397
|
include ModelFactory
|
403
398
|
include RequestSpecHelper
|
404
399
|
|
@@ -407,7 +402,7 @@ describe "A Haml page" do
|
|
407
402
|
end
|
408
403
|
|
409
404
|
after(:each) do
|
410
|
-
|
405
|
+
remove_temp_directory
|
411
406
|
Nesta::FileModel.purge_cache
|
412
407
|
end
|
413
408
|
|
@@ -440,7 +435,6 @@ describe "A Haml page" do
|
|
440
435
|
end
|
441
436
|
|
442
437
|
describe "attachments" do
|
443
|
-
include ConfigSpecHelper
|
444
438
|
include ModelFactory
|
445
439
|
include RequestSpecHelper
|
446
440
|
|
@@ -457,7 +451,7 @@ describe "attachments" do
|
|
457
451
|
end
|
458
452
|
|
459
453
|
after(:each) do
|
460
|
-
|
454
|
+
remove_temp_directory
|
461
455
|
Nesta::FileModel.purge_cache
|
462
456
|
end
|
463
457
|
|
data/spec/plugin_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Plugin gem loading" do
|
4
|
+
include ConfigSpecHelper
|
5
|
+
|
6
|
+
def remove_plugin_from_list_of_required_files
|
7
|
+
$".delete_if { |path| path =~ /nesta-plugin-test/ } # feel free to vomit
|
8
|
+
end
|
9
|
+
|
10
|
+
def remove_plugin_constants
|
11
|
+
Nesta::Plugin::Test
|
12
|
+
rescue NameError
|
13
|
+
else
|
14
|
+
Nesta::Plugin::Test.send(:remove_const, :VERSION)
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
stub_configuration
|
19
|
+
@plugin_lib_path = File.expand_path(
|
20
|
+
File.join(%w(fixtures nesta-plugin-test lib)), File.dirname(__FILE__))
|
21
|
+
$LOAD_PATH.unshift(@plugin_lib_path)
|
22
|
+
Nesta::Plugin.loaded.clear
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
$LOAD_PATH.shift if $LOAD_PATH[0] == @plugin_lib_path
|
27
|
+
remove_plugin_from_list_of_required_files
|
28
|
+
remove_plugin_constants
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not occur prior to gem is required" do
|
32
|
+
Nesta::Plugin.loaded.should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should record loaded plugins" do
|
36
|
+
require 'nesta-plugin-test'
|
37
|
+
Nesta::Plugin.loaded.size.should == 1
|
38
|
+
Nesta::Plugin.loaded.last.should == 'nesta-plugin-test'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have loaded the plugin's module" do
|
42
|
+
require 'nesta-plugin-test'
|
43
|
+
Nesta::Plugin::Test::VERSION
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should initialize the plugin" do
|
47
|
+
require 'nesta-plugin-test'
|
48
|
+
Nesta::Plugin.initialize_plugins
|
49
|
+
Nesta::Page.should respond_to(:method_added_by_plugin)
|
50
|
+
end
|
51
|
+
end
|
data/spec/sitemap_spec.rb
CHANGED
@@ -2,7 +2,6 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
2
|
require File.expand_path('model_factory', File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "sitemap XML" do
|
5
|
-
include ConfigSpecHelper
|
6
5
|
include RequestSpecHelper
|
7
6
|
include ModelFactory
|
8
7
|
|
@@ -19,7 +18,7 @@ describe "sitemap XML" do
|
|
19
18
|
|
20
19
|
after(:each) do
|
21
20
|
Nesta::FileModel.purge_cache
|
22
|
-
|
21
|
+
remove_temp_directory
|
23
22
|
end
|
24
23
|
|
25
24
|
it "should render successfully" do
|
@@ -62,7 +61,6 @@ describe "sitemap XML" do
|
|
62
61
|
end
|
63
62
|
|
64
63
|
describe "sitemap XML lastmod" do
|
65
|
-
include ConfigSpecHelper
|
66
64
|
include ModelFactory
|
67
65
|
include RequestSpecHelper
|
68
66
|
|
@@ -71,7 +69,7 @@ describe "sitemap XML lastmod" do
|
|
71
69
|
end
|
72
70
|
|
73
71
|
after(:each) do
|
74
|
-
|
72
|
+
remove_temp_directory
|
75
73
|
Nesta::FileModel.purge_cache
|
76
74
|
end
|
77
75
|
|