diff --git a/app/controllers/api/v2/planning_elements_controller.rb b/app/controllers/api/v2/planning_elements_controller.rb index 419a32aa8a..4427d7f9be 100644 --- a/app/controllers/api/v2/planning_elements_controller.rb +++ b/app/controllers/api/v2/planning_elements_controller.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 diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index d7bec8034e..3fad44c0ab 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -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 diff --git a/features/planning_elements/filter.feature b/features/planning_elements/filter.feature index cf078760d7..05eae0c122 100644 --- a/features/planning_elements/filter.feature +++ b/features/planning_elements/filter.feature @@ -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" \ No newline at end of file diff --git a/features/step_definitions/api_steps.rb b/features/step_definitions/api_steps.rb index 8de3c801a7..3b5290f70b 100644 --- a/features/step_definitions/api_steps.rb +++ b/features/step_definitions/api_steps.rb @@ -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(','))