Sha256: e9b1eeaa7a4586521818f8a80779e606f70c5120f7a4e0a76f7b01c6443ee0e4
Contents?: true
Size: 1.1 KB
Versions: 9
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true shared_examples_for "has reference" do context "when the reference is nil" do before do subject[:reference] = nil end context "when there is not a custom resource reference generator present" do it "generates a valid reference" do expect(subject.reference).to match(/[a-zA-Z]+/) end end context "when there is a custom resource reference generator present" do before do allow(Decidim).to receive(:reference_generator).and_return(->(resource, _component) { "1234-#{resource.id}" }) end it "generates a valid reference" do expect(subject.reference).to eq("1234-#{subject.id}") end end end context "when the reference is already set" do before do subject[:reference] = "ARBITRARYREF" end it "keeps the preexisting reference" do expect(subject.reference).to eq("ARBITRARYREF") end end context "when saving" do it "stores the reference" do subject.reference = nil subject.save! expect(subject.reload.reference).not_to be_blank end end end
Version data entries
9 entries across 9 versions & 1 rubygems