Add model MembershipApplication
This commit is contained in:
parent
2304194b6a
commit
4a02eae063
|
@ -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
|
|
@ -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
|
10
db/schema.rb
10
db/schema.rb
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
Reference in New Issue