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

Bring back assert_serializer #1099

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only load test helpers in the test environment
  • Loading branch information
maurogeorge committed Dec 21, 2015
commit 3a96cc1bcc9d897379b26d7ab29a445ad817b934
4 changes: 3 additions & 1 deletion lib/active_model/serializer/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Railtie < Rails::Railtie
require 'generators/serializer/resource_override'
end

ActionController::TestCase.send(:include, ActiveModelSerializers::Test::Serializer)
if Rails.env.test?
ActionController::TestCase.send(:include, ActiveModelSerializers::Test::Serializer)
end
end
end
2 changes: 1 addition & 1 deletion lib/active_model_serializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def self.config
autoload :Model
autoload :Callbacks
autoload :Logging
autoload :Test

module_function

Expand Down Expand Up @@ -51,7 +52,6 @@ def silence_warnings
require 'active_model/serializer'
require 'active_model/serializable_resource'
require 'active_model/serializer/version'
require 'active_model_serializers/test/serializer'

require 'action_controller/serialization'
ActiveSupport.on_load(:action_controller) do
Expand Down
5 changes: 5 additions & 0 deletions lib/active_model_serializers/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module ActiveModelSerializers
module Test
autoload :Serializer, 'active_model_serializers/test/serializer'
end
end
2 changes: 2 additions & 0 deletions test/active_model_serializers/test/serializer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
module ActiveModelSerializers
module Test
class SerializerTest < ActionController::TestCase
include ActiveModelSerializers::Test::Serializer

class MyController < ActionController::Base
def render_using_serializer
render json: Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
Expand Down