1
0
Fork 0

Add model MembershipApplication

This commit is contained in:
Alex Kotov 2018-11-26 18:39:32 +05:00
parent 2304194b6a
commit 4a02eae063
No known key found for this signature in database
GPG Key ID: 4E831250F47DE154
5 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
class MembershipApplication < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
validates :middle_name, presence: true
end

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
class CreateMembershipApplications < ActiveRecord::Migration[5.2]
def change
create_table :membership_applications do |t|
t.timestamps null: false
t.string :first_name, null: false
t.string :last_name, null: false
t.string :middle_name, null: false
end
end
end

View File

@ -10,9 +10,17 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 0) do
ActiveRecord::Schema.define(version: 2018_11_26_132402) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "membership_applications", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "first_name", null: false
t.string "last_name", null: false
t.string "middle_name", null: false
end
end

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
factory :membership_application do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
middle_name { Faker::Name.first_name }
end
end

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipApplication, type: :model do
subject { create :membership_application }
it { is_expected.to validate_presence_of :first_name }
it { is_expected.to validate_presence_of :last_name }
it { is_expected.to validate_presence_of :middle_name }
end