Add model MembershipPool
This commit is contained in:
parent
250f00f715
commit
938b15fc46
|
@ -0,0 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class MembershipPool < ApplicationRecord
|
||||||
|
validates :name, presence: true
|
||||||
|
end
|
|
@ -0,0 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CreateMembershipPools < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :membership_pools do |t|
|
||||||
|
t.timestamps null: false
|
||||||
|
t.string :name, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_12_06_014718) do
|
ActiveRecord::Schema.define(version: 2018_12_06_190602) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -77,6 +77,12 @@ ActiveRecord::Schema.define(version: 2018_12_06_014718) do
|
||||||
t.index ["country_state_id"], name: "index_membership_applications_on_country_state_id"
|
t.index ["country_state_id"], name: "index_membership_applications_on_country_state_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "membership_pools", force: :cascade do |t|
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.string "name", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "passport_confirmations", force: :cascade do |t|
|
create_table "passport_confirmations", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
|
15
db/seeds.rb
15
db/seeds.rb
|
@ -10,10 +10,11 @@ country_state_names.each do |name|
|
||||||
CountryState.create! name: name
|
CountryState.create! name: name
|
||||||
end
|
end
|
||||||
|
|
||||||
admin_account = Account.create!
|
User.where(email: Rails.application.credentials.initial_superuser_email)
|
||||||
admin_account.create_user!(
|
.first_or_create! do |new_user|
|
||||||
email: Rails.application.credentials.initial_superuser_email,
|
new_user.account = Account.create!
|
||||||
password: Rails.application.credentials.initial_superuser_password,
|
new_user.password = Rails.application.credentials.initial_superuser_password
|
||||||
confirmed_at: Time.zone.now,
|
new_user.confirmed_at = Time.zone.now
|
||||||
)
|
end.account.add_role :superuser
|
||||||
admin_account.add_role :superuser
|
|
||||||
|
MembershipPool.create! name: 'Все заявления' unless MembershipPool.any?
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
FactoryBot.define do
|
||||||
|
factory :membership_pool do
|
||||||
|
name { Faker::Lorem.sentence[0...-1] }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe MembershipPool do
|
||||||
|
subject { create :membership_pool }
|
||||||
|
|
||||||
|
it { is_expected.to validate_presence_of :name }
|
||||||
|
end
|
Reference in New Issue