diff --git a/app/views/layouts/mobile.m.erb b/app/views/layouts/mobile.m.erb
index 42c1c81e..79836850 100644
--- a/app/views/layouts/mobile.m.erb
+++ b/app/views/layouts/mobile.m.erb
@@ -12,7 +12,7 @@
<%= @page_title %>
<% if !(@new_mobile || @edit_mobile)
- if !current_user.prefs.nil? -%>
+ if current_user && !current_user.prefs.nil? -%>
<%= @down_count %> <%=
l(Date.today, :format => current_user.prefs.title_date_format) -%>
@@ -25,7 +25,7 @@
end -%><%= render_flash -%>
<%= yield -%>
-
<% if !current_user.prefs.nil? -%>
+
<% if current_user && !current_user.prefs.nil? -%>
<%= (link_to(t('layouts.mobile_navigation.logout'), logout_path(:format => 'm')) +" | ") -%>
<%= (link_to(t('layouts.mobile_navigation.new_action'), new_todo_path(new_todo_params), {:accesskey => "0"})+" | ") unless @new_mobile -%>
diff --git a/features/mobile_add_action.feature b/features/mobile_add_action.feature
new file mode 100644
index 00000000..bb1429bd
--- /dev/null
+++ b/features/mobile_add_action.feature
@@ -0,0 +1,27 @@
+Feature: Add new next action from mobile page
+ In order to be able to add next actions from the mobile interface
+ As a Tracks user
+ I want to to be able to add a new next actions from the mobile interface and prepopulate the context and / or project of the prior page
+
+ Background:
+ Given the following user record
+ | login | password | is_admin |
+ | testuser | secret | false |
+ And I am working on the mobile interface
+ And I have logged in as "testuser" with password "secret"
+ And I have a context called "a context"
+ And I have a project "test project" with a default context of "test context"
+
+ Scenario Outline: The new action form is prefilled with context and project
+ Given I am on the
+ When I follow "0-New action"
+ Then the selected project should be ""
+ And the selected context should be ""
+
+ Scenarios: # empty means no selected, i.e. first in list is shown
+ | page | project | context |
+ | home page | | |
+ | tickler page | | |
+ | "test project" project | test project | |
+ | context page for "test context" | | test context |
+ | tag page for "starred" | | |
\ No newline at end of file
diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb
index 65b1439e..07d58d93 100644
--- a/features/step_definitions/generic_steps.rb
+++ b/features/step_definitions/generic_steps.rb
@@ -17,3 +17,7 @@ Then /the badge should show (.*)/ do |number|
badge.should == number.to_i
end
+
+Given /^I am working on the mobile interface$/ do
+ @mobile_interface = true
+end
diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb
index 83af76a4..fa420799 100644
--- a/features/step_definitions/login_steps.rb
+++ b/features/step_definitions/login_steps.rb
@@ -1,5 +1,5 @@
Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password|
- visit login_path
+ When "I go to the login page"
fill_in "Login", :with => username
fill_in "Password", :with => password
uncheck "Stay logged in:"
@@ -7,7 +7,8 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
if response.respond_to? :selenium
selenium.wait_for_page_to_load(5000)
end
- response.should contain(/Logout \(#{username}\)/)
+ logout_string = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
+ response.should contain(/#{logout_string}/)
@current_user = User.find_by_login(username)
end
diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb
index b01ce894..a74ca756 100644
--- a/features/step_definitions/project_steps.rb
+++ b/features/step_definitions/project_steps.rb
@@ -24,6 +24,13 @@ Given /^I have a project called "([^"]*)"$/ do |project_name|
Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
end
+Given /^I have a project "([^"]*)" with a default context of "([^"]*)"$/ do |project_name, context_name|
+ Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
+ context = @current_user.contexts.create!(:name => context_name)
+ @project.default_context = context
+ @project.save!
+end
+
Given /^I have the following projects:$/ do |table|
table.hashes.each do |project|
Given 'I have a project called "'+project[:project_name]+'"'
@@ -189,4 +196,4 @@ end
Then /^I should see the project name is "([^"]*)"$/ do |project_name|
Then "the project title should be \"#{project_name}\""
-end
\ No newline at end of file
+end
diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb
index a794b2f8..8a15f620 100644
--- a/features/step_definitions/todo_steps.rb
+++ b/features/step_definitions/todo_steps.rb
@@ -271,3 +271,13 @@ Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_descripti
selenium.is_element_present(xpath).should be_false
end
+
+Then /^the selected project should be "([^"]*)"$/ do |content|
+ # Works for mobile. TODO: make it work for both mobile and non-mobile
+ field_labeled("Project").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
+end
+
+Then /^the selected context should be "([^"]*)"$/ do |content|
+ # Works for mobile. TODO: make it work for both mobile and non-mobile
+ field_labeled("Context").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
+end
diff --git a/features/support/paths.rb b/features/support/paths.rb
index 9df097ce..3ec5f54e 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -6,53 +6,54 @@ module NavigationHelpers
# step definition in web_steps.rb
#
def path_to(page_name)
+ options = @mobile_interface ? {:format => :m} : {}
case page_name
when /the home\s?page/
- root_path
+ root_path(options)
when /the statistics page/
- stats_path
+ stats_path(options)
when /the signup page/
- signup_path
+ signup_path(options)
when /the login page/
- login_path
+ login_path(options)
when /the notes page/
- notes_path
+ notes_path(options)
when /the contexts page/
- contexts_path
+ contexts_path(options)
when /the projects page/
- projects_path
+ projects_path(options)
when /the manage users page/
- users_path
+ users_path(options)
when /the repeating todos page/
- recurring_todos_path
+ recurring_todos_path(options)
when /the integrations page/
- integrations_path
+ integrations_path(options)
when /the tickler page/
- tickler_path
+ tickler_path(options)
when /the export page/
- data_path
+ data_path(options)
when /the preference page/
- preferences_path
+ preferences_path(options)
when /the rest api docs page/
- rest_api_docs_path
+ rest_api_docs_path(options)
when /the search page/
- search_path
+ search_path(options)
when /the starred page/
- tag_path("starred")
+ tag_path("starred", options)
when /the feeds page/
- feeds_path
+ feeds_path(options)
when /the context page for "([^\"]*)" for user "([^\"]*)"/i
- context_path(User.find_by_login($2).contexts.find_by_name($1))
+ context_path(User.find_by_login($2).contexts.find_by_name($1), options)
when /the context page for "([^\"]*)"/i
- context_path(@current_user.contexts.find_by_name($1))
+ context_path(@current_user.contexts.find_by_name($1), options)
when /the "([^\"]*)" project for user "([^\"]*)"/i
- project_path(User.find_by_login($2).projects.find_by_name($1))
+ project_path(User.find_by_login($2).projects.find_by_name($1), options)
when /the "([^\"]*)" project/i
@project = @current_user.projects.find_by_name($1)
- project_path(@project)
+ project_path(@project, options)
when /the tag page for "([^"]*)"/i
- tag_path($1)
+ tag_path($1, options)
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 341e8fa9..c888e7f6 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -315,7 +315,7 @@ var TodoItems = {
getContextsForAutocomplete: function (term, element_to_block) {
var allContexts = null;
var params = default_ajax_options_for_scripts('GET', relative_to_root('contexts.autocomplete'), element_to_block);
- params.data = "term="+term;
+ params.data += "&term="+term;
params.dataType = "json";
params.async = false;
params.success = function(result){