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

Fix belongs_to cmodel inheritance. #391

Merged
merged 1 commit into from
Apr 11, 2014

Conversation

scande3
Copy link

@scande3 scande3 commented Apr 10, 2014

While has_many was still working as intended, some changes to
belongs_to broke a cmodel inheritance use case. This use case was
not adequately tested corrected and I've updated the appropriate
unit test to check for the below.

Given the following setup:

class SimpleCollection < ActiveFedora::Base
   has_many :objects, property: :is_part_of, class_name: 'Object'
 end

 class ComplexCollection < SimpleCollection
 end

 class Item < ActiveFedora::Base
   belongs_to :collection, :property=>:is_part_of, \
   :class_name=>''SimpleCollection”
 end

Doing the following should work:

object = Item.new
object.collection = ComplexCollection.create
object.save!

object.collection #returns the complex collection

In our exact use case, we have “SystemCollection” and
“OAICollection” that inherit from a base “Collection”
class. Before this fix, mapping to “Collection” would
return neither despite that being in their cmodel
structure since the code was updated to only look at an
exact class match.

As no one else is using inheritance that I am aware of,
this change should not impact any other hydra heads.

While has_many was still working as intended, some changes to
belongs_to broke a cmodel inheritance use case. This use case was
not adequately tested corrected and I've updated the appropriate
unit test to check for the below.

Given the following setup:

    class SimpleCollection < ActiveFedora::Base
       has_many :objects, property: :is_part_of, class_name: 'Object'
     end

     class ComplexCollection < SimpleCollection
     end

     class Item < ActiveFedora::Base
       belongs_to :collection, :property=>:is_part_of, \
       :class_name=>''SimpleCollection”
     end

Doing the following should work:

    object = Item.new
    object.collection = ComplexCollection.create
    object.save!

    object.collection #returns the complex collection

In our exact use case, we have “SystemCollection” and
“OAICollection” that inherit from a base “Collection”
class. Before this fix, mapping to “Collection” would
return neither despite that being in their cmodel
structure since the code was updated to only look at an
exact class match.

As no one else is using inheritance that I am aware of,
this change should not impact any other hydra heads.
@jcoyne
Copy link
Member

jcoyne commented Apr 11, 2014

Travis isn't finding this. Can you amend the commit message and force-push? Maybe Travis will see it then?

jcoyne added a commit that referenced this pull request Apr 11, 2014
@jcoyne jcoyne merged commit 186a1f7 into samvera:master Apr 11, 2014
@mjgiarlo
Copy link
Member

Travis has been a bit sluggish of late. Looks like the tests passed.

https://travis-ci.org/projecthydra/active_fedora/builds/22730907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants