Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently ignoring it. misc models: convert to strong params. artist commentaries: convert to strong params. * Disallow changing or setting post_id to a nonexistent post. artists: convert to strong params. * Disallow setting `is_banned` in create/update actions. Changing it this way instead of with the ban/unban actions would leave the artist in a partially banned state. bans: convert to strong params. * Disallow changing the user_id after the ban has been created. comments: convert to strong params. favorite groups: convert to strong params. news updates: convert to strong params. post appeals: convert to strong params. post flags: convert to strong params. * Disallow users from setting the `is_deleted` / `is_resolved` flags. ip bans: convert to strong params. user feedbacks: convert to strong params. * Disallow users from setting `disable_dmail_notification` when creating feedbacks. * Disallow changing the user_id after the feedback has been created. notes: convert to strong params. wiki pages: convert to strong params. * Also fix non-Builders being able to delete wiki pages. saved searches: convert to strong params. pools: convert to strong params. * Disallow setting `post_count` or `is_deleted` in create/update actions. janitor trials: convert to strong params. post disapprovals: convert to strong params. * Factor out quick-mod bar to shared partial. * Fix quick-mod bar to use `Post#is_approvable?` to determine visibility of Approve button. dmail filters: convert to strong params. password resets: convert to strong params. user name change requests: convert to strong params. posts: convert to strong params. users: convert to strong params. * Disallow setting password_hash, last_logged_in_at, last_forum_read_at, has_mail, and dmail_filter_attributes[user_id]. * Remove initialize_default_image_size (dead code). uploads: convert to strong params. * Remove `initialize_status` because status already defaults to pending in the database. tag aliases/implications: convert to strong params. tags: convert to strong params. forum posts: convert to strong params. * Disallow changing the topic_id after creating the post. * Disallow setting is_deleted (destroy/undelete actions should be used instead). * Remove is_sticky / is_locked (nonexistent attributes). forum topics: convert to strong params. * merges https://github.com/evazion/danbooru/tree/wip-rails-5.1 * lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4) * switch to factorybot and change all references Co-authored-by: r888888888 <r888888888@gmail.com> Co-authored-by: evazion <noizave@gmail.com> add diffs
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:artist) do
|
||||
name {rand(1_000_000).to_s}
|
||||
is_active true
|
||||
association :creator, factory: :user
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:artist_commentary) do
|
||||
post :factory => :post
|
||||
post factory: :post
|
||||
original_title { FFaker::Lorem.sentences.join(" ") }
|
||||
original_description { FFaker::Lorem.sentences.join(" ") }
|
||||
translated_title { FFaker::Lorem.sentences.join(" ") }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:artist_url) do
|
||||
artist
|
||||
url {FFaker::Internet.domain_name}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:ban) do |f|
|
||||
banner :factory => :admin_user
|
||||
reason {FFaker::Lorem.words.join(" ")}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:bulk_update_request) do |f|
|
||||
title "xxx"
|
||||
script "create alias aaa -> bbb"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:comment) do |f|
|
||||
post
|
||||
body {FFaker::Lorem.sentences.join(" ")}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:comment_vote) do
|
||||
score 1
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:dmail) do
|
||||
to :factory => :user
|
||||
title {FFaker::Lorem.words.join(" ")}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:favorite)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :favorite_group do
|
||||
name { FFaker::Lorem.word }
|
||||
creator
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:forum_post) do
|
||||
body {FFaker::Lorem.sentences.join(" ")}
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:forum_subscription) do
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:forum_topic) do
|
||||
title {FFaker::Lorem.words.join(" ")}
|
||||
is_sticky false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:forum_topic_visit) do
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:ip_ban) do
|
||||
creator :factory => :user
|
||||
reason {FFaker::Lorem.words.join(" ")}
|
||||
ip_addr "127.0.0.1"
|
||||
ip_addr "127.0.0.2"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:janitor_trial) do
|
||||
user
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:mod_action) do
|
||||
creator :factory => :user
|
||||
description "1234"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:news_update) do
|
||||
message "xxx"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:note) do
|
||||
creator
|
||||
post
|
||||
x 1
|
||||
y 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:pool) do
|
||||
name {"pool_" + (rand(1_000_000) + 100).to_s}
|
||||
association :creator, :factory => :user
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:post) do
|
||||
sequence :md5 do |n|
|
||||
n.to_s
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:post_appeal) do
|
||||
reason "xxx"
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:post_disapproval) do
|
||||
reason { %w(breaks_rules poor_quality disinterest).sample }
|
||||
message { FFaker::Lorem.sentence }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:post_flag) do
|
||||
reason "xxx"
|
||||
is_resolved false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:post_replacement) do
|
||||
original_url { FFaker::Internet.http_url }
|
||||
replacement_url { FFaker::Internet.http_url }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:saved_search) do
|
||||
query { FFaker::Lorem.words }
|
||||
labels { [FFaker::Lorem.word] }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:super_voter) do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:tag) do
|
||||
name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
post_count 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :tag_alias do
|
||||
antecedent_name "aaa"
|
||||
consequent_name "bbb"
|
||||
@@ -8,7 +8,7 @@ FactoryGirl.define do
|
||||
|
||||
after(:create) do |tag_alias|
|
||||
unless tag_alias.status == "pending"
|
||||
approver = FactoryGirl.create(:admin_user) unless approver.present?
|
||||
approver = FactoryBot.create(:admin_user) unless approver.present?
|
||||
tag_alias.approve!(approver: approver)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :tag_implication do
|
||||
antecedent_name "aaa"
|
||||
consequent_name "bbb"
|
||||
@@ -7,7 +7,7 @@ FactoryGirl.define do
|
||||
|
||||
after(:create) do |tag_implication|
|
||||
unless tag_implication.status == "pending"
|
||||
approver = FactoryGirl.create(:admin_user) unless approver.present?
|
||||
approver = FactoryBot.create(:admin_user) unless approver.present?
|
||||
tag_implication.approve!(approver: approver)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
require 'fileutils'
|
||||
|
||||
FactoryBot.define do
|
||||
factory(:upload) do
|
||||
rating "s"
|
||||
uploader :factory => :user, :level => 20
|
||||
@@ -19,6 +21,14 @@ FactoryGirl.define do
|
||||
ActionDispatch::Http::UploadedFile.new(tempfile: f, filename: "test.jpg")
|
||||
end
|
||||
end
|
||||
|
||||
factory(:large_jpg_upload) do
|
||||
file do
|
||||
f = Tempfile.new
|
||||
IO.copy_stream("#{Rails.root}/test/files/test-large.jpg", f.path)
|
||||
ActionDispatch::Http::UploadedFile.new(tempfile: f, filename: "test.jpg")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:user, aliases: [:creator, :updater]) do
|
||||
name {(rand(1_000_000) + 10).to_s}
|
||||
password "password"
|
||||
@@ -15,7 +15,6 @@ FactoryGirl.define do
|
||||
factory(:banned_user) do
|
||||
transient { ban_duration 3 }
|
||||
is_banned true
|
||||
after(:create) { |user, ctx| create(:ban, user: user, duration: ctx.ban_duration) }
|
||||
end
|
||||
|
||||
factory(:member_user) do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:user_feedback) do
|
||||
user
|
||||
category "positive"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:user_name_change_request) do
|
||||
desired_name {FFaker::Internet.user_name}
|
||||
change_reason {FFaker::Lorem.sentence}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:user_password_reset_nonce)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory(:wiki_page) do
|
||||
creator :factory => :user
|
||||
title {FFaker::Lorem.words.join(" ")}
|
||||
|
||||
Reference in New Issue
Block a user