Files
grecia/spec/helpers/signature_sheets_helper_spec.rb
Javi Martín da121ebc53 Remove redundant setting resets in after blocks
Settings are stored in the database, and so any changes to the settings
done during the tests are automatically rolled back between one test and
the next one.

There were also a few places where we weren't using an `after` block but
changing the setting at the end of the test.
2019-09-23 13:47:45 +02:00

77 lines
3.2 KiB
Ruby

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
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