locomotivecms_wagon 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/generators/foundation5/public/stylesheets/foundation/_functions.scss +3 -2
- data/generators/foundation5/public/stylesheets/foundation/_settings.scss +419 -274
- data/generators/foundation5/public/stylesheets/foundation/components/_accordion.scss +110 -6
- data/generators/foundation5/public/stylesheets/foundation/components/_alert-boxes.scss +4 -2
- data/generators/foundation5/public/stylesheets/foundation/components/_block-grid.scss +2 -2
- data/generators/foundation5/public/stylesheets/foundation/components/_breadcrumbs.scss +8 -3
- data/generators/foundation5/public/stylesheets/foundation/components/_button-groups.scss +98 -9
- data/generators/foundation5/public/stylesheets/foundation/components/_buttons.scss +66 -29
- data/generators/foundation5/public/stylesheets/foundation/components/_clearing.scss +5 -5
- data/generators/foundation5/public/stylesheets/foundation/components/_dropdown-buttons.scss +11 -10
- data/generators/foundation5/public/stylesheets/foundation/components/_dropdown.scss +49 -35
- data/generators/foundation5/public/stylesheets/foundation/components/_forms.scss +125 -38
- data/generators/foundation5/public/stylesheets/foundation/components/_global.scss +64 -38
- data/generators/foundation5/public/stylesheets/foundation/components/_grid.scss +19 -4
- data/generators/foundation5/public/stylesheets/foundation/components/_icon-bar.scss +293 -0
- data/generators/foundation5/public/stylesheets/foundation/components/_joyride.scss +11 -9
- data/generators/foundation5/public/stylesheets/foundation/components/_keystrokes.scss +4 -4
- data/generators/foundation5/public/stylesheets/foundation/components/_labels.scss +5 -3
- data/generators/foundation5/public/stylesheets/foundation/components/_magellan.scss +1 -1
- data/generators/foundation5/public/stylesheets/foundation/components/_offcanvas.scss +190 -33
- data/generators/foundation5/public/stylesheets/foundation/components/_orbit.scss +92 -147
- data/generators/foundation5/public/stylesheets/foundation/components/_pagination.scss +22 -10
- data/generators/foundation5/public/stylesheets/foundation/components/_panels.scss +12 -7
- data/generators/foundation5/public/stylesheets/foundation/components/_pricing-tables.scss +11 -11
- data/generators/foundation5/public/stylesheets/foundation/components/_progress-bars.scss +2 -2
- data/generators/foundation5/public/stylesheets/foundation/components/_range-slider.scss +29 -9
- data/generators/foundation5/public/stylesheets/foundation/components/_reveal.scss +62 -56
- data/generators/foundation5/public/stylesheets/foundation/components/_side-nav.scss +3 -2
- data/generators/foundation5/public/stylesheets/foundation/components/_split-buttons.scss +2 -2
- data/generators/foundation5/public/stylesheets/foundation/components/_sub-nav.scss +4 -6
- data/generators/foundation5/public/stylesheets/foundation/components/_switches.scss +230 -0
- data/generators/foundation5/public/stylesheets/foundation/components/_tables.scss +13 -7
- data/generators/foundation5/public/stylesheets/foundation/components/_tabs.scss +22 -8
- data/generators/foundation5/public/stylesheets/foundation/components/_thumbs.scss +2 -4
- data/generators/foundation5/public/stylesheets/foundation/components/_toolbar.scss +70 -0
- data/generators/foundation5/public/stylesheets/foundation/components/_tooltips.scss +9 -7
- data/generators/foundation5/public/stylesheets/foundation/components/_top-bar.scss +82 -56
- data/generators/foundation5/public/stylesheets/foundation/components/_type.scss +23 -11
- data/generators/foundation5/public/stylesheets/foundation/components/_visibility.scss +7 -7
- data/generators/foundation5/public/stylesheets/foundation.css +4327 -3587
- data/generators/foundation5/public/stylesheets/foundation.css.scss +38 -38
- data/generators/foundation5/public/stylesheets/normalize.css +71 -139
- data/generators/foundation5/public/stylesheets/normalize.css.scss +5 -3
- data/lib/locomotive/wagon/cli.rb +24 -1
- data/lib/locomotive/wagon/generators/content_type.rb +4 -1
- data/lib/locomotive/wagon/generators/page.rb +10 -5
- data/lib/locomotive/wagon/generators/relationship.rb +100 -0
- data/lib/locomotive/wagon/generators/site/foundation5.rb +2 -2
- data/lib/locomotive/wagon/generators/snippet.rb +3 -3
- data/lib/locomotive/wagon/liquid/tags/locale_switcher.rb +2 -2
- data/lib/locomotive/wagon/version.rb +1 -1
- data/lib/locomotive/wagon.rb +1 -0
- data/locomotivecms_wagon.gemspec +1 -1
- data/spec/fixtures/blog/app/content_types/comments.yml +20 -0
- data/spec/fixtures/blog/app/content_types/posts.yml +19 -0
- data/spec/fixtures/blog/app/views/pages/404.liquid +11 -0
- data/spec/fixtures/blog/app/views/pages/about-us.liquid.haml +29 -0
- data/spec/fixtures/blog/app/views/pages/index.liquid +25 -0
- data/spec/fixtures/blog/app/views/pages/posts/content_type_template.fr.liquid +14 -0
- data/spec/fixtures/blog/app/views/pages/posts/content_type_template.liquid +15 -0
- data/spec/fixtures/blog/app/views/pages/posts.fr.liquid +13 -0
- data/spec/fixtures/blog/app/views/pages/posts.liquid +13 -0
- data/spec/fixtures/blog/config/deploy.yml +4 -0
- data/spec/fixtures/blog/config/site.yml +16 -0
- data/spec/fixtures/blog/data/comments.yml +16 -0
- data/spec/fixtures/blog/data/posts.yml +7 -0
- data/spec/integration/generators/page_spec.rb +87 -0
- data/spec/integration/generators/relationship_spec.rb +102 -0
- data/spec/support/helpers.rb +19 -1
- metadata +38 -6
- data/generators/foundation5/public/stylesheets/foundation/components/_reveal-new.scss +0 -0
- data/generators/foundation5/public/stylesheets/foundation/components/_switch.scss +0 -294
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
require 'thor/error'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
module Locomotive
|
7
|
+
module Wagon
|
8
|
+
module Generators
|
9
|
+
class Relationship < Thor::Group
|
10
|
+
|
11
|
+
include Thor::Actions
|
12
|
+
include Locomotive::Wagon::CLI::ForceColor
|
13
|
+
|
14
|
+
argument :source # slug of a content type
|
15
|
+
argument :type # belongs_to, has_many or many_to_many
|
16
|
+
argument :target # slug of a content type
|
17
|
+
argument :target_path # path to the site
|
18
|
+
|
19
|
+
def content_types_must_exist
|
20
|
+
unless File.exists?(File.join(destination_root, source_path))
|
21
|
+
fail Thor::Error, "The #{source} content type does not exist"
|
22
|
+
end
|
23
|
+
|
24
|
+
unless File.exists?(File.join(destination_root, target_path))
|
25
|
+
fail Thor::Error, "The #{target} content type does not exist"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def modify_content_types
|
30
|
+
case type.to_sym
|
31
|
+
when :belongs_to
|
32
|
+
append_to_file source_path, build_belongs_to_field(source, target)
|
33
|
+
append_to_file target_path, build_has_many_field(target, source)
|
34
|
+
when :has_many
|
35
|
+
append_to_file source_path, build_has_many_field(source, target)
|
36
|
+
append_to_file target_path, build_belongs_to_field(target, source)
|
37
|
+
when :many_to_many
|
38
|
+
append_to_file source_path, build_many_to_many_field(source, target)
|
39
|
+
append_to_file target_path, build_many_to_many_field(target, source)
|
40
|
+
else
|
41
|
+
fail Thor::Error, "#{type} is an unknown relationship type"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def source_path
|
48
|
+
"app/content_types/#{source}.yml"
|
49
|
+
end
|
50
|
+
|
51
|
+
def target_path
|
52
|
+
"app/content_types/#{target}.yml"
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_belongs_to_field(source_class, target_class)
|
56
|
+
in_yaml({
|
57
|
+
target_class.singularize => {
|
58
|
+
'label' => target_class.singularize.humanize,
|
59
|
+
'hint' => 'A description of the relationship for the editors',
|
60
|
+
'type' => 'belongs_to',
|
61
|
+
'class_name' => target_class
|
62
|
+
}
|
63
|
+
})
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_has_many_field(source_class, target_class)
|
67
|
+
in_yaml({
|
68
|
+
target_class => {
|
69
|
+
'label' => target_class.humanize,
|
70
|
+
'hint' => 'A description of the relationship for the editors',
|
71
|
+
'type' => 'has_many',
|
72
|
+
'class_name' => target_class,
|
73
|
+
'inverse_of' => source_class.singularize,
|
74
|
+
'ui_enabled' => true
|
75
|
+
}
|
76
|
+
})
|
77
|
+
end
|
78
|
+
|
79
|
+
def build_many_to_many_field(source_class, target_class)
|
80
|
+
in_yaml({
|
81
|
+
target_class => {
|
82
|
+
'label' => target_class.humanize,
|
83
|
+
'hint' => 'A description of the relationship for the editors',
|
84
|
+
'type' => 'many_to_many',
|
85
|
+
'class_name' => target_class,
|
86
|
+
'inverse_of' => source_class,
|
87
|
+
'ui_enabled' => true
|
88
|
+
}
|
89
|
+
})
|
90
|
+
end
|
91
|
+
|
92
|
+
def in_yaml(hash)
|
93
|
+
[hash].to_yaml.gsub(/^(---\s+)/, "\n")
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -36,7 +36,7 @@ module Locomotive
|
|
36
36
|
_slug = slug.clone.downcase.gsub(/[-]/, '_')
|
37
37
|
|
38
38
|
options = { slug: _slug, translated: false }
|
39
|
-
file_path = File.join(
|
39
|
+
file_path = File.join(snippets_path, _slug)
|
40
40
|
|
41
41
|
template "template.#{extension}.tt", "#{file_path}.#{extension}", options
|
42
42
|
|
@@ -52,7 +52,7 @@ module Locomotive
|
|
52
52
|
|
53
53
|
protected
|
54
54
|
|
55
|
-
def
|
55
|
+
def snippets_path
|
56
56
|
File.join(target_path, 'app', 'views', 'snippets')
|
57
57
|
end
|
58
58
|
|
@@ -60,4 +60,4 @@ module Locomotive
|
|
60
60
|
|
61
61
|
end
|
62
62
|
end
|
63
|
-
end
|
63
|
+
end
|
@@ -76,7 +76,7 @@ module Locomotive
|
|
76
76
|
def link_label(locale)
|
77
77
|
case @_options[:label]
|
78
78
|
when 'iso' then locale
|
79
|
-
when 'locale' then I18n.t("locales.#{locale}")
|
79
|
+
when 'locale' then I18n.t("locomotive.locales.#{locale}")
|
80
80
|
when 'title' then @page.title # FIXME: this returns nil if the page has not been translated in the locale
|
81
81
|
else
|
82
82
|
locale
|
@@ -103,4 +103,4 @@ module Locomotive
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
|
-
end
|
106
|
+
end
|
data/lib/locomotive/wagon.rb
CHANGED
data/locomotivecms_wagon.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |gem|
|
|
35
35
|
|
36
36
|
gem.add_dependency 'httmultiparty', '0.3.10'
|
37
37
|
gem.add_dependency 'will_paginate', '~> 3.0.3'
|
38
|
-
gem.add_dependency 'locomotivecms_mounter', '~> 1.5.
|
38
|
+
gem.add_dependency 'locomotivecms_mounter', '~> 1.5.1'
|
39
39
|
|
40
40
|
gem.add_dependency 'faker', '~> 0.9.5'
|
41
41
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Comments
|
2
|
+
slug: comments
|
3
|
+
description: Comments
|
4
|
+
label_field_name: name
|
5
|
+
order_by: created_at
|
6
|
+
order_direction: asc
|
7
|
+
public_submission_enabled: true
|
8
|
+
|
9
|
+
fields:
|
10
|
+
- name:
|
11
|
+
label: Name
|
12
|
+
type: string
|
13
|
+
required: true
|
14
|
+
localized: false
|
15
|
+
|
16
|
+
- description:
|
17
|
+
label: Description
|
18
|
+
type: text
|
19
|
+
required: false
|
20
|
+
localized: false
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Posts
|
2
|
+
slug: posts
|
3
|
+
description: A description of the content type for the editors
|
4
|
+
label_field_name: title
|
5
|
+
order_by: manually
|
6
|
+
|
7
|
+
fields:
|
8
|
+
- title:
|
9
|
+
label: Title
|
10
|
+
type: string
|
11
|
+
required: true
|
12
|
+
localized: false
|
13
|
+
|
14
|
+
- description:
|
15
|
+
label: Description
|
16
|
+
type: text
|
17
|
+
required: false
|
18
|
+
localized: false
|
19
|
+
text_formatting: html
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
title: About us (test)
|
3
|
+
|
4
|
+
# true if the page is included in the menu
|
5
|
+
listed: true
|
6
|
+
|
7
|
+
# true if the page is published
|
8
|
+
published: true
|
9
|
+
|
10
|
+
# position among sibling pages
|
11
|
+
# position: 1
|
12
|
+
|
13
|
+
# sets a redirection to the given url (301)
|
14
|
+
# redirect_url: "<url to a page or to a remote url>"
|
15
|
+
|
16
|
+
# content type that this page is templatizing
|
17
|
+
# content_type: "<slug of one of the content types>"
|
18
|
+
|
19
|
+
# editable_elements:
|
20
|
+
# 'some_block/some_slug': "<text>"
|
21
|
+
# 'some_block/some_slug': "<relative path to the file under the public/samples folder>"
|
22
|
+
---
|
23
|
+
{% extends parent %}
|
24
|
+
|
25
|
+
{% block main %}
|
26
|
+
|
27
|
+
%p Hello world
|
28
|
+
|
29
|
+
{% endblock %}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
title: Home page
|
3
|
+
published: true
|
4
|
+
---
|
5
|
+
<!DOCTYPE html>
|
6
|
+
<html lang="en">
|
7
|
+
<head>
|
8
|
+
<meta charset="utf-8">
|
9
|
+
<title>{{ site.name }}</title>
|
10
|
+
<meta name="keywords" value="{{ site.meta_keywords }}" />
|
11
|
+
<meta name="description" value="{{ site.meta_description }}" />
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
{% block 'main' %}
|
15
|
+
<h1>{{ page.title }}</h1>
|
16
|
+
<p>keywords = {{ params.q }}</p>
|
17
|
+
<p>post list</p>
|
18
|
+
<ul>
|
19
|
+
{% for post in contents.posts %}
|
20
|
+
<li><a href="/posts/{{ post._permalink }}">{{ post.title }}</a></li>
|
21
|
+
{% endfor %}
|
22
|
+
</ul>
|
23
|
+
{% endblock %}
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
title: Template d'un post
|
3
|
+
published: false
|
4
|
+
content_type: posts
|
5
|
+
---
|
6
|
+
<h1>{{ post.title }}</h1>
|
7
|
+
{{ post.description }}
|
8
|
+
<hr />
|
9
|
+
<p>commentaires:</p>
|
10
|
+
<ul>
|
11
|
+
{% for comment in post.comments %}
|
12
|
+
<li><strong>{{comment.name}}</strong><br />{{ comment.description }}</li>
|
13
|
+
{% endfor %}
|
14
|
+
</ul>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
title: Post page
|
3
|
+
published: false
|
4
|
+
content_type: posts
|
5
|
+
---
|
6
|
+
|
7
|
+
<h1>{{ post.title }}</h1>
|
8
|
+
{{ post.description }}
|
9
|
+
<hr />
|
10
|
+
<p>comments:</p>
|
11
|
+
<ul>
|
12
|
+
{% for comment in post.comments %}
|
13
|
+
<li><strong>{{comment.name}}</strong><br />{{ comment.description }}</li>
|
14
|
+
{% endfor %}
|
15
|
+
</ul>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: Liste des articles
|
3
|
+
published: true
|
4
|
+
---
|
5
|
+
{% extends 'index' %}
|
6
|
+
{% block main %}
|
7
|
+
<h1>Liste des articles</h1>
|
8
|
+
<ul>
|
9
|
+
{% for post in contents.posts %}
|
10
|
+
<li><strong>{{post.title}}</strong> (<a href="/posts/{{ post._permalink }}">more</a>)</li>
|
11
|
+
{% endfor %}
|
12
|
+
</ul>
|
13
|
+
{% endblock %}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: List of posts
|
3
|
+
published: true
|
4
|
+
---
|
5
|
+
{% extends 'index' %}
|
6
|
+
{% block main %}
|
7
|
+
<h1>List of posts</h1>
|
8
|
+
<ul>
|
9
|
+
{% for post in contents.posts %}
|
10
|
+
<li><strong>{{post.title}}</strong> (<a href="/posts/{{ post._permalink }}">more</a>)</li>
|
11
|
+
{% endfor %}
|
12
|
+
</ul>
|
13
|
+
{% endblock %}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# TODO: explain it
|
2
|
+
name: Blog
|
3
|
+
|
4
|
+
# TODO: explain it
|
5
|
+
# subdomain: sample
|
6
|
+
|
7
|
+
# TODO: explain it
|
8
|
+
# domains: [www.example.com, example.com]
|
9
|
+
|
10
|
+
# TODO: explain it
|
11
|
+
locales: [en, fr]
|
12
|
+
|
13
|
+
# TODO: explain it
|
14
|
+
seo_title: locoblog
|
15
|
+
meta_keywords: "some meta keywords"
|
16
|
+
meta_description: "some meta description"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
- "Sample 1":
|
2
|
+
description: "Laboriosam dignissimos quo ut possimus voluptatem. Autem iusto itaque molestiae similique cum vel. Sunt quibusdam ea illo ut in ratione tempore."
|
3
|
+
post: post-1
|
4
|
+
|
5
|
+
- "Sample 2":
|
6
|
+
description: "Rem non fugit aperiam et qui animi. Et aut eum possimus nihil ad. Qui eum ut voluptatem et aut magni aspernatur deleniti. Consequatur id aut id. Hic dolores quidem quas."
|
7
|
+
post: post-1
|
8
|
+
|
9
|
+
- "Sample 3":
|
10
|
+
description: "Voluptatum quisquam assumenda dolor nobis exercitationem est iusto expedita. Molestiae nulla quasi et quibusdam. Iste amet sed corrupti minima numquam quia dolorem ab. Hic itaque doloribus iure totam at praesentium. Illum dolorem incidunt quos laborum."
|
11
|
+
post: post-2
|
12
|
+
|
13
|
+
- "Sample 4":
|
14
|
+
description: "Possimus unde et dolor. Molestias est harum laborum. Nisi est sequi animi et. Qui suscipit ut consequatur odio autem quia est quia."
|
15
|
+
post: post-2
|
16
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
- "Post 1":
|
2
|
+
_permalink: post-1
|
3
|
+
description: "Assumenda et quasi illum praesentium facere labore. Dolores quia aliquam vel officiis consequatur repellendus eum et. Repudiandae assumenda ipsa sed. Non perferendis eligendi aut. Magnam aut quos excepturi nihil necessitatibus a et ratione."
|
4
|
+
|
5
|
+
- "Post 2":
|
6
|
+
_permalink: post-2
|
7
|
+
description: "Sit ipsa exercitationem harum ut sint accusantium delectus. Eum reprehenderit minus consequatur sed ad. Nulla ut rem blanditiis tenetur officia reprehenderit assumenda libero. Ut nam sapiente voluptatibus."
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../integration_helper'
|
4
|
+
|
5
|
+
require 'locomotive/wagon'
|
6
|
+
require 'locomotive/wagon/cli'
|
7
|
+
|
8
|
+
describe 'Locomotive::Wagon::Generators::Page' do
|
9
|
+
|
10
|
+
before { make_working_copy_of_site(:blog) }
|
11
|
+
after { remove_working_copy_of_site(:blog) }
|
12
|
+
|
13
|
+
let(:path) { working_copy_of_site(:blog) }
|
14
|
+
let(:fullpath) { 'new-page' }
|
15
|
+
let(:default_locales) { ['en', 'fr'] }
|
16
|
+
let(:locales) { nil }
|
17
|
+
let(:page_options) { { haml: false, locales: locales, default_locales: default_locales } }
|
18
|
+
let(:options) { { 'force_color' => true, 'path' => path, 'quiet' => true }.merge(page_options) }
|
19
|
+
|
20
|
+
subject { Locomotive::Wagon.generate(:page, [fullpath, options.delete('path')], options) }
|
21
|
+
|
22
|
+
describe 'wrong parameters' do
|
23
|
+
|
24
|
+
describe 'empty locales' do
|
25
|
+
|
26
|
+
let(:locales) { '' }
|
27
|
+
|
28
|
+
it { lambda { subject }.should_not raise_error }
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'generating a page' do
|
35
|
+
|
36
|
+
before { subject }
|
37
|
+
|
38
|
+
it 'creates the page in the FS' do
|
39
|
+
File.exists?(page_path('new-page')).should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'generates an header in YAML' do
|
43
|
+
read_page('new-page').should include <<-EXPECTED
|
44
|
+
---
|
45
|
+
title: New-page
|
46
|
+
EXPECTED
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'other locales' do
|
50
|
+
|
51
|
+
let(:locales) { 'en fr' }
|
52
|
+
|
53
|
+
it 'creates the EN page in the FS' do
|
54
|
+
File.exists?(page_path('new-page')).should be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'creates the FR page in the FS' do
|
58
|
+
File.exists?(page_path('new-page.fr')).should be_true
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'separated by a comma' do
|
62
|
+
|
63
|
+
let(:locales) { 'en,fr' }
|
64
|
+
|
65
|
+
it 'creates the EN page in the FS' do
|
66
|
+
File.exists?(page_path('new-page')).should be_true
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'creates the FR page in the FS' do
|
70
|
+
File.exists?(page_path('new-page.fr')).should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def page_path(slug)
|
80
|
+
File.join(path, 'app', 'views', 'pages', "#{slug}.liquid")
|
81
|
+
end
|
82
|
+
|
83
|
+
def read_page(slug)
|
84
|
+
File.read(page_path(slug))
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../integration_helper'
|
4
|
+
|
5
|
+
require 'locomotive/wagon'
|
6
|
+
require 'locomotive/wagon/cli'
|
7
|
+
|
8
|
+
describe 'Locomotive::Wagon::Generators::Relationship' do
|
9
|
+
|
10
|
+
before(:all) { make_working_copy_of_site(:blog) }
|
11
|
+
after(:all) { remove_working_copy_of_site(:blog) }
|
12
|
+
|
13
|
+
let(:path) { working_copy_of_site(:blog) }
|
14
|
+
let(:source_slug) { 'comments' }
|
15
|
+
let(:target_slug) { 'posts' }
|
16
|
+
let(:type) { 'belongs_to' }
|
17
|
+
let(:options) { { 'force_color' => true, 'path' => path, 'quiet' => true } }
|
18
|
+
|
19
|
+
subject { Locomotive::Wagon.generate(:relationship, [source_slug, type, target_slug, options.delete('path')], options) }
|
20
|
+
|
21
|
+
describe 'wrong parameters' do
|
22
|
+
|
23
|
+
describe 'unknown slugs' do
|
24
|
+
|
25
|
+
let(:source_slug) { 'authors' }
|
26
|
+
|
27
|
+
it { lambda { subject }.should raise_error 'The authors content type does not exist' }
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'unknown type' do
|
32
|
+
|
33
|
+
let(:type) { 'has_one' }
|
34
|
+
|
35
|
+
it { lambda { subject }.should raise_error 'has_one is an unknown relationship type' }
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'generating a belongs_to relationship' do
|
42
|
+
|
43
|
+
before { subject }
|
44
|
+
|
45
|
+
it 'adds code to the source content type' do
|
46
|
+
read_content_type(:comments).should include <<-EXPECTED
|
47
|
+
- post:
|
48
|
+
label: Post
|
49
|
+
hint: A description of the relationship for the editors
|
50
|
+
type: belongs_to
|
51
|
+
class_name: posts
|
52
|
+
EXPECTED
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'adds code the target content type' do
|
56
|
+
read_content_type(:posts).should include <<-EXPECTED
|
57
|
+
- comments:
|
58
|
+
label: Comments
|
59
|
+
hint: A description of the relationship for the editors
|
60
|
+
type: has_many
|
61
|
+
class_name: comments
|
62
|
+
inverse_of: post
|
63
|
+
EXPECTED
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'generating a many_to_many relationship' do
|
69
|
+
|
70
|
+
before { subject }
|
71
|
+
|
72
|
+
let(:type) { 'many_to_many' }
|
73
|
+
|
74
|
+
it 'adds code to the source content type' do
|
75
|
+
read_content_type(:comments).should include <<-EXPECTED
|
76
|
+
- posts:
|
77
|
+
label: Posts
|
78
|
+
hint: A description of the relationship for the editors
|
79
|
+
type: many_to_many
|
80
|
+
class_name: posts
|
81
|
+
inverse_of: comments
|
82
|
+
EXPECTED
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'adds code the target content type' do
|
86
|
+
read_content_type(:posts).should include <<-EXPECTED
|
87
|
+
- comments:
|
88
|
+
label: Comments
|
89
|
+
hint: A description of the relationship for the editors
|
90
|
+
type: many_to_many
|
91
|
+
class_name: comments
|
92
|
+
inverse_of: posts
|
93
|
+
EXPECTED
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def read_content_type(name)
|
99
|
+
File.read(File.join(path, 'app', 'content_types', "#{name}.yml"))
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/spec/support/helpers.rb
CHANGED
@@ -15,6 +15,24 @@ module Spec
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def working_copy_of_site(name)
|
19
|
+
tmp_path = File.expand_path('../../tmp', __FILE__)
|
20
|
+
tmp_path = FileUtils.mkdir_p(tmp_path)
|
21
|
+
File.join(tmp_path, name.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def make_working_copy_of_site(name)
|
25
|
+
source = File.join(File.expand_path('../../fixtures', __FILE__), name.to_s)
|
26
|
+
target = working_copy_of_site(name)
|
27
|
+
|
28
|
+
FileUtils.cp_r(source, target)
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_working_copy_of_site(name)
|
32
|
+
path = working_copy_of_site(name)
|
33
|
+
FileUtils.rm_rf(path)
|
34
|
+
end
|
35
|
+
|
18
36
|
def run_server
|
19
37
|
path = 'spec/fixtures/default'
|
20
38
|
Locomotive::Wagon::Logger.setup(path, false)
|
@@ -31,4 +49,4 @@ module Spec
|
|
31
49
|
end
|
32
50
|
|
33
51
|
end
|
34
|
-
end
|
52
|
+
end
|