Wednesday, July 15, 2026 3:58:07 AM
> community_default_spec.rb
# frozen_string_literal: true

RSpec.describe ESM::CommunityDefault do
  let!(:community) { create(:community) }
  let!(:server) { create(:server, community: community) }

  it "can be created as a global default (no channel_id)" do
    result = create(:community_default, community: community, server: server)
    expect(result.channel_id).to be_nil
  end

  it "can be created with a specific channel_id" do
    channel_id = Faker::Number.number(digits: 18).to_s
    result = create(:community_default, community: community, server: server, channel_id: channel_id)
    expect(result.channel_id).to eq(channel_id)
  end

  describe ".global" do
    it "returns the default with no channel_id" do
      global_default = create(:community_default, community: community, server: server, channel_id: nil)
      create(:community_default, community: community, server: server, channel_id: "123456789")

      expect(described_class.where(community: community, server: server).global).to eq(global_default)
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 43aa0d7