Sha256: 7cc914dc6a2a7eab910937583decf80848b024bceb34ad23a32149e68e1e6dca

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

require 'test_helper'

module ActiveModel
  class ArraySerializer
    class ScopeTest < ActiveModel::TestCase
      def test_array_serializer_pass_options_to_items_serializers
        array = [Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
                 Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' })]
        serializer = ArraySerializer.new(array, scope: current_user)

        expected = [{ name: 'Name 1', description: 'Description 1 - user' },
                    { name: 'Name 2', description: 'Description 2 - user' }]

        assert_equal expected, serializer.serializable_array
      end

      private

      def current_user
        'user'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_serializers-0.9.0.alpha1 test/unit/active_model/array_serializer/scope_test.rb