Skip to content

Commit

Permalink
test parent_works when relationships are setup with ordered_members
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Mar 28, 2019
1 parent b6d1183 commit bbb049d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions spec/hydra/works/models/file_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,55 @@
context 'relationships' do
context '#parent_works and #parent_work_ids' do
let(:parent_work) { Hydra::Works::Work.new(id: 'parent_work') }
let(:parent_work2) { Hydra::Works::Work.new(id: 'parent_work2') }
let(:child_file_set1) { described_class.new(id: 'child_file_set1') }
let(:child_file_set2) { described_class.new(id: 'child_file_set2') }

context 'when parent work knows about child file sets' do
before do
parent_work.members = [child_file_set1, child_file_set2]
parent_work2.members = [child_file_set1]
child_file_set1.save
child_file_set2.save
parent_work.save
parent_work2.save
end

it 'gets parent work' do
expect(child_file_set1.parent_works).to match_array [parent_work]
expect(child_file_set1.parent_work_ids).to match_array [parent_work.id]
expect(child_file_set1.parent_works).to match_array [parent_work, parent_work2]
expect(child_file_set1.parent_work_ids).to match_array [parent_work.id, parent_work2.id]
end
end

context 'when child works know about parent works' do
# before do
# # NOOP: The :member_of relationship is not defined for works. It only uses the :members relationship.
# child_file_set1.member_of = [parent_work]
# child_file_set1.member_of = [parent_work2]
# child_file_set2.member_of = [parent_work]
# child_file_set1.save
# child_file_set2.save
# end

it 'gets parent work' do
skip 'Pending implementation of the :member_of relationship for works'
expect(child_file_set1.parent_works).to match_array [parent_work]
expect(child_file_set1.parent_work_ids).to match_array [parent_work.id]
expect(child_file_set1.parent_works).to match_array [parent_work, parent_work2]
expect(child_file_set1.parent_work_ids).to match_array [parent_work.id, parent_work2.id]
end
end

context 'when child works know about parent works as ordered members' do
before do
parent_work.ordered_members = [child_file_set1]
parent_work2.ordered_members = [child_file_set1]
child_file_set1.save
parent_work.save
parent_work2.save
end

it 'gets parent work' do
expect(child_file_set1.parent_works).to match_array [parent_work, parent_work2]
expect(child_file_set1.parent_work_ids).to match_array [parent_work.id, parent_work2.id]
end
end
end
Expand Down

0 comments on commit bbb049d

Please sign in to comment.