middleman-dato 0.5.16.3 → 0.5.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +0 -1
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/lib/middleman-dato.rb +2 -1
- data/lib/middleman_dato/meta_tags/article_modified_time.rb +1 -0
- data/lib/middleman_dato/meta_tags/article_publisher.rb +1 -0
- data/lib/middleman_dato/meta_tags/base.rb +3 -2
- data/lib/middleman_dato/meta_tags/description.rb +1 -0
- data/lib/middleman_dato/meta_tags/favicon.rb +7 -11
- data/lib/middleman_dato/meta_tags/image.rb +1 -0
- data/lib/middleman_dato/meta_tags/og_locale.rb +1 -0
- data/lib/middleman_dato/meta_tags/og_meta_tag.rb +1 -0
- data/lib/middleman_dato/meta_tags/og_site_name.rb +1 -0
- data/lib/middleman_dato/meta_tags/og_type.rb +1 -0
- data/lib/middleman_dato/meta_tags/robots.rb +1 -0
- data/lib/middleman_dato/meta_tags/title.rb +1 -0
- data/lib/middleman_dato/meta_tags/twitter_card.rb +1 -0
- data/lib/middleman_dato/meta_tags/twitter_meta_tag.rb +1 -0
- data/lib/middleman_dato/meta_tags/twitter_site.rb +1 -0
- data/lib/middleman_dato/meta_tags/url.rb +1 -0
- data/lib/middleman_dato/meta_tags_builder.rb +1 -0
- data/lib/middleman_dato/middleman_extension.rb +14 -5
- data/lib/middleman_dato/version.rb +2 -2
- data/middleman-dato.gemspec +3 -4
- data/spec/middleman_dato/meta_tags/article_modified_time_spec.rb +1 -0
- data/spec/middleman_dato/meta_tags/favicon_spec.rb +8 -7
- data/spec/middleman_dato/meta_tags/image_spec.rb +1 -0
- data/spec/middleman_dato/meta_tags/og_locale_spec.rb +1 -0
- data/spec/spec_helper.rb +7 -7
- data/spec/support/mock_builder.rb +1 -0
- metadata +8 -73
- data/lib/middleman_dato/client.rb +0 -68
- data/lib/middleman_dato/entities_repo.rb +0 -43
- data/lib/middleman_dato/field_type/boolean.rb +0 -9
- data/lib/middleman_dato/field_type/date.rb +0 -9
- data/lib/middleman_dato/field_type/date_time.rb +0 -9
- data/lib/middleman_dato/field_type/file.rb +0 -30
- data/lib/middleman_dato/field_type/float.rb +0 -9
- data/lib/middleman_dato/field_type/image.rb +0 -29
- data/lib/middleman_dato/field_type/integer.rb +0 -9
- data/lib/middleman_dato/field_type/lat_lon.rb +0 -20
- data/lib/middleman_dato/field_type/link.rb +0 -9
- data/lib/middleman_dato/field_type/links.rb +0 -9
- data/lib/middleman_dato/field_type/seo.rb +0 -21
- data/lib/middleman_dato/field_type/string.rb +0 -9
- data/lib/middleman_dato/field_type/text.rb +0 -9
- data/lib/middleman_dato/field_type/video.rb +0 -52
- data/lib/middleman_dato/item.rb +0 -121
- data/lib/middleman_dato/items_repo.rb +0 -107
- data/lib/middleman_dato/json_api_entity.rb +0 -75
- data/lib/middleman_dato/site.rb +0 -36
- data/spec/middleman_dato/entities_repo_spec.rb +0 -41
- data/spec/middleman_dato/field_type/file_spec.rb +0 -20
- data/spec/middleman_dato/field_type/image_spec.rb +0 -24
- data/spec/middleman_dato/field_type/lat_lon_spec.rb +0 -18
- data/spec/middleman_dato/field_type/seo_spec.rb +0 -31
- data/spec/middleman_dato/field_type/video_spec.rb +0 -32
- data/spec/middleman_dato/item_spec.rb +0 -188
- data/spec/middleman_dato/items_repo_spec.rb +0 -125
- data/spec/middleman_dato/json_api_entity_spec.rb +0 -123
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'middleman_dato/items_repo'
|
2
|
-
|
3
|
-
module MiddlemanDato
|
4
|
-
RSpec.describe ItemsRepo do
|
5
|
-
subject(:repo) { described_class.new(entities_repo) }
|
6
|
-
let(:entities_repo) do
|
7
|
-
instance_double('MiddlemanDato::EntitiesRepo')
|
8
|
-
end
|
9
|
-
let(:item_type) do
|
10
|
-
double('MiddlemanDato::JsonApiEntity', api_key: 'post', singleton: false)
|
11
|
-
end
|
12
|
-
let(:singleton_item_type) do
|
13
|
-
double('MiddlemanDato::JsonApiEntity', api_key: 'homepage', singleton: true)
|
14
|
-
end
|
15
|
-
let(:item_entity) do
|
16
|
-
double('MiddlemanDato::JsonApiEntity', item_type: item_type)
|
17
|
-
end
|
18
|
-
let(:singleton_item_entity) do
|
19
|
-
double('MiddlemanDato::JsonApiEntity', item_type: singleton_item_type)
|
20
|
-
end
|
21
|
-
let(:item) do
|
22
|
-
instance_double('MiddlemanDato::Item', id: '14')
|
23
|
-
end
|
24
|
-
let(:singleton_item) do
|
25
|
-
instance_double('MiddlemanDato::Item', id: '22')
|
26
|
-
end
|
27
|
-
|
28
|
-
before do
|
29
|
-
allow(entities_repo).to receive(:find_entities_of_type).with('item_type') do
|
30
|
-
[item_type, singleton_item_type]
|
31
|
-
end
|
32
|
-
|
33
|
-
allow(entities_repo).to receive(:find_entities_of_type).with('item') do
|
34
|
-
[item_entity, singleton_item_entity]
|
35
|
-
end
|
36
|
-
|
37
|
-
allow(Item).to receive(:new).with(item_entity, anything) do
|
38
|
-
item
|
39
|
-
end
|
40
|
-
|
41
|
-
allow(Item).to receive(:new).with(singleton_item_entity, anything) do
|
42
|
-
singleton_item
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#find' do
|
47
|
-
it 'returns the specified item' do
|
48
|
-
expect(repo.find('14')).to eq item
|
49
|
-
expect(repo.find('22')).to eq singleton_item
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'item_types' do
|
54
|
-
describe 'singleton' do
|
55
|
-
it 'returns the associated item' do
|
56
|
-
expect(repo.respond_to?(:homepage)).to be_truthy
|
57
|
-
expect(repo.homepage).to eq singleton_item
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'non-singleton' do
|
62
|
-
it 'returns the associated items' do
|
63
|
-
expect(repo.respond_to?(:posts)).to be_truthy
|
64
|
-
expect(repo.posts).to eq [item]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'non existing content types' do
|
69
|
-
it 'returns NoMethodError' do
|
70
|
-
expect(repo.respond_to?(:foobars)).to be_falsy
|
71
|
-
expect { repo.foobars }.to raise_error NoMethodError
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe ItemsRepo::ItemCollection do
|
77
|
-
subject(:collection) { described_class.new(items) }
|
78
|
-
let(:items) do
|
79
|
-
[foo]
|
80
|
-
end
|
81
|
-
|
82
|
-
let(:foo) { double('MiddlemanDato::Item', id: '1', name: 'Foo') }
|
83
|
-
|
84
|
-
describe '#[]' do
|
85
|
-
it 'returns the item with the specified id or index' do
|
86
|
-
expect(collection['1']).to eq foo
|
87
|
-
expect(collection[0]).to eq foo
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#keys' do
|
92
|
-
it 'returns the list of ids' do
|
93
|
-
expect(collection.keys).to eq ['1']
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#each' do
|
98
|
-
context 'with arity == 2' do
|
99
|
-
it 'iterates with id and item' do
|
100
|
-
collection.each do |a, b|
|
101
|
-
expect(a).to eq '1'
|
102
|
-
expect(b).to eq foo
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'with arity != 2' do
|
108
|
-
it 'iterates just like a regular array' do
|
109
|
-
collection.each do |a|
|
110
|
-
expect(a).to eq foo
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it '#values' do
|
117
|
-
expect(collection.values).to eq [foo]
|
118
|
-
end
|
119
|
-
|
120
|
-
it '#sort_by' do
|
121
|
-
expect(collection.sort_by(&:name)).to eq [foo]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'middleman_dato/json_api_entity'
|
2
|
-
|
3
|
-
module MiddlemanDato
|
4
|
-
RSpec.describe JsonApiEntity do
|
5
|
-
subject(:object) { described_class.new(payload, data_source) }
|
6
|
-
let(:payload) do
|
7
|
-
{
|
8
|
-
id: 'peter',
|
9
|
-
type: 'person',
|
10
|
-
attributes: {
|
11
|
-
first_name: 'Peter',
|
12
|
-
last_name: 'Griffin'
|
13
|
-
},
|
14
|
-
relationships: {
|
15
|
-
children: {
|
16
|
-
data: [
|
17
|
-
{ type: 'person', id: 'stewie' }
|
18
|
-
]
|
19
|
-
},
|
20
|
-
mother: {
|
21
|
-
data: { type: 'person', id: 'thelma' }
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
let(:data_source) do
|
28
|
-
instance_double('MiddlemanDato::DataSource')
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#id' do
|
32
|
-
it 'returns the object ID' do
|
33
|
-
expect(object.id).to eq 'peter'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#type' do
|
38
|
-
it 'returns the object type' do
|
39
|
-
expect(object.type).to eq 'person'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'attributes' do
|
44
|
-
it 'returns the attribute if it exists' do
|
45
|
-
expect(object.respond_to?(:first_name)).to be_truthy
|
46
|
-
expect(object.first_name).to eq 'Peter'
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'returns NoMethodError if it doesnt' do
|
50
|
-
expect(object.respond_to?(:foo_bar)).to be_falsy
|
51
|
-
expect { object.foo_bar }.to raise_error NoMethodError
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '[]' do
|
56
|
-
it 'returns the attribute if it exists' do
|
57
|
-
expect(object[:first_name]).to eq 'Peter'
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'returns nil if it doesnt' do
|
61
|
-
expect(object[:foo_bar]).to be_nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '==' do
|
66
|
-
context 'same id and type' do
|
67
|
-
let(:other) do
|
68
|
-
described_class.new({ id: 'peter', type: 'person' }, data_source)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'returns true' do
|
72
|
-
expect(object == other).to be_truthy
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'different id and type' do
|
77
|
-
let(:other) do
|
78
|
-
described_class.new({ id: 'stewie', type: 'person' }, data_source)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'returns false' do
|
82
|
-
expect(object == other).to be_falsy
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'different class' do
|
87
|
-
let(:other) do
|
88
|
-
12
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'returns false' do
|
92
|
-
expect(object == other).to be_falsy
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe 'links' do
|
98
|
-
let(:stewie) { instance_double('MiddlemanDato::JsonApiObject') }
|
99
|
-
let(:thelma) { instance_double('MiddlemanDato::JsonApiObject') }
|
100
|
-
|
101
|
-
before do
|
102
|
-
allow(data_source).to receive(:find_entity).with('person', 'stewie') { stewie }
|
103
|
-
allow(data_source).to receive(:find_entity).with('person', 'thelma') { thelma }
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'multiple linkages' do
|
107
|
-
it 'returns the array of JsonApiObjects' do
|
108
|
-
expect(object.children).to eq [stewie]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'single linkage' do
|
113
|
-
it 'returns the JsonApiObject' do
|
114
|
-
expect(object.mother).to eq thelma
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'returns NoMethodError if it does not exist' do
|
119
|
-
expect { object.father }.to raise_error NoMethodError
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|