2022-11-02 21:41:30 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
RSpec.describe DirectMessageChannel do
|
|
|
|
subject(:channel) { Fabricate.build(:direct_message_channel) }
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
it_behaves_like "a chat channel model"
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
it { is_expected.to delegate_method(:allowed_user_ids).to(:direct_message).as(:user_ids) }
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#category_channel?" do
|
|
|
|
it "always returns false" do
|
|
|
|
expect(channel).not_to be_a_category_channel
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|
2022-11-02 22:53:36 +08:00
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#public_channel?" do
|
|
|
|
it "always returns false" do
|
|
|
|
expect(channel).not_to be_a_public_channel
|
|
|
|
end
|
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#chatable_has_custom_fields?" do
|
|
|
|
it "always returns false" do
|
|
|
|
expect(channel).not_to be_a_chatable_has_custom_fields
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|
2022-11-02 22:53:36 +08:00
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#direct_message_channel?" do
|
|
|
|
it "always returns true" do
|
|
|
|
expect(channel).to be_a_direct_message_channel
|
|
|
|
end
|
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#read_restricted?" do
|
|
|
|
it "always returns true" do
|
|
|
|
expect(channel).to be_read_restricted
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|
2022-11-02 22:53:36 +08:00
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#allowed_group_ids" do
|
|
|
|
it "always returns nothing" do
|
|
|
|
expect(channel.allowed_group_ids).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
describe "#chatable_url" do
|
|
|
|
it "always returns nothing" do
|
|
|
|
expect(channel.chatable_url).to be_nil
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|
2022-11-02 22:53:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "#title" do
|
|
|
|
subject(:title) { channel.title(user) }
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
let(:user) { stub }
|
|
|
|
let(:direct_message) { channel.direct_message }
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-11-02 22:53:36 +08:00
|
|
|
it "delegates to direct_message" do
|
|
|
|
direct_message.expects(:chat_channel_title_for_user).with(channel, user).returns("something")
|
|
|
|
expect(title).to eq("something")
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|
|
|
|
end
|
2022-11-09 08:28:31 +08:00
|
|
|
|
|
|
|
describe "slug generation" do
|
|
|
|
subject(:channel) { Fabricate(:direct_message_channel) }
|
|
|
|
|
|
|
|
it "always sets the slug to nil for direct message channels" do
|
|
|
|
channel.name = "Cool Channel"
|
|
|
|
channel.validate!
|
|
|
|
expect(channel.slug).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|
2022-11-02 21:41:30 +08:00
|
|
|
end
|