Fixes #3618 - Ensure to migrate old calendar URLs for google calendar sources

This commit is contained in:
Mantas 2021-06-17 08:37:10 +03:00 committed by Thorsten Eckel
parent bc898f7bea
commit 64f72916cb
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,14 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
class Issue3618GoogleCalendarUrlHttps < ActiveRecord::Migration[5.2]
def change
return if !Setting.exists?(name: 'system_init_done')
Calendar
.where('ical_url LIKE ?', 'http://www.google.com/calendar/ical/%')
.each do |calendar|
calendar.ical_url.sub!(%r{^http://}, 'https://')
calendar.save
end
end
end

View file

@ -0,0 +1,15 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe Issue3618GoogleCalendarUrlHttps, type: :db_migration, db_strategy: :reset do
let(:url) { 'http://www.google.com/calendar/ical/en.lithuanian%%23holiday%%40group.v.calendar.google.com/public/basic.ics' }
let(:calendar) { create :calendar, ical_url: url }
it 'migrates Google Calendar URLs' do
expect { migrate }
.to change { calendar.reload.ical_url.starts_with? 'https://' }
.from(false)
.to(true)
end
end