tests for time comparisons.

pull/513/head
Nils Kenneweg 11 years ago
parent c448a4f2fc
commit be65c3d946
  1. 41
      features/step_definitions/timelines_comparison_steps.rb
  2. 4
      features/timelines/timeline_comparison_view.feature.disabled

@ -26,6 +26,10 @@
# See doc/COPYRIGHT.rdoc for more details. # See doc/COPYRIGHT.rdoc for more details.
#++ #++
def getWPRowByName(name)
find("a", :text => name).find(:xpath, "./ancestor::tr")
end
Given(/^there are the following work packages were added "(.*?)"(?: in project "([^"]*)")?:$/) do |time, project_name, table| Given(/^there are the following work packages were added "(.*?)"(?: in project "([^"]*)")?:$/) do |time, project_name, table|
project = get_project(project_name) project = get_project(project_name)
@ -36,12 +40,9 @@ Given(/^there are the following work packages were added "(.*?)"(?: in project "
else else
target_time = Time.now target_time = Time.now
end end
Timecop.travel(target_time) Timecop.freeze(target_time) do
create_work_packages_from_table table, project
create_work_packages_from_table table, project end
# Ensure timecop returns after each scenario
Support::ResetTimecop.reset_after
end end
Given(/^the work package "(.*?)" was changed "(.*?)" to:$/) do |name, time, table| Given(/^the work package "(.*?)" was changed "(.*?)" to:$/) do |name, time, table|
@ -56,17 +57,17 @@ Given(/^the work package "(.*?)" was changed "(.*?)" to:$/) do |name, time, tabl
else else
target_time = Time.now target_time = Time.now
end end
Timecop.travel(target_time)
#TODO provide generic support for all possible values. Timecop.freeze(target_time) do
work_package = WorkPackage.find_by_subject(name)
work_package.subject = table.hashes.first[:subject]
work_package.start_date = table.hashes.first[:start_date]
work_package.due_date = table.hashes.first[:due_date]
work_package.save!
# Ensure timecop returns after each scenario #TODO provide generic support for all possible values.
Support::ResetTimecop.reset_after work_package = WorkPackage.find_by_subject(name)
work_package.subject = table.hashes.first[:subject]
work_package.start_date = table.hashes.first[:start_date]
work_package.due_date = table.hashes.first[:due_date]
work_package.save!
end
end end
When(/^I set the timeline to compare "now" to "(.*?) days ago"$/) do |time| When(/^I set the timeline to compare "now" to "(.*?) days ago"$/) do |time|
@ -81,12 +82,14 @@ When(/^I set the timeline to compare "now" to "(.*?) days ago"$/) do |time|
page.execute_script("jQuery('#content form').submit()") page.execute_script("jQuery('#content form').submit()")
end end
Then(/^I should see the work package "(.*?)" has not moved$/) do |arg1| Then(/^I should see the work package "(.*?)" has not moved$/) do |name|
pending # express the regexp above with the code you wish you had row = getWPRowByName(name)
row.should_not have_selector(".tl-icon-changed");
end end
Then(/^I should see the work package "(.*?)" has moved$/) do |arg1| Then(/^I should see the work package "(.*?)" has moved$/) do |name|
pending # express the regexp above with the code you wish you had row = getWPRowByName(name)
row.should have_selector(".tl-icon-changed");
end end
Then(/^I should not see the work package "(.*?)"$/) do |arg1| Then(/^I should not see the work package "(.*?)"$/) do |arg1|

@ -67,7 +67,7 @@ Feature: Timeline Comparison View Tests
And I wait for timeline to load table And I wait for timeline to load table
Then I should see the work package "May" has not moved Then I should see the work package "May" has not moved
And I should see the work package "February" has moved And I should see the work package "February" has moved
And I should not see the work package "January" And I should not see the work package "January" in the timeline
@javascript @javascript
Scenario: sixteen days comparison Scenario: sixteen days comparison
@ -78,4 +78,4 @@ Feature: Timeline Comparison View Tests
And I wait for timeline to load table And I wait for timeline to load table
Then I should see the work package "May" has moved Then I should see the work package "May" has moved
And I should see the work package "February" has moved And I should see the work package "February" has moved
And I should not see the work package "January" And I should not see the work package "January" in the timeline

Loading…
Cancel
Save