# frozen_string_literal: true # == Schema Information # # Table name: users # # id :integer not null, primary key # anonymous_by_default :boolean default(FALSE), not null # authentication_token :string not null # avatar :string # comments_always_jump_to_last :boolean default(FALSE), not null # comments_newest_first :boolean default(TRUE), not null # comments_per_page :integer default(20), not null # comments_posted_count :integer default(0), not null # consumed_timestep :integer # current_sign_in_at :datetime # current_sign_in_ip :inet # deleted_at :datetime # description :string # email :string default(""), not null # encrypted_otp_secret :string # encrypted_otp_secret_iv :string # encrypted_otp_secret_salt :string # encrypted_password :string default(""), not null # failed_attempts :integer # fancy_tag_field_on_edit :boolean default(TRUE), not null # fancy_tag_field_on_upload :boolean default(TRUE), not null # forum_posts_count :integer default(0), not null # hide_comments :boolean default(FALSE) # hide_default_role :boolean default(FALSE), not null # hide_vote_counts :boolean default(FALSE), not null # images_per_page :integer default(15), not null # last_renamed_at :datetime default(Thu, 01 Jan 1970 00:00:00.000000000 UTC +00:00), not null # last_sign_in_at :datetime # last_sign_in_ip :inet # locked_at :datetime # messages_newest_first :boolean default(FALSE), not null # metadata_updates_count :integer default(0), not null # name :string not null # no_spoilered_in_watched :boolean default(FALSE), not null # otp_backup_codes :string is an Array # otp_required_for_login :boolean # otp_secret :text # personal_title :string # posts_favorited_count :integer default(0), not null # recent_filter_ids :integer default([]), not null, is an Array # remember_created_at :datetime # reset_password_sent_at :datetime # reset_password_token :string # role :string default("user"), not null # scale_large_images :boolean default(TRUE), not null # scratchpad :text # secondary_role :string # serve_webm :boolean default(FALSE), not null # show_large_thumbnails :boolean default(TRUE), not null # show_sidebar_and_watched_images :boolean default(TRUE), not null # sign_in_count :integer default(0), not null # slug :string not null # spoiler_type :string default("static"), not null # theme :string default("default"), not null # topic_count :integer default(0), not null # unlock_token :string # uploads_count :integer default(0), not null # use_centered_layout :boolean default(FALSE), not null # votes_cast_count :integer default(0), not null # watch_on_new_topic :boolean default(TRUE), not null # watch_on_reply :boolean default(TRUE), not null # watch_on_upload :boolean default(TRUE), not null # watched_images_exclude_str :string default(""), not null # watched_images_query_str :string default(""), not null # watched_tag_ids :integer default([]), not null, is an Array # created_at :datetime not null # updated_at :datetime not null # current_filter_id :integer # deleted_by_user_id :integer # # Indexes # # index_users_on_authentication_token (authentication_token) UNIQUE # index_users_on_current_filter_id (current_filter_id) # index_users_on_deleted_by_user_id (deleted_by_user_id) WHERE (deleted_by_user_id IS NOT NULL) # index_users_on_email (email) UNIQUE # index_users_on_name (name) # index_users_on_reset_password_token (reset_password_token) UNIQUE # index_users_on_slug (slug) # # Foreign Keys # # fk_rails_... (current_filter_id => filters.id) ON DELETE => restrict ON UPDATE => cascade # fk_rails_... (deleted_by_user_id => users.id) ON DELETE => nullify ON UPDATE => cascade # FactoryBot.define do factory :user_old do name { generate(:name) } email { "#{SecureRandom.hex(6)}@example.com" } password { 'WRcWfFxU1BZHtJ' } password_confirmation { 'WRcWfFxU1BZHtJ' } role { 'user' } current_sign_in_ip { '123.123.123.123' } factory :admin do role { 'admin' } end factory :moderator do role { 'moderator' } end factory :assistant do role { 'assistant' } factory :dupe_assistant do transient do roles { [[:moderator, DuplicateReport]] } end end factory :image_assistant do transient do roles { [[:moderator, Image], [:moderator, DuplicateReport]] } end end factory :comment_assistant do transient do roles { [[:moderator, Comment]] } end end factory :tag_assistant do transient do roles { [[:moderator, Tag]] } end end end after(:create) do |u, evaluator| evaluator.roles.each do |role| u.add_role(*role) end end end end