Sha256: 664cb7102d651e5f2edf0e157f3e4f4fe1807f4c861cd18119acfe6988785bfe

Contents?: true

Size: 1.21 KB

Versions: 65

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

65 entries across 65 versions & 1 rubygems

Version Path
decidim-admin-0.23.6 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.24.2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.5 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.24.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.24.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.24.0.rc2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.4 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.24.0.rc1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.3 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.2 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.1.rc1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.23.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.22.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.21.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.20.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.20.0 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.19.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.18.1 lib/decidim/admin/test/commands/destroy_category_examples.rb
decidim-admin-0.19.0 lib/decidim/admin/test/commands/destroy_category_examples.rb