Add save! method to ActiveModel models

This way we make it clear we expect records to be valid when we save
them, just like we do with ActiveRecord models.
This commit is contained in:
Javi Martín
2019-10-12 04:28:43 +02:00
parent b4b20e0295
commit 431074c99f
9 changed files with 26 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ describe LocalCensusRecords::Import do
context "#save" do
it "Create valid local census records with provided values" do
import.save
import.save!
local_census_record = LocalCensusRecord.find_by(document_number: "X11556678")
expect(local_census_record).not_to be_nil
@@ -57,7 +57,7 @@ describe LocalCensusRecords::Import do
end
it "Add successfully created local census records to created_records array" do
import.save
import.save!
valid_document_numbers = ["44556678T", "33556678T", "22556678T", "X11556678"]
expect(import.created_records.collect(&:document_number)).to eq(valid_document_numbers)
@@ -68,7 +68,7 @@ describe LocalCensusRecords::Import do
file = Rack::Test::UploadedFile.new(Rails.root.join(*path))
import.file = file
import.save
import.save!
invalid_records_document_types = [nil, "DNI", "Passport", "NIE"]
invalid_records_document_numbers = ["44556678T", nil, "22556678T", "X11556678"]

View File

@@ -23,7 +23,7 @@ describe Verification::Letter do
it "updates letter_requested" do
letter = build(:verification_letter)
letter.save
letter.save!
expect(letter.user.letter_requested_at).to be
end

View File

@@ -43,7 +43,7 @@ describe Verification::Management::Email do
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
validation.save!
expect(user.reload).to be_level_two_verified
expect(user.document_type).to eq("1")