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

@@ -23,14 +23,8 @@ class TagRelationshipRetirementServiceTest < ActiveSupport::TestCase
setup do
subject.stubs(:is_unused?).returns(true)
@user = FactoryBot.create(:user)
as_user do
@new_alias = FactoryBot.create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
travel_to(3.years.ago) do
@old_alias = FactoryBot.create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd")
end
end
@new_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
@old_alias = create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd", created_at: 3.years.ago)
end
should "find old tag relationships" do
@@ -50,17 +44,11 @@ class TagRelationshipRetirementServiceTest < ActiveSupport::TestCase
subject { TagRelationshipRetirementService }
setup do
@user = FactoryBot.create(:user)
@new_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
@new_post = create(:post, tag_string: "bbb")
as_user do
@new_alias = FactoryBot.create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
@new_post = FactoryBot.create(:post, tag_string: "bbb")
travel_to(3.years.ago) do
@old_alias = FactoryBot.create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd")
@old_post = FactoryBot.create(:post, tag_string: "ddd")
end
end
@old_alias = create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd", created_at: 3.years.ago)
@old_post = create(:post, tag_string: "ddd", created_at: 3.years.ago)
end
should "return true if no recent post exists" do