get features running for recurring todos

This commit is contained in:
Reinier Balt 2010-12-04 22:28:31 +01:00
parent f90d0d8eb9
commit ffd4ae1fcd
7 changed files with 131 additions and 27 deletions

View file

@ -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 = '<a class="icon">' + image_tag("blank.png") + "</a> "
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

View file

@ -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)

View file

@ -12,7 +12,7 @@
<div id="recurring_todo_form_container">
<div id="recurring_todo">
<label for="recurring_todo_description">Description</label><%=
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") -%>
<label for="recurring_todo_notes">Notes</label><%=
text_area_tag( "recurring_todo[notes]", @recurring_todo.notes, {:cols => 29, :rows => 6, :tabindex => 2}) -%>

View file

@ -1,5 +1,5 @@
<div id="display_box">
<div class="container recurring_todos">
<div class="container" id="active_recurring_todos_container">
<h2><%= t('todos.recurring_todos') %></h2>
<div id="recurring_todos_container">
<div id="recurring-todos-empty-nd" style="<%= @no_recurring_todos ? 'display:block' : 'display:none'%>">
@ -9,7 +9,7 @@
</div>
</div>
<div class="container recurring_todos_done">
<div class="container" id="completed_recurring_todos_container">
<h2><%= t('todos.completed_recurring') %></h2>
<div id="completed_recurring_todos_container">
<div id="completed-empty-nd" style="<%= @no_completed_recurring_todos ? 'display:block' : 'display:none'%>">

View file

@ -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
@ -25,16 +27,37 @@ Feature: Manage recurring todos
@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

View file

@ -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

View file

@ -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"