Skip to content

Commit

Permalink
Use ActionView url_helpers in MembershipHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Mar 11, 2022
1 parent 2fef3db commit c30b4d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/helpers/hyrax/hyrax_helper_behavior.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/helpers/hyrax/membership_helper.rb
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/features/edit_work_spec.rb
Expand Up @@ -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

0 comments on commit c30b4d3

Please sign in to comment.