diff --git a/app/helpers/hyrax/hyrax_helper_behavior.rb b/app/helpers/hyrax/hyrax_helper_behavior.rb index b5af63404a..5b9b911bb6 100644 --- a/app/helpers/hyrax/hyrax_helper_behavior.rb +++ b/app/helpers/hyrax/hyrax_helper_behavior.rb @@ -360,5 +360,10 @@ def search_state_with_facets(params, facet = {}) def institution Institution end + + # ActionView url helpers + def url_helpers + Rails.application.routes.url_helpers + end end end diff --git a/app/helpers/hyrax/membership_helper.rb b/app/helpers/hyrax/membership_helper.rb index dc032c8fb1..0bf275d199 100644 --- a/app/helpers/hyrax/membership_helper.rb +++ b/app/helpers/hyrax/membership_helper.rb @@ -41,7 +41,7 @@ def work_members_json(resource) Hyrax.custom_queries.find_child_works(resource: resource).map do |member| { id: member.id.to_s, label: member.title.first, - path: url_for(member) } + path: url_helpers.url_for([member, { only_path: true }]) } end.to_json end end diff --git a/spec/features/edit_work_spec.rb b/spec/features/edit_work_spec.rb index e0ad41944b..9d3a422d40 100644 --- a/spec/features/edit_work_spec.rb +++ b/spec/features/edit_work_spec.rb @@ -78,4 +78,17 @@ expect(page).to have_selector('#new_group_name_skel', text: 'librarians admin donor') end end + + context 'with a parent Valkyrie resource' do + let(:monograph) { FactoryBot.valkyrie_create(:monograph, :with_member_works) } + + before do + sign_in user_admin + end + + it 'displays an edit page with a relationships tab' do + visit edit_hyrax_monograph_path(monograph) + expect(page).to have_link("Relationships") + end + end end