Browse Source

Add migration tests for negative settings (#27012)

lets-bump-hometown-to-mastodon-4.2
Claire 3 years ago committed by GitHub
parent
commit
890e334703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      db/migrate/20230215074423_move_user_settings.rb
  2. 10
      lib/tasks/tests.rake

2
db/migrate/20230215074423_move_user_settings.rb

@ -69,7 +69,7 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
MAPPING.each do |legacy_key, new_key|
value = previous_settings[legacy_key]&.value
next if value.blank?
next if value.nil?
if value.is_a?(Hash)
value.each do |nested_key, nested_value|

10
lib/tasks/tests.rake

@ -59,6 +59,11 @@ namespace :tests do
exit(1)
end
unless User.find(1).settings['web.trends'] == false
puts 'User settings not kept as expected'
exit(1)
end
unless Account.find_remote('bob', 'ActivityPub.com').domain == 'activitypub.com'
puts 'Account domains not properly normalized'
exit(1)
@ -131,7 +136,8 @@ namespace :tests do
INSERT INTO "settings"
(id, thing_type, thing_id, var, value, created_at, updated_at)
VALUES
(3, 'User', 1, 'notification_emails', E'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfollow: false\nreblog: true\nfavourite: true\nmention: false\nfollow_request: true\ndigest: true\nreport: true\npending_account: false\ntrending_tag: true\nappeal: true\n', now(), now());
(3, 'User', 1, 'notification_emails', E'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfollow: false\nreblog: true\nfavourite: true\nmention: false\nfollow_request: true\ndigest: true\nreport: true\npending_account: false\ntrending_tag: true\nappeal: true\n', now(), now()),
(4, 'User', 1, 'trends', E'--- false\n', now(), now());
INSERT INTO "accounts"
(id, username, domain, private_key, public_key, created_at, updated_at)
@ -146,7 +152,7 @@ namespace :tests do
INSERT INTO "settings"
(id, thing_type, thing_id, var, value, created_at, updated_at)
VALUES
(4, 'User', 4, 'default_language', E'--- kmr\n', now(), now());
(5, 'User', 4, 'default_language', E'--- kmr\n', now(), now());
SQL
end

Loading…
Cancel
Save