2018-11-30 06:19:38 +05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-11-30 12:00:03 +05:00
|
|
|
RSpec.describe Passport do
|
2018-12-02 21:44:02 +05:00
|
|
|
subject { create :empty_passport }
|
2018-11-30 06:19:38 +05:00
|
|
|
|
2019-01-31 08:04:42 +05:00
|
|
|
it { is_expected.to belong_to(:person).optional }
|
|
|
|
|
2018-12-02 19:16:16 +05:00
|
|
|
it do
|
|
|
|
is_expected.to \
|
2018-12-03 01:29:39 +05:00
|
|
|
have_many(:passport_maps)
|
2018-12-02 19:16:16 +05:00
|
|
|
.dependent(:restrict_with_exception)
|
|
|
|
end
|
|
|
|
|
2018-11-30 13:28:40 +05:00
|
|
|
it do
|
|
|
|
is_expected.to \
|
|
|
|
have_many(:passport_confirmations)
|
|
|
|
.dependent(:restrict_with_exception)
|
|
|
|
end
|
|
|
|
|
2018-12-03 01:29:39 +05:00
|
|
|
pending '#passport_map'
|
2018-12-01 15:23:58 +05:00
|
|
|
pending '#image'
|
2018-12-03 01:51:10 +05:00
|
|
|
pending '#can_have_confirmations?'
|
2018-12-01 05:40:34 +05:00
|
|
|
pending '#enough_confirmations?'
|
|
|
|
|
2018-12-01 22:18:37 +05:00
|
|
|
describe '#confirmed' do
|
|
|
|
def allow_value(*)
|
|
|
|
super.for :confirmed
|
|
|
|
end
|
|
|
|
|
2018-12-02 21:44:02 +05:00
|
|
|
context 'when passport is empty' do
|
|
|
|
subject { create :empty_passport }
|
2018-12-01 22:18:37 +05:00
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
2018-12-02 21:44:02 +05:00
|
|
|
context 'when passport has passport map' do
|
|
|
|
subject { create :passport_with_passport_map }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when passport has image' do
|
2018-12-01 22:18:37 +05:00
|
|
|
subject { create :passport_with_image }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
2018-12-02 21:44:02 +05:00
|
|
|
context 'when passport has passport map and image' do
|
|
|
|
subject { create :passport_with_passport_map_and_image }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
2018-12-01 22:18:37 +05:00
|
|
|
context 'when passport has almost enough confirmations' do
|
|
|
|
subject { create :passport_with_almost_enough_confirmations }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when passport has enough confirmations' do
|
|
|
|
subject { create :passport_with_enough_confirmations }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.to allow_value true }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when passport is confirmed' do
|
|
|
|
subject { create :confirmed_passport }
|
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.to allow_value true }
|
|
|
|
end
|
|
|
|
end
|
2018-11-30 06:19:38 +05:00
|
|
|
end
|