0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/spec/jobs/set_after_time_wizard_spec.rb

34 Zeilen
977 B
Ruby

2020-11-03 01:24:20 +01:00
# frozen_string_literal: true
require_relative '../plugin_helper'
2020-11-03 01:24:20 +01:00
describe Jobs::SetAfterTimeWizard do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
fab!(:user3) { Fabricate(:user) }
2021-03-11 07:30:15 +01:00
2021-09-07 14:06:13 +02:00
let(:template) { get_wizard_fixture("wizard") }
2020-11-03 01:24:20 +01:00
it "sets wizard redirect for all users " do
after_time_template = template.dup
2020-11-23 01:40:46 +01:00
after_time_template["after_time"] = true
after_time_template["after_time_scheduled"] = (Time.now + 3.hours).iso8601
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
CustomWizard::Template.save(after_time_template)
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
messages = MessageBus.track_publish("/redirect_to_wizard") do
described_class.new.execute(wizard_id: 'super_mega_fun_wizard')
end
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
expect(
UserCustomField.where(
name: 'redirect_to_wizard',
value: 'super_mega_fun_wizard'
).length
).to eq(3)
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
expect(messages.first.data).to eq("super_mega_fun_wizard")
2021-03-11 07:30:15 +01:00
expect(messages.first.user_ids).to match_array([user1.id, user2.id, user3.id])
2020-11-03 01:24:20 +01:00
end
2021-03-11 07:30:15 +01:00
end