diff --git a/app/helpers/recurring_todos_helper.rb b/app/helpers/recurring_todos_helper.rb index e36e1a7f..53bd6c71 100644 --- a/app/helpers/recurring_todos_helper.rb +++ b/app/helpers/recurring_todos_helper.rb @@ -18,7 +18,7 @@ module RecurringTodosHelper def recurring_todo_remote_star_icon link_to( image_tag_for_star(@recurring_todo), - toggle_star_recurring_todo_path(@recurring_todo), + toggle_star_recurring_todo_path(@recurring_todo), :id => "star_icon_"+@recurring_todo.id.to_s, :class => "icon star_item", :title => t('todos.star_action')) end @@ -26,7 +26,7 @@ module RecurringTodosHelper if !@recurring_todo.completed? str = link_to( image_tag_for_edit(@recurring_todo), edit_recurring_todo_path(@recurring_todo), - :class => "icon edit_icon") + :class => "icon edit_icon", :id => "link_edit_recurring_todo_#{@recurring_todo.id}") else str = '' + image_tag("blank.png") + " " end @@ -34,8 +34,7 @@ module RecurringTodosHelper end def recurring_todo_remote_toggle_checkbox - str = check_box_tag('item_id', toggle_check_recurring_todo_path(@recurring_todo), @recurring_todo.completed?, :class => 'item-checkbox') - str + return check_box_tag("check_#{@recurring_todo.id}", toggle_check_recurring_todo_path(@recurring_todo), @recurring_todo.completed?, :class => 'item-checkbox') end private diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 85512d89..d3c3cb0b 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -300,7 +300,7 @@ module TodosHelper def image_tag_for_star(todo) class_str = todo.starred? ? "starred_todo" : "unstarred_todo" - image_tag("blank.png", :title =>t('todos.star_action'), :class => class_str) + image_tag("blank.png", :title =>t('todos.star_action'), :class => class_str, :id => "star_img_"+todo.id.to_s) end def auto_complete_result2(entries, phrase = nil) diff --git a/app/views/recurring_todos/_edit_form.html.erb b/app/views/recurring_todos/_edit_form.html.erb index e0daff5a..2d61fd5c 100644 --- a/app/views/recurring_todos/_edit_form.html.erb +++ b/app/views/recurring_todos/_edit_form.html.erb @@ -12,7 +12,7 @@
<%= - text_field_tag( "recurring_todo[description]", @recurring_todo.description, "size" => 30, "tabindex" => 1, "maxlength" => 100) -%> + text_field_tag( "recurring_todo[description]", @recurring_todo.description, "size" => 30, "tabindex" => 1, "maxlength" => 100, :id => "edit_recurring_todo_description") -%> <%= text_area_tag( "recurring_todo[notes]", @recurring_todo.notes, {:cols => 29, :rows => 6, :tabindex => 2}) -%> diff --git a/app/views/recurring_todos/index.html.erb b/app/views/recurring_todos/index.html.erb index 6ecc7b08..ac11ae26 100644 --- a/app/views/recurring_todos/index.html.erb +++ b/app/views/recurring_todos/index.html.erb @@ -1,5 +1,5 @@
-
+

<%= t('todos.recurring_todos') %>

@@ -9,7 +9,7 @@
-
+

<%= t('todos.completed_recurring') %>

