DEV: Use describe for methods in specs

This commit is contained in:
Loïc Guitaut 2022-07-27 12:21:10 +02:00 committed by Loïc Guitaut
parent f1c3670d74
commit 296aad430a
69 changed files with 214 additions and 214 deletions

View File

@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/discourse/rubocop-discourse.git remote: https://github.com/discourse/rubocop-discourse.git
revision: e44784b759aef45306b0eaee29ddadd8ca5b40a6 revision: 5afeae107d3c003bf5bcf75457501ee7c1248fd2
specs: specs:
rubocop-discourse (2.5.0) rubocop-discourse (2.5.0)
rubocop (>= 1.1.0) rubocop (>= 1.1.0)

View File

@ -14,7 +14,7 @@ describe ImportExport::CategoryExporter do
STDOUT.stubs(:write) STDOUT.stubs(:write)
end end
context '.perform' do describe '.perform' do
it 'export the category when it is found' do it 'export the category when it is found' do
data = ImportExport::CategoryExporter.new([category.id]).perform.export_data data = ImportExport::CategoryExporter.new([category.id]).perform.export_data

View File

@ -17,7 +17,7 @@ describe ImportExport::Importer do
ImportExport::Importer.new(data).perform ImportExport::Importer.new(data).perform
end end
context '.perform' do describe '.perform' do
it 'topics and users' do it 'topics and users' do
data = import_data.dup data = import_data.dup

View File

@ -12,7 +12,7 @@ describe ImportExport::TopicExporter do
fab!(:topic) { Fabricate(:topic, user: user) } fab!(:topic) { Fabricate(:topic, user: user) }
fab!(:post) { Fabricate(:post, topic: topic, user: user) } fab!(:post) { Fabricate(:post, topic: topic, user: user) }
context '.perform' do describe '.perform' do
it 'export a single topic' do it 'export a single topic' do
data = ImportExport::TopicExporter.new([topic.id]).perform.export_data data = ImportExport::TopicExporter.new([topic.id]).perform.export_data

View File

@ -5,7 +5,7 @@ describe Jobs::CleanDismissedTopicUsers do
fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) } fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) }
fab!(:dismissed_topic_user) { Fabricate(:dismissed_topic_user, user: user, topic: topic) } fab!(:dismissed_topic_user) { Fabricate(:dismissed_topic_user, user: user, topic: topic) }
context '#delete_overdue_dismissals!' do describe '#delete_overdue_dismissals!' do
it 'does not delete when new_topic_duration_minutes is set to always' do it 'does not delete when new_topic_duration_minutes is set to always' do
user.user_option.update(new_topic_duration_minutes: User::NewTopicDuration::ALWAYS) user.user_option.update(new_topic_duration_minutes: User::NewTopicDuration::ALWAYS)
expect { described_class.new.execute({}) }.not_to change { DismissedTopicUser.count } expect { described_class.new.execute({}) }.not_to change { DismissedTopicUser.count }
@ -28,7 +28,7 @@ describe Jobs::CleanDismissedTopicUsers do
end end
end end
context '#delete_over_the_limit_dismissals!' do describe '#delete_over_the_limit_dismissals!' do
fab!(:user2) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) } fab!(:user2) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) }
fab!(:topic2) { Fabricate(:topic, created_at: 6.hours.ago) } fab!(:topic2) { Fabricate(:topic, created_at: 6.hours.ago) }
fab!(:topic3) { Fabricate(:topic, created_at: 2.hours.ago) } fab!(:topic3) { Fabricate(:topic, created_at: 2.hours.ago) }

View File

@ -2,7 +2,7 @@
describe Jobs::DisableBootstrapMode do describe Jobs::DisableBootstrapMode do
context '.execute' do describe '.execute' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
before do before do

View File

@ -2,7 +2,7 @@
describe Jobs::EnableBootstrapMode do describe Jobs::EnableBootstrapMode do
context '.execute' do describe '.execute' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
before do before do

View File

@ -2,7 +2,7 @@
describe Jobs::ExportCsvFile do describe Jobs::ExportCsvFile do
context '#execute' do describe '#execute' do
let(:other_user) { Fabricate(:user) } let(:other_user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }
let(:action_log) { StaffActionLogger.new(admin).log_revoke_moderation(other_user) } let(:action_log) { StaffActionLogger.new(admin).log_revoke_moderation(other_user) }
@ -51,7 +51,7 @@ describe Jobs::ExportCsvFile do
end end
end end
context '.report_export' do describe '.report_export' do
let(:user) { Fabricate(:admin) } let(:user) { Fabricate(:admin) }

View File

@ -36,7 +36,7 @@ describe Jobs::ExportUserArchive do
JSON.parse(MultiJson.dump(job.public_send(:"#{component}_export"))) JSON.parse(MultiJson.dump(job.public_send(:"#{component}_export")))
end end
context '#execute' do describe '#execute' do
before do before do
_ = post _ = post
user.user_profile.website = 'https://doe.example.com/john' user.user_profile.website = 'https://doe.example.com/john'

View File

@ -2,7 +2,7 @@
describe Jobs::InviteEmail do describe Jobs::InviteEmail do
context '.execute' do describe '.execute' do
it 'raises an error when the invite_id is missing' do it 'raises an error when the invite_id is missing' do
expect { Jobs::InviteEmail.new.execute({}) }.to raise_error(Discourse::InvalidParameters) expect { Jobs::InviteEmail.new.execute({}) }.to raise_error(Discourse::InvalidParameters)

View File

@ -89,7 +89,7 @@ describe Jobs::ProcessPost do
end end
end end
context "#enqueue_pull_hotlinked_images" do describe "#enqueue_pull_hotlinked_images" do
fab!(:post) { Fabricate(:post, created_at: 20.days.ago) } fab!(:post) { Fabricate(:post, created_at: 20.days.ago) }
let(:job) { Jobs::ProcessPost.new } let(:job) { Jobs::ProcessPost.new }

View File

@ -592,7 +592,7 @@ describe Jobs::PullHotlinkedImages do
end end
end end
context "#disable_if_low_on_disk_space" do describe "#disable_if_low_on_disk_space" do
fab!(:post) { Fabricate(:post, created_at: 20.days.ago) } fab!(:post) { Fabricate(:post, created_at: 20.days.ago) }
let(:job) { Jobs::PullHotlinkedImages.new } let(:job) { Jobs::PullHotlinkedImages.new }

View File

@ -22,7 +22,7 @@ describe ComposerMessagesFinder do
end end
context '.check_education_message' do describe '.check_education_message' do
let(:user) { Fabricate.build(:user) } let(:user) { Fabricate.build(:user) }
context 'creating topic' do context 'creating topic' do
@ -82,7 +82,7 @@ describe ComposerMessagesFinder do
end end
end end
context '.check_new_user_many_replies' do describe '.check_new_user_many_replies' do
let(:user) { Fabricate.build(:user) } let(:user) { Fabricate.build(:user) }
context 'replying' do context 'replying' do
@ -101,7 +101,7 @@ describe ComposerMessagesFinder do
end end
context '.check_avatar_notification' do describe '.check_avatar_notification' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') } let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') }
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
@ -148,7 +148,7 @@ describe ComposerMessagesFinder do
end end
end end
context '.check_sequential_replies' do describe '.check_sequential_replies' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) } fab!(:topic) { Fabricate(:topic) }
@ -223,7 +223,7 @@ describe ComposerMessagesFinder do
end end
context '.check_dominating_topic' do describe '.check_dominating_topic' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) } fab!(:topic) { Fabricate(:topic) }
@ -308,7 +308,7 @@ describe ComposerMessagesFinder do
end end
context '.check_get_a_room' do describe '.check_get_a_room' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:other_user) { Fabricate(:user) } fab!(:other_user) { Fabricate(:user) }
fab!(:third_user) { Fabricate(:user) } fab!(:third_user) { Fabricate(:user) }
@ -431,7 +431,7 @@ describe ComposerMessagesFinder do
end end
context '.check_reviving_old_topic' do describe '.check_reviving_old_topic' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) } fab!(:topic) { Fabricate(:topic) }

View File

