nesta 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +5 -5
  2. data/.gitmodules +6 -0
  3. data/.travis.yml +9 -4
  4. data/CHANGES +18 -2
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +70 -54
  7. data/LICENSE +1 -1
  8. data/RELEASING.md +5 -6
  9. data/Rakefile +20 -3
  10. data/lib/nesta/app.rb +4 -8
  11. data/lib/nesta/commands/command.rb +1 -2
  12. data/lib/nesta/commands/demo/content.rb +23 -5
  13. data/lib/nesta/commands/theme/install.rb +9 -7
  14. data/lib/nesta/helpers.rb +14 -0
  15. data/lib/nesta/models.rb +26 -22
  16. data/lib/nesta/navigation.rb +1 -1
  17. data/lib/nesta/version.rb +1 -1
  18. data/nesta.gemspec +10 -11
  19. data/templates/config/config.yml +1 -1
  20. data/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
  21. data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
  22. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
  23. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +0 -0
  24. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
  25. data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
  26. data/test/integration/atom_feed_test.rb +178 -0
  27. data/test/integration/commands/demo/content_test.rb +31 -0
  28. data/test/integration/commands/edit_test.rb +21 -0
  29. data/test/integration/commands/new_test.rb +120 -0
  30. data/test/integration/commands/plugin/create_test.rb +128 -0
  31. data/test/integration/commands/theme/create_test.rb +35 -0
  32. data/test/integration/commands/theme/enable_test.rb +22 -0
  33. data/test/integration/commands/theme/install_test.rb +62 -0
  34. data/test/integration/default_theme_test.rb +220 -0
  35. data/test/integration/overrides_test.rb +118 -0
  36. data/test/integration/route_handlers_test.rb +96 -0
  37. data/test/integration/sitemap_test.rb +85 -0
  38. data/test/integration_test_helper.rb +61 -0
  39. data/test/support/model_factory.rb +169 -0
  40. data/test/support/silence_commands_during_tests.rb +5 -0
  41. data/test/support/temporary_files.rb +33 -0
  42. data/test/support/test_configuration.rb +19 -0
  43. data/test/test_helper.rb +26 -0
  44. data/test/unit/commands_test.rb +23 -0
  45. data/test/unit/config_test.rb +138 -0
  46. data/test/unit/file_model_test.rb +71 -0
  47. data/test/unit/menu_test.rb +82 -0
  48. data/test/unit/page_test.rb +571 -0
  49. data/test/unit/path_test.rb +41 -0
  50. data/test/unit/plugin_test.rb +47 -0
  51. data/views/master.sass +1 -1
  52. metadata +81 -85
  53. data/smoke-test.sh +0 -107
  54. data/spec/atom_spec.rb +0 -141
  55. data/spec/commands/demo/content_spec.rb +0 -65
  56. data/spec/commands/edit_spec.rb +0 -27
  57. data/spec/commands/new_spec.rb +0 -88
  58. data/spec/commands/plugin/create_spec.rb +0 -97
  59. data/spec/commands/system_spec.rb +0 -25
  60. data/spec/commands/theme/create_spec.rb +0 -41
  61. data/spec/commands/theme/enable_spec.rb +0 -44
  62. data/spec/commands/theme/install_spec.rb +0 -56
  63. data/spec/config_spec.rb +0 -127
  64. data/spec/model_factory.rb +0 -92
  65. data/spec/models_spec.rb +0 -700
  66. data/spec/overrides_spec.rb +0 -132
  67. data/spec/page_spec.rb +0 -560
  68. data/spec/path_spec.rb +0 -28
  69. data/spec/plugin_spec.rb +0 -51
  70. data/spec/sitemap_spec.rb +0 -105
  71. data/spec/spec_helper.rb +0 -114
@@ -1,28 +0,0 @@
1
- require File.expand_path('spec_helper', File.dirname(__FILE__))
2
-
3
- describe 'Nesta::Path' do
4
- before(:each) do
5
- @root = File.expand_path('..', File.dirname(__FILE__))
6
- @local_foo_bar = File.join(@root, 'foo/bar')
7
- end
8
-
9
- it 'should return local path' do
10
- Nesta::Path.local.should == @root
11
- end
12
-
13
- it 'should return path for file within local directory' do
14
- Nesta::Path.local('foo/bar').should == @local_foo_bar
15
- end
16
-
17
- it 'should combine path components' do
18
- Nesta::Path.local('foo', 'bar').should == @local_foo_bar
19
- end
20
-
21
- it 'should return themes path' do
22
- Nesta::Path.themes.should == File.expand_path('themes', @root)
23
- end
24
-
25
- it 'should return path for file within themes directory' do
26
- Nesta::Path.themes('foo/bar').should == File.join(@root, 'themes/foo/bar')
27
- end
28
- end
@@ -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
@@ -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
@@ -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