From be41f79916c9c00f38179aa332fbdcb1fac16091 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 23 Jul 2019 01:56:11 +0500 Subject: [PATCH] Set min length --- app/models/account.rb | 4 ++-- db/migrate/20181129203927_initial_migration.rb | 4 ++-- db/structure.sql | 4 ++-- spec/models/account_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index c316547..47e9e2a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -67,9 +67,9 @@ class Account < ApplicationRecord format: NICKNAME_RE, uniqueness: { case_sensitive: false } - validates :public_name, allow_nil: true, length: { in: 3..255 } + validates :public_name, allow_nil: true, length: { in: 1..255 } - validates :biography, allow_nil: true, length: { in: 3..10_000 } + validates :biography, allow_nil: true, length: { in: 1..10_000 } validates :avatar, allow_nil: true, image: true diff --git a/db/migrate/20181129203927_initial_migration.rb b/db/migrate/20181129203927_initial_migration.rb index d5992d2..05d542d 100644 --- a/db/migrate/20181129203927_initial_migration.rb +++ b/db/migrate/20181129203927_initial_migration.rb @@ -261,11 +261,11 @@ class InitialMigration < ActiveRecord::Migration[6.0] SQL constraint :accounts, :public_name, <<~SQL - public_name IS NULL OR is_good_limited_text(public_name, 3, 255) + public_name IS NULL OR is_good_limited_text(public_name, 1, 255) SQL constraint :accounts, :biography, <<~SQL - biography IS NULL OR is_good_limited_text(biography, 3, 10000) + biography IS NULL OR is_good_limited_text(biography, 1, 10000) SQL constraint :federal_subjects, :english_name, <<~SQL diff --git a/db/structure.sql b/db/structure.sql index 61ae549..b6de657 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -174,10 +174,10 @@ CREATE TABLE public.accounts ( biography text, person_id bigint, contacts_list_id bigint NOT NULL, - CONSTRAINT biography CHECK (((biography IS NULL) OR public.is_good_limited_text(biography, 3, 10000))), + CONSTRAINT biography CHECK (((biography IS NULL) OR public.is_good_limited_text(biography, 1, 10000))), CONSTRAINT guest_token CHECK (public.is_guest_token((guest_token)::text)), CONSTRAINT nickname CHECK (public.is_nickname((nickname)::text)), - CONSTRAINT public_name CHECK (((public_name IS NULL) OR public.is_good_limited_text((public_name)::text, 3, 255))) + CONSTRAINT public_name CHECK (((public_name IS NULL) OR public.is_good_limited_text((public_name)::text, 1, 255))) ); diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 36be0b9..35af877 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -121,7 +121,7 @@ RSpec.describe Account do it do is_expected.to \ - validate_length_of(:public_name).is_at_least(3).is_at_most(255) + validate_length_of(:public_name).is_at_least(1).is_at_most(255) end context 'when it was set to blank value' do @@ -158,7 +158,7 @@ RSpec.describe Account do it do is_expected.to \ - validate_length_of(:biography).is_at_least(3).is_at_most(10_000) + validate_length_of(:biography).is_at_least(1).is_at_most(10_000) end context 'when it was set to blank value' do