@ -7,7 +7,7 @@ describe CookedPostProcessor do
fab!(:upload) { Fabricate(:upload) } fab!(:upload) { Fabricate(:upload) }
let(:upload_path) { Discourse.store.upload_path } let(:upload_path) { Discourse.store.upload_path }
context "#post_process" do describe "#post_process" do
fab!(:post) do fab!(:post) do
Fabricate(:post, raw: <<~RAW) Fabricate(:post, raw: <<~RAW)
<img src="#{upload.url}"> <img src="#{upload.url}">
@ -837,7 +837,7 @@ describe CookedPostProcessor do
end end
end end
context "#extract_images" do describe "#extract_images" do
let(:post) { build(:post_with_plenty_of_images) } let(:post) { build(:post_with_plenty_of_images) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -848,7 +848,7 @@ describe CookedPostProcessor do
end end
context "#get_size_from_attributes" do describe "#get_size_from_attributes" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -882,7 +882,7 @@ describe CookedPostProcessor do
end end
context "#get_size_from_image_sizes" do describe "#get_size_from_image_sizes" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -894,7 +894,7 @@ describe CookedPostProcessor do
end end
context "#get_size" do describe "#get_size" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -916,7 +916,7 @@ describe CookedPostProcessor do
end end
end end
context "#is_valid_image_url?" do describe "#is_valid_image_url?" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -939,7 +939,7 @@ describe CookedPostProcessor do
end end
context "#get_filename" do describe "#get_filename" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -960,7 +960,7 @@ describe CookedPostProcessor do
end end
context "#convert_to_link" do describe "#convert_to_link" do
fab!(:thumbnail) { Fabricate(:optimized_image, upload: upload, width: 512, height: 384) } fab!(:thumbnail) { Fabricate(:optimized_image, upload: upload, width: 512, height: 384) }
before do before do
@ -1051,7 +1051,7 @@ describe CookedPostProcessor do
end end
end end
context "#post_process_oneboxes" do describe "#post_process_oneboxes" do
let(:post) { build(:post_with_youtube, id: 123) } let(:post) { build(:post_with_youtube, id: 123) }
let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) }
@ -1161,7 +1161,7 @@ describe CookedPostProcessor do
end end
end end
context "#post_process_oneboxes removes nofollow if add_rel_nofollow_to_user_content is disabled" do describe "#post_process_oneboxes removes nofollow if add_rel_nofollow_to_user_content is disabled" do
let(:post) { build(:post_with_youtube, id: 123) } let(:post) { build(:post_with_youtube, id: 123) }
let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) }
@ -1179,7 +1179,7 @@ describe CookedPostProcessor do
end end
end end
context "#post_process_oneboxes removes nofollow if user is tl3" do describe "#post_process_oneboxes removes nofollow if user is tl3" do
let(:post) { build(:post_with_youtube, id: 123) } let(:post) { build(:post_with_youtube, id: 123) }
let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) }
@ -1200,7 +1200,7 @@ describe CookedPostProcessor do
end end
end end
context "#post_process_oneboxes with oneboxed image" do describe "#post_process_oneboxes with oneboxed image" do
let(:post) { build(:post_with_youtube, id: 123) } let(:post) { build(:post_with_youtube, id: 123) }
let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) }
@ -1225,7 +1225,7 @@ describe CookedPostProcessor do
end end
end end
context "#post_process_oneboxes with square image" do describe "#post_process_oneboxes with square image" do
it "generates a onebox-avatar class" do it "generates a onebox-avatar class" do
url = 'https://square-image.com/onebox' url = 'https://square-image.com/onebox'
@ -1259,7 +1259,7 @@ describe CookedPostProcessor do
end end
context "#optimize_urls" do describe "#optimize_urls" do
let(:post) { build(:post_with_uploads_and_links) } let(:post) { build(:post_with_uploads_and_links) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -1515,7 +1515,7 @@ describe CookedPostProcessor do
end end
context "#remove_user_ids" do describe "#remove_user_ids" do
let(:topic) { Fabricate(:topic) } let(:topic) { Fabricate(:topic) }
let(:post) do let(:post) do
@ -1542,7 +1542,7 @@ describe CookedPostProcessor do
end end
end end
context "#is_a_hyperlink?" do describe "#is_a_hyperlink?" do
let(:post) { build(:post) } let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) } let(:cpp) { CookedPostProcessor.new(post) }
@ -1958,7 +1958,7 @@ describe CookedPostProcessor do
end end
end end
context "#html" do describe "#html" do
it "escapes attributes" do it "escapes attributes" do
post = Fabricate(:post, raw: '<img alt="<something>">') post = Fabricate(:post, raw: '<img alt="<something>">')
expect(post.cook(post.raw)).to eq('<p><img alt="&lt;something&gt;"></p>') expect(post.cook(post.raw)).to eq('<p><img alt="&lt;something&gt;"></p>')

View File

@ -83,7 +83,7 @@ describe DiscourseEvent do
end end
end end
context '#all_off' do describe '#all_off' do
let(:event_handler_2) do let(:event_handler_2) do
Proc.new { |user| user.job = 'Supervillain' } Proc.new { |user| user.job = 'Supervillain' }

View File

@ -55,42 +55,42 @@ describe DiscoursePluginRegistry do
end end
end end
context '#stylesheets' do describe '#stylesheets' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.stylesheets).to eq(Hash.new) expect(registry.stylesheets).to eq(Hash.new)
end end
end end
context '#mobile_stylesheets' do describe '#mobile_stylesheets' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.mobile_stylesheets).to eq(Hash.new) expect(registry.mobile_stylesheets).to eq(Hash.new)
end end
end end
context '#javascripts' do describe '#javascripts' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.javascripts).to eq(Set.new) expect(registry.javascripts).to eq(Set.new)
end end
end end
context '#auth_providers' do describe '#auth_providers' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.auth_providers).to eq(Set.new) expect(registry.auth_providers).to eq(Set.new)
end end
end end
context '#admin_javascripts' do describe '#admin_javascripts' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.admin_javascripts).to eq(Set.new) expect(registry.admin_javascripts).to eq(Set.new)
end end
end end
context '#seed_data' do describe '#seed_data' do
it 'defaults to an empty Set' do it 'defaults to an empty Set' do
registry.reset! registry.reset!
expect(registry.seed_data).to be_a(Hash) expect(registry.seed_data).to be_a(Hash)
@ -98,7 +98,7 @@ describe DiscoursePluginRegistry do
end end
end end
context '.register_html_builder' do describe '.register_html_builder' do
it "can register and build html" do it "can register and build html" do
DiscoursePluginRegistry.register_html_builder(:my_html) { "<b>my html</b>" } DiscoursePluginRegistry.register_html_builder(:my_html) { "<b>my html</b>" }
expect(DiscoursePluginRegistry.build_html(:my_html)).to eq('<b>my html</b>') expect(DiscoursePluginRegistry.build_html(:my_html)).to eq('<b>my html</b>')
@ -114,7 +114,7 @@ describe DiscoursePluginRegistry do
end end
end end
context '.register_css' do describe '.register_css' do
let(:plugin_directory_name) { "hello" } let(:plugin_directory_name) { "hello" }
before do before do
@ -134,7 +134,7 @@ describe DiscoursePluginRegistry do
end end
end end
context '.register_js' do describe '.register_js' do
before do before do
registry_instance.register_js('hello.js') registry_instance.register_js('hello.js')
end end
@ -148,7 +148,7 @@ describe DiscoursePluginRegistry do
end end
end end
context '.register_auth_provider' do describe '.register_auth_provider' do
let(:registry) { DiscoursePluginRegistry } let(:registry) { DiscoursePluginRegistry }
let(:auth_provider) do let(:auth_provider) do
provider = Auth::AuthProvider.new provider = Auth::AuthProvider.new
@ -170,7 +170,7 @@ describe DiscoursePluginRegistry do
end end
context '.register_service_worker' do describe '.register_service_worker' do
let(:registry) { DiscoursePluginRegistry } let(:registry) { DiscoursePluginRegistry }
before do before do
@ -189,14 +189,14 @@ describe DiscoursePluginRegistry do
end end
end end
context '.register_archetype' do describe '.register_archetype' do
it "delegates archetypes to the Archetype component" do it "delegates archetypes to the Archetype component" do
Archetype.expects(:register).with('threaded', hello: 123) Archetype.expects(:register).with('threaded', hello: 123)
registry_instance.register_archetype('threaded', hello: 123) registry_instance.register_archetype('threaded', hello: 123)
end end
end end
context '#register_asset' do describe '#register_asset' do
let(:registry) { DiscoursePluginRegistry } let(:registry) { DiscoursePluginRegistry }
let(:plugin_directory_name) { "my_plugin" } let(:plugin_directory_name) { "my_plugin" }
@ -247,7 +247,7 @@ describe DiscoursePluginRegistry do
end end
end end
context '#register_seed_data' do describe '#register_seed_data' do
let(:registry) { DiscoursePluginRegistry } let(:registry) { DiscoursePluginRegistry }
after do after do

View File

@ -177,7 +177,7 @@ describe Discourse do
end end
end end
context '#site_contact_user' do describe '#site_contact_user' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:another_admin) { Fabricate(:admin) } fab!(:another_admin) { Fabricate(:admin) }
@ -194,13 +194,13 @@ describe Discourse do
end end
context '#system_user' do describe '#system_user' do
it 'returns the system user' do it 'returns the system user' do
expect(Discourse.system_user.id).to eq(-1) expect(Discourse.system_user.id).to eq(-1)
end end
end end
context "#store" do describe "#store" do
it "returns LocalStore by default" do it "returns LocalStore by default" do
expect(Discourse.store).to be_a(FileStore::LocalStore) expect(Discourse.store).to be_a(FileStore::LocalStore)
@ -319,7 +319,7 @@ describe Discourse do
end end
end end
context "#handle_exception" do describe "#handle_exception" do
class TempSidekiqLogger class TempSidekiqLogger
attr_accessor :exception, :context attr_accessor :exception, :context
@ -363,7 +363,7 @@ describe Discourse do
end end
end end
context '#deprecate' do describe '#deprecate' do
def old_method(m) def old_method(m)
Discourse.deprecate(m) Discourse.deprecate(m)
end end
@ -472,7 +472,7 @@ describe Discourse do
end end
end end
context ".clear_all_theme_cache!" do describe ".clear_all_theme_cache!" do
before do before do
setup_s3 setup_s3
SiteSetting.s3_cdn_url = "https://s3.cdn.com/gg" SiteSetting.s3_cdn_url = "https://s3.cdn.com/gg"

View File

