diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 4c5f3a7..449637b 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -18,3 +18,8 @@ body padding-top: 20px + + #new_supporter + label.required + abbr + display: none diff --git a/app/controllers/supporters_controller.rb b/app/controllers/supporters_controller.rb index 58e6bfb..a626293 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) + params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :age_category, :city) end end diff --git a/app/models/supporter.rb b/app/models/supporter.rb index 9232576..5a51e3f 100644 --- a/app/models/supporter.rb +++ b/app/models/supporter.rb @@ -11,6 +11,11 @@ class Supporter field :support, type: String # Indicates the type of support field :age_category, type: String + validates :first_name, presence: true + validates :last_name, presence: true + validates :street, presence: true + validates :zip, presence: true + validates :city, presence: true validates :email, presence: true, uniqueness: true validates :support, presence: true validates :age_category, presence: true diff --git a/spec/features/support_spec.rb b/spec/features/support_spec.rb index 541465f..b387006 100644 --- a/spec/features/support_spec.rb +++ b/spec/features/support_spec.rb @@ -11,7 +11,6 @@ feature 'Support announcement' do fill_in 'Postleitzahl', with: '8704' fill_in 'Ort', with: 'Hinterm Mond' fill_in 'E-Mail', with: 'blocher@blocher.ch' - fill_in 'E-Mail', with: 'blocher@blocher.ch' choose 'Ich unterschreibe eine Volksinitiative für die Freigabe von Cannabis und helfe aktiv Unterschriften in meiner Umgebung zu sammeln.' @@ -26,7 +25,7 @@ feature 'Support announcement' do click_button 'Unterstützung zusichern' expect(page).to have_content 'Ihre Eingabe war zu schnell.' - + # Test twice just to be sure that it's not become an update action click_button 'Unterstützung zusichern' diff --git a/spec/models/supporter_spec.rb b/spec/models/supporter_spec.rb index 23ba915..10da54c 100644 --- a/spec/models/supporter_spec.rb +++ b/spec/models/supporter_spec.rb @@ -1,7 +1,13 @@ require 'rails_helper' describe Supporter do + it { is_expected.to validate_presence_of(:first_name) } + it { is_expected.to validate_presence_of(:last_name) } + it { is_expected.to validate_presence_of(:street) } + it { is_expected.to validate_presence_of(:zip) } + it { is_expected.to validate_presence_of(:city) } it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_uniqueness_of(:email) } it { is_expected.to validate_presence_of(:support) } + it { is_expected.to validate_presence_of(:age_category) } end