DEV: Apply syntax_tree formatting to spec/*

This commit is contained in:
David Taylor
2023-01-09 11:18:21 +00:00
parent 0cf6421716
commit cb932d6ee1
907 changed files with 58693 additions and 45909 deletions

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:allowed_pm_user) do
user
end
Fabricator(:allowed_pm_user) { user }

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:api_key) do
end
Fabricator(:api_key) {}

View File

@@ -2,6 +2,6 @@
Fabricator(:associated_group) do
name { sequence(:name) { |n| "group_#{n}" } }
provider_name 'google'
provider_name "google"
provider_id { SecureRandom.hex(20) }
end

View File

@@ -1,8 +1,6 @@
# frozen_string_literal: true
Fabricator(:badge_type) do
name { sequence(:name) { |i| "Silver #{i}" } }
end
Fabricator(:badge_type) { name { sequence(:name) { |i| "Silver #{i}" } } }
Fabricator(:badge) do
name { sequence(:name) { |i| "Badge #{i}" } }

View File

@@ -10,13 +10,14 @@ end
Fabricator(:bookmark_next_business_day_reminder, from: :bookmark) do
reminder_at do
date = if Time.zone.now.friday?
Time.zone.now + 3.days
elsif Time.zone.now.saturday?
Time.zone.now + 2.days
else
Time.zone.now + 1.day
end
date =
if Time.zone.now.friday?
Time.zone.now + 3.days
elsif Time.zone.now.saturday?
Time.zone.now + 2.days
else
Time.zone.now + 1.day
end
date.iso8601
end
reminder_set_at { Time.zone.now }

View File

@@ -6,9 +6,7 @@ Fabricator(:category) do
user
end
Fabricator(:category_with_definition, from: :category) do
skip_category_definition false
end
Fabricator(:category_with_definition, from: :category) { skip_category_definition false }
Fabricator(:private_category, from: :category) do
transient :group
@@ -20,7 +18,10 @@ Fabricator(:private_category, from: :category) do
after_build do |cat, transients|
cat.update!(read_restricted: true)
cat.category_groups.build(group_id: transients[:group].id, permission_type: transients[:permission_type] || CategoryGroup.permission_types[:full])
cat.category_groups.build(
group_id: transients[:group].id,
permission_type: transients[:permission_type] || CategoryGroup.permission_types[:full],
)
end
end
@@ -33,7 +34,7 @@ Fabricator(:link_category, from: :category) do
end
Fabricator(:mailinglist_mirror_category, from: :category) do
email_in 'list@example.com'
email_in "list@example.com"
email_in_allow_strangers true
mailinglist_mirror true
end

View File

@@ -2,5 +2,7 @@
Fabricator(:color_scheme) do
name { sequence(:name) { |i| "Palette #{i}" } }
color_scheme_colors(count: 2) { |attrs, i| Fabricate.build(:color_scheme_color, color_scheme: nil) }
color_scheme_colors(count: 2) do |attrs, i|
Fabricate.build(:color_scheme_color, color_scheme: nil)
end
end

View File

@@ -5,7 +5,12 @@ Fabricator(:external_upload_stub) do
created_by { Fabricate(:user) }
original_filename "test.txt"
key { |attrs| FileStore::BaseStore.temporary_upload_path("test.txt", folder_prefix: attrs[:folder_prefix] || "") }
key do |attrs|
FileStore::BaseStore.temporary_upload_path(
"test.txt",
folder_prefix: attrs[:folder_prefix] || "",
)
end
upload_type "card_background"
filesize 1024
status 1
@@ -14,16 +19,28 @@ end
Fabricator(:image_external_upload_stub, from: :external_upload_stub) do
original_filename "logo.png"
filesize 1024
key { |attrs| FileStore::BaseStore.temporary_upload_path("logo.png", folder_prefix: attrs[:folder_prefix] || "") }
key do |attrs|
FileStore::BaseStore.temporary_upload_path(
"logo.png",
folder_prefix: attrs[:folder_prefix] || "",
)
end
end
Fabricator(:attachment_external_upload_stub, from: :external_upload_stub) do
original_filename "file.pdf"
filesize 1024
key { |attrs| FileStore::BaseStore.temporary_upload_path("file.pdf", folder_prefix: attrs[:folder_prefix] || "") }
key do |attrs|
FileStore::BaseStore.temporary_upload_path(
"file.pdf",
folder_prefix: attrs[:folder_prefix] || "",
)
end
end
Fabricator(:multipart_external_upload_stub, from: :external_upload_stub) do
multipart true
external_upload_identifier { "#{SecureRandom.hex(6)}._#{SecureRandom.hex(6)}_#{SecureRandom.hex(6)}.d.ghQ" }
external_upload_identifier do
"#{SecureRandom.hex(6)}._#{SecureRandom.hex(6)}_#{SecureRandom.hex(6)}.d.ghQ"
end
end

View File

@@ -1,8 +1,6 @@
# frozen_string_literal: true
Fabricator(:group) do
name { sequence(:name) { |n| "my_group_#{n}" } }
end
Fabricator(:group) { name { sequence(:name) { |n| "my_group_#{n}" } } }
Fabricator(:public_group, from: :group) do
public_admission true

View File

@@ -2,5 +2,5 @@
Fabricator(:invite) do
invited_by(fabricator: :user)
email 'iceking@ADVENTURETIME.ooo'
email "iceking@ADVENTURETIME.ooo"
end

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:muted_user) do
user
end
Fabricator(:muted_user) { user }

View File

@@ -27,7 +27,7 @@ Fabricator(:private_message_notification, from: :notification) do
original_post_type: post.post_type,
original_username: post.user.username,
revision_number: nil,
display_username: post.user.username
display_username: post.user.username,
}.to_json
end
end
@@ -44,7 +44,7 @@ Fabricator(:bookmark_reminder_notification, from: :notification) do
original_username: post.user.username,
revision_number: nil,
display_username: post.user.username,
bookmark_name: "Check out Mr Freeze's opinion here"
bookmark_name: "Check out Mr Freeze's opinion here",
}.to_json
end
end
@@ -58,7 +58,7 @@ Fabricator(:replied_notification, from: :notification) do
original_post_id: post.id,
original_username: post.user.username,
revision_number: nil,
display_username: post.user.username
display_username: post.user.username,
}.to_json
end
end
@@ -73,7 +73,7 @@ Fabricator(:posted_notification, from: :notification) do
original_post_type: post.post_type,
original_username: post.user.username,
revision_number: nil,
display_username: post.user.username
display_username: post.user.username,
}.to_json
end
end
@@ -87,7 +87,7 @@ Fabricator(:mentioned_notification, from: :notification) do
original_post_type: attrs[:post].post_type,
original_username: attrs[:post].user.username,
revision_number: nil,
display_username: attrs[:post].user.username
display_username: attrs[:post].user.username,
}.to_json
end
end
@@ -101,7 +101,7 @@ Fabricator(:watching_first_post_notification, from: :notification) do
original_post_type: attrs[:post].post_type,
original_username: attrs[:post].user.username,
revision_number: nil,
display_username: attrs[:post].user.username
display_username: attrs[:post].user.username,
}.to_json
end
end

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:permalink) do
url { sequence(:url) { |i| "my/#{i}/url" } }
end
Fabricator(:permalink) { url { sequence(:url) { |i| "my/#{i}/url" } } }

View File

@@ -7,19 +7,17 @@ Fabricator(:post) do
post_type Post.types[:regular]
# Fabrication bypasses PostCreator, for performance reasons, where the counts are updated so we have to handle this manually here.
after_create do |post, _transients|
UserStatCountUpdater.increment!(post)
end
after_create { |post, _transients| UserStatCountUpdater.increment!(post) }
end
Fabricator(:post_with_long_raw_content, from: :post) do
raw 'This is a sample post with semi-long raw content. The raw content is also more than
raw "This is a sample post with semi-long raw content. The raw content is also more than
two hundred characters to satisfy any test conditions that require content longer
than the typical test post raw content. It really is some long content, folks.'
than the typical test post raw content. It really is some long content, folks."
end
Fabricator(:post_with_youtube, from: :post) do
raw 'http://www.youtube.com/watch?v=9bZkp7q19f0'
raw "http://www.youtube.com/watch?v=9bZkp7q19f0"
cooked '<p><a href="http://www.youtube.com/watch?v=9bZkp7q19f0" class="onebox" target="_blank">http://www.youtube.com/watch?v=9bZkp7q19f0</a></p>'
end
@@ -39,7 +37,7 @@ Fabricator(:basic_reply, from: :post) do
user(fabricator: :coding_horror)
reply_to_post_number 1
topic
raw 'this reply has no quotes'
raw "this reply has no quotes"
end
Fabricator(:reply, from: :post) do
@@ -51,14 +49,12 @@ Fabricator(:reply, from: :post) do
'
end
Fabricator(:post_with_plenty_of_images, from: :post) do
cooked <<~HTML
Fabricator(:post_with_plenty_of_images, from: :post) { cooked <<~HTML }
<aside class="quote"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></aside>
<div class="onebox-result"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></div>
<div class="onebox"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></div>
<p>With an emoji! <img src="//cdn.discourse.org/meta/images/emoji/twitter/smile.png?v=#{Emoji::EMOJI_VERSION}" title=":smile:" class="emoji" alt="smile" loading="lazy" width="20" height="20"></p>
HTML
end
Fabricator(:post_with_uploaded_image, from: :post) do
raw { "<img src=\"#{Fabricate(:image_upload)}\" width=\"1500\" height=\"2000\">" }
@@ -101,8 +97,7 @@ Fabricator(:post_with_uploads, from: :post) do
"
end
Fabricator(:post_with_uploads_and_links, from: :post) do
raw <<~MD
Fabricator(:post_with_uploads_and_links, from: :post) { raw <<~MD }
<a href="/#{Discourse.store.upload_path}/original/2X/2345678901234567.jpg">Link</a>
<img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg">
<a href="http://www.google.com">Google</a>
@@ -110,7 +105,6 @@ Fabricator(:post_with_uploads_and_links, from: :post) do
<a class="attachment" href="/#{Discourse.store.upload_path}/original/1X/af2c2618032c679333bebf745e75f9088748d737.txt">text.txt</a> (20 Bytes)
:smile:
MD
end
Fabricator(:post_with_external_links, from: :post) do
user
@@ -130,14 +124,15 @@ Fabricator(:private_message_post, from: :post) do
transient :recipient
user
topic do |attrs|
Fabricate(:private_message_topic,
Fabricate(
:private_message_topic,
user: attrs[:user],
created_at: attrs[:created_at],
subtype: TopicSubtype.user_to_user,
topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: attrs[:user]),
Fabricate.build(:topic_allowed_user, user: attrs[:recipient] || Fabricate(:user))
]
Fabricate.build(:topic_allowed_user, user: attrs[:recipient] || Fabricate(:user)),
],
)
end
raw "Ssshh! This is our secret conversation!"
@@ -147,16 +142,15 @@ Fabricator(:group_private_message_post, from: :post) do
transient :recipients
user
topic do |attrs|
Fabricate(:private_message_topic,
Fabricate(
:private_message_topic,
user: attrs[:user],
created_at: attrs[:created_at],
subtype: TopicSubtype.user_to_user,
topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: attrs[:user]),
],
topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: attrs[:user])],
topic_allowed_groups: [
Fabricate.build(:topic_allowed_group, group: attrs[:recipients] || Fabricate(:group))
]
Fabricate.build(:topic_allowed_group, group: attrs[:recipients] || Fabricate(:group)),
],
)
end
raw "Ssshh! This is our group secret conversation!"
@@ -165,13 +159,12 @@ end
Fabricator(:private_message_post_one_user, from: :post) do
user
topic do |attrs|
Fabricate(:private_message_topic,
Fabricate(
:private_message_topic,
user: attrs[:user],
created_at: attrs[:created_at],
subtype: TopicSubtype.user_to_user,
topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: attrs[:user]),
]
topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: attrs[:user])],
)
end
raw "Ssshh! This is our secret conversation!"
@@ -188,10 +181,6 @@ Fabricator(:post_via_email, from: :post) do
end
end
Fabricator(:whisper, from: :post) do
post_type Post.types[:whisper]
end
Fabricator(:whisper, from: :post) { post_type Post.types[:whisper] }
Fabricator(:small_action, from: :post) do
post_type Post.types[:small_action]
end
Fabricator(:small_action, from: :post) { post_type Post.types[:small_action] }

View File

@@ -4,7 +4,5 @@ Fabricator(:post_revision) do
post
user
number 2
modifications do
{ "cooked" => ["<p>BEFORE</p>", "<p>AFTER</p>"], "raw" => ["BEFORE", "AFTER"] }
end
modifications { { "cooked" => %w[<p>BEFORE</p> <p>AFTER</p>], "raw" => %w[BEFORE AFTER] } }
end

View File

@@ -2,70 +2,75 @@
Fabricator(:reviewable) do
reviewable_by_moderator true
type 'ReviewableUser'
type "ReviewableUser"
created_by { Fabricate(:user) }
target_id { Fabricate(:user).id }
target_type "User"
target_created_by { Fabricate(:user) }
category
score 1.23
payload {
{ list: [1, 2, 3], name: 'bandersnatch' }
}
payload { { list: [1, 2, 3], name: "bandersnatch" } }
end
Fabricator(:reviewable_queued_post_topic, class_name: :reviewable_queued_post) do
reviewable_by_moderator true
type 'ReviewableQueuedPost'
type "ReviewableQueuedPost"
created_by { Fabricate(:user) }
category
payload {
payload do
{
raw: "hello world post contents.",
title: "queued post title",
tags: ['cool', 'neat'],
tags: %w[cool neat],
extra: "some extra data",
archetype: 'regular'
archetype: "regular",
}
}
end
end
Fabricator(:reviewable_queued_post) do
reviewable_by_moderator true
type 'ReviewableQueuedPost'
type "ReviewableQueuedPost"
created_by { Fabricate(:user) }
topic
payload {
payload do
{
raw: "hello world post contents.",
reply_to_post_number: 1,
via_email: true,
raw_email: 'store_me',
raw_email: "store_me",
auto_track: true,
custom_fields: { hello: 'world' },
cooking_options: { cat: 'hat' },
custom_fields: {
hello: "world",
},
cooking_options: {
cat: "hat",
},
cook_method: Post.cook_methods[:raw_html],
image_sizes: { "http://foo.bar/image.png" => { "width" => 0, "height" => 222 } }
image_sizes: {
"http://foo.bar/image.png" => {
"width" => 0,
"height" => 222,
},
},
}
}
end
end
Fabricator(:reviewable_flagged_post) do
reviewable_by_moderator true
type 'ReviewableFlaggedPost'
type "ReviewableFlaggedPost"
created_by { Fabricate(:user) }
topic
target_type 'Post'
target_type "Post"
target { Fabricate(:post) }
reviewable_scores { |p| [
Fabricate.build(:reviewable_score, reviewable_id: p[:id]),
]}
reviewable_scores { |p| [Fabricate.build(:reviewable_score, reviewable_id: p[:id])] }
end
Fabricator(:reviewable_user) do
reviewable_by_moderator true
type 'ReviewableUser'
type "ReviewableUser"
created_by { Fabricate(:user) }
target_type 'User'
target_type "User"
target { Fabricate(:user) }
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator(:screened_url) do
url { sequence(:url) { |n| "spammers#{n}.org/buy/stuff" } }
domain { sequence(:domain) { |n| "spammers#{n}.org" } }
url { sequence(:url) { |n| "spammers#{n}.org/buy/stuff" } }
domain { sequence(:domain) { |n| "spammers#{n}.org" } }
action_type ScreenedEmail.actions[:do_nothing]
end

View File

@@ -1,13 +1,9 @@
# frozen_string_literal: true
Fabricator(:sidebar_section_link) do
user
end
Fabricator(:sidebar_section_link) { user }
Fabricator(:category_sidebar_section_link, from: :sidebar_section_link) do
linkable(fabricator: :category)
end
Fabricator(:tag_sidebar_section_link, from: :sidebar_section_link) do
linkable(fabricator: :tag)
end
Fabricator(:tag_sidebar_section_link, from: :sidebar_section_link) { linkable(fabricator: :tag) }

View File

@@ -5,5 +5,7 @@ Fabricator(:single_sign_on_record) do
external_id { sequence(:external_id) { |i| "ext_#{i}" } }
external_username { sequence(:username) { |i| "bruce#{i}" } }
external_email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
last_payload { sequence(:last_payload) { |i| "nonce=#{i}1870a940bbcbb46f06880ed338d58a07&name=" } }
last_payload do
sequence(:last_payload) { |i| "nonce=#{i}1870a940bbcbb46f06880ed338d58a07&name=" }
end
end

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:tag) do
name { sequence(:name) { |i| "tag#{i + 1}" } }
end
Fabricator(:tag) { name { sequence(:name) { |i| "tag#{i + 1}" } } }

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:tag_group) do
name { sequence(:name) { |i| "tag_group_#{i}" } }
end
Fabricator(:tag_group) { name { sequence(:name) { |i| "tag_group_#{i}" } } }

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:topic_allowed_user) do
user
end
Fabricator(:topic_allowed_user) { user }

View File

@@ -8,25 +8,21 @@ Fabricator(:topic) do
end
end
Fabricator(:deleted_topic, from: :topic) do
deleted_at { 1.minute.ago }
end
Fabricator(:deleted_topic, from: :topic) { deleted_at { 1.minute.ago } }
Fabricator(:closed_topic, from: :topic) do
closed true
end
Fabricator(:closed_topic, from: :topic) { closed true }
Fabricator(:banner_topic, from: :topic) do
archetype Archetype.banner
end
Fabricator(:banner_topic, from: :topic) { archetype Archetype.banner }
Fabricator(:private_message_topic, from: :topic) do
transient :recipient
category_id { nil }
title { sequence(:title) { |i| "This is a private message #{i}" } }
archetype "private_message"
topic_allowed_users { |t| [
Fabricate.build(:topic_allowed_user, user: t[:user]),
Fabricate.build(:topic_allowed_user, user: t[:recipient] || Fabricate(:user))
]}
topic_allowed_users do |t|
[
Fabricate.build(:topic_allowed_user, user: t[:user]),
Fabricate.build(:topic_allowed_user, user: t[:recipient] || Fabricate(:user)),
]
end
end

View File

@@ -12,9 +12,7 @@ Fabricator(:upload) do
url do |attrs|
sequence(:url) do |n|
Discourse.store.get_path_for(
"original", n + 1, attrs[:sha1], ".#{attrs[:extension]}"
)
Discourse.store.get_path_for("original", n + 1, attrs[:sha1], ".#{attrs[:extension]}")
end
end
@@ -35,15 +33,16 @@ Fabricator(:image_upload, from: :upload) do
transient color: "white"
after_create do |upload, transients|
file = Tempfile.new(['fabricated', '.png'])
file = Tempfile.new(%w[fabricated .png])
`convert -size #{upload.width}x#{upload.height} xc:#{transients[:color]} "#{file.path}"`
upload.url = Discourse.store.store_upload(file, upload)
upload.sha1 = Upload.generate_digest(file.path)
WebMock
.stub_request(:get, "http://#{Discourse.current_hostname}#{upload.url}")
.to_return(status: 200, body: File.new(file.path))
WebMock.stub_request(:get, "http://#{Discourse.current_hostname}#{upload.url}").to_return(
status: 200,
body: File.new(file.path),
)
end
end
@@ -72,13 +71,9 @@ end
Fabricator(:upload_s3, from: :upload) do
url do |attrs|
sequence(:url) do |n|
path = +Discourse.store.get_path_for(
"original", n + 1, attrs[:sha1], ".#{attrs[:extension]}"
)
path = +Discourse.store.get_path_for("original", n + 1, attrs[:sha1], ".#{attrs[:extension]}")
if Rails.configuration.multisite
path.prepend(File.join(Discourse.store.upload_path, "/"))
end
path.prepend(File.join(Discourse.store.upload_path, "/")) if Rails.configuration.multisite
File.join(Discourse.store.absolute_base_url, path)
end
@@ -87,15 +82,13 @@ end
Fabricator(:s3_image_upload, from: :upload_s3) do
after_create do |upload|
file = Tempfile.new(['fabricated', '.png'])
file = Tempfile.new(%w[fabricated .png])
`convert -size #{upload.width}x#{upload.height} xc:white "#{file.path}"`
upload.url = Discourse.store.store_upload(file, upload)
upload.sha1 = Upload.generate_digest(file.path)
WebMock
.stub_request(:get, upload.url)
.to_return(status: 200, body: File.new(file.path))
WebMock.stub_request(:get, upload.url).to_return(status: 200, body: File.new(file.path))
end
end

View File

@@ -3,15 +3,15 @@
Fabricator(:user_api_key) do
user
client_id { SecureRandom.hex }
application_name 'some app'
application_name "some app"
end
Fabricator(:user_api_key_scope)
Fabricator(:readonly_user_api_key, from: :user_api_key) do
scopes { [Fabricate.build(:user_api_key_scope, name: 'read')] }
scopes { [Fabricate.build(:user_api_key_scope, name: "read")] }
end
Fabricator(:bookmarks_calendar_user_api_key, from: :user_api_key) do
scopes { [Fabricate.build(:user_api_key_scope, name: 'bookmarks_calendar')] }
scopes { [Fabricate.build(:user_api_key_scope, name: "bookmarks_calendar")] }
end

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
Fabricator(:user_avatar) do
user
end
Fabricator(:user_avatar) { user }

View File

@@ -1,13 +1,12 @@
# frozen_string_literal: true
Fabricator(:user_stat) do
end
Fabricator(:user_stat) {}
Fabricator(:user, class_name: :user) do
name 'Bruce Wayne'
name "Bruce Wayne"
username { sequence(:username) { |i| "bruce#{i}" } }
email { sequence(:email) { |i| "bruce#{i}@wayne.com" } }
password 'myawesomepassword'
password "myawesomepassword"
trust_level TrustLevel[1]
ip_address { sequence(:ip_address) { |i| "99.232.23.#{i % 254}" } }
active true
@@ -18,31 +17,31 @@ Fabricator(:user_with_secondary_email, from: :user) do
end
Fabricator(:coding_horror, from: :user) do
name 'Coding Horror'
username 'CodingHorror'
email 'jeff@somewhere.com'
password 'mymoreawesomepassword'
name "Coding Horror"
username "CodingHorror"
email "jeff@somewhere.com"
password "mymoreawesomepassword"
end
Fabricator(:evil_trout, from: :user) do
name 'Evil Trout'
username 'eviltrout'
email 'eviltrout@somewhere.com'
password 'imafish123'
name "Evil Trout"
username "eviltrout"
email "eviltrout@somewhere.com"
password "imafish123"
end
Fabricator(:walter_white, from: :user) do
name 'Walter White'
username 'heisenberg'
email 'wwhite@bluemeth.com'
password 'letscook123'
name "Walter White"
username "heisenberg"
email "wwhite@bluemeth.com"
password "letscook123"
end
Fabricator(:inactive_user, from: :user) do
name 'Inactive User'
username 'inactive_user'
email 'inactive@idontexist.com'
password 'qwerqwer123'
name "Inactive User"
username "inactive_user"
email "inactive@idontexist.com"
password "qwerqwer123"
active false
end
@@ -59,7 +58,7 @@ Fabricator(:moderator, from: :user) do
end
Fabricator(:admin, from: :user) do
name 'Anne Admin'
name "Anne Admin"
username { sequence(:username) { |i| "anne#{i}" } }
email { sequence(:email) { |i| "anne#{i}@discourse.org" } }
admin true
@@ -71,17 +70,17 @@ Fabricator(:admin, from: :user) do
end
Fabricator(:newuser, from: :user) do
name 'Newbie Newperson'
username 'newbie'
email 'newbie@new.com'
name "Newbie Newperson"
username "newbie"
email "newbie@new.com"
trust_level TrustLevel[0]
end
Fabricator(:active_user, from: :user) do
name 'Luke Skywalker'
name "Luke Skywalker"
username { sequence(:username) { |i| "luke#{i}" } }
email { sequence(:email) { |i| "luke#{i}@skywalker.com" } }
password 'myawesomepassword'
password "myawesomepassword"
trust_level TrustLevel[1]
after_create do |user|
@@ -91,29 +90,25 @@ Fabricator(:active_user, from: :user) do
end
Fabricator(:leader, from: :user) do
name 'Veteran McVeteranish'
name "Veteran McVeteranish"
username { sequence(:username) { |i| "leader#{i}" } }
email { sequence(:email) { |i| "leader#{i}@leaderfun.com" } }
trust_level TrustLevel[3]
end
Fabricator(:trust_level_0, from: :user) do
trust_level TrustLevel[0]
end
Fabricator(:trust_level_0, from: :user) { trust_level TrustLevel[0] }
Fabricator(:trust_level_1, from: :user) do
trust_level TrustLevel[1]
end
Fabricator(:trust_level_1, from: :user) { trust_level TrustLevel[1] }
Fabricator(:trust_level_4, from: :user) do
name 'Leader McElderson'
name "Leader McElderson"
username { sequence(:username) { |i| "tl4#{i}" } }
email { sequence(:email) { |i| "tl4#{i}@elderfun.com" } }
trust_level TrustLevel[4]
end
Fabricator(:anonymous, from: :user) do
name ''
name ""
username { sequence(:username) { |i| "anonymous#{i}" } }
email { sequence(:email) { |i| "anonymous#{i}@anonymous.com" } }
trust_level TrustLevel[1]
@@ -127,13 +122,9 @@ Fabricator(:anonymous, from: :user) do
end
end
Fabricator(:staged, from: :user) do
staged true
end
Fabricator(:staged, from: :user) { staged true }
Fabricator(:unicode_user, from: :user) do
username { sequence(:username) { |i| "Löwe#{i}" } }
end
Fabricator(:unicode_user, from: :user) { username { sequence(:username) { |i| "Löwe#{i}" } } }
Fabricator(:bot, from: :user) do
id do

View File

@@ -3,7 +3,7 @@
Fabricator(:user_field) do
name { sequence(:name) { |i| "field_#{i}" } }
description "user field description"
field_type 'text'
field_type "text"
editable true
required true
end

View File

@@ -1,4 +1,3 @@
# frozen_string_literal: true
Fabricator(:user_history) do
end
Fabricator(:user_history) {}

View File

@@ -1,4 +1,3 @@
# frozen_string_literal: true
Fabricator(:user_option) do
end
Fabricator(:user_option) {}

View File

@@ -5,6 +5,4 @@ Fabricator(:user_profile) do
user
end
Fabricator(:user_profile_long, from: :user_profile) do
bio_raw ("trout" * 1000)
end
Fabricator(:user_profile_long, from: :user_profile) { bio_raw ("trout" * 1000) }

View File

@@ -2,7 +2,7 @@
Fabricator(:user_second_factor_totp, from: :user_second_factor) do
user
data 'rcyryaqage3jexfj'
data "rcyryaqage3jexfj"
enabled true
method UserSecondFactor.methods[:totp]
end

View File

@@ -5,8 +5,12 @@ Fabricator(:user_security_key) do
# Note: these values are valid and decode to a credential ID and COSE public key
# HOWEVER they are largely useless unless you have the device that created
# them. It is nice to have an approximation though.
credential_id { 'mJAJ4CznTO0SuLkJbYwpgK75ao4KMNIPlU5KWM92nq39kRbXzI9mSv6GxTcsMYoiPgaouNw7b7zBiS4vsQaO6A==' }
public_key { 'pQECAyYgASFYIMNgw4GCpwBUlR2SznJ1yY7B9yFvsuxhfo+C9kcA4IitIlggRdofrCezymy2B/YarX+gfB6gZKg648/cHIMjf6wWmmU=' }
credential_id do
"mJAJ4CznTO0SuLkJbYwpgK75ao4KMNIPlU5KWM92nq39kRbXzI9mSv6GxTcsMYoiPgaouNw7b7zBiS4vsQaO6A=="
end
public_key do
"pQECAyYgASFYIMNgw4GCpwBUlR2SznJ1yY7B9yFvsuxhfo+C9kcA4IitIlggRdofrCezymy2B/YarX+gfB6gZKg648/cHIMjf6wWmmU="
end
enabled true
factor_type { UserSecurityKey.factor_types[:second_factor] }
name { sequence(:name) { |i| "Security Key #{i + 1}" } }

View File

@@ -1,62 +1,48 @@
# frozen_string_literal: true
Fabricator(:web_hook) do
payload_url 'https://meta.discourse.org/webhook_listener'
content_type WebHook.content_types['application/json']
payload_url "https://meta.discourse.org/webhook_listener"
content_type WebHook.content_types["application/json"]
wildcard_web_hook false
secret 'my_lovely_secret_for_web_hook'
secret "my_lovely_secret_for_web_hook"
verify_certificate true
active true
transient post_hook: WebHookEventType.find_by(name: 'post')
transient post_hook: WebHookEventType.find_by(name: "post")
after_build do |web_hook, transients|
web_hook.web_hook_event_types << transients[:post_hook]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types << transients[:post_hook] }
end
Fabricator(:inactive_web_hook, from: :web_hook) do
active false
end
Fabricator(:inactive_web_hook, from: :web_hook) { active false }
Fabricator(:wildcard_web_hook, from: :web_hook) do
wildcard_web_hook true
end
Fabricator(:wildcard_web_hook, from: :web_hook) { wildcard_web_hook true }
Fabricator(:topic_web_hook, from: :web_hook) do
transient topic_hook: WebHookEventType.find_by(name: 'topic')
transient topic_hook: WebHookEventType.find_by(name: "topic")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:topic_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:topic_hook]] }
end
Fabricator(:post_web_hook, from: :web_hook) do
transient topic_hook: WebHookEventType.find_by(name: 'post')
transient topic_hook: WebHookEventType.find_by(name: "post")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:post_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:post_hook]] }
end
Fabricator(:user_web_hook, from: :web_hook) do
transient user_hook: WebHookEventType.find_by(name: 'user')
transient user_hook: WebHookEventType.find_by(name: "user")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:user_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:user_hook]] }
end
Fabricator(:group_web_hook, from: :web_hook) do
transient group_hook: WebHookEventType.find_by(name: 'group')
transient group_hook: WebHookEventType.find_by(name: "group")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:group_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:group_hook]] }
end
Fabricator(:category_web_hook, from: :web_hook) do
transient category_hook: WebHookEventType.find_by(name: 'category')
transient category_hook: WebHookEventType.find_by(name: "category")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:category_hook]]
@@ -64,15 +50,13 @@ Fabricator(:category_web_hook, from: :web_hook) do
end
Fabricator(:tag_web_hook, from: :web_hook) do
transient tag_hook: WebHookEventType.find_by(name: 'tag')
transient tag_hook: WebHookEventType.find_by(name: "tag")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:tag_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:tag_hook]] }
end
Fabricator(:reviewable_web_hook, from: :web_hook) do
transient reviewable_hook: WebHookEventType.find_by(name: 'reviewable')
transient reviewable_hook: WebHookEventType.find_by(name: "reviewable")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:reviewable_hook]]
@@ -80,7 +64,7 @@ Fabricator(:reviewable_web_hook, from: :web_hook) do
end
Fabricator(:notification_web_hook, from: :web_hook) do
transient notification_hook: WebHookEventType.find_by(name: 'notification')
transient notification_hook: WebHookEventType.find_by(name: "notification")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:notification_hook]]
@@ -88,7 +72,7 @@ Fabricator(:notification_web_hook, from: :web_hook) do
end
Fabricator(:user_badge_web_hook, from: :web_hook) do
transient user_badge_hook: WebHookEventType.find_by(name: 'user_badge')
transient user_badge_hook: WebHookEventType.find_by(name: "user_badge")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:user_badge_hook]]
@@ -96,7 +80,7 @@ Fabricator(:user_badge_web_hook, from: :web_hook) do
end
Fabricator(:group_user_web_hook, from: :web_hook) do
transient group_user_hook: WebHookEventType.find_by(name: 'group_user')
transient group_user_hook: WebHookEventType.find_by(name: "group_user")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:group_user_hook]]
@@ -104,15 +88,13 @@ Fabricator(:group_user_web_hook, from: :web_hook) do
end
Fabricator(:like_web_hook, from: :web_hook) do
transient like_hook: WebHookEventType.find_by(name: 'like')
transient like_hook: WebHookEventType.find_by(name: "like")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:like_hook]]
end
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:like_hook]] }
end
Fabricator(:user_promoted_web_hook, from: :web_hook) do
transient user_promoted_hook: WebHookEventType.find_by(name: 'user_promoted')
transient user_promoted_hook: WebHookEventType.find_by(name: "user_promoted")
after_build do |web_hook, transients|
web_hook.web_hook_event_types = [transients[:user_promoted_hook]]