Fixes #3618 - Ensure to migrate old calendar URLs for google calendar sources
This commit is contained in:
parent
bc898f7bea
commit
64f72916cb
2 changed files with 29 additions and 0 deletions
|
@ -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
|
15
spec/db/migrate/issue_3618_google_calendar_url_https_spec.rb
Normal file
15
spec/db/migrate/issue_3618_google_calendar_url_https_spec.rb
Normal 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
|
Loading…
Reference in a new issue