Skip to content

Commit

Permalink
Merge pull request #6 from TrailerVote/feature/issues
Browse files Browse the repository at this point in the history
Add Issue MediaType
  • Loading branch information
SleeplessByte committed Oct 17, 2018
2 parents b1330ee + 36cb150 commit cb1d007
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions ruby/Gemfile.lock
Expand Up @@ -31,6 +31,7 @@ GEM
simplecov-html (0.10.2)

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions ruby/lib/trailer_vote/media_types.rb
Expand Up @@ -22,6 +22,7 @@
require_relative './media_types/product_image'
require_relative './media_types/product_place_link'
require_relative './media_types/product_video'
require_relative './media_types/issue'

module TrailerVote
module MediaTypes
Expand Down
1 change: 1 addition & 0 deletions ruby/lib/trailer_vote/media_types/configuration.rb
Expand Up @@ -30,6 +30,7 @@ class Configuration < BaseText
link :telemetrics do
attribute :href, Types::InfluxDbConnectionUrl
end
link :issues
end
end

Expand Down
49 changes: 49 additions & 0 deletions ruby/lib/trailer_vote/media_types/issue.rb
@@ -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
Expand Up @@ -22,6 +22,9 @@
"persona": {
"href": "https://fake.trailervote.com/api/personas/{uuid}",
"templated": true
},
"issues": {
"href": "https://fake.trailervote.com/api/issues"
}
}
}
Expand Down
@@ -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"
}
}
}
}
@@ -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"
}
}
}
}
}
35 changes: 35 additions & 0 deletions ruby/test/trailer_vote/media_types/issue_test.rb
@@ -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

0 comments on commit cb1d007

Please sign in to comment.