contentful_middleman 1.3.1 → 1.3.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/contentful_middleman/import_task.rb +10 -5
- data/lib/contentful_middleman/mappers/base.rb +3 -0
- data/lib/contentful_middleman/tools/backup.rb +1 -1
- data/lib/contentful_middleman/version.rb +1 -1
- data/spec/contentful_middleman/import_task_spec.rb +22 -1
- data/spec/contentful_middleman/mappers/base_spec.rb +10 -0
- data/spec/contentful_middleman/version_hash_spec.rb +1 -10
- data/spec/spec_helper.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afab6f9f2082efc2316157faf338a513c2e6e6eb
|
4
|
+
data.tar.gz: 40656a4aec70d29441724ade7b93ef12b48b7f79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf2b26d03c3f463dce1bcb6ea57c5b8e0e76424752bfd00d0afdad350fc1ba9fadb70acfab4cf1d1eecad4ee6ea8e2473076eade4216431a3638a3a7b68c577
|
7
|
+
data.tar.gz: 60c4bc8fe795b67fdd33188c9de8349aa09ece3f8168a0fecea667283fb122bf368789e66812db330cc0c07eff5c57176fb9f0dd2b789d8b994009e8869984f7
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
## Unreleased
|
3
3
|
|
4
|
+
## 1.3.2
|
5
|
+
### Fixed
|
6
|
+
* Fixed Entry ID fetch on import task when having an ID field in the Content Type[#77](https://github.com/contentful/contentful_middleman/issues/77)
|
7
|
+
* Fixed `NoMethodError` when Entry has no populated fields[#76](https://github.com/contentful/contentful_middleman/issues/76)
|
8
|
+
|
4
9
|
## 1.3.1
|
5
10
|
### Fixed
|
6
11
|
* Middleman not loading extension due to `@app` reassignment
|
@@ -22,6 +22,15 @@ module ContentfulMiddleman
|
|
22
22
|
@changed_local_data
|
23
23
|
end
|
24
24
|
|
25
|
+
def entries
|
26
|
+
@entries ||= @contentful.entries
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_name(content_type_name, entry)
|
30
|
+
entry_id = entry.sys.key?(:id) ? entry.sys[:id] : entry.id
|
31
|
+
File.join(@space_name, content_type_name, entry_id.to_s)
|
32
|
+
end
|
33
|
+
|
25
34
|
private
|
26
35
|
def local_data_files
|
27
36
|
entries.map do |entry|
|
@@ -35,12 +44,8 @@ module ContentfulMiddleman
|
|
35
44
|
content_type_mapper = content_type_mapper_class.new(entries, @contentful.options)
|
36
45
|
content_type_mapper.map(context, entry)
|
37
46
|
|
38
|
-
LocalData::File.new(context.to_yaml,
|
47
|
+
LocalData::File.new(context.to_yaml, file_name(content_type_name, entry))
|
39
48
|
end.compact
|
40
49
|
end
|
41
|
-
|
42
|
-
def entries
|
43
|
-
@entries ||= @contentful.entries
|
44
|
-
end
|
45
50
|
end
|
46
51
|
end
|
@@ -6,9 +6,13 @@ class ClientDouble
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
+
class EntryDouble
|
10
|
+
end
|
11
|
+
|
9
12
|
describe ContentfulMiddleman::ImportTask do
|
10
13
|
let(:path) { File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'space_hash_fixtures')) }
|
11
|
-
|
14
|
+
let(:client) { ClientDouble.new }
|
15
|
+
subject { described_class.new 'foobar', {}, {}, client }
|
12
16
|
|
13
17
|
describe 'instance methods' do
|
14
18
|
before do
|
@@ -37,5 +41,22 @@ describe ContentfulMiddleman::ImportTask do
|
|
37
41
|
expect(subject.changed_local_data?).to eq(true)
|
38
42
|
end
|
39
43
|
end
|
44
|
+
|
45
|
+
it '#entries' do
|
46
|
+
expect(subject.entries).to eq client.entries
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#file_name' do
|
50
|
+
it 'uses entry.sys[:id] over entry.id' do
|
51
|
+
entry = EntryDouble.new('foo', {}, {id: 'bar'})
|
52
|
+
client.entries << entry
|
53
|
+
|
54
|
+
expect(entry.id).not_to eq entry.sys[:id]
|
55
|
+
expect(entry.id).to eq 'bar'
|
56
|
+
expect(entry.sys[:id]).to eq 'foo'
|
57
|
+
|
58
|
+
expect(subject.file_name('baz', entry)).to eq File.join('foobar', 'baz', 'foo')
|
59
|
+
end
|
60
|
+
end
|
40
61
|
end
|
41
62
|
end
|
@@ -85,4 +85,14 @@ describe ContentfulMiddleman::Mapper::Base do
|
|
85
85
|
expect(subject.entries).to match(entries)
|
86
86
|
end
|
87
87
|
end
|
88
|
+
|
89
|
+
describe 'issues' do
|
90
|
+
it 'should not fail on empty entry - #76' do
|
91
|
+
entry = EntryDouble.new('foo', {}, nil)
|
92
|
+
context = ContentfulMiddleman::Context.new
|
93
|
+
|
94
|
+
expect { subject.map(context, entry) }.not_to raise_error
|
95
|
+
expect(context.hashize).to eq(id: 'foo')
|
96
|
+
end
|
97
|
+
end
|
88
98
|
end
|
@@ -1,14 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class EntryDouble
|
4
|
-
attr_reader :id, :updated_at
|
5
|
-
|
6
|
-
def initialize(id, updated_at)
|
7
|
-
@id = id
|
8
|
-
@updated_at = updated_at
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
3
|
describe ContentfulMiddleman::VersionHash do
|
13
4
|
let(:path) { File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'space_hash_fixtures')) }
|
14
5
|
describe 'class methods' do
|
@@ -32,7 +23,7 @@ describe ContentfulMiddleman::VersionHash do
|
|
32
23
|
end
|
33
24
|
|
34
25
|
describe '::write_for_space_with_entries' do
|
35
|
-
let(:entries) { [EntryDouble.new(1, '2015-11-25'), EntryDouble.new(2, '2015-11-25')] }
|
26
|
+
let(:entries) { [EntryDouble.new(1, {}, {}, '2015-11-25'), EntryDouble.new(2, {}, {}, '2015-11-25')] }
|
36
27
|
|
37
28
|
before do
|
38
29
|
described_class.source_root = path
|
data/spec/spec_helper.rb
CHANGED
@@ -64,3 +64,27 @@ class OptionsDouble
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
class EntryDouble
|
69
|
+
attr_reader :id, :sys, :fields
|
70
|
+
|
71
|
+
def initialize(id, sys_data = {}, fields = {}, updated_at = nil)
|
72
|
+
@id = id
|
73
|
+
sys_data[:id] = id
|
74
|
+
sys_data[:updated_at] = updated_at
|
75
|
+
@sys = sys_data
|
76
|
+
@fields = fields
|
77
|
+
|
78
|
+
unless fields.nil?
|
79
|
+
fields.each do |k, v|
|
80
|
+
define_singleton_method k do
|
81
|
+
v
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def updated_at
|
88
|
+
sys[:updated_at]
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful_middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sascha Konietzke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|