Merge pull request #128 from NobodysNightmare/feature/schema_for_overall_costs

Include overallCosts in schema
pull/6827/head
Florian Kraft 10 years ago
commit 1b1c33b7ce
  1. 8
      lib/open_project/costs/engine.rb
  2. 20
      spec/lib/api/v3/work_packages/work_package_schema_representer_spec.rb

@ -219,6 +219,14 @@ module OpenProject::Costs
represented.project.costs_enabled?) represented.project.costs_enabled?)
} }
# N.B. in the long term we should have a type like "Currency", but that requires a proper
# format and not a string like "10 EUR"
schema :overall_costs,
type: 'String',
required: false,
writable: false,
show_if: -> (*) { represented.project.costs_enabled? }
schema_with_allowed_collection :cost_object, schema_with_allowed_collection :cost_object,
type: 'Budget', type: 'Budget',
required: false, required: false,

@ -143,6 +143,26 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end end
end end
describe 'overallCosts' do
it_behaves_like 'has basic schema properties' do
let(:path) { 'overallCosts' }
let(:type) { 'String' }
let(:name) { I18n.t('activerecord.attributes.work_package.overall_costs') }
let(:required) { false }
let(:writable) { false }
end
context 'costs disabled' do
before do
allow(schema.project).to receive(:costs_enabled?).and_return(false)
end
it 'has no schema for budget' do
is_expected.not_to have_json_path('overallCosts')
end
end
end
describe 'budget' do describe 'budget' do
it_behaves_like 'has basic schema properties' do it_behaves_like 'has basic schema properties' do
let(:path) { 'costObject' } let(:path) { 'costObject' }

Loading…
Cancel
Save