Sha256: 047ef3c57d33ddf22faf3cd04d30e97d86d7b29af36c828d70298a71a8c3e641

Contents?: true

Size: 1.56 KB

Versions: 62

Compression:

Stored size: 1.56 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_return(amendment)

      expect(Decidim.traceability)
        .to receive(:perform_action!)
        .with(
          :update,
          amendable,
          emendation.creator_author,
          visibility: "public-only"
        ).and_call_original

      command.call
    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

62 entries across 62 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc2 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb