Skip to content

Commit

Permalink
Fixing bug in looking up parent_id, and using existing method to look…
Browse files Browse the repository at this point in the history
…up parent instead of duplicating
  • Loading branch information
escowles committed Jan 29, 2016
1 parent 7538320 commit f74b514
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def lookup_parent_from_child
end

def parent_id
@parent_id ||= new_or_create? ? params[:parent_id] : curation_concern.generic_works.in_objects.first.id
@parent_id ||= new_or_create? ? params[:parent_id] : lookup_parent_from_child.id
end

protected
Expand Down
23 changes: 23 additions & 0 deletions spec/controllers/curation_concerns/file_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,27 @@
end
end
end

context 'finds parents' do
let(:file_set) do
file_set = FileSet.create! do |gf|
gf.apply_depositor_metadata(user)
end
parent.ordered_members << file_set
parent.save
file_set
end

before do
allow_any_instance_of(described_class).to receive(:curation_concern).and_return(file_set)
end

it 'finds a parent' do
expect(controller.parent).to eq(parent)
end

it 'finds a parent id' do
expect(controller.parent_id).to eq(parent.id)
end
end
end

0 comments on commit f74b514

Please sign in to comment.