2012-12-24 15:36:47 +01:00
|
|
|
When /^I select the second page$/ do
|
|
|
|
|
step "I follow \"2\" within \"div.paginate_header\""
|
|
|
|
|
end
|
|
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
####### DELETE #######
|
2011-08-11 17:13:01 +02:00
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
When /^I delete the action "([^"]*)"$/ do |action_description|
|
2013-04-29 09:31:15 +02:00
|
|
|
todo = find_todo(action_description)
|
2010-10-22 11:55:54 +02:00
|
|
|
|
2012-01-30 03:42:47 +01:00
|
|
|
handle_js_confirm do
|
2013-02-28 12:47:18 +01:00
|
|
|
open_submenu_for(todo) do
|
|
|
|
|
click_link "delete_todo_#{todo.id}"
|
|
|
|
|
end
|
2011-04-21 16:54:35 +02:00
|
|
|
end
|
2012-01-30 03:42:47 +01:00
|
|
|
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?"
|
2012-02-03 15:57:23 +01:00
|
|
|
|
|
|
|
|
wait_for_ajax
|
2011-04-21 16:54:35 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
When /^I delete the todo "([^"]*)"$/ do |action_description|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I delete the action \"#{action_description}\""
|
2011-04-21 16:54:35 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
####### Notes #######
|
2011-04-21 16:54:35 +02:00
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
When /^I open the notes of "([^"]*)"$/ do |action_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => action_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2012-02-15 21:42:06 +01:00
|
|
|
page.find(:xpath, "//div[@id='line_todo_#{todo.id}']/div/a/img").click
|
2012-03-19 14:05:54 +01:00
|
|
|
|
|
|
|
|
page.should have_xpath("//div[@id='notes_todo_#{todo.id}']", :visible=>true)
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
####### THEN #######
|
2011-06-26 23:05:33 +02:00
|
|
|
|
2011-04-21 16:54:35 +02:00
|
|
|
Then /^I should see a starred "([^"]*)"$/ do |action_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => action_description).first
|
2011-04-21 16:54:35 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2011-08-11 10:13:53 +02:00
|
|
|
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
|
2012-02-15 21:42:06 +01:00
|
|
|
page.should have_xpath(xpath_starred)
|
2011-01-08 09:12:37 +01:00
|
|
|
end
|
|
|
|
|
|
2011-06-26 23:05:33 +02:00
|
|
|
Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => action_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2011-08-11 10:13:53 +02:00
|
|
|
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
|
2012-03-12 22:52:45 +01:00
|
|
|
page.should have_xpath(xpath_starred)
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
|
2011-03-08 23:28:48 +01:00
|
|
|
Then /^I should see ([0-9]+) todos$/ do |count|
|
2012-03-12 22:52:45 +01:00
|
|
|
total = page.all("div.item-container").inject(0) { |s, e| s+=1 }
|
|
|
|
|
total.should == count.to_i
|
2011-02-03 16:59:59 +01:00
|
|
|
end
|
|
|
|
|
|
2010-07-04 20:13:32 -07:00
|
|
|
Then /^I should see the todo "([^\"]*)"$/ do |todo_description|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should have_xpath("//span[.=\"#{todo_description}\"]", :visible => true)
|
2010-07-04 20:13:32 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should not see the todo "([^\"]*)"$/ do |todo_description|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should_not have_xpath("//span[.=\"#{todo_description}\"]", :visible => true)
|
2010-07-04 20:13:32 -07:00
|
|
|
end
|
2010-07-14 23:34:47 +02:00
|
|
|
|
2011-09-16 12:38:35 +02:00
|
|
|
Then /^I should see a completed todo "([^"]*)"$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-09-16 12:38:35 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
|
|
|
|
# only completed todos have a grey span with the completed_at date
|
|
|
|
|
xpath = "//div[@id='line_todo_#{todo.id}']/div/span[@class='grey']"
|
2012-03-19 14:05:54 +01:00
|
|
|
page.should have_xpath(xpath, :visible=>true)
|
2011-09-16 12:38:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see an active todo "([^"]*)"$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-09-16 12:38:35 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
|
|
|
|
xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']"
|
2012-03-12 21:50:53 +01:00
|
|
|
page.should have_xpath(xpath, :visible=>true)
|
2011-09-16 12:38:35 +02:00
|
|
|
end
|
|
|
|
|
|
2010-07-14 23:34:47 +02:00
|
|
|
Then /^the number of actions should be (\d+)$/ do |count|
|
|
|
|
|
@current_user.todos.count.should == count.to_i
|
|
|
|
|
end
|
2011-01-08 09:12:37 +01:00
|
|
|
|
|
|
|
|
Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |context_name|
|
2012-03-12 21:50:53 +01:00
|
|
|
get_confirm_text.should == "New context '#{context_name}' will be also created. Are you sure?"
|
2011-02-03 16:59:59 +01:00
|
|
|
end
|
|
|
|
|
|
2011-02-26 11:38:39 +01:00
|
|
|
Then /^the selected project should be "([^"]*)"$/ do |content|
|
|
|
|
|
# Works for mobile. TODO: make it work for both mobile and non-mobile
|
2012-02-21 20:18:26 +01:00
|
|
|
if content.blank?
|
|
|
|
|
page.has_css?("select#todo_project_id option[selected='selected']").should be_false
|
|
|
|
|
else
|
|
|
|
|
page.find("select#todo_project_id option[selected='selected']").text.should =~ /#{content}/
|
|
|
|
|
end
|
2011-02-26 11:38:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the selected context should be "([^"]*)"$/ do |content|
|
|
|
|
|
# Works for mobile. TODO: make it work for both mobile and non-mobile
|
2012-02-21 20:18:26 +01:00
|
|
|
if content.blank?
|
|
|
|
|
page.has_css?("select#todo_context_id option[selected='selected']").should be_false
|
|
|
|
|
else
|
|
|
|
|
page.find("select#todo_context_id option[selected='selected']").text.should =~ /#{content}/
|
|
|
|
|
end
|
2011-02-26 11:38:39 +01:00
|
|
|
end
|
2011-06-17 20:17:01 +02:00
|
|
|
|
|
|
|
|
Then /^I should see the page selector$/ do
|
2012-03-12 22:52:45 +01:00
|
|
|
page.should have_xpath(".//a[@class='next_page']")
|
2011-06-17 20:17:01 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the page should be "([^"]*)"$/ do |page_number|
|
2012-12-24 15:36:47 +01:00
|
|
|
page.find(:xpath, ".//div[@class='paginate_header']//em[@class='current']").text.should == page_number
|
2011-06-17 20:17:01 +02:00
|
|
|
end
|
2011-09-14 20:50:21 +02:00
|
|
|
|
|
|
|
|
Then /^the project field of the new todo form should contain "([^"]*)"$/ do |project_name|
|
|
|
|
|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_project_name']"
|
2012-03-01 20:31:16 +01:00
|
|
|
project_name.should == page.find(:xpath, xpath).value
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name|
|
|
|
|
|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']"
|
2012-03-01 20:31:16 +01:00
|
|
|
context_name.should == page.find(:xpath, xpath).value
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the tag field in the new todo form should be empty$/ do
|
2012-05-10 13:53:01 -05:00
|
|
|
xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find(:xpath, xpath).value.blank?.should be_true
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list|
|
2012-05-10 13:53:01 -05:00
|
|
|
xpath= "//form[@id='todo-form-new-action']/input[@id='tag_list']"
|
2012-03-01 20:31:16 +01:00
|
|
|
tag_list.should == page.find(:xpath, xpath).value
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list|
|
2013-04-22 11:17:57 +02:00
|
|
|
find_todo(todo_description).tag_list.should == tag_list
|
2012-01-13 21:26:22 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see "([^"]*)" in the completed section of the mobile site$/ do |desc|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => desc).first
|
2012-01-13 21:26:22 -06:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
|
|
|
|
xpath = "//div[@id='completed_container']//a[@href='/todos/#{todo.id}.m']"
|
2012-02-21 20:18:26 +01:00
|
|
|
page.should have_xpath(xpath)
|
2012-01-13 21:26:22 -06:00
|
|
|
end
|
2012-02-15 21:42:06 +01:00
|
|
|
|
2012-03-19 14:05:54 +01:00
|
|
|
Then /^I should (see|not see) the notes of "([^"]*)"$/ do |visible, todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2012-02-15 21:42:06 +01:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2012-03-19 14:05:54 +01:00
|
|
|
page.find("div#notes_todo_#{todo.id}").send(visible=="see" ? "should" : "should_not", be_visible)
|
2012-05-10 13:53:01 -05:00
|
|
|
end
|
2013-03-18 12:24:42 +01:00
|
|
|
|
|
|
|
|
Then /^I should (see|not see) the empty tickler message$/ do |see|
|
|
|
|
|
elem = find("div#no_todos_in_view")
|
|
|
|
|
elem.send(see=="see" ? "should" : "should_not", be_visible)
|
|
|
|
|
end
|