Skip to content
Browse files

Merge pull request #6 from lostisland/remove-simple-rels-from-data

Remove simple links from data when parsed
  • Loading branch information...
2 parents 38e69a7 + 413052e commit e92351ea3856ed7db37f8c86c12682d6247a4943 @pengwynn pengwynn committed
Showing with 4 additions and 1 deletion.
  1. +1 −1 lib/sawyer/link_parsers/simple.rb
  2. +3 −0 test/resource_test.rb
View
2 lib/sawyer/link_parsers/simple.rb
@@ -17,7 +17,7 @@ def parse(data)
inline_links = data.keys.select {|k| k.to_s[LINK_REGEX] }
inline_links.each do |key|
rel_name = key.to_s == 'url' ? 'self' : key.to_s.gsub(LINK_REGEX, '')
- links[rel_name.to_sym] = data[key]
+ links[rel_name.to_sym] = data.delete(key)
end
return data, links
View
3 test/resource_test.rb
@@ -131,9 +131,12 @@ def test_simple_rel_parsing
assert_equal '/', res.rels[:self].href
assert_kind_of Resource, res.user
+ assert !res.fields.include?(:url)
assert_equal 1, res.user.id
assert_equal '/users/1', res.user.rels[:self].href
+ assert !res.user.fields.include?(:url)
assert_equal '/users/1/followers', res.user.rels[:followers].href
+ assert !res.user.fields.include?(:followers_url)
end
end
end

0 comments on commit e92351e

Please sign in to comment.
Something went wrong with that request. Please try again.