2010-10-07 23:24:50 +02:00
|
|
|
When /^I delete project "([^"]*)"$/ do |project_name|
|
|
|
|
|
project = @current_user.projects.find_by_name(project_name)
|
|
|
|
|
project.should_not be_nil
|
2012-03-01 20:31:16 +01:00
|
|
|
|
|
|
|
|
handle_js_confirm do
|
|
|
|
|
click_link "delete_project_#{project.id}"
|
|
|
|
|
end
|
|
|
|
|
get_confirm_text.should == "Are you sure that you want to delete the project '#{project_name}'?"
|
|
|
|
|
|
|
|
|
|
wait_until do
|
|
|
|
|
!page.has_css?("a#delete_project_#{project.id}")
|
2010-10-07 23:24:50 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-15 11:49:34 +02:00
|
|
|
When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_drop|
|
|
|
|
|
drag_id = @current_user.projects.find_by_name(project_drag).id
|
2012-03-01 20:31:16 +01:00
|
|
|
sortable_css = "div.ui-sortable div#container_project_#{drag_id}"
|
2010-10-15 11:49:34 +02:00
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
drag_index = project_list_find_index(project_drag)
|
|
|
|
|
drop_index = project_list_find_index(project_drop)
|
|
|
|
|
|
|
|
|
|
page.execute_script "$('#{sortable_css}').simulateDragSortable({move: #{drop_index-drag_index}, handle: '.grip'});"
|
2010-10-15 11:49:34 +02:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 16:45:08 +02:00
|
|
|
When /^I submit a new project with name "([^"]*)"$/ do |project_name|
|
|
|
|
|
fill_in "project[name]", :with => project_name
|
|
|
|
|
submit_new_project_form
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-16 17:22:55 +02:00
|
|
|
When /^I submit a new project with name "([^"]*)" and select take me to the project$/ do |project_name|
|
|
|
|
|
fill_in "project[name]", :with => project_name
|
|
|
|
|
check "go_to_project"
|
|
|
|
|
submit_new_project_form
|
|
|
|
|
end
|
|
|
|
|
|
2010-10-22 11:55:54 +02:00
|
|
|
When /^I sort the active list alphabetically$/ do
|
2012-03-01 20:31:16 +01:00
|
|
|
handle_js_confirm do
|
|
|
|
|
click_link "Alphabetically"
|
|
|
|
|
wait_for_ajax
|
|
|
|
|
end
|
|
|
|
|
get_confirm_text.should == "Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order."
|
2010-10-20 09:00:04 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
When /^I sort the list by number of tasks$/ do
|
2012-03-01 20:31:16 +01:00
|
|
|
handle_js_confirm do
|
|
|
|
|
click_link "By number of tasks"
|
|
|
|
|
wait_for_ajax
|
|
|
|
|
end
|
|
|
|
|
get_confirm_text.should == "Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order."
|
2010-10-20 09:00:04 +02:00
|
|
|
end
|
|
|
|
|
|
2010-11-08 22:36:35 +01:00
|
|
|
Then /^I should see that a project named "([^"]*)" is not present$/ do |project_name|
|
2012-03-01 20:31:16 +01:00
|
|
|
within "div#display_box" do
|
|
|
|
|
step "I should not see \"#{project_name}\""
|
|
|
|
|
end
|
2010-11-08 22:36:35 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see that a project named "([^"]*)" is present$/ do |project_name|
|
2012-03-01 20:31:16 +01:00
|
|
|
within "div#display_box" do
|
|
|
|
|
step "I should see \"#{project_name}\""
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see a project named "([^"]*)"$/ do |project_name|
|
|
|
|
|
step "I should see that a project named \"#{project_name}\" is present"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should not see a project named "([^"]*)"$/ do |project_name|
|
|
|
|
|
step "I should see that a project named \"#{project_name}\" is not present"
|
2010-11-08 22:36:35 +01:00
|
|
|
end
|
|
|
|
|
|
2010-10-15 11:49:34 +02:00
|
|
|
Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low|
|
2012-03-01 20:31:16 +01:00
|
|
|
project_list_find_index(project_high).should < project_list_find_index(project_low)
|
2010-10-15 11:49:34 +02:00
|
|
|
end
|
|
|
|
|
|
2010-10-08 21:07:17 +02:00
|
|
|
Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name|
|
|
|
|
|
project = @current_user.projects.find_by_name(project_name)
|
|
|
|
|
project.should_not be_nil
|
2012-03-12 21:50:53 +01:00
|
|
|
|
|
|
|
|
list_id = @source_view=="review" ? "list-#{state}-projects" : "list-#{state_name}-projects-container"
|
|
|
|
|
xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']"
|
|
|
|
|
|
|
|
|
|
page.should_not have_xpath(xpath)
|
2010-10-08 21:07:17 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name|
|
|
|
|
|
project = @current_user.projects.find_by_name(project_name)
|
|
|
|
|
project.should_not be_nil
|
2012-03-12 21:50:53 +01:00
|
|
|
|
|
|
|
|
list_id = @source_view=="review" ? "list-#{state_name}-projects" : "list-#{state_name}-projects-container"
|
|
|
|
|
xpath = "//div[@id='#{list_id}']//div[@id='project_#{project.id}']"
|
|
|
|
|
|
|
|
|
|
page.should have_xpath(xpath)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I see the project "([^"]*)" in the "([^"]*)" list$/ do |project_name, state_name|
|
|
|
|
|
step "the project \"#{project_name}\" should be in state list \"#{state_name}\""
|
2010-10-08 21:07:17 +02:00
|
|
|
end
|
|
|
|
|
|
2010-10-07 23:24:50 +02:00
|
|
|
Then /^the project list badge for "([^"]*)" projects should show (\d+)$/ do |state_name, count|
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find(:xpath, "//span[@id='#{state_name}-projects-count']").text.should == count
|
2010-10-15 12:39:29 +02:00
|
|
|
end
|
|
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
Then /^the new project form should be visible$/ do
|
2012-03-12 21:50:53 +01:00
|
|
|
page.should have_css("div#project_new", :visible => true)
|
2010-10-15 12:39:29 +02:00
|
|
|
end
|
2011-10-20 12:10:24 -05:00
|
|
|
|
2012-03-01 20:31:16 +01:00
|
|
|
Then /^the new project form should not be visible$/ do
|
2012-03-19 14:05:54 +01:00
|
|
|
page.should_not have_css("div#project_new", :visible => true)
|
2011-10-20 12:10:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |name, count|
|
|
|
|
|
project = @current_user.projects.find_by_name(name)
|
|
|
|
|
project.should_not be_nil
|
|
|
|
|
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find(:xpath, xpath).text.should == "#{project.name} (#{count} actions)"
|
2011-10-20 12:10:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |name, deferred|
|
|
|
|
|
project = @current_user.projects.find_by_name(name)
|
|
|
|
|
project.should_not be_nil
|
|
|
|
|
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
2012-03-01 20:31:16 +01:00
|
|
|
page.find(:xpath, xpath).text.should == "#{project.name} (#{deferred} deferred actions)"
|
|
|
|
|
end
|