-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
14 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
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 |
---|---|---|
|
@@ -10,6 +10,48 @@ def app | |
Sinatra::Application.new | ||
end | ||
|
||
def test_uncoalesced_find_head | ||
head '/authors' | ||
assert_ok | ||
assert_equal 'GET,POST', last_response.headers['Allow'] | ||
end | ||
|
||
def test_uncoalesced_find | ||
DB[:authors].multi_insert [ | ||
{ :email=>'[email protected]', :display_name=>'Dilbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Dogbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Catbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Wally' } | ||
] | ||
get '/authors' | ||
assert_ok | ||
vals = json[:data].map do |t| | ||
name = t[:attributes][:'display-name'] | ||
name = nil if name == 'Anonymous Coward' | ||
{ :id=>t[:id].to_i, :display_name=>name } | ||
end | ||
assert_equal DB[:authors].select(:id, :display_name).all, vals | ||
end | ||
|
||
def test_coalesced_find_head | ||
head '/tags?filter[id]=2,4' | ||
assert_ok | ||
assert_equal 'GET', last_response.headers['Allow'] | ||
end | ||
|
||
def test_coalesced_find | ||
DB[:authors].multi_insert [ | ||
{ :email=>'[email protected]', :display_name=>'Dilbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Dogbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Catbert' }, | ||
{ :email=>'[email protected]', :display_name=>'Wally' } | ||
] | ||
get '/authors?filter[id]=2,4' | ||
assert_ok | ||
vals = json[:data].map { |t| { :id=>t[:id].to_i, :display_name=>t[:attributes][:'display-name'] } } | ||
assert_equal DB[:authors].where(:id=>[2, 4]).select(:id, :display_name).all, vals | ||
end | ||
|
||
def test_disallow_client_generated_id | ||
post '/authors', JSON.generate(:data=>{ | ||
:type=>'authors', | ||
|
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