Ignore empty identity for regisrar user switch #2754

This commit is contained in:
Priit Tark 2015-08-18 14:15:16 +03:00
parent 85e5a17509
commit 598ab7ba63
4 changed files with 32 additions and 11 deletions

View file

@ -3,6 +3,22 @@ require 'rails_helper'
describe ApiUser do
it { should belong_to(:registrar) }
context 'class methods' do
before do
Fabricate(:api_user, identity_code: '')
Fabricate(:api_user, identity_code: 14212128025)
end
it 'should return all api users with given identity code' do
ApiUser.all_by_identity_code('14212128025').size.should == 1
ApiUser.all_by_identity_code(14212128025).size.should == 1
end
it 'should not return any api user with blank identity code' do
ApiUser.all_by_identity_code('').size.should == 0
end
end
context 'with invalid attribute' do
before :all do
@api_user = ApiUser.new