models: remove belongs_to_creator macro.

The belongs_to_creator macro was used to initialize the creator_id field
to the CurrentUser. This made tests complicated because it meant you had
to create and set the current user every time you wanted to create an
object, when lead to the current user being set over and over again. It
also meant you had to constantly be aware of what the CurrentUser was in
many different contexts, which was often confusing. Setting creators
explicitly simplifies everything greatly.
This commit is contained in:
evazion
2020-01-18 15:52:01 -06:00
parent 77bf9ac7f3
commit b4ce2d83a6
86 changed files with 215 additions and 433 deletions

View File

@@ -1,7 +1,7 @@
FactoryBot.define do
factory(:artist) do
creator
name { rand(1_000_000).to_s }
is_active { true }
association :creator, factory: :user
end
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:bulk_update_request) do |f|
user
title {"xxx"}
script {"create alias aaa -> bbb"}
skip_secondary_validations {true}

View File

@@ -1,6 +1,8 @@
FactoryBot.define do
factory(:comment) do |f|
creator
post
creator_ip_addr { FFaker::Internet.ip_v4_address }
body {FFaker::Lorem.sentences.join(" ")}
end
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory :favorite_group do
creator
name { FFaker::Lorem.word }
end
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:forum_post) do
creator
body {FFaker::Lorem.sentences.join(" ")}
end
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:forum_topic) do
creator
title {FFaker::Lorem.words.join(" ")}
is_sticky {false}
is_locked {false}

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:news_update) do
creator
message {"xxx"}
end
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:note) do
creator
post
x { 1 }
y { 1 }

View File

@@ -1,7 +1,7 @@
FactoryBot.define do
factory(:pool) do
creator
name {"pool_" + rand(100..1000099).to_s}
association :creator, :factory => :user
description {FFaker::Lorem.sentences.join(" ")}
end
end

View File

@@ -1,5 +1,7 @@
FactoryBot.define do
factory(:post_appeal) do
creator
post
reason {"xxx"}
end
end

View File

@@ -1,5 +1,7 @@
FactoryBot.define do
factory(:post_flag) do
creator
post
reason {"xxx"}
is_resolved {false}
end

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory :tag_alias do
creator
antecedent_name {"aaa"}
consequent_name {"bbb"}
status {"active"}

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory :tag_implication do
creator
antecedent_name {"aaa"}
consequent_name {"bbb"}
status {"active"}

View File

@@ -11,6 +11,7 @@ FactoryBot.define do
last_logged_in_at {Time.now}
favorite_count {0}
bit_prefs {0}
last_forum_read_at {nil}
factory(:banned_user) do
transient { ban_duration {3} }

View File

@@ -1,5 +1,6 @@
FactoryBot.define do
factory(:user_feedback) do
creator factory: :builder_user
user
category { "positive" }
body { FFaker::Lorem.words.join(" ") }