Sha256: ce878f0e4a44e7694803c1bea95397ff77c984fe2130eac8436fb4993e398980
Contents?: true
Size: 1.38 KB
Versions: 51
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true shared_examples "create amendment draft" do context "when the form is valid" do it "broadcasts ok" do expect { command.call }.to broadcast(:ok) end it "creates an amendment (draft) and the emendation (not published)" do expect { command.call } .to change(Decidim::Amendment, :count) .by(1) .and change(amendable.class, :count) .by(1) expect(Decidim::Amendment.last.draft?).to eq(true) expect(amendable.class.last.published?).to eq(false) end it "traces the action without creating a PaperTrail version for the emendation", versioning: true do expect(Decidim.traceability) .to receive(:perform_action!) .with( :create, amendable.class, form.current_user, kind_of(Hash) ).and_call_original expect { command.call }.to change(Decidim::ActionLog, :count).by(1) expect(amendable.class.last.versions.count).to eq(0) end end context "when the form is invalid" do let(:title) { "Too short" } it "broadcasts invalid" do expect { command.call }.to broadcast(:invalid) end it "doesn't create an amendment and the emendation" do expect { command.call } .to change(Decidim::Amendment, :count) .by(0) .and change(amendable.class, :count) .by(0) end end end
Version data entries
51 entries across 51 versions & 1 rubygems