adds specs

This commit is contained in:
rgarcia
2015-09-23 20:55:28 +02:00
parent ddb2ab1c2a
commit 3098fe3baa
2 changed files with 39 additions and 0 deletions

View File

@@ -32,6 +32,26 @@ feature 'Residence' do
expect(page).to have_content /\d errors? prevented your residence verification/
end
scenario 'Error on postal code not in Madrid census' do
user = create(:user)
login_as(user)
visit account_path
click_link 'Verify my account'
fill_in 'residence_document_number', with: "12345678Z"
select 'Spanish ID', from: 'residence_document_type'
select '1997', from: 'residence_date_of_birth_1i'
select 'January', from: 'residence_date_of_birth_2i'
select '1', from: 'residence_date_of_birth_3i'
fill_in 'residence_postal_code', with: '12345'
check 'residence_terms_of_service'
click_button 'Verify residence'
expect(page).to have_content 'Please, to verify your account you need to be in the census of the Madrid town.'
end
scenario 'Error on Madrid census' do
user = create(:user)
login_as(user)

View File

@@ -29,6 +29,25 @@ describe Verification::Residence do
expect(residence.errors[:date_of_birth]).to include("You need yo be at least 16 years old")
end
describe "postal code" do
it "should be valid with postal codes starting with 280" do
residence.postal_code = "28012"
expect(residence.errors[:postal_code].size).to eq(0)
residence.postal_code = "28023"
expect(residence.errors[:postal_code].size).to eq(0)
end
it "should not be valid with postal codes not starting with 280" do
residence.postal_code = "12345"
expect(residence.errors[:postal_code].size).to eq(1)
residence.postal_code = "13280"
expect(residence.errors[:postal_code].size).to eq(1)
expect(residence.errors[:postal_code]).to include("Please, to verify your account you need to be in the census of the Madrid town.")
end
end
it "should validate uniquness of document_number" do
user = create(:user)
residence.user = user