remove dynamic finders from cucumber scenarios

This commit is contained in:
Reinier Balt 2013-02-27 20:02:01 +01:00
parent 2b2572a2d1
commit 48e47fc009
20 changed files with 133 additions and 134 deletions

View file

@ -73,7 +73,7 @@ class RecurringTodosController < ApplicationController
# update context # update context
if params['recurring_todo']['context_id'].blank? && !params['context_name'].blank? if params['recurring_todo']['context_id'].blank? && !params['context_name'].blank?
context = current_user.contexts.where(:name => params['context_name'].strip) context = current_user.contexts.where(:name => params['context_name'].strip).first
unless context unless context
context = current_user.contexts.build context = current_user.contexts.build
context.name = params['context_name'].strip context.name = params['context_name'].strip

View file

@ -34,7 +34,7 @@ class TodosController < ApplicationController
end end
if params[:tag] if params[:tag]
tag = Tag.where(:name => params['tag']) tag = Tag.where(:name => params['tag']).first
@not_done_todos = @not_done_todos.where('taggings.tag_id = ?', tag.id) @not_done_todos = @not_done_todos.where('taggings.tag_id = ?', tag.id)
end end
@ -103,8 +103,8 @@ class TodosController < ApplicationController
def create def create
@source_view = params['_source_view'] || 'todo' @source_view = params['_source_view'] || 'todo'
@default_context = current_user.contexts.where(:name => params['default_context_name']) @default_context = current_user.contexts.where(:name => params['default_context_name']).first
@default_project = current_user.projects.where(:name => params['default_project_name']) unless params['default_project_name'].blank? @default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank?
@tag_name = params['_tag_name'] @tag_name = params['_tag_name']
@ -719,7 +719,7 @@ class TodosController < ApplicationController
@source_view = params['_source_view'] || 'tag' @source_view = params['_source_view'] || 'tag'
@tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability! @tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability!
@page_title = t('todos.completed_tagged_page_title', :tag_name => @tag_name) @page_title = t('todos.completed_tagged_page_title', :tag_name => @tag_name)
@tag = Tag.where(:name => @tag_name) @tag = Tag.where(:name => @tag_name).first
@tag = Tag.new(:name => @tag_name) if @tag.nil? @tag = Tag.new(:name => @tag_name) if @tag.nil?
completed_todos = current_user.todos.completed.with_tag(@tag.id) completed_todos = current_user.todos.completed.with_tag(@tag.id)
@ -736,7 +736,7 @@ class TodosController < ApplicationController
@source_view = params['_source_view'] || 'tag' @source_view = params['_source_view'] || 'tag'
@tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability! @tag_name = sanitize(params[:name]) # sanitize to prevent XSS vunerability!
@page_title = t('todos.all_completed_tagged_page_title', :tag_name => @tag_name) @page_title = t('todos.all_completed_tagged_page_title', :tag_name => @tag_name)
@tag = Tag.where(:name => @tag_name) @tag = Tag.where(:name => @tag_name).first
@tag = Tag.new(:name => @tag_name) if @tag.nil? @tag = Tag.new(:name => @tag_name) if @tag.nil?
@done = current_user.todos.completed.with_tag(@tag.id).reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).paginate :page => params[:page], :per_page => 20 @done = current_user.todos.completed.with_tag(@tag.id).reorder('completed_at DESC').includes(Todo::DEFAULT_INCLUDES).paginate :page => params[:page], :per_page => 20
@ -1017,7 +1017,7 @@ class TodosController < ApplicationController
end end
from.tag do from.tag do
@tag_name = params['_tag_name'] @tag_name = params['_tag_name']
@tag = Tag.where(:name => @tag_name) @tag = Tag.where(:name => @tag_name).first
if @tag.nil? if @tag.nil?
@tag = Tag.new(:name => @tag_name) @tag = Tag.new(:name => @tag_name)
end end
@ -1034,7 +1034,7 @@ class TodosController < ApplicationController
@target_context_count = current_user.contexts.find(@todo.context_id).todos.deferred_or_blocked.count @target_context_count = current_user.contexts.find(@todo.context_id).todos.deferred_or_blocked.count
} }
from.tag { from.tag {
tag = Tag.where(:name => params['_tag_name']) tag = Tag.where(:name => params['_tag_name']).first
if tag.nil? if tag.nil?
tag = Tag.new(:name => params['tag']) tag = Tag.new(:name => params['tag'])
end end
@ -1103,7 +1103,7 @@ class TodosController < ApplicationController
end end
def determine_deferred_tag_count(tag_name) def determine_deferred_tag_count(tag_name)
tag = Tag.where(:name => tag_name) tag = Tag.where(:name => tag_name).first
# tag.nil? should normally not happen, but is a workaround for #929 # tag.nil? should normally not happen, but is a workaround for #929
@remaining_deferred_or_pending_count = tag.nil? ? 0 : current_user.todos.deferred.with_tag(tag.id).count @remaining_deferred_or_pending_count = tag.nil? ? 0 : current_user.todos.deferred.with_tag(tag.id).count
end end

View file

@ -23,7 +23,7 @@ Feature: Manage users
Then I should be on the manage users page Then I should be on the manage users page
And I should see "new.user" And I should see "new.user"
@selenium @javascript
Scenario: Delete account from users page Scenario: Delete account from users page
When I go to the manage users page When I go to the manage users page
And I delete the user "testuser" And I delete the user "testuser"

View file

@ -1,5 +1,5 @@
When /^I collapse the context container of "([^"]*)"$/ do |context_name| When /^I collapse the context container of "([^"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
xpath = "//a[@id='toggle_c#{context.id}']" xpath = "//a[@id='toggle_c#{context.id}']"
@ -15,7 +15,7 @@ end
####### Context ####### ####### Context #######
Then /^I should not see the context "([^"]*)"$/ do |context_name| Then /^I should not see the context "([^"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
xpath = "//div[@id='c#{context.id}']" xpath = "//div[@id='c#{context.id}']"
@ -35,7 +35,7 @@ Then /^the container for the context "([^"]*)" should not be visible$/ do |conte
end end
Then /^I should see the container for context "([^"]*)"$/ do |context_name| Then /^I should see the container for context "([^"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
xpath = "//div[@id='c#{context.id}']" xpath = "//div[@id='c#{context.id}']"
@ -47,9 +47,9 @@ Then /^the container for the context "([^"]*)" should be visible$/ do |context_n
end end
Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
@ -57,9 +57,9 @@ Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_
end end
Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
@ -69,21 +69,21 @@ end
####### Deferred ####### ####### Deferred #######
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description| Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
page.should have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']") page.should have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
end end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description| Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
page.should_not have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']") page.should_not have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
end end
Then /^I should (not see|see) "([^"]*)" in the action container$/ do |visible, todo_description| Then /^I should (not see|see) "([^"]*)" in the action container$/ do |visible, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
id = @source_view=="project" ? "p#{todo.project_id}items" : "c#{todo.context_id}items" id = @source_view=="project" ? "p#{todo.project_id}items" : "c#{todo.context_id}items"
@ -99,10 +99,10 @@ end
####### Project ####### ####### Project #######
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name| Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
@ -110,10 +110,10 @@ Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |to
end end
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name| Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='p#{project.id}items']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='p#{project.id}items']//div[@id='line_todo_#{todo.id}']"
@ -123,7 +123,7 @@ end
####### Completed ####### ####### Completed #######
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description| Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
@ -131,7 +131,7 @@ Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
end end
Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description| Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
@ -141,7 +141,7 @@ end
####### Hidden ####### ####### Hidden #######
Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description| Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
@ -151,7 +151,7 @@ end
####### Calendar ####### ####### Calendar #######
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description| Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
within "div#due_after_this_month" do within "div#due_after_this_month" do
@ -162,7 +162,7 @@ end
####### Repeat patterns ####### ####### Repeat patterns #######
Then /^I should (see|not see) "([^"]*)" in the active recurring todos container$/ do |visibility, repeat_pattern| Then /^I should (see|not see) "([^"]*)" in the active recurring todos container$/ do |visibility, repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern) repeat = @current_user.recurring_todos.where(:description => repeat_pattern).first
unless repeat.nil? unless repeat.nil?
xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']" xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
@ -173,7 +173,7 @@ Then /^I should (see|not see) "([^"]*)" in the active recurring todos container$
end end
Then /^I should not see "([^"]*)" in the completed recurring todos container$/ do |repeat_pattern| Then /^I should not see "([^"]*)" in the completed recurring todos container$/ do |repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern) repeat = @current_user.todos.where(:description => repeat_pattern).first
unless repeat.nil? unless repeat.nil?
xpath = "//div[@id='completed_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']" xpath = "//div[@id='completed_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
@ -182,4 +182,3 @@ Then /^I should not see "([^"]*)" in the completed recurring todos container$/ d
step "I should not see \"#{repeat_pattern}\"" step "I should not see \"#{repeat_pattern}\""
end end
end end

