2018-11-26 08:39:32 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-12-06 14:37:45 -05:00
|
|
|
RSpec.describe MembershipApp do
|
|
|
|
subject { create :membership_app }
|
2018-11-26 08:39:32 -05:00
|
|
|
|
2018-12-06 17:39:11 -05:00
|
|
|
it { is_expected.to belong_to(:account).inverse_of(:own_membership_apps) }
|
2018-12-01 13:55:36 -05:00
|
|
|
it { is_expected.to belong_to(:country_state).optional }
|
|
|
|
|
2018-12-02 05:54:56 -05:00
|
|
|
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 }
|
2018-11-26 09:14:27 -05:00
|
|
|
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 }
|
2018-11-26 09:14:27 -05:00
|
|
|
it { is_expected.not_to validate_presence_of :middle_name }
|
2018-11-26 11:34:42 -05:00
|
|
|
it { is_expected.to validate_presence_of :date_of_birth }
|
2018-11-26 11:53:04 -05:00
|
|
|
it { is_expected.not_to validate_presence_of :occupation }
|
2018-11-28 08:09:23 -05:00
|
|
|
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 }
|
2018-11-28 08:16:53 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|
2018-12-06 14:37:45 -05:00
|
|
|
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
|