set a language flag in database
This commit is contained in:
@@ -6,7 +6,7 @@ class SupportersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@supporter = Supporter.new supporter_form_params
|
@supporter = Supporter.new supporter_form_params.merge(language: I18n.locale)
|
||||||
if !input_to_fast? && @supporter.save
|
if !input_to_fast? && @supporter.save
|
||||||
redirect_to thanks_path
|
redirect_to thanks_path
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Supporter
|
|||||||
field :age_category, type: String
|
field :age_category, type: String
|
||||||
field :coordinates, type: Array
|
field :coordinates, type: Array
|
||||||
field :comments, type: String
|
field :comments, type: String
|
||||||
|
field :language, type: String
|
||||||
|
|
||||||
validates :first_name, presence: true
|
validates :first_name, presence: true
|
||||||
validates :last_name, presence: true
|
validates :last_name, presence: true
|
||||||
@@ -27,6 +28,7 @@ class Supporter
|
|||||||
validates :email, presence: true, uniqueness: true, format: /.+@.+\..+/i
|
validates :email, presence: true, uniqueness: true, format: /.+@.+\..+/i
|
||||||
validates :support, presence: true
|
validates :support, presence: true
|
||||||
validates :age_category, presence: true
|
validates :age_category, presence: true
|
||||||
|
validates :language, presence: true
|
||||||
|
|
||||||
def self.counter
|
def self.counter
|
||||||
actual = count.to_i
|
actual = count.to_i
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ feature 'Support announcement' do
|
|||||||
supporter = Supporter.find_by(email: 'blocher@blocher.ch')
|
supporter = Supporter.find_by(email: 'blocher@blocher.ch')
|
||||||
expect(supporter.coordinates).to eq [8.618589100000001, 47.2926304]
|
expect(supporter.coordinates).to eq [8.618589100000001, 47.2926304]
|
||||||
expect(supporter.comments).to eq 'Test text'
|
expect(supporter.comments).to eq 'Test text'
|
||||||
|
expect(supporter.language).to eq 'de'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'A bot tries to enter data' do
|
scenario 'A bot tries to enter data' do
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ describe Supporter do
|
|||||||
it { is_expected.to validate_uniqueness_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(:support) }
|
||||||
it { is_expected.to validate_presence_of(:age_category) }
|
it { is_expected.to validate_presence_of(:age_category) }
|
||||||
|
it { is_expected.to validate_presence_of(:language) }
|
||||||
|
|
||||||
describe '.counter' do
|
describe '.counter' do
|
||||||
it 'counts only from a certain number on' do
|
it 'counts only from a certain number on' do
|
||||||
|
|||||||
Reference in New Issue
Block a user