Sha256: e96957343c88e42053e3f7096fbf12998aab419c58a84dca58a3fa75b3448819

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

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

    context "and the amendment has no votes" do
      it "withdraws the amendment" do
        expect { command.call }.to broadcast(:ok)
        expect(amendment.state).to eq("withdrawn")
        expect(emendation.state).to eq("withdrawn")
      end
    end

    context "and the amendment has some votes" do
      before do
        emendation.votes.create!(author: other_user)
      end

      it "is not able to withdraw the amendment" do
        expect { command.call }.to broadcast(:invalid)
        expect(amendment.state).not_to eq("withdrawn")
        expect(emendation.state).not_to eq("withdrawn")
      end
    end
  end

  context "when current user is not the author of the amendment" do
    let!(:current_user) { other_user }

    it "is not able to withdraw the amendment" do
      expect { command.call }.to broadcast(:invalid)
      expect(amendment.state).not_to eq("withdrawn")
      expect(emendation.state).not_to eq("withdrawn")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc2 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb