Sha256: da1364dab2aa111919052fafa99ada649b97437d3818ee3606f79fe99b41eb60

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

describe "Proposals feature" do
  let!(:feature) { create(:proposal_feature) }

  describe "on destroy" do
    context "when there are no proposals for the feature" do
      it "destroys the feature" do
        expect do
          Decidim::Admin::DestroyFeature.call(feature)
        end.to change { Decidim::Feature.count }.by(-1)

        expect(feature).to be_destroyed
      end
    end

    context "when there are proposals for the feature" do
      before do
        create(:proposal, feature: feature)
      end

      it "raises an error" do
        expect do
          Decidim::Admin::DestroyFeature.call(feature)
        end.to broadcast(:invalid)

        expect(feature).not_to be_destroyed
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-proposals/spec/lib/decidim/proposals/feature_spec.rb