locomotivecms_wagon 2.1.0.rc4 → 2.1.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/generators/blank/config/metafields_schema.yml +2 -2
- data/generators/bootstrap/config/metafields_schema.yml +2 -2
- data/generators/foundation5/config/metafields_schema.yml +2 -2
- data/generators/site_metafields/schema.yml.tt +2 -2
- data/lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb +25 -3
- data/lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb +48 -4
- data/lib/locomotive/wagon/commands/serve_command.rb +5 -1
- data/lib/locomotive/wagon/decorators/page_decorator.rb +10 -0
- data/lib/locomotive/wagon/version.rb +1 -1
- data/locomotivecms_wagon.gemspec +1 -1
- data/spec/fixtures/cassettes/authenticate.yml +59 -49
- data/spec/fixtures/cassettes/delete.yml +322 -272
- data/spec/fixtures/cassettes/push.yml +1694 -1470
- data/spec/unit/commands/push_sub_commands/push_pages_command_spec.rb +116 -0
- data/spec/unit/decorators/page_decorator_spec.rb +35 -0
- metadata +8 -4
@@ -0,0 +1,116 @@
|
|
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(:page) { instance_double('Page', fullpath: 'modified-about-us', folder_path: folder, handle: handle) }
|
90
|
+
|
91
|
+
subject { command.send(:can_update?, page) }
|
92
|
+
|
93
|
+
it { is_expected.to eq true }
|
94
|
+
|
95
|
+
context 'with a handle' do
|
96
|
+
|
97
|
+
let(:handle) { 'about' }
|
98
|
+
let(:remote_entities) { { 'index' => 1, 'about-us' => 2, :about => 2 } }
|
99
|
+
|
100
|
+
before { allow(command).to receive(:remote_entities).and_return(remote_entities) }
|
101
|
+
|
102
|
+
it { is_expected.to eq true }
|
103
|
+
|
104
|
+
context 'but different folder' do
|
105
|
+
|
106
|
+
let(:folder) { 'deeper' }
|
107
|
+
|
108
|
+
it { is_expected.to eq false }
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_wagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.rc5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -115,14 +115,14 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.1.0.
|
118
|
+
version: 1.1.0.rc3
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.1.0.
|
125
|
+
version: 1.1.0.rc3
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: listen
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -630,8 +630,10 @@ files:
|
|
630
630
|
- spec/support/vcr.rb
|
631
631
|
- spec/unit/commands/pull_sub_commands/concerns/assets_concern_spec.rb
|
632
632
|
- spec/unit/commands/pull_sub_commands/pull_content_types_command_spec.rb
|
633
|
+
- spec/unit/commands/push_sub_commands/push_pages_command_spec.rb
|
633
634
|
- spec/unit/commands/push_sub_commands/push_theme_assets_command_spec.rb
|
634
635
|
- spec/unit/decorators/content_entry_decorator_spec.rb
|
636
|
+
- spec/unit/decorators/page_decorator_spec.rb
|
635
637
|
- spec/unit/decorators/site_decorator_spec.rb
|
636
638
|
- spec/unit/decorators/theme_asset_decorator_spec.rb
|
637
639
|
- spec/unit/tools/glob_spec.rb
|
@@ -766,8 +768,10 @@ test_files:
|
|
766
768
|
- spec/support/vcr.rb
|
767
769
|
- spec/unit/commands/pull_sub_commands/concerns/assets_concern_spec.rb
|
768
770
|
- spec/unit/commands/pull_sub_commands/pull_content_types_command_spec.rb
|
771
|
+
- spec/unit/commands/push_sub_commands/push_pages_command_spec.rb
|
769
772
|
- spec/unit/commands/push_sub_commands/push_theme_assets_command_spec.rb
|
770
773
|
- spec/unit/decorators/content_entry_decorator_spec.rb
|
774
|
+
- spec/unit/decorators/page_decorator_spec.rb
|
771
775
|
- spec/unit/decorators/site_decorator_spec.rb
|
772
776
|
- spec/unit/decorators/theme_asset_decorator_spec.rb
|
773
777
|
- spec/unit/tools/glob_spec.rb
|