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

82 lines
2.0 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Passport do
subject { create :empty_passport }
it { is_expected.to belong_to(:person).optional }
it do
is_expected.to \
have_many(:passport_maps)
.dependent(:restrict_with_exception)
end
it do
is_expected.to \
have_many(:passport_confirmations)
.dependent(:restrict_with_exception)
end
pending '#passport_map'
pending '#image'
pending '#can_have_confirmations?'
pending '#enough_confirmations?'
describe '#confirmed' do
def allow_value(*)
super.for :confirmed
end
context 'when passport is empty' do
subject { create :empty_passport }
it { is_expected.to allow_value false }
it { is_expected.not_to allow_value true }
end
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
subject { create :passport_with_image }
it { is_expected.to allow_value false }
it { is_expected.not_to allow_value true }
end
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
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
end