2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-09-21 15:18:08 +02:00
|
|
|
describe Champs::RNAChamp do
|
2024-07-01 15:31:32 +02:00
|
|
|
let(:champ) { Champs::RNAChamp.new(value: "W182736273", dossier: build(:dossier)) }
|
2024-09-20 14:54:26 +02:00
|
|
|
before do
|
|
|
|
allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_rna))
|
|
|
|
allow(champ).to receive(:in_dossier_revision?).and_return(true)
|
|
|
|
end
|
2024-07-01 15:31:32 +02:00
|
|
|
def with_value(value)
|
|
|
|
champ.tap { _1.value = value }
|
|
|
|
end
|
2022-09-21 15:18:08 +02:00
|
|
|
describe '#valid?' do
|
2024-07-01 15:31:32 +02:00
|
|
|
it { expect(with_value(nil).validate(:champs_public_value)).to be_truthy }
|
|
|
|
it { expect(with_value("2736251627").validate(:champs_public_value)).to be_falsey }
|
|
|
|
it { expect(with_value("A172736283").validate(:champs_public_value)).to be_falsey }
|
|
|
|
it { expect(with_value("W1827362718").validate(:champs_public_value)).to be_falsey }
|
|
|
|
it { expect(with_value("W182736273").validate(:champs_public_value)).to be_truthy }
|
2022-09-21 15:18:08 +02:00
|
|
|
end
|
2022-09-22 17:13:53 +02:00
|
|
|
|
|
|
|
describe "#export" do
|
|
|
|
context "with association title" do
|
|
|
|
before do
|
|
|
|
champ.update(data: { association_titre: "Super asso" })
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(champ.for_export).to eq("W182736273 (Super asso)") }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "no association title" do
|
|
|
|
it { expect(champ.for_export).to eq("W182736273") }
|
|
|
|
end
|
|
|
|
end
|
2022-09-21 15:18:08 +02:00
|
|
|
end
|