FIX: do not destroy recurring events

FIX: do not destroy recurring events

diff --git a/jobs/scheduled/ensure_expired_event_destruction.rb b/jobs/scheduled/ensure_expired_event_destruction.rb
index aefc82c..feb90d0 100644
--- a/jobs/scheduled/ensure_expired_event_destruction.rb
+++ b/jobs/scheduled/ensure_expired_event_destruction.rb
@@ -10,6 +10,8 @@ module Jobs
           details = JSON.parse(pcf.value)
 
           details.each do |post_number, detail|
+            return if detail[::DiscourseCalendar::RECURRING_INDEX]
+
             to = detail[::DiscourseCalendar::TO_INDEX] ||
                  detail[::DiscourseCalendar::FROM_INDEX]
 
diff --git a/spec/jobs/ensure_expired_event_destruction_spec.rb b/spec/jobs/ensure_expired_event_destruction_spec.rb
index d354940..e033577 100644
--- a/spec/jobs/ensure_expired_event_destruction_spec.rb
+++ b/spec/jobs/ensure_expired_event_destruction_spec.rb
@@ -36,4 +36,27 @@ describe DiscourseCalendar::EnsuredExpiredEventDestruction do
 
     expect(@op.calendar_details[@post.post_number.to_s]).to be_nil
   end
+
+  it "wont destroy recurring events" do
+    freeze_time Time.strptime("2018-06-03 09:21:00 UTC", "%Y-%m-%d %H:%M:%S %Z")
+
+    raw = <<~MD
+      Rome [date="2018-06-05" time="10:20:00" recurring="1.weeks"] to [date="2018-06-06" time="11:20:00"]
+    MD
+    @post = create_post(raw: raw, topic: @op.topic)
+    CookedPostProcessor.new(@post).post_process
+
+    DiscourseCalendar::EnsuredExpiredEventDestruction.new.execute(nil)
+    @op.reload
+
+    expect(@op.calendar_details[@post.post_number.to_s]).to eq([
+      "Rome  to", "2018-06-05T10:20:00Z", "2018-06-06T11:20:00Z", @post.user.username_lower, "1.weeks"
+    ])
+
+    freeze_time Time.strptime("2018-06-06 13:21:00 UTC", "%Y-%m-%d %H:%M:%S %Z")
+    DiscourseCalendar::EnsuredExpiredEventDestruction.new.execute(nil)
+    @op.reload
+
+    expect(@op.calendar_details[@post.post_number.to_s]).to_not be_nil
+  end
 end

GitHub sha: 01bbad9d