Files
danbooru/test/factories/user.rb
evazion 7c8c4e9f82 tests: fix null uploader_ip_addr exceptions in create(:post).
Caused by a change in FactoryBot 5. Associations in factories are now
constructed using the same strategy as the base object, meaning that
using `build` to construct an object will also construct the
associations using `build`. This meant that overriding `create` to do
`build` + `save` broke the way that associations were constructed.

https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
2019-08-04 12:43:12 -05:00

65 lines
1.2 KiB
Ruby

FactoryBot.define do
factory(:user, aliases: [:creator, :updater, :uploader]) do
sequence :name do |n|
"user#{n}"
end
password {"password"}
password_hash {User.sha1("password")}
email {FFaker::Internet.email}
default_image_size {"large"}
base_upload_limit {10}
level {20}
created_at {Time.now}
last_logged_in_at {Time.now}
favorite_count {0}
bit_prefs {0}
factory(:banned_user) do
transient { ban_duration {3} }
is_banned {true}
end
factory(:member_user) do
level {20}
end
factory(:gold_user) do
level {30}
end
factory(:platinum_user) do
level {31}
end
factory(:builder_user) do
level {32}
end
factory(:contributor_user) do
level {32}
bit_prefs {User.flag_value_for("can_upload_free")}
end
factory(:contrib_user) do
level {32}
bit_prefs {User.flag_value_for("can_upload_free")}
end
factory(:moderator_user) do
level {40}
can_approve_posts {true}
end
factory(:mod_user) do
level {40}
can_approve_posts {true}
end
factory(:admin_user) do
level {50}
can_approve_posts {true}
end
end
end