nesta 0.11.1 → 0.13.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.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +21 -0
- data/.gitmodules +0 -0
- data/CHANGES +44 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +73 -55
- data/LICENSE +1 -1
- data/README.md +7 -14
- data/RELEASING.md +10 -9
- data/Rakefile +20 -3
- data/bin/nesta +1 -1
- data/config/deploy.rb.sample +1 -1
- data/lib/nesta/app.rb +4 -8
- data/lib/nesta/commands/demo/content.rb +28 -12
- data/lib/nesta/commands/edit.rb +2 -6
- data/lib/nesta/commands/new.rb +9 -11
- data/lib/nesta/commands/plugin/create.rb +7 -9
- data/lib/nesta/commands/template.rb +20 -0
- data/lib/nesta/commands/theme/create.rb +8 -8
- data/lib/nesta/commands/theme/enable.rb +3 -5
- data/lib/nesta/commands/theme/install.rb +12 -14
- data/lib/nesta/commands.rb +8 -0
- data/lib/nesta/config_file.rb +25 -0
- data/lib/nesta/helpers.rb +14 -0
- data/lib/nesta/models.rb +26 -22
- data/lib/nesta/navigation.rb +1 -1
- data/lib/nesta/system_command.rb +15 -0
- data/lib/nesta/version.rb +1 -1
- data/lib/nesta.rb +6 -1
- data/nesta.gemspec +11 -12
- data/templates/config/config.yml +1 -1
- 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/init.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.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 +33 -0
- data/test/integration/commands/edit_test.rb +21 -0
- data/test/integration/commands/new_test.rb +91 -0
- data/test/integration/commands/plugin/create_test.rb +131 -0
- data/test/integration/commands/theme/create_test.rb +41 -0
- data/test/integration/commands/theme/enable_test.rb +28 -0
- data/test/integration/commands/theme/install_test.rb +66 -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/temporary_files.rb +33 -0
- data/test/support/test_configuration.rb +19 -0
- data/test/test_helper.rb +26 -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/test/unit/system_command_test.rb +20 -0
- data/views/master.sass +1 -1
- metadata +90 -89
- data/.hound.yml +0 -2
- data/.rspec +0 -1
- data/.travis.yml +0 -6
- data/lib/nesta/commands/command.rb +0 -58
- data/smoke-test.sh +0 -107
- data/spec/atom_spec.rb +0 -141
- data/spec/commands/demo/content_spec.rb +0 -65
- data/spec/commands/edit_spec.rb +0 -27
- data/spec/commands/new_spec.rb +0 -88
- data/spec/commands/plugin/create_spec.rb +0 -97
- data/spec/commands/system_spec.rb +0 -25
- data/spec/commands/theme/create_spec.rb +0 -41
- data/spec/commands/theme/enable_spec.rb +0 -44
- data/spec/commands/theme/install_spec.rb +0 -56
- data/spec/config_spec.rb +0 -127
- data/spec/model_factory.rb +0 -92
- data/spec/models_spec.rb +0 -700
- data/spec/overrides_spec.rb +0 -132
- data/spec/page_spec.rb +0 -560
- data/spec/path_spec.rb +0 -28
- data/spec/plugin_spec.rb +0 -51
- data/spec/sitemap_spec.rb +0 -105
- data/spec/spec_helper.rb +0 -114
data/spec/plugin_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
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
DELETED
@@ -1,105 +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 "sitemap XML" do
|
5
|
-
include RequestSpecHelper
|
6
|
-
include ModelFactory
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
stub_configuration
|
10
|
-
@category = create_category do |path|
|
11
|
-
mock_file_stat(:stub, path, "3 Jan 2009, 15:07")
|
12
|
-
end
|
13
|
-
@article = create_article do |path|
|
14
|
-
mock_file_stat(:stub, path, "3 Jan 2009, 15:10")
|
15
|
-
end
|
16
|
-
skipped_page_definition = {
|
17
|
-
path: 'unlisted-page',
|
18
|
-
metadata: { 'flags' => 'skip-sitemap' }
|
19
|
-
}
|
20
|
-
@skipped = create_page(skipped_page_definition) do |path|
|
21
|
-
mock_file_stat(:stub, path, "3 Jan 2009, 15:07")
|
22
|
-
end
|
23
|
-
get "/sitemap.xml"
|
24
|
-
end
|
25
|
-
|
26
|
-
after(:each) do
|
27
|
-
Nesta::FileModel.purge_cache
|
28
|
-
remove_temp_directory
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should render successfully" do
|
32
|
-
last_response.should be_ok
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should have a urlset tag" do
|
36
|
-
namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"
|
37
|
-
assert_xpath "//urlset[@xmlns='#{namespace}']"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should reference the home page" do
|
41
|
-
assert_xpath "//urlset/url/loc", content: "http://example.org/"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should configure home page to be checked frequently" do
|
45
|
-
assert_xpath "//urlset/url/loc", content: "http://example.org/"
|
46
|
-
assert_xpath "//urlset/url/changefreq", content: "daily"
|
47
|
-
assert_xpath "//urlset/url/priority", content: "1.0"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should set the homepage lastmod from latest article" do
|
51
|
-
assert_xpath "//urlset/url/loc", content: "http://example.org/"
|
52
|
-
assert_xpath "//urlset/url/lastmod", content: "2009-01-03T15:10:00"
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_url(path)
|
56
|
-
"http://example.org/#{path}"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should reference category pages" do
|
60
|
-
assert_xpath "//urlset/url/loc", content: test_url(@category.path)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should reference article pages" do
|
64
|
-
assert_xpath "//urlset/url/loc", content: test_url(@article.path)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should not include pages that have the skip-sitemap flag set" do
|
68
|
-
assert_not_xpath "//urlset/url/loc", content: test_url(@skipped.path)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "sitemap XML lastmod" do
|
73
|
-
include ModelFactory
|
74
|
-
include RequestSpecHelper
|
75
|
-
|
76
|
-
before(:each) do
|
77
|
-
stub_configuration
|
78
|
-
end
|
79
|
-
|
80
|
-
after(:each) do
|
81
|
-
remove_temp_directory
|
82
|
-
Nesta::FileModel.purge_cache
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should be set for file based page" do
|
86
|
-
create_article do |path|
|
87
|
-
mock_file_stat(:stub, path, "3 January 2009, 15:37:01")
|
88
|
-
end
|
89
|
-
get "/sitemap.xml"
|
90
|
-
assert_selector("url loc:contains('my-article')")
|
91
|
-
assert_selector("url lastmod:contains('2009-01-03T15:37:01')")
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should be set to latest page for home page" do
|
95
|
-
create_article(path: "article-1") do |path|
|
96
|
-
mock_file_stat(:stub, path, "4 January 2009")
|
97
|
-
end
|
98
|
-
create_article(path: "article-2") do |path|
|
99
|
-
mock_file_stat(:stub, path, "3 January 2009")
|
100
|
-
end
|
101
|
-
get "/sitemap.xml"
|
102
|
-
assert_selector("url loc:contains('http://example.org/')")
|
103
|
-
assert_selector("url lastmod:contains('2009-01-04')")
|
104
|
-
end
|
105
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'rack/test'
|
3
|
-
require 'sinatra'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'webrat'
|
6
|
-
require 'webrat/core/matchers'
|
7
|
-
|
8
|
-
module Nesta
|
9
|
-
class App < Sinatra::Base
|
10
|
-
set :environment, :test
|
11
|
-
set :reload_templates, true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require File.expand_path('../lib/nesta/env', File.dirname(__FILE__))
|
16
|
-
require File.expand_path('../lib/nesta/app', File.dirname(__FILE__))
|
17
|
-
|
18
|
-
module ConfigSpecHelper
|
19
|
-
def stub_yaml_config
|
20
|
-
@config = {}
|
21
|
-
Nesta::Config.stub(:yaml_exists?).and_return(true)
|
22
|
-
Nesta::Config.stub(:yaml_conf).and_return(@config)
|
23
|
-
end
|
24
|
-
|
25
|
-
def stub_config_key(key, value, options = {})
|
26
|
-
stub_yaml_config unless @config
|
27
|
-
if options[:for_environment]
|
28
|
-
@config['test'] ||= {}
|
29
|
-
@config['test'][key] = value
|
30
|
-
else
|
31
|
-
@config[key] = value
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def stub_configuration(options = {})
|
36
|
-
stub_config_key('title', 'My blog', options)
|
37
|
-
stub_config_key('subtitle', 'about stuff', options)
|
38
|
-
stub_config_key(
|
39
|
-
'content', temp_path('content'), options.merge(rack_env: true))
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
module TempFileHelper
|
44
|
-
TEMP_DIR = File.expand_path('tmp', File.dirname(__FILE__))
|
45
|
-
|
46
|
-
def create_temp_directory
|
47
|
-
FileUtils.mkdir_p(TempFileHelper::TEMP_DIR)
|
48
|
-
end
|
49
|
-
|
50
|
-
def remove_temp_directory
|
51
|
-
FileUtils.rm_r(TempFileHelper::TEMP_DIR, force: true)
|
52
|
-
end
|
53
|
-
|
54
|
-
def temp_path(base)
|
55
|
-
File.join(TempFileHelper::TEMP_DIR, base)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
RSpec.configure do |config|
|
60
|
-
config.include(ConfigSpecHelper)
|
61
|
-
config.include(TempFileHelper)
|
62
|
-
config.include(Rack::Test::Methods)
|
63
|
-
end
|
64
|
-
|
65
|
-
module RequestSpecHelper
|
66
|
-
include Webrat::Matchers
|
67
|
-
|
68
|
-
def app
|
69
|
-
Nesta::App
|
70
|
-
end
|
71
|
-
|
72
|
-
def body
|
73
|
-
last_response.body
|
74
|
-
end
|
75
|
-
|
76
|
-
def assert_xpath(*args)
|
77
|
-
body.should have_xpath(*args)
|
78
|
-
end
|
79
|
-
|
80
|
-
def assert_not_xpath(*args)
|
81
|
-
body.should_not have_xpath(*args)
|
82
|
-
end
|
83
|
-
|
84
|
-
def assert_selector(*args)
|
85
|
-
body.should have_selector(*args)
|
86
|
-
end
|
87
|
-
|
88
|
-
def assert_not_selector(*args)
|
89
|
-
body.should_not have_selector(*args)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
shared_context "temporary working directory" do
|
94
|
-
before(:each) do
|
95
|
-
create_temp_directory
|
96
|
-
@project_path = temp_path('mysite.com')
|
97
|
-
end
|
98
|
-
|
99
|
-
after(:each) do
|
100
|
-
remove_temp_directory
|
101
|
-
end
|
102
|
-
|
103
|
-
def project_path(path)
|
104
|
-
File.join(@project_path, path)
|
105
|
-
end
|
106
|
-
|
107
|
-
def should_exist(file)
|
108
|
-
File.exist?(project_path(file)).should be_true
|
109
|
-
end
|
110
|
-
|
111
|
-
def create_config_yaml(text)
|
112
|
-
File.open(Nesta::Config.yaml_path, 'w') { |f| f.puts(text) }
|
113
|
-
end
|
114
|
-
end
|