-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from o19s/bugfix-3-rating-docs
base64 encode document ids that contain a period. fixes #3
- Loading branch information
Showing
5 changed files
with
72 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'test_helper' | ||
|
||
class RatingDocumentsFlowTest < ActionDispatch::IntegrationTest | ||
|
||
test "can rate documents that have various formatted document ids" do | ||
|
||
# asserts the route for normal doc id's works. | ||
assert_routing( | ||
{ method: 'put', path: "/api/cases/44/queries/62/ratings/99" }, | ||
{ controller: "api/v1/queries/ratings", action: "update", format: :json, case_id: "44", "query_id": "62", doc_id: "99" } | ||
) | ||
|
||
# make sure using other non numeric identifiers works. | ||
assert_routing( | ||
{ method: 'put', path: "/api/cases/44/queries/62/ratings/mydoc" }, | ||
{ controller: "api/v1/queries/ratings", action: "update", format: :json, case_id: "44", "query_id": "62", doc_id: "mydoc" } | ||
) | ||
|
||
# A period in the doc_id should work, however Rails assumes that post the dot is the format type. We deal with this by | ||
# Base64 encoding in the Angular front end and decoding in ratings controller. | ||
assert_routing( | ||
{ method: 'put', path: "/api/cases/44/queries/62/ratings/mydoc.pdf" }, | ||
{ controller: "api/v1/queries/ratings", action: "update", "format": "pdf", case_id: "44", "query_id": "62", doc_id: "mydoc" } | ||
) | ||
end | ||
end |