Sha256: 3545d4f1604ef6ea229fb0c11d749e0e8dac859faf33d8b5523f865a86626cdb

Contents?: true

Size: 684 Bytes

Versions: 4

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

shared_examples_for "has reference" do
  context "when the reference is nil" do
    before do
      subject[:reference] = nil
    end

    it "generates a valid reference" do
      expect(subject.reference).to match(/[A-z]+/)
    end
  end

  context "when the reference is already set" do
    before do
      subject[:reference] = "ARBITRARYREF"
    end

    it "keeps the pre-existing 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).to_not be_blank
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.3.2 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.3.1 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.3.0 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.2.0 lib/decidim/core/test/shared_examples/has_reference.rb