mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Implement basic rendering
Woo actioncontroller
This commit is contained in:
25
test/action_controller/serialization_test.rb
Normal file
25
test/action_controller/serialization_test.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'test_helper'
|
||||
|
||||
module ActionController
|
||||
module Serialization
|
||||
class ImplicitSerializerTest < ActionController::TestCase
|
||||
class MyController < ActionController::Base
|
||||
def render_using_implicit_serializer
|
||||
render json: Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
end
|
||||
end
|
||||
|
||||
tests MyController
|
||||
|
||||
# We just have Null for now, this will change
|
||||
def test_render_using_implicit_serializer
|
||||
get :render_using_implicit_serializer
|
||||
|
||||
assert_equal 'application/json', @response.content_type
|
||||
assert_equal '{"name":"Name 1","description":"Description 1"}', @response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
require "bundler/setup"
|
||||
|
||||
require 'rails'
|
||||
require 'action_controller'
|
||||
require 'action_controller/test_case'
|
||||
require "active_support/json"
|
||||
require 'minitest/autorun'
|
||||
|
||||
require "active_model_serializers"
|
||||
|
||||
require 'fixtures/poro'
|
||||
|
||||
module TestHelper
|
||||
Routes = ActionDispatch::Routing::RouteSet.new
|
||||
Routes.draw do
|
||||
get ':controller(/:action(/:id))'
|
||||
get ':controller(/:action)'
|
||||
end
|
||||
|
||||
ActionController::Base.send :include, Routes.url_helpers
|
||||
end
|
||||
|
||||
ActionController::TestCase.class_eval do
|
||||
def setup
|
||||
@routes = TestHelper::Routes
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user