migrate dependencies and admin feature

This commit is contained in:
Reinier Balt 2012-02-03 15:57:23 +01:00
parent c8ab797924
commit d193e21ee0
11 changed files with 70 additions and 117 deletions

View file

@ -16,7 +16,7 @@
<%= hidden_field "user", "login", :value => session[:cas_user] %> <%= hidden_field "user", "login", :value => session[:cas_user] %>
<%= hidden_field "user", "password", :value => session[:cas_user] %> <%= hidden_field "user", "password", :value => session[:cas_user] %>
<%= hidden_field "user", "password_confirmation", :value => session[:cas_user] %> <%= hidden_field "user", "password_confirmation", :value => session[:cas_user] %>
<%= hidden_field"user", "auth_type", :value => "cas" %></td> <%= hidden_field "user", "auth_type", :value => "cas" %></td>
</tr> </tr>
<%else%> <%else%>
<tr> <tr>

View file

@ -4,5 +4,5 @@ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'pr
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip" std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
%> %>
default: <%= std_opts %> features default: <%= std_opts %> features
wip: --tags @wip:3 --wip features wip: --tags @wip:10 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip

View file

@ -103,7 +103,7 @@ Feature: Manage the list of contexts
And I add a new active context "foo, bar" And I add a new active context "foo, bar"
Then I should see "Name cannot contain the comma" Then I should see "Name cannot contain the comma"
@javascript @wip @javascript
Scenario: I can drag and drop to order the contexts Scenario: I can drag and drop to order the contexts
Given I have the following contexts Given I have the following contexts
| context | | context |

View file

@ -9,7 +9,7 @@ Feature: dependencies
| testuser | secret | false | | testuser | secret | false |
And I have logged in as "testuser" with password "secret" And I have logged in as "testuser" with password "secret"
@selenium @javascript @webkit_only
Scenario: Adding dependency to dependency by drag and drop Scenario: Adding dependency to dependency by drag and drop
Given I have a project "dependencies" with 3 todos Given I have a project "dependencies" with 3 todos
And "todo 2" depends on "todo 1" And "todo 2" depends on "todo 1"
@ -23,7 +23,7 @@ Feature: dependencies
When I expand the dependencies of "todo 2" When I expand the dependencies of "todo 2"
Then I should see "todo 3" within the dependencies of "todo 2" Then I should see "todo 3" within the dependencies of "todo 2"
@selenium @javascript
Scenario: I can edit a todo to add the todo as a dependency to another Scenario: I can edit a todo to add the todo as a dependency to another
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -43,7 +43,7 @@ Feature: dependencies
Then I should see "test 1" within the dependencies of "test 3" Then I should see "test 1" within the dependencies of "test 3"
Then I should see "test 2" within the dependencies of "test 3" Then I should see "test 2" within the dependencies of "test 3"
@selenium @javascript
Scenario: I can remove a dependency by editing the todo Scenario: I can remove a dependency by editing the todo
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -57,7 +57,7 @@ Feature: dependencies
Then I should not see "test 1" within the dependencies of "test 2" Then I should not see "test 1" within the dependencies of "test 2"
And I should not see "test 1" in the deferred container And I should not see "test 1" in the deferred container
@selenium @javascript
Scenario: Completing a predecessor will activate successors Scenario: Completing a predecessor will activate successors
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -75,7 +75,7 @@ Feature: dependencies
And I should not see "test 2" in the deferred container And I should not see "test 2" in the deferred container
And I should see the empty message in the deferred container And I should see the empty message in the deferred container
@selenium @javascript @selenium_only
Scenario: Deleting a predecessor will activate successors Scenario: Deleting a predecessor will activate successors
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -88,11 +88,11 @@ Feature: dependencies
Then I should see "test 2" in the deferred container Then I should see "test 2" in the deferred container
And I should see "test 1" in the action container And I should see "test 1" in the action container
When I delete the action "test 1" When I delete the action "test 1"
And I should see "test 2" in the action container Then I should see "test 2" in the action container
And I should not see "test 2" in the deferred container And I should not see "test 2" in the deferred container
And I should see the empty message in the deferred container And I should see the empty message in the deferred container
@selenium @javascript @selenium_only
Scenario: Deleting a successor will update predecessor Scenario: Deleting a successor will update predecessor
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -111,7 +111,7 @@ Feature: dependencies
Then I should see "test 3" within the dependencies of "test 1" Then I should see "test 3" within the dependencies of "test 1"
And I should not see "test 2" And I should not see "test 2"
@selenium @javascript @webkit_only
Scenario: Dragging an action to a completed action will not add it as a dependency Scenario: Dragging an action to a completed action will not add it as a dependency
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -124,7 +124,7 @@ Feature: dependencies
Then I should see an error flash message saying "Cannot add this action as a dependency to a completed action!" Then I should see an error flash message saying "Cannot add this action as a dependency to a completed action!"
And I should see "test 1" in project container for "dependencies" And I should see "test 1" in project container for "dependencies"
@selenium @javascript @webkit_only
Scenario Outline: Marking a successor as complete will update predecessor Scenario Outline: Marking a successor as complete will update predecessor
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos
@ -146,7 +146,7 @@ Feature: dependencies
| "dependencies" project | | "dependencies" project |
| tag page for "bla" | | tag page for "bla" |
@selenium @javascript @webkit_only
Scenario Outline: Marking a successor as active will update predecessor Scenario Outline: Marking a successor as active will update predecessor
Given I have a context called "@pc" Given I have a context called "@pc"
And I have a project "dependencies" that has the following todos And I have a project "dependencies" that has the following todos

