Sha256: 54bfeeda433988660e74f4993f6f5645dac3a6e439e95c6dee3e0c609fcd1c82

Contents?: true

Size: 1.13 KB

Versions: 59

Compression:

Stored size: 1.13 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 supports" 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 supports" 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

59 entries across 59 versions & 1 rubygems

Version Path
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.0 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.0.rc5 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.28.0.rc4 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb