Sha256: f99dc2318f44b7d0f380a24eb5e9332234eeb6b7711c68bdcfaa540c3b9eef6e
Contents?: true
Size: 1.66 KB
Versions: 5
Compression:
Stored size: 1.66 KB
Contents
module Adva::Core::Paths def path_to(page) case page when /^\// page when /^the home\s?page$/ '/' when /^the site installation page$/ new_installation_path when /^the site installation confirmation page$/ installation_path(Site.last) when /^the "([^"]*)" section page$/ section = Section.where(:name => $1).first || raise("could not find section named #{$1}") polymorphic_path(section) when /^the admin sites page$/ polymorphic_path([:admin, :sites]) when /^the admin dashboard page$/ site = Site.first polymorphic_path([:admin, site]) when /^the admin dashboard page for the site on "([^"]*)"$/ site = Site.find_by_host($1) || raise("could not find site with host #{$1}") polymorphic_path([:admin, site]) when /^the admin sections page$/ site = Site.first polymorphic_path([:admin, site, :sections]) when /^the admin "([^"]*)" section page$/ site = Site.first section = Section.where(:name => $1).first || raise("could not find section named #{$1}") polymorphic_path([:admin, site, section]) when /^the admin "([^"]*)" section settings page$/ site = Site.first section = Section.where(:name => $1).first || raise("could not find section named #{$1}") polymorphic_path([:edit, :admin, site, section]) else named_route_helper = page.gsub(/(\Athe )|( page\Z)/, '').gsub(/ +/, '_').downcase + '_path' raise "Can't find mapping from \"#{page}\" to a path.\nNow, go and add a mapping in #{__FILE__}" unless respond_to?(named_route_helper) send named_route_helper end end end World(Adva::Core::Paths)
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
adva-core-0.0.6 | lib/testing/paths.rb |
adva-core-0.0.5 | lib/testing/paths.rb |
adva-core-0.0.4 | lib/testing/paths.rb |
adva-core-0.0.2 | lib/testing/paths.rb |
adva-core-0.0.1 | lib/testing/paths.rb |