1
0
Fork 0
discourse-custom-wizard-unl.../spec/jobs/clear_after_time_wizard_spec.rb

42 Zeilen
1,1 KiB
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::ClearAfterTimeWizard do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
fab!(:user3) { Fabricate(:user) }
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
let(:template) {
JSON.parse(File.open(
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/wizard.json"
).read).with_indifferent_access
}
it "clears 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
Jobs::SetAfterTimeWizard.new.execute(wizard_id: 'super_mega_fun_wizard')
2021-03-11 07:30:15 +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
described_class.new.execute(wizard_id: 'super_mega_fun_wizard')
2021-03-11 07:30:15 +01:00
2020-11-03 01:24:20 +01:00
expect(
UserCustomField.where("
name = 'redirect_to_wizard' AND
value = 'super_mega_fun_wizard'
").exists?
).to eq(false)
end
2021-03-11 07:30:15 +01:00
end