2022-11-02 09:41:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-17 09:24:38 -04:00
|
|
|
describe Jobs::Chat::AutoJoinUsers do
|
2023-06-21 10:00:19 -04:00
|
|
|
subject(:job) { described_class.new }
|
|
|
|
|
2022-11-02 09:41:30 -04:00
|
|
|
it "works" do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
channel = Fabricate(:category_channel, auto_join_users: true)
|
|
|
|
user = Fabricate(:user, last_seen_at: 1.minute.ago, active: true)
|
|
|
|
|
2023-03-17 09:24:38 -04:00
|
|
|
membership = Chat::UserChatChannelMembership.find_by(user: user, chat_channel: channel)
|
2022-11-02 09:41:30 -04:00
|
|
|
expect(membership).to be_nil
|
|
|
|
|
2023-06-21 10:00:19 -04:00
|
|
|
job.execute({})
|
2022-11-02 09:41:30 -04:00
|
|
|
|
2023-03-17 09:24:38 -04:00
|
|
|
membership = Chat::UserChatChannelMembership.find_by(user: user, chat_channel: channel)
|
2022-11-02 09:41:30 -04:00
|
|
|
expect(membership.following).to eq(true)
|
|
|
|
end
|
|
|
|
end
|