Skip to content

Commit

Permalink
Merge pull request #377 from crv/master
Browse files Browse the repository at this point in the history
Fixing the singleton class can't be dumped error while trying to her …
  • Loading branch information
hubert committed Oct 10, 2015
2 parents c546ebc + f70f0a6 commit b1f6c37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/her/model/associations/association_proxy.rb
Expand Up @@ -33,8 +33,7 @@ def method_missing(name, *args, &block)
end

# create a proxy to the fetched object's method
metaclass = (class << self; self; end)
metaclass.install_proxy_methods 'association.fetch', name
AssociationProxy.install_proxy_methods 'association.fetch', name

# resend message to fetched object
__send__(name, *args, &block)
Expand Down
13 changes: 13 additions & 0 deletions spec/model_spec.rb
Expand Up @@ -23,6 +23,19 @@
it { should have_key(:comments) }
end

describe :serialization do
it 'should be serialized without an error' do
expect { Marshal.dump(subject.comments) }.not_to raise_error
end

it 'should correctly load serialized object' do
serialized_comments = Marshal.load(Marshal.dump(subject.comments))
subject.comments.size.should eq(serialized_comments.size)
subject.comments.first.id.should eq(serialized_comments.first.id)
subject.comments.first.body.should eq(serialized_comments.first.body)
end
end

describe :[] do
it { should_not have_key(:unknown_method_for_a_user) }
specify { subject[:name].should == "Tobias Fünke" }
Expand Down

0 comments on commit b1f6c37

Please sign in to comment.