2018-11-29 20:19:38 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-11-30 02:00:03 -05:00
|
|
|
RSpec.describe Passport do
|
2018-12-02 11:44:02 -05:00
|
|
|
subject { create :empty_passport }
|
2018-11-29 20:19:38 -05:00
|
|
|
|
2018-12-02 09:16:16 -05:00
|
|
|
it do
|
|
|
|
is_expected.to \
|
2018-12-02 15:29:39 -05:00
|
|
|
have_many(:passport_maps)
|
2018-12-02 09:16:16 -05:00
|
|
|
.dependent(:restrict_with_exception)
|
|
|
|
end
|
|
|
|
|
2018-11-30 03:28:40 -05:00
|
|
|
it do
|
|
|
|
is_expected.to \
|
|
|
|
have_many(:passport_confirmations)
|
|
|
|
.dependent(:restrict_with_exception)
|
|
|
|
end
|
|
|
|
|
2018-12-02 15:29:39 -05:00
|
|
|
pending '#passport_map'
|
2018-12-01 05:23:58 -05:00
|
|
|
pending '#image'
|
2018-12-02 15:51:10 -05:00
|
|
|
pending '#can_have_confirmations?'
|
2018-11-30 19:40:34 -05:00
|
|
|
pending '#enough_confirmations?'
|
|
|
|
|
2018-12-01 12:18:37 -05:00
|
|
|
describe '#confirmed' do
|
|
|
|
def allow_value(*)
|
|
|
|
super.for :confirmed
|
|
|
|
end
|
|
|
|
|
2018-12-02 11:44:02 -05:00
|
|
|
context 'when passport is empty' do
|
|
|
|
subject { create :empty_passport }
|
2018-12-01 12:18:37 -05:00
|
|
|
|
|
|
|
it { is_expected.to allow_value false }
|
|
|
|
it { is_expected.not_to allow_value true }
|
|
|
|
end
|
|
|
|
|
2018-12-02 11: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 12: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 11: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 12: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-29 20:19:38 -05:00
|
|
|
end
|