@ -1529,7 +1529,7 @@ describe Email::Receiver do
end end
context "#reply_by_email_address_regex" do describe "#reply_by_email_address_regex" do
before do before do
SiteSetting.reply_by_email_address = nil SiteSetting.reply_by_email_address = nil
@ -1863,7 +1863,7 @@ describe Email::Receiver do
expect(email.cc_addresses).to eq("bob@example.com;carol@example.com") expect(email.cc_addresses).to eq("bob@example.com;carol@example.com")
end end
context "#select_body" do describe "#select_body" do
let(:email) { let(:email) {
<<~EMAIL <<~EMAIL

View File

@ -44,7 +44,7 @@ describe InlineOneboxer do
end end
end end
context ".lookup" do describe ".lookup" do
let(:category) { Fabricate(:private_category, group: Group[:staff]) } let(:category) { Fabricate(:private_category, group: Group[:staff]) }
let(:category2) { Fabricate(:private_category, group: Group[:staff]) } let(:category2) { Fabricate(:private_category, group: Group[:staff]) }

View File

@ -149,7 +149,7 @@ describe Oneboxer do
end end
end end
context ".onebox_raw" do describe ".onebox_raw" do
it "should escape the onebox URL before processing" do it "should escape the onebox URL before processing" do
post = Fabricate(:post, raw: Discourse.base_url + "/new?'class=black") post = Fabricate(:post, raw: Discourse.base_url + "/new?'class=black")
cpp = CookedPostProcessor.new(post, invalidate_oneboxes: true) cpp = CookedPostProcessor.new(post, invalidate_oneboxes: true)
@ -158,7 +158,7 @@ describe Oneboxer do
end end
end end
context ".external_onebox" do describe ".external_onebox" do
html = <<~HTML html = <<~HTML
<html> <html>
<head> <head>

View File

@ -162,7 +162,7 @@ describe Plugin::Instance do
end end
end end
context "#add_report" do describe "#add_report" do
it "adds a report" do it "adds a report" do
plugin = Plugin::Instance.new nil, "/tmp/test.rb" plugin = Plugin::Instance.new nil, "/tmp/test.rb"
plugin.add_report("readers") {} plugin.add_report("readers") {}

View File

@ -1793,7 +1793,7 @@ describe PostCreator do
end end
end end
context "#create_post_notice" do describe "#create_post_notice" do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:staged) { Fabricate(:staged) } fab!(:staged) { Fabricate(:staged) }
fab!(:anonymous) { Fabricate(:anonymous) } fab!(:anonymous) { Fabricate(:anonymous) }

View File

@ -758,7 +758,7 @@ describe PostRevisor do
expect(post.post_revisions.last.modifications).to eq('tags' => [[], ['new-tag-3']]) expect(post.post_revisions.last.modifications).to eq('tags' => [[], ['new-tag-3']])
end end
context "#publish_changes" do describe "#publish_changes" do
let!(:post) { Fabricate(:post, topic: topic) } let!(:post) { Fabricate(:post, topic: topic) }
it "should publish topic changes to clients" do it "should publish topic changes to clients" do

View File

@ -9,7 +9,7 @@ describe Search do
Jobs.run_immediately! Jobs.run_immediately!
end end
context "#ts_config" do describe "#ts_config" do
it "maps locales to correct Postgres dictionaries" do it "maps locales to correct Postgres dictionaries" do
expect(Search.ts_config).to eq("english") expect(Search.ts_config).to eq("english")
expect(Search.ts_config("en")).to eq("english") expect(Search.ts_config("en")).to eq("english")
@ -20,7 +20,7 @@ describe Search do
end end
end end
context "#GroupedSearchResults.blurb_for" do describe "#GroupedSearchResults.blurb_for" do
it "strips audio and video URLs from search blurb" do it "strips audio and video URLs from search blurb" do
cooked = <<~RAW cooked = <<~RAW
link to an external page: https://google.com/?u=bar link to an external page: https://google.com/?u=bar
@ -55,7 +55,7 @@ describe Search do
end end
end end
context "#execute" do describe "#execute" do
before do before do
SiteSetting.tagging_enabled = true SiteSetting.tagging_enabled = true
end end
@ -2030,7 +2030,7 @@ describe Search do
end end
end end
context '#ts_query' do describe '#ts_query' do
it 'can parse complex strings using ts_query helper' do it 'can parse complex strings using ts_query helper' do
str = +" grigio:babel deprecated? " str = +" grigio:babel deprecated? "
str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa.js:222 aaa'\"bbb" str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa.js:222 aaa'\"bbb"
@ -2052,7 +2052,7 @@ describe Search do
end end
end end
context '#word_to_date' do describe '#word_to_date' do
it 'parses relative dates correctly' do it 'parses relative dates correctly' do
time = Time.zone.parse('2001-02-20 2:55') time = Time.zone.parse('2001-02-20 2:55')
freeze_time(time) freeze_time(time)
@ -2080,7 +2080,7 @@ describe Search do
end end
end end
context "#min_post_id" do describe "#min_post_id" do
it "returns 0 when prefer_recent_posts is disabled" do it "returns 0 when prefer_recent_posts is disabled" do
SiteSetting.search_prefer_recent_posts = false SiteSetting.search_prefer_recent_posts = false
expect(Search.min_post_id_no_cache).to eq(0) expect(Search.min_post_id_no_cache).to eq(0)

View File

@ -8,7 +8,7 @@ describe Stylesheet::Importer do
Stylesheet::Compiler.compile_asset(name)[0] Stylesheet::Compiler.compile_asset(name)[0]
end end
context "#category_backgrounds" do describe "#category_backgrounds" do
it "applies CDN to background category images" do it "applies CDN to background category images" do
expect(compile_css("color_definitions")).to_not include("body.category-") expect(compile_css("color_definitions")).to_not include("body.category-")
@ -37,7 +37,7 @@ describe Stylesheet::Importer do
end end
context "#font" do describe "#font" do
it "includes font variable" do it "includes font variable" do
default_font = ":root{--font-family: Arial, sans-serif}" default_font = ":root{--font-family: Arial, sans-serif}"
expect(compile_css("color_definitions")).to include(default_font) expect(compile_css("color_definitions")).to include(default_font)
@ -76,7 +76,7 @@ describe Stylesheet::Importer do
end end
end end
context "#import_color_definitions" do describe "#import_color_definitions" do
let(:scss) { ":root{--custom-color: green}" } let(:scss) { ":root{--custom-color: green}" }
let(:scss_child) { "$navy: #000080; :root{--custom-color: red; --custom-color-rgb: \#{hexToRGB($navy)}}" } let(:scss_child) { "$navy: #000080; :root{--custom-color: red; --custom-color-rgb: \#{hexToRGB($navy)}}" }
@ -115,7 +115,7 @@ describe Stylesheet::Importer do
end end
end end
context "#import_wcag_overrides" do describe "#import_wcag_overrides" do
it "should do nothing on a regular scheme" do it "should do nothing on a regular scheme" do
scheme = ColorScheme.create_from_base(name: 'Regular') scheme = ColorScheme.create_from_base(name: 'Regular')
expect(Stylesheet::Importer.new({ color_scheme_id: scheme.id }).import_wcag_overrides).to eq("") expect(Stylesheet::Importer.new({ color_scheme_id: scheme.id }).import_wcag_overrides).to eq("")

View File

@ -5,7 +5,7 @@ require 'topic_subtype'
describe SystemMessage do describe SystemMessage do
context '#create' do describe '#create' do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }

View File

@ -6,7 +6,7 @@ require 'theme_store/git_importer'
describe ThemeStore::GitImporter do describe ThemeStore::GitImporter do
context "#import" do describe "#import" do
let(:url) { "https://github.com/example/example.git" } let(:url) { "https://github.com/example/example.git" }
let(:trailing_slash_url) { "https://github.com/example/example/" } let(:trailing_slash_url) { "https://github.com/example/example/" }

View File

@ -65,7 +65,7 @@ describe TopicQuery do
end end
end end
context "#list_topics_by" do describe "#list_topics_by" do
it "allows users to view their own invisible topics" do it "allows users to view their own invisible topics" do
_topic = Fabricate(:topic, user: user) _topic = Fabricate(:topic, user: user)
@ -77,7 +77,7 @@ describe TopicQuery do
end end
context "#prioritize_pinned_topics" do describe "#prioritize_pinned_topics" do
it "does the pagination correctly" do it "does the pagination correctly" do
num_topics = 15 num_topics = 15
per_page = 3 per_page = 3
@ -503,7 +503,7 @@ describe TopicQuery do
end end
end end
context "#list_top_for" do describe "#list_top_for" do
it "lists top for the week" do it "lists top for the week" do
Fabricate(:topic, like_count: 1000, posts_count: 100) Fabricate(:topic, like_count: 1000, posts_count: 100)
TopTopic.refresh! TopTopic.refresh!
@ -892,7 +892,7 @@ describe TopicQuery do
end end
context '#list_new' do describe '#list_new' do
context 'without a new topic' do context 'without a new topic' do
it "has no new topics" do it "has no new topics" do
@ -969,7 +969,7 @@ describe TopicQuery do
end end
context '#list_posted' do describe '#list_posted' do
let(:topics) { topic_query.list_posted.topics } let(:topics) { topic_query.list_posted.topics }
it "returns blank when there are no posted topics" do it "returns blank when there are no posted topics" do
@ -1023,7 +1023,7 @@ describe TopicQuery do
end end
end end
context '#list_unseen' do describe '#list_unseen' do
it "returns an empty list when there aren't topics" do it "returns an empty list when there aren't topics" do
expect(topic_query.list_unseen.topics).to be_blank expect(topic_query.list_unseen.topics).to be_blank
end end
@ -1074,7 +1074,7 @@ describe TopicQuery do
end end
end end
context '#list_related_for' do describe '#list_related_for' do
let(:user) do let(:user) do
Fabricate(:admin) Fabricate(:admin)

