From 8191268821da91eccc949076b35198dcd5ae01c0 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Mon, 22 Feb 2010 11:35:00 +0100 Subject: [PATCH] add drag and drop feature for dependencies --- features/dependencies.feature | 20 ++++++++++++++++++++ features/step_definitions/todo_steps.rb | 22 ++++++++++++++++++++++ features/support/selenium.rb | 1 + 3 files changed, 43 insertions(+) create mode 100644 features/dependencies.feature diff --git a/features/dependencies.feature b/features/dependencies.feature new file mode 100644 index 00000000..038c6e02 --- /dev/null +++ b/features/dependencies.feature @@ -0,0 +1,20 @@ +Feature: dependencies + + As a Tracks user + In order to keep track of complex todos + I want to assign and manage todo dependencies + + Background: + Given the following user record + | login | password | is_admin | + | testuser | secret | false | + And I have logged in as "testuser" with password "secret" + + @selenium + Scenario: Adding dependency to dependency + Given I have 3 todos + And "todo 2" depends on "todo 1" + When I go to the home page + And I drag "todo 3" to "todo 1" + Then the dependencies of "todo 1" should include "todo 2" + And the dependencies of "todo 1" should include "todo 3" \ No newline at end of file diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index bd366f4c..e97d302d 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -24,8 +24,30 @@ Given /^I have ([0-9]+) completed todos$/ do |count| end end +Given /^"(.*)" depends on "(.*)"$/ do |successor_name, predecessor_name| + successor = Todo.find_by_description(successor_name) + predecessor = Todo.find_by_description(predecessor_name) + + successor.add_predecessor(predecessor) + successor.state = "pending" + successor.save! +end + +When /^I drag "(.*)" to "(.*)"$/ do |dragged, target| + drag_id = Todo.find_by_description(dragged).id + drop_id = Todo.find_by_description(target).id + drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']" + drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//div[@class='description']" + selenium.drag_and_drop_to_object(drag_name, drop_name) +end + Then /^I should see ([0-9]+) todos$/ do |count| count.to_i.downto 1 do |i| match_xpath "div[" end +end + +Then /^the dependencies of "(.*)" should include "(.*)"$/ do |parent_name, child_name| + parent_id = Todo.find_by_description(parent_name).id + assert_contain(parent_name) end \ No newline at end of file diff --git a/features/support/selenium.rb b/features/support/selenium.rb index 3796a754..af319c12 100644 --- a/features/support/selenium.rb +++ b/features/support/selenium.rb @@ -2,6 +2,7 @@ Webrat.configure do |config| config.mode = :selenium config.application_environment = :selenium config.selenium_browser_startup_timeout = 30 + #config.selenium_server_address = "localhost" end Cucumber::Rails::World.use_transactional_fixtures = false