Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Issue MediaType #6

Merged
merged 6 commits into from Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
45 changes: 45 additions & 0 deletions ruby/lib/trailer_vote/media_types/issue.rb
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require_relative 'base_text'

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
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF newline

@@ -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"
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF newline

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF newline