Skip to content

using ordered_members puts parent-child relationship in both directions #361

@elrayle

Description

@elrayle

Descriptive summary

Adding a child work to a parent work using ordered members causes the child to respond with parent works using both in_work_ids and member_of_work_ids, resulting in the parent work being listed twice.

Rationale

In the list of parent_works, the parents should not repeat.

Expected behavior

        parent_work1.ordered_members = [child_work]
        parent_work2.ordered_members = [child_work]
        child_work.save
        parent_work1.save
        parent_work2.save

        expect(child_work.parent_work_ids).to match_array [parent_work1.id, parent_work2.id]

Actual behavior

       expected collection contained:  ["wk1", "wk2"]
       actual collection contained:    ["wk1", "wk1", "wk2", "wk2"]

See PR #360 which includes a test that fails because of this bug.

Steps to reproduce the behavior

Use test provided in PR #360 to debug.

  1. Setup the relationships
        parent_work1.ordered_members = [child_work]
        parent_work2.ordered_members = [child_work]
        child_work.save
        parent_work1.save
        parent_work2.save
  1. Get list of parents
        child_work.parent_works

Expect parent_works to return parent_work1 and parent_work2, but you get the two parent works in the list twice.

Related Work

PR samvera/hyrax#3697 - Orders members when converting to AF objects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions