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

Add support for :sync with :raw_mode on #70

Merged
merged 1 commit into from
Oct 26, 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 @@ -2,6 +2,7 @@
## Unreleased
### Fixed
* Fix Custom Resource creation parameters [#69](https://github.com/contentful/contentful.rb/issues/69)
* `Sync API` now works with `:raw_mode` enabled [#68](https://github.com/contentful/contentful.rb/issues/68)

## 0.6.0
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions lib/contentful/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def get(options_or_url)
page = Request.new(@client, '/sync', options_or_url).get
end

if @client.configuration[:raw_mode]
return page
end

link_page_to_sync! page
update_sync_state_from! page

Expand Down
106 changes: 106 additions & 0 deletions spec/fixtures/vcr_cassettes/sync_page_short.yml

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

58 changes: 58 additions & 0 deletions spec/sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,62 @@
}
end
end

describe 'raw_mode' do
before do
@sync = create_client(raw_mode: true).sync(initial: true)
end

it 'should not fail' do
vcr('sync_page_short') {
expect { @sync.first_page }.not_to raise_error
}
end

it 'should return a raw Response' do
vcr('sync_page_short') {
expect(@sync.first_page).to be_a Contentful::Response
}
end

it 'should return JSON' do
expected = {
"sys" => {"type" => "Array"},
"items" => [
{
"sys" => {
"space" => {
"sys" => {
"type" => "Link",
"linkType" => "Space",
"id" => "cfexampleapi"}
},
"type" => "Entry",
"contentType" => {
"sys" => {
"type" => "Link",
"linkType" => "ContentType",
"id" => "1t9IbcfdCk6m04uISSsaIK"
}
},
"id" => "5ETMRzkl9KM4omyMwKAOki",
"revision" => 2,
"createdAt" => "2014-02-21T13:42:57.752Z",
"updatedAt" => "2014-04-16T12:44:02.691Z"
},
"fields" => {
"name" => {"en-US"=>"London"},
"center" => {
"en-US" => {"lat"=>51.508515, "lon"=>-0.12548719999995228}
}
}
}
],
"nextSyncUrl" => "https://cdn.contentful.com/spaces/cfexampleapi/sync?sync_token=w5ZGw6JFwqZmVcKsE8Kow4grw45QdybCr8Okw6AYwqbDksO3ehvDpUPCgcKsKXbCiAwPC8K2w4LDvsOkw6nCjhPDpcOQADElWsOoU8KGR3HCtsOAwqd6wp_Dulp8w6LDsF_CtsK7Kk05wrMvwrLClMOgG2_Dn2sGPg"
}
vcr('sync_page_short') {
expect(@sync.first_page.object).to eql expected
}
end
end
end