diff --git a/app/views/todos/create.js.erb b/app/views/todos/create.js.erb index 4df36032..17373b4f 100644 --- a/app/views/todos/create.js.erb +++ b/app/views/todos/create.js.erb @@ -25,7 +25,11 @@ function clear_form() { } function insert_new_context_with_new_todo() { - $('#no_todos_in_view').slideUp(100); + <%- + empty_id = '#no_todos_in_view' + empty_id = '#tickler-empty-nd' if source_view_is :tickler + -%> + $('<%=empty_id%>').slideUp(100); $('#display_box').prepend(html_for_new_context()); } @@ -34,6 +38,7 @@ function add_todo_to_existing_context() { <% unless source_view_is_one_of(:todo, :tag) && @todo.deferred? -%> $('#c<%= @todo.context_id %>').fadeIn(500, function() {}); $('#no_todos_in_view').slideUp(100); + <%= "$('#tickler-empty-nd').slideUp(100);" if source_view_is(:deferred) && @todo.deferred? %> <% end -%> <% end -%> $('#<%=empty_container_msg_div_id%>').hide(); diff --git a/app/views/todos/update.js.erb b/app/views/todos/update.js.erb index c76d71b1..62c3cc6a 100644 --- a/app/views/todos/update.js.erb +++ b/app/views/todos/update.js.erb @@ -69,6 +69,7 @@ function replace_todo(next_steps) { function hide_context(next_steps) { <% context_id = @context_changed ? @original_item_context_id : @todo.context_id -%> $('#c<%= context_id %>').fadeOut(400, function(){ next_steps.go(); }); + <%= "$('#tickler-empty-nd').slideDown(400);" if source_view_is(:deferred) && @down_count == 0 %> } function highlight_updated_todo(next_steps) { diff --git a/config/locales/en.yml b/config/locales/en.yml index 14baa0bf..98ddbc97 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -101,10 +101,10 @@ en: forth: Forth fourth: Fourth last: Last - month: Month - months: Months - week: Week - weeks: Weeks + month: month + months: months + week: week + weeks: weeks errors: user_unauthorized: "401 Unauthorized: Only administrative users are allowed access to this function." footer: @@ -539,7 +539,7 @@ en: - tuesday - wednesday - thursday - - vriday + - friday - saturday month_names: - diff --git a/features/step_definitions/container_steps.rb b/features/step_definitions/container_steps.rb index 5f811c11..ab70189d 100644 --- a/features/step_definitions/container_steps.rb +++ b/features/step_definitions/container_steps.rb @@ -44,6 +44,23 @@ Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_ selenium.is_visible(xpath).should be_true end +Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| + context = @current_user.contexts.find_by_name(context_name) + context.should_not be_nil + todo = @current_user.todos.find_by_description(todo_description) + todo.should_not be_nil + + xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" + + if selenium.is_element_present(xpath) + # give jquery some time to finish + wait_for :timeout_in_seconds => 5 do + !selenium.is_visible(xpath) + end + end +end + + Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name| todo = @current_user.todos.find_by_description(todo_description) todo.should_not be_nil diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index a7568a57..4b876ad2 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -28,6 +28,18 @@ Then /^I should see the empty message in the deferred container$/ do end end +Then /^I should see the empty tickler message$/ do + wait_for :timeout => 5 do + selenium.is_visible("xpath=//div[@id='tickler-empty-nd']") + end +end + +Then /^I should not see the empty tickler message$/ do + wait_for :timeout => 5 do + !selenium.is_visible("xpath=//div[@id='tickler-empty-nd']") + end +end + Then /^I should see an error flash message saying "([^"]*)"$/ do |message| xpath = "//div[@id='message_holder']/h4[@id='flash']" text = response.selenium.get_text("xpath=#{xpath}") diff --git a/features/step_definitions/todo_create_steps.rb b/features/step_definitions/todo_create_steps.rb index 9a9ee5b6..01fd572d 100644 --- a/features/step_definitions/todo_create_steps.rb +++ b/features/step_definitions/todo_create_steps.rb @@ -42,6 +42,12 @@ When /^I submit a deferred new action with description "([^"]*)" to project "([^ When "I submit a new deferred action with description \"#{description}\" to project \"#{project_name}\" with tags \"\" in the context \"#{context_name}\"" end +When /^I submit a new deferred action with description "([^"]*)"$/ do |description| + fill_in "todo[description]", :with => description + fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week) + submit_next_action_form +end + When /^I submit a new action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, tags, context_name| fill_in "todo[description]", :with => description diff --git a/features/step_definitions/todo_edit_steps.rb b/features/step_definitions/todo_edit_steps.rb index 8654718f..2be789f1 100644 --- a/features/step_definitions/todo_edit_steps.rb +++ b/features/step_definitions/todo_edit_steps.rb @@ -42,3 +42,13 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description| 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) end + +When /^I remove the show from date from "([^"]*)"$/ do |action_description| + todo = @current_user.todos.find_by_description(action_description) + todo.should_not be_nil + + open_edit_form_for(todo) + selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery) + + submit_edit_todo_form(todo) +end diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 835112a9..1dda0ab5 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -31,8 +31,12 @@ Given /^I have ([0-9]+) deferred todos$/ do |count| end end -Given /^I have a deferred todo "(.*)"$/ do |description| - context = @current_user.contexts.create!(:name => "context B") +Given /^I have a deferred todo "([^"]*)"$/ do |description| + Given "I have a deferred todo \"#{description}\" in the context \"context B\"" +end + +Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name| + context = @current_user.contexts.find_or_create(:name => context_name) @current_user.todos.create!(:context_id => context.id, :description => description, :show_from => @current_user.time + 1.week) end diff --git a/features/tickler.feature b/features/tickler.feature index 3c6462a1..56376b25 100644 --- a/features/tickler.feature +++ b/features/tickler.feature @@ -10,23 +10,46 @@ Feature: Manage deferred todos And there exists a project "manage me" for user "testuser" And I have logged in as "testuser" with password "secret" - @selenium @wip + @selenium Scenario: I can add a deferred todo and it will show in the tickler # also adding the first deferred todo will hide the empty message - When I go to the tickler + Given I have a context called "test" + When I go to the tickler page Then I should see the empty tickler message - When I submit a deferred new action with description "a new next action" + When I submit a new deferred action with description "a new next action" Then I should see "a new next action" And I should not see the empty tickler message - Scenario: Editing the description of a todo updated the todo - Given this is a pending scenario + @selenium + Scenario: Editing the description of a todo in the tickler updated the todo + Given I have a deferred todo "not yet now" + When I go to the tickler page + Then I should see "not yet now" + When I edit the description of "not yet now" to "almost" + Then I should not see "not yet now" + And I should see "almost" + @selenium Scenario: Editing the context of a todo moves it to the new context - Given this is a pending scenario + Given I have a context called "A" + And I have a context called "B" + And I have a deferred todo "not yet now" in the context "A" + When I go to the tickler page + Then I should see "not yet now" in the context container for "A" + When I edit the context of "not yet now" to "B" + Then I should see "not yet now" in the context container for "B" + And I should not see "not yet now" in the context container for "A" + @selenium Scenario: Removing the show from date from a todo removes it from the tickler - Given this is a pending scenario + Given I have a deferred todo "not yet now" + When I go to the tickler page + Then I should see "not yet now" + When I remove the show from date from "not yet now" + Then I should not see "not yet now" + And I should see the empty tickler message + When I go to the home page + Then I should see "not yet now" Scenario: Opening the tickler page shows me all deferred todos Given I have a deferred todo "not yet now" diff --git a/test/unit/recurring_todo_test.rb b/test/unit/recurring_todo_test.rb index e74b5361..03f2bb3f 100644 --- a/test/unit/recurring_todo_test.rb +++ b/test/unit/recurring_todo_test.rb @@ -27,8 +27,8 @@ class RecurringTodoTest < ActiveSupport::TestCase def test_pattern_text assert_equal "every day", @every_day.recurrence_pattern assert_equal "on work days", @every_workday.recurrence_pattern - assert_equal "every last Friday of every 2 months", @monthly_every_last_friday.recurrence_pattern - assert_equal "every year on June 8", @yearly.recurrence_pattern + assert_equal "every last friday of every 2 months", @monthly_every_last_friday.recurrence_pattern + assert_equal "every year on June 08", @yearly.recurrence_pattern end def test_daily_every_day