View File

@ -341,7 +341,7 @@ RSpec.describe TopicView do
end end
end end
context '.post_counts_by_user' do describe '.post_counts_by_user' do
it 'returns the two posters with their appropriate counts' do it 'returns the two posters with their appropriate counts' do
SiteSetting.enable_whispers = true SiteSetting.enable_whispers = true
Fabricate(:post, topic: topic, user: evil_trout, post_type: Post.types[:whisper]) Fabricate(:post, topic: topic, user: evil_trout, post_type: Post.types[:whisper])
@ -361,13 +361,13 @@ RSpec.describe TopicView do
end end
end end
context '.participants' do describe '.participants' do
it 'returns the two participants hashed by id' do it 'returns the two participants hashed by id' do
expect(topic_view.participants.to_a).to match_array([[first_poster.id, first_poster], [evil_trout.id, evil_trout]]) expect(topic_view.participants.to_a).to match_array([[first_poster.id, first_poster], [evil_trout.id, evil_trout]])
end end
end end
context '.all_post_actions' do describe '.all_post_actions' do
it 'is blank at first' do it 'is blank at first' do
expect(topic_view.all_post_actions).to be_blank expect(topic_view.all_post_actions).to be_blank
end end
@ -378,7 +378,7 @@ RSpec.describe TopicView do
end end
end end
context '.read?' do describe '.read?' do
it 'tracks correctly' do it 'tracks correctly' do
# anon is assumed to have read everything # anon is assumed to have read everything
expect(TopicView.new(topic.id).read?(1)).to eq(true) expect(TopicView.new(topic.id).read?(1)).to eq(true)
@ -395,7 +395,7 @@ RSpec.describe TopicView do
end end
end end
context "#bookmarks" do describe "#bookmarks" do
let!(:user) { Fabricate(:user) } let!(:user) { Fabricate(:user) }
let!(:bookmark1) { Fabricate(:bookmark, bookmarkable: Fabricate(:post, topic: topic), user: user) } let!(:bookmark1) { Fabricate(:bookmark, bookmarkable: Fabricate(:post, topic: topic), user: user) }
let!(:bookmark2) { Fabricate(:bookmark, bookmarkable: Fabricate(:post, topic: topic), user: user) } let!(:bookmark2) { Fabricate(:bookmark, bookmarkable: Fabricate(:post, topic: topic), user: user) }
@ -412,7 +412,7 @@ RSpec.describe TopicView do
end end
end end
context "#bookmarks" do describe "#bookmarks" do
let!(:user) { Fabricate(:user) } let!(:user) { Fabricate(:user) }
let!(:bookmark1) { Fabricate(:bookmark_next_business_day_reminder, bookmarkable: topic.first_post, user: user) } let!(:bookmark1) { Fabricate(:bookmark_next_business_day_reminder, bookmarkable: topic.first_post, user: user) }
let!(:bookmark2) { Fabricate(:bookmark_next_business_day_reminder, bookmarkable: topic.posts[1], user: user) } let!(:bookmark2) { Fabricate(:bookmark_next_business_day_reminder, bookmarkable: topic.posts[1], user: user) }
@ -452,13 +452,13 @@ RSpec.describe TopicView do
end end
end end
context '.topic_user' do describe '.topic_user' do
it 'returns nil when there is no user' do it 'returns nil when there is no user' do
expect(TopicView.new(topic.id, nil).topic_user).to be_blank expect(TopicView.new(topic.id, nil).topic_user).to be_blank
end end
end end
context '#recent_posts' do describe '#recent_posts' do
before do before do
24.times do |t| # our let()s have already created 3 24.times do |t| # our let()s have already created 3
Fabricate(:post, topic: topic, user: first_poster, created_at: t.seconds.from_now) Fabricate(:post, topic: topic, user: first_poster, created_at: t.seconds.from_now)
@ -497,7 +497,7 @@ RSpec.describe TopicView do
end end
end end
context '#posts' do describe '#posts' do
# Create the posts in a different order than the sort_order # Create the posts in a different order than the sort_order
let!(:p5) { Fabricate(:post, topic: topic, user: evil_trout) } let!(:p5) { Fabricate(:post, topic: topic, user: evil_trout) }

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
describe TwitterApi do describe TwitterApi do
context '.link_handles_in' do describe '.link_handles_in' do
it 'correctly replaces handles' do it 'correctly replaces handles' do
expect(TwitterApi.send(:link_handles_in, "@foo @foobar")).to match_html <<~HTML expect(TwitterApi.send(:link_handles_in, "@foo @foobar")).to match_html <<~HTML
<a href='https://twitter.com/foo' target='_blank'>@foo</a> <a href='https://twitter.com/foobar' target='_blank'>@foobar</a> <a href='https://twitter.com/foo' target='_blank'>@foo</a> <a href='https://twitter.com/foobar' target='_blank'>@foobar</a>
@ -9,7 +9,7 @@ describe TwitterApi do
end end
end end
context '.link_hashtags_in' do describe '.link_hashtags_in' do
it 'correctly replaces hashtags' do it 'correctly replaces hashtags' do
expect(TwitterApi.send(:link_hashtags_in, "#foo #foobar")).to match_html <<~HTML expect(TwitterApi.send(:link_hashtags_in, "#foo #foobar")).to match_html <<~HTML
<a href='https://twitter.com/search?q=%23foo' target='_blank'>#foo</a> <a href='https://twitter.com/search?q=%23foobar' target='_blank'>#foobar</a> <a href='https://twitter.com/search?q=%23foo' target='_blank'>#foo</a> <a href='https://twitter.com/search?q=%23foobar' target='_blank'>#foobar</a>

View File

@ -5,7 +5,7 @@ describe PostValidator do
let(:post) { build(:post, topic: topic) } let(:post) { build(:post, topic: topic) }
let(:validator) { PostValidator.new({}) } let(:validator) { PostValidator.new({}) }
context "#post_body_validator" do describe "#post_body_validator" do
it 'should not allow a post with an empty raw' do it 'should not allow a post with an empty raw' do
post.raw = "" post.raw = ""
validator.post_body_validator(post) validator.post_body_validator(post)

View File

@ -221,7 +221,7 @@ describe Badge do
end end
end end
context "#seed" do describe "#seed" do
let(:regular_badge) do let(:regular_badge) do
Badge.find(Badge::Regular) Badge.find(Badge::Regular)

View File

@ -1089,13 +1089,13 @@ describe Category do
SQL SQL
end end
context "#depth_of_descendants" do describe "#depth_of_descendants" do
it "should produce max_depth" do it "should produce max_depth" do
expect(category.depth_of_descendants(3)).to eq(3) expect(category.depth_of_descendants(3)).to eq(3)
end end
end end
context "#height_of_ancestors" do describe "#height_of_ancestors" do
it "should produce max_height" do it "should produce max_height" do
expect(category.height_of_ancestors(3)).to eq(3) expect(category.height_of_ancestors(3)).to eq(3)
end end
@ -1107,13 +1107,13 @@ describe Category do
category.parent_category_id = category.id category.parent_category_id = category.id
end end
context "#depth_of_descendants" do describe "#depth_of_descendants" do
it "should produce max_depth" do it "should produce max_depth" do
expect(category.depth_of_descendants(3)).to eq(3) expect(category.depth_of_descendants(3)).to eq(3)
end end
end end
context "#height_of_ancestors" do describe "#height_of_ancestors" do
it "should produce max_height" do it "should produce max_height" do
expect(category.height_of_ancestors(3)).to eq(3) expect(category.height_of_ancestors(3)).to eq(3)
end end
@ -1125,20 +1125,20 @@ describe Category do
category.parent_category_id = subcategory.id category.parent_category_id = subcategory.id
end end
context "#depth_of_descendants" do describe "#depth_of_descendants" do
it "should produce max_depth" do it "should produce max_depth" do
expect(category.depth_of_descendants(3)).to eq(3) expect(category.depth_of_descendants(3)).to eq(3)
end end
end end
context "#height_of_ancestors" do describe "#height_of_ancestors" do
it "should produce max_height" do it "should produce max_height" do
expect(category.height_of_ancestors(3)).to eq(3) expect(category.height_of_ancestors(3)).to eq(3)
end end
end end
end end
context "#depth_of_descendants" do describe "#depth_of_descendants" do
it "should be 0 when the category has no descendants" do it "should be 0 when the category has no descendants" do
expect(subcategory.depth_of_descendants).to eq(0) expect(subcategory.depth_of_descendants).to eq(0)
end end
@ -1148,7 +1148,7 @@ describe Category do
end end
end end
context "#height_of_ancestors" do describe "#height_of_ancestors" do
it "should be 0 when the category has no ancestors" do it "should be 0 when the category has no ancestors" do
expect(category.height_of_ancestors).to eq(0) expect(category.height_of_ancestors).to eq(0)
end end

