Bike!Bike! Website!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

10 years ago
module NavigationHelpers
7 years ago
def path_to(path)
path = path.to_sym
args = []
7 years ago
case path
when /^landing$/i
path = :home
when /^(my )?workshop$/i
path = :view_workshop
args << TestState.last_conference.slug
args << TestState.last_workshop.id
when /^delete_workshop$/i
args << TestState.last_conference.slug
args << TestState.last_workshop.id
7 years ago
when /^registration$/i
path = :register
args << TestState.last_conference.slug
when /^(conference|register|workshops)$/i
args << TestState.last_conference.slug
when /^confirm(ation)?$/
path = :confirm
args << TestState.last_token
when /^google maps$/
path = /^https?:\/\/www\.google\.com\/maps\/place\/.*/
7 years ago
end
10 years ago
7 years ago
if path.is_a?(Symbol)
path = Rails.application.routes.url_helpers.send("#{path}_path".to_sym, *args)
end
7 years ago
raise "Can't find mapping from \"#{path}\" to a path." unless path.present?
7 years ago
return path
end
10 years ago
end
World(NavigationHelpers)