~cytrogen/masto-fe

890e3347034db20410f8b11a7bf2518cfdf527b9 — Claire 2 years ago c74670b
Add migration tests for negative settings (#27012)

2 files changed, 9 insertions(+), 3 deletions(-)

M db/migrate/20230215074423_move_user_settings.rb
M lib/tasks/tests.rake
M db/migrate/20230215074423_move_user_settings.rb => db/migrate/20230215074423_move_user_settings.rb +1 -1
@@ 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|

M lib/tasks/tests.rake => lib/tasks/tests.rake +8 -2
@@ 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