39 lines
1.1 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
2017-09-04 14:10:55 -07:00
when /^(conference(?:[_\s]survey)?|register|workshops)$/i
2017-04-09 11:37:16 -07:00
args << TestState.last_conference.slug
when /^confirm(ation)?$/
path = :confirm
args << TestState.last_token
when /^google maps$/
2017-06-11 15:27:18 -07:00
path = /^https?:\/\/www\.google\.com\/maps\/.*/
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)
2017-09-04 14:10:55 -07:00
path = Rails.application.routes.url_helpers.send("#{path.to_s.gsub(/\s+/, '_')}_path".to_sym, *args)
2017-04-09 11:37:16 -07:00
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)