From 74cac73a83ffbbdd7b65a25fe76ad54e120da931 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Mon, 7 Oct 2013 09:43:06 -0500 Subject: [PATCH] Remove internal deprecation --- lib/active_fedora/associations.rb | 3 ++- spec/integration/associations_spec.rb | 28 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/active_fedora/associations.rb b/lib/active_fedora/associations.rb index 60f52b42f..e234accab 100644 --- a/lib/active_fedora/associations.rb +++ b/lib/active_fedora/associations.rb @@ -227,7 +227,8 @@ def association_accessor_methods(reflection, association_proxy_class) end redefine_method("#{reflection.name}_id=") do |new_value| - obj = new_value.blank? ? nil : reflection.klass.find(new_value) + options = reflection.klass == ActiveFedora::Base ? {cast: true} : {} + obj = new_value.blank? ? nil : reflection.klass.find(new_value, options) send("#{reflection.name}=", obj) end redefine_method("#{reflection.name}_id") do diff --git a/spec/integration/associations_spec.rb b/spec/integration/associations_spec.rb index 211126fc9..728a5437a 100644 --- a/spec/integration/associations_spec.rb +++ b/spec/integration/associations_spec.rb @@ -473,6 +473,32 @@ class Topic < ActiveFedora::Base end end + describe "belongs_to when class_name is ActiveFedora::Base" do + before :all do + class Textbook < ActiveFedora::Base + belongs_to :container, :property=>:is_part_of, :class_name=>'ActiveFedora::Base' + end + class Shelf < ActiveFedora::Base; end + end + + after :all do + Object.send(:remove_const, :Textbook) + Object.send(:remove_const, :Shelf) + end + + after do + shelf.destroy + end + + let(:shelf) { Shelf.create} + subject { Textbook.new } + + it "Should not raise a deprecation message" do + Deprecation.should_not_receive(:warn) # a deprecation in 6.6.0 that's going away in 7.0.0 + subject.container_id = shelf.id + end + end + describe "single direction habtm" do before :all do class Course < ActiveFedora::Base @@ -860,4 +886,4 @@ class ComplexCollection < SimpleCollection end end end -end \ No newline at end of file +end