Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal deprecation #243

Merged
merged 1 commit into from
Oct 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/active_fedora/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion spec/integration/associations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -860,4 +886,4 @@ class ComplexCollection < SimpleCollection
end
end
end
end
end