Sha256: 2b4e2509a90c3c9ff8c7cb452a7fc60b69da90a5442161c4e380b4442fb5f033

Contents?: true

Size: 1.21 KB

Versions: 32

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Admin
    shared_examples_for "DestroyCategory command" do
      describe "call" do
        let(:organization) { create(:organization) }
        let(:category) { create(:category, participatory_space: participatory_space) }
        let(:command) { described_class.new(category) }

        describe "when the category is not present" do
          let(:category) { nil }

          it "broadcasts invalid" do
            expect { command.call }.to broadcast(:invalid)
          end
        end

        context "when the category is not empty" do
          let!(:subcategory) { create :subcategory, parent: category }

          it "doesn't destroy the category" do
            expect do
              command.call
            end.not_to change { Category.count }
          end
        end

        describe "when the data is valid" do
          it "broadcasts ok" do
            expect { command.call }.to broadcast(:ok)
          end

          it "destroys the category in the process" do
            category
            expect do
              command.call
            end.to change { Category.count }.by(-1)
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
decidim-admin-0.9.3 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.9.2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.9.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.9.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.8.4 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.8.3 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.8.2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.8.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.8.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.7.4 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.7.3 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.7.2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.7.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.7.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.6.8 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-0.6.8 decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.6.7 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-0.6.7 decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.6.6 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-0.6.6 decidim-admin/lib/decidim/admin/test/commands/destroy_category_examples.rb