diff --git a/.streerc b/.streerc index 615e88d6e24..016c131272c 100644 --- a/.streerc +++ b/.streerc @@ -3,4 +3,3 @@ --ignore-files=app/* --ignore-files=db/* --ignore-files=lib/* ---ignore-files=spec/* diff --git a/spec/fabricators/allowed_pm_users.rb b/spec/fabricators/allowed_pm_users.rb index c160aef83dd..fd7286396df 100644 --- a/spec/fabricators/allowed_pm_users.rb +++ b/spec/fabricators/allowed_pm_users.rb @@ -1,5 +1,3 @@ # frozen_string_literal: true -Fabricator(:allowed_pm_user) do - user -end +Fabricator(:allowed_pm_user) { user } diff --git a/spec/fabricators/api_key_fabricator.rb b/spec/fabricators/api_key_fabricator.rb index 2f75d78c0bb..b2c6748fb13 100644 --- a/spec/fabricators/api_key_fabricator.rb +++ b/spec/fabricators/api_key_fabricator.rb @@ -1,5 +1,3 @@ # frozen_string_literal: true -Fabricator(:api_key) do - -end +Fabricator(:api_key) {} diff --git a/spec/fabricators/associated_group_fabricator.rb b/spec/fabricators/associated_group_fabricator.rb index f7aff76893c..15117bae957 100644 --- a/spec/fabricators/associated_group_fabricator.rb +++ b/spec/fabricators/associated_group_fabricator.rb @@ -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 diff --git a/spec/fabricators/badge_fabricator.rb b/spec/fabricators/badge_fabricator.rb index b99fe209e7a..7ec3cb1b3b5 100644 --- a/spec/fabricators/badge_fabricator.rb +++ b/spec/fabricators/badge_fabricator.rb @@ -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}" } } diff --git a/spec/fabricators/bookmark_fabricator.rb b/spec/fabricators/bookmark_fabricator.rb index 30dafdf0f11..ba9271a22e2 100644 --- a/spec/fabricators/bookmark_fabricator.rb +++ b/spec/fabricators/bookmark_fabricator.rb @@ -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 } diff --git a/spec/fabricators/category_fabricator.rb b/spec/fabricators/category_fabricator.rb index 0e14967af41..eb6dbcbd0cf 100644 --- a/spec/fabricators/category_fabricator.rb +++ b/spec/fabricators/category_fabricator.rb @@ -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 diff --git a/spec/fabricators/color_scheme_fabricator.rb b/spec/fabricators/color_scheme_fabricator.rb index 711b0f5e949..539926b71cc 100644 --- a/spec/fabricators/color_scheme_fabricator.rb +++ b/spec/fabricators/color_scheme_fabricator.rb @@ -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 diff --git a/spec/fabricators/external_upload_stub_fabricator.rb b/spec/fabricators/external_upload_stub_fabricator.rb index 5f8eb3e25e0..e175aa0d258 100644 --- a/spec/fabricators/external_upload_stub_fabricator.rb +++ b/spec/fabricators/external_upload_stub_fabricator.rb @@ -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 diff --git a/spec/fabricators/group_fabricator.rb b/spec/fabricators/group_fabricator.rb index de9993d3628..c0a13a3f39d 100644 --- a/spec/fabricators/group_fabricator.rb +++ b/spec/fabricators/group_fabricator.rb @@ -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 diff --git a/spec/fabricators/invite_fabricator.rb b/spec/fabricators/invite_fabricator.rb index aedc23c1772..d8a8747796b 100644 --- a/spec/fabricators/invite_fabricator.rb +++ b/spec/fabricators/invite_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:invite) do invited_by(fabricator: :user) - email 'iceking@ADVENTURETIME.ooo' + email "iceking@ADVENTURETIME.ooo" end diff --git a/spec/fabricators/muted_user.rb b/spec/fabricators/muted_user.rb index 4bee8414e01..992c205abe8 100644 --- a/spec/fabricators/muted_user.rb +++ b/spec/fabricators/muted_user.rb @@ -1,5 +1,3 @@ # frozen_string_literal: true -Fabricator(:muted_user) do - user -end +Fabricator(:muted_user) { user } diff --git a/spec/fabricators/notification_fabricator.rb b/spec/fabricators/notification_fabricator.rb index 6ee4c1bcfb9..51d34032e48 100644 --- a/spec/fabricators/notification_fabricator.rb +++ b/spec/fabricators/notification_fabricator.rb @@ -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 diff --git a/spec/fabricators/permalink_fabricator.rb b/spec/fabricators/permalink_fabricator.rb index b2852126064..0f21d1f2e6b 100644 --- a/spec/fabricators/permalink_fabricator.rb +++ b/spec/fabricators/permalink_fabricator.rb @@ -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" } } } diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb index e18628a141a..07e8a734482 100644 --- a/spec/fabricators/post_fabricator.rb +++ b/spec/fabricators/post_fabricator.rb @@ -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 '
http://www.youtube.com/watch?v=9bZkp7q19f0
' 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 }With an emoji!
BEFORE
", "AFTER
"], "raw" => ["BEFORE", "AFTER"] } - end + modifications { { "cooked" => %w[BEFORE
AFTER
], "raw" => %w[BEFORE AFTER] } } end diff --git a/spec/fabricators/reviewable_fabricator.rb b/spec/fabricators/reviewable_fabricator.rb index b2f26120406..2606a99c291 100644 --- a/spec/fabricators/reviewable_fabricator.rb +++ b/spec/fabricators/reviewable_fabricator.rb @@ -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 diff --git a/spec/fabricators/screened_url_fabricator.rb b/spec/fabricators/screened_url_fabricator.rb index 8533946c65a..7225852a5d6 100644 --- a/spec/fabricators/screened_url_fabricator.rb +++ b/spec/fabricators/screened_url_fabricator.rb @@ -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 diff --git a/spec/fabricators/sidebar_section_link_fabricator.rb b/spec/fabricators/sidebar_section_link_fabricator.rb index 4a5d7683807..569de894fe0 100644 --- a/spec/fabricators/sidebar_section_link_fabricator.rb +++ b/spec/fabricators/sidebar_section_link_fabricator.rb @@ -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) } diff --git a/spec/fabricators/single_sign_on_record_fabricator.rb b/spec/fabricators/single_sign_on_record_fabricator.rb index 95c6a6028f4..1afbc727062 100644 --- a/spec/fabricators/single_sign_on_record_fabricator.rb +++ b/spec/fabricators/single_sign_on_record_fabricator.rb @@ -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 diff --git a/spec/fabricators/tag_fabricator.rb b/spec/fabricators/tag_fabricator.rb index c2192294efb..6d68de48f4d 100644 --- a/spec/fabricators/tag_fabricator.rb +++ b/spec/fabricators/tag_fabricator.rb @@ -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}" } } } diff --git a/spec/fabricators/tag_group_fabricator.rb b/spec/fabricators/tag_group_fabricator.rb index 990ec85d72a..64a38f9004b 100644 --- a/spec/fabricators/tag_group_fabricator.rb +++ b/spec/fabricators/tag_group_fabricator.rb @@ -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}" } } } diff --git a/spec/fabricators/topic_allowed_user_fabricator.rb b/spec/fabricators/topic_allowed_user_fabricator.rb index eb3d75f6e26..99494eb170c 100644 --- a/spec/fabricators/topic_allowed_user_fabricator.rb +++ b/spec/fabricators/topic_allowed_user_fabricator.rb @@ -1,5 +1,3 @@ # frozen_string_literal: true -Fabricator(:topic_allowed_user) do - user -end +Fabricator(:topic_allowed_user) { user } diff --git a/spec/fabricators/topic_fabricator.rb b/spec/fabricators/topic_fabricator.rb index b65cd48d7fa..c693fc213c6 100644 --- a/spec/fabricators/topic_fabricator.rb +++ b/spec/fabricators/topic_fabricator.rb @@ -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 diff --git a/spec/fabricators/upload_fabricator.rb b/spec/fabricators/upload_fabricator.rb index cb47f293b09..aec9a20721d 100644 --- a/spec/fabricators/upload_fabricator.rb +++ b/spec/fabricators/upload_fabricator.rb @@ -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 diff --git a/spec/fabricators/user_api_key_fabricator.rb b/spec/fabricators/user_api_key_fabricator.rb index 3ca55431c8e..fc2e805ecb2 100644 --- a/spec/fabricators/user_api_key_fabricator.rb +++ b/spec/fabricators/user_api_key_fabricator.rb @@ -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 diff --git a/spec/fabricators/user_avatar_fabricator.rb b/spec/fabricators/user_avatar_fabricator.rb index f7431bcbb17..773947f04b9 100644 --- a/spec/fabricators/user_avatar_fabricator.rb +++ b/spec/fabricators/user_avatar_fabricator.rb @@ -1,5 +1,3 @@ # frozen_string_literal: true -Fabricator(:user_avatar) do - user -end +Fabricator(:user_avatar) { user } diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index bee8812bd89..1a0fcca19a6 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -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 diff --git a/spec/fabricators/user_field_fabricator.rb b/spec/fabricators/user_field_fabricator.rb index c8019b390af..8534e80657c 100644 --- a/spec/fabricators/user_field_fabricator.rb +++ b/spec/fabricators/user_field_fabricator.rb @@ -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 diff --git a/spec/fabricators/user_history_fabricator.rb b/spec/fabricators/user_history_fabricator.rb index 4464b03c7cd..72bdd160754 100644 --- a/spec/fabricators/user_history_fabricator.rb +++ b/spec/fabricators/user_history_fabricator.rb @@ -1,4 +1,3 @@ # frozen_string_literal: true -Fabricator(:user_history) do -end +Fabricator(:user_history) {} diff --git a/spec/fabricators/user_option_fabricator.rb b/spec/fabricators/user_option_fabricator.rb index 17c0cbc788e..77e55384a8a 100644 --- a/spec/fabricators/user_option_fabricator.rb +++ b/spec/fabricators/user_option_fabricator.rb @@ -1,4 +1,3 @@ # frozen_string_literal: true -Fabricator(:user_option) do -end +Fabricator(:user_option) {} diff --git a/spec/fabricators/user_profile_fabricator.rb b/spec/fabricators/user_profile_fabricator.rb index 042474ed8bc..ada2483eebe 100644 --- a/spec/fabricators/user_profile_fabricator.rb +++ b/spec/fabricators/user_profile_fabricator.rb @@ -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) } diff --git a/spec/fabricators/user_second_factor_fabricator.rb b/spec/fabricators/user_second_factor_fabricator.rb index cbb2d5aa4ae..8d4a5176318 100644 --- a/spec/fabricators/user_second_factor_fabricator.rb +++ b/spec/fabricators/user_second_factor_fabricator.rb @@ -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 diff --git a/spec/fabricators/user_security_key_fabricator.rb b/spec/fabricators/user_security_key_fabricator.rb index 827413a18de..edc4279f60c 100644 --- a/spec/fabricators/user_security_key_fabricator.rb +++ b/spec/fabricators/user_security_key_fabricator.rb @@ -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}" } } diff --git a/spec/fabricators/web_hook_fabricator.rb b/spec/fabricators/web_hook_fabricator.rb index 3e490b3f4cb..97f753bd134 100644 --- a/spec/fabricators/web_hook_fabricator.rb +++ b/spec/fabricators/web_hook_fabricator.rb @@ -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]] diff --git a/spec/fixtures/db/post_migrate/change/20990309014015_drop_email_logs.rb b/spec/fixtures/db/post_migrate/change/20990309014015_drop_email_logs.rb index 7b4b1e2252d..441440772af 100644 --- a/spec/fixtures/db/post_migrate/change/20990309014015_drop_email_logs.rb +++ b/spec/fixtures/db/post_migrate/change/20990309014015_drop_email_logs.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class DropEmailLogs < ActiveRecord::Migration[5.2] - DROPPED_TABLES ||= %i{email_logs} + DROPPED_TABLES ||= %i[email_logs] def change drop_table :email_logs diff --git a/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb b/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb index 8390f83207d..556489f2553 100644 --- a/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb +++ b/spec/fixtures/db/post_migrate/drop_column/20990309014014_drop_post_columns.rb @@ -1,9 +1,7 @@ # frozen_string_literal: true class DropPostColumns < ActiveRecord::Migration[5.2] - DROPPED_COLUMNS ||= { - posts: %i{via_email raw_email} - } + DROPPED_COLUMNS ||= { posts: %i[via_email raw_email] } def up remove_column :posts, :via_email diff --git a/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb b/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb index 5d07960ea7a..ed8d31d7e64 100644 --- a/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb +++ b/spec/fixtures/db/post_migrate/drop_table/20990309014013_drop_email_logs_table.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class DropEmailLogsTable < ActiveRecord::Migration[5.2] - DROPPED_TABLES ||= %i{email_logs} + DROPPED_TABLES ||= %i[email_logs] def up drop_table :email_logs diff --git a/spec/fixtures/plugins/csp_extension/plugin.rb b/spec/fixtures/plugins/csp_extension/plugin.rb index e694598c4a1..0991754eb60 100644 --- a/spec/fixtures/plugins/csp_extension/plugin.rb +++ b/spec/fixtures/plugins/csp_extension/plugin.rb @@ -6,8 +6,8 @@ # authors: xrav3nz extend_content_security_policy( - script_src: ['https://from-plugin.com', '/local/path'], - object_src: ['https://test-stripping.com'], - frame_ancestors: ['https://frame-ancestors-plugin.ext'], - manifest_src: ['https://manifest-src.com'] + script_src: %w[https://from-plugin.com /local/path], + object_src: ["https://test-stripping.com"], + frame_ancestors: ["https://frame-ancestors-plugin.ext"], + manifest_src: ["https://manifest-src.com"], ) diff --git a/spec/fixtures/plugins/my_plugin/plugin.rb b/spec/fixtures/plugins/my_plugin/plugin.rb index 2253f3a1b03..62c7ed4dc5b 100644 --- a/spec/fixtures/plugins/my_plugin/plugin.rb +++ b/spec/fixtures/plugins/my_plugin/plugin.rb @@ -5,8 +5,7 @@ # version: 0.1 # authors: Frank Zappa -auth_provider title: 'with Ubuntu', - authenticator: Auth::FacebookAuthenticator.new +auth_provider title: "with Ubuntu", authenticator: Auth::FacebookAuthenticator.new register_javascript <This is the first paragraph, but you should read more.
", - "And here is its friend, the second paragraph.
" - ] } - - let(:cooked) do - paragraphs.join("\n") + describe "#email_excerpt" do + let(:paragraphs) do + [ + "This is the first paragraph, but you should read more.
", + "And here is its friend, the second paragraph.
", + ] end - let(:post_quote) do - <<~HTML + let(:cooked) { paragraphs.join("\n") } + + let(:post_quote) { <<~HTML }