39 lines
1.0 KiB
Ruby
Raw Normal View History

2014-09-14 16:00:41 -07:00
module NavigationHelpers
2017-04-09 11:37:16 -07:00
def path_to(path)
path = path.to_sym
args = []
2015-08-18 22:18:29 -07:00
2017-04-09 11:37:16 -07:00
case path
when /^landing$/i
path = :home
when /^(my )?workshop$/i
path = :view_workshop
args << TestState.last_conference.slug
args << TestState.last_workshop.id
2017-04-11 21:42:29 -07:00
when /^delete_workshop$/i
args << TestState.last_conference.slug
args << TestState.last_workshop.id
2017-04-09 11:37:16 -07:00
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$/
2017-04-12 00:43:36 +00:00
path = /^https?:\/\/www\.google\.com\/maps\/place\/.*/
2017-04-09 11:37:16 -07:00
end
2014-09-14 16:00:41 -07:00
2017-04-09 11:37:16 -07:00
if path.is_a?(Symbol)
path = Rails.application.routes.url_helpers.send("#{path}_path".to_sym, *args)
end
2015-08-18 22:18:29 -07:00
2017-04-09 11:37:16 -07:00
raise "Can't find mapping from \"#{path}\" to a path." unless path.present?
2015-08-18 22:18:29 -07:00
2017-04-09 11:37:16 -07:00
return path
end
2014-09-14 16:00:41 -07:00
end
World(NavigationHelpers)