replaces length 9 validation by format validation: only numbers, spaces and plus sign allowed

This commit is contained in:
kikito
2016-04-13 19:27:04 +02:00
parent 005bd26965
commit 92ecd7c983
2 changed files with 10 additions and 3 deletions

View File

@@ -7,9 +7,16 @@ describe Verification::Sms do
end
it "should validate uniqness of phone" do
user = create(:user, confirmed_phone: "699999999")
create(:user, confirmed_phone: "699999999")
sms = Verification::Sms.new(phone: "699999999")
expect(sms).to_not be_valid
end
end
it "only allows spaces, numbers and the + sign" do
expect(build(:verification_sms, phone: "0034 666666666")).to be_valid
expect(build(:verification_sms, phone: "+34 666666666")).to be_valid
expect(build(:verification_sms, phone: "hello there")).to_not be_valid
expect(build(:verification_sms, phone: "555; DROP TABLE USERS")).to_not be_valid
end
end