Skip to content

Commit

Permalink
Hook up user validations (#58)
Browse files Browse the repository at this point in the history
While working on updating a user through their profile page, we found
that the first and last names were lacking presence validations.
  • Loading branch information
thestrabusiness authored and Anthony M committed Dec 8, 2020
1 parent 784774d commit 42953e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class User < ApplicationRecord
include Clearance::User

validates :first_name, :last_name, presence: true

has_many :memberships
has_many :commitments, through: :memberships
has_many :groups, through: :memberships
Expand Down
10 changes: 10 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe User do
describe "validations" do
it { should validate_presence_of(:first_name) }
it { should validate_presence_of(:last_name) }
end
end

0 comments on commit 42953e5

Please sign in to comment.