From 4c9406bdb0938367615a12083199705304d29e27 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 10 Jun 2023 03:29:37 +0200 Subject: [PATCH 1/4] Add time zone preference (#25342) --- app/controllers/api/v1/accounts_controller.rb | 2 +- app/controllers/settings/preferences/base_controller.rb | 2 +- app/models/account.rb | 1 + app/models/user.rb | 2 ++ app/services/app_sign_up_service.rb | 2 +- app/views/notification_mailer/_status.html.haml | 2 +- app/views/notification_mailer/favourite.html.haml | 2 +- app/views/notification_mailer/mention.html.haml | 2 +- app/views/notification_mailer/reblog.html.haml | 2 +- app/views/settings/preferences/appearance/show.html.haml | 7 +++++-- app/views/user_mailer/appeal_approved.html.haml | 2 +- app/views/user_mailer/appeal_approved.text.erb | 2 +- app/views/user_mailer/appeal_rejected.html.haml | 2 +- app/views/user_mailer/appeal_rejected.text.erb | 2 +- app/views/user_mailer/suspicious_sign_in.html.haml | 2 +- app/views/user_mailer/suspicious_sign_in.text.erb | 2 +- app/views/user_mailer/warning.html.haml | 2 +- config/locales/simple_form.en.yml | 1 + db/migrate/20230605085711_add_time_zone_to_users.rb | 7 +++++++ db/schema.rb | 3 ++- 20 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20230605085711_add_time_zone_to_users.rb diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 8af4242ba3..ddb94d5ca4 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -90,7 +90,7 @@ class Api::V1::AccountsController < Api::BaseController end def account_params - params.permit(:username, :email, :password, :agreement, :locale, :reason) + params.permit(:username, :email, :password, :agreement, :locale, :reason, :time_zone) end def check_enabled_registrations diff --git a/app/controllers/settings/preferences/base_controller.rb b/app/controllers/settings/preferences/base_controller.rb index faf778a7e5..c1f8b49898 100644 --- a/app/controllers/settings/preferences/base_controller.rb +++ b/app/controllers/settings/preferences/base_controller.rb @@ -19,6 +19,6 @@ class Settings::Preferences::BaseController < Settings::BaseController end def user_params - params.require(:user).permit(:locale, chosen_languages: [], settings_attributes: UserSettings.keys) + params.require(:user).permit(:locale, :time_zone, chosen_languages: [], settings_attributes: UserSettings.keys) end end diff --git a/app/models/account.rb b/app/models/account.rb index 1d24a7ec81..8a606fd2a2 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -140,6 +140,7 @@ class Account < ApplicationRecord :locale, :shows_application?, :prefers_noindex?, + :time_zone, to: :user, prefix: true, allow_nil: true diff --git a/app/models/user.rb b/app/models/user.rb index b903344be9..5ee14bbdaf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,6 +40,7 @@ # sign_up_ip :inet # role_id :bigint(8) # settings :text +# time_zone :string # class User < ApplicationRecord @@ -99,6 +100,7 @@ class User < ApplicationRecord validates_with BlacklistedEmailValidator, if: -> { ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed? } validates_with EmailMxValidator, if: :validate_email_dns? validates :agreement, acceptance: { allow_nil: false, accept: [true, 'true', '1'] }, on: :create + validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map { |tz| tz.tzinfo.name } }, allow_blank: true # Honeypot/anti-spam fields attr_accessor :registration_form_time, :website, :confirm_password diff --git a/app/services/app_sign_up_service.rb b/app/services/app_sign_up_service.rb index 3833327bbc..94547b61b2 100644 --- a/app/services/app_sign_up_service.rb +++ b/app/services/app_sign_up_service.rb @@ -35,7 +35,7 @@ class AppSignUpService < BaseService end def user_params - @params.slice(:email, :password, :agreement, :locale) + @params.slice(:email, :password, :agreement, :locale, :time_zone) end def account_params diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index fd65039ae9..d8aa38b112 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -42,4 +42,4 @@ = link_to a.remote_url, a.remote_url %p.status-footer - = link_to l(status.created_at), web_url("@#{status.account.pretty_acct}/#{status.id}") + = link_to l(status.created_at.in_time_zone(time_zone)), web_url("@#{status.account.pretty_acct}/#{status.id}") diff --git a/app/views/notification_mailer/favourite.html.haml b/app/views/notification_mailer/favourite.html.haml index 4ec89172d9..325f0aff5f 100644 --- a/app/views/notification_mailer/favourite.html.haml +++ b/app/views/notification_mailer/favourite.html.haml @@ -22,7 +22,7 @@ %h1= t 'notification_mailer.favourite.title' %p.lead= t('notification_mailer.favourite.body', name: @account.pretty_acct) -= render 'status', status: @status += render 'status', status: @status, time_zone: @me.user_time_zone %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/notification_mailer/mention.html.haml b/app/views/notification_mailer/mention.html.haml index 4ae9bb7b0b..e830644c3f 100644 --- a/app/views/notification_mailer/mention.html.haml +++ b/app/views/notification_mailer/mention.html.haml @@ -22,7 +22,7 @@ %h1= t 'notification_mailer.mention.title' %p.lead= t('notification_mailer.mention.body', name: @status.account.pretty_acct) -= render 'status', status: @status += render 'status', status: @status, time_zone: @me.user_time_zone %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/notification_mailer/reblog.html.haml b/app/views/notification_mailer/reblog.html.haml index f805c79f0d..e4f9441236 100644 --- a/app/views/notification_mailer/reblog.html.haml +++ b/app/views/notification_mailer/reblog.html.haml @@ -22,7 +22,7 @@ %h1= t 'notification_mailer.reblog.title' %p.lead= t('notification_mailer.reblog.body', name: @account.pretty_acct) -= render 'status', status: @status += render 'status', status: @status, time_zone: @me.user_time_zone %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index af61df71b8..ce3a30c5ee 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -9,8 +9,11 @@ .fields-group.fields-row__column.fields-row__column-6 = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| native_locale_name(locale) }, selected: I18n.locale, hint: false .fields-group.fields-row__column.fields-row__column-6 - = f.simple_fields_for :settings, current_user.settings do |ff| - = ff.input :theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_theme'), include_blank: false, hint: false + = f.input :time_zone, wrapper: :with_label, collection: ActiveSupport::TimeZone.all.map { |tz| ["(GMT#{tz.formatted_offset}) #{tz.name}", tz.tzinfo.name] }, hint: false + + .fields-group + = f.simple_fields_for :settings, current_user.settings do |ff| + = ff.input :theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_theme'), include_blank: false, hint: false - unless I18n.locale == :en .flash-message.translation-prompt diff --git a/app/views/user_mailer/appeal_approved.html.haml b/app/views/user_mailer/appeal_approved.html.haml index 962cab2e2c..d62789a067 100644 --- a/app/views/user_mailer/appeal_approved.html.haml +++ b/app/views/user_mailer/appeal_approved.html.haml @@ -36,7 +36,7 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) + %p= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/appeal_approved.text.erb b/app/views/user_mailer/appeal_approved.text.erb index 290fa24c36..99596605aa 100644 --- a/app/views/user_mailer/appeal_approved.text.erb +++ b/app/views/user_mailer/appeal_approved.text.erb @@ -2,6 +2,6 @@ === -<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) %> +<%= t 'user_mailer.appeal_approved.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %> => <%= root_url %> diff --git a/app/views/user_mailer/appeal_rejected.html.haml b/app/views/user_mailer/appeal_rejected.html.haml index c316a73fb5..ae60775b01 100644 --- a/app/views/user_mailer/appeal_rejected.html.haml +++ b/app/views/user_mailer/appeal_rejected.html.haml @@ -36,7 +36,7 @@ %tbody %tr %td.column-cell.text-center - %p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) + %p= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/appeal_rejected.text.erb b/app/views/user_mailer/appeal_rejected.text.erb index f47a768181..3c93777180 100644 --- a/app/views/user_mailer/appeal_rejected.text.erb +++ b/app/views/user_mailer/appeal_rejected.text.erb @@ -2,6 +2,6 @@ === -<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at), strike_date: l(@appeal.strike.created_at) %> +<%= t 'user_mailer.appeal_rejected.explanation', appeal_date: l(@appeal.created_at.in_time_zone(@resource.time_zone)), strike_date: l(@appeal.strike.created_at.in_time_zone(@resource.time_zone)) %> => <%= root_url %> diff --git a/app/views/user_mailer/suspicious_sign_in.html.haml b/app/views/user_mailer/suspicious_sign_in.html.haml index e4ad500c3d..6ebba3fa55 100644 --- a/app/views/user_mailer/suspicious_sign_in.html.haml +++ b/app/views/user_mailer/suspicious_sign_in.html.haml @@ -47,7 +47,7 @@ %strong= "#{t('sessions.browser')}:" %span{ title: @user_agent }= t 'sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s) %br/ - = l(@timestamp) + = l(@timestamp.in_time_zone(@resource.time_zone)) %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/app/views/user_mailer/suspicious_sign_in.text.erb b/app/views/user_mailer/suspicious_sign_in.text.erb index 7d2ca28e84..956071e774 100644 --- a/app/views/user_mailer/suspicious_sign_in.text.erb +++ b/app/views/user_mailer/suspicious_sign_in.text.erb @@ -8,7 +8,7 @@ <%= t('sessions.ip') %>: <%= @remote_ip %> <%= t('sessions.browser') %>: <%= t('sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: "#{@detection.id}"), platform: t("sessions.platforms.#{@detection.platform.id}", default: "#{@detection.platform.id}")) %> -<%= l(@timestamp) %> +<%= l(@timestamp.in_time_zone(@resource.time_zone)) %> <%= t 'user_mailer.suspicious_sign_in.further_actions_html', action: t('user_mailer.suspicious_sign_in.change_password') %> diff --git a/app/views/user_mailer/warning.html.haml b/app/views/user_mailer/warning.html.haml index b9422e9502..9cb73b0fee 100644 --- a/app/views/user_mailer/warning.html.haml +++ b/app/views/user_mailer/warning.html.haml @@ -58,7 +58,7 @@ - unless @statuses.empty? - @statuses.each_with_index do |status, i| - = render 'notification_mailer/status', status: status, i: i + 1, highlighted: true + = render 'notification_mailer/status', status: status, i: i + 1, highlighted: true, time_zone: @resource.time_zone %table.email-table{ cellspacing: 0, cellpadding: 0 } %tbody diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index f92e66e55a..330c8732ff 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -297,6 +297,7 @@ en: usable: Allow posts to use this hashtag user: role: Role + time_zone: Time zone user_role: color: Badge color highlighted: Display role as badge on user profiles diff --git a/db/migrate/20230605085711_add_time_zone_to_users.rb b/db/migrate/20230605085711_add_time_zone_to_users.rb new file mode 100644 index 0000000000..fc6c0b091c --- /dev/null +++ b/db/migrate/20230605085711_add_time_zone_to_users.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddTimeZoneToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :time_zone, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 28d8d83902..9866b10149 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_06_05_085710) do +ActiveRecord::Schema.define(version: 2023_06_05_085711) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1088,6 +1088,7 @@ ActiveRecord::Schema.define(version: 2023_06_05_085710) do t.boolean "skip_sign_in_token" t.bigint "role_id" t.text "settings" + t.string "time_zone" t.index ["account_id"], name: "index_users_on_account_id" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)" From c81f59583cf35dabbe58621042b334b9d8cf40b0 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Sat, 10 Jun 2023 18:24:37 +0200 Subject: [PATCH 2/4] Fix logging of messages that are binary before closing their connection (#25361) --- streaming/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streaming/index.js b/streaming/index.js index 4b2607ed92..9b43112d22 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -1209,7 +1209,7 @@ const startServer = async () => { ws.on('message', (data, isBinary) => { if (isBinary) { - log.debug('Received binary data, closing connection'); + log.warn('socket', 'Received binary data, closing connection'); ws.close(1003, 'The mastodon streaming server does not support binary messages'); return; } From c94bb9ba9a1df2e060e6f3debff57a0b7539be9f Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 10 Jun 2023 12:27:35 -0400 Subject: [PATCH 3/4] Disable paperclip processing in specs (#25359) --- spec/models/media_attachment_spec.rb | 2 +- spec/rails_helper.rb | 6 ++++++ spec/support/examples/models/concerns/account_avatar.rb | 2 +- spec/support/examples/models/concerns/account_header.rb | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 4d4bc748f7..2dfc6cf925 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe MediaAttachment do +RSpec.describe MediaAttachment, paperclip_processing: true do describe 'local?' do subject { media_attachment.local? } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d7e2b5c185..f4113d565f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -94,6 +94,12 @@ RSpec.configure do |config| stub_jsonld_contexts! end + config.before(:each) do |example| + unless example.metadata[:paperclip_processing] + allow_any_instance_of(Paperclip::Attachment).to receive(:post_process).and_return(true) # rubocop:disable RSpec/AnyInstance + end + end + config.after :each do Rails.cache.clear redis.del(redis.keys) diff --git a/spec/support/examples/models/concerns/account_avatar.rb b/spec/support/examples/models/concerns/account_avatar.rb index 2180f52739..8f5b81f3a5 100644 --- a/spec/support/examples/models/concerns/account_avatar.rb +++ b/spec/support/examples/models/concerns/account_avatar.rb @@ -17,7 +17,7 @@ shared_examples 'AccountAvatar' do |fabricator| end end - describe 'base64-encoded files' do + describe 'base64-encoded files', paperclip_processing: true do let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" } let(:account) { Fabricate(fabricator, avatar: base64_attachment) } diff --git a/spec/support/examples/models/concerns/account_header.rb b/spec/support/examples/models/concerns/account_header.rb index 77ee0e6290..d65f54f00f 100644 --- a/spec/support/examples/models/concerns/account_header.rb +++ b/spec/support/examples/models/concerns/account_header.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true shared_examples 'AccountHeader' do |fabricator| - describe 'base64-encoded files' do + describe 'base64-encoded files', paperclip_processing: true do let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" } let(:account) { Fabricate(fabricator, header: base64_attachment) } From 3a2a15c6ea4d4603469861ed9be09da12a122e45 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 10 Jun 2023 12:29:01 -0400 Subject: [PATCH 4/4] Use `build` where possible in fabricators (#25360) --- spec/fabricators/account_domain_block_fabricator.rb | 2 +- spec/fabricators/account_moderation_note_fabricator.rb | 4 ++-- spec/fabricators/account_note_fabricator.rb | 4 ++-- spec/fabricators/account_stat_fabricator.rb | 2 +- .../fabricators/account_statuses_cleanup_policy_fabricator.rb | 2 +- spec/fabricators/account_warning_fabricator.rb | 2 +- spec/fabricators/admin_action_log_fabricator.rb | 2 +- spec/fabricators/backup_fabricator.rb | 2 +- spec/fabricators/block_fabricator.rb | 4 ++-- spec/fabricators/bookmark_fabricator.rb | 4 ++-- spec/fabricators/bulk_import_fabricator.rb | 2 +- spec/fabricators/bulk_import_row_fabricator.rb | 2 +- spec/fabricators/canonical_email_block_fabricator.rb | 2 +- spec/fabricators/custom_filter_fabricator.rb | 2 +- spec/fabricators/custom_filter_keyword_fabricator.rb | 2 +- spec/fabricators/custom_filter_status_fabricator.rb | 4 ++-- spec/fabricators/device_fabricator.rb | 4 ++-- spec/fabricators/encrypted_message_fabricator.rb | 4 ++-- spec/fabricators/favourite_fabricator.rb | 4 ++-- spec/fabricators/featured_tag_fabricator.rb | 4 ++-- spec/fabricators/follow_fabricator.rb | 4 ++-- spec/fabricators/follow_request_fabricator.rb | 4 ++-- spec/fabricators/identity_fabricator.rb | 2 +- spec/fabricators/invite_fabricator.rb | 2 +- spec/fabricators/list_fabricator.rb | 2 +- spec/fabricators/login_activity_fabricator.rb | 2 +- spec/fabricators/marker_fabricator.rb | 2 +- spec/fabricators/media_attachment_fabricator.rb | 2 +- spec/fabricators/mention_fabricator.rb | 4 ++-- spec/fabricators/mute_fabricator.rb | 4 ++-- spec/fabricators/notification_fabricator.rb | 2 +- spec/fabricators/one_time_key_fabricator.rb | 2 +- spec/fabricators/poll_fabricator.rb | 4 ++-- spec/fabricators/poll_vote_fabricator.rb | 2 +- spec/fabricators/report_fabricator.rb | 4 ++-- spec/fabricators/report_note_fabricator.rb | 4 ++-- spec/fabricators/scheduled_status_fabricator.rb | 2 +- spec/fabricators/session_activation_fabricator.rb | 2 +- spec/fabricators/status_fabricator.rb | 2 +- spec/fabricators/status_pin_fabricator.rb | 4 ++-- spec/fabricators/tag_follow_fabricator.rb | 2 +- 41 files changed, 58 insertions(+), 58 deletions(-) diff --git a/spec/fabricators/account_domain_block_fabricator.rb b/spec/fabricators/account_domain_block_fabricator.rb index ff85e17f3f..83df509da2 100644 --- a/spec/fabricators/account_domain_block_fabricator.rb +++ b/spec/fabricators/account_domain_block_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:account_domain_block) do - account + account { Fabricate.build(:account) } domain 'example.com' end diff --git a/spec/fabricators/account_moderation_note_fabricator.rb b/spec/fabricators/account_moderation_note_fabricator.rb index 341a24dea0..05a687bf4e 100644 --- a/spec/fabricators/account_moderation_note_fabricator.rb +++ b/spec/fabricators/account_moderation_note_fabricator.rb @@ -2,6 +2,6 @@ Fabricator(:account_moderation_note) do content 'MyText' - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/account_note_fabricator.rb b/spec/fabricators/account_note_fabricator.rb index bb4ed8b24d..241362c144 100644 --- a/spec/fabricators/account_note_fabricator.rb +++ b/spec/fabricators/account_note_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_note) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } comment 'User note text' end diff --git a/spec/fabricators/account_stat_fabricator.rb b/spec/fabricators/account_stat_fabricator.rb index e6085c5f2b..20272fb22f 100644 --- a/spec/fabricators/account_stat_fabricator.rb +++ b/spec/fabricators/account_stat_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_stat) do - account + account { Fabricate.build(:account) } statuses_count '123' following_count '456' followers_count '789' diff --git a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb index 0e756ddbaa..fcf7a53475 100644 --- a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb +++ b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true Fabricator(:account_statuses_cleanup_policy) do - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/account_warning_fabricator.rb b/spec/fabricators/account_warning_fabricator.rb index e5059e37f5..70005a927b 100644 --- a/spec/fabricators/account_warning_fabricator.rb +++ b/spec/fabricators/account_warning_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_warning) do - account + account { Fabricate.build(:account) } target_account(fabricator: :account) text { Faker::Lorem.paragraph } action 'suspend' diff --git a/spec/fabricators/admin_action_log_fabricator.rb b/spec/fabricators/admin_action_log_fabricator.rb index a259644bdc..3acedbffd3 100644 --- a/spec/fabricators/admin_action_log_fabricator.rb +++ b/spec/fabricators/admin_action_log_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator('Admin::ActionLog') do - account + account { Fabricate.build(:account) } action 'MyString' target nil end diff --git a/spec/fabricators/backup_fabricator.rb b/spec/fabricators/backup_fabricator.rb index c73ae54bed..58e37c9875 100644 --- a/spec/fabricators/backup_fabricator.rb +++ b/spec/fabricators/backup_fabricator.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true Fabricator(:backup) do - user + user { Fabricate.build(:user) } end diff --git a/spec/fabricators/block_fabricator.rb b/spec/fabricators/block_fabricator.rb index c2e9e9628d..c4087e46d2 100644 --- a/spec/fabricators/block_fabricator.rb +++ b/spec/fabricators/block_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:block) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/bookmark_fabricator.rb b/spec/fabricators/bookmark_fabricator.rb index e21046fc25..994ac6e687 100644 --- a/spec/fabricators/bookmark_fabricator.rb +++ b/spec/fabricators/bookmark_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:bookmark) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/bulk_import_fabricator.rb b/spec/fabricators/bulk_import_fabricator.rb index 673b7960d9..d30758dfe0 100644 --- a/spec/fabricators/bulk_import_fabricator.rb +++ b/spec/fabricators/bulk_import_fabricator.rb @@ -8,5 +8,5 @@ Fabricator(:bulk_import) do imported_items 1 finished_at '2022-11-18 14:55:07' overwrite false - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/bulk_import_row_fabricator.rb b/spec/fabricators/bulk_import_row_fabricator.rb index f8358e734d..10a4bf1608 100644 --- a/spec/fabricators/bulk_import_row_fabricator.rb +++ b/spec/fabricators/bulk_import_row_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:bulk_import_row) do - bulk_import + bulk_import { Fabricate.build(:bulk_import) } data '' end diff --git a/spec/fabricators/canonical_email_block_fabricator.rb b/spec/fabricators/canonical_email_block_fabricator.rb index 3a018059fc..1ef53ff4a4 100644 --- a/spec/fabricators/canonical_email_block_fabricator.rb +++ b/spec/fabricators/canonical_email_block_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:canonical_email_block) do email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } } - reference_account { Fabricate(:account) } + reference_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/custom_filter_fabricator.rb b/spec/fabricators/custom_filter_fabricator.rb index 5fee4f01af..766cc3b115 100644 --- a/spec/fabricators/custom_filter_fabricator.rb +++ b/spec/fabricators/custom_filter_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:custom_filter) do - account + account { Fabricate.build(:account) } expires_at nil phrase 'discourse' context %w(home notifications) diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index f1fb440dc5..aa4bf84739 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:custom_filter_keyword) do - custom_filter + custom_filter { Fabricate.build(:custom_filter) } keyword 'discourse' end diff --git a/spec/fabricators/custom_filter_status_fabricator.rb b/spec/fabricators/custom_filter_status_fabricator.rb index 3ef1d0ec83..f66f62e561 100644 --- a/spec/fabricators/custom_filter_status_fabricator.rb +++ b/spec/fabricators/custom_filter_status_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:custom_filter_status) do - custom_filter - status + custom_filter { Fabricate.build(:custom_filter) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/device_fabricator.rb b/spec/fabricators/device_fabricator.rb index 26c71b4fdd..37a2e8977d 100644 --- a/spec/fabricators/device_fabricator.rb +++ b/spec/fabricators/device_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:device) do - access_token - account + access_token { Fabricate.build(:access_token) } + account { Fabricate.build(:account) } device_id { Faker::Number.number(digits: 5) } name { Faker::App.name } fingerprint_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) } diff --git a/spec/fabricators/encrypted_message_fabricator.rb b/spec/fabricators/encrypted_message_fabricator.rb index 43b3105146..349b659c2f 100644 --- a/spec/fabricators/encrypted_message_fabricator.rb +++ b/spec/fabricators/encrypted_message_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:encrypted_message) do - device - from_account { Fabricate(:account) } + device { Fabricate.build(:device) } + from_account { Fabricate.build(:account) } from_device_id { Faker::Number.number(digits: 5) } end diff --git a/spec/fabricators/favourite_fabricator.rb b/spec/fabricators/favourite_fabricator.rb index 005947e6f8..639416987e 100644 --- a/spec/fabricators/favourite_fabricator.rb +++ b/spec/fabricators/favourite_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:favourite) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/featured_tag_fabricator.rb b/spec/fabricators/featured_tag_fabricator.rb index 838364056b..0803dc43a7 100644 --- a/spec/fabricators/featured_tag_fabricator.rb +++ b/spec/fabricators/featured_tag_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:featured_tag) do - account - tag + account { Fabricate.build(:account) } + tag { Fabricate.build(:tag) } name { sequence(:name) { |i| "Tag#{i}" } } end diff --git a/spec/fabricators/follow_fabricator.rb b/spec/fabricators/follow_fabricator.rb index 41b5305d55..29886b4301 100644 --- a/spec/fabricators/follow_fabricator.rb +++ b/spec/fabricators/follow_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:follow) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/follow_request_fabricator.rb b/spec/fabricators/follow_request_fabricator.rb index 86b82611f7..6b2d658a37 100644 --- a/spec/fabricators/follow_request_fabricator.rb +++ b/spec/fabricators/follow_request_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:follow_request) do - account - target_account { Fabricate(:account, locked: true) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account, locked: true) } end diff --git a/spec/fabricators/identity_fabricator.rb b/spec/fabricators/identity_fabricator.rb index 58072c0d65..83655ee839 100644 --- a/spec/fabricators/identity_fabricator.rb +++ b/spec/fabricators/identity_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:identity) do - user + user { Fabricate.build(:user) } provider 'MyString' uid 'MyString' end diff --git a/spec/fabricators/invite_fabricator.rb b/spec/fabricators/invite_fabricator.rb index 4f47d6ce2f..8fdf5f9185 100644 --- a/spec/fabricators/invite_fabricator.rb +++ b/spec/fabricators/invite_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:invite) do - user + user { Fabricate.build(:user) } expires_at nil max_uses nil uses 0 diff --git a/spec/fabricators/list_fabricator.rb b/spec/fabricators/list_fabricator.rb index 47af752b8c..d2bdc10129 100644 --- a/spec/fabricators/list_fabricator.rb +++ b/spec/fabricators/list_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:list) do - account + account { Fabricate.build(:account) } title 'MyString' end diff --git a/spec/fabricators/login_activity_fabricator.rb b/spec/fabricators/login_activity_fabricator.rb index 2b30658ff5..3309a303db 100644 --- a/spec/fabricators/login_activity_fabricator.rb +++ b/spec/fabricators/login_activity_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:login_activity) do - user + user { Fabricate.build(:user) } authentication_method 'password' success true failure_reason nil diff --git a/spec/fabricators/marker_fabricator.rb b/spec/fabricators/marker_fabricator.rb index 561c2553ae..641db6b9ec 100644 --- a/spec/fabricators/marker_fabricator.rb +++ b/spec/fabricators/marker_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:marker) do - user + user { Fabricate.build(:user) } timeline 'home' last_read_id 0 lock_version 0 diff --git a/spec/fabricators/media_attachment_fabricator.rb b/spec/fabricators/media_attachment_fabricator.rb index 4a081dccbe..062d3cbfec 100644 --- a/spec/fabricators/media_attachment_fabricator.rb +++ b/spec/fabricators/media_attachment_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:media_attachment) do - account + account { Fabricate.build(:account) } file do |attrs| case attrs[:type] diff --git a/spec/fabricators/mention_fabricator.rb b/spec/fabricators/mention_fabricator.rb index 5a83928275..ee8160aeb3 100644 --- a/spec/fabricators/mention_fabricator.rb +++ b/spec/fabricators/mention_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:mention) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/mute_fabricator.rb b/spec/fabricators/mute_fabricator.rb index 242ae2b08e..a70d3ff26d 100644 --- a/spec/fabricators/mute_fabricator.rb +++ b/spec/fabricators/mute_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:mute) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/notification_fabricator.rb b/spec/fabricators/notification_fabricator.rb index 1e0c809874..fdfd7673ef 100644 --- a/spec/fabricators/notification_fabricator.rb +++ b/spec/fabricators/notification_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:notification) do activity fabricator: :status - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/one_time_key_fabricator.rb b/spec/fabricators/one_time_key_fabricator.rb index cfb365cabb..505282e05d 100644 --- a/spec/fabricators/one_time_key_fabricator.rb +++ b/spec/fabricators/one_time_key_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:one_time_key) do - device + device { Fabricate.build(:device) } key_id { Faker::Alphanumeric.alphanumeric(number: 10) } key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) } diff --git a/spec/fabricators/poll_fabricator.rb b/spec/fabricators/poll_fabricator.rb index 19c3b1d164..0203609ce7 100644 --- a/spec/fabricators/poll_fabricator.rb +++ b/spec/fabricators/poll_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:poll) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } expires_at { 7.days.from_now } options %w(Foo Bar) multiple false diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index 9099ae96fe..47813cdb71 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:poll_vote) do - account + account { Fabricate.build(:account) } poll choice 0 end diff --git a/spec/fabricators/report_fabricator.rb b/spec/fabricators/report_fabricator.rb index 7124773ad0..ed890230a7 100644 --- a/spec/fabricators/report_fabricator.rb +++ b/spec/fabricators/report_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:report) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } comment 'You nasty' action_taken_at nil end diff --git a/spec/fabricators/report_note_fabricator.rb b/spec/fabricators/report_note_fabricator.rb index f257fe2b7d..080fad51ac 100644 --- a/spec/fabricators/report_note_fabricator.rb +++ b/spec/fabricators/report_note_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:report_note) do - report - account { Fabricate(:account) } + report { Fabricate.build(:report) } + account { Fabricate.build(:account) } content 'Test Content' end diff --git a/spec/fabricators/scheduled_status_fabricator.rb b/spec/fabricators/scheduled_status_fabricator.rb index e517f258a2..eed275ab92 100644 --- a/spec/fabricators/scheduled_status_fabricator.rb +++ b/spec/fabricators/scheduled_status_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:scheduled_status) do - account + account { Fabricate.build(:account) } scheduled_at { 20.hours.from_now } end diff --git a/spec/fabricators/session_activation_fabricator.rb b/spec/fabricators/session_activation_fabricator.rb index b28d5e41d7..4b5244cec6 100644 --- a/spec/fabricators/session_activation_fabricator.rb +++ b/spec/fabricators/session_activation_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:session_activation) do - user + user { Fabricate.build(:user) } session_id 'MyString' end diff --git a/spec/fabricators/status_fabricator.rb b/spec/fabricators/status_fabricator.rb index 17ac9ccd8a..32a2cbf6ac 100644 --- a/spec/fabricators/status_fabricator.rb +++ b/spec/fabricators/status_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:status) do - account + account { Fabricate.build(:account) } text 'Lorem ipsum dolor sit amet' after_build do |status| diff --git a/spec/fabricators/status_pin_fabricator.rb b/spec/fabricators/status_pin_fabricator.rb index 9ad0ac9de3..ceaaa34a79 100644 --- a/spec/fabricators/status_pin_fabricator.rb +++ b/spec/fabricators/status_pin_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:status_pin) do - account - status { |attrs| Fabricate(:status, account: attrs[:account], visibility: :public) } + account { Fabricate.build(:account) } + status { |attrs| Fabricate.build(:status, account: attrs[:account], visibility: :public) } end diff --git a/spec/fabricators/tag_follow_fabricator.rb b/spec/fabricators/tag_follow_fabricator.rb index cbe5b09898..014435d606 100644 --- a/spec/fabricators/tag_follow_fabricator.rb +++ b/spec/fabricators/tag_follow_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:tag_follow) do tag - account + account { Fabricate.build(:account) } end