Add model State
This commit is contained in:
parent
1727086fee
commit
b765349175
7 changed files with 55 additions and 1 deletions
5
app/models/state.rb
Normal file
5
app/models/state.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class State < ApplicationRecord
|
||||
validates :name, presence: true, uniqueness: true
|
||||
end
|
|
@ -7,6 +7,9 @@ en:
|
|||
passport:
|
||||
one: Passport
|
||||
other: Passports
|
||||
state:
|
||||
one: State
|
||||
other: States
|
||||
user:
|
||||
one: User
|
||||
other: Users
|
||||
|
@ -39,6 +42,9 @@ en:
|
|||
issued_by: Issued by
|
||||
unit_code: Unit code
|
||||
date_of_issue: Date of issue
|
||||
state:
|
||||
id: ID
|
||||
name: Name
|
||||
passport/confirmed:
|
||||
'true': Confirmed
|
||||
'false': Unconfirmed
|
||||
|
|
|
@ -7,6 +7,9 @@ ru:
|
|||
passport:
|
||||
one: Паспорт
|
||||
other: Паспорта
|
||||
state:
|
||||
one: Субъект РФ
|
||||
other: Субъекты РФ
|
||||
user:
|
||||
one: Пользователь
|
||||
other: Пользователи
|
||||
|
@ -39,6 +42,9 @@ ru:
|
|||
issued_by: Кем выдан
|
||||
unit_code: Код подразделения
|
||||
date_of_issue: Дата выдачи
|
||||
state:
|
||||
id: ID
|
||||
name: Название
|
||||
passport/confirmed:
|
||||
'true': Подтверждён
|
||||
'false': Не подтверждён
|
||||
|
|
12
db/migrate/20181130161628_create_states.rb
Normal file
12
db/migrate/20181130161628_create_states.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateStates < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :states do |t|
|
||||
t.timestamps null: false
|
||||
t.string :name, null: false
|
||||
|
||||
t.index :name, unique: true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_11_30_090126) do
|
||||
ActiveRecord::Schema.define(version: 2018_11_30_161628) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -88,6 +88,13 @@ ActiveRecord::Schema.define(version: 2018_11_30_090126) do
|
|||
t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id"
|
||||
end
|
||||
|
||||
create_table "states", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "name", null: false
|
||||
t.index ["name"], name: "index_states_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "telegram_bots", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
|
|
7
factories/states.rb
Normal file
7
factories/states.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :state do
|
||||
name { Faker::Address.state }
|
||||
end
|
||||
end
|
11
spec/models/state_spec.rb
Normal file
11
spec/models/state_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe State do
|
||||
subject { create :state }
|
||||
|
||||
it { is_expected.to validate_presence_of :name }
|
||||
|
||||
it { is_expected.to validate_uniqueness_of :name }
|
||||
end
|
Reference in a new issue