Commit c8d90c47 authored by marcheing's avatar marcheing

Add presence validators for required profile fields

parent 84a218d7
...@@ -2,4 +2,6 @@ class Profile < ApplicationRecord ...@@ -2,4 +2,6 @@ class Profile < ApplicationRecord
belongs_to :user belongs_to :user
validates :terms_of_service, acceptance: true validates :terms_of_service, acceptance: true
validates :first_name, :last_name, :country, :state, :city,
:zip_code, :birthdate, :gender, :occupation, presence: true
end end
...@@ -4,4 +4,10 @@ RSpec.describe Profile, type: :model do ...@@ -4,4 +4,10 @@ RSpec.describe Profile, type: :model do
describe 'associations' do describe 'associations' do
it { belong_to(:user) } it { belong_to(:user) }
end end
describe 'validations' do
%i(first_name last_name country state city zip_code birthdate gender occupation).each do |field|
it { validate_presence_of field }
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment