From b27eaaf6c2bffc7e55c988ae0311fda31fe60bec Mon Sep 17 00:00:00 2001 From: "Ryan T. Hosford" Date: Thu, 18 Feb 2016 11:58:53 -0600 Subject: [PATCH] Registers application/vnd.api+json mime type --- app/controllers/bugs_controller.rb | 1 - config/initializers/custom_json_mime_type.rb | 2 ++ test/controllers/bugs_controller_test.rb | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 config/initializers/custom_json_mime_type.rb diff --git a/app/controllers/bugs_controller.rb b/app/controllers/bugs_controller.rb index bfcdd15..aba2d71 100644 --- a/app/controllers/bugs_controller.rb +++ b/app/controllers/bugs_controller.rb @@ -16,7 +16,6 @@ def show # POST /bugs def create - binding.pry @bug = Bug.new(bug_params) if @bug.save diff --git a/config/initializers/custom_json_mime_type.rb b/config/initializers/custom_json_mime_type.rb new file mode 100644 index 0000000..8532cd0 --- /dev/null +++ b/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 ) diff --git a/test/controllers/bugs_controller_test.rb b/test/controllers/bugs_controller_test.rb index 178935a..07acc11 100644 --- a/test/controllers/bugs_controller_test.rb +++ b/test/controllers/bugs_controller_test.rb @@ -6,8 +6,8 @@ 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] @@ -15,7 +15,7 @@ class BugsControllerTest < ActionDispatch::IntegrationTest 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]