locomotivecms_wagon 3.0.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/bin/wagon +64 -3
- data/bin/wagon_dev +11 -0
- data/generators/.DS_Store +0 -0
- data/generators/blank/Gemfile.tt +6 -2
- data/generators/blank/app/assets/stylesheets/app.scss +2 -0
- data/generators/blank/app/assets/stylesheets/sections/.empty_directory +1 -0
- data/generators/blank/app/views/pages/404.liquid +1 -1
- data/generators/blank/app/views/pages/index.liquid +1 -1
- data/generators/section/%type%.scss.tt +3 -0
- data/generators/section/template.liquid.tt +139 -80
- data/generators/webpack/app/assets/javascripts/.DS_Store +0 -0
- data/lib/locomotive/wagon.rb +15 -1
- data/lib/locomotive/wagon/cli.rb +11 -11
- data/lib/locomotive/wagon/commands/generate_command.rb +2 -7
- data/lib/locomotive/wagon/commands/push_command.rb +4 -8
- data/lib/locomotive/wagon/commands/serve_command.rb +5 -5
- data/lib/locomotive/wagon/generators/section.rb +121 -17
- data/lib/locomotive/wagon/generators/site/base.rb +0 -23
- data/lib/locomotive/wagon/version.rb +1 -1
- data/locomotivecms_wagon.gemspec +7 -4
- metadata +14 -233
- data/.gitignore +0 -36
- data/.rspec +0 -1
- data/.travis.yml +0 -11
- data/Gemfile +0 -30
- data/Rakefile +0 -32
- data/spec/fixtures/blog/app/content_types/comments.yml +0 -20
- data/spec/fixtures/blog/app/content_types/posts.yml +0 -19
- data/spec/fixtures/blog/app/views/pages/404.liquid +0 -11
- data/spec/fixtures/blog/app/views/pages/about-us.liquid.haml +0 -29
- data/spec/fixtures/blog/app/views/pages/index.liquid +0 -25
- data/spec/fixtures/blog/app/views/pages/posts.fr.liquid +0 -13
- data/spec/fixtures/blog/app/views/pages/posts.liquid +0 -13
- data/spec/fixtures/blog/app/views/pages/posts/content_type_template.fr.liquid +0 -14
- data/spec/fixtures/blog/app/views/pages/posts/content_type_template.liquid +0 -15
- data/spec/fixtures/blog/config/deploy.yml +0 -4
- data/spec/fixtures/blog/config/site.yml +0 -16
- data/spec/fixtures/blog/data/comments.yml +0 -16
- data/spec/fixtures/blog/data/posts.yml +0 -7
- data/spec/fixtures/cassettes/authenticate.yml +0 -236
- data/spec/fixtures/cassettes/delete.yml +0 -1255
- data/spec/fixtures/cassettes/push.yml +0 -9946
- data/spec/fixtures/cassettes/sync.yml +0 -11462
- data/spec/fixtures/default/README +0 -0
- data/spec/fixtures/default/app/content_types/bands.yml +0 -21
- data/spec/fixtures/default/app/content_types/events.yml +0 -25
- data/spec/fixtures/default/app/content_types/messages.yml +0 -17
- data/spec/fixtures/default/app/content_types/songs.yml +0 -25
- data/spec/fixtures/default/app/content_types/updates.yml +0 -33
- data/spec/fixtures/default/app/views/pages/404.liquid.haml +0 -10
- data/spec/fixtures/default/app/views/pages/about_us.fr.liquid.haml +0 -7
- data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +0 -21
- data/spec/fixtures/default/app/views/pages/about_us.nb.liquid.haml +0 -4
- data/spec/fixtures/default/app/views/pages/about_us/jane_doe.liquid.haml +0 -4
- data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +0 -5
- data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +0 -6
- data/spec/fixtures/default/app/views/pages/all.liquid.haml +0 -16
- data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +0 -10
- data/spec/fixtures/default/app/views/pages/contact.liquid.haml +0 -54
- data/spec/fixtures/default/app/views/pages/contest.liquid.haml +0 -18
- data/spec/fixtures/default/app/views/pages/events.liquid.haml +0 -64
- data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +0 -20
- data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +0 -8
- data/spec/fixtures/default/app/views/pages/index.fr.liquid.haml +0 -3
- data/spec/fixtures/default/app/views/pages/index.liquid.haml +0 -101
- data/spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml +0 -13
- data/spec/fixtures/default/app/views/pages/music.fr.liquid.haml +0 -4
- data/spec/fixtures/default/app/views/pages/music.liquid.haml +0 -42
- data/spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml +0 -16
- data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +0 -18
- data/spec/fixtures/default/app/views/pages/songs/template/band.liquid.haml +0 -16
- data/spec/fixtures/default/app/views/pages/store.fr.liquid.haml +0 -5
- data/spec/fixtures/default/app/views/pages/store.liquid +0 -5
- data/spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +0 -6
- data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +0 -6
- data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +0 -9
- data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +0 -1
- data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +0 -6
- data/spec/fixtures/default/app/views/snippets/header.liquid.haml +0 -1
- data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +0 -8
- data/spec/fixtures/default/app/views/snippets/song.liquid +0 -12
- data/spec/fixtures/default/config/autoprefixer.yml +0 -2
- data/spec/fixtures/default/config/deploy.yml +0 -12
- data/spec/fixtures/default/config/deploy_example.yml +0 -12
- data/spec/fixtures/default/config/site.yml +0 -13
- data/spec/fixtures/default/config/translations.yml +0 -3
- data/spec/fixtures/default/data/bands.yml +0 -13
- data/spec/fixtures/default/data/events.yml +0 -54
- data/spec/fixtures/default/data/songs.yml +0 -46
- data/spec/fixtures/default/data/updates.yml +0 -48
- data/spec/fixtures/default/icon.png +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +0 -213
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
- data/spec/fixtures/default/public/fonts/chunkfive.css +0 -8
- data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
- data/spec/fixtures/default/public/images/nav_on.png +0 -0
- data/spec/fixtures/default/public/images/photo_frame.png +0 -0
- data/spec/fixtures/default/public/images/sep.png +0 -0
- data/spec/fixtures/default/public/images/top.jpg +0 -0
- data/spec/fixtures/default/public/javascripts/application.js.coffee +0 -2
- data/spec/fixtures/default/public/javascripts/common.js +0 -1
- data/spec/fixtures/default/public/samples/asset_collections/cover.jpg +0 -0
- data/spec/fixtures/default/public/samples/photo.jpg +0 -0
- data/spec/fixtures/default/public/samples/photo_2.jpg +0 -0
- data/spec/fixtures/default/public/stylesheets/application.css +0 -64
- data/spec/fixtures/default/public/stylesheets/other/extra.css.less +0 -8
- data/spec/fixtures/default/public/stylesheets/other/style.css.scss +0 -13
- data/spec/fixtures/default/public/stylesheets/reboot.css +0 -77
- data/spec/integration/cli_spec.rb +0 -17
- data/spec/integration/commands/authenticate_command_spec.rb +0 -60
- data/spec/integration/commands/delete_command_spec.rb +0 -147
- data/spec/integration/commands/push_command_spec.rb +0 -86
- data/spec/integration/commands/sync_command_spec.rb +0 -60
- data/spec/integration/generators/page_spec.rb +0 -87
- data/spec/integration/generators/relationship_spec.rb +0 -102
- data/spec/integration/integration_helper.rb +0 -15
- data/spec/spec_helper.rb +0 -19
- data/spec/support/api_settings.rb +0 -5
- data/spec/support/chronic.rb +0 -6
- data/spec/support/helpers.rb +0 -39
- data/spec/support/matchers.rb +0 -5
- data/spec/support/pry.rb +0 -4
- data/spec/support/thor.rb +0 -12
- data/spec/support/vcr.rb +0 -27
- data/spec/unit/commands/pull_sub_commands/concerns/assets_concern_spec.rb +0 -48
- data/spec/unit/commands/pull_sub_commands/pull_content_types_command_spec.rb +0 -41
- data/spec/unit/commands/push_sub_commands/push_pages_command_spec.rb +0 -125
- data/spec/unit/commands/push_sub_commands/push_theme_assets_command_spec.rb +0 -42
- data/spec/unit/decorators/content_entry_decorator_spec.rb +0 -104
- data/spec/unit/decorators/page_decorator_spec.rb +0 -35
- data/spec/unit/decorators/site_decorator_spec.rb +0 -62
- data/spec/unit/decorators/theme_asset_decorator_spec.rb +0 -89
- data/spec/unit/tools/glob_spec.rb +0 -26
- data/spec/unit/tools/yaml_ext_spec.rb +0 -46
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'active_support'
|
6
|
-
require 'active_support/core_ext'
|
7
|
-
require 'locomotive/wagon/commands/pull_sub_commands/pull_base_command'
|
8
|
-
require 'locomotive/wagon/commands/pull_sub_commands/pull_content_types_command'
|
9
|
-
|
10
|
-
describe Locomotive::Wagon::PullContentTypesCommand do
|
11
|
-
|
12
|
-
let(:locales) { ['en'] }
|
13
|
-
let(:site) { instance_double('Site', locales: locales) }
|
14
|
-
let(:command) { described_class.new(nil, site, nil) }
|
15
|
-
|
16
|
-
describe '#select_options_yaml' do
|
17
|
-
|
18
|
-
subject { command.send(:select_options_yaml, options) }
|
19
|
-
|
20
|
-
context 'the site is localized' do
|
21
|
-
|
22
|
-
let(:locales) { ['en', 'fr'] }
|
23
|
-
let(:options) { [{ 'id' => '1', 'name' => { 'en' => 'team', 'fr' => 'équipe' }, 'position' => 2 }, { 'id' => '2', 'name' => { 'en' => 'accounting', 'fr' => 'compta' }, 'position' => 1 }] }
|
24
|
-
|
25
|
-
it { expect(subject['en']).to eq(['accounting', 'team']) }
|
26
|
-
it { expect(subject['fr']).to eq(['compta', 'équipe']) }
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'the site is not localized' do
|
31
|
-
|
32
|
-
let(:locales) { ['fr'] }
|
33
|
-
let(:options) { [{ 'id' => '1', 'name' => { 'fr' => 'équipe' }, 'position' => 2 }, { 'id' => '2', 'name' => {'fr' => 'compta' }, 'position' => 1 }] }
|
34
|
-
|
35
|
-
it { is_expected.to eq(['compta', 'équipe']) }
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'locomotive/wagon/commands/push_sub_commands/push_base_command'
|
6
|
-
require 'locomotive/wagon/commands/push_sub_commands/push_pages_command'
|
7
|
-
require 'ostruct'
|
8
|
-
|
9
|
-
describe Locomotive::Wagon::PushPagesCommand do
|
10
|
-
|
11
|
-
let(:api_response) { [] }
|
12
|
-
let(:site) { instance_double('Site', default_locale: 'en', locales: ['en'])}
|
13
|
-
let(:pages_api) { instance_double('PagesAPI', fullpaths: api_response) }
|
14
|
-
let(:api_client) { instance_double('ApiClient', pages: pages_api) }
|
15
|
-
let(:command) { described_class.new(api_client, nil, nil, nil) }
|
16
|
-
|
17
|
-
before { allow(command).to receive(:current_site).and_return(site) }
|
18
|
-
|
19
|
-
describe '#remote_entities' do
|
20
|
-
|
21
|
-
let(:api_response) { [OpenStruct.new('_id' => 1, 'fullpath' => 'index', 'handle' => nil), OpenStruct.new('_id' => 2, 'fullpath' => 'about-us', 'handle' => 'about')] }
|
22
|
-
|
23
|
-
before { allow(command).to receive(:api_client).and_return(api_client) }
|
24
|
-
|
25
|
-
subject { command.send(:remote_entities) }
|
26
|
-
|
27
|
-
it { is_expected.to eq({ 'index' => 1, 'about-us' => 2, :about => 2 }) }
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#remote_entity_id' do
|
32
|
-
|
33
|
-
let(:remote_entities) { { 'index' => 1, 'about-us' => 2, :about => 2 } }
|
34
|
-
let(:page) { instance_double('Page', fullpath: 'about-us', handle: nil) }
|
35
|
-
|
36
|
-
subject { command.send(:remote_entity_id, page) }
|
37
|
-
|
38
|
-
before { allow(command).to receive(:remote_entities).and_return(remote_entities) }
|
39
|
-
|
40
|
-
it { is_expected.to eq(2) }
|
41
|
-
|
42
|
-
context 'if no matching fullpath, use the handle instead' do
|
43
|
-
|
44
|
-
let(:page) { instance_double('Page', fullpath: 'modified-about-us', handle: 'about') }
|
45
|
-
|
46
|
-
it { is_expected.to eq(2) }
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#remote_entities_by_id' do
|
53
|
-
|
54
|
-
let(:remote_entities) { { 'index' => 1, 'about-us' => 2, :about => 2 } }
|
55
|
-
|
56
|
-
subject { command.send(:remote_entities_by_id) }
|
57
|
-
|
58
|
-
before { allow(command).to receive(:remote_entities).and_return(remote_entities) }
|
59
|
-
|
60
|
-
it { is_expected.to eq(1 => 'index', 2 => 'about-us') }
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#remote_entity_folder_path' do
|
65
|
-
|
66
|
-
let(:some_id) { 1 }
|
67
|
-
let(:remote_entities_by_id) { { 1 => 'index', 2 => 'about-us', 3 => 'foo/bar' } }
|
68
|
-
|
69
|
-
before { allow(command).to receive(:remote_entities_by_id).and_return(remote_entities_by_id) }
|
70
|
-
|
71
|
-
subject { command.send(:remote_entity_folder_path, some_id) }
|
72
|
-
|
73
|
-
it { is_expected.to eq '' }
|
74
|
-
|
75
|
-
context 'deeper' do
|
76
|
-
|
77
|
-
let(:some_id) { 3 }
|
78
|
-
|
79
|
-
it { is_expected.to eq 'foo' }
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#can_update?' do
|
86
|
-
|
87
|
-
let(:handle) { nil }
|
88
|
-
let(:folder) { '' }
|
89
|
-
let(:locale) { :en }
|
90
|
-
let(:page) { instance_double('Page', fullpath: 'modified-about-us', folder_path: folder, handle: handle, __locale__: locale, __default_locale__: :en) }
|
91
|
-
|
92
|
-
subject { command.send(:can_update?, page) }
|
93
|
-
|
94
|
-
it { is_expected.to eq true }
|
95
|
-
|
96
|
-
context 'with a handle' do
|
97
|
-
|
98
|
-
let(:handle) { 'about' }
|
99
|
-
let(:remote_entities) { { 'index' => 1, 'about-us' => 2, :about => 2 } }
|
100
|
-
|
101
|
-
before { allow(command).to receive(:remote_entities).and_return(remote_entities) }
|
102
|
-
|
103
|
-
it { is_expected.to eq true }
|
104
|
-
|
105
|
-
context 'but different folder' do
|
106
|
-
|
107
|
-
let(:folder) { 'deeper' }
|
108
|
-
|
109
|
-
it { is_expected.to eq false }
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'another locale' do
|
116
|
-
|
117
|
-
let(:locale) { :fr }
|
118
|
-
|
119
|
-
it { is_expected.to eq true }
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'locomotive/wagon/commands/push_sub_commands/push_base_command'
|
6
|
-
require 'locomotive/wagon/commands/push_sub_commands/push_theme_assets_command'
|
7
|
-
|
8
|
-
describe Locomotive::Wagon::PushThemeAssetsCommand do
|
9
|
-
|
10
|
-
let(:command) { described_class.new(nil, nil, nil, nil) }
|
11
|
-
|
12
|
-
describe '#replace_assets' do
|
13
|
-
|
14
|
-
let(:content) { "body{background-image:url(/images/body.png)}" }
|
15
|
-
let(:urls) { { 'images/body.png' => 'http://cdn/images/body.png?42' } }
|
16
|
-
|
17
|
-
before { command.instance_variable_set(:@remote_urls, urls) }
|
18
|
-
|
19
|
-
subject { command.send(:replace_assets!, content) }
|
20
|
-
|
21
|
-
it { is_expected.to eq "body{background-image:url(http://cdn/images/body.png?42)}" }
|
22
|
-
|
23
|
-
context 'font' do
|
24
|
-
|
25
|
-
let(:content) { "@font-face{src: url(\"/fonts/external/myfont.woff?first\");}" }
|
26
|
-
let(:urls) { { 'fonts/external/myfont.woff' => 'http://cdn/fonts/external/myfont.woff?42' } }
|
27
|
-
|
28
|
-
it { is_expected.to eq "@font-face{src: url(\"http://cdn/fonts/external/myfont.woff?42\");}" }
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'no correct reference to an image' do
|
33
|
-
|
34
|
-
let(:content) { "body{background-image:url(/somewhere/body.png)}" }
|
35
|
-
|
36
|
-
it { is_expected.to eq nil }
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'locomotive/steam'
|
6
|
-
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
|
7
|
-
require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
|
8
|
-
require 'locomotive/wagon/decorators/content_entry_decorator'
|
9
|
-
|
10
|
-
describe Locomotive::Wagon::ContentEntryDecorator do
|
11
|
-
|
12
|
-
let(:content_type) { instance_double('ContentType', fields: fields) }
|
13
|
-
let(:entry) { instance_double('ContentEntry', attributes.merge(content_type: content_type, localized_attributes: [])) }
|
14
|
-
let(:decorator) { described_class.new(entry, 'en', '.') }
|
15
|
-
|
16
|
-
before { Chronic.time_class = Time.zone }
|
17
|
-
|
18
|
-
before { allow(decorator).to receive(:_slug).and_return('sample') }
|
19
|
-
|
20
|
-
describe '#to_hash' do
|
21
|
-
|
22
|
-
describe 'no field' do
|
23
|
-
|
24
|
-
let(:fields) { instance_double('Fields', by_name: nil, no_associations: []) }
|
25
|
-
let(:attributes) { {} }
|
26
|
-
|
27
|
-
subject { decorator.to_hash }
|
28
|
-
|
29
|
-
it { is_expected.to eq({}) }
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'string field' do
|
34
|
-
|
35
|
-
let(:field) { instance_double('Field', name: 'title', type: 'string') }
|
36
|
-
let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) }
|
37
|
-
let(:attributes) { { title: 'Hello world' } }
|
38
|
-
|
39
|
-
subject { decorator.to_hash }
|
40
|
-
|
41
|
-
it { is_expected.to eq({ _slug: 'sample', title: 'Hello world' }) }
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'text field' do
|
46
|
-
|
47
|
-
let(:field) { instance_double('Field', name: 'body', type: 'text') }
|
48
|
-
let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) }
|
49
|
-
let(:attributes) { { body: 'Hello world ! http://domain.tld/samples/foo.png ! <img src="/samples/bar.png" /> <div style="background: url(/samples/42.png);"/>' } }
|
50
|
-
let(:asset_pusher) { SimpleAssetPusher.new }
|
51
|
-
|
52
|
-
before { allow(decorator).to receive(:__content_assets_pusher__).and_return(asset_pusher) }
|
53
|
-
|
54
|
-
subject { decorator.to_hash }
|
55
|
-
|
56
|
-
it 'only replaces assets wrapped by a double quotes' do
|
57
|
-
is_expected.to eq({ _slug: 'sample', body: 'Hello world ! http://domain.tld/samples/foo.png ! <img src="done" /> <div style="background: url(done);"/>' })
|
58
|
-
expect(asset_pusher.assets).to eq(['/samples/bar.png', '/samples/42.png'])
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'date field' do
|
64
|
-
|
65
|
-
let(:field) { instance_double('Field', name: 'posted_at', type: 'date') }
|
66
|
-
let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) }
|
67
|
-
let(:attributes) { { posted_at: Chronic.parse('2015-09-26').to_date } }
|
68
|
-
|
69
|
-
subject { decorator.to_hash }
|
70
|
-
|
71
|
-
it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-09-26' }) }
|
72
|
-
|
73
|
-
context 'nil field' do
|
74
|
-
let(:attributes) { { posted_at: nil } }
|
75
|
-
it { is_expected.to eq({}) }
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'date time field' do
|
81
|
-
|
82
|
-
let(:field) { instance_double('Field', name: 'posted_at', type: 'date_time') }
|
83
|
-
let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) }
|
84
|
-
let(:attributes) { { posted_at: Chronic.parse('2015-11-11 18:00:00').to_datetime } }
|
85
|
-
|
86
|
-
subject { decorator.to_hash }
|
87
|
-
|
88
|
-
it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-11-11T17:00:00Z' }) }
|
89
|
-
|
90
|
-
context 'nil field' do
|
91
|
-
let(:attributes) { { posted_at: nil } }
|
92
|
-
it { is_expected.to eq({}) }
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
class SimpleAssetPusher
|
100
|
-
attr_reader :assets
|
101
|
-
def persist(asset); (@assets ||= []).push(asset); 'done'; end
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
|
7
|
-
require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
|
8
|
-
require 'locomotive/steam/decorators/template_decorator'
|
9
|
-
require 'locomotive/wagon/decorators/page_decorator'
|
10
|
-
|
11
|
-
describe Locomotive::Wagon::PageDecorator do
|
12
|
-
|
13
|
-
let(:page) { instance_double('Page', attributes) }
|
14
|
-
let(:decorator) { described_class.new(page, 'en', nil, nil) }
|
15
|
-
|
16
|
-
describe '#folder_path' do
|
17
|
-
|
18
|
-
let(:fullpath) { 'index' }
|
19
|
-
let(:attributes) { { fullpath: fullpath, localized_attributes: [] } }
|
20
|
-
|
21
|
-
subject { decorator.folder_path }
|
22
|
-
|
23
|
-
it { is_expected.to eq '' }
|
24
|
-
|
25
|
-
context 'deeper' do
|
26
|
-
|
27
|
-
let(:fullpath) { 'foo/bar' }
|
28
|
-
|
29
|
-
it { is_expected.to eq 'foo' }
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
|
7
|
-
require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
|
8
|
-
require 'locomotive/steam/decorators/i18n_decorator'
|
9
|
-
require 'locomotive/wagon/decorators/site_decorator'
|
10
|
-
|
11
|
-
describe Locomotive::Wagon::SiteDecorator do
|
12
|
-
|
13
|
-
let(:site) { instance_double('Site', attributes) }
|
14
|
-
let(:decorator) { described_class.new(site) }
|
15
|
-
|
16
|
-
describe '#domains' do
|
17
|
-
|
18
|
-
let(:attributes) { { domains: ['acme.com', 'localhost'], default_locale: 'en', localized_attributes: [] } }
|
19
|
-
|
20
|
-
subject { decorator.domains }
|
21
|
-
|
22
|
-
it { is_expected.to eq ['acme.com'] }
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#to_hash' do
|
27
|
-
|
28
|
-
let(:seo_title) { instance_double('I18nField', translations: { en: 'Hi', fr: 'Bonjour' }) }
|
29
|
-
let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, default_locale: 'en', localized_attributes: [] } }
|
30
|
-
let(:site) { OpenStruct.new(attributes) }
|
31
|
-
|
32
|
-
subject { decorator.to_hash }
|
33
|
-
|
34
|
-
it { is_expected.to eq(name: 'Acme', seo_title: { en: 'Hi', fr: 'Bonjour' }) }
|
35
|
-
|
36
|
-
context 'with image metafields' do
|
37
|
-
|
38
|
-
let(:metafields) { { some: 'Acme', img: '/samples/42.png', img2: '/samples/bar.png' } }
|
39
|
-
let(:schema) { { some: { label: 'Some', type: 'string' }, img: { label: 'img', type: 'image' }, img2: { label: 'img2', type: 'image' } } }
|
40
|
-
let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, metafields: metafields, metafields_schema: schema, default_locale: 'en', localized_attributes: [] } }
|
41
|
-
let(:asset_pusher) { SimpleAssetPusher.new }
|
42
|
-
|
43
|
-
before { allow(decorator).to receive(:__content_assets_pusher__).and_return(asset_pusher) }
|
44
|
-
|
45
|
-
it 'only replaces assets wrapped by a double quotes' do
|
46
|
-
expect(decorator.metafields).to eq(metafields.to_json)
|
47
|
-
is_expected.to eq(name: 'Acme', seo_title: { en: 'Hi', fr: 'Bonjour' },
|
48
|
-
metafields: metafields.to_json,
|
49
|
-
metafields_schema: schema.to_json)
|
50
|
-
expect(asset_pusher.assets).to eq(['/samples/42.png', '/samples/bar.png'])
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
class SimpleAssetPusher
|
58
|
-
attr_reader :assets
|
59
|
-
def persist(asset); (@assets ||= []).push(asset); 'done'; end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
|
7
|
-
require 'locomotive/wagon/decorators/theme_asset_decorator'
|
8
|
-
|
9
|
-
describe Locomotive::Wagon::ThemeAssetDecorator do
|
10
|
-
|
11
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.css' }
|
12
|
-
let(:asset) { instance_double('Asset', source: filepath) }
|
13
|
-
let(:decorator) { described_class.new(asset) }
|
14
|
-
|
15
|
-
describe '#realname' do
|
16
|
-
|
17
|
-
subject { decorator.realname }
|
18
|
-
|
19
|
-
describe 'no extension' do
|
20
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application' }
|
21
|
-
it { is_expected.to eq 'application' }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'css' do
|
25
|
-
|
26
|
-
it { is_expected.to eq 'application.css' }
|
27
|
-
|
28
|
-
describe 'scss extension' do
|
29
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.scss' }
|
30
|
-
it { is_expected.to eq 'application.css' }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'css.scss extension' do
|
34
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.css.scss' }
|
35
|
-
it { is_expected.to eq 'application.css' }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'sass extension' do
|
39
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.sass' }
|
40
|
-
it { is_expected.to eq 'application.css' }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'css.sass extension' do
|
44
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.css.sass' }
|
45
|
-
it { is_expected.to eq 'application.css' }
|
46
|
-
end
|
47
|
-
|
48
|
-
describe 'less extension' do
|
49
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.less' }
|
50
|
-
it { is_expected.to eq 'application.css' }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'css.less extension' do
|
54
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/application.css.less' }
|
55
|
-
it { is_expected.to eq 'application.css' }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe 'jquery.pluginXy.css' do
|
59
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/jquery.pluginXy.css' }
|
60
|
-
it { is_expected.to eq 'jquery.pluginXy.css' }
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'jquery.pluginXy.css.scss' do
|
64
|
-
let(:filepath) { '/somewhere/mysite/public/stylesheets/jquery.pluginXy.css' }
|
65
|
-
it { is_expected.to eq 'jquery.pluginXy.css' }
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
describe 'js' do
|
71
|
-
|
72
|
-
let(:filepath) { '/somewhere/mysite/public/javascripts/application.js' }
|
73
|
-
it { is_expected.to eq 'application.js' }
|
74
|
-
|
75
|
-
describe 'coffee extension' do
|
76
|
-
let(:filepath) { '/somewhere/mysite/public/javascripts/application.coffee' }
|
77
|
-
it { is_expected.to eq 'application.js' }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'js.coffee extension' do
|
81
|
-
let(:filepath) { '/somewhere/mysite/public/javascripts/application.js.coffee' }
|
82
|
-
it { is_expected.to eq 'application.js' }
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|