From 6f0675b52e22003156b6a1892a50c69ae0275415 Mon Sep 17 00:00:00 2001 From: Stefan Frank Date: Thu, 17 Oct 2013 13:28:30 +0200 Subject: [PATCH 1/2] added the status to the planning-elements-api --- app/views/api/v2/planning_elements/index.api.rabl | 4 ++++ spec/views/api/v2/planning_elements/index_api_json_spec.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/app/views/api/v2/planning_elements/index.api.rabl b/app/views/api/v2/planning_elements/index.api.rabl index 7e2d9e59bc..f9aac8b052 100644 --- a/app/views/api/v2/planning_elements/index.api.rabl +++ b/app/views/api/v2/planning_elements/index.api.rabl @@ -50,6 +50,10 @@ child :type => :planning_element_type do attributes :id, :name end +child :status => :planning_element_status do + attributes :id, :name +end + node :children, unless: lambda{|pe| pe.children.empty?} do |pe| pe.children.to_a.map { |wp| { id: wp.id, subject: wp.subject}} end diff --git a/spec/views/api/v2/planning_elements/index_api_json_spec.rb b/spec/views/api/v2/planning_elements/index_api_json_spec.rb index 7642dd3035..c3e3076f35 100644 --- a/spec/views/api/v2/planning_elements/index_api_json_spec.rb +++ b/spec/views/api/v2/planning_elements/index_api_json_spec.rb @@ -79,6 +79,11 @@ describe 'api/v2/planning_elements/index.api.rabl' do end + it 'should render a status-element' do + expeced_json = {id: wp1.status.id, name: wp1.status.name}.to_json + response.body.should be_json_eql(expeced_json).at_path("planning_elements/0/planning_element_status") + end + it 'should render a project with name and identifier' do expected_json = {name: "Sample Project", identifier: "sample_project"}.to_json From e5a657d3b7639425ec16f291b0de913262843522 Mon Sep 17 00:00:00 2001 From: Stefan Frank Date: Thu, 17 Oct 2013 13:33:25 +0200 Subject: [PATCH 2/2] fixed a typo --- spec/views/api/v2/planning_elements/index_api_json_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/api/v2/planning_elements/index_api_json_spec.rb b/spec/views/api/v2/planning_elements/index_api_json_spec.rb index c3e3076f35..490a77ff0a 100644 --- a/spec/views/api/v2/planning_elements/index_api_json_spec.rb +++ b/spec/views/api/v2/planning_elements/index_api_json_spec.rb @@ -80,8 +80,8 @@ describe 'api/v2/planning_elements/index.api.rabl' do end it 'should render a status-element' do - expeced_json = {id: wp1.status.id, name: wp1.status.name}.to_json - response.body.should be_json_eql(expeced_json).at_path("planning_elements/0/planning_element_status") + expected_json = {id: wp1.status.id, name: wp1.status.name}.to_json + response.body.should be_json_eql(expected_json).at_path("planning_elements/0/planning_element_status") end it 'should render a project with name and identifier' do