diff --git a/app/models/registration_form.rb b/app/models/registration_form.rb index aa6bf486..8f824f86 100644 --- a/app/models/registration_form.rb +++ b/app/models/registration_form.rb @@ -24,7 +24,7 @@ def to_pdf form_data['timing_factors'] = @organisation.reg_form_timing_factors - form_data['business_carried_out'] = @organisation.reg_form_business_carried_out + form_data['business_carried_out'] = (@organisation.objectives.respond_to?(:capitalize) ? @organisation.objectives.capitalize : '') form_data['funding'] = @organisation.reg_form_funding form_data['members_benefit'] = @organisation.reg_form_members_benefit form_data['members_participate'] = @organisation.reg_form_members_participate diff --git a/spec/models/registration_form_spec.rb b/spec/models/registration_form_spec.rb index 0d0f0690..0bc72b3c 100644 --- a/spec/models/registration_form_spec.rb +++ b/spec/models/registration_form_spec.rb @@ -14,7 +14,9 @@ reg_form_members_benefit: nil, reg_form_members_participate: nil, reg_form_members_control: nil, - reg_form_profit_use: nil + reg_form_profit_use: nil, + reg_form_financial_year_end: nil, + objectives: nil )} let(:registration_form) {RegistrationForm.new(organisation)} let(:constitution) {double('constitution', document: document)} @@ -22,6 +24,9 @@ paragraph_numbers_for_topic: nil, paragraph_numbers_for_topics: nil )} + let(:form) { double('PdfFormFiller::Form', + render: nil + ) } describe 'financial year end' do it 'does not raise an error when processing an incorrect date format' do @@ -30,4 +35,20 @@ end end + describe '"business_carried_out" field' do + it 'is filled in with the "objectives" from the constitution' do + allow(PdfFormFiller::Form).to receive(:new).and_return(form) + allow(organisation).to receive(:objectives).and_return('Raise pigs in an environmentally-friendly manner.') + expect(form).to receive(:fill_form).with(hash_including('business_carried_out' => 'Raise pigs in an environmentally-friendly manner.')) + registration_form.to_pdf + end + + it 'capitalizes the objectives' do + allow(PdfFormFiller::Form).to receive(:new).and_return(form) + allow(organisation).to receive(:objectives).and_return('raise pigs.') + expect(form).to receive(:fill_form).with(hash_including('business_carried_out' => 'Raise pigs.')) + registration_form.to_pdf + end + end + end