Apply Layout/LineLength rubocop rule
Note we're excluding a few files: * Configuration files that weren't generated by us * Migration files that weren't generated by us * The Gemfile, since it includes an important comment that must be on the same line as the gem declaration * The Budget::Stats class, since the heading statistics are a mess and having shorter lines would require a lot of refactoring
This commit is contained in:
@@ -75,41 +75,49 @@ describe Verification::Management::Document do
|
||||
end
|
||||
|
||||
describe "Allowed Age" do
|
||||
let(:min_age) { User.minimum_required_age }
|
||||
let(:over_minium_age_date_of_birth) { Date.new((min_age + 10).years.ago.year, 12, 31) }
|
||||
let(:under_minium_age_date_of_birth) { Date.new(min_age.years.ago.year, 12, 31) }
|
||||
let(:just_minium_age_date_of_birth) { Date.new(min_age.years.ago.year, min_age.years.ago.month, min_age.years.ago.day) }
|
||||
let(:min_age) { User.minimum_required_age }
|
||||
let(:over_minium_age_date_of_birth) { Date.new((min_age + 10).years.ago.year, 12, 31) }
|
||||
let(:under_minium_age_date_of_birth) { Date.new(min_age.years.ago.year, 12, 31) }
|
||||
let(:just_minium_age_date_of_birth) do
|
||||
Date.new(min_age.years.ago.year, min_age.years.ago.month, min_age.years.ago.day)
|
||||
end
|
||||
|
||||
describe "#valid_age?" do
|
||||
it "returns false when the user is younger than the user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: under_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: under_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.valid_age?(census_response)).to be false
|
||||
end
|
||||
|
||||
it "returns true when the user has the user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: just_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: just_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.valid_age?(census_response)).to be true
|
||||
end
|
||||
|
||||
it "returns true when the user is older than the user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: over_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: over_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.valid_age?(census_response)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#under_age?" do
|
||||
it "returns true when the user is younger than the user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: under_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: under_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.under_age?(census_response)).to be true
|
||||
end
|
||||
|
||||
it "returns false when the user is user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: just_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: just_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.under_age?(census_response)).to be false
|
||||
end
|
||||
|
||||
it "returns false when the user is older than user's minimum required age" do
|
||||
census_response = instance_double("CensusApi::Response", date_of_birth: over_minium_age_date_of_birth)
|
||||
census_response = instance_double("CensusApi::Response",
|
||||
date_of_birth: over_minium_age_date_of_birth)
|
||||
expect(Verification::Management::Document.new.under_age?(census_response)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,11 @@ require "rails_helper"
|
||||
|
||||
describe Verification::Management::Email do
|
||||
describe "#user" do
|
||||
subject { Verification::Management::Email.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com") }
|
||||
subject do
|
||||
Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "1234",
|
||||
email: "inexisting@gmail.com")
|
||||
end
|
||||
|
||||
it "returns nil/false when the user does not exist" do
|
||||
expect(subject.user).to be_nil
|
||||
@@ -12,34 +16,50 @@ describe Verification::Management::Email do
|
||||
|
||||
describe "validations" do
|
||||
it "is not valid if the user does not exist" do
|
||||
expect(Verification::Management::Email.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com")).not_to be_valid
|
||||
expect(Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "1234",
|
||||
email: "inexisting@gmail.com")).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid if the user is already level 3" do
|
||||
user = create(:user, :level_three)
|
||||
expect(Verification::Management::Email.new(document_type: "1", document_number: "1234", email: user.email)).not_to be_valid
|
||||
|
||||
expect(Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "1234",
|
||||
email: user.email)).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid if the user already has a different document number" do
|
||||
user = create(:user, document_number: "1234", document_type: "1")
|
||||
expect(Verification::Management::Email.new(document_type: "1", document_number: "5678", email: user.email)).not_to be_valid
|
||||
|
||||
expect(Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "5678",
|
||||
email: user.email)).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe "#save" do
|
||||
it "does nothing if not valid" do
|
||||
expect(Verification::Management::Email.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com").save).to eq(false)
|
||||
email = Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "1234",
|
||||
email: "inexisting@gmail.com")
|
||||
|
||||
expect(email.save).to eq(false)
|
||||
end
|
||||
|
||||
it "updates the user and sends an email" do
|
||||
user = create(:user)
|
||||
validation = Verification::Management::Email.new(document_type: "1", document_number: "1234", email: user.email)
|
||||
validation = Verification::Management::Email.new(document_type: "1",
|
||||
document_number: "1234",
|
||||
email: user.email)
|
||||
|
||||
mail = double(:mail)
|
||||
|
||||
allow(validation).to receive(:user).and_return user
|
||||
allow(mail).to receive(:deliver_later)
|
||||
allow(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1", "2"])
|
||||
allow(Devise.token_generator).to(receive(:generate)
|
||||
.with(User, :email_verification_token)
|
||||
.and_return(["1", "2"]))
|
||||
allow(Mailer).to receive(:email_verification).with(user, user.email, "2", "1", "1234").and_return(mail)
|
||||
|
||||
validation.save!
|
||||
|
||||
@@ -11,13 +11,17 @@ describe Verification::Residence do
|
||||
|
||||
describe "dates" do
|
||||
it "is valid with a valid date of birth" do
|
||||
residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980")
|
||||
residence = Verification::Residence.new("date_of_birth(3i)" => "1",
|
||||
"date_of_birth(2i)" => "1",
|
||||
"date_of_birth(1i)" => "1980")
|
||||
|
||||
expect(residence.errors[:date_of_birth]).to be_empty
|
||||
end
|
||||
|
||||
it "is not valid without a date of birth" do
|
||||
residence = Verification::Residence.new("date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => "")
|
||||
residence = Verification::Residence.new("date_of_birth(3i)" => "",
|
||||
"date_of_birth(2i)" => "",
|
||||
"date_of_birth(1i)" => "")
|
||||
expect(residence).not_to be_valid
|
||||
expect(residence.errors[:date_of_birth]).to include("can't be blank")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user