View file

@ -44,10 +44,7 @@ Then /^I should see the container for context "([^"]*)"$/ do |context_name|
context.should_not be_nil context.should_not be_nil
xpath = "//div[@id='c#{context.id}']" xpath = "//div[@id='c#{context.id}']"
page.should have_xpath(xpath)
wait_for :timeout => 5 do
selenium.is_visible(xpath)
end
end end
Then /^the container for the context "([^"]*)" should be visible$/ do |context_name| Then /^the container for the context "([^"]*)" should be visible$/ do |context_name|
@ -61,9 +58,7 @@ Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_
todo.should_not be_nil todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do page.should have_xpath(xpath)
selenium.is_visible(xpath)
end
end end
Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name|
@ -73,13 +68,7 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
todo.should_not be_nil todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
page.should_not have_xpath(xpath)
if selenium.is_element_present(xpath)
# give jquery some time to finish
wait_for :timeout_in_seconds => 5 do
!selenium.is_visible(xpath)
end
end
end end
####### Deferred ####### ####### Deferred #######
@ -88,22 +77,14 @@ Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']" page.should have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description| Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']" page.should_not have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end end
####### Project ####### ####### Project #######
@ -113,10 +94,7 @@ Then /^I should see "([^"]*)" in the action container$/ do |todo_description|
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
page.should have_xpath(xpath)
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end end
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name| Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
@ -127,12 +105,7 @@ Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |to
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
page.should_not have_xpath(xpath)
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
end end
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name| Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
@ -143,9 +116,7 @@ Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_desc
project.should_not be_nil project.should_not be_nil
xpath = "//div[@id='p#{project.id}items']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='p#{project.id}items']//div[@id='line_todo_#{todo.id}']"
page.should have_xpath(xpath)
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
end end
####### Completed ####### ####### Completed #######
@ -155,10 +126,7 @@ Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
page.should have_xpath(xpath)
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end end
Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description| Then /^I should not see "([^"]*)" in the completed container$/ do |todo_description|
@ -166,12 +134,7 @@ Then /^I should not see "([^"]*)" in the completed container$/ do |todo_descript
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
page.should_not have_xpath(xpath)
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
end end
####### Hidden ####### ####### Hidden #######
@ -181,10 +144,7 @@ Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
todo.should_not be_nil todo.should_not be_nil
xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']" xpath = "//div[@id='hidden']//div[@id='line_todo_#{todo.id}']"
page.should have_xpath(xpath)
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end end
####### Calendar ####### ####### Calendar #######
@ -194,7 +154,7 @@ Then /^I should see "([^"]*)" in the due next month container$/ do |todo_descrip
todo.should_not be_nil todo.should_not be_nil
within "div#due_after_this_month" do within "div#due_after_this_month" do
find("div#line_todo_#{todo.id}").should_not be_nil page.should have_css("div#line_todo_#{todo.id}")
end end
end end

