-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* finish bug fix and spec * fix * without extending data * do not return an internal collection * fix extend with references naming * fix rubocop * fix include issue * patch version * fix specs * wrong variable * request as before * extend as before * request spec as before * adding spec to prevent internal collection from returning to the outside * proper extension before continue including * not for now * fix rubocop
- Loading branch information
Showing
6 changed files
with
110 additions
and
18 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,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module LHS | ||
VERSION = '25.0.3' | ||
VERSION = '25.0.4' | ||
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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe LHS::Record do | ||
context 'includes records after expansion' do | ||
|
||
before do | ||
class User < LHS::Record | ||
endpoint 'http://users/{id}' | ||
end | ||
|
||
class Places < LHS::Record | ||
endpoint 'http://users/{id}/places' | ||
endpoint 'http://places/{id}' | ||
end | ||
|
||
class Contracts < LHS::Record | ||
endpoint 'http://places/{place_id}/contracts' | ||
end | ||
|
||
stub_request(:get, 'http://users/1') | ||
.to_return( | ||
body: { | ||
places: { | ||
href: 'http://users/1/places' | ||
} | ||
}.to_json | ||
) | ||
|
||
stub_request(:get, 'http://users/1/places?limit=100') | ||
.to_return( | ||
body: { | ||
items: [ | ||
{ href: 'http://places/345' } | ||
], | ||
total: 1, | ||
offset: 0, | ||
limit: 10 | ||
}.to_json | ||
) | ||
|
||
stub_request(:get, 'http://places/345') | ||
.to_return( | ||
body: { | ||
contracts: { | ||
href: "http://places/345/contracts?offset=0&limit=10" | ||
} | ||
}.to_json | ||
) | ||
|
||
stub_request(:get, 'http://places/345/contracts?offset=0&limit=10') | ||
.to_return( | ||
body: { | ||
items: [ | ||
{ | ||
product: { name: 'OPL' } | ||
} | ||
] | ||
}.to_json | ||
) | ||
|
||
end | ||
|
||
it 'includes resources after expanding plain links' do | ||
user = User.includes(places: :contracts).find(1) | ||
expect( | ||
user.places.first.contracts.first.product.name | ||
).to eq 'OPL' | ||
end | ||
end | ||
end |