1
0
Fork 0

Add attribute Account#biography

This commit is contained in:
Alex Kotov 2019-02-01 09:02:51 +05:00
parent 9399451171
commit 9f30b1f24d
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
6 changed files with 18 additions and 1 deletions

View File

@ -30,6 +30,8 @@ class Account < ApplicationRecord
format: USERNAME_RE,
uniqueness: { case_sensitive: false }
validates :biography, length: { maximum: 10_000 }
validates :person_id, allow_nil: true, uniqueness: true
def guest?

View File

@ -35,6 +35,7 @@ en:
account:
id: ID
username: Username
biography: Bio
account_telegram_contact:
id: ID
country_state:

View File

@ -35,6 +35,7 @@ ru:
account:
id: ID
username: Имя пользователя
biography: Биография
account_telegram_contact:
id: ID
country_state:

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddBiographyToAccounts < ActiveRecord::Migration[6.0]
def change
add_column :accounts, :biography, :text
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_02_01_013649) do
ActiveRecord::Schema.define(version: 2019_02_01_035804) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -40,6 +40,7 @@ ActiveRecord::Schema.define(version: 2019_02_01_013649) do
t.string "guest_token", null: false
t.bigint "person_id"
t.string "username", null: false
t.text "biography"
t.index ["person_id"], name: "index_accounts_on_person_id", unique: true
end

View File

@ -71,6 +71,11 @@ RSpec.describe Account do
it { is_expected.not_to allow_value '1foo' }
end
describe '#biography' do
it { is_expected.not_to validate_presence_of :biography }
it { is_expected.to validate_length_of(:biography).is_at_most(10_000) }
end
describe '#add_role' do
context 'to guest account' do
subject { create :guest_account }