Add attribute Account#biography
This commit is contained in:
parent
9399451171
commit
9f30b1f24d
|
@ -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?
|
||||
|
|
|
@ -35,6 +35,7 @@ en:
|
|||
account:
|
||||
id: ID
|
||||
username: Username
|
||||
biography: Bio
|
||||
account_telegram_contact:
|
||||
id: ID
|
||||
country_state:
|
||||
|
|
|
@ -35,6 +35,7 @@ ru:
|
|||
account:
|
||||
id: ID
|
||||
username: Имя пользователя
|
||||
biography: Биография
|
||||
account_telegram_contact:
|
||||
id: ID
|
||||
country_state:
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddBiographyToAccounts < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :accounts, :biography, :text
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
|
Reference in New Issue