Sha256: 6fe7f95f83f3b98db1ac6f5d70e74b53c5e6818a7549a52ba13ea99f4b8ed84d

Contents?: true

Size: 755 Bytes

Versions: 14

Compression:

Stored size: 755 Bytes

Contents

require 'test_helper'

module ActiveModel
  class ArraySerializer
    class ScopeTest < Minitest::Test
      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

14 entries across 14 versions & 2 rubygems

Version Path
active_model_serializers-0.9.13 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.12 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.11 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.9 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.8 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.7 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.6 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.5 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.4 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.3 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.2 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.1 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers-0.9.0 test/unit/active_model/array_serializer/scope_test.rb
active_model_serializers_rails_2.3-0.9.0.alpha1 test/unit/active_model/array_serializer/scope_test.rb