Skip to content

Commit

Permalink
Remove test dependencies (hack data so tests don't interfere).
Browse files Browse the repository at this point in the history
  ToDo: fix this the right way
  • Loading branch information
lgebhardt committed Apr 2, 2015
1 parent 14533b2 commit c7a3482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion test/fixtures/comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ post_2_thanks_man:
id: 3
post_id: 2
body: Thanks man. Great post. But what is JR?
author_id: 2
author_id: 2

rogue_comment:
body: Rogue Comment Here
author_id: 3
12 changes: 6 additions & 6 deletions test/integration/requests/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,24 @@ def test_put_update_association_has_one
def test_patch_update_association_has_many_acts_as_set
# Comments are acts_as_set=false so PUT/PATCH should respond with 403

like = Comment.find_by(body: 'i liked it')
patch '/posts/3/links/comments', { 'data' => [{type: 'comments', id: like.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
rogue = Comment.find_by(body: 'Rogue Comment Here')
patch '/posts/5/links/comments', { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE

assert_equal 403, status
end

def test_post_update_association_has_many
like = Comment.find_by(body: 'i liked it')
post '/posts/3/links/comments', { 'data' => [{type: 'comments', id: like.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
rogue = Comment.find_by(body: 'Rogue Comment Here')
post '/posts/5/links/comments', { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE

assert_equal 204, status
end

def test_put_update_association_has_many_acts_as_set
# Comments are acts_as_set=false so PUT/PATCH should respond with 403. Note: JR currently treats PUT and PATCH as equivalent

like = Comment.find_by(body: 'i liked it')
put '/posts/3/links/comments', { 'data' => [{type: 'comments', id: like.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE
rogue = Comment.find_by(body: 'Rogue Comment Here')
put '/posts/5/links/comments', { 'data' => [{type: 'comments', id: rogue.id.to_s }]}.to_json, "CONTENT_TYPE" => JSONAPI::MEDIA_TYPE

assert_equal 403, status
end
Expand Down

0 comments on commit c7a3482

Please sign in to comment.