1
0
Fork 0

Add model MembershipPool

This commit is contained in:
Alex Kotov 2018-12-07 00:19:41 +05:00
parent 250f00f715
commit 938b15fc46
No known key found for this signature in database
GPG Key ID: 4E831250F47DE154
6 changed files with 46 additions and 8 deletions

View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
class MembershipPool < ApplicationRecord
validates :name, presence: true
end

View File

@ -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

View File

@ -10,7 +10,7 @@
#
# 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
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"
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|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false

View File

@ -10,10 +10,11 @@ country_state_names.each do |name|
CountryState.create! name: name
end
admin_account = Account.create!
admin_account.create_user!(
email: Rails.application.credentials.initial_superuser_email,
password: Rails.application.credentials.initial_superuser_password,
confirmed_at: Time.zone.now,
)
admin_account.add_role :superuser
User.where(email: Rails.application.credentials.initial_superuser_email)
.first_or_create! do |new_user|
new_user.account = Account.create!
new_user.password = Rails.application.credentials.initial_superuser_password
new_user.confirmed_at = Time.zone.now
end.account.add_role :superuser
MembershipPool.create! name: 'Все заявления' unless MembershipPool.any?

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :membership_pool do
name { Faker::Lorem.sentence[0...-1] }
end
end

View File

@ -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