Make polymorphic_path work with booth assignments
This commit is contained in:
@@ -16,7 +16,7 @@ module ActionDispatch::Routing::UrlFor
|
||||
end
|
||||
|
||||
def admin_polymorphic_path(resource, options = {})
|
||||
if %w[Budget::Group Budget::Heading Poll::Booth Poll::Officer
|
||||
if %w[Budget::Group Budget::Heading Poll::Booth Poll::BoothAssignment Poll::Officer
|
||||
Poll::Question Poll::Question::Answer::Video].include?(resource.class.name)
|
||||
resolve = resolve_for(resource)
|
||||
resolve_options = resolve.pop
|
||||
|
||||
@@ -278,6 +278,10 @@ resolve "Poll::Booth" do |booth, options|
|
||||
[:booth, options.merge(id: booth)]
|
||||
end
|
||||
|
||||
resolve "Poll::BoothAssignment" do |assignment, options|
|
||||
[assignment.poll, :booth_assignment, options.merge(id: assignment)]
|
||||
end
|
||||
|
||||
resolve "Poll::Officer" do |officer, options|
|
||||
[:officer, options.merge(id: officer)]
|
||||
end
|
||||
|
||||
@@ -148,6 +148,15 @@ describe "Polymorphic routes" do
|
||||
)
|
||||
end
|
||||
|
||||
it "routes booth assignments" do
|
||||
poll = create(:poll)
|
||||
assignment = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
expect(admin_polymorphic_path(assignment)).to eq(
|
||||
admin_poll_booth_assignment_path(poll, assignment)
|
||||
)
|
||||
end
|
||||
|
||||
it "supports routes for actions like edit" do
|
||||
proposal = create(:proposal)
|
||||
milestone = create(:milestone, milestoneable: proposal)
|
||||
|
||||
Reference in New Issue
Block a user