Moved the timecop-steps aout of the api into the timecop-steps

pull/1215/head
Stefan Frank 11 years ago
parent 0bd5701c18
commit 9c7cf12843
  1. 5
      app/services/planning_comparison_service.rb
  2. 2
      features/planning_elements/filter.feature
  3. 5
      features/step_definitions/api_steps.rb
  4. 5
      features/step_definitions/timecop_steps.rb
  5. 5
      features/support/env.rb

@ -10,7 +10,7 @@ class PlanningComparisonService
and #{Journal.table_name}.created_at=latest.latest_date
and #{Journal.table_name}.journable_id in (#work_package_ids);
SQL
@@mapped_attributes = Journal::WorkPackageJournal::journaled_attributes_keys.map{|attribute| "#{Journal::WorkPackageJournal.table_name}.#{attribute}"}.join ','
@@mapped_attributes = Journal::WorkPackageJournal.journaled_attributes.map{|attribute| "#{Journal::WorkPackageJournal.table_name}.#{attribute}"}.join ','
@@work_package_select = <<SQL
Select #{Journal.table_name}.journable_id as id,
@ -60,9 +60,6 @@ SQL
journal_ids = ActiveRecord::Base.connection.execute(sql)
.map{|result| result["id"]}
# use the journaled attributes to make the journal-entry appear like a real(tm) WorkPackage
attributes = Journal::WorkPackageJournal::journaled_attributes_keys.map{|attribute| "#{Journal::WorkPackageJournal.table_name}.#{attribute}"}.join ','
# 3&4 fetch the journaled data and make rails think it is actually a work_package
work_packages = WorkPackage.find_by_sql(@@work_package_select.gsub('#journal_ids',journal_ids.join(',')))
end

@ -214,7 +214,6 @@ Feature: Filtering work packages via the api
# Always make sure, that historical tests are tagged with @timetravel:
# otherwise the time remains frozen for other features!!!
@timetravel
Scenario: looking up historical data
Given the date is "2010/01/01"
And there are the following work packages in project "sample_project":
@ -232,7 +231,6 @@ Feature: Filtering work packages via the api
And the json-response for work_package "work_package#3" should have the type "Task"
And the json-response for work_package "work_package#3" should have the responsible "Pamela Anderson"
@timetravel
Scenario: comparing due dates
Given the date is "2010/01/01"
And there are the following work packages in project "sample_project":

@ -157,11 +157,6 @@ Then(/^the time to get the filtered results should be faster than the time to ge
@filtered_benchmark.total.should < @unfiltered_benchmark.total
end
Given /^the date is "(.*?)"$/ do |date|
new_time = Time.parse date
Timecop.freeze(new_time)
end
def lookup_work_package(work_package_name)
work_package = decoded_json["planning_elements"].select {|wp| wp["name"] == work_package_name}.first
end

@ -42,6 +42,11 @@ Given /^the time is ([0-9]+) days later$/ do |duration|
Support::ResetTimecop.reset_after
end
Given /^the date is "(.*?)"$/ do |date|
new_time = Time.parse date
Timecop.freeze(new_time)
end
module Support
module ResetTimecop
def self.reset_after

@ -107,8 +107,3 @@ Cucumber::Rails::Database.javascript_strategy = :truncation
# Capybara::Selenium::Driver.new(app, :browser => :chrome)
# end
#
# Make sure, that scenarios that involve time-travelling are cleaned up properly
After '@timetravel' do
Timecop.return
end

Loading…
Cancel
Save