Skip to content

Commit

Permalink
Use SerializableResource on ActionController integration
Browse files Browse the repository at this point in the history
On the ActionController was using a adapter, and since the instrumentation is
made on the SerializableResource we need to use the SerializableResource over
the adapter directly. Otherwise the logger is not called on a Rails app.

Use SerializableResource on the ActionController, since this is the main
interface to create and call a serializer.

Using always the SerializableResource we can keep the adapter code more easy to
mantain since no Adapter will need to call the instrumentation, only the
SerializableResource care about this.
  • Loading branch information
maurogeorge committed Oct 24, 2015
1 parent b0ef4d7 commit 981c229
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/action_controller/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def get_serializer(resource, options = {})
serializable_resource.serialization_scope_name = _serialization_scope
begin
serializable_resource.adapter
serializable_resource
rescue ActiveModel::Serializer::CollectionSerializer::NoSerializerError
resource
end
Expand Down
10 changes: 10 additions & 0 deletions test/action_controller/serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ def use_adapter?
controller.get_serializer(Profile.new)
end)
end

def test_render_event_is_emmited
ActiveSupport::Notifications.subscribe('render.active_model_serializers') do |name|
@name = name
end

get :render_using_implicit_serializer

assert_equal 'render.active_model_serializers', @name
end
end
end
end

0 comments on commit 981c229

Please sign in to comment.