2010-03-02 11:14:45 +01:00
|
|
|
Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos|
|
2010-10-22 11:55:54 +02:00
|
|
|
context = @current_user.contexts.find_or_create_by_name("Context A")
|
2010-03-02 11:14:45 +01:00
|
|
|
project = @current_user.projects.create!(:name => project_name)
|
|
|
|
|
1.upto num_todos.to_i do |i|
|
|
|
|
|
@current_user.todos.create!(
|
|
|
|
|
:project_id => project.id,
|
|
|
|
|
:context_id => context.id,
|
|
|
|
|
:description => "Todo #{i}")
|
|
|
|
|
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)
|
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
|
|
|
|
|
Given "there exists a project \"#{project_name}\" for user \"#{login}\""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Given /^I have a project called "([^"]*)"$/ do |project_name|
|
|
|
|
|
Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
|
|
|
|
|
end
|
|
|
|
|
|
2011-02-26 11:38:39 +01:00
|
|
|
Given /^I have a project "([^"]*)" with a default context of "([^"]*)"$/ do |project_name, context_name|
|
|
|
|
|
Given "there exists a project \"#{project_name}\" for user \"#{@current_user.login}\""
|
|
|
|
|
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|
|
|
|
|
|
Given 'I have a project called "'+project[:project_name]+'"'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-06-20 06:50:25 +02:00
|
|
|
Given /^I have a completed project called "([^"]*)"$/ do |project_name|
|
|
|
|
|
Given "I have a project called \"#{project_name}\""
|
|
|
|
|
@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|
|
|
|
|
|
Given "I have a completed project called \"Project #{i}\""
|
|
|
|
|
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
|
|
|
|
|
|
2010-02-12 12:35:19 +01:00
|
|
|
When /^I edit the project description to "([^\"]*)"$/ do |new_description|
|
|
|
|
|
click_link "link_edit_project_#{@project.id}"
|
2010-03-24 20:45:59 +01:00
|
|
|
fill_in "project[description]", :with => new_description
|
2010-02-12 12:35:19 +01:00
|
|
|
click_button "submit_project_#{@project.id}"
|
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|
|
|
|
|
|
click_link "link_edit_project_#{@project.id}"
|
2010-11-09 23:12:21 +01:00
|
|
|
|
|
|
|
|
wait_for do
|
|
|
|
|
selenium.is_element_present("submit_project_#{@project.id}")
|
|
|
|
|
end
|
2010-10-08 21:07:17 +02:00
|
|
|
|
2010-07-05 08:24:58 -07:00
|
|
|
fill_in "project[name]", :with => new_title
|
2010-08-03 20:55:07 +02:00
|
|
|
|
2010-07-05 09:58:25 -07:00
|
|
|
selenium.click "submit_project_#{@project.id}",
|
|
|
|
|
:wait_for => :text,
|
2010-11-09 23:12:21 +01:00
|
|
|
:text => "Project saved",
|
|
|
|
|
:timeout => 5
|
|
|
|
|
|
|
|
|
|
wait_for do
|
|
|
|
|
!selenium.is_element_present("submit_context_#{@project.id}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I try to edit the project name to "([^\"]*)"$/ do |new_title|
|
|
|
|
|
click_link "link_edit_project_#{@project.id}"
|
|
|
|
|
|
|
|
|
|
wait_for do
|
|
|
|
|
selenium.is_element_present("submit_project_#{@project.id}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
fill_in "project[name]", :with => new_title
|
|
|
|
|
|
|
|
|
|
selenium.click "submit_project_#{@project.id}",
|
|
|
|
|
:wait_for => :text,
|
|
|
|
|
:text => "There were problems with the following fields:",
|
|
|
|
|
:timeout => 5
|
2010-08-03 20:55:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
When "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
|
|
|
|
|
When "I try to edit the project name to \"#{project_new_name}\""
|
|
|
|
|
end
|
|
|
|
|
|
2010-11-08 22:36:35 +01:00
|
|
|
When /^I edit the project name in place to be "([^"]*)"$/ do |new_project_name|
|
|
|
|
|
selenium.click "project_name"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
click_link "link_edit_project_#{project.id}"
|
|
|
|
|
selenium.wait_for_element("xpath=//div[@id='edit_project_#{project.id}']/form//button[@id='submit_project_#{project.id}']")
|
|
|
|
|
|
|
|
|
|
choose "project_state_#{state_name}"
|
|
|
|
|
|
|
|
|
|
# changed to make sure selenium waits until the saving has a result either
|
|
|
|
|
# positive or negative. Was: :element=>"flash", :text=>"Project saved"
|
|
|
|
|
# we may need to change it back if you really need a positive outcome, i.e.
|
|
|
|
|
# this step needs to fail if the project was not saved successfully
|
|
|
|
|
selenium.click "submit_project_#{project.id}",
|
|
|
|
|
:wait_for => :text,
|
|
|
|
|
:text => /(Project saved|1 error prohibited this project from being saved)/
|
|
|
|
|
|
2010-10-15 11:49:34 +02:00
|
|
|
wait_for do # wait for the form to go away
|
|
|
|
|
!selenium.is_element_present("submit_project_#{project.id}")
|
|
|
|
|
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
|
|
|
|
|
wait_for do # wait for the form to go away
|
|
|
|
|
!selenium.is_visible("edit_form_note")
|
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
selenium.wait_for_element("xpath=//div[@class='note_wrapper']")
|
|
|
|
|
end
|
|
|
|
|
|
2010-03-24 20:45:59 +01:00
|
|
|
Then /^I should see the bold text "([^\"]*)" in the project description$/ do |bold|
|
|
|
|
|
xpath="//div[@class='project_description']/p/strong"
|
|
|
|
|
|
|
|
|
|
response.should have_xpath(xpath)
|
|
|
|
|
bold_text = response.selenium.get_text("xpath=#{xpath}")
|
|
|
|
|
|
|
|
|
|
bold_text.should =~ /#{bold}/
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see the italic text "([^\"]*)" in the project description$/ do |italic|
|
|
|
|
|
xpath="//div[@class='project_description']/p/em"
|
|
|
|
|
|
|
|
|
|
response.should have_xpath(xpath)
|
|
|
|
|
italic_text = response.selenium.get_text("xpath=#{xpath}")
|
|
|
|
|
|
|
|
|
|
italic_text.should =~ /#{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|
|
|
|
|
|
selenium.get_text("css=h2#project_name").should == title
|
2010-11-08 22:36:35 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see the project name is "([^"]*)"$/ do |project_name|
|
|
|
|
|
Then "the project title should be \"#{project_name}\""
|
2011-02-26 11:38:39 +01:00
|
|
|
end
|