View file

@ -10,20 +10,20 @@ end
When /^I drag "(.*)" to "(.*)"$/ do |dragged, target| When /^I drag "(.*)" to "(.*)"$/ do |dragged, target|
drag_id = Todo.find_by_description(dragged).id drag_id = Todo.find_by_description(dragged).id
drop_id = Todo.find_by_description(target).id drop_id = Todo.find_by_description(target).id
drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']" drag_elem = page.find(:xpath, "//div[@id='line_todo_#{drag_id}']//img[@class='grip']")
drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//div[@class='description']" drop_elem = page.find(:xpath, "//div[@id='line_todo_#{drop_id}']//div[@class='description']")
selenium.drag_and_drop_to_object(drag_name, drop_name) drag_elem.drag_to(drop_elem)
wait_for_ajax
end end
When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name| When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
todo = Todo.find_by_description(todo_name) todo = Todo.find_by_description(todo_name)
todo.should_not be_nil todo.should_not be_nil
expand_img_locator = "xpath=//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" expand_img_locator = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
selenium.click(expand_img_locator) page.find(:xpath, expand_img_locator).click
wait_for_animations_to_end
end end
When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description| When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |todo_description, predecessor_description|
@ -34,20 +34,23 @@ When /^I edit the dependency of "([^"]*)" to add "([^"]*)" as predecessor$/ do |
open_edit_form_for(todo) open_edit_form_for(todo)
input = "xpath=//form[@id='form_todo_#{todo.id}']//input[@id='predecessor_input']" form_css = "form#form_todo_#{todo.id}"
selenium.focus(input)
selenium.type_keys input, predecessor_description within form_css do
fill_in 'predecessor_input', :with => predecessor_description
end
# in webkit, the autocompleter is not fired after fill_in
page.execute_script %Q{$("#{form_css}").find('input[id$="predecessor_input"]').autocomplete('search')} if Capybara.javascript_driver == :webkit
# wait for auto complete # wait for auto complete
autocomplete = "xpath=//a[@id='ui-active-menuitem']" page.should have_css("a#ui-active-menuitem")
selenium.wait_for_element(autocomplete, :timeout_in_seconds => 5)
# click first line # click first line
first_elem = "xpath=//ul/li[1]/a[@id='ui-active-menuitem']" page.find(:xpath, "//ul/li[1]/a[@id='ui-active-menuitem']").click
selenium.click(first_elem)
new_dependency_line = "xpath=//li[@id='pred_#{predecessor.id}']" # wait for the new dependency to be added to the list
selenium.wait_for_element(new_dependency_line, :timeout_in_seconds => 5) page.should have_css("li#pred_#{predecessor.id}")
submit_edit_todo_form(todo) submit_edit_todo_form(todo)
end end
@ -60,14 +63,14 @@ When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ d
open_edit_form_for(todo) open_edit_form_for(todo)
delete_dep_button = "xpath=//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']" delete_dep_button = "//form[@id='form_todo_#{todo.id}']//img[@id='delete_dep_#{predecessor.id}']"
selenium.click(delete_dep_button) page.find(:xpath, delete_dep_button).click
wait_for :timeout=>5 do
!selenium.is_element_present(delete_dep_button) page.should_not have_xpath(delete_dep_button)
end
submit_edit_todo_form(todo) submit_edit_todo_form(todo)
# note that animations will be running after the ajax is completed wait_for_ajax
wait_for_animations_to_end
end end
When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps| When /^I edit the dependency of "([^"]*)" to "([^"]*)"$/ do |todo_name, deps|
@ -90,40 +93,21 @@ end
Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description| Then /^I should see "([^\"]*)" within the dependencies of "([^\"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil 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 Then "I should see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
# 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, :timeout_in_seconds => 5)
end end
Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description| Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |successor_description, todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil todo.should_not be_nil
successor = @current_user.todos.find_by_description(successor_description)
successor.should_not be_nil Then "I should not see \"#{successor_description}\" within \"div#line_todo_#{todo.id}\""
# 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"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end end
Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description| Then /^I should see that "([^"]*)" does not have dependencies$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description) todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil todo.should_not be_nil
dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img" dependencies_icon = "//div[@id='line_todo_#{todo.id}']/div/a[@class='show_successors']/img"
page.should_not have_xpath(dependencies_icon)
if selenium.is_element_present(dependencies_icon)
wait_for :timeout => 5 do
!selenium.is_element_present(dependencies_icon)
end
end
end end