diff --git a/features/recurring_todos.feature b/features/recurring_todos.feature index d3963ee5..40849d57 100644 --- a/features/recurring_todos.feature +++ b/features/recurring_todos.feature @@ -8,6 +8,8 @@ Feature: Manage recurring todos | login | password | is_admin | | testuser | secret | false | And I have logged in as "testuser" with password "secret" + And I have a context called "test context" + And I have a repeat pattern called "run tests" @selenium Scenario: Being able to select daily, weekly, monthly and yearly pattern @@ -23,18 +25,39 @@ Feature: Manage recurring todos When I select "Daily" recurrence pattern Then I should see the form for "Daily" recurrence pattern - @selenium + @selenium Scenario: I can mark a repeat pattern as starred - Given this scenario is pending + When I go to the repeating todos page + And I star the pattern "run tests" + Then the pattern "run tests" should be starred @selenium Scenario: I can edit a repeat pattern - Given this scenario is pending + When I go to the repeating todos page + And I edit the name of the pattern "run tests" to "report test results" + Then the pattern "report test results" should be in the state list "active" + And I should not see "run tests" @selenium Scenario: I can delete a repeat pattern - Given this scenario is pending + When I go to the repeating todos page + And I delete the pattern "run tests" + And I should not see "run tests" @selenium Scenario: I can mark a repeat pattern as done - Given this scenario is pending + When I go to the repeating todos page + Then the pattern "run tests" should be in the state list "active" + And the state list "completed" should be empty + When I mark the pattern "run tests" as complete + Then the pattern "run tests" should be in the state list "completed" + And the state list "active" should be empty + + @selenium + Scenario: I can reactivate a repeat pattern + Given I have a completed repeat pattern "I'm done" + When I go to the repeating todos page + Then the pattern "I'm done" should be in the state list "completed" + When I mark the pattern "I'm done" as active + Then the pattern "I'm done" should be in the state list "active" + And the state list "completed" should be empty \ No newline at end of file diff --git a/features/step_definitions/recurring_todo_steps.rb b/features/step_definitions/recurring_todo_steps.rb index 2982eb26..76697b26 100644 --- a/features/step_definitions/recurring_todo_steps.rb +++ b/features/step_definitions/recurring_todo_steps.rb @@ -1,7 +1,103 @@ +Given /^I have a repeat pattern called "([^"]*)"$/ do |pattern_name| + context = @current_user.contexts.first + @recurring_todo = @current_user.recurring_todos.create!( + :description => pattern_name, + :context_id => context.id, + :state => 'active', + :start_from => Time.now - 1.day, + :ends_on => 'no_end_date', + :target => 'due_date', + :recurring_period => 'daily', + :every_other1 => 1, + :show_always => 1, + :created_at => Time.now - 1.day, + :completed_at => nil + ) + @recurring_todo.completed?.should be_false + @todo = @current_user.todos.create!( + :description => pattern_name, + :context_id => context.id, + :recurring_todo_id => @recurring_todo.id) +end + +Given /^I have a completed repeat pattern "([^"]*)"$/ do |pattern_name| + Given "I have a repeat pattern called \"#{pattern_name}\"" + @recurring_todo.toggle_completion! + @recurring_todo.completed?.should be_true +end + When /^I select "([^\"]*)" recurrence pattern$/ do |recurrence_period| selenium.click("recurring_todo_recurring_period_#{recurrence_period.downcase}") end +When /^I edit the name of the pattern "([^\"]*)" to "([^\"]*)"$/ do |pattern_name, new_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + click_link "link_edit_recurring_todo_#{pattern.id}" + + selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery + + fill_in "edit_recurring_todo_description", :with => new_name + selenium.click "recurring_todo_edit_action_submit" + + wait_for do + !selenium.is_visible("overlay") + end +end + +When /^I star the pattern "([^\"]*)"$/ do |pattern_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + click_link "star_icon_#{pattern.id}" + selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery +end + +When /^I delete the pattern "([^"]*)"$/ do |pattern_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + click_link "delete_icon_#{pattern.id}" + selenium.get_confirmation.should == "Are you sure that you want to delete the recurring action '#{pattern_name}'?" + wait_for do + !selenium.is_element_present("delete_icon_#{pattern.id}") + end +end + +When /^I mark the pattern "([^"]*)" as complete$/ do |pattern_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + pattern.completed?.should be_false + selenium.click "check_#{pattern.id}" + selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery +end + +When /^I mark the pattern "([^"]*)" as active$/ do |pattern_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + pattern.completed?.should be_true + selenium.click "check_#{pattern.id}" + selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery +end + +Then /^the state list "([^"]*)" should be empty$/ do |state| + empty_id = "recurring-todos-empty-nd" if state.downcase == "active" + empty_id = "completed-empty-nd" if state.downcase == "completed" + selenium.is_visible( empty_id ) +end + +Then /^the pattern "([^\"]*)" should be starred$/ do |pattern_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + xpath = "//div[@id='recurring_todo_#{pattern.id}']//img[@class='starred_todo']" + response.should have_xpath(xpath) +end + Then /^I should see the form for "([^\"]*)" recurrence pattern$/ do |recurrence_period| selenium.is_visible("recurring_#{recurrence_period.downcase}") end + +Then /^the pattern "([^"]*)" should be in the state list "([^"]*)"$/ do |pattern_name, state_name| + pattern = @current_user.recurring_todos.find_by_description(pattern_name) + pattern.should_not be_nil + xpath = "//div[@id='#{state_name}_recurring_todos_container']//div[@id='recurring_todo_#{pattern.id}']" + response.should have_xpath(xpath) +end diff --git a/test/selenium/project_detail/add_note.rsel b/test/selenium/project_detail/add_note.rsel deleted file mode 100644 index ff0040ba..00000000 --- a/test/selenium/project_detail/add_note.rsel +++ /dev/null @@ -1,14 +0,0 @@ -setup :fixtures => :all -login :as => 'admin' - -#first, defer a todo -open "/projects/1" - -click "css=.add_note_link a" - -assert_visible "new-note" - -type "note_body", "this is a note" -click 'css=#new-note input[type=submit]' - -wait_for_text_present "this is a note"