View file

@ -1,5 +1,5 @@
When /^I delete the context "([^\"]*)"$/ do |context_name| When /^I delete the context "([^\"]*)"$/ do |context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
handle_js_confirm do handle_js_confirm do
@ -44,7 +44,7 @@ When /^I add a new hidden context "([^"]*)"$/ do |context_name|
end end
When /^I drag context "([^"]*)" above context "([^"]*)"$/ do |context_drag, context_drop| When /^I drag context "([^"]*)" above context "([^"]*)"$/ do |context_drag, context_drop|
drag_id = @current_user.contexts.find_by_name(context_drag).id drag_id = @current_user.contexts.where(:name => context_drag).first.id
sortable_css = "div.ui-sortable div#container_context_#{drag_id}" sortable_css = "div.ui-sortable div#container_context_#{drag_id}"
drag_index = context_list_find_index(context_drag) drag_index = context_list_find_index(context_drag)
@ -73,7 +73,7 @@ Then /^I should see that the context container for (.*) contexts is present$/ do
end end
Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, state| Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, state|
context = Context.find_by_name(context_name) context = Context.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
page.has_css?("div#list-contexts-#{state} div#context_#{context.id}").should be_true page.has_css?("div#list-contexts-#{state} div#context_#{context.id}").should be_true

View file

@ -4,9 +4,9 @@ Given /^I have no contexts$/ do
end end
Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login| Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
user = User.find_by_login(login) user = User.where(:login => login).first
user.should_not be_nil user.should_not be_nil
@context = user.contexts.find_or_create_by_name(:name => context_name, :hide => false) @context = user.contexts.where(:name => context_name, :hide => false).first_or_create
end end
Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login| Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
@ -14,7 +14,7 @@ Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context
end end
Given /^there exists a hidden context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login| Given /^there exists a hidden context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
user = User.find_by_login(login) user = User.where(:login => login).first
user.should_not be_nil user.should_not be_nil
@context = user.contexts.create!(:name => context_name, :hide => true) @context = user.contexts.create!(:name => context_name, :hide => true)
end end
@ -70,7 +70,7 @@ Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
end end
Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible| Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
if visible == "is" if visible == "is"
context.should_not be_nil context.should_not be_nil
css = "div#context_#{context.id} div.context_description a" css = "div#context_#{context.id} div.context_description a"

View file

@ -1,6 +1,6 @@
Given /^"([^"]*)" depends on "([^"]*)"$/ do |successor_name, predecessor_name| Given /^"([^"]*)" depends on "([^"]*)"$/ do |successor_name, predecessor_name|
successor = Todo.find_by_description(successor_name) successor = Todo.where(:description => successor_name).first
predecessor = Todo.find_by_description(predecessor_name) predecessor = Todo.where(:description => predecessor_name).first
successor.add_predecessor(predecessor) successor.add_predecessor(predecessor)
successor.state = "pending" successor.state = "pending"
@ -8,8 +8,8 @@ Given /^"([^"]*)" depends on "([^"]*)"$/ do |successor_name, predecessor_name|
end end
When /^I drag "(.*)" to "(.*)"$/ do |dragged, target| When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
drag_id = Todo.find_by_description(dragged).id drag_id = Todo.where(:description => dragged).first.id
drop_id = Todo.find_by_description(target).id drop_id = Todo.where(:description => target).first.id
drag_elem = page.find(:xpath, "//div[@id='line_todo_#{drag_id}']//img[@class='grip']") drag_elem = page.find(:xpath, "//div[@id='line_todo_#{drag_id}']//img[@class='grip']")
drop_elem = page.find(:xpath, "//div[@id='line_todo_#{drop_id}']") drop_elem = page.find(:xpath, "//div[@id='line_todo_#{drop_id}']")
@ -17,7 +17,7 @@ When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
end end
When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name| When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
todo = Todo.find_by_description(todo_name) todo = Todo.where(:description=>todo_name).first
todo.should_not be_nil todo.should_not be_nil
expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
@ -27,9 +27,9 @@ When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
end end
When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description| When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
predecessor = @current_user.todos.find_by_description(predecessor_description) predecessor = @current_user.todos.where(:description => predecessor_description).first
predecessor.should_not be_nil predecessor.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -55,9 +55,9 @@ When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |
end end
When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ do |todo_description, predecessor_description| When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
predecessor = @current_user.todos.find_by_description(predecessor_description) predecessor = @current_user.todos.where(:description => predecessor_description).first
predecessor.should_not be_nil predecessor.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -73,7 +73,7 @@ When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ d
end end
When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps| When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps|
todo = @dep_todo = @current_user.todos.find_by_description(todo_name) todo = @dep_todo = @current_user.todos.where(:description => todo_name).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -82,19 +82,19 @@ When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps|
end end
Then /^the successors of "(.*)" should include "(.*)"$/ do |parent_name, child_name| Then /^the successors of "(.*)" should include "(.*)"$/ do |parent_name, child_name|
parent = @current_user.todos.find_by_description(parent_name) parent = @current_user.todos.where(:description => parent_name).first
parent.should_not be_nil parent.should_not be_nil
# wait until the successor is added. TODO: make this not loop indefinitly # wait until the successor is added. TODO: make this not loop indefinitly
wait_until do wait_until do
found = !parent.pending_successors.find_by_description(child_name).nil? found = !parent.pending_successors.where(:description => child_name).first.nil?
sleep 0.2 unless found sleep 0.2 unless found
found found
end end
end end
Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description| Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
# open successors # open successors
@ -108,14 +108,14 @@ Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |succe
end end
Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description| Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
step "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\"" step "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
end end
Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description| Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
page.should_not have_xpath(dependencies_icon) page.should_not have_xpath(dependencies_icon)

View file

@ -9,7 +9,7 @@ end
Then /^I should see a script "([^\"]*)" for "([^\"]*)"$/ do |script, context_name| Then /^I should see a script "([^\"]*)" for "([^\"]*)"$/ do |script, context_name|
page.should have_css("##{script}", :visible => true) page.should have_css("##{script}", :visible => true)
context = Context.find_by_name(context_name) context = Context.where(:name => context_name).first
page.should have_content("#{context.id} (* #{context_name} *)") page.should have_content("#{context.id} (* #{context_name} *)")

View file

@ -7,7 +7,7 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)" logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
page.should have_content(logout_regexp) page.should have_content(logout_regexp)
@current_user = User.find_by_login(username) @current_user = User.where(:login => username).first
end end
When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do |username, password| When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do |username, password|

View file

@ -1,5 +1,5 @@
When /^I add note "([^\"]*)" from the "([^\"]*)" project page$/ do |note, project| When /^I add note "([^\"]*)" from the "([^\"]*)" project page$/ do |note, project|
project = Project.find_by_name(project) project = Project.where(:name => project).first
project.notes.create!(:user_id => @current_user.id, :body => note) project.notes.create!(:user_id => @current_user.id, :body => note)
end end
@ -31,7 +31,7 @@ When /^I edit the first note to "([^"]*)"$/ do |note_body|
end end
When /^I toggle the note of "([^"]*)"$/ do |todo_description| When /^I toggle the note of "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='line_todo_#{todo.id}']/div/a/img" xpath = "//div[@id='line_todo_#{todo.id}']/div/a/img"
@ -54,7 +54,7 @@ Then /^(.*) notes should be visible$/ do |number|
end end
Then /^I should see note "([^\"]*)" on the "([^\"]*)" project page$/ do |note, project| Then /^I should see note "([^\"]*)" on the "([^\"]*)" project page$/ do |note, project|
project = Project.find_by_name(project) project = Project.where(:name => project).first
visit project_path(project) visit project_path(project)
step "I should see the note \"#{note}\"" step "I should see the note \"#{note}\""
end end

