Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for Field.items #76

Merged
merged 2 commits into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `Sync API` now works with `:raw_mode` enabled [#68](https://github.com/contentful/contentful.rb/issues/68)
* Handles multiple locales when requesting with `locale: "*"` [contentful_middleman/#39](https://github.com/contentful-labs/contentful_middleman/issues/39)
* Add support for querying a field's `linkType` [#75](https://github.com/contentful/contentful.rb/pull/75)
* Bugfix for `Field.items` [#76](https://github.com/contentful/contentful.rb/pull/76)

## 0.6.0
### Fixed
Expand Down
1 change: 1 addition & 0 deletions lib/contentful/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def coerce_value_or_array(value, what = nil)
def should_coerce_hash?(value)
value.is_a?(::Hash) &&
!self.is_a?(Asset) &&
!self.is_a?(Field) &&
!is_location?(value) &&
!is_link?(value) &&
!is_image?(value)
Expand Down
17 changes: 17 additions & 0 deletions spec/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
let(:linkField) { vcr('linkField') {
create_client.content_type('cat').fields.select { |f| f.id == 'image' }.first
} }
let(:arrayField) { vcr('arrayField') {
Contentful::Client.new(
space: 'wl1z0pal05vy',
access_token: '9b76e1bbc29eb513611a66b9fc5fb7acd8d95e83b0f7d6bacfe7ec926c819806'
).content_type('2PqfXUJwE8qSYKuM0U6w8M').fields.select { |f| f.id == 'categories' }.first
} }

describe 'Properties' do
it 'has a #properties getter returning a hash with symbol keys' do
Expand Down Expand Up @@ -46,4 +52,15 @@
expect(linkField.link_type).to eq 'Asset'
end
end

describe 'Array field properties' do
it 'has #type' do
expect(arrayField.type).to eq 'Array'
end

it 'has #items' do
expect(arrayField.items.type).to eq 'Link'
expect(arrayField.items.link_type).to eq 'Entry'
end
end
end
87 changes: 87 additions & 0 deletions spec/fixtures/vcr_cassettes/arrayField.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.