Skip to content

A platform for community discussion. Free, open, simple.

DEV: Use dynamic/static fabricator attrs correctly (#9519)

Jarek Radosz8adccaf98c73
diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb
index cd18b78967e..412504c7c4e 100644
--- a/spec/fabricators/post_fabricator.rb
+++ b/spec/fabricators/post_fabricator.rb
@@ -20,7 +20,7 @@ end
Fabricator(:old_post, from: :post) do
topic { |attrs| Fabricate(:topic, user: attrs[:user], created_at: (DateTime.now - 100)) }
- created_at (DateTime.now - 100)
+ created_at { 100.days.ago }
end
Fabricator(:moderator_post, from: :post) do
diff --git a/spec/fabricators/topic_fabricator.rb b/spec/fabricators/topic_fabricator.rb
index 8fc0307929e..3bcee07d2e7 100644
--- a/spec/fabricators/topic_fabricator.rb
+++ b/spec/fabricators/topic_fabricator.rb
@@ -9,7 +9,7 @@ Fabricator(:topic) do
end
Fabricator(:deleted_topic, from: :topic) do
- deleted_at Time.now
+ deleted_at { 1.minute.ago }
end
Fabricator(:closed_topic, from: :topic) do
diff --git a/spec/fabricators/topic_timer_fabricator.rb b/spec/fabricators/topic_timer_fabricator.rb
index 99bacf7cb5f..56e3bbae131 100644
--- a/spec/fabricators/topic_timer_fabricator.rb
+++ b/spec/fabricators/topic_timer_fabricator.rb
@@ -3,6 +3,6 @@
Fabricator(:topic_timer) do
user
topic
- execute_at Time.zone.now + 1.hour
+ execute_at { 1.hour.from_now }
status_type TopicTimer.types[:close]
end
diff --git a/spec/fabricators/upload_fabricator.rb b/spec/fabricators/upload_fabricator.rb
index 72bcb6c7232..c2f69527365 100644
--- a/spec/fabricators/upload_fabricator.rb
+++ b/spec/fabricators/upload_fabricator.rb
@@ -45,7 +45,7 @@ Fabricator(:video_upload, from: :upload) do
end
Fabricator(:secure_upload, from: :upload) do
- secure { true }
+ secure true
sha1 { SecureRandom.hex(20) }
original_sha1 { sequence(:sha1) { |n| Digest::SHA1.hexdigest(n.to_s) } }
end
@@ -67,7 +67,7 @@ Fabricator(:upload_s3, from: :upload) do
end
Fabricator(:secure_upload_s3, from: :upload_s3) do
- secure { true }
+ secure true
sha1 { SecureRandom.hex(20) }
original_sha1 { sequence(:sha1) { |n| Digest::SHA1.hexdigest(n.to_s) } }
end
diff --git a/spec/fabricators/watched_word_fabricator.rb b/spec/fabricators/watched_word_fabricator.rb
index b3796cad15b..521cb2fded6 100644
--- a/spec/fabricators/watched_word_fabricator.rb
+++ b/spec/fabricators/watched_word_fabricator.rb
@@ -2,5 +2,5 @@
Fabricator(:watched_word) do
word { sequence(:word) { |i| "word#{i}" } }
- action { WatchedWord.actions[:block] }
+ action WatchedWord.actions[:block]
end
diff --git a/spec/fabricators/web_crawler_request_fabricator.rb b/spec/fabricators/web_crawler_request_fabricator.rb
index 2d2be02fdf4..a20ab4225f0 100644
--- a/spec/fabricators/web_crawler_request_fabricator.rb
+++ b/spec/fabricators/web_crawler_request_fabricator.rb
@@ -2,6 +2,6 @@
Fabricator(:web_crawler_request) do
user_agent { sequence(:ua) { |i| "Googlebot #{i}.0" } }
- date Time.zone.now.to_date
+ date { Time.zone.now.to_date }
count 0
end