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
|
|
|
|
|
2024-10-21 11:51:34 +02:00
|
|
|
it { expect(champ.type_de_champ.champ_value_for_export(champ)).to eq("W182736273 (Super asso)") }
|
2022-09-22 17:13:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context "no association title" do
|
2024-10-21 11:51:34 +02:00
|
|
|
it { expect(champ.type_de_champ.champ_value_for_export(champ)).to eq("W182736273") }
|
2022-09-22 17:13:53 +02:00
|
|
|
end
|
|
|
|
end
|
2022-09-21 15:18:08 +02:00
|
|
|
end
|