Skip to content

Commit

Permalink
Registration form: Fill in 'business carried out' using objectives fr…
Browse files Browse the repository at this point in the history
…om constitution. Closes #485.
  • Loading branch information
chrismear committed Aug 16, 2014
1 parent 4cf45b4 commit 3b83736
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/registration_form.rb
Expand Up @@ -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
Expand Down
23 changes: 22 additions & 1 deletion spec/models/registration_form_spec.rb
Expand Up @@ -14,14 +14,19 @@
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)}
let(:document) {mock_model(Rticles::Document,
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
Expand All @@ -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

0 comments on commit 3b83736

Please sign in to comment.