2010-03-02 11:14:45 +01:00
|
|
|
Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos|
|
|
|
|
|
context = @current_user.contexts.create!(:name => "Context A")
|
|
|
|
|
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
|
|
|
|
|
user.projects.create!(:name => project_name)
|
|
|
|
|
end
|
|
|
|
|
|
2010-03-02 11:14:45 +01:00
|
|
|
When /^I visit the "([^\"]*)" project$/ do |project_name|
|
|
|
|
|
@project = Project.find_by_name(project_name)
|
|
|
|
|
@project.should_not be_nil
|
|
|
|
|
visit project_path(@project)
|
|
|
|
|
end
|
|
|
|
|
|
2010-07-14 15:13:20 +02:00
|
|
|
When /^I visit the project page for "([^"]*)"$/ do |project_name|
|
|
|
|
|
When "I visit the \"#{project_name}\" project"
|
|
|
|
|
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}"
|
|
|
|
|
fill_in "project[name]", :with => new_title
|
2010-07-05 09:58:25 -07:00
|
|
|
selenium.click "submit_project_#{@project.id}",
|
|
|
|
|
:wait_for => :text,
|
|
|
|
|
:element => "flash",
|
|
|
|
|
:text => "Project saved"
|
2010-07-05 08:24:58 -07:00
|
|
|
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
|
|
|
|
|
end
|