Unverified Commit ad91dddd authored by Noah Leal's avatar Noah Leal Committed by Dennis Schubert

Issue #8119 - Add length validation to a profile's gender field.

closes #8127
parent 71930999
......@@ -5,6 +5,7 @@
## Bug fixes
* Don't link to deleted users in admin user stats [#8063](https://github.com/diaspora/diaspora/pull/8063)
* Properly validate a profile's gender field length instead of failing with a database error. [#8127](https://github.com/diaspora/diaspora/pull/8127)
## Features
......
......@@ -21,6 +21,7 @@ class Profile < ApplicationRecord
validates :first_name, :length => { :maximum => 32 }
validates :last_name, :length => { :maximum => 32 }
validates :location, :length => { :maximum =>255 }
validates :gender, length: {maximum: 255}
validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true
......
......@@ -124,6 +124,18 @@ describe Profile, :type => :model do
end
end
describe "of gender" do
it "can be 255 characters long" do
profile = FactoryGirl.build(:profile, gender: "a" * 255)
expect(profile).to be_valid
end
it "cannot be 256 characters" do
profile = FactoryGirl.build(:profile, gender: "a" * 256)
expect(profile).not_to be_valid
end
end
describe "image_url setters" do
%i(image_url image_url_small image_url_medium).each do |method|
describe "##{method}=" do
......
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