Sha256: d31509772f8dec9ed71f9480b380b4fd89e9ad3b24b92fa7433b8f8dd41a5af8

Contents?: true

Size: 997 Bytes

Versions: 69

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

shared_examples "destroy amendment draft" do
  context "when current user is the author of the amendment" do
    let(:current_user) { amendment.amender }

    describe "and the amendment is a draft" do
      it "broadcasts ok" do
        expect { command.call }.to broadcast(:ok)
      end

      it "destroys the amendment and the emendation" do
        expect { command.call }
          .to change(Decidim::Amendment, :count)
          .by(-1)
          .and change(amendable.class, :count)
          .by(-1)
      end
    end

    describe "and the amendment is not a draft" do
      before do
        amendment.update(state: "evaluating")
      end

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

  describe "when the current user is not the amender" do
    let!(:current_user) { other_user }

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

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc3 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.30.0.rc2 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/amendable/destroy_amendment_draft_examples.rb