diff --git a/app/controllers/supporters_controller.rb b/app/controllers/supporters_controller.rb index a626293..2ac685c 100644 --- a/app/controllers/supporters_controller.rb +++ b/app/controllers/supporters_controller.rb @@ -18,6 +18,6 @@ class SupportersController < ApplicationController private def supporter_form_params - params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :age_category, :city) + params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :age_category, :city, :comments) end end diff --git a/app/models/supporter.rb b/app/models/supporter.rb index f435d83..9b38a17 100644 --- a/app/models/supporter.rb +++ b/app/models/supporter.rb @@ -17,6 +17,7 @@ class Supporter field :support, type: String # Indicates the type of support field :age_category, type: String field :coordinates, type: Array + field :comments, type: String validates :first_name, presence: true validates :last_name, presence: true diff --git a/app/views/supporters/_form.slim b/app/views/supporters/_form.slim index dcd6477..708381a 100644 --- a/app/views/supporters/_form.slim +++ b/app/views/supporters/_form.slim @@ -11,6 +11,7 @@ h1 = title t('.title_html') = f.input :email, placeholder: t('.placeholders.email') = f.input :support, as: :radio_buttons, collection: t('support_type'), label_method: :last, value_method: :first = f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first + = f.input :comments, as: :text .form-group = f.submit value: t('.submit'), class: 'btn btn-success' .form-group diff --git a/config/locales/de.yml b/config/locales/de.yml index 75caeee..b55a890 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -42,3 +42,4 @@ de: email: E-Mail support: Unterstützung age_category: Alterskategorie + comments: Kommentar / Feedback (optional) diff --git a/spec/features/support_spec.rb b/spec/features/support_spec.rb index f70089c..fe490b7 100644 --- a/spec/features/support_spec.rb +++ b/spec/features/support_spec.rb @@ -11,14 +11,16 @@ feature 'Support announcement' do fill_in 'Postleitzahl', with: '8704' fill_in 'Ort', with: 'Herrliberg' fill_in 'E-Mail', with: 'blocher@blocher.ch' + fill_in 'Kommentar / Feedback', with: 'Test text' choose 'Ich unterschreibe eine Volksinitiative für die Freigabe von Cannabis und helfe aktiv Unterschriften in meiner Umgebung zu sammeln.' choose 'Ich bin über 64 Jahre alt' expect { click_button 'Unterstützung zusichern' }.to change { Supporter.count }.by(1) - - expect(Supporter.find_by(email: 'blocher@blocher.ch').coordinates).to eq [8.618589100000001, 47.2926304] + supporter = Supporter.find_by(email: 'blocher@blocher.ch') + expect(supporter.coordinates).to eq [8.618589100000001, 47.2926304] + expect(supporter.comments).to eq 'Test text' end scenario 'A bot tries to enter data' do