View File

@ -12,7 +12,7 @@ describe CategoryUser do
CategoryUser.notification_levels[:regular] CategoryUser.notification_levels[:regular]
end end
context '#batch_set' do describe '#batch_set' do
fab!(:category) { Fabricate(:category) } fab!(:category) { Fabricate(:category) }
def category_ids_at_level(level) def category_ids_at_level(level)

View File

@ -5,7 +5,7 @@ describe EmailToken do
it { is_expected.to validate_presence_of :email } it { is_expected.to validate_presence_of :email }
it { is_expected.to belong_to :user } it { is_expected.to belong_to :user }
context '#create' do describe '#create' do
fab!(:user) { Fabricate(:user, active: false) } fab!(:user) { Fabricate(:user, active: false) }
let!(:original_token) { user.email_tokens.first } let!(:original_token) { user.email_tokens.first }
let!(:email_token) { Fabricate(:email_token, user: user, email: 'bubblegum@adventuretime.ooo') } let!(:email_token) { Fabricate(:email_token, user: user, email: 'bubblegum@adventuretime.ooo') }
@ -41,7 +41,7 @@ describe EmailToken do
end end
end end
context '#confirm' do describe '#confirm' do
fab!(:user) { Fabricate(:user, active: false) } fab!(:user) { Fabricate(:user, active: false) }
let!(:email_token) { Fabricate(:email_token, user: user) } let!(:email_token) { Fabricate(:email_token, user: user) }

View File

@ -65,7 +65,7 @@ describe Invite do
end end
end end
context '.generate' do describe '.generate' do
it 'saves an invites' do it 'saves an invites' do
invite = Invite.generate(user, email: 'TEST@EXAMPLE.COM') invite = Invite.generate(user, email: 'TEST@EXAMPLE.COM')
expect(invite.invite_key).to be_present expect(invite.invite_key).to be_present
@ -201,7 +201,7 @@ describe Invite do
end end
end end
context '#redeem' do describe '#redeem' do
fab!(:invite) { Fabricate(:invite) } fab!(:invite) { Fabricate(:invite) }
it 'works' do it 'works' do

View File

@ -1491,7 +1491,7 @@ describe Post do
expect(UploadReference.count).to eq(0) expect(UploadReference.count).to eq(0)
end end
context "#link_post_uploads" do describe "#link_post_uploads" do
it "finds all the uploads in the post" do it "finds all the uploads in the post" do
post.link_post_uploads post.link_post_uploads
@ -1547,7 +1547,7 @@ describe Post do
end end
end end
context '#update_uploads_secure_status' do describe '#update_uploads_secure_status' do
fab!(:user) { Fabricate(:user, trust_level: 0) } fab!(:user) { Fabricate(:user, trust_level: 0) }
let(:raw) do let(:raw) do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
describe RemoteTheme do describe RemoteTheme do
context '#import_remote' do describe '#import_remote' do
def about_json(love_color: "FAFAFA", tertiary_low_color: "FFFFFF", color_scheme_name: "Amazing", about_url: "https://www.site.com/about") def about_json(love_color: "FAFAFA", tertiary_low_color: "FFFFFF", color_scheme_name: "Amazing", about_url: "https://www.site.com/about")
<<~JSON <<~JSON
{ {
@ -201,7 +201,7 @@ describe RemoteTheme do
) )
end end
context "#github_diff_link" do describe "#github_diff_link" do
it "is blank for non-github repos" do it "is blank for non-github repos" do
expect(gitlab_repo.github_diff_link).to be_blank expect(gitlab_repo.github_diff_link).to be_blank
end end
@ -218,7 +218,7 @@ describe RemoteTheme do
end end
end end
context ".joined_remotes" do describe ".joined_remotes" do
it "finds records that are associated with themes" do it "finds records that are associated with themes" do
github_repo github_repo
gitlab_repo gitlab_repo
@ -232,7 +232,7 @@ describe RemoteTheme do
end end
end end
context ".out_of_date_themes" do describe ".out_of_date_themes" do
let(:remote) { RemoteTheme.create!(remote_url: "https://github.com/org/testtheme") } let(:remote) { RemoteTheme.create!(remote_url: "https://github.com/org/testtheme") }
let!(:theme) { Fabricate(:theme, remote_theme: remote) } let!(:theme) { Fabricate(:theme, remote_theme: remote) }
@ -252,7 +252,7 @@ describe RemoteTheme do
end end
context ".unreachable_themes" do describe ".unreachable_themes" do
let(:remote) { RemoteTheme.create!(remote_url: "https://github.com/org/testtheme", last_error_text: "can't contact this repo :(") } let(:remote) { RemoteTheme.create!(remote_url: "https://github.com/org/testtheme", last_error_text: "can't contact this repo :(") }
let!(:theme) { Fabricate(:theme, remote_theme: remote) } let!(:theme) { Fabricate(:theme, remote_theme: remote) }

View File

@ -2,7 +2,7 @@
RSpec.describe Reviewable, type: :model do RSpec.describe Reviewable, type: :model do
context ".create" do describe ".create" do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
@ -31,7 +31,7 @@ RSpec.describe Reviewable, type: :model do
end end
end end
context ".needs_review!" do describe ".needs_review!" do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
@ -86,7 +86,7 @@ RSpec.describe Reviewable, type: :model do
end end
end end
context ".list_for" do describe ".list_for" do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
it "returns an empty list for nil user" do it "returns an empty list for nil user" do
@ -381,7 +381,7 @@ RSpec.describe Reviewable, type: :model do
end end
end end
context ".score_required_to_hide_post" do describe ".score_required_to_hide_post" do
it "will return the default visibility if it's higher" do it "will return the default visibility if it's higher" do
Reviewable.set_priorities(low: 40.0, high: 100.0) Reviewable.set_priorities(low: 40.0, high: 100.0)
@ -411,7 +411,7 @@ RSpec.describe Reviewable, type: :model do
end end
end end
context ".spam_score_to_silence_new_user" do describe ".spam_score_to_silence_new_user" do
it "returns a default value if we can't calculated any percentiles" do it "returns a default value if we can't calculated any percentiles" do
SiteSetting.silence_new_user_sensitivity = Reviewable.sensitivity[:low] SiteSetting.silence_new_user_sensitivity = Reviewable.sensitivity[:low]
expect(Reviewable.spam_score_to_silence_new_user).to eq(7.5) expect(Reviewable.spam_score_to_silence_new_user).to eq(7.5)
@ -434,7 +434,7 @@ RSpec.describe Reviewable, type: :model do
end end
end end
context ".score_to_auto_close_topic" do describe ".score_to_auto_close_topic" do
it "returns the default if we can't calculated any percentiles" do it "returns the default if we can't calculated any percentiles" do
SiteSetting.auto_close_topic_sensitivity = Reviewable.sensitivity[:low] SiteSetting.auto_close_topic_sensitivity = Reviewable.sensitivity[:low]

View File

@ -55,7 +55,7 @@ RSpec.describe ReviewableUser, type: :model do
end end
end end
context "#update_fields" do describe "#update_fields" do
fab!(:moderator) { Fabricate(:moderator) } fab!(:moderator) { Fabricate(:moderator) }
fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable) { Fabricate(:reviewable) }

View File

@ -8,7 +8,7 @@ describe TopicEmbed do
it { is_expected.to belong_to :post } it { is_expected.to belong_to :post }
it { is_expected.to validate_presence_of :embed_url } it { is_expected.to validate_presence_of :embed_url }
context '.import' do describe '.import' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
let(:title) { "How to turn a fish from good to evil in 30 seconds" } let(:title) { "How to turn a fish from good to evil in 30 seconds" }
@ -173,7 +173,7 @@ describe TopicEmbed do
end end
end end
context '.topic_id_for_embed' do describe '.topic_id_for_embed' do
it "returns correct topic id irrespective of url protocol" do it "returns correct topic id irrespective of url protocol" do
topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248") topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248")
@ -195,7 +195,7 @@ describe TopicEmbed do
describe '.find_remote' do describe '.find_remote' do
fab!(:embeddable_host) { Fabricate(:embeddable_host) } fab!(:embeddable_host) { Fabricate(:embeddable_host) }
context ".title_scrub" do describe ".title_scrub" do
let(:url) { 'http://eviltrout.com/123' } let(:url) { 'http://eviltrout.com/123' }
let(:contents) { "<title>Through the Looking Glass - Classic Books</title><body>some content here</body>" } let(:contents) { "<title>Through the Looking Glass - Classic Books</title><body>some content here</body>" }

View File

