Apply explict RSpec/DescribedClass rubocop rule
We settled on using this style in commit 4cbe81a1, but didn't add the
rule enforcing this style and we didn't apply it to existing code.
This commit is contained in:
@@ -71,14 +71,14 @@ describe Verification::Management::Document do
|
||||
|
||||
describe "dates" do
|
||||
it "is valid with a valid date of birth" do
|
||||
verification_document = described_class.new("date_of_birth(3i)" => "1",
|
||||
verification_document = Verification::Management::Document.new("date_of_birth(3i)" => "1",
|
||||
"date_of_birth(2i)" => "1",
|
||||
"date_of_birth(1i)" => "1980")
|
||||
expect(verification_document.errors[:date_of_birth].size).to eq(0)
|
||||
end
|
||||
|
||||
it "is not valid without a date of birth" do
|
||||
verification_document = described_class.new("date_of_birth(3i)" => "",
|
||||
verification_document = Verification::Management::Document.new("date_of_birth(3i)" => "",
|
||||
"date_of_birth(2i)" => "",
|
||||
"date_of_birth(1i)" => "")
|
||||
expect(verification_document).not_to be_valid
|
||||
@@ -97,34 +97,34 @@ describe Verification::Management::Document do
|
||||
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)
|
||||
expect(described_class.new.valid_age?(census_response)).to be false
|
||||
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)
|
||||
expect(described_class.new.valid_age?(census_response)).to be true
|
||||
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)
|
||||
expect(described_class.new.valid_age?(census_response)).to be true
|
||||
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)
|
||||
expect(described_class.new.under_age?(census_response)).to be true
|
||||
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)
|
||||
expect(described_class.new.under_age?(census_response)).to be false
|
||||
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)
|
||||
expect(described_class.new.under_age?(census_response)).to be false
|
||||
expect(Verification::Management::Document.new.under_age?(census_response)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require "rails_helper"
|
||||
describe Verification::Management::Email do
|
||||
|
||||
describe "#user" do
|
||||
subject { described_class.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com") }
|
||||
subject { Verification::Management::Email.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com") }
|
||||
|
||||
it "returns nil/false when the user does not exist" do
|
||||
expect(subject.user).to be_nil
|
||||
@@ -13,28 +13,28 @@ describe Verification::Management::Email do
|
||||
|
||||
describe "validations" do
|
||||
it "is not valid if the user does not exist" do
|
||||
expect(described_class.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(described_class.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(described_class.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(described_class.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com").save).to eq(false)
|
||||
expect(Verification::Management::Email.new(document_type: "1", document_number: "1234", email: "inexisting@gmail.com").save).to eq(false)
|
||||
end
|
||||
|
||||
it "updates the user and sends an email" do
|
||||
user = create(:user)
|
||||
validation = described_class.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)
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ describe Verification::Residence do
|
||||
|
||||
describe "dates" do
|
||||
it "is valid with a valid date of birth" do
|
||||
residence = described_class.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].size).to eq(0)
|
||||
end
|
||||
|
||||
it "is not valid without a date of birth" do
|
||||
residence = described_class.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
|
||||
end
|
||||
|
||||
it "validates user has allowed age" do
|
||||
residence = described_class.new("date_of_birth(3i)" => "1",
|
||||
residence = Verification::Residence.new("date_of_birth(3i)" => "1",
|
||||
"date_of_birth(2i)" => "1",
|
||||
"date_of_birth(1i)" => 5.years.ago.year.to_s)
|
||||
expect(residence).not_to be_valid
|
||||
@@ -52,12 +52,12 @@ describe Verification::Residence do
|
||||
|
||||
describe "new" do
|
||||
it "upcases document number" do
|
||||
residence = described_class.new(document_number: "x1234567z")
|
||||
residence = Verification::Residence.new(document_number: "x1234567z")
|
||||
expect(residence.document_number).to eq("X1234567Z")
|
||||
end
|
||||
|
||||
it "removes all characters except numbers and letters" do
|
||||
residence = described_class.new(document_number: " 12.345.678 - B")
|
||||
residence = Verification::Residence.new(document_number: " 12.345.678 - B")
|
||||
expect(residence.document_number).to eq("12345678B")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ describe Verification::Sms do
|
||||
|
||||
it "validates uniqness of phone" do
|
||||
create(:user, confirmed_phone: "699999999")
|
||||
sms = described_class.new(phone: "699999999")
|
||||
sms = Verification::Sms.new(phone: "699999999")
|
||||
expect(sms).not_to be_valid
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user