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"