fix #1052 based on the work of Tim Madden. Thanks Tim!

This commit is contained in:
Reinier Balt 2011-02-26 11:38:39 +01:00
parent e9d92438d6
commit b53fbc64dc
8 changed files with 78 additions and 28 deletions

View file

@ -12,7 +12,7 @@
<title><%= @page_title %></title> <title><%= @page_title %></title>
</head><body> </head><body>
<% if !(@new_mobile || @edit_mobile) <% if !(@new_mobile || @edit_mobile)
if !current_user.prefs.nil? -%> if current_user && !current_user.prefs.nil? -%>
<h1><span class="count"><%= @down_count %></span> <%= <h1><span class="count"><%= @down_count %></span> <%=
l(Date.today, :format => current_user.prefs.title_date_format) -%></h1> l(Date.today, :format => current_user.prefs.title_date_format) -%></h1>
<div class="nav"> <div class="nav">
@ -25,7 +25,7 @@
end -%><%= render_flash -%> end -%><%= render_flash -%>
</div> </div>
<%= yield -%> <%= yield -%>
<hr/><% if !current_user.prefs.nil? -%> <hr/><% if current_user && !current_user.prefs.nil? -%>
<div class="nav"> <div class="nav">
<%= (link_to(t('layouts.mobile_navigation.logout'), logout_path(:format => 'm')) +" | ") -%> <%= (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 -%> <%= (link_to(t('layouts.mobile_navigation.new_action'), new_todo_path(new_todo_params), {:accesskey => "0"})+" | ") unless @new_mobile -%>

View file

@ -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 <page>
When I follow "0-New action"
Then the selected project should be "<project>"
And the selected context should be "<context>"
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" | | |

View file

@ -17,3 +17,7 @@ Then /the badge should show (.*)/ do |number|
badge.should == number.to_i badge.should == number.to_i
end end
Given /^I am working on the mobile interface$/ do
@mobile_interface = true
end

View file

@ -1,5 +1,5 @@
Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password| 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 "Login", :with => username
fill_in "Password", :with => password fill_in "Password", :with => password
uncheck "Stay logged in:" uncheck "Stay logged in:"
@ -7,7 +7,8 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
if response.respond_to? :selenium if response.respond_to? :selenium
selenium.wait_for_page_to_load(5000) selenium.wait_for_page_to_load(5000)
end 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) @current_user = User.find_by_login(username)
end end

View file

@ -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}\"" Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
end 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| Given /^I have the following projects:$/ do |table|
table.hashes.each do |project| table.hashes.each do |project|
Given 'I have a project called "'+project[:project_name]+'"' Given 'I have a project called "'+project[:project_name]+'"'

View file

@ -271,3 +271,13 @@ Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_descripti
selenium.is_element_present(xpath).should be_false selenium.is_element_present(xpath).should be_false
end 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

View file

@ -6,53 +6,54 @@ module NavigationHelpers
# step definition in web_steps.rb # step definition in web_steps.rb
# #
def path_to(page_name) def path_to(page_name)
options = @mobile_interface ? {:format => :m} : {}
case page_name case page_name
when /the home\s?page/ when /the home\s?page/
root_path root_path(options)
when /the statistics page/ when /the statistics page/
stats_path stats_path(options)
when /the signup page/ when /the signup page/
signup_path signup_path(options)
when /the login page/ when /the login page/
login_path login_path(options)
when /the notes page/ when /the notes page/
notes_path notes_path(options)
when /the contexts page/ when /the contexts page/
contexts_path contexts_path(options)
when /the projects page/ when /the projects page/
projects_path projects_path(options)
when /the manage users page/ when /the manage users page/
users_path users_path(options)
when /the repeating todos page/ when /the repeating todos page/
recurring_todos_path recurring_todos_path(options)
when /the integrations page/ when /the integrations page/
integrations_path integrations_path(options)
when /the tickler page/ when /the tickler page/
tickler_path tickler_path(options)
when /the export page/ when /the export page/
data_path data_path(options)
when /the preference page/ when /the preference page/
preferences_path preferences_path(options)
when /the rest api docs page/ when /the rest api docs page/
rest_api_docs_path rest_api_docs_path(options)
when /the search page/ when /the search page/
search_path search_path(options)
when /the starred page/ when /the starred page/
tag_path("starred") tag_path("starred", options)
when /the feeds page/ when /the feeds page/
feeds_path feeds_path(options)
when /the context page for "([^\"]*)" for user "([^\"]*)"/i 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 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 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 when /the "([^\"]*)" project/i
@project = @current_user.projects.find_by_name($1) @project = @current_user.projects.find_by_name($1)
project_path(@project) project_path(@project, options)
when /the tag page for "([^"]*)"/i when /the tag page for "([^"]*)"/i
tag_path($1) tag_path($1, options)
# Add more mappings here. # Add more mappings here.
# Here is an example that pulls values out of the Regexp: # Here is an example that pulls values out of the Regexp:

View file

@ -315,7 +315,7 @@ var TodoItems = {
getContextsForAutocomplete: function (term, element_to_block) { getContextsForAutocomplete: function (term, element_to_block) {
var allContexts = null; var allContexts = null;
var params = default_ajax_options_for_scripts('GET', relative_to_root('contexts.autocomplete'), element_to_block); 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.dataType = "json";
params.async = false; params.async = false;
params.success = function(result){ params.success = function(result){