-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to specify query params when updating/creating resources
- Loading branch information
Alcides Ramos
committed
Apr 25, 2023
1 parent
4e48e15
commit 1776ee8
Showing
5 changed files
with
97 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe "Updating resources" do | ||
|
||
example "Updating a resource" do | ||
stub_auth_request(:put, "http://movida.example.com/projects/1").with do |req| | ||
url = "http://movida.example.com/projects/1" | ||
|
||
stub_auth_request(:put, url).with do |req| | ||
req.body == {name: "Wadus Wadus"}.to_xml(root: "project") | ||
end.to_return(body: <<-XML) | ||
<project> | ||
<name>Wadus Wadus</name> | ||
<link rel="self" href="http://movida.example.com/projects/1"/> | ||
<link rel="self" href="#{url}"/> | ||
</project> | ||
XML | ||
project = Almodovar::Resource("http://movida.example.com/projects/1", auth) | ||
|
||
project = Almodovar::Resource(url, auth) | ||
|
||
project.update(project: {name: "Wadus Wadus"}) | ||
|
||
expect(project.name).to eq("Wadus Wadus") | ||
end | ||
|
||
example "Updating a document resource" do | ||
stub_auth_request(:put, "http://movida.example.com/people/1/extra_data").with do |req| | ||
url = "http://movida.example.com/people/1/extra_data" | ||
|
||
stub_auth_request(:put, url).with do |req| | ||
req.body == {birthplace: "Calzada de Calatrava"}.to_xml(root: "extra-data") | ||
end.to_return(body: <<-XML) | ||
<extra-data type="document"> | ||
<birthplace>Calzada de Calatrava</birthplace> | ||
<birthyear type="integer">1949</birthyear> | ||
</extra-data> | ||
XML | ||
extra_data = Almodovar::Resource("http://movida.example.com/people/1/extra_data", auth) | ||
extra_data.update(extra_data: {birthplace: "Calzada de Calatrava"}) | ||
|
||
extra_data = Almodovar::Resource(url, auth) | ||
extra_data.update(extra_data: { birthplace: "Calzada de Calatrava" }) | ||
expect(extra_data.birthplace).to eq("Calzada de Calatrava") | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters