discourse/plugins/chat/spec/support/examples/chatable_model.rb
Roman Rizzi 0a5f548635
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00

25 lines
792 B
Ruby

# frozen_string_literal: true
RSpec.shared_examples "a chatable model" do
describe "#chat_channel" do
subject(:chat_channel) { chatable.chat_channel }
it "returns a new chat channel model" do
expect(chat_channel).to have_attributes persisted?: false,
class: channel_class,
chatable: chatable
end
end
describe "#create_chat_channel!" do
subject(:create_chat_channel) { chatable.create_chat_channel!(name: name) }
let(:name) { "a custom name" }
it "creates a proper chat channel" do
expect { create_chat_channel }.to change { channel_class.count }.by(1)
expect(channel_class.last).to have_attributes chatable: chatable, name: name
end
end
end