View file

@ -1,5 +1,5 @@
When /^I delete project "([^"]*)"$/ do |project_name| When /^I delete project "([^"]*)"$/ do |project_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
handle_js_confirm do handle_js_confirm do
@ -13,7 +13,7 @@ When /^I delete project "([^"]*)"$/ do |project_name|
end end
When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_drop| When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_drop|
drag_id = @current_user.projects.find_by_name(project_drag).id drag_id = @current_user.projects.where(:name => project_drag).first.id
sortable_css = "div.ui-sortable div#container_project_#{drag_id}" sortable_css = "div.ui-sortable div#container_project_#{drag_id}"
drag_index = project_list_find_index(project_drag) drag_index = project_list_find_index(project_drag)
@ -78,7 +78,7 @@ Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project
end end
Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name| Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
list_id = @source_view=="review" ? "list-#{state}-projects" : "list-#{state_name}-projects-container" list_id = @source_view=="review" ? "list-#{state}-projects" : "list-#{state_name}-projects-container"
@ -88,7 +88,7 @@ Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project
end end
Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name| Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
list_id = @source_view=="review" ? "list-#{state_name}-projects" : "list-#{state_name}-projects-container" list_id = @source_view=="review" ? "list-#{state_name}-projects" : "list-#{state_name}-projects-container"
@ -113,15 +113,15 @@ Then /^the new project form should not be visible$/ do
page.should_not have_css("div#project_new", :visible => true) page.should_not have_css("div#project_new", :visible => true)
end end
Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |name, count| Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |project_name, count|
project = @current_user.projects.find_by_name(name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']" xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
page.find(:xpath, xpath).text.should == "#{project.name} (#{count} actions)" page.find(:xpath, xpath).text.should == "#{project.name} (#{count} actions)"
end end
Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |name, deferred| Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |project_name, deferred|
project = @current_user.projects.find_by_name(name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']" xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
page.find(:xpath, xpath).text.should == "#{project.name} (#{deferred} deferred actions)" page.find(:xpath, xpath).text.should == "#{project.name} (#{deferred} deferred actions)"

View file

@ -4,7 +4,7 @@ end
Given /^I have an outdated project "([^"]*)" with (\d+) todos$/ do |project_name, num_todos| Given /^I have an outdated project "([^"]*)" with (\d+) todos$/ do |project_name, num_todos|
step "I have a project \"#{project_name}\" with #{num_todos} todos" step "I have a project \"#{project_name}\" with #{num_todos} todos"
@project = @current_user.projects.find_by_name(project_name) @project = @current_user.projects.where(:name => project_name).first
@project.last_reviewed = @current_user.time - @current_user.prefs.review_period.days-1 @project.last_reviewed = @current_user.time - @current_user.prefs.review_period.days-1
@project.save @project.save
end end
@ -19,8 +19,8 @@ Given /^I have a project "([^"]*)" with (\d+) active actions and (\d+) deferred
end end
Given /^I have a project "([^"]*)" with (\d+) (todo|active todo|deferred todo)s prefixed by "([^\"]*)"$/ do |project_name, num_todos, state, prefix| Given /^I have a project "([^"]*)" with (\d+) (todo|active todo|deferred todo)s prefixed by "([^\"]*)"$/ do |project_name, num_todos, state, prefix|
@context = @current_user.contexts.find_or_create_by_name("Context A") @context = @current_user.contexts.where(:name => "Context A").first_or_create
@project = @current_user.projects.find_or_create_by_name(project_name) @project = @current_user.projects.where(:name => project_name).first_or_create
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this # acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@project.move_to_bottom @project.move_to_bottom
@ -41,7 +41,7 @@ Given /^I have a project "([^"]*)" with (\d+) (todos|active todos|deferred todos
end end
Given /^there exists a project (?:|called )"([^"]*)" for user "([^"]*)"$/ do |project_name, user_name| Given /^there exists a project (?:|called )"([^"]*)" for user "([^"]*)"$/ do |project_name, user_name|
user = User.find_by_login(user_name) user = User.where(:login => user_name).first
user.should_not be_nil user.should_not be_nil
@project = user.projects.create!(:name => project_name) @project = user.projects.create!(:name => project_name)
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this # acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@ -101,7 +101,7 @@ Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num|
end end
Given /^the default tags for "(.*?)" are "(.*?)"$/ do |project_name, default_tags| Given /^the default tags for "(.*?)" are "(.*?)"$/ do |project_name, default_tags|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
project.default_tags = default_tags project.default_tags = default_tags
@ -146,13 +146,13 @@ When /^I edit the default context to "([^"]*)"$/ do |default_context|
end end
When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name| When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.find_by_name(project_current_name) @project = @current_user.projects.where(:name => project_current_name).first
@project.should_not be_nil @project.should_not be_nil
step "I edit the project name to \"#{project_new_name}\"" step "I edit the project name to \"#{project_new_name}\""
end end
When /^I try to edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name| When /^I try to edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.find_by_name(project_current_name) @project = @current_user.projects.where(:name => project_current_name).first
@project.should_not be_nil @project.should_not be_nil
step "I try to edit the project name to \"#{project_new_name}\"" step "I try to edit the project name to \"#{project_new_name}\""
end end
@ -182,7 +182,7 @@ When /^I close the project settings$/ do
end end
When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name| When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
edit_project_settings(project) do edit_project_settings(project) do
@ -191,7 +191,7 @@ When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, st
end end
When /^I edit project "([^"]*)" and mark the project as reviewed$/ do |project_name| When /^I edit project "([^"]*)" and mark the project as reviewed$/ do |project_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
open_project_edit_form(project) open_project_edit_form(project)
@ -318,12 +318,12 @@ Then /^I should (see|not see) the default project settings$/ do |visible|
end end
Then /^I should have a project called "([^"]*)"$/ do |project_name| Then /^I should have a project called "([^"]*)"$/ do |project_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
end end
Then /^I should have (\d+) todo in project "([^"]*)"$/ do |todo_count, project_name| Then /^I should have (\d+) todo in project "([^"]*)"$/ do |todo_count, project_name|
project = @current_user.projects.find_by_name(project_name) project = @current_user.projects.where(:name => project_name).first
project.should_not be_nil project.should_not be_nil
project.todos.count.should == todo_count.to_i project.todos.count.should == todo_count.to_i
end end

View file

@ -38,7 +38,7 @@ When /^I select "([^\"]*)" recurrence pattern$/ do |recurrence_period|
end end
When /^I edit the name of the pattern "([^\"]*)" to "([^\"]*)"$/ do |pattern_name, new_name| 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 = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
click_link "link_edit_recurring_todo_#{pattern.id}" click_link "link_edit_recurring_todo_#{pattern.id}"
@ -51,13 +51,13 @@ When /^I edit the name of the pattern "([^\"]*)" to "([^\"]*)"$/ do |pattern_nam
end end
When /^I star the pattern "([^\"]*)"$/ do |pattern_name| When /^I star the pattern "([^\"]*)"$/ do |pattern_name|
pattern = @current_user.recurring_todos.find_by_description(pattern_name) pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
click_link "star_icon_#{pattern.id}" click_link "star_icon_#{pattern.id}"
end end
When /^I delete the pattern "([^"]*)"$/ do |pattern_name| When /^I delete the pattern "([^"]*)"$/ do |pattern_name|
pattern = @current_user.recurring_todos.find_by_description(pattern_name) pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
handle_js_confirm do handle_js_confirm do
@ -69,7 +69,7 @@ When /^I delete the pattern "([^"]*)"$/ do |pattern_name|
end end
When /^I mark the pattern "([^"]*)" as (complete|active)$/ do |pattern_name, state| When /^I mark the pattern "([^"]*)" as (complete|active)$/ do |pattern_name, state|
pattern = @current_user.recurring_todos.find_by_description(pattern_name) pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
pattern.completed?.should(state=="complete" ? be_false : be_true) pattern.completed?.should(state=="complete" ? be_false : be_true)
page.find("#check_#{pattern.id}").click page.find("#check_#{pattern.id}").click
@ -78,7 +78,7 @@ When /^I mark the pattern "([^"]*)" as (complete|active)$/ do |pattern_name, sta
end end
When /^I follow the recurring todo link of "([^"]*)"$/ do |action_description| When /^I follow the recurring todo link of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
page.find(:xpath, "//div[@id='todo_#{todo.id}']//a[@class='recurring_icon']/img").click page.find(:xpath, "//div[@id='todo_#{todo.id}']//a[@class='recurring_icon']/img").click
@ -93,7 +93,7 @@ Then /^the state list "([^"]*)" should be empty$/ do |state|
end end
Then /^the pattern "([^\"]*)" should be starred$/ do |pattern_name| Then /^the pattern "([^\"]*)" should be starred$/ do |pattern_name|
pattern = @current_user.recurring_todos.find_by_description(pattern_name) pattern = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
page.should have_xpath("//div[@id='recurring_todo_#{pattern.id}']//img[@class='todo_star starred']") page.should have_xpath("//div[@id='recurring_todo_#{pattern.id}']//img[@class='todo_star starred']")
end end
@ -103,7 +103,7 @@ Then /^I should see the form for "([^\"]*)" recurrence pattern$/ do |recurrence_
end end
Then /^the pattern "([^"]*)" should be in the state list "([^"]*)"$/ do |pattern_name, state_name| 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 = @current_user.recurring_todos.where(:description => pattern_name).first
pattern.should_not be_nil pattern.should_not be_nil
page.should have_xpath("//div[@id='#{state_name}_recurring_todos_container']//div[@id='recurring_todo_#{pattern.id}']") page.should have_xpath("//div[@id='#{state_name}_recurring_todos_container']//div[@id='recurring_todo_#{pattern.id}']")
end end

View file

@ -3,7 +3,7 @@ Given /^I have no todos$/ do
end end
Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name| Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first_or_create
@todo = @current_user.todos.create!(:context_id => context.id, :description => description) @todo = @current_user.todos.create!(:context_id => context.id, :description => description)
end end
@ -14,17 +14,17 @@ Given /^I have a todo "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |d
end end
Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ do |description, context_name| Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ do |description, context_name|
context = @current_user.contexts.find_or_create_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first_or_create
@todo = @current_user.todos.create!(:context_id => context.id, :description => description) @todo = @current_user.todos.create!(:context_id => context.id, :description => description)
@todo.due = @todo.created_at + 1.day @todo.due = @todo.created_at + 1.day
@todo.save! @todo.save!
end end
Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)" prefixed by "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names, prefix| Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)" prefixed by "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names, prefix|
@context = @current_user.contexts.find_by_name(context_name) @context = @current_user.contexts.where(:name => context_name).first
@context.should_not be_nil @context.should_not be_nil
@project = @current_user.projects.find_by_name(project_name) @project = @current_user.projects.where(:name => project_name).first
@project.should_not be_nil @project.should_not be_nil
@todos = [] @todos = []
@ -63,8 +63,8 @@ Given /^I have ([0-9]+) todos$/ do |count|
end end
Given /^I have a 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 "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
context = @current_user.contexts.find_or_create_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first_or_create
project = @current_user.projects.find_or_create_by_name(project_name) project = @current_user.projects.where(:name => project_name).first_or_create
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description) @todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
@todo.tag_with(tags) @todo.tag_with(tags)
@todo.save @todo.save
@ -88,7 +88,7 @@ Given /^I have ([0-9]+) deferred todos$/ do |count|
end end
Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name| Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first_or_create
todo = @current_user.todos.create!(:context_id => context.id, :description => description) todo = @current_user.todos.create!(:context_id => context.id, :description => description)
todo.show_from = @current_user.time + 1.week todo.show_from = @current_user.time + 1.week
todo.save! todo.save!
@ -107,10 +107,10 @@ end
####### COMPLETED TODOS ####### ####### COMPLETED TODOS #######
Given /^I have ([0-9]+) completed todos in project "([^"]*)" in context "([^"]*)"$/ do |count, project_name, context_name| 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 = @current_user.contexts.where(:name => context_name).first
@context.should_not be_nil @context.should_not be_nil
@project = @current_user.projects.find_by_name(project_name) @project = @current_user.projects.where(:name => project_name).first
@project.should_not be_nil @project.should_not be_nil
@todos = [] @todos = []
@ -133,7 +133,7 @@ Given /^I have (\d+) completed todos in project "([^"]*)" in context "([^"]*)" w
end end
Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name| Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name|
context = @current_user.contexts.find_by_name(context_name) context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil context.should_not be_nil
count.to_i.downto 1 do |i| count.to_i.downto 1 do |i|
@ -168,7 +168,7 @@ Given /^I have a project "([^"]*)" that has the following (todos|deferred todos)
step "I have a project called \"#{project_name}\"" step "I have a project called \"#{project_name}\""
@project.should_not be_nil @project.should_not be_nil
todos.hashes.each do |todo| todos.hashes.each do |todo|
context = @current_user.contexts.find_by_name(todo[:context]) context = @current_user.contexts.where(:name => todo[:context]).first
context.should_not be_nil context.should_not be_nil
new_todo = @current_user.todos.create!( new_todo = @current_user.todos.create!(
:description => todo[:description], :description => todo[:description],
@ -195,7 +195,7 @@ When /^I submit a new action with description "([^"]*)"$/ do |description|
end end
When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description| When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description|
predecessor = @current_user.todos.find_by_description(predecessor_description) predecessor = @current_user.todos.where(:description => predecessor_description).first
predecessor.should_not be_nil predecessor.should_not be_nil
within "form#todo-form-new-action" do within "form#todo-form-new-action" do

