Skip to content

Commit

Permalink
Registers application/vnd.api+json mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
rthbound committed Feb 18, 2016
1 parent dd99c60 commit b27eaaf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/controllers/bugs_controller.rb
Expand Up @@ -16,7 +16,6 @@ def show

# POST /bugs
def create
binding.pry
@bug = Bug.new(bug_params)

if @bug.save
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/custom_json_mime_type.rb
@@ -0,0 +1,2 @@
Mime::Type.unregister :json
Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest application/vnd.api+json application/json )
6 changes: 3 additions & 3 deletions test/controllers/bugs_controller_test.rb
Expand Up @@ -6,16 +6,16 @@ class BugsControllerTest < ActionDispatch::IntegrationTest
end

test "should demonstrate bug" do
params = { data: { maybe_a_bug: true } }
post bugs_url, params, { "Content-Type" => "application/vnd.api+json" }
params = { data: {"maybe_a_bug"=>"true"} }
post bugs_url, params: params, headers: { "Content-Type" => "application/vnd.api+json" }

assert_equal params[:data], request.params[:data]

assert_response 201
end

test "should demonstrate no-bug for comparison" do
params = { data: { maybe_a_bug: true } }
params = { data: {"maybe_a_bug"=>"true"} }
post bugs_url, params

assert_equal params[:data], request.params[:data]
Expand Down

0 comments on commit b27eaaf

Please sign in to comment.