-
Notifications
You must be signed in to change notification settings - Fork 532
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
4 changed files
with
139 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require File.expand_path('../test_helper', __FILE__) | ||
|
||
# Replace this with the code necessary to make your test fail. | ||
class BugTest < Minitest::Test | ||
include Rack::Test::Methods | ||
|
||
def json_api_headers | ||
{'Accept' => JSONAPI::MEDIA_TYPE, 'CONTENT_TYPE' => JSONAPI::MEDIA_TYPE} | ||
end | ||
|
||
def teardown | ||
Individual.delete_all | ||
ContactMedium.delete_all | ||
end | ||
|
||
def test_find_party_via_contact_medium | ||
individual = Individual.create(name: 'test') | ||
contact_medium = ContactMedium.create(party: individual, name: 'test contact medium') | ||
fetched_party = contact_medium.party | ||
assert_same individual, fetched_party, "Expect an individual to have been found via contact medium model's relationship 'party'" | ||
end | ||
|
||
def test_get_individual | ||
individual = Individual.create(name: 'test') | ||
ContactMedium.create(party: individual, name: 'test contact medium') | ||
get "/individuals/#{individual.id}" | ||
assert last_response.ok? | ||
end | ||
|
||
def test_get_party_via_contact_medium | ||
individual = Individual.create(name: 'test') | ||
contact_medium = ContactMedium.create(party: individual, name: 'test contact medium') | ||
get "/contact_media/#{contact_medium.id}/party" | ||
assert last_response.ok?, "Expect an individual to have been found via contact medium resource's relationship 'party'" | ||
end | ||
|
||
private | ||
|
||
def app | ||
Rails.application | ||
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
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