Wednesday, July 15, 2026 4:00:20 AM
> decline_spec.rb
# frozen_string_literal: true

describe ESM::Command::Request::Decline, category: "command" do
  include_context "command"
  include_examples "validate_command"

  describe "#execute" do
    let!(:user_2) { create(:user) }

    let!(:request) do
      create(
        :request,
        requestor_user_id: user.id,
        requestee_user_id: user_2.id,
        requested_from_channel_id: community.discord_server.channels.first.id,
        command_name: "id"
      )
    end

    context "when the request is for this user" do
      it "declines the request" do
        execute!(user: user_2, channel_type: :dm, arguments: {uuid: request.uuid_short})

        embed = ESM.discord_bot.test_outbox.first.content
        expect(embed).not_to be(nil)
        expect(ESM::Request.all.size).to eq(0)
      end
    end

    context "when the request is for a different user" do
      it "raises an exception" do
        # The uuid is valid, but the user is not the who the request is for
        execution_args = {user: user, channel_type: :dm, arguments: {uuid: request.uuid_short}}

        expect { execute!(**execution_args) }.to raise_error(ESM::Exception::CheckFailure, /unable to find a request/i)
      end
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 43aa0d7