Sha256: 6cedb41277b55e6270e3a45690c5e5531e0da4b6681379cbd1463e14c8f8447e

Contents?: true

Size: 1003 Bytes

Versions: 12

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

shared_examples_for "has category" do
  let(:participatory_space) { subject.participatory_space }

  context "when the category is from another organization" do
    before do
      subject.category = create(:category)
    end

    it { is_expected.not_to be_valid }
  end

  context "when the category is from the same organization" do
    before do
      subject.category = create(:category, participatory_space:)
    end

    it { is_expected.to be_valid }
  end

  context "when the resource is being deleted" do
    before do
      subject.category = create(:category, participatory_space:)
      subject.save!
    end

    it "persists the categorization" do
      expect(subject.categorization).to be_persisted
    end

    it "deletes the categorization" do
      expect(Decidim::Categorization.count).to eq(1)
      expect { subject.destroy }.to change(Decidim::Categorization, :count).by(-1)
      expect(Decidim::Categorization.count).to eq(0)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/has_category.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/has_category.rb