Sha256: d373cc2e19482970ca91af8cbfb291db11eaec63c56b278373b63981a2905e64
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'test_helper' module ActiveModel class Serializer class ScopeTest < ActiveRecord::TestCase def setup @serializer = ProfileSerializer.new(nil, scope: current_user) end def test_scope assert_equal('user', @serializer.scope) end private def current_user 'user' end end class NestedScopeTest < ActiveSupport::TestCase def setup @association = UserSerializer._associations[:profile] @old_association = @association.dup @user = User.new({ name: 'Name 1', email: 'mail@server.com', gender: 'M' }) @user_serializer = UserSerializer.new(@user, scope: 'user') end def teardown UserSerializer._associations[:profile] = @old_association end def test_scope_passed_through @association.serializer_class = Class.new(ActiveModel::Serializer) do def name scope end attributes :name end assert_equal({ name: 'Name 1', email: 'mail@server.com', profile: { name: 'user' } }, @user_serializer.serializable_hash) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_model_serializers_rails_2.3-0.9.0.pre2 | test/unit/active_model/serializer/scope_test.rb |