Sha256: 19da313b3bc0ab8d2d85d9b0799883c64b02e7d0ff40806c5db639a99d5c44c9
Contents?: true
Size: 1.65 KB
Versions: 13
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true shared_examples "accept amendment" do context "when the form is valid" do it "broadcasts ok" do expect { command.call }.to broadcast(:ok) end it "changes the emendation state to accepted" do expect { command.call && emendation.reload }.to change(emendation, :state) .from("evaluating").to("accepted") end it "adds the emendation author as coauthor of the proposal" do expect { command.call }.to change { amendable.coauthorships.count } .from(1).to(2) .and change { amendable.authored_by?(emendation.creator_author) } .from(false).to(true) end it "traces the action", versioning: true do expect(Decidim.traceability) .to receive(:update!) .with( amendment, amendable.creator_author, { state: "accepted" }, visibility: "public-only" ).and_call_original expect(Decidim.traceability) .to receive(:update!) .with( amendable, emendation.creator_author, { body: emendation.body, title: emendation.title }, visibility: "public-only" ).and_call_original expect { command.call }.to change(Decidim::ActionLog, :count).by(2) end it "notifies the change" do expect(Decidim::EventsManager) .to receive(:publish) .with( event: "decidim.events.amendments.amendment_accepted", event_class: Decidim::Amendable::AmendmentAcceptedEvent, resource: emendation, followers: kind_of(Array), affected_users: kind_of(Array) ) command.call end end end
Version data entries
13 entries across 13 versions & 1 rubygems