2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-24 01:50:20 -04:00
|
|
|
RSpec.describe Jobs::SendDefaultWelcomeMessage do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
it "should send the right welcome message" do
|
|
|
|
described_class.new.execute(user_id: user.id)
|
|
|
|
|
|
|
|
topic = Topic.last
|
|
|
|
|
|
|
|
expect(topic.title).to eq(
|
|
|
|
I18n.t("system_messages.welcome_user.subject_template", site_name: SiteSetting.title),
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(topic.first_post.raw).to eq(
|
|
|
|
I18n.t(
|
|
|
|
"system_messages.welcome_user.text_body_template",
|
|
|
|
SystemMessage.new(user).defaults,
|
|
|
|
).chomp,
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(topic.closed).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "for an invited user" do
|
2020-06-09 11:19:32 -04:00
|
|
|
let(:invite) { Fabricate(:invite, email: "foo@bar.com") }
|
|
|
|
let(:invited_user) do
|
|
|
|
Fabricate(
|
|
|
|
:invited_user,
|
|
|
|
invite: invite,
|
|
|
|
user: Fabricate(:user, email: "foo@bar.com"),
|
|
|
|
redeemed_at: Time.zone.now,
|
|
|
|
)
|
2023-01-06 15:42:16 -05:00
|
|
|
end
|
2017-05-24 01:50:20 -04:00
|
|
|
|
|
|
|
it "should send the right welcome message" do
|
2020-06-09 11:19:32 -04:00
|
|
|
described_class.new.execute(user_id: invited_user.user_id)
|
2017-05-24 01:50:20 -04:00
|
|
|
|
|
|
|
topic = Topic.last
|
|
|
|
|
|
|
|
expect(topic.title).to eq(
|
|
|
|
I18n.t("system_messages.welcome_invite.subject_template", site_name: SiteSetting.title),
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(topic.first_post.raw).to eq(
|
|
|
|
I18n.t(
|
|
|
|
"system_messages.welcome_invite.text_body_template",
|
2020-06-09 11:19:32 -04:00
|
|
|
SystemMessage.new(invited_user.user).defaults,
|
2017-05-24 01:50:20 -04:00
|
|
|
).chomp,
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(topic.closed).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|