View file

@ -1,7 +1,7 @@
####### MARK (UN)COMPLETE ####### ####### MARK (UN)COMPLETE #######
When /^I mark "([^"]*)" as complete$/ do |action_description| When /^I mark "([^"]*)" as complete$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
check "mark_complete_#{todo.id}" check "mark_complete_#{todo.id}"
@ -11,7 +11,7 @@ When /^I mark "([^"]*)" as complete$/ do |action_description|
end end
When /^I mark "([^"]*)" as uncompleted$/ do |action_description| When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
uncheck "mark_complete_#{todo.id}" uncheck "mark_complete_#{todo.id}"
@ -29,7 +29,7 @@ end
####### (UN)STARRING ####### ####### (UN)STARRING #######
When /^I star the action "([^"]*)"$/ do |action_description| When /^I star the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
@ -47,7 +47,7 @@ When /^I star the action "([^"]*)"$/ do |action_description|
end end
When /^I unstar the action "([^"]*)"$/ do |action_description| When /^I unstar the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
@ -64,7 +64,7 @@ end
####### Editing a todo using Edit Form ####### ####### Editing a todo using Edit Form #######
When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo_name, new_value| When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo_name, new_value|
todo = @current_user.todos.find_by_description(todo_name) todo = @current_user.todos.where(:description => todo_name).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -86,7 +86,7 @@ When /^I edit the project of "([^"]*)" to "([^"]*)"$/ do |todo_name, project_new
end end
When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description| When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -97,7 +97,7 @@ When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description
end end
When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description| When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -111,7 +111,7 @@ When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_desc
end end
When /^I edit the due date of "([^"]*)" to "([^"]*)"$/ do |action_description, date| When /^I edit the due date of "([^"]*)" to "([^"]*)"$/ do |action_description, date|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -130,7 +130,7 @@ When /^I edit the due date of "([^"]*)" to next month$/ do |action_description|
end end
When /^I clear the due date of "([^"]*)"$/ do |action_description| When /^I clear the due date of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -144,7 +144,7 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description|
end end
When /^I edit the show from date of "([^"]*)" to next month$/ do |action_description| When /^I edit the show from date of "([^"]*)" to next month$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -153,7 +153,7 @@ When /^I edit the show from date of "([^"]*)" to next month$/ do |action_descri
end end
When /^I remove the show from date from "([^"]*)"$/ do |action_description| When /^I remove the show from date from "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -166,7 +166,7 @@ When /^I clear the show from date of "([^"]*)"$/ do |action_description|
end end
When /^I defer "([^"]*)" for 1 day$/ do |action_description| When /^I defer "([^"]*)" for 1 day$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_submenu_for(todo) open_submenu_for(todo)
@ -178,7 +178,7 @@ When /^I defer "([^"]*)" for 1 day$/ do |action_description|
end end
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags| When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_edit_form_for(todo) open_edit_form_for(todo)
@ -189,7 +189,7 @@ When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
end end
When /^I make a project of "([^"]*)"$/ do |action_description| When /^I make a project of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
open_submenu_for(todo) open_submenu_for(todo)

View file

@ -5,7 +5,7 @@ end
####### DELETE ####### ####### DELETE #######
When /^I delete the action "([^"]*)"$/ do |action_description| When /^I delete the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
handle_js_confirm do handle_js_confirm do
@ -26,7 +26,7 @@ end
####### Notes ####### ####### Notes #######
When /^I open the notes of "([^"]*)"$/ do |action_description| When /^I open the notes of "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
page.find(:xpath, "//div[@id='line_todo_#{todo.id}']/div/a/img").click page.find(:xpath, "//div[@id='line_todo_#{todo.id}']/div/a/img").click
@ -37,7 +37,7 @@ end
####### THEN ####### ####### THEN #######
Then /^I should see a starred "([^"]*)"$/ do |action_description| Then /^I should see a starred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star starred']"
@ -45,7 +45,7 @@ Then /^I should see a starred "([^"]*)"$/ do |action_description|
end end
Then /^I should see an unstarred "([^"]*)"$/ do |action_description| Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description) todo = @current_user.todos.where(:description => action_description).first
todo.should_not be_nil todo.should_not be_nil
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']" xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='todo_star']"
@ -66,7 +66,7 @@ Then /^I should not see the todo "([^\"]*)"$/ do |todo_description|
end end
Then /^I should see a completed todo "([^"]*)"$/ do |todo_description| Then /^I should see a completed todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
# only completed todos have a grey span with the completed_at date # only completed todos have a grey span with the completed_at date
@ -75,7 +75,7 @@ Then /^I should see a completed todo "([^"]*)"$/ do |todo_description|
end end
Then /^I should see an active todo "([^"]*)"$/ do |todo_description| Then /^I should see an active todo "([^"]*)"$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']" xpath = "//div[@id='line_todo_#{todo.id}']/img[@class='grip']"
@ -137,14 +137,14 @@ Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list|
end end
Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list| Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
todo.tag_list.should == tag_list todo.tag_list.should == tag_list
end end
Then /^I should see "([^"]*)" in the completed section of the mobile site$/ do |desc| Then /^I should see "([^"]*)" in the completed section of the mobile site$/ do |desc|
todo = @current_user.todos.find_by_description(desc) todo = @current_user.todos.where(:description => desc).first
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='completed_container']//a[@href='/todos/#{todo.id}.m']" xpath = "//div[@id='completed_container']//a[@href='/todos/#{todo.id}.m']"
@ -162,7 +162,7 @@ Then /^I should (see|not see) the empty tickler message$/ do |see|
end end
Then /^I should (see|not see) the notes of "([^"]*)"$/ do |visible, todo_description| Then /^I should (see|not see) the notes of "([^"]*)"$/ do |visible, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.where(:description => todo_description).first
todo.should_not be_nil todo.should_not be_nil
page.find("div#notes_todo_#{todo.id}").send(visible=="see" ? "should" : "should_not", be_visible) page.find("div#notes_todo_#{todo.id}").send(visible=="see" ? "should" : "should_not", be_visible)

View file

@ -48,7 +48,7 @@ end
When /^I delete the user "([^\"]*)"$/ do |username| When /^I delete the user "([^\"]*)"$/ do |username|
# click "//tr[@id='user-3']//img" # click "//tr[@id='user-3']//img"
# assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?" # assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?"
user = User.find_by_login(username) user = User.where(:login => username).first
user.should_not be_nil user.should_not be_nil
handle_js_confirm do handle_js_confirm do

View file

@ -21,11 +21,11 @@ module NavigationHelpers
done_overview_path(options) done_overview_path(options)
when /the done actions page for context "([^"]*)"/i when /the done actions page for context "([^"]*)"/i
@source_view = "done" @source_view = "done"
context = @current_user.contexts.find_by_name($1) context = @current_user.contexts.where(:name => $1).first
done_todos_context_path(context, options) done_todos_context_path(context, options)
when /the done actions page for project "([^"]*)"/i when /the done actions page for project "([^"]*)"/i
@source_view = "done" @source_view = "done"
project = @current_user.projects.find_by_name($1) project = @current_user.projects.where(:name => $1).first
done_todos_project_path(project, options) done_todos_project_path(project, options)
when /the done actions page for tag "([^"]*)"/i when /the done actions page for tag "([^"]*)"/i
@source_view = "done" @source_view = "done"
@ -35,11 +35,11 @@ module NavigationHelpers
done_todos_path(options) done_todos_path(options)
when /the all done actions page for context "([^"]*)"/i when /the all done actions page for context "([^"]*)"/i
@source_view = "done" @source_view = "done"
context = @current_user.contexts.find_by_name($1) context = @current_user.contexts.where(:name => $1).first
all_done_todos_context_path(context, options) all_done_todos_context_path(context, options)
when /the all done actions page for project "([^"]*)"/i when /the all done actions page for project "([^"]*)"/i
@source_view = "done" @source_view = "done"
project = @current_user.projects.find_by_name($1) project = @current_user.projects.where(:name => $1).first
all_done_todos_project_path(project, options) all_done_todos_project_path(project, options)
when /the all done actions page for tag "([^"]*)"/i when /the all done actions page for tag "([^"]*)"/i
@source_view = "done" @source_view = "done"
@ -93,23 +93,23 @@ module NavigationHelpers
feeds_path(options) feeds_path(options)
when /the context page for "([^\"]*)" for user "([^\"]*)"/i when /the context page for "([^\"]*)" for user "([^\"]*)"/i
@source_view = "context" @source_view = "context"
@context = User.find_by_login($2).contexts.find_by_name($1) @context = User.where(:login => $2).first.contexts.where(:name => $1).first
context_path(@context, options) context_path(@context, options)
when /the context page for "([^\"]*)"/i when /the context page for "([^\"]*)"/i
@source_view = "context" @source_view = "context"
@context = @current_user.contexts.find_by_name($1) @context = @current_user.contexts.where(:name => $1).first
context_path(@context, options) context_path(@context, options)
when /the "([^\"]*)" context/i when /the "([^\"]*)" context/i
@source_view = "context" @source_view = "context"
@context = @current_user.contexts.find_by_name($1) @context = @current_user.contexts.where(:name => $1).first
context_path(@context, options) context_path(@context, options)
when /the "([^\"]*)" project for user "([^\"]*)"/i when /the "([^\"]*)" project for user "([^\"]*)"/i
@source_view = "project" @source_view = "project"
@project = User.find_by_login($2).projects.find_by_name($1) @project = User.where(:login => $2).first.projects.where(:name => $1).first
project_path(@project, options) project_path(@project, options)
when /the "([^\"]*)" project/i when /the "([^\"]*)" project/i
@source_view = "project" @source_view = "project"
@project = @current_user.projects.find_by_name($1) @project = @current_user.projects.where(:name => $1).first
project_path(@project, options) project_path(@project, options)
when /the tag page for "([^"]*)"/i when /the tag page for "([^"]*)"/i
@source_view = "tag" @source_view = "tag"
@ -121,7 +121,7 @@ module NavigationHelpers
# Here is an example that pulls values out of the Regexp: # Here is an example that pulls values out of the Regexp:
# #
# when /^(.*)'s profile page$/i # when /^(.*)'s profile page$/i
# user_profile_path(User.find_by_login($1)) # user_profile_path(User.where(:login => $1))first.
else else
begin begin

View file

@ -112,14 +112,14 @@ module TracksStepHelper
end end
def context_list_find_index(context_name) def context_list_find_index(context_name)
div_id = "context_#{@current_user.contexts.find_by_name(context_name).id}" div_id = "context_#{@current_user.contexts.where(:name => context_name).first.id}"
contexts = page.all("div.context").map { |x| x[:id] } contexts = page.all("div.context").map { |x| x[:id] }
return contexts.find_index(div_id) return contexts.find_index(div_id)
end end
def project_list_find_index(project_name) def project_list_find_index(project_name)
# TODO: refactor with context_list_find_index # TODO: refactor with context_list_find_index
div_id = "project_#{@current_user.projects.find_by_name(project_name).id}" div_id = "project_#{@current_user.projects.where(:name => project_name).first.id}"
project = page.all("div.project").map { |x| x[:id] } project = page.all("div.project").map { |x| x[:id] }
return project.find_index(div_id) return project.find_index(div_id)
end end