SPEC: Add test methods for update_holiday_usernames job
This commit is contained in:
parent
28a6631287
commit
4c9d42ecc2
|
@ -1,5 +1,4 @@
|
|||
import loadScript from "discourse/lib/load-script";
|
||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { minimumOffset } from "discourse/lib/offset-calculator";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe DiscourseSimpleCalendar::UpdateHolidayUsernames do
|
||||
before do
|
||||
SiteSetting.queue_jobs = false
|
||||
|
||||
raw = <<~MD
|
||||
[calendar]
|
||||
[/calendar]
|
||||
MD
|
||||
@topic = Fabricate(:topic, first_post: create_post(raw: raw))
|
||||
SiteSetting.discourse_simple_calendar_holiday_post_id = @topic.first_post.id
|
||||
end
|
||||
|
||||
it "should update users on holiday list" do
|
||||
raw = <<~MD
|
||||
Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]
|
||||
MD
|
||||
post = create_post(raw: raw, topic: @topic)
|
||||
CookedPostProcessor.new(post).post_process
|
||||
|
||||
freeze_time Time.strptime("2018-06-05 18:40:00 UTC", "%Y-%m-%d %H:%M:%S %Z")
|
||||
DiscourseSimpleCalendar::UpdateHolidayUsernames.new.execute(nil)
|
||||
|
||||
expect(DiscourseSimpleCalendar.users_on_holiday).to eq([post.user.username])
|
||||
end
|
||||
|
||||
it "should have empty users on holiday list" do
|
||||
raw = <<~MD
|
||||
Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]
|
||||
MD
|
||||
post = create_post(raw: raw, topic: @topic)
|
||||
CookedPostProcessor.new(post).post_process
|
||||
|
||||
freeze_time Time.strptime("2018-06-07 18:40:00 UTC", "%Y-%m-%d %H:%M:%S %Z")
|
||||
DiscourseSimpleCalendar::UpdateHolidayUsernames.new.execute(nil)
|
||||
|
||||
expect(DiscourseSimpleCalendar.users_on_holiday).to eq([])
|
||||
end
|
||||
end
|
|
@ -79,7 +79,7 @@ describe DiscourseSimpleCalendar::EventUpdater do
|
|||
|
||||
op.reload
|
||||
|
||||
detail = op.custom_fields[DiscourseSimpleCalendar::CALENDAR_DETAILS_CUSTOM_FIELD][post.post_number.to_s ]
|
||||
detail = op.custom_fields[DiscourseSimpleCalendar::CALENDAR_DETAILS_CUSTOM_FIELD][post.post_number.to_s]
|
||||
expect(detail[DiscourseSimpleCalendar::FROM_INDEX]).to eq("2018-06-05T00:00:00Z")
|
||||
expect(detail[DiscourseSimpleCalendar::TO_INDEX]).to eq("2018-06-11T23:59:59Z")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue