mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 03:00:12 +01:00
clean up cucumber scenarios and add a few more
This commit is contained in:
parent
ef961188ea
commit
a8f4199adc
7 changed files with 411 additions and 357 deletions
|
|
@ -62,11 +62,6 @@ module TodosHelper
|
|||
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => t('todos.defer_x_days', :count => days), :align => "absmiddle")+" "+t('todos.defer_x_days', :count => days)
|
||||
end
|
||||
|
||||
# waiting stuff can be deleted after migration of defer and dependencies
|
||||
def successor_start_waiting_js(successor)
|
||||
return "$('##{dom_id(successor, "successor")}').block({message: null})"
|
||||
end
|
||||
|
||||
def collapsed_notes_image(todo)
|
||||
link = link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_notes', :title => 'Show notes'})
|
||||
notes = content_tag(:div, {:class => "todo_notes", :id => dom_id(todo, 'notes'), :style => "display:none"}) { format_note(todo.notes) }
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function insert_new_context_with_new_todo() {
|
|||
|
||||
function add_todo_to_existing_context() {
|
||||
<% if source_view_is_one_of(:todo, :deferred, :tag) -%>
|
||||
<% unless source_view_is_one_of(:todo, :tag) && @todo.deferred? -%>
|
||||
<% unless source_view_is_one_of(:todo, :tag) && (@todo.deferred?||@todo.hidden?) -%>
|
||||
$('#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? %>
|
||||
|
|
|
|||
|
|
@ -121,6 +121,17 @@ Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_descripti
|
|||
end
|
||||
end
|
||||
|
||||
Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
|
||||
todo = @current_user.todos.find_by_description(todo_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath)
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,200 @@
|
|||
Given /^I have no todos$/ do
|
||||
Todo.delete_all
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ 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)
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |description, context_name, tag_names|
|
||||
Given "I have a todo \"#{description}\" in the context \"#{context_name}\""
|
||||
@todo.tag_with(tag_names)
|
||||
@todo.save!
|
||||
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 (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names|
|
||||
@context = @current_user.contexts.find_by_name(context_name)
|
||||
@context.should_not be_nil
|
||||
|
||||
@project = @current_user.projects.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
|
||||
@todos = []
|
||||
number_of_todos.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
|
||||
todo.tag_with(tag_names)
|
||||
todo.save!
|
||||
@todos << todo
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)"$/ do |description|
|
||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" with notes "([^"]*)"$/ do |description, notes|
|
||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
@todo.notes = notes
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
Given "I have a todo \"todo #{i}\" in the context \"Context A\""
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
context = @current_user.contexts.find_or_create(:name => context_name)
|
||||
project = @current_user.projects.find_or_create(:name => project_name)
|
||||
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
|
||||
@todo.tag_with(tags)
|
||||
@todo.save
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)" that is due next week$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.due = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
###### DEFERRED TODOS #######
|
||||
|
||||
Given /^I have ([0-9]+) deferred todos$/ do |count|
|
||||
context = @current_user.contexts.create!(:name => "context B")
|
||||
count.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
||||
todo.show_from = @current_user.time + 1.week
|
||||
todo.save!
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ 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.show_from = @current_user.time + 1.week
|
||||
todo.save!
|
||||
end
|
||||
|
||||
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 context "([^"]*)" with tags "([^"]*)"$/ do |action_description, context_name, tag_list|
|
||||
Given "I have a todo \"#{action_description}\" in context \"#{context_name}\" with tags \"#{tag_list}\""
|
||||
@todo.show_from = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
####### COMPLETED TODOS #######
|
||||
|
||||
Given /^I have ([0-9]+) completed todos in project "([^"]*)" in context "([^"]*)"$/ do |count, project_name, context_name|
|
||||
@context = @current_user.contexts.find_by_name(context_name)
|
||||
@context.should_not be_nil
|
||||
|
||||
@project = @current_user.projects.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
|
||||
@todos = []
|
||||
count.to_i.downto 1 do |i|
|
||||
@todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
|
||||
@todo.complete!
|
||||
@todos << @todo
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a completed todo "([^"]*)" in project "([^"]*)" in context "([^"]*)"$/ do |action_description, project_name, context_name|
|
||||
Given "I have 1 completed todos in project \"#{project_name}\" in context \"#{context_name}\""
|
||||
@todos[0].description = action_description
|
||||
@todos[0].save!
|
||||
end
|
||||
|
||||
Given /^I have (\d+) completed todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
|
||||
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\""
|
||||
@todos.each { |t| t.tag_with(tags); t.save! }
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name|
|
||||
context = @current_user.contexts.find_by_name(context_name)
|
||||
context.should_not be_nil
|
||||
|
||||
count.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
||||
todo.complete!
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos$/ do |count|
|
||||
Given "I have a context called \"context D\""
|
||||
Given "I have #{count} completed todos in context \"context D\""
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos with a note$/ do |count|
|
||||
Given "I have #{count} completed todos"
|
||||
@todos.each { |t| t.notes = "note #{t.id}"; t.save!}
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos with a note in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
|
||||
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\" with tags \"#{tags}\""
|
||||
@todos.each { |t| t.notes = "note #{t.id}"; t.save! }
|
||||
end
|
||||
|
||||
Given /^I have a completed todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.complete!
|
||||
end
|
||||
|
||||
####### PROJECT WITH TODOS ######
|
||||
|
||||
Given /^I have a project "([^"]*)" that has the following todos$/ do |project_name, todos|
|
||||
Given "I have a project called \"#{project_name}\""
|
||||
@project.should_not be_nil
|
||||
todos.hashes.each do |todo|
|
||||
context = @current_user.contexts.find_by_name(todo[:context])
|
||||
context.should_not be_nil
|
||||
new_todo = @current_user.todos.create!(
|
||||
:description => todo[:description],
|
||||
:context_id => context.id,
|
||||
:project_id=>@project.id)
|
||||
unless todo[:tags].nil?
|
||||
new_todo.tag_with(todo[:tags])
|
||||
end
|
||||
unless todo[:completed].nil?
|
||||
new_todo.complete! if todo[:completed] == 'yes'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a project "([^"]*)" that has the following deferred todos$/ do |project_name, todos|
|
||||
Given "I have a project called \"#{project_name}\""
|
||||
@project.should_not be_nil
|
||||
todos.hashes.each do |todo|
|
||||
context = @current_user.contexts.find_by_name(todo[:context])
|
||||
context.should_not be_nil
|
||||
new_todo = @current_user.todos.create!(
|
||||
:description => todo[:description],
|
||||
:context_id => context.id,
|
||||
:project_id=>@project.id,
|
||||
:show_from=>Time.zone.now+1.week)
|
||||
unless todo[:tags].nil?
|
||||
new_todo.tag_with(todo[:tags])
|
||||
end
|
||||
unless todo[:completed].nil?
|
||||
new_todo.complete! if todo[:completed] == 'yes'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
####### submitting using sidebar form #######
|
||||
|
||||
When /^I submit a new action with description "([^"]*)"$/ do |description|
|
||||
fill_in "todo[description]", :with => description
|
||||
submit_next_action_form
|
||||
|
|
@ -37,6 +234,41 @@ When /^I submit a new action with description "([^"]*)" and the tags "([^"]*)" i
|
|||
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
|
||||
|
||||
clear_project_name_from_next_action_form
|
||||
clear_context_name_from_next_action_form
|
||||
|
||||
fill_in "todo_project_name", :with => project_name
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
|
||||
submit_next_action_form
|
||||
end
|
||||
|
||||
When /^I submit a new action with description "([^"]*)" to project "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, context_name|
|
||||
When "I submit a new action with description \"#{description}\" to project \"#{project_name}\" with tags \"\" in the context \"#{context_name}\""
|
||||
end
|
||||
|
||||
|
||||
When /^I submit a new action with description "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
|
||||
clear_context_name_from_next_action_form
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
|
||||
submit_next_action_form
|
||||
end
|
||||
|
||||
####### submitting using sidebar form: DEFERRED #######
|
||||
|
||||
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 deferred action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
|
||||
|
|
@ -66,38 +298,7 @@ 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
|
||||
|
||||
clear_project_name_from_next_action_form
|
||||
clear_context_name_from_next_action_form
|
||||
|
||||
fill_in "todo_project_name", :with => project_name
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
|
||||
submit_next_action_form
|
||||
end
|
||||
|
||||
When /^I submit a new action with description "([^"]*)" to project "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, context_name|
|
||||
When "I submit a new action with description \"#{description}\" to project \"#{project_name}\" with tags \"\" in the context \"#{context_name}\""
|
||||
end
|
||||
|
||||
|
||||
When /^I submit a new action with description "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
|
||||
clear_context_name_from_next_action_form
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
|
||||
submit_next_action_form
|
||||
end
|
||||
####### submitting using sidebar form: MULTIPLE ACTIONS #######
|
||||
|
||||
When /^I submit multiple actions with using$/ do |multiple_actions|
|
||||
fill_in "todo[multiple_todos]", :with => multiple_actions
|
||||
|
|
|
|||
|
|
@ -1,3 +1,86 @@
|
|||
####### MARK (UN)COMPLETE #######
|
||||
|
||||
When /^I mark "([^"]*)" as complete$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
check "mark_complete_#{todo.id}"
|
||||
|
||||
todo_container = "fail" # fail this test if @source_view is wrong
|
||||
todo_container = "p#{todo.project_id}items" if @source_view=="project"
|
||||
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
|
||||
|
||||
# container should be there
|
||||
selenium.is_element_present("//div[@id='#{todo_container}']").should be_true
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
!selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
check "mark_complete_#{todo.id}"
|
||||
|
||||
todo_container = "fail" # fail this test if @source_view is wrong
|
||||
todo_container = "p#{todo.project_id}items" if @source_view=="project"
|
||||
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
|
||||
|
||||
todo_container.should_not == "fail" unless @source_view=="done"
|
||||
|
||||
unless @source_view=="done"
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
|
||||
end
|
||||
else
|
||||
wait_for_ajax
|
||||
end
|
||||
end
|
||||
|
||||
When /^I mark the complete todo "([^"]*)" active$/ do |action_description|
|
||||
When "I mark \"#{action_description}\" as uncompleted"
|
||||
end
|
||||
|
||||
####### (UN)STARRING #######
|
||||
|
||||
When /^I star the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_unstarred).should be_true
|
||||
|
||||
star_img = "//img[@id='star_img_#{todo.id}']"
|
||||
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_starred)
|
||||
end
|
||||
end
|
||||
|
||||
When /^I unstar the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_starred).should be_true
|
||||
|
||||
star_img = "//img[@id='star_img_#{todo.id}']"
|
||||
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_unstarred)
|
||||
end
|
||||
end
|
||||
|
||||
####### Editing a todo using Edit Form #######
|
||||
|
||||
When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo_name, new_value|
|
||||
todo = @current_user.todos.find_by_description(todo_name)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -32,19 +115,29 @@ When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_desc
|
|||
# do not wait for form to disappear to be able to test failures
|
||||
end
|
||||
|
||||
When /^I edit the due date of "([^"]*)" to tomorrow$/ do |action_description|
|
||||
When /^I edit the due date of "([^"]*)" to "([^"]*)"$/ do |action_description, date|
|
||||
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.day)
|
||||
fill_in "due_todo_#{todo.id}", :with => date
|
||||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I edit the due date of "([^"]*)" to tomorrow$/ do |action_description|
|
||||
date = format_date(todo.created_at + 1.day)
|
||||
When "I edit the due date of \"#{action_description}\" to \"#{date}\""
|
||||
end
|
||||
|
||||
When /^I edit the due date of "([^"]*)" to next month$/ do |action_description|
|
||||
date = format_date(todo.created_at + 1.month)
|
||||
When "I edit the due date of \"#{action_description}\" to \"#{date}\""
|
||||
end
|
||||
|
||||
When /^I clear the due date of "([^"]*)"$/ 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)
|
||||
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
|
||||
|
||||
|
|
@ -56,14 +149,6 @@ When /^I edit the show from date of "([^"]*)" to next month$/ do |action_descri
|
|||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I clear the due date of "([^"]*)"$/ 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='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
|
||||
|
|
@ -74,15 +159,6 @@ When /^I remove the show from date from "([^"]*)"$/ do |action_description|
|
|||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
open_edit_form_for(todo)
|
||||
fill_in "tag_list", :with => tags
|
||||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I defer "([^"]*)" for 1 day$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -93,6 +169,15 @@ When /^I defer "([^"]*)" for 1 day$/ do |action_description|
|
|||
wait_for_ajax
|
||||
end
|
||||
|
||||
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
open_edit_form_for(todo)
|
||||
fill_in "tag_list", :with => tags
|
||||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I make a project of "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -105,9 +190,11 @@ When /^I make a project of "([^"]*)"$/ do |action_description|
|
|||
end
|
||||
end
|
||||
|
||||
####### THEN #######
|
||||
|
||||
Then /^I should see an error message$/ do
|
||||
error_block = "xpath=//form/div[@id='edit_error_status']"
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(error_block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,295 +1,4 @@
|
|||
Given /^I have no todos$/ do
|
||||
Todo.delete_all
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ 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)
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |description, context_name, tag_names|
|
||||
Given "I have a todo \"#{description}\" in the context \"#{context_name}\""
|
||||
@todo.tag_with(tag_names)
|
||||
@todo.save!
|
||||
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 (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names|
|
||||
@context = @current_user.contexts.find_by_name(context_name)
|
||||
@context.should_not be_nil
|
||||
|
||||
@project = @current_user.projects.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
|
||||
@todos = []
|
||||
number_of_todos.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
|
||||
todo.tag_with(tag_names)
|
||||
todo.save!
|
||||
@todos << todo
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)"$/ do |description|
|
||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" with notes "([^"]*)"$/ do |description, notes|
|
||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
@todo.notes = notes
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
Given "I have a todo \"todo #{i}\" in the context \"Context A\""
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
context = @current_user.contexts.find_or_create(:name => context_name)
|
||||
project = @current_user.projects.find_or_create(:name => project_name)
|
||||
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
|
||||
@todo.tag_with(tags)
|
||||
@todo.save
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)" that is due next week$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.due = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
###### DEFERRED TODOS #######
|
||||
|
||||
Given /^I have ([0-9]+) deferred todos$/ do |count|
|
||||
context = @current_user.contexts.create!(:name => "context B")
|
||||
count.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
||||
todo.show_from = @current_user.time + 1.week
|
||||
todo.save!
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ 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.show_from = @current_user.time + 1.week
|
||||
todo.save!
|
||||
end
|
||||
|
||||
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 context "([^"]*)" with tags "([^"]*)"$/ do |action_description, context_name, tag_list|
|
||||
Given "I have a todo \"#{action_description}\" in context \"#{context_name}\" with tags \"#{tag_list}\""
|
||||
@todo.show_from = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
####### COMPLETED TODOS #######
|
||||
|
||||
Given /^I have ([0-9]+) completed todos in project "([^"]*)" in context "([^"]*)"$/ do |count, project_name, context_name|
|
||||
@context = @current_user.contexts.find_by_name(context_name)
|
||||
@context.should_not be_nil
|
||||
|
||||
@project = @current_user.projects.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
|
||||
@todos = []
|
||||
count.to_i.downto 1 do |i|
|
||||
@todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
|
||||
@todo.complete!
|
||||
@todos << @todo
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a completed todo "([^"]*)" in project "([^"]*)" in context "([^"]*)"$/ do |action_description, project_name, context_name|
|
||||
Given "I have 1 completed todos in project \"#{project_name}\" in context \"#{context_name}\""
|
||||
@todos[0].description = action_description
|
||||
@todos[0].save!
|
||||
end
|
||||
|
||||
Given /^I have (\d+) completed todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
|
||||
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\""
|
||||
@todos.each { |t| t.tag_with(tags); t.save! }
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name|
|
||||
context = @current_user.contexts.find_by_name(context_name)
|
||||
context.should_not be_nil
|
||||
|
||||
count.to_i.downto 1 do |i|
|
||||
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
||||
todo.complete!
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos$/ do |count|
|
||||
Given "I have a context called \"context D\""
|
||||
Given "I have #{count} completed todos in context \"context D\""
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos with a note$/ do |count|
|
||||
Given "I have #{count} completed todos"
|
||||
@todos.each { |t| t.notes = "note #{t.id}"; t.save!}
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos with a note in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
|
||||
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\" with tags \"#{tags}\""
|
||||
@todos.each { |t| t.notes = "note #{t.id}"; t.save! }
|
||||
end
|
||||
|
||||
Given /^I have a completed todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.complete!
|
||||
end
|
||||
|
||||
####### PROJECT WITH TODOS ######
|
||||
|
||||
Given /^I have a project "([^"]*)" that has the following todos$/ do |project_name, todos|
|
||||
Given "I have a project called \"#{project_name}\""
|
||||
@project.should_not be_nil
|
||||
todos.hashes.each do |todo|
|
||||
context = @current_user.contexts.find_by_name(todo[:context])
|
||||
context.should_not be_nil
|
||||
new_todo = @current_user.todos.create!(
|
||||
:description => todo[:description],
|
||||
:context_id => context.id,
|
||||
:project_id=>@project.id)
|
||||
unless todo[:tags].nil?
|
||||
new_todo.tag_with(todo[:tags])
|
||||
end
|
||||
unless todo[:completed].nil?
|
||||
new_todo.complete! if todo[:completed] == 'yes'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a project "([^"]*)" that has the following deferred todos$/ do |project_name, todos|
|
||||
Given "I have a project called \"#{project_name}\""
|
||||
@project.should_not be_nil
|
||||
todos.hashes.each do |todo|
|
||||
context = @current_user.contexts.find_by_name(todo[:context])
|
||||
context.should_not be_nil
|
||||
new_todo = @current_user.todos.create!(
|
||||
:description => todo[:description],
|
||||
:context_id => context.id,
|
||||
:project_id=>@project.id,
|
||||
:show_from=>Time.zone.now+1.week)
|
||||
unless todo[:tags].nil?
|
||||
new_todo.tag_with(todo[:tags])
|
||||
end
|
||||
unless todo[:completed].nil?
|
||||
new_todo.complete! if todo[:completed] == 'yes'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
When /^I mark "([^"]*)" as complete$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
check "mark_complete_#{todo.id}"
|
||||
|
||||
todo_container = "fail" # fail this test if @source_view is wrong
|
||||
todo_container = "p#{todo.project_id}items" if @source_view=="project"
|
||||
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
|
||||
|
||||
# container should be there
|
||||
selenium.is_element_present("//div[@id='#{todo_container}']").should be_true
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
!selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
check "mark_complete_#{todo.id}"
|
||||
|
||||
todo_container = "fail" # fail this test if @source_view is wrong
|
||||
todo_container = "p#{todo.project_id}items" if @source_view=="project"
|
||||
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
|
||||
|
||||
todo_container.should_not == "fail" unless @source_view=="done"
|
||||
|
||||
unless @source_view=="done"
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
|
||||
end
|
||||
else
|
||||
wait_for_ajax
|
||||
end
|
||||
end
|
||||
|
||||
When /^I mark the complete todo "([^"]*)" active$/ do |action_description|
|
||||
When "I mark \"#{action_description}\" as uncompleted"
|
||||
end
|
||||
|
||||
When /^I star the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_unstarred).should be_true
|
||||
|
||||
star_img = "//img[@id='star_img_#{todo.id}']"
|
||||
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_starred)
|
||||
end
|
||||
end
|
||||
|
||||
When /^I unstar the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_starred).should be_true
|
||||
|
||||
star_img = "//img[@id='star_img_#{todo.id}']"
|
||||
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_unstarred)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Then /^I should see a starred "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_starred).should be_true
|
||||
end
|
||||
|
||||
Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_starred)
|
||||
end
|
||||
end
|
||||
####### DELETE #######
|
||||
|
||||
When /^I delete the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
|
|
@ -308,6 +17,8 @@ When /^I delete the todo "([^"]*)"$/ do |action_description|
|
|||
When "I delete the action \"#{action_description}\""
|
||||
end
|
||||
|
||||
####### Notes #######
|
||||
|
||||
When /^I open the notes of "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -320,6 +31,28 @@ When /^I open the notes of "([^"]*)"$/ do |action_description|
|
|||
end
|
||||
end
|
||||
|
||||
####### THEN #######
|
||||
|
||||
Then /^I should see a starred "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
||||
|
||||
selenium.is_element_present(xpath_starred).should be_true
|
||||
end
|
||||
|
||||
Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath_starred)
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
match_xpath "div["
|
||||
|
|
|
|||
|
|
@ -8,18 +8,45 @@ Feature: Tagging todos
|
|||
| login | password | is_admin |
|
||||
| testuser | secret | false |
|
||||
And I have logged in as "testuser" with password "secret"
|
||||
And I have a context called "@pc"
|
||||
And I have a project called "hacking tracks"
|
||||
|
||||
Scenario: I can remove a tag from a todo from the tag view and the tag will be removed
|
||||
Given this is a pending scenario
|
||||
@selenium
|
||||
Scenario: I can remove a tag from a todo from the tag view and the todo will be removed
|
||||
Given I have a todo "fix tests" in context "@pc" with tags "now"
|
||||
When I go to the tag page for "now"
|
||||
Then I should see "fix tests"
|
||||
When I edit the tags of "fix tests" to "later"
|
||||
Then I should not see "fix tests"
|
||||
|
||||
@selenium
|
||||
Scenario: I can add a new todo from tag view with that tag and it will be added to the page
|
||||
Given this is a pending scenario
|
||||
When I go to the tag page for "tracks"
|
||||
And I submit a new action with description "prepare release" and the tags "tracks, release" in the context "@pc"
|
||||
Then I should see "prepare release" in the context container for "@pc"
|
||||
|
||||
@selenium
|
||||
Scenario: I can add a new todo from tag view with a different tag and it will not be added to the page
|
||||
Given this is a pending scenario
|
||||
When I go to the tag page for "tracks"
|
||||
And I submit a new action with description "prepare release" with tags "release, next" in the context "@pc"
|
||||
Then I should not see "prepare release"
|
||||
|
||||
@selenium
|
||||
Scenario: I can move a tagged todo in tag view to a hidden project and it will move the todo on the page to the hidden container
|
||||
Given this is a pending scenario
|
||||
Given I have a hidden project called "secret"
|
||||
When I go to the tag page for "tracks"
|
||||
And I submit a new action with description "prepare release" to project "hacking tracks" with tags "release, tracks" in the context "@pc"
|
||||
Then I should see "prepare release" in the context container for "@pc"
|
||||
When I edit the project of "prepare release" to "secret"
|
||||
Then I should not see "prepare release" in the context container for "@pc"
|
||||
And I should see "prepare release" in the hidden container
|
||||
|
||||
@selenium @wip
|
||||
Scenario: I can move a tagged todo in tag view to a hidden context and it will move the todo on the page to the hidden container
|
||||
Given this is a pending scenario
|
||||
Given I have a hidden context called "@secret"
|
||||
When I go to the tag page for "tracks"
|
||||
And I submit a new action with description "prepare release" and the tags "release, tracks" in the context "@pc"
|
||||
Then I should see "prepare release" in the context container for "@pc"
|
||||
When I edit the context of "prepare release" to "@secret"
|
||||
Then I should not see "prepare release" in the context container for "@pc"
|
||||
Then I should see "prepare release" in the hidden container
|
||||
Loading…
Add table
Add a link
Reference in a new issue