@ -17,7 +17,7 @@ describe Topic do
context 'validations' do context 'validations' do
let(:topic) { Fabricate.build(:topic) } let(:topic) { Fabricate.build(:topic) }
context "#featured_link" do describe "#featured_link" do
describe 'when featured_link contains more than a URL' do describe 'when featured_link contains more than a URL' do
it 'should not be valid' do it 'should not be valid' do
topic.featured_link = 'http://meta.discourse.org TEST' topic.featured_link = 'http://meta.discourse.org TEST'
@ -33,7 +33,7 @@ describe Topic do
end end
end end
context "#external_id" do describe "#external_id" do
describe 'when external_id is too long' do describe 'when external_id is too long' do
it 'should not be valid' do it 'should not be valid' do
topic.external_id = 'a' * (Topic::EXTERNAL_ID_MAX_LENGTH + 1) topic.external_id = 'a' * (Topic::EXTERNAL_ID_MAX_LENGTH + 1)
@ -78,7 +78,7 @@ describe Topic do
end end
end end
context "#title" do describe "#title" do
it { is_expected.to validate_presence_of :title } it { is_expected.to validate_presence_of :title }
describe 'censored words' do describe 'censored words' do
@ -165,7 +165,7 @@ describe Topic do
it { is_expected.to rate_limit } it { is_expected.to rate_limit }
context '#visible_post_types' do describe '#visible_post_types' do
let(:types) { Post.types } let(:types) { Post.types }
before do before do
@ -260,7 +260,7 @@ describe Topic do
end end
end end
context '#ascii_generator' do describe '#ascii_generator' do
before { SiteSetting.slug_generation_method = 'ascii' } before { SiteSetting.slug_generation_method = 'ascii' }
context 'with ascii letters' do context 'with ascii letters' do
@ -613,7 +613,7 @@ describe Topic do
end end
end end
context '.similar_to' do describe '.similar_to' do
fab!(:category) { Fabricate(:category_with_definition) } fab!(:category) { Fabricate(:category_with_definition) }
it 'returns an empty array with nil params' do it 'returns an empty array with nil params' do

View File

