mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-01 02:20:16 +01:00
add scenario to show bug #972
took me a while to figure out that drag_and_drop does not wait for ajax to finish
This commit is contained in:
parent
8191268821
commit
c0db9b41b9
5 changed files with 88 additions and 41 deletions
|
|
@ -140,8 +140,8 @@ class TodosController < ApplicationController
|
|||
|
||||
def add_predecessor
|
||||
@source_view = params['_source_view'] || 'todo'
|
||||
@predecessor = Todo.find(params['predecessor'])
|
||||
@todo = Todo.find(params['successor'])
|
||||
@predecessor = current_user.todos.find(params['predecessor'])
|
||||
@todo = current_user.todos.find(params['successor'])
|
||||
@original_state = @todo.state
|
||||
# Add predecessor
|
||||
@todo.add_predecessor(@predecessor)
|
||||
|
|
@ -154,7 +154,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def remove_predecessor
|
||||
@source_view = params['_source_view'] || 'todo'
|
||||
@predecessor = Todo.find(params['predecessor'])
|
||||
@predecessor = current_user.todos.find(params['predecessor'])
|
||||
@successor = @todo
|
||||
@removed = @successor.remove_predecessor(@predecessor)
|
||||
respond_to do |format|
|
||||
|
|
|
|||
|
|
@ -12,9 +12,14 @@ Feature: dependencies
|
|||
|
||||
@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"
|
||||
Given I have a project "dependencies" with 3 todos
|
||||
And "Todo 2" depends on "Todo 1"
|
||||
When I visit the "dependencies" project
|
||||
And I drag "Todo 3" to "Todo 2"
|
||||
Then the dependencies of "Todo 2" should include "Todo 1"
|
||||
And the dependencies of "Todo 3" should include "Todo 2"
|
||||
When I expand the dependencies of "Todo 1"
|
||||
Then I should see "Todo 2" within the dependencies of "Todo 1"
|
||||
And I should see "Todo 3" within the dependencies of "Todo 1"
|
||||
When I expand the dependencies of "Todo 2"
|
||||
Then I should see "Todo 3" within the dependencies of "Todo 2"
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
Given /^I have one project "([^\"]*)" with no notes$/ do |project_name|
|
||||
@current_user.projects.create!(:name => project_name)
|
||||
end
|
||||
|
||||
Given /^I have two projects with one note each$/ do
|
||||
project_a = @current_user.projects.create!(:name => 'project A')
|
||||
project_a.notes.create!(:user_id => @current_user.id, :body => 'note for project A')
|
||||
|
|
@ -5,26 +9,38 @@ Given /^I have two projects with one note each$/ do
|
|||
project_b.notes.create!(:user_id => @current_user.id, :body => 'note for project B')
|
||||
end
|
||||
|
||||
Then /^(.*) notes should be visible$/ do |number|
|
||||
# count number of project_notes
|
||||
count = 0
|
||||
response.should have_xpath("//div[@class='project_notes']") { |nodes| nodes.each { |n| count += 1 }}
|
||||
count.should == number.to_i
|
||||
Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num|
|
||||
project = @current_user.projects.create!(:name => project_name)
|
||||
1.upto num.to_i do |i|
|
||||
project.notes.create!(:user_id => @current_user.id, :body => "A note #{i}. This is the very long body of note #{i} where you should not see the last part of the note after 50 characters")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I click Toggle Notes$/ do
|
||||
click_link 'Toggle notes'
|
||||
end
|
||||
|
||||
Given /^I have one project "([^\"]*)" with no notes$/ do |project_name|
|
||||
@current_user.projects.create!(:name => project_name)
|
||||
end
|
||||
|
||||
When /^I add note "([^\"]*)" from the "([^\"]*)" project page$/ do |note, project|
|
||||
project = Project.find_by_name(project)
|
||||
project.notes.create!(:user_id => @current_user.id, :body => note)
|
||||
end
|
||||
|
||||
When /^I delete the first note$/ do
|
||||
click_link "delete note"
|
||||
selenium.get_confirmation.should == "Are you sure that you want to delete the note '1'?"
|
||||
end
|
||||
|
||||
When /^I click the icon next to the note$/ do
|
||||
click_link "Show note"
|
||||
end
|
||||
|
||||
Then /^(.*) notes should be visible$/ do |number|
|
||||
# count number of project_notes
|
||||
count = 0
|
||||
response.should have_xpath("//div[@class='project_notes']") { |nodes| nodes.each { |n| count += 1 }}
|
||||
count.should == number.to_i
|
||||
end
|
||||
|
||||
Then /^I should see note "([^\"]*)" on the "([^\"]*)" project page$/ do |note, project|
|
||||
project = Project.find_by_name(project)
|
||||
visit project_path(project)
|
||||
|
|
@ -36,26 +52,11 @@ Then /^I should see note "([^\"]*)" on the notes page$/ do |note|
|
|||
Then "I should see \"#{note}\""
|
||||
end
|
||||
|
||||
Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num|
|
||||
project = @current_user.projects.create!(:name => project_name)
|
||||
1.upto num.to_i do |i|
|
||||
project.notes.create!(:user_id => @current_user.id, :body => "A note #{i}. This is the very long body of note #{i} where you should not see the last part of the note after 50 characters")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I delete the first note$/ do
|
||||
click_link "delete note"
|
||||
selenium.get_confirmation.should == "Are you sure that you want to delete the note '1'?"
|
||||
end
|
||||
|
||||
Then /^the first note should disappear$/ do
|
||||
# the first note contains "A note 1", generated by the Given def above
|
||||
Then "I should not see \"A note 1\""
|
||||
end
|
||||
|
||||
When /^I click the icon next to the note$/ do
|
||||
click_link "Show note"
|
||||
end
|
||||
|
||||
Then /^I should see the note text$/ do
|
||||
Then "I should see \"after 50 characters\""
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
When /^I visit the "([^\"]*)" project$/ do |project_name|
|
||||
@project = Project.find_by_name(project_name)
|
||||
@project.should_not be_nil
|
||||
visit project_path(@project)
|
||||
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
|
||||
end
|
||||
|
||||
Given /^there exists a project "([^\"]*)" for user "([^\"]*)"$/ do |project_name, user_name|
|
||||
|
|
@ -10,6 +15,12 @@ Given /^there exists a project "([^\"]*)" for user "([^\"]*)"$/ do |project_name
|
|||
user.projects.create!(:name => project_name)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
When /^I edit the project description to "([^\"]*)"$/ do |new_description|
|
||||
click_link "link_edit_project_#{@project.id}"
|
||||
fill_in "project[description]", new_description
|
||||
|
|
|
|||
|
|
@ -38,7 +38,19 @@ When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
|
|||
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)
|
||||
|
||||
arrow = "xpath=//div[@id='line_todo_#{drop_id}']/div/a[@class='show_successors']/img"
|
||||
selenium.wait_for_element(arrow)
|
||||
end
|
||||
|
||||
When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
|
||||
todo = Todo.find_by_description(todo_name)
|
||||
todo.should_not be_nil
|
||||
|
||||
expand_img_locator = "xpath=//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
|
||||
selenium.click(expand_img_locator)
|
||||
end
|
||||
|
||||
Then /^I should see ([0-9]+) todos$/ do |count|
|
||||
|
|
@ -47,7 +59,25 @@ Then /^I should see ([0-9]+) todos$/ do |count|
|
|||
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
|
||||
Then /^the dependencies of "(.*)" should include "(.*)"$/ do |child_name, parent_name|
|
||||
parent = @current_user.todos.find_by_description(parent_name)
|
||||
parent.should_not be_nil
|
||||
|
||||
child = parent.pending_successors.find_by_description(child_name)
|
||||
child.should_not be_nil
|
||||
end
|
||||
|
||||
Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description|
|
||||
todo = @current_user.todos.find_by_description(todo_description)
|
||||
todo.should_not be_nil
|
||||
successor = @current_user.todos.find_by_description(successor_description)
|
||||
successor.should_not be_nil
|
||||
|
||||
# argh, webrat on selenium does not support within, so this won't work
|
||||
# xpath = "//div[@id='line_todo_#{todo.id}'"
|
||||
# Then "I should see \"#{successor_description}\" within \"xpath=#{xpath}\""
|
||||
|
||||
# let selenium look for the presence of the successor
|
||||
xpath = "xpath=//div[@id='line_todo_#{todo.id}']//div[@id='successor_line_todo_#{successor.id}']//span"
|
||||
selenium.wait_for_element(xpath)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue