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