2010-04-12 23:33:25 +00:00
|
|
|
module NavigationHelpers
|
2011-12-06 14:46:21 +00:00
|
|
|
include Locomotive::Engine.routes.url_helpers # Load engine routes
|
|
|
|
|
2010-04-12 23:33:25 +00:00
|
|
|
# Maps a name to a path. Used by the
|
|
|
|
#
|
|
|
|
# When /^I go to (.+)$/ do |page_name|
|
|
|
|
#
|
|
|
|
# step definition in web_steps.rb
|
|
|
|
#
|
|
|
|
def path_to(page_name)
|
|
|
|
case page_name
|
2010-05-09 12:44:53 +00:00
|
|
|
|
2011-06-29 01:05:07 +00:00
|
|
|
when /the home\s?page$/
|
2010-04-12 23:33:25 +00:00
|
|
|
'/'
|
2010-05-09 12:44:53 +00:00
|
|
|
when /login/
|
2011-12-06 14:46:21 +00:00
|
|
|
new_locomotive_account_session_path
|
2010-05-09 12:44:53 +00:00
|
|
|
when /logout/
|
2011-12-06 14:46:21 +00:00
|
|
|
destroy_locomotive_account_session_url
|
2011-06-27 15:27:07 +00:00
|
|
|
when /pages( list)?/
|
2012-02-17 00:16:22 +00:00
|
|
|
pages_path
|
2011-06-27 15:27:07 +00:00
|
|
|
when /new page/
|
2012-02-17 00:16:22 +00:00
|
|
|
new_page_path
|
2011-06-27 15:27:07 +00:00
|
|
|
when /"(.*)" edition page/
|
2012-03-01 10:07:22 +00:00
|
|
|
page = Locomotive::Site.first.pages.where(:slug => $1).first
|
2012-02-17 00:16:22 +00:00
|
|
|
edit_page_path(page)
|
2011-02-04 09:39:23 +00:00
|
|
|
when /theme assets/
|
2012-02-17 00:16:22 +00:00
|
|
|
theme_assets_path
|
2011-06-27 15:27:07 +00:00
|
|
|
when /site settings/
|
2012-02-17 00:16:22 +00:00
|
|
|
edit_current_site_path
|
2011-07-05 09:56:24 +00:00
|
|
|
when /account settings/
|
2012-02-17 00:16:22 +00:00
|
|
|
edit_my_account_path
|
2012-03-01 10:07:22 +00:00
|
|
|
when /the list of "(.*)"/
|
2011-12-06 14:46:21 +00:00
|
|
|
content_type = Locomotive::Site.first.content_types.where(:name => $1).first
|
2012-02-17 00:16:22 +00:00
|
|
|
content_entries_path(content_type.slug)
|
2012-03-01 10:07:22 +00:00
|
|
|
when /the "(.*)" model edition page/
|
2011-12-06 14:46:21 +00:00
|
|
|
content_type = Locomotive::Site.first.content_types.where(:name => $1).first
|
2012-03-01 10:07:22 +00:00
|
|
|
edit_content_type_path(content_type)
|
2010-05-09 12:44:53 +00:00
|
|
|
|
2010-04-12 23:33:25 +00:00
|
|
|
# Add more mappings here.
|
|
|
|
# Here is an example that pulls values out of the Regexp:
|
|
|
|
#
|
|
|
|
# when /^(.*)'s profile page$/i
|
|
|
|
# user_profile_path(User.find_by_login($1))
|
|
|
|
|
|
|
|
else
|
2010-05-09 12:44:53 +00:00
|
|
|
begin
|
2011-06-29 01:05:07 +00:00
|
|
|
page_name =~ /^the (.*) page$/
|
2010-05-09 12:44:53 +00:00
|
|
|
path_components = $1.split(/\s+/)
|
|
|
|
self.send(path_components.push('path').join('_').to_sym)
|
2011-06-29 01:05:07 +00:00
|
|
|
rescue NoMethodError, ArgumentError
|
2010-05-09 12:44:53 +00:00
|
|
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
|
|
"Now, go and add a mapping in #{__FILE__}"
|
|
|
|
end
|
2010-04-12 23:33:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
World(NavigationHelpers)
|