Skip to content

Commit

Permalink
Include example to test phone number pattern validation
Browse files Browse the repository at this point in the history
  • Loading branch information
entantoencuanto committed Apr 17, 2024
1 parent 00b6f90 commit fe9a368
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion spec/forms/decidim/registration_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ module Decidim
)
end

let(:organization) { create(:organization) }
let(:organization) { create(:organization, extra_user_fields:) }
let(:extra_user_fields) do
{
"enabled" => true,
"country" => { "enabled" => true },
"postal_code" => { "enabled" => true },
"date_of_birth" => { "enabled" => true },
"gender" => { "enabled" => true },
"phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil },
"location" => { "enabled" => true }
}
end
let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" }
let(:name) { "User" }
let(:email) { "[email protected]" }
let(:password) { "S4CGQ9AM4ttJdPKS" }
Expand Down Expand Up @@ -65,6 +77,14 @@ module Decidim
it { is_expected.not_to be_valid }
end

context "with invalid phone number format" do
let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" }

it "is invalid" do
expect(subject).not_to be_valid
end
end

context "when the email is not present" do
let(:email) { nil }

Expand Down

0 comments on commit fe9a368

Please sign in to comment.