Added a cuke for the due_date-comparison; made the api more robust against missing filters.

pull/1215/head
Stefan Frank 11 years ago
parent bc25c450f9
commit f89b3baa04
  1. 2
      app/controllers/api/v2/planning_elements_controller.rb
  2. 1
      doc/CHANGELOG.md
  3. 19
      features/planning_elements/filter.feature
  4. 10
      features/step_definitions/api_steps.rb

@ -191,7 +191,7 @@ module Api
def historical_work_packages(projects)
at_time = Date.parse(params[:at_time])
filter = {f: params[:f], op: params[:op], v: params[:v]}
filter = params[:f] ? {f: params[:f], op: params[:op], v: params[:v]}: {}
historical = PlanningComparisonService.compare(projects, at_time, filter)
end

@ -31,6 +31,7 @@ See doc/COPYRIGHT.rdoc for more details.
* `#1560` WorkPackage/update does not retain some fields when validations fail
* `#1771` Refactor Types Project Settings into new Tab
* `#1878` Project Plan Comparison(server-side implementation): api/v2 can now resolve historical data for work_packages
* `#1929` Too many lines in work package view
* `#1946` Modal shown within in Modal
* `#1949` External links within modals do not work

@ -232,7 +232,18 @@ 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":
| subject | type | responsible | due_date |
| work_package#1 | Task | bob | 2010/01/15 |
Given the date is "2010/02/01"
And the work_package "work_package#1" is updated with the following:
| type | Story |
| responsible | pamela |
| due_date | 2010/01/20 |
Given the date is "2010/03/01"
And I call the work_package-api on project "sample_project" at time "2010/01/03" and filter for types "Story"
Then the json-response for work_package "work_package#1" should have the due_date "2010/01/15"
And the work package "work_package#1" has the due_date "2010/01/20"

@ -61,7 +61,10 @@ And(/^the json\-response for work_package "(.*?)" should have the responsible "(
work_package = lookup_work_package(work_package_name)
expect(work_package["responsible"]["name"]).to eql responsible_name
end
Then(/^the json\-response for work_package "(.*?)" should have the due_date "(.*?)"$/) do |work_package_name, due_date|
work_package = lookup_work_package(work_package_name)
expect(work_package["end_date"]).to eql due_date.gsub('/','-') # normalize the date-format
end
And(/^the json\-response should say that "(.*?)" is parent of "(.*?)"$/) do |parent_name, child_name|
child = lookup_work_package(child_name)
@ -78,6 +81,11 @@ And(/^the json\-response should say that "(.*?)" has (\d+) child(ren)?$/) do |pa
expect(parent["children"].size).to eql nr_of_children.to_i
end
And(/^the work package "(.*?)" has the due_date "(.*?)"$/) do |work_package_name, due_date|
wp = WorkPackage.where(:subject => work_package_name).first
expect(wp.due_date).to eql Date.parse(due_date)
end
When(/^I call the work_package\-api on project "(.*?)" requesting format "(.*?)" filtering for status "(.*?)"$/) do |project_name, format, status_names|
statuses = Status.where(name: status_names.split(','))

Loading…
Cancel
Save