Add ISO 8601 validations

This commit is contained in:
Martin Lensment 2014-12-22 13:54:20 +02:00
parent b5bf21b127
commit 2ac59e68ff
10 changed files with 104 additions and 4 deletions

View file

@ -0,0 +1,23 @@
require 'rails_helper'
describe Keyrelay do
it { should belong_to(:domain) }
it { should belong_to(:requester) }
it { should belong_to(:accepter) }
it 'is in pending status' do
kr = Fabricate(:keyrelay)
expect(kr.status).to eq('pending')
end
it 'is in expired status' do
kr = Fabricate(:keyrelay, pa_date: DateTime.now - 2.weeks)
expect(kr.status).to eq('expired')
end
it 'does not accept invalid relative expiry' do
kr = Fabricate.build(:keyrelay, expiry_relative: 'adf')
expect(kr.save).to eq(false)
expect(kr.errors[:expiry_relative].first).to eq('Expiry relative must be compatible to ISO 8601')
end
end