Update help text and add dynamic example text

- Display help text and example text according to
  remote census configuration:

  Examples with expecte results:
  * With remote census without :date_of_birth and :postal_code:
    -> "To verify a user, your application needs: Document number"
    -> "Required fields for each user must be separated by commas and
        each user must be separated by semicolons."
    -> "Example: 12345678Z; 87654321Y"

  * With remote census with :date_of_birth required:
    -> "To verify a user, your application needs: Document number,
        Day of birth (dd/mm/yyyy)"
    -> "Required fields for each user must be separated by commas and
        each user must be separated by semicolons."
    -> "Example: 12345678Z, 01/01/1980; 87654321Y, 01/02/1990"

  * With remote census with :date_of_birth and :postal_code required:
    -> "To verify a user, your application needs: Document number,
        Day of birth (dd/mm/yyyy) and Postal Code"
    -> "Required fields for each user must be separated by commas and
        each user must be separated by semicolons."
    -> "Example: 12345678Z, 01/01/1980, 28001; 87654321Y, 01/02/1990, 28002"
This commit is contained in:
taitus
2019-05-14 11:56:38 +02:00
committed by Javi Martín
parent d07f9312e5
commit 5953e87c71
5 changed files with 141 additions and 2 deletions

View File

@@ -0,0 +1,82 @@
require "rails_helper"
describe SignatureSheetsHelper do
describe "#required_fields_to_verify_text_help by default" do
it "returns text help by default" do
text = "Write the numbers separated by semicolons (;)"
expect(required_fields_to_verify_text_help).to eq(text)
end
end
describe "#required_fields_to_verify_text_help with remote_census active" do
before do
Setting["feature.remote_census"] = true
end
after do
Setting["feature.remote_census"] = nil
end
it "returns text help when date_of_birth and postal_code are not required" do
text_help_1 = "To verify a user, your application needs: Document number"
text_help_2 = "Required fields for each user must be separated by commas and each user must be separated by semicolons."
text_example = "Example: 12345678Z; 87654321Y"
expect(required_fields_to_verify_text_help).to include(text_help_1)
expect(required_fields_to_verify_text_help).to include(text_help_2)
expect(example_text_help).to include(text_example)
end
it "returns text help when date_of_birth is required" do
Setting["remote_census.request.date_of_birth"] = "some.value"
text_help_1 = "To verify a user, your application needs: Document number, Day of birth (dd/mm/yyyy)"
text_help_2 = "Required fields for each user must be separated by commas and each user must be separated by semicolons."
text_example = "Example: 12345678Z, 01/01/1980; 87654321Y, 01/02/1990"
expect(required_fields_to_verify_text_help).to include(text_help_1)
expect(required_fields_to_verify_text_help).to include(text_help_2)
expect(example_text_help).to include(text_example)
Setting["remote_census.request.date_of_birth"] = nil
end
it "returns text help when postal_code is required" do
Setting["remote_census.request.postal_code"] = "some.value"
text_help_1 = "To verify a user, your application needs: Document number and Postal Code"
text_help_2 = "Required fields for each user must be separated by commas and each user must be separated by semicolons."
text_example = "Example: 12345678Z, 28001; 87654321Y, 28002"
expect(required_fields_to_verify_text_help).to include(text_help_1)
expect(required_fields_to_verify_text_help).to include(text_help_2)
expect(example_text_help).to include(text_example)
Setting["remote_census.request.postal_code"] = nil
end
it "returns text help when date_of_birth and postal_code are required" do
Setting["remote_census.request.date_of_birth"] = "some.value"
Setting["remote_census.request.postal_code"] = "some.value"
text_help_1 = "To verify a user, your application needs: Document number, Day of birth (dd/mm/yyyy) and Postal Code"
text_help_2 = "Required fields for each user must be separated by commas and each user must be separated by semicolons."
text_example = "Example: 12345678Z, 01/01/1980, 28001; 87654321Y, 01/02/1990, 28002"
expect(required_fields_to_verify_text_help).to include(text_help_1)
expect(required_fields_to_verify_text_help).to include(text_help_2)
expect(example_text_help).to include(text_example)
Setting["remote_census.request.postal_code"] = nil
Setting["remote_census.request.postal_code"] = nil
end
end
end