2009-04-13 22:26:20 +02:00
|
|
|
module NavigationHelpers
|
2010-07-22 13:54:26 +02:00
|
|
|
# Maps a name to a path. Used by the
|
|
|
|
|
#
|
|
|
|
|
# When /^I go to (.+)$/ do |page_name|
|
|
|
|
|
#
|
|
|
|
|
# step definition in web_steps.rb
|
|
|
|
|
#
|
2009-04-13 22:26:20 +02:00
|
|
|
def path_to(page_name)
|
2011-02-26 11:38:39 +01:00
|
|
|
options = @mobile_interface ? {:format => :m} : {}
|
2011-07-09 14:53:37 +02:00
|
|
|
options = {:locale => @locale}.merge(options) if @locale
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = nil
|
2012-01-27 11:23:36 +01:00
|
|
|
|
2009-04-13 22:26:20 +02:00
|
|
|
case page_name
|
2010-07-22 13:54:26 +02:00
|
|
|
|
|
|
|
|
when /the home\s?page/
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "todos"
|
2011-02-26 11:38:39 +01:00
|
|
|
root_path(options)
|
2011-06-26 23:05:33 +02:00
|
|
|
|
2011-06-17 20:17:01 +02:00
|
|
|
when /the done page/
|
2011-06-26 23:05:33 +02:00
|
|
|
@source_view = "done"
|
2011-06-17 20:17:01 +02:00
|
|
|
done_overview_path(options)
|
|
|
|
|
when /the done actions page for context "([^"]*)"/i
|
2011-06-26 23:05:33 +02:00
|
|
|
@source_view = "done"
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => $1).first
|
2011-06-26 23:05:33 +02:00
|
|
|
done_todos_context_path(context, options)
|
2011-06-17 20:17:01 +02:00
|
|
|
when /the done actions page for project "([^"]*)"/i
|
2011-06-26 23:05:33 +02:00
|
|
|
@source_view = "done"
|
2013-02-27 20:02:01 +01:00
|
|
|
project = @current_user.projects.where(:name => $1).first
|
2011-06-26 23:05:33 +02:00
|
|
|
done_todos_project_path(project, options)
|
|
|
|
|
when /the done actions page for tag "([^"]*)"/i
|
|
|
|
|
@source_view = "done"
|
|
|
|
|
done_tag_path($1, options)
|
2011-06-17 20:17:01 +02:00
|
|
|
when /the done actions page/
|
2011-06-26 23:05:33 +02:00
|
|
|
@source_view = "done"
|
2011-06-17 20:17:01 +02:00
|
|
|
done_todos_path(options)
|
2011-06-26 23:05:33 +02:00
|
|
|
when /the all done actions page for context "([^"]*)"/i
|
|
|
|
|
@source_view = "done"
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => $1).first
|
2011-06-26 23:05:33 +02:00
|
|
|
all_done_todos_context_path(context, options)
|
|
|
|
|
when /the all done actions page for project "([^"]*)"/i
|
|
|
|
|
@source_view = "done"
|
2013-02-27 20:02:01 +01:00
|
|
|
project = @current_user.projects.where(:name => $1).first
|
2011-06-26 23:05:33 +02:00
|
|
|
all_done_todos_project_path(project, options)
|
|
|
|
|
when /the all done actions page for tag "([^"]*)"/i
|
|
|
|
|
@source_view = "done"
|
|
|
|
|
all_done_tag_path($1, options)
|
2011-06-17 20:17:01 +02:00
|
|
|
when /the all done actions page/
|
2011-06-26 23:05:33 +02:00
|
|
|
@source_view = "done"
|
2011-06-17 20:17:01 +02:00
|
|
|
all_done_todos_path(options)
|
2011-06-26 23:05:33 +02:00
|
|
|
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the statistics page/
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "stats"
|
2011-02-26 11:38:39 +01:00
|
|
|
stats_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the signup page/
|
2011-02-26 11:38:39 +01:00
|
|
|
signup_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the login page/
|
2011-02-26 11:38:39 +01:00
|
|
|
login_path(options)
|
2011-08-18 12:48:59 +02:00
|
|
|
when /the logout page/
|
|
|
|
|
logout_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the notes page/
|
2011-02-26 11:38:39 +01:00
|
|
|
notes_path(options)
|
2011-04-21 16:54:35 +02:00
|
|
|
when /the calendar page/
|
|
|
|
|
calendar_path(options)
|
2011-09-16 23:34:09 -04:00
|
|
|
when /the review page/
|
|
|
|
|
@source_view = "review"
|
|
|
|
|
review_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the contexts page/
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "contexts"
|
2011-02-26 11:38:39 +01:00
|
|
|
contexts_path(options)
|
2010-10-06 20:37:21 +02:00
|
|
|
when /the projects page/
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "projects"
|
2011-02-26 11:38:39 +01:00
|
|
|
projects_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the manage users page/
|
2011-02-26 11:38:39 +01:00
|
|
|
users_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the repeating todos page/
|
2011-02-26 11:38:39 +01:00
|
|
|
recurring_todos_path(options)
|
2010-07-27 23:32:22 +02:00
|
|
|
when /the integrations page/
|
2011-02-26 11:38:39 +01:00
|
|
|
integrations_path(options)
|
2010-07-14 15:13:20 +02:00
|
|
|
when /the tickler page/
|
2011-08-18 17:15:00 +02:00
|
|
|
@source_view = "deferred"
|
2011-02-26 11:38:39 +01:00
|
|
|
tickler_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the export page/
|
2011-02-26 11:38:39 +01:00
|
|
|
data_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the preference page/
|
2011-02-26 11:38:39 +01:00
|
|
|
preferences_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the rest api docs page/
|
2011-02-26 11:38:39 +01:00
|
|
|
rest_api_docs_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the search page/
|
2011-02-26 11:38:39 +01:00
|
|
|
search_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the starred page/
|
2011-02-26 11:38:39 +01:00
|
|
|
tag_path("starred", options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the feeds page/
|
2011-02-26 11:38:39 +01:00
|
|
|
feeds_path(options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the context page for "([^\"]*)" for user "([^\"]*)"/i
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "context"
|
2013-02-27 20:02:01 +01:00
|
|
|
@context = User.where(:login => $2).first.contexts.where(:name => $1).first
|
2012-02-15 21:42:06 +01:00
|
|
|
context_path(@context, options)
|
2011-01-08 19:50:19 +01:00
|
|
|
when /the context page for "([^\"]*)"/i
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "context"
|
2013-02-27 20:02:01 +01:00
|
|
|
@context = @current_user.contexts.where(:name => $1).first
|
2012-02-15 21:42:06 +01:00
|
|
|
context_path(@context, options)
|
2012-03-23 20:39:04 +01:00
|
|
|
when /the "([^\"]*)" context/i
|
|
|
|
|
@source_view = "context"
|
2013-02-27 20:02:01 +01:00
|
|
|
@context = @current_user.contexts.where(:name => $1).first
|
2012-03-23 20:39:04 +01:00
|
|
|
context_path(@context, options)
|
2010-07-30 21:06:12 +02:00
|
|
|
when /the "([^\"]*)" project for user "([^\"]*)"/i
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "project"
|
2013-02-27 20:02:01 +01:00
|
|
|
@project = User.where(:login => $2).first.projects.where(:name => $1).first
|
2012-02-15 21:42:06 +01:00
|
|
|
project_path(@project, options)
|
2010-10-06 20:37:21 +02:00
|
|
|
when /the "([^\"]*)" project/i
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "project"
|
2013-02-27 20:02:01 +01:00
|
|
|
@project = @current_user.projects.where(:name => $1).first
|
2011-02-26 11:38:39 +01:00
|
|
|
project_path(@project, options)
|
2011-01-08 19:50:19 +01:00
|
|
|
when /the tag page for "([^"]*)"/i
|
2011-04-14 16:26:16 +02:00
|
|
|
@source_view = "tag"
|
2011-02-26 11:38:39 +01:00
|
|
|
tag_path($1, options)
|
2011-09-05 22:06:37 +02:00
|
|
|
when /the change password page/
|
|
|
|
|
change_password_user_path @current_user
|
2012-01-27 11:23:36 +01:00
|
|
|
|
|
|
|
|
# Add more mappings here.
|
|
|
|
|
# Here is an example that pulls values out of the Regexp:
|
|
|
|
|
#
|
|
|
|
|
# when /^(.*)'s profile page$/i
|
2013-02-27 20:02:01 +01:00
|
|
|
# user_profile_path(User.where(:login => $1))first.
|
2010-07-22 13:54:26 +02:00
|
|
|
|
2009-04-13 22:26:20 +02:00
|
|
|
else
|
2010-07-22 13:54:26 +02:00
|
|
|
begin
|
|
|
|
|
page_name =~ /the (.*) page/
|
|
|
|
|
path_components = $1.split(/\s+/)
|
|
|
|
|
self.send(path_components.push('path').join('_').to_sym)
|
|
|
|
|
rescue Object => e
|
|
|
|
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
|
|
|
"Now, go and add a mapping in #{__FILE__}"
|
|
|
|
|
end
|
2009-04-13 22:26:20 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2009-05-25 20:30:20 +02:00
|
|
|
World(NavigationHelpers)
|