View file

@ -16,9 +16,7 @@ Then /the badge should show (.*)/ do |number|
end end
Then /^I should see the empty message in the deferred container$/ do Then /^I should see the empty message in the deferred container$/ do
wait_for :timeout => 5 do page.should have_xpath("//div[@id='tickler']//div[@id='tickler-empty-nd']")
selenium.is_visible("xpath=//div[@id='tickler']//div[@id='tickler-empty-nd']")
end
end end
Then /^I should see the empty tickler message$/ do Then /^I should see the empty tickler message$/ do
@ -35,7 +33,7 @@ end
Then /^I should see an error flash message saying "([^"]*)"$/ do |message| Then /^I should see an error flash message saying "([^"]*)"$/ do |message|
xpath = "//div[@id='message_holder']/h4[@id='flash']" xpath = "//div[@id='message_holder']/h4[@id='flash']"
text = response.selenium.get_text("xpath=#{xpath}") text = page.find(:xpath, xpath).text
text.should == message text.should == message
end end

View file

@ -1,5 +1,5 @@
Given /^public signups are turned (.*)$/ do |state| Given /^public signups are turned (.*)$/ do |state|
case state case state
when 'on' when 'on'
SITE_CONFIG['open_signups'] = true SITE_CONFIG['open_signups'] = true
when 'off' when 'off'
@ -13,5 +13,5 @@ When /^I submit the signup form with username "([^\"]*)", password "([^\"]*)" an
fill_in 'Desired login', :with => username fill_in 'Desired login', :with => username
fill_in 'Choose password', :with => password fill_in 'Choose password', :with => password
fill_in 'Confirm password', :with => confirm fill_in 'Confirm password', :with => confirm
click_button click_button "Signup"
end end

View file

@ -9,6 +9,9 @@ When /^I delete the action "([^"]*)"$/ do |action_description|
find("a#delete_todo_#{todo.id}").click find("a#delete_todo_#{todo.id}").click
end end
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?" get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?"
wait_for_ajax
wait_for_animations_to_end
end end
When /^I delete the todo "([^"]*)"$/ do |action_description| When /^I delete the todo "([^"]*)"$/ do |action_description|

View file

@ -19,7 +19,7 @@ require 'capybara/session'
# BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript # BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
Capybara.default_wait_time = 5 Capybara.default_wait_time = 5
Capybara.javascript_driver = :webkit Capybara.javascript_driver = ENV["JS_DRIVER"] ? ENV["JS_DRIVER"].to_sym : :selenium
if Capybara.javascript_driver == :webkit if Capybara.javascript_driver == :webkit
require 'capybara/webkit' require 'capybara/webkit'

View file

@ -62,6 +62,14 @@ module TracksStepHelper
page.evaluate_script('$(":animated").length') == 0 page.evaluate_script('$(":animated").length') == 0
end end
end end
def wait_for_ajax
start_time = Time.now
page.evaluate_script('jQuery.isReady&&jQuery.active==0').class.should_not eql(String)
until(page.evaluate_script('jQuery.isReady&&jQuery.active==0') || (start_time + 5.seconds) < Time.now)
sleep 1
end
end
def handle_js_confirm(accept=true) def handle_js_confirm(accept=true)
page.execute_script "window.original_confirm_function = window.confirm" page.execute_script "window.original_confirm_function = window.confirm"