@ -6,7 +6,7 @@ describe TopicTag do
fab!(:tag) { Fabricate(:tag) } fab!(:tag) { Fabricate(:tag) }
let(:topic_tag) { Fabricate(:topic_tag, topic: topic, tag: tag) } let(:topic_tag) { Fabricate(:topic_tag, topic: topic, tag: tag) }
context '#after_create' do describe '#after_create' do
it "tag topic_count should be increased" do it "tag topic_count should be increased" do
expect { expect {
@ -24,7 +24,7 @@ describe TopicTag do
end end
context '#after_destroy' do describe '#after_destroy' do
it "tag topic_count should be decreased" do it "tag topic_count should be decreased" do
topic_tag topic_tag

View File

@ -43,7 +43,7 @@ describe Upload do
end end
end end
context ".create_thumbnail!" do describe ".create_thumbnail!" do
it "does not create a thumbnail when disabled" do it "does not create a thumbnail when disabled" do
SiteSetting.create_thumbnails = false SiteSetting.create_thumbnails = false
OptimizedImage.expects(:create_for).never OptimizedImage.expects(:create_for).never
@ -118,7 +118,7 @@ describe Upload do
expect(created_upload.valid?).to eq(false) expect(created_upload.valid?).to eq(false)
end end
context ".extract_url" do describe ".extract_url" do
let(:url) { 'https://example.com/uploads/default/original/1X/d1c2d40ab994e8410c.png' } let(:url) { 'https://example.com/uploads/default/original/1X/d1c2d40ab994e8410c.png' }
it 'should return the right part of url' do it 'should return the right part of url' do
@ -126,7 +126,7 @@ describe Upload do
end end
end end
context ".get_from_url" do describe ".get_from_url" do
let(:sha1) { "10f73034616a796dfd70177dc54b6def44c4ba6f" } let(:sha1) { "10f73034616a796dfd70177dc54b6def44c4ba6f" }
let(:upload) { Fabricate(:upload, sha1: sha1) } let(:upload) { Fabricate(:upload, sha1: sha1) }
@ -258,7 +258,7 @@ describe Upload do
end end
end end
context ".get_from_urls" do describe ".get_from_urls" do
let(:upload) { Fabricate(:upload, sha1: "10f73034616a796dfd70177dc54b6def44c4ba6f") } let(:upload) { Fabricate(:upload, sha1: "10f73034616a796dfd70177dc54b6def44c4ba6f") }
let(:upload2) { Fabricate(:upload, sha1: "2a7081e615f9075befd87a9a6d273935c0262cd5") } let(:upload2) { Fabricate(:upload, sha1: "2a7081e615f9075befd87a9a6d273935c0262cd5") }
@ -549,7 +549,7 @@ describe Upload do
stub_upload(upload) stub_upload(upload)
end end
context '.destroy' do describe '.destroy' do
it "can correctly clear information when destroying an upload" do it "can correctly clear information when destroying an upload" do
upload = Fabricate(:upload) upload = Fabricate(:upload)
user = Fabricate(:user) user = Fabricate(:user)
@ -568,7 +568,7 @@ describe Upload do
end end
end end
context ".signed_url_from_secure_media_url" do describe ".signed_url_from_secure_media_url" do
before do before do
# must be done so signed_url_for_path exists # must be done so signed_url_for_path exists
enable_secure_media enable_secure_media
@ -589,7 +589,7 @@ describe Upload do
end end
end end
context ".secure_media_url_from_upload_url" do describe ".secure_media_url_from_upload_url" do
before do before do
# must be done so signed_url_for_path exists # must be done so signed_url_for_path exists
enable_secure_media enable_secure_media
@ -603,7 +603,7 @@ describe Upload do
end end
end end
context ".secure_media_url?" do describe ".secure_media_url?" do
it "works for a secure media url with or without schema + host" do it "works for a secure media url with or without schema + host" do
url = "//localhost:3000/secure-media-uploads/original/2X/f/f62055931bb702c7fd8f552fb901f977e0289a18.png" url = "//localhost:3000/secure-media-uploads/original/2X/f/f62055931bb702c7fd8f552fb901f977e0289a18.png"
expect(Upload.secure_media_url?(url)).to eq(true) expect(Upload.secure_media_url?(url)).to eq(true)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
describe UserApiKey do describe UserApiKey do
context "#allow?" do describe "#allow?" do
def request_env(method, path, **path_parameters) def request_env(method, path, **path_parameters)
ActionDispatch::TestRequest.create.tap do |request| ActionDispatch::TestRequest.create.tap do |request|
request.request_method = method request.request_method = method

View File

@ -120,7 +120,7 @@ describe UserAvatar do
end end
end end
context '.import_url_for_user' do describe '.import_url_for_user' do
it 'creates user_avatar record if missing' do it 'creates user_avatar record if missing' do
user = Fabricate(:user) user = Fabricate(:user)

View File

@ -261,7 +261,7 @@ RSpec.describe UserProfile do
end end
end end
context '.import_url_for_user' do describe '.import_url_for_user' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
before do before do

View File

@ -289,7 +289,7 @@ RSpec.describe User do
end end
end end
context '.enqueue_welcome_message' do describe '.enqueue_welcome_message' do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
it 'enqueues the system message' do it 'enqueues the system message' do
@ -333,7 +333,7 @@ RSpec.describe User do
end end
end end
context '.set_default_tags_preferences' do describe '.set_default_tags_preferences' do
let(:tag) { Fabricate(:tag) } let(:tag) { Fabricate(:tag) }
it "should set default tag preferences when new user created" do it "should set default tag preferences when new user created" do
@ -2450,7 +2450,7 @@ RSpec.describe User do
end end
end end
context "#destroy!" do describe "#destroy!" do
it 'clears up associated data on destroy!' do it 'clears up associated data on destroy!' do
user = Fabricate(:user) user = Fabricate(:user)
post = Fabricate(:post) post = Fabricate(:post)

View File

@ -10,7 +10,7 @@ describe UserStat do
expect(user.user_stat.new_since).to be_present expect(user.user_stat.new_since).to be_present
end end
context '#update_view_counts' do describe '#update_view_counts' do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:stat) { user.user_stat } let(:stat) { user.user_stat }

View File

@ -2,7 +2,7 @@
describe AboutController do describe AboutController do
context '.index' do describe '.index' do
it "should display the about page for anonymous user when login_required is false" do it "should display the about page for anonymous user when login_required is false" do
SiteSetting.login_required = false SiteSetting.login_required = false

View File

@ -17,7 +17,7 @@ RSpec.describe Admin::EmailTemplatesController do
I18n.reload! I18n.reload!
end end
context "#index" do describe "#index" do
it "raises an error if you aren't logged in" do it "raises an error if you aren't logged in" do
get '/admin/customize/email_templates.json' get '/admin/customize/email_templates.json'
expect(response.status).to eq(404) expect(response.status).to eq(404)
@ -63,7 +63,7 @@ RSpec.describe Admin::EmailTemplatesController do
end end
end end
context "#update" do describe "#update" do
it "raises an error if you aren't logged in" do it "raises an error if you aren't logged in" do
put '/admin/customize/email_templates/some_id', params: { put '/admin/customize/email_templates/some_id', params: {
email_template: { subject: 'Subject', body: 'Body' } email_template: { subject: 'Subject', body: 'Body' }
@ -256,7 +256,7 @@ RSpec.describe Admin::EmailTemplatesController do
end end
context "#revert" do describe "#revert" do
it "raises an error if you aren't logged in" do it "raises an error if you aren't logged in" do
delete '/admin/customize/email_templates/some_id', headers: headers delete '/admin/customize/email_templates/some_id', headers: headers
expect(response.status).to eq(404) expect(response.status).to eq(404)

View File

@ -260,7 +260,7 @@ RSpec.describe Admin::GroupsController do
end end
end end
context "#destroy" do describe "#destroy" do
it 'should return the right response for an invalid group_id' do it 'should return the right response for an invalid group_id' do
max_id = Group.maximum(:id).to_i max_id = Group.maximum(:id).to_i
delete "/admin/groups/#{max_id + 1}.json" delete "/admin/groups/#{max_id + 1}.json"

View File

@ -12,7 +12,7 @@ RSpec.describe Admin::SearchLogsController do
SearchLog.clear_debounce_cache! SearchLog.clear_debounce_cache!
end end
context "#index" do describe "#index" do
it "raises an error if you aren't logged in" do it "raises an error if you aren't logged in" do
get '/admin/logs/search_logs.json' get '/admin/logs/search_logs.json'
expect(response.status).to eq(404) expect(response.status).to eq(404)
@ -37,7 +37,7 @@ RSpec.describe Admin::SearchLogsController do
end end
end end
context "#term" do describe "#term" do
it "raises an error if you aren't logged in" do it "raises an error if you aren't logged in" do
get '/admin/logs/search_logs/term.json', params: { get '/admin/logs/search_logs/term.json', params: {
term: "ruby" term: "ruby"

View File

@ -116,7 +116,7 @@ RSpec.describe Admin::WatchedWordsController do
end end
end end
context '#clear_all' do describe '#clear_all' do
context 'non admins' do context 'non admins' do
it "doesn't allow them to perform #clear_all" do it "doesn't allow them to perform #clear_all" do
word = Fabricate(:watched_word, action: WatchedWord.actions[:block]) word = Fabricate(:watched_word, action: WatchedWord.actions[:block])

View File

@ -259,7 +259,7 @@ describe CategoriesController do
end end
end end
context '#create' do describe '#create' do
it "requires the user to be logged in" do it "requires the user to be logged in" do
post "/categories.json" post "/categories.json"
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -351,7 +351,7 @@ describe CategoriesController do
end end
end end
context '#show' do describe '#show' do
before do before do
category.set_permissions(admins: :full) category.set_permissions(admins: :full)
category.save! category.save!
@ -378,7 +378,7 @@ describe CategoriesController do
end end
end end
context '#destroy' do describe '#destroy' do
it "requires the user to be logged in" do it "requires the user to be logged in" do
delete "/categories/category.json" delete "/categories/category.json"
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -407,7 +407,7 @@ describe CategoriesController do
end end
end end
context '#reorder' do describe '#reorder' do
it "reorders the categories" do it "reorders the categories" do
sign_in(admin) sign_in(admin)
@ -444,7 +444,7 @@ describe CategoriesController do
end end
end end
context '#update' do describe '#update' do
before do before do
Jobs.run_immediately! Jobs.run_immediately!
end end
@ -647,7 +647,7 @@ describe CategoriesController do
end end
end end
context '#update_slug' do describe '#update_slug' do
it 'requires the user to be logged in' do it 'requires the user to be logged in' do
put "/category/category/slug.json" put "/category/category/slug.json"
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -695,7 +695,7 @@ describe CategoriesController do
end end
end end
context '#categories_and_topics' do describe '#categories_and_topics' do
before do before do
10.times.each { Fabricate(:topic) } 10.times.each { Fabricate(:topic) }
end end

View File

@ -6,7 +6,7 @@ describe ClicksController do
let(:headers) { { REMOTE_ADDR: "192.168.0.1" } } let(:headers) { { REMOTE_ADDR: "192.168.0.1" } }
let(:post_with_url) { create_post(raw: "this is a post with a link #{url}") } let(:post_with_url) { create_post(raw: "this is a post with a link #{url}") }
context '#track' do describe '#track' do
it "creates a TopicLinkClick" do it "creates a TopicLinkClick" do
sign_in(Fabricate(:user)) sign_in(Fabricate(:user))

View File

@ -4,7 +4,7 @@ describe ComposerMessagesController do
fab!(:topic) { Fabricate(:topic, created_at: 10.years.ago, last_posted_at: 10.years.ago) } fab!(:topic) { Fabricate(:topic, created_at: 10.years.ago, last_posted_at: 10.years.ago) }
fab!(:post) { Fabricate(:post, topic: topic, post_number: 1, created_at: 10.years.ago) } fab!(:post) { Fabricate(:post, topic: topic, post_number: 1, created_at: 10.years.ago) }
context '#index' do describe '#index' do
it 'requires you to be logged in' do it 'requires you to be logged in' do
get "/composer_messages.json" get "/composer_messages.json"
expect(response.status).to eq(403) expect(response.status).to eq(403)

View File

@ -152,7 +152,7 @@ describe EmailController do
end end
end end
context '#unsubscribe' do describe '#unsubscribe' do
it 'displays not found if key is not found' do it 'displays not found if key is not found' do
navigate_to_unsubscribe(SecureRandom.hex) navigate_to_unsubscribe(SecureRandom.hex)

View File

@ -30,7 +30,7 @@ describe EmbedController do
end end
end end
context "#info" do describe "#info" do
context "without api key" do context "without api key" do
it "fails" do it "fails" do
get '/embed/info.json' get '/embed/info.json'
@ -70,7 +70,7 @@ describe EmbedController do
end end
end end
context "#topics" do describe "#topics" do
it "raises an error when not enabled" do it "raises an error when not enabled" do
get '/embed/topics?embed_id=de-1234' get '/embed/topics?embed_id=de-1234'
expect(response.status).to eq(400) expect(response.status).to eq(400)

View File

@ -1323,7 +1323,7 @@ describe GroupsController do
end end
describe "membership edits" do describe "membership edits" do
context '#add_members' do describe '#add_members' do
before do before do
sign_in(admin) sign_in(admin)
end end
@ -1591,7 +1591,7 @@ describe GroupsController do
end end
end end
context '#join' do describe '#join' do
let(:public_group) { Fabricate(:public_group) } let(:public_group) { Fabricate(:public_group) }
it 'should allow a user to join a public group' do it 'should allow a user to join a public group' do
@ -1642,7 +1642,7 @@ describe GroupsController do
end end
end end
context '#remove_member' do describe '#remove_member' do
before do before do
sign_in(admin) sign_in(admin)
end end
@ -1736,7 +1736,7 @@ describe GroupsController do
end end
end end
context '#remove_members' do describe '#remove_members' do
context "is able to remove several members from a group" do context "is able to remove several members from a group" do
fab!(:user1) { Fabricate(:user) } fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user, username: "UsEr2") } fab!(:user2) { Fabricate(:user, username: "UsEr2") }
@ -1790,7 +1790,7 @@ describe GroupsController do
end end
end end
context '#leave' do describe '#leave' do
let(:group_with_public_exit) { Fabricate(:group, public_exit: true, users: [user]) } let(:group_with_public_exit) { Fabricate(:group, public_exit: true, users: [user]) }
it 'should allow a user to leave a group with public exit' do it 'should allow a user to leave a group with public exit' do

View File

@ -4,7 +4,7 @@ describe InvitesController do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user, trust_level: SiteSetting.min_trust_level_to_allow_invite) } fab!(:user) { Fabricate(:user, trust_level: SiteSetting.min_trust_level_to_allow_invite) }
context '#show' do describe '#show' do
fab!(:invite) { Fabricate(:invite) } fab!(:invite) { Fabricate(:invite) }
it 'shows the accept invite page' do it 'shows the accept invite page' do
@ -178,7 +178,7 @@ describe InvitesController do
end end
end end
context '#create' do describe '#create' do
it 'requires to be logged in' do it 'requires to be logged in' do
post '/invites.json', params: { email: 'test@example.com' } post '/invites.json', params: { email: 'test@example.com' }
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -407,7 +407,7 @@ describe InvitesController do
end end
end end
context '#retrieve' do describe '#retrieve' do
it 'requires to be logged in' do it 'requires to be logged in' do
get '/invites/retrieve.json', params: { email: 'test@example.com' } get '/invites/retrieve.json', params: { email: 'test@example.com' }
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -437,7 +437,7 @@ describe InvitesController do
end end
end end
context '#update' do describe '#update' do
fab!(:invite) { Fabricate(:invite, invited_by: admin, email: 'test@example.com') } fab!(:invite) { Fabricate(:invite, invited_by: admin, email: 'test@example.com') }
it 'requires to be logged in' do it 'requires to be logged in' do
@ -519,7 +519,7 @@ describe InvitesController do
end end
end end
context '#destroy' do describe '#destroy' do
it 'requires to be logged in' do it 'requires to be logged in' do
delete '/invites.json', params: { email: 'test@example.com' } delete '/invites.json', params: { email: 'test@example.com' }
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -555,7 +555,7 @@ describe InvitesController do
end end
end end
context '#perform_accept_invitation' do describe '#perform_accept_invitation' do
context 'with an invalid invite' do context 'with an invalid invite' do
it 'redirects to the root' do it 'redirects to the root' do
put '/invites/show/doesntexist.json' put '/invites/show/doesntexist.json'
@ -721,7 +721,7 @@ describe InvitesController do
end end
end end
context '.post_process_invite' do describe '.post_process_invite' do
it 'sends a welcome message if set' do it 'sends a welcome message if set' do
SiteSetting.send_welcome_message = true SiteSetting.send_welcome_message = true
user.send_welcome_message = true user.send_welcome_message = true
@ -971,7 +971,7 @@ describe InvitesController do
end end
end end
context '#destroy_all_expired' do describe '#destroy_all_expired' do
it 'removes all expired invites sent by a user' do it 'removes all expired invites sent by a user' do
SiteSetting.invite_expiry_days = 1 SiteSetting.invite_expiry_days = 1
@ -991,7 +991,7 @@ describe InvitesController do
end end
end end
context '#resend_invite' do describe '#resend_invite' do
it 'requires to be logged in' do it 'requires to be logged in' do
post '/invites/reinvite.json', params: { email: 'first_name@example.com' } post '/invites/reinvite.json', params: { email: 'first_name@example.com' }
expect(response.status).to eq(403) expect(response.status).to eq(403)
@ -1025,7 +1025,7 @@ describe InvitesController do
end end
end end
context '#resend_all_invites' do describe '#resend_all_invites' do
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }
before do before do
@ -1067,7 +1067,7 @@ describe InvitesController do
end end
end end
context '#upload_csv' do describe '#upload_csv' do
it 'requires to be logged in' do it 'requires to be logged in' do
post '/invites/upload_csv.json' post '/invites/upload_csv.json'
expect(response.status).to eq(403) expect(response.status).to eq(403)

