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 TrailerVote/feature/issues
Add Issue MediaType
- Loading branch information
Showing
8 changed files
with
126 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ GEM | |
simplecov-html (0.10.2) | ||
|
||
PLATFORMS | ||
ruby | ||
x64-mingw32 | ||
|
||
DEPENDENCIES | ||
|
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,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'base_text' | ||
require_relative 'types/iso8601' | ||
|
||
module TrailerVote | ||
module MediaTypes | ||
class Issue < BaseText | ||
media_type 'issue', defaults: { suffix: :json, version: 1 } | ||
|
||
validations do | ||
|
||
version 1 do | ||
version_1_base = ::MediaTypes::Scheme.new do | ||
attribute :error_name, String | ||
attribute :error_message, String | ||
|
||
attribute :rescue_context do | ||
attribute :caller, String | ||
attribute :args, ::Hash, allow_empty: true do | ||
not_strict | ||
end | ||
end | ||
end | ||
|
||
attribute :issue do | ||
merge version_1_base | ||
attribute :updated_at, Types::Iso8601 | ||
|
||
link :self | ||
end | ||
|
||
view 'create' do | ||
attribute :issue do | ||
merge version_1_base | ||
end | ||
end | ||
end | ||
end | ||
|
||
registrations :issue do | ||
view 'create', :create_issue | ||
|
||
versions 1 | ||
end | ||
|
||
end | ||
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
21 changes: 21 additions & 0 deletions
21
ruby/test/trailer_vote/fixtures/application/vnd.trailervote.issue.v1+json
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,21 @@ | ||
{ | ||
"issue": { | ||
"error_name": "ConflictingIdentifiers", | ||
"error_message": "Command failed when ingesting movie because of Conflicting Identifiers", | ||
"rescue_context": { | ||
"caller": "TMDb::Ingestion::IngestMovieJob", | ||
"args": { | ||
"movie": { | ||
"id": "12345", | ||
"title": "The Testing Movie" | ||
} | ||
} | ||
}, | ||
"updated_at": "2018-10-03T20:34:43.092Z", | ||
"_links": { | ||
"self": { | ||
"href": "https://fake.trailervote.com/api/issues/23403a0a-24f7-457d-945e-c6d27e04c73f" | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
ruby/test/trailer_vote/fixtures/application/vnd.trailervote.issue.v1.create+json
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,15 @@ | ||
{ | ||
"issue": { | ||
"error_name": "ConflictingIdentifiers", | ||
"error_message": "Command failed when ingesting movie because of Conflicting Identifiers", | ||
"rescue_context": { | ||
"caller": "TMDb::Ingestion::IngestMovieJob", | ||
"args": { | ||
"movie": { | ||
"id": "12345", | ||
"title": "The Testing Movie" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../test_helper' | ||
|
||
module TrailerVote | ||
module MediaTypes | ||
class IssueTest < Minitest::Test | ||
|
||
def test_the_default_media_type | ||
# When this changes, the default version has changes and you should make downstream changes / have this gems | ||
# version change as well. If you pin a certain media type gem version, you get consistent media types. | ||
assert_equal 'application/vnd.trailervote.issue.v1+json', Issue.to_constructable.to_s | ||
end | ||
|
||
def test_it_registers | ||
assert_media_types_registered(Issue) do | ||
formatted_mime_type 'application/vnd.trailervote.issue.v%<version>s+json' do | ||
version 1, symbol: :issue_v1_json, synonyms: [] | ||
end | ||
|
||
formatted_mime_type 'application/vnd.trailervote.issue.v%<version>s.%<view>s+json' do | ||
|
||
version 1 do | ||
view 'create', symbol: :create_issue_v1_json, synonyms: [] | ||
end | ||
end | ||
end | ||
end | ||
|
||
def test_fixtures | ||
assert_fixture_passes_validation Issue | ||
end | ||
end | ||
end | ||
end |