1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/models/membership_app_spec.rb

133 lines
3.4 KiB
Ruby
Raw Normal View History

2018-11-26 08:39:32 -05:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipApp do
subject { create :membership_app }
2018-11-26 08:39:32 -05:00
it { is_expected.to belong_to(:account).inverse_of(:own_membership_apps) }
it { is_expected.to belong_to(:country_state).optional }
it { is_expected.to validate_presence_of(:account).with_message(:required) }
2018-12-01 20:12:16 -05:00
it { is_expected.not_to validate_presence_of :country_state }
it { is_expected.to validate_presence_of :first_name }
2018-11-26 09:15:29 -05:00
it { is_expected.to validate_presence_of :last_name }
it { is_expected.not_to validate_presence_of :middle_name }
it { is_expected.to validate_presence_of :date_of_birth }
it { is_expected.not_to validate_presence_of :occupation }
it { is_expected.to validate_presence_of :email }
it { is_expected.to validate_presence_of :phone_number }
it { is_expected.not_to validate_presence_of :telegram_username }
it { is_expected.not_to validate_presence_of :organization_membership }
2018-11-28 08:11:39 -05:00
it { is_expected.not_to validate_presence_of :comment }
2018-11-28 09:05:58 -05:00
2018-12-05 21:46:32 -05:00
describe '#email' do
def allow_value(*)
super.for :email
end
it { is_expected.to allow_value Faker::Internet.email }
it { is_expected.not_to allow_value Faker::Internet.username }
context 'when it has extra spaces' do
subject { create :membership_app, email: " #{email} " }
2018-12-05 21:46:32 -05:00
let(:email) { Faker::Internet.email }
specify do
expect(subject.email).to eq email
end
end
end
2018-11-28 09:05:58 -05:00
describe '#middle_name' do
context 'when it is empty' do
subject { create :membership_app, middle_name: '' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.middle_name).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, middle_name: ' ' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.middle_name).to eq nil
end
end
end
describe '#occupation' do
context 'when it is empty' do
subject { create :membership_app, occupation: '' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.occupation).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, occupation: ' ' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.occupation).to eq nil
end
end
end
describe '#telegram_username' do
context 'when it is empty' do
subject { create :membership_app, telegram_username: '' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.telegram_username).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, telegram_username: ' ' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.telegram_username).to eq nil
end
end
end
describe '#organization_membership' do
context 'when it is empty' do
subject { create :membership_app, organization_membership: '' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.organization_membership).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, organization_membership: ' ' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.organization_membership).to eq nil
end
end
end
describe '#comment' do
context 'when it is empty' do
subject { create :membership_app, comment: '' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.comment).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, comment: ' ' }
2018-11-28 09:05:58 -05:00
specify do
expect(subject.comment).to eq nil
end
end
end
2018-11-26 08:39:32 -05:00
end