View File

@ -47,7 +47,7 @@ describe ReviewablesController do
sign_in(admin) sign_in(admin)
end end
context "#index" do describe "#index" do
it "returns empty JSON when nothing to review" do it "returns empty JSON when nothing to review" do
get "/review.json" get "/review.json"
expect(response.code).to eq("200") expect(response.code).to eq("200")
@ -254,7 +254,7 @@ describe ReviewablesController do
end end
end end
context "#show" do describe "#show" do
context "basics" do context "basics" do
fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable) { Fabricate(:reviewable) }
before do before do
@ -320,7 +320,7 @@ describe ReviewablesController do
end end
end end
context "#explain" do describe "#explain" do
context "basics" do context "basics" do
fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable) { Fabricate(:reviewable) }
@ -344,7 +344,7 @@ describe ReviewablesController do
end end
end end
context "#perform" do describe "#perform" do
fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable) { Fabricate(:reviewable) }
before do before do
sign_in(Fabricate(:moderator)) sign_in(Fabricate(:moderator))
@ -490,7 +490,7 @@ describe ReviewablesController do
end end
end end
context "#topics" do describe "#topics" do
fab!(:post0) { Fabricate(:post) } fab!(:post0) { Fabricate(:post) }
fab!(:post1) { Fabricate(:post, topic: post0.topic) } fab!(:post1) { Fabricate(:post, topic: post0.topic) }
fab!(:post2) { Fabricate(:post) } fab!(:post2) { Fabricate(:post) }
@ -542,7 +542,7 @@ describe ReviewablesController do
end end
end end
context "#settings" do describe "#settings" do
it "renders the settings as JSON" do it "renders the settings as JSON" do
get "/review/settings.json" get "/review/settings.json"
expect(response.code).to eq("200") expect(response.code).to eq("200")
@ -572,7 +572,7 @@ describe ReviewablesController do
end end
end end
context "#update" do describe "#update" do
fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable) { Fabricate(:reviewable) }
fab!(:reviewable_post) { Fabricate(:reviewable_queued_post) } fab!(:reviewable_post) { Fabricate(:reviewable_queued_post) }
fab!(:reviewable_topic) { Fabricate(:reviewable_queued_post_topic) } fab!(:reviewable_topic) { Fabricate(:reviewable_queued_post_topic) }
@ -679,7 +679,7 @@ describe ReviewablesController do
end end
context "#destroy" do describe "#destroy" do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
before do before do
@ -705,7 +705,7 @@ describe ReviewablesController do
end end
end end
context "#count" do describe "#count" do
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
before do before do

View File

@ -205,7 +205,7 @@ describe SearchController do
end end
end end
context "#query" do describe "#query" do
it "logs the search term" do it "logs the search term" do
SiteSetting.log_search_queries = true SiteSetting.log_search_queries = true
get "/search/query.json", params: { term: 'wookie' } get "/search/query.json", params: { term: 'wookie' }
@ -317,7 +317,7 @@ describe SearchController do
end end
end end
context "#show" do describe "#show" do
it "doesn't raise an error when search term not specified" do it "doesn't raise an error when search term not specified" do
get "/search" get "/search"
expect(response.status).to eq(200) expect(response.status).to eq(200)
@ -601,7 +601,7 @@ describe SearchController do
end end
end end
context "#click" do describe "#click" do
after do after do
SearchLog.clear_debounce_cache! SearchLog.clear_debounce_cache!
end end

View File

@ -3,7 +3,7 @@
describe StaticController do describe StaticController do
fab!(:upload) { Fabricate(:upload) } fab!(:upload) { Fabricate(:upload) }
context '#favicon' do describe '#favicon' do
let(:filename) { 'smallest.png' } let(:filename) { 'smallest.png' }
let(:file) { file_from_fixtures(filename) } let(:file) { file_from_fixtures(filename) }
@ -66,7 +66,7 @@ describe StaticController do
end end
end end
context '#brotli_asset' do describe '#brotli_asset' do
it 'returns a non brotli encoded 404 if asset is missing' do it 'returns a non brotli encoded 404 if asset is missing' do
get "/brotli_asset/missing.js" get "/brotli_asset/missing.js"
@ -133,7 +133,7 @@ describe StaticController do
end end
end end
context '#cdn_asset' do describe '#cdn_asset' do
let (:site) { RailsMultisite::ConnectionManagement.current_db } let (:site) { RailsMultisite::ConnectionManagement.current_db }
it 'can serve assets' do it 'can serve assets' do
@ -155,7 +155,7 @@ describe StaticController do
end end
end end
context '#show' do describe '#show' do
before do before do
post = create_post post = create_post
SiteSetting.tos_topic_id = post.topic.id SiteSetting.tos_topic_id = post.topic.id

View File

@ -59,7 +59,7 @@ describe StylesheetsController do
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
context "#color_scheme" do describe "#color_scheme" do
it 'works as expected' do it 'works as expected' do
scheme = ColorScheme.last scheme = ColorScheme.last
get "/color-scheme-stylesheet/#{scheme.id}.json" get "/color-scheme-stylesheet/#{scheme.id}.json"

View File

@ -965,7 +965,7 @@ describe TagsController do
end end
end end
context '#upload_csv' do describe '#upload_csv' do
it 'requires you to be logged in' do it 'requires you to be logged in' do
post "/tags/upload.json" post "/tags/upload.json"
expect(response.status).to eq(403) expect(response.status).to eq(403)

View File

@ -290,7 +290,7 @@ describe UserApiKeysController do
end end
end end
context '#create-one-time-password' do describe '#create-one-time-password' do
let :otp_args do let :otp_args do
{ {
auth_redirect: 'http://somewhere.over.the/rainbow', auth_redirect: 'http://somewhere.over.the/rainbow',

View File

@ -29,7 +29,7 @@ RSpec.describe CurrentUserSerializer do
end end
end end
context "#top_category_ids" do describe "#top_category_ids" do
fab!(:category1) { Fabricate(:category) } fab!(:category1) { Fabricate(:category) }
fab!(:category2) { Fabricate(:category) } fab!(:category2) { Fabricate(:category) }
fab!(:category3) { Fabricate(:category) } fab!(:category3) { Fabricate(:category) }
@ -58,7 +58,7 @@ RSpec.describe CurrentUserSerializer do
end end
end end
context "#muted_tag" do describe "#muted_tag" do
fab!(:tag) { Fabricate(:tag) } fab!(:tag) { Fabricate(:tag) }
let!(:tag_user) do let!(:tag_user) do
@ -75,7 +75,7 @@ RSpec.describe CurrentUserSerializer do
end end
end end
context "#second_factor_enabled" do describe "#second_factor_enabled" do
let(:guardian) { Guardian.new(user) } let(:guardian) { Guardian.new(user) }
let(:json) { serializer.as_json } let(:json) { serializer.as_json }
@ -104,7 +104,7 @@ RSpec.describe CurrentUserSerializer do
end end
end end
context "#groups" do describe "#groups" do
it "should only show visible groups" do it "should only show visible groups" do
Fabricate.build(:group, visibility_level: Group.visibility_levels[:public]) Fabricate.build(:group, visibility_level: Group.visibility_levels[:public])
hidden_group = Fabricate.build(:group, visibility_level: Group.visibility_levels[:owners]) hidden_group = Fabricate.build(:group, visibility_level: Group.visibility_levels[:owners])
@ -121,7 +121,7 @@ RSpec.describe CurrentUserSerializer do
end end
end end
context "#has_topic_draft" do describe "#has_topic_draft" do
it "is not included by default" do it "is not included by default" do
payload = serializer.as_json payload = serializer.as_json
expect(payload).not_to have_key(:has_topic_draft) expect(payload).not_to have_key(:has_topic_draft)
@ -144,7 +144,7 @@ RSpec.describe CurrentUserSerializer do
end end
context "#can_review" do describe "#can_review" do
let(:guardian) { Guardian.new(user) } let(:guardian) { Guardian.new(user) }
let(:payload) { serializer.as_json } let(:payload) { serializer.as_json }

View File

@ -39,7 +39,7 @@ describe UserAuthenticator do
end end
end end
context "#finish" do describe "#finish" do
fab!(:group) { Fabricate(:group, automatic_membership_email_domains: "discourse.org") } fab!(:group) { Fabricate(:group, automatic_membership_email_domains: "discourse.org") }
it "confirms email and adds the user to appropriate groups based on email" do it "confirms email and adds the user to appropriate groups based on email" do