render author in planning_element/show

pull/791/head
Markus Kahl 11 years ago committed by Johannes Wollert
parent 7bef8ddac2
commit 6a2808ca28
  1. 6
      app/views/api/v2/planning_elements/_planning_element.api.rabl
  2. 15
      spec/views/api/v2/planning_elements/show_api_json_spec.rb

@ -31,7 +31,7 @@
# which drastically affects the performance of inline vs. partials: as the planning-elements are
# highly performance-critical, we need to live with this duplication until these issues are solved.
object @planning_element
attributes :id, :subject, :description, :project_id, :parent_id, :status_id, :type_id, :priority_id
attributes :id, :subject, :description, :author_id, :project_id, :parent_id, :status_id, :type_id, :priority_id
node :start_date, :if => lambda{|pe| pe.start_date.present?} { |pe| pe.start_date.to_formatted_s(:db) }
node :due_date, :if => lambda{|pe| pe.due_date.present?} {|pe| pe.due_date.to_formatted_s(:db) }
@ -63,6 +63,10 @@ node :children, unless: lambda{|pe| pe.children.empty?} do |pe|
pe.children.to_a.map { |wp| { id: wp.id, subject: wp.subject}}
end
child :author => :author do
attributes :id, :name
end
node :responsible, if: lambda{|pe| pe.responsible.present?} do |pe|
child :responsible => :responsible do
attributes :id, :name

@ -198,6 +198,21 @@ describe 'api/v2/planning_elements/show.api.rabl' do
end
end
describe 'with a planning element having an author' do
let(:author) { FactoryGirl.create(:user) }
let(:planning_element) { FactoryGirl.build(:work_package, :author => author) }
before do
assign(:planning_element, planning_element)
render
end
it 'renders an author node containing the author\'s id and name' do
author_json = {id: author.id, name: author.name}.to_json
response.should be_json_eql(author_json).at_path('planning_element/author')
end
end
describe "a destroyed planning element" do
let(:planning_element) { FactoryGirl.create(:work_package) }

Loading…
Cancel
Save