Sha256: 0c07d53502e89ab303c0b07398872550a23e5cf3608a34db5f5814cb14bedf95
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true require "spec_helper" describe Decidim::Admin::DestroyParticipatoryProcessStep, class: true do let(:subject) { described_class } let!(:participatory_process) { create(:participatory_process) } let!(:active_step) do create(:participatory_process_step, participatory_process: participatory_process, active: true) end context "when there's more than one step" do let!(:inactive_step) do create(:participatory_process_step, participatory_process: participatory_process, active: false) end context "when destroying the active step" do it "broadcasts invalid" do expect { subject.call(active_step) }.to broadcast(:invalid, :active_step) end it "doesn't destroy the step" do subject.call(active_step) expect(active_step).to be_persisted end end context "when destroying an inactive step" do let(:reorderer) { double(call: true) } it "broadcasts ok" do expect { subject.call(inactive_step) }.to broadcast(:ok) end it "destroys the step" do subject.call(inactive_step) expect(inactive_step).not_to be_persisted end it "reorders the remaining steps" do allow(Decidim::Admin::ReorderParticipatoryProcessSteps) .to receive(:new) .with([active_step], [active_step.id]) .and_return(reorderer) expect(reorderer).to receive(:call) subject.call(inactive_step) end end end context "when trying to destroy the last step" do it "broadcasts invalid" do expect { subject.call(active_step) }.to broadcast(:invalid, :last_step) end end end
Version data entries
4 entries across 4 versions & 1 rubygems