2012-01-30 09:56:58 -05:00
|
|
|
Given /^I have an outdated project "([^"]*)" with (\d+) todos$/ do |project_name, num_todos|
|
2012-03-01 20:31:16 +01:00
|
|
|
step "I have a project \"#{project_name}\" with #{num_todos} todos"
|
2012-01-30 09:56:58 -05:00
|
|
|
@project = @current_user.projects.find_by_name(project_name)
|
|
|
|
|
@project.last_reviewed = @current_user.time - @current_user.prefs.review_period.days-1
|
|
|
|
|
@project.save
|
|
|
|
|
end
|
|
|
|
|
|
2011-09-14 20:50:21 +02:00
|
|
|
Given /^I have a project "([^\"]*)" with ([0-9]+) todos$/ do |project_name, num_todos|
|
2011-08-11 17:13:01 +02:00
|
|
|
@context = @current_user.contexts.find_or_create_by_name("Context A")
|
|
|
|
|
@project = @current_user.projects.create!(:name => project_name)
|
2011-09-14 13:49:06 +02:00
|
|
|
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
|
|
|
|
|
@project.move_to_bottom
|
|
|
|
|
|
2011-09-14 20:50:21 +02:00
|
|
|
@todos=[]
|
2010-03-02 11:14:45 +01:00
|
|
|
1.upto num_todos.to_i do |i|
|
2011-09-14 20:50:21 +02:00
|
|
|
todo = @current_user.todos.create!(
|
2011-08-11 17:13:01 +02:00
|
|
|
:project_id => @project.id,
|
|
|
|
|
:context_id => @context.id,
|
|
|
|
|
:description => "todo #{i}")
|
2011-09-14 20:50:21 +02:00
|
|
|
@todos << todo
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have a project "([^\"]*)" with ([0-9]+) deferred todos$/ do |project_name, num_todos|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I have a project \"#{project_name}\" with #{num_todos} todos"
|
2011-09-14 20:50:21 +02:00
|
|
|
@todos.each do |todo|
|
|
|
|
|
todo.show_from = Time.zone.now + 1.week
|
|
|
|
|
todo.save!
|
2010-03-02 11:14:45 +01:00
|
|
|
end
|
2010-02-12 12:35:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^there exists a project "([^\"]*)" for user "([^\"]*)"$/ do |project_name, user_name|
|
|
|
|
|
user = User.find_by_login(user_name)
|
|
|
|
|
user.should_not be_nil
|
2010-08-12 14:39:58 +02:00
|
|
|
@project = user.projects.create!(:name => project_name)
|
2011-09-14 13:49:06 +02:00
|
|
|
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
|
|
|
|
|
@project.move_to_bottom
|
2010-02-12 12:35:19 +01:00
|
|
|
end
|
|
|
|
|
|
2010-07-30 21:06:12 +02:00
|
|
|
Given /^there exists a project called "([^"]*)" for user "([^"]*)"$/ do |project_name, login|
|
|
|
|
|
# TODO: regexp change to integrate this with the previous since only 'called' is different
|
2012-02-15 21:42:06 +01:00
|
|
|
step "there exists a project \"#{project_name}\" for user \"#{login}\""
|
2010-07-30 21:06:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have a project called "([^"]*)"$/ do |project_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
|
2010-07-30 21:06:12 +02:00
|
|
|
end
|
|
|
|
|
|
2011-02-26 11:38:39 +01:00
|
|
|
Given /^I have a project "([^"]*)" with a default context of "([^"]*)"$/ do |project_name, context_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
|
2011-02-26 11:38:39 +01:00
|
|
|
context = @current_user.contexts.create!(:name => context_name)
|
|
|
|
|
@project.default_context = context
|
|
|
|
|
@project.save!
|
|
|
|
|
end
|
|
|
|
|
|
2010-11-27 17:12:09 +01:00
|
|
|
Given /^I have the following projects:$/ do |table|
|
|
|
|
|
table.hashes.each do |project|
|
2012-02-15 21:42:06 +01:00
|
|
|
step 'I have a project called "'+project[:project_name]+'"'
|
2011-09-13 11:15:14 +02:00
|
|
|
# acts_as_list puts the last added project at the top, but we want it
|
|
|
|
|
# at the bottom to be consistent with the table in the scenario
|
|
|
|
|
@project.move_to_bottom
|
|
|
|
|
@project.save!
|
2010-11-27 17:12:09 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-06-20 06:50:25 +02:00
|
|
|
Given /^I have a completed project called "([^"]*)"$/ do |project_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I have a project called \"#{project_name}\""
|
2011-06-20 06:50:25 +02:00
|
|
|
@project.complete!
|
|
|
|
|
@project.reload
|
|
|
|
|
assert @project.completed?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have (\d+) completed projects$/ do |number_of_projects|
|
|
|
|
|
1.upto number_of_projects.to_i do |i|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I have a completed project called \"Project #{i}\""
|
2011-06-20 06:50:25 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-11-27 17:12:09 +01:00
|
|
|
Given /^I have no projects$/ do
|
|
|
|
|
Project.delete_all
|
|
|
|
|
end
|
|
|
|
|
|
2011-01-08 19:50:19 +01:00
|
|
|
Given /^I have a hidden project called "([^"]*)"$/ do |project_name|
|
|
|
|
|
@project = @current_user.projects.create!(:name => project_name)
|
|
|
|
|
@project.hide!
|
|
|
|
|
end
|
|
|
|
|
|
2011-08-15 17:04:59 +02:00
|
|
|
When /^I open the project edit form$/ do
|
|
|
|
|
click_link "link_edit_project_#{@project.id}"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should have_css("button#submit_project_#{@project.id}", :visible => true)
|
2011-08-15 17:04:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I cancel the project edit form$/ do
|
|
|
|
|
click_link "cancel_project_#{@project.id}"
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
wait_until do
|
|
|
|
|
!page.has_css?("submit_project_#{@project.id}")
|
2011-08-15 17:04:59 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-02-12 12:35:19 +01:00
|
|
|
When /^I edit the project description to "([^\"]*)"$/ do |new_description|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project(@project) do
|
|
|
|
|
fill_in "project[description]", :with => new_description
|
2011-08-15 17:04:59 +02:00
|
|
|
end
|
2009-08-05 16:28:06 +02:00
|
|
|
end
|
2010-03-24 20:45:59 +01:00
|
|
|
|
2010-07-05 08:24:58 -07:00
|
|
|
When /^I edit the project name to "([^\"]*)"$/ do |new_title|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project(@project) do
|
|
|
|
|
fill_in "project[name]", :with => new_title
|
2010-11-09 23:12:21 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I try to edit the project name to "([^\"]*)"$/ do |new_title|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project_no_wait(@project) do
|
|
|
|
|
fill_in "project[name]", :with => new_title
|
2010-11-09 23:12:21 +01:00
|
|
|
end
|
2010-08-03 20:55:07 +02:00
|
|
|
end
|
|
|
|
|
|
2011-09-14 20:50:21 +02:00
|
|
|
When /^I edit the default context to "([^"]*)"$/ do |default_context|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project(@project) do
|
|
|
|
|
fill_in "project[default_context_name]", :with => default_context
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
Then /^I should (see|not see) empty message for (todos|deferred todos|completed todos) of project/ do |visible, state|
|
|
|
|
|
case state
|
|
|
|
|
when "todos"
|
|
|
|
|
css = "div#p#{@project.id}empty-nd"
|
|
|
|
|
when "deferred todos"
|
|
|
|
|
css = "div#tickler-empty-nd"
|
|
|
|
|
when "completed todos"
|
|
|
|
|
css = "div#empty-d"
|
|
|
|
|
else
|
|
|
|
|
css = "wrong state"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
elem = find(css)
|
|
|
|
|
elem.nil?.should be_false
|
|
|
|
|
elem.visible?.should(visible=="see" ? be_true : be_false)
|
2012-02-15 21:42:06 +01:00
|
|
|
end
|
|
|
|
|
|
2011-09-14 20:50:21 +02:00
|
|
|
Then /^I edit the default tags to "([^"]*)"$/ do |default_tags|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project(@project) do
|
|
|
|
|
fill_in "project[default_tags]", :with => default_tags
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-08-03 20:55:07 +02:00
|
|
|
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.should_not be_nil
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I edit the project name to \"#{project_new_name}\""
|
2010-07-05 08:24:58 -07:00
|
|
|
end
|
|
|
|
|
|
2010-11-09 23:12:21 +01:00
|
|
|
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.should_not be_nil
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I try to edit the project name to \"#{project_new_name}\""
|
2010-11-09 23:12:21 +01:00
|
|
|
end
|
|
|
|
|
|
2010-11-08 22:36:35 +01:00
|
|
|
When /^I edit the project name in place to be "([^"]*)"$/ do |new_project_name|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find("div#project_name").click
|
2010-11-08 22:36:35 +01:00
|
|
|
fill_in "value", :with => new_project_name
|
2011-02-09 20:41:34 +01:00
|
|
|
click_button "Ok"
|
2010-11-08 22:36:35 +01:00
|
|
|
end
|
2010-10-08 21:07:17 +02:00
|
|
|
|
2011-12-12 12:34:28 -06:00
|
|
|
When /^I click to edit the project name in place$/ do
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find("div#project_name").click
|
2011-12-12 12:34:28 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should be able to change the project name in place$/ do
|
|
|
|
|
#Note that this is not changing the project name
|
2012-03-01 20:31:16 +01:00
|
|
|
wait_until do
|
|
|
|
|
page.has_css? "div#project_name>form>input"
|
|
|
|
|
end
|
|
|
|
|
page.find("div#project_name > form > button[type=cancel]").click
|
2011-12-12 12:34:28 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I edit the project settings$/ do
|
|
|
|
|
@project.should_not be_nil
|
|
|
|
|
|
|
|
|
|
click_link "link_edit_project_#{@project.id}"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.has_xpath?("//div[@id='edit_project_#{@project.id}']/form//button[@id='submit_project_#{@project.id}']").should be_true
|
2011-12-12 12:34:28 -06:00
|
|
|
end
|
|
|
|
|
|
2011-12-12 21:49:29 -06:00
|
|
|
Then /^I should not be able to change the project name in place$/ do
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I click to edit the project name in place"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.has_xpath?("//div[@id='project_name']/form/input").should be_false
|
2011-12-12 12:34:28 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I close the project settings$/ do
|
2012-02-15 21:42:06 +01:00
|
|
|
@project.should_not be_nil
|
|
|
|
|
click_link "Cancel"
|
2012-03-01 20:31:16 +01:00
|
|
|
wait_for_ajax
|
|
|
|
|
wait_for_animations_to_end
|
2011-12-12 12:34:28 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2010-10-08 21:07:17 +02:00
|
|
|
When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name|
|
|
|
|
|
project = @current_user.projects.find_by_name(project_name)
|
|
|
|
|
project.should_not be_nil
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
edit_project_settings(project) do
|
|
|
|
|
choose "project_state_#{state_name}"
|
2010-10-15 11:49:34 +02:00
|
|
|
end
|
2010-10-08 21:07:17 +02:00
|
|
|
end
|
|
|
|
|
|
2010-11-24 22:01:23 +01:00
|
|
|
When /^I add a note "([^"]*)" to the project$/ do |note_body|
|
|
|
|
|
click_link "Add a note"
|
|
|
|
|
fill_in "note[body]", :with => note_body
|
|
|
|
|
click_button "Add note"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I click on the first note icon$/ do
|
|
|
|
|
@project.should_not be_nil
|
|
|
|
|
@note = @project.notes.first # assume first note is also first on screen
|
|
|
|
|
@note.should_not be_nil
|
|
|
|
|
|
|
|
|
|
click_link "link_note_#{@note.id}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I cancel adding a note to the project$/ do
|
|
|
|
|
click_link "Add a note"
|
|
|
|
|
fill_in "note[body]", :with => "will not save this"
|
|
|
|
|
click_link "neg_edit_form_note"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the form for adding a note should not be visible$/ do
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should_not have_css("edit_form_note")
|
2010-11-24 22:01:23 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should go to that note page$/ do
|
|
|
|
|
current_path = URI.parse(current_url).path
|
|
|
|
|
note_path = note_path(@note)
|
|
|
|
|
current_path.should == note_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see one note in the project$/ do
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should have_xpath("//div[@class='note_wrapper']")
|
2010-11-24 22:01:23 +01:00
|
|
|
end
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
Then /^I should see the bold text "([^\"]*)" in the project description$/ do |text_in_bold|
|
2010-03-24 20:45:59 +01:00
|
|
|
xpath="//div[@class='project_description']/p/strong"
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should have_xpath(xpath)
|
|
|
|
|
bold_text = page.find(:xpath, xpath).text
|
2011-08-11 17:13:01 +02:00
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
bold_text.should =~ /#{text_in_bold}/
|
2010-03-24 20:45:59 +01:00
|
|
|
end
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
Then /^I should see the italic text "([^\"]*)" in the project description$/ do |text_in_italic|
|
2010-03-24 20:45:59 +01:00
|
|
|
xpath="//div[@class='project_description']/p/em"
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.should have_xpath(xpath)
|
|
|
|
|
italic_text = page.find(:xpath, xpath).text
|
2010-03-24 20:45:59 +01:00
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
italic_text.should =~ /#{text_in_italic}/
|
2010-04-10 15:23:38 -04:00
|
|
|
end
|
2010-07-05 08:24:58 -07:00
|
|
|
|
|
|
|
|
Then /^the project title should be "(.*)"$/ do |title|
|
2012-03-01 20:31:16 +01:00
|
|
|
wait_until do
|
|
|
|
|
page.find("h2#project_name_container div#project_name").text == title
|
2011-09-14 20:50:21 +02:00
|
|
|
end
|
2010-11-08 22:36:35 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see the project name is "([^"]*)"$/ do |project_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "the project title should be \"#{project_name}\""
|
2011-02-26 11:38:39 +01:00
|
|
|
end
|
2012-03-01 20:31:16 +01:00
|
|
|
|
|
|
|
|
Then /^I should (see|not see) the default project settings$/ do |visible|
|
|
|
|
|
default_settings = "This project is active with no default context and with no default tags"
|
|
|
|
|
if visible == "see"
|
|
|
|
|
elem = page.find("div.project_settings")
|
|
|
|
|
elem.visible?.should be_true
|
|
|
|
|
elem.text.should =~ /#{default_settings}/
|
|
|
|
|
else
|
|
|
|
|
elem = page.find("div.project_settings")
|
|
|
|
|
elem.visible?.should be_false
|
|
|
|
|
end
|
|
|
|
|
end
|