mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-10 09:24:22 +01:00
fix #1121 and add tests for this
This commit is contained in:
parent
3711acb6ab
commit
b02bb3fdde
7 changed files with 70 additions and 13 deletions
|
|
@ -904,7 +904,7 @@ class TodosController < ApplicationController
|
||||||
@target_context_count = current_user.projects.find(project_id).todos.active.count
|
@target_context_count = current_user.projects.find(project_id).todos.active.count
|
||||||
}
|
}
|
||||||
from.calendar {
|
from.calendar {
|
||||||
@target_context_count = count_old_due_empty(@new_due_id)
|
@target_context_count = @new_due_id.blank? ? 0 : count_old_due_empty(@new_due_id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@remaining_in_context = current_user.contexts.find(context_id).todos(true).active.not_hidden.count if !@remaining_in_context
|
@remaining_in_context = current_user.contexts.find(context_id).todos(true).active.not_hidden.count if !@remaining_in_context
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_field_tag(name, id, value = nil, options = {})
|
def date_field_tag(name, id, value = nil, options = {})
|
||||||
text_field_tag name, value, {"size" => 12, "id" => id, "class" => "Date", "onfocus" => "Calendar.setup", "autocomplete" => "off"}.update(options.stringify_keys)
|
text_field_tag name, value, {"size" => 12, "id" => id, "class" => "Date", "autocomplete" => "off"}.update(options.stringify_keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_needs_to_hide_context
|
def update_needs_to_hide_context
|
||||||
|
|
@ -295,7 +295,7 @@ module TodosHelper
|
||||||
(@remaining_in_context == 0 && @todo_was_deferred_from_active_state) ||
|
(@remaining_in_context == 0 && @todo_was_deferred_from_active_state) ||
|
||||||
(@remaining_in_context == 0 && @todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden)) if source_view_is(:tag)
|
(@remaining_in_context == 0 && @todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden)) if source_view_is(:tag)
|
||||||
|
|
||||||
return false if source_view_is(:project)
|
return false if source_view_is_one_of(:project, :calendar)
|
||||||
|
|
||||||
return (@remaining_in_context == 0) && !source_view_is(:context)
|
return (@remaining_in_context == 0) && !source_view_is(:context)
|
||||||
end
|
end
|
||||||
|
|
@ -403,7 +403,7 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
html += "}}) " * animation.count
|
html += "}}) " * animation.count
|
||||||
return html
|
return html + ";"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,10 @@ function show_empty_messages() {
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if empty_container_msg_div_id && todo_container_is_empty -%>
|
<% if empty_container_msg_div_id && todo_container_is_empty -%>
|
||||||
$('#<%=empty_container_msg_div_id%>').slideDown(1000);
|
$('#<%=empty_container_msg_div_id%>').slideDown(1000);
|
||||||
|
<% if @down_count == 0 -%>
|
||||||
|
$('#no_todos_in_view').slideDown(1000);
|
||||||
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if source_view_is(:deferred) && @down_count==0 -%>
|
<% if source_view_is(:deferred) && @down_count==0 -%>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
animation = []
|
animation = []
|
||||||
animation << "remove_todo"
|
animation << "remove_todo"
|
||||||
if @todo.completed?
|
if @todo.completed?
|
||||||
animation << "add_to_completed_container"
|
animation << "add_to_completed_container" unless source_view_is(:calendar)
|
||||||
animation << "add_new_recurring_todo"
|
animation << "add_new_recurring_todo"
|
||||||
animation << "activate_pending_todos"
|
animation << "activate_pending_todos"
|
||||||
animation << "remove_source_container"
|
animation << "remove_source_container"
|
||||||
|
|
@ -22,7 +22,8 @@
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
function redirect_after_complete() {
|
function redirect_after_complete() {
|
||||||
redirect_to("<%= project_path(@todo.project) -%>");
|
var path = "<%= @todo.project_id.nil? ? "/" : project_path(@todo.project) -%>";
|
||||||
|
redirect_to(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_todo(next_steps) {
|
function remove_todo(next_steps) {
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,36 @@ Feature: Show all due actions in a calendar view
|
||||||
Then the badge should show 1
|
Then the badge should show 1
|
||||||
And I should see "a new next action"
|
And I should see "a new next action"
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Clearing the due date of a todo will remove it from the calendar
|
Scenario: Clearing the due date of a todo will remove it from the calendar
|
||||||
When I submit a new action with description "a new next action" in the context "@calendar"
|
When I go to the home page
|
||||||
|
And I submit a new action with description "a new next action" in the context "@calendar"
|
||||||
And I edit the due date of "a new next action" to tomorrow
|
And I edit the due date of "a new next action" to tomorrow
|
||||||
And I go to the calendar page
|
And I go to the calendar page
|
||||||
Then I should see "a new next action"
|
Then I should see "a new next action"
|
||||||
When I clear the due date of "a new next action"
|
When I clear the due date of "a new next action"
|
||||||
Then I should not see "a new next action"
|
Then I should not see "a new next action"
|
||||||
|
|
||||||
|
@selenium
|
||||||
|
Scenario: Marking a todo complete will remove it from the calendar
|
||||||
|
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||||
|
When I go to the calendar page
|
||||||
|
Then I should see "a new next action"
|
||||||
|
When I clear the due date of "a new next action"
|
||||||
|
Then I should not see "a new next action"
|
||||||
|
|
||||||
|
@selenium
|
||||||
|
Scenario: Deleting a todo complete will remove it from the calendar
|
||||||
|
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||||
|
When I go to the calendar page
|
||||||
|
Then I should see "a new next action"
|
||||||
|
When I delete the action "a new next action"
|
||||||
|
Then I should not see "a new next action"
|
||||||
|
|
||||||
|
@selenium
|
||||||
Scenario: Changing due date of a todo will move it in the calendar
|
Scenario: Changing due date of a todo will move it in the calendar
|
||||||
Given this is a pending scenario
|
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||||
|
When I go to the calendar page
|
||||||
|
Then I should see "a new next action"
|
||||||
|
When I edit the due date of "a new next action" to next month
|
||||||
|
Then I should see "a new next action" in the due next month container
|
||||||
|
|
@ -7,6 +7,13 @@ Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, cont
|
||||||
@current_user.todos.create!(:context_id => context.id, :description => description)
|
@current_user.todos.create!(:context_id => context.id, :description => description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ do |description, context_name|
|
||||||
|
context = @current_user.contexts.find_or_create(:name => context_name)
|
||||||
|
@todo = @current_user.todos.create!(:context_id => context.id, :description => description)
|
||||||
|
@todo.due = @todo.created_at + 1.day
|
||||||
|
@todo.save!
|
||||||
|
end
|
||||||
|
|
||||||
Given /^I have a todo "([^"]*)"$/ do |description|
|
Given /^I have a todo "([^"]*)"$/ do |description|
|
||||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||||
end
|
end
|
||||||
|
|
@ -148,11 +155,19 @@ When /^I edit the due date of "([^"]*)" to tomorrow$/ do |action_description|
|
||||||
submit_edit_todo_form(todo)
|
submit_edit_todo_form(todo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I edit the due date of "([^"]*)" to next month$/ do |action_description|
|
||||||
|
todo = @current_user.todos.find_by_description(action_description)
|
||||||
|
todo.should_not be_nil
|
||||||
|
open_edit_form_for(todo)
|
||||||
|
fill_in "due_todo_#{todo.id}", :with => format_date(todo.created_at + 1.month)
|
||||||
|
submit_edit_todo_form(todo)
|
||||||
|
end
|
||||||
|
|
||||||
When /^I clear the due date of "([^"]*)"$/ do |action_description|
|
When /^I clear the due date of "([^"]*)"$/ do |action_description|
|
||||||
todo = @current_user.todos.find_by_description(action_description)
|
todo = @current_user.todos.find_by_description(action_description)
|
||||||
todo.should_not be_nil
|
todo.should_not be_nil
|
||||||
open_edit_form_for(todo)
|
open_edit_form_for(todo)
|
||||||
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo_id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
|
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||||
submit_edit_todo_form(todo)
|
submit_edit_todo_form(todo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -272,6 +287,17 @@ Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_descripti
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
|
||||||
|
todo = @current_user.todos.find_by_description(todo_description)
|
||||||
|
todo.should_not be_nil
|
||||||
|
|
||||||
|
xpath = "xpath=//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
|
||||||
|
|
||||||
|
wait_for :timeout => 5 do
|
||||||
|
!selenium.is_element_present(xpath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the selected project should be "([^"]*)"$/ do |content|
|
Then /^the selected project should be "([^"]*)"$/ do |content|
|
||||||
# Works for mobile. TODO: make it work for both mobile and non-mobile
|
# 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}/
|
field_labeled("Project").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,13 @@ module TracksStepHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_edit_form_for(todo)
|
def open_edit_form_for(todo)
|
||||||
# click edit
|
edit_button = "xpath=//div[@id='line_todo_#{todo.id}']//img[@id='edit_icon_todo_#{todo.id}']"
|
||||||
selenium.click("//div[@id='line_todo_#{todo.id}']//img[@id='edit_icon_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery)
|
|
||||||
|
wait_for :timeout => 5 do
|
||||||
|
selenium.is_element_present(edit_button)
|
||||||
|
end
|
||||||
|
|
||||||
|
selenium.click(edit_button, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||||
end
|
end
|
||||||
|
|
||||||
def wait_for_ajax
|
def wait_for_ajax
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue