diff --git a/Gemfile.lock b/Gemfile.lock index 533e3487b84..cb8558e7c3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT GIT remote: https://github.com/discourse/rubocop-discourse.git - revision: e44784b759aef45306b0eaee29ddadd8ca5b40a6 + revision: 5afeae107d3c003bf5bcf75457501ee7c1248fd2 specs: rubocop-discourse (2.5.0) rubocop (>= 1.1.0) diff --git a/spec/import_export/category_exporter_spec.rb b/spec/import_export/category_exporter_spec.rb index 91af5c5b4aa..6f943d69376 100644 --- a/spec/import_export/category_exporter_spec.rb +++ b/spec/import_export/category_exporter_spec.rb @@ -14,7 +14,7 @@ describe ImportExport::CategoryExporter do STDOUT.stubs(:write) end - context '.perform' do + describe '.perform' do it 'export the category when it is found' do data = ImportExport::CategoryExporter.new([category.id]).perform.export_data diff --git a/spec/import_export/importer_spec.rb b/spec/import_export/importer_spec.rb index 78c52eccb7a..217c68da570 100644 --- a/spec/import_export/importer_spec.rb +++ b/spec/import_export/importer_spec.rb @@ -17,7 +17,7 @@ describe ImportExport::Importer do ImportExport::Importer.new(data).perform end - context '.perform' do + describe '.perform' do it 'topics and users' do data = import_data.dup diff --git a/spec/import_export/topic_exporter_spec.rb b/spec/import_export/topic_exporter_spec.rb index ba3cf17f386..bf10d59d7f6 100644 --- a/spec/import_export/topic_exporter_spec.rb +++ b/spec/import_export/topic_exporter_spec.rb @@ -12,7 +12,7 @@ describe ImportExport::TopicExporter do fab!(:topic) { Fabricate(:topic, user: user) } fab!(:post) { Fabricate(:post, topic: topic, user: user) } - context '.perform' do + describe '.perform' do it 'export a single topic' do data = ImportExport::TopicExporter.new([topic.id]).perform.export_data diff --git a/spec/jobs/clean_dismissed_topic_users_spec.rb b/spec/jobs/clean_dismissed_topic_users_spec.rb index eb7c03560d1..b74a534043a 100644 --- a/spec/jobs/clean_dismissed_topic_users_spec.rb +++ b/spec/jobs/clean_dismissed_topic_users_spec.rb @@ -5,7 +5,7 @@ describe Jobs::CleanDismissedTopicUsers do fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) } 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 user.user_option.update(new_topic_duration_minutes: User::NewTopicDuration::ALWAYS) expect { described_class.new.execute({}) }.not_to change { DismissedTopicUser.count } @@ -28,7 +28,7 @@ describe Jobs::CleanDismissedTopicUsers do 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!(:topic2) { Fabricate(:topic, created_at: 6.hours.ago) } fab!(:topic3) { Fabricate(:topic, created_at: 2.hours.ago) } diff --git a/spec/jobs/disable_bootstrap_mode_spec.rb b/spec/jobs/disable_bootstrap_mode_spec.rb index 82f9447f72d..1b9e1cfb7df 100644 --- a/spec/jobs/disable_bootstrap_mode_spec.rb +++ b/spec/jobs/disable_bootstrap_mode_spec.rb @@ -2,7 +2,7 @@ describe Jobs::DisableBootstrapMode do - context '.execute' do + describe '.execute' do fab!(:admin) { Fabricate(:admin) } before do diff --git a/spec/jobs/enable_bootstrap_mode_spec.rb b/spec/jobs/enable_bootstrap_mode_spec.rb index ec8145eda92..29a2284862b 100644 --- a/spec/jobs/enable_bootstrap_mode_spec.rb +++ b/spec/jobs/enable_bootstrap_mode_spec.rb @@ -2,7 +2,7 @@ describe Jobs::EnableBootstrapMode do - context '.execute' do + describe '.execute' do fab!(:admin) { Fabricate(:admin) } before do diff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rb index ce51cfe5dd2..9b6fcb8b030 100644 --- a/spec/jobs/export_csv_file_spec.rb +++ b/spec/jobs/export_csv_file_spec.rb @@ -2,7 +2,7 @@ describe Jobs::ExportCsvFile do - context '#execute' do + describe '#execute' do let(:other_user) { Fabricate(:user) } let(:admin) { Fabricate(:admin) } let(:action_log) { StaffActionLogger.new(admin).log_revoke_moderation(other_user) } @@ -51,7 +51,7 @@ describe Jobs::ExportCsvFile do end end - context '.report_export' do + describe '.report_export' do let(:user) { Fabricate(:admin) } diff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rb index 42fb4f2fdec..234d26697d8 100644 --- a/spec/jobs/export_user_archive_spec.rb +++ b/spec/jobs/export_user_archive_spec.rb @@ -36,7 +36,7 @@ describe Jobs::ExportUserArchive do JSON.parse(MultiJson.dump(job.public_send(:"#{component}_export"))) end - context '#execute' do + describe '#execute' do before do _ = post user.user_profile.website = 'https://doe.example.com/john' diff --git a/spec/jobs/invite_email_spec.rb b/spec/jobs/invite_email_spec.rb index c0c2c9587ce..e494f327ee5 100644 --- a/spec/jobs/invite_email_spec.rb +++ b/spec/jobs/invite_email_spec.rb @@ -2,7 +2,7 @@ describe Jobs::InviteEmail do - context '.execute' do + describe '.execute' do it 'raises an error when the invite_id is missing' do expect { Jobs::InviteEmail.new.execute({}) }.to raise_error(Discourse::InvalidParameters) diff --git a/spec/jobs/process_post_spec.rb b/spec/jobs/process_post_spec.rb index 0fb49e684b9..ddcfe663551 100644 --- a/spec/jobs/process_post_spec.rb +++ b/spec/jobs/process_post_spec.rb @@ -89,7 +89,7 @@ describe Jobs::ProcessPost do end end - context "#enqueue_pull_hotlinked_images" do + describe "#enqueue_pull_hotlinked_images" do fab!(:post) { Fabricate(:post, created_at: 20.days.ago) } let(:job) { Jobs::ProcessPost.new } diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb index c44f00f95e0..a9cfeeec453 100644 --- a/spec/jobs/pull_hotlinked_images_spec.rb +++ b/spec/jobs/pull_hotlinked_images_spec.rb @@ -592,7 +592,7 @@ describe Jobs::PullHotlinkedImages do 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) } let(:job) { Jobs::PullHotlinkedImages.new } diff --git a/spec/lib/composer_messages_finder_spec.rb b/spec/lib/composer_messages_finder_spec.rb index 6830d6cc944..735614bf740 100644 --- a/spec/lib/composer_messages_finder_spec.rb +++ b/spec/lib/composer_messages_finder_spec.rb @@ -22,7 +22,7 @@ describe ComposerMessagesFinder do end - context '.check_education_message' do + describe '.check_education_message' do let(:user) { Fabricate.build(:user) } context 'creating topic' do @@ -82,7 +82,7 @@ describe ComposerMessagesFinder do end end - context '.check_new_user_many_replies' do + describe '.check_new_user_many_replies' do let(:user) { Fabricate.build(:user) } context 'replying' do @@ -101,7 +101,7 @@ describe ComposerMessagesFinder do end - context '.check_avatar_notification' do + describe '.check_avatar_notification' do let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') } fab!(:user) { Fabricate(:user) } @@ -148,7 +148,7 @@ describe ComposerMessagesFinder do end end - context '.check_sequential_replies' do + describe '.check_sequential_replies' do fab!(:user) { Fabricate(:user) } fab!(:topic) { Fabricate(:topic) } @@ -223,7 +223,7 @@ describe ComposerMessagesFinder do end - context '.check_dominating_topic' do + describe '.check_dominating_topic' do fab!(:user) { Fabricate(:user) } fab!(:topic) { Fabricate(:topic) } @@ -308,7 +308,7 @@ describe ComposerMessagesFinder do end - context '.check_get_a_room' do + describe '.check_get_a_room' do fab!(:user) { Fabricate(:user) } fab!(:other_user) { Fabricate(:user) } fab!(:third_user) { Fabricate(:user) } @@ -431,7 +431,7 @@ describe ComposerMessagesFinder do end - context '.check_reviving_old_topic' do + describe '.check_reviving_old_topic' do fab!(:user) { Fabricate(:user) } fab!(:topic) { Fabricate(:topic) } diff --git a/spec/lib/cooked_post_processor_spec.rb b/spec/lib/cooked_post_processor_spec.rb index 4215f72eb83..9f327dd9862 100644 --- a/spec/lib/cooked_post_processor_spec.rb +++ b/spec/lib/cooked_post_processor_spec.rb @@ -7,7 +7,7 @@ describe CookedPostProcessor do fab!(:upload) { Fabricate(:upload) } let(:upload_path) { Discourse.store.upload_path } - context "#post_process" do + describe "#post_process" do fab!(:post) do Fabricate(:post, raw: <<~RAW) @@ -837,7 +837,7 @@ describe CookedPostProcessor do end end - context "#extract_images" do + describe "#extract_images" do let(:post) { build(:post_with_plenty_of_images) } let(:cpp) { CookedPostProcessor.new(post) } @@ -848,7 +848,7 @@ describe CookedPostProcessor do end - context "#get_size_from_attributes" do + describe "#get_size_from_attributes" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -882,7 +882,7 @@ describe CookedPostProcessor do end - context "#get_size_from_image_sizes" do + describe "#get_size_from_image_sizes" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -894,7 +894,7 @@ describe CookedPostProcessor do end - context "#get_size" do + describe "#get_size" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -916,7 +916,7 @@ describe CookedPostProcessor do end end - context "#is_valid_image_url?" do + describe "#is_valid_image_url?" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -939,7 +939,7 @@ describe CookedPostProcessor do end - context "#get_filename" do + describe "#get_filename" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -960,7 +960,7 @@ describe CookedPostProcessor do end - context "#convert_to_link" do + describe "#convert_to_link" do fab!(:thumbnail) { Fabricate(:optimized_image, upload: upload, width: 512, height: 384) } before do @@ -1051,7 +1051,7 @@ describe CookedPostProcessor do end end - context "#post_process_oneboxes" do + describe "#post_process_oneboxes" do let(:post) { build(:post_with_youtube, id: 123) } let(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } @@ -1161,7 +1161,7 @@ describe CookedPostProcessor do 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(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } @@ -1179,7 +1179,7 @@ describe CookedPostProcessor do 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(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } @@ -1200,7 +1200,7 @@ describe CookedPostProcessor do 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(:cpp) { CookedPostProcessor.new(post, invalidate_oneboxes: true) } @@ -1225,7 +1225,7 @@ describe CookedPostProcessor do 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 url = 'https://square-image.com/onebox' @@ -1259,7 +1259,7 @@ describe CookedPostProcessor do end - context "#optimize_urls" do + describe "#optimize_urls" do let(:post) { build(:post_with_uploads_and_links) } let(:cpp) { CookedPostProcessor.new(post) } @@ -1515,7 +1515,7 @@ describe CookedPostProcessor do end - context "#remove_user_ids" do + describe "#remove_user_ids" do let(:topic) { Fabricate(:topic) } let(:post) do @@ -1542,7 +1542,7 @@ describe CookedPostProcessor do end end - context "#is_a_hyperlink?" do + describe "#is_a_hyperlink?" do let(:post) { build(:post) } let(:cpp) { CookedPostProcessor.new(post) } @@ -1958,7 +1958,7 @@ describe CookedPostProcessor do end end - context "#html" do + describe "#html" do it "escapes attributes" do post = Fabricate(:post, raw: '<something>') expect(post.cook(post.raw)).to eq('

<something>

') diff --git a/spec/lib/discourse_event_spec.rb b/spec/lib/discourse_event_spec.rb index fbc916a608c..ee7a0c73e9f 100644 --- a/spec/lib/discourse_event_spec.rb +++ b/spec/lib/discourse_event_spec.rb @@ -83,7 +83,7 @@ describe DiscourseEvent do end end - context '#all_off' do + describe '#all_off' do let(:event_handler_2) do Proc.new { |user| user.job = 'Supervillain' } diff --git a/spec/lib/discourse_plugin_registry_spec.rb b/spec/lib/discourse_plugin_registry_spec.rb index f876d5272a4..a212f9bc02e 100644 --- a/spec/lib/discourse_plugin_registry_spec.rb +++ b/spec/lib/discourse_plugin_registry_spec.rb @@ -55,42 +55,42 @@ describe DiscoursePluginRegistry do end end - context '#stylesheets' do + describe '#stylesheets' do it 'defaults to an empty Set' do registry.reset! expect(registry.stylesheets).to eq(Hash.new) end end - context '#mobile_stylesheets' do + describe '#mobile_stylesheets' do it 'defaults to an empty Set' do registry.reset! expect(registry.mobile_stylesheets).to eq(Hash.new) end end - context '#javascripts' do + describe '#javascripts' do it 'defaults to an empty Set' do registry.reset! expect(registry.javascripts).to eq(Set.new) end end - context '#auth_providers' do + describe '#auth_providers' do it 'defaults to an empty Set' do registry.reset! expect(registry.auth_providers).to eq(Set.new) end end - context '#admin_javascripts' do + describe '#admin_javascripts' do it 'defaults to an empty Set' do registry.reset! expect(registry.admin_javascripts).to eq(Set.new) end end - context '#seed_data' do + describe '#seed_data' do it 'defaults to an empty Set' do registry.reset! expect(registry.seed_data).to be_a(Hash) @@ -98,7 +98,7 @@ describe DiscoursePluginRegistry do end end - context '.register_html_builder' do + describe '.register_html_builder' do it "can register and build html" do DiscoursePluginRegistry.register_html_builder(:my_html) { "my html" } expect(DiscoursePluginRegistry.build_html(:my_html)).to eq('my html') @@ -114,7 +114,7 @@ describe DiscoursePluginRegistry do end end - context '.register_css' do + describe '.register_css' do let(:plugin_directory_name) { "hello" } before do @@ -134,7 +134,7 @@ describe DiscoursePluginRegistry do end end - context '.register_js' do + describe '.register_js' do before do registry_instance.register_js('hello.js') end @@ -148,7 +148,7 @@ describe DiscoursePluginRegistry do end end - context '.register_auth_provider' do + describe '.register_auth_provider' do let(:registry) { DiscoursePluginRegistry } let(:auth_provider) do provider = Auth::AuthProvider.new @@ -170,7 +170,7 @@ describe DiscoursePluginRegistry do end - context '.register_service_worker' do + describe '.register_service_worker' do let(:registry) { DiscoursePluginRegistry } before do @@ -189,14 +189,14 @@ describe DiscoursePluginRegistry do end end - context '.register_archetype' do + describe '.register_archetype' do it "delegates archetypes to the Archetype component" do Archetype.expects(:register).with('threaded', hello: 123) registry_instance.register_archetype('threaded', hello: 123) end end - context '#register_asset' do + describe '#register_asset' do let(:registry) { DiscoursePluginRegistry } let(:plugin_directory_name) { "my_plugin" } @@ -247,7 +247,7 @@ describe DiscoursePluginRegistry do end end - context '#register_seed_data' do + describe '#register_seed_data' do let(:registry) { DiscoursePluginRegistry } after do diff --git a/spec/lib/discourse_spec.rb b/spec/lib/discourse_spec.rb index cd3a85e6520..1438789a3eb 100644 --- a/spec/lib/discourse_spec.rb +++ b/spec/lib/discourse_spec.rb @@ -177,7 +177,7 @@ describe Discourse do end end - context '#site_contact_user' do + describe '#site_contact_user' do fab!(:admin) { Fabricate(:admin) } fab!(:another_admin) { Fabricate(:admin) } @@ -194,13 +194,13 @@ describe Discourse do end - context '#system_user' do + describe '#system_user' do it 'returns the system user' do expect(Discourse.system_user.id).to eq(-1) end end - context "#store" do + describe "#store" do it "returns LocalStore by default" do expect(Discourse.store).to be_a(FileStore::LocalStore) @@ -319,7 +319,7 @@ describe Discourse do end end - context "#handle_exception" do + describe "#handle_exception" do class TempSidekiqLogger attr_accessor :exception, :context @@ -363,7 +363,7 @@ describe Discourse do end end - context '#deprecate' do + describe '#deprecate' do def old_method(m) Discourse.deprecate(m) end @@ -472,7 +472,7 @@ describe Discourse do end end - context ".clear_all_theme_cache!" do + describe ".clear_all_theme_cache!" do before do setup_s3 SiteSetting.s3_cdn_url = "https://s3.cdn.com/gg" diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rb index 73b0fb873d0..2a12c0d1a1c 100644 --- a/spec/lib/email/receiver_spec.rb +++ b/spec/lib/email/receiver_spec.rb @@ -1529,7 +1529,7 @@ describe Email::Receiver do end - context "#reply_by_email_address_regex" do + describe "#reply_by_email_address_regex" do before do 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") end - context "#select_body" do + describe "#select_body" do let(:email) { <<~EMAIL diff --git a/spec/lib/inline_oneboxer_spec.rb b/spec/lib/inline_oneboxer_spec.rb index f9c33427236..456d31a3f1d 100644 --- a/spec/lib/inline_oneboxer_spec.rb +++ b/spec/lib/inline_oneboxer_spec.rb @@ -44,7 +44,7 @@ describe InlineOneboxer do end end - context ".lookup" do + describe ".lookup" do let(:category) { Fabricate(:private_category, group: Group[:staff]) } let(:category2) { Fabricate(:private_category, group: Group[:staff]) } diff --git a/spec/lib/oneboxer_spec.rb b/spec/lib/oneboxer_spec.rb index d8f6b8246b3..3bba57e0d23 100644 --- a/spec/lib/oneboxer_spec.rb +++ b/spec/lib/oneboxer_spec.rb @@ -149,7 +149,7 @@ describe Oneboxer do end end - context ".onebox_raw" do + describe ".onebox_raw" do it "should escape the onebox URL before processing" do post = Fabricate(:post, raw: Discourse.base_url + "/new?'class=black") cpp = CookedPostProcessor.new(post, invalidate_oneboxes: true) @@ -158,7 +158,7 @@ describe Oneboxer do end end - context ".external_onebox" do + describe ".external_onebox" do html = <<~HTML diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb index c11fbc4c0c4..f30fb1026ee 100644 --- a/spec/lib/plugin/instance_spec.rb +++ b/spec/lib/plugin/instance_spec.rb @@ -162,7 +162,7 @@ describe Plugin::Instance do end end - context "#add_report" do + describe "#add_report" do it "adds a report" do plugin = Plugin::Instance.new nil, "/tmp/test.rb" plugin.add_report("readers") {} diff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rb index 748cd6a2250..d59823d1cac 100644 --- a/spec/lib/post_creator_spec.rb +++ b/spec/lib/post_creator_spec.rb @@ -1793,7 +1793,7 @@ describe PostCreator do end end - context "#create_post_notice" do + describe "#create_post_notice" do fab!(:user) { Fabricate(:user) } fab!(:staged) { Fabricate(:staged) } fab!(:anonymous) { Fabricate(:anonymous) } diff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rb index 7d0aa2183ed..49f3143ee89 100644 --- a/spec/lib/post_revisor_spec.rb +++ b/spec/lib/post_revisor_spec.rb @@ -758,7 +758,7 @@ describe PostRevisor do expect(post.post_revisions.last.modifications).to eq('tags' => [[], ['new-tag-3']]) end - context "#publish_changes" do + describe "#publish_changes" do let!(:post) { Fabricate(:post, topic: topic) } it "should publish topic changes to clients" do diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb index b7ece4605a4..6135fb32c03 100644 --- a/spec/lib/search_spec.rb +++ b/spec/lib/search_spec.rb @@ -9,7 +9,7 @@ describe Search do Jobs.run_immediately! end - context "#ts_config" do + describe "#ts_config" do it "maps locales to correct Postgres dictionaries" do expect(Search.ts_config).to eq("english") expect(Search.ts_config("en")).to eq("english") @@ -20,7 +20,7 @@ describe Search do end end - context "#GroupedSearchResults.blurb_for" do + describe "#GroupedSearchResults.blurb_for" do it "strips audio and video URLs from search blurb" do cooked = <<~RAW link to an external page: https://google.com/?u=bar @@ -55,7 +55,7 @@ describe Search do end end - context "#execute" do + describe "#execute" do before do SiteSetting.tagging_enabled = true end @@ -2030,7 +2030,7 @@ describe Search do end end - context '#ts_query' do + describe '#ts_query' do it 'can parse complex strings using ts_query helper' do str = +" grigio:babel deprecated? " 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 - context '#word_to_date' do + describe '#word_to_date' do it 'parses relative dates correctly' do time = Time.zone.parse('2001-02-20 2:55') freeze_time(time) @@ -2080,7 +2080,7 @@ describe Search do end end - context "#min_post_id" do + describe "#min_post_id" do it "returns 0 when prefer_recent_posts is disabled" do SiteSetting.search_prefer_recent_posts = false expect(Search.min_post_id_no_cache).to eq(0) diff --git a/spec/lib/stylesheet/importer_spec.rb b/spec/lib/stylesheet/importer_spec.rb index 27b9727f328..09c6e6701f8 100644 --- a/spec/lib/stylesheet/importer_spec.rb +++ b/spec/lib/stylesheet/importer_spec.rb @@ -8,7 +8,7 @@ describe Stylesheet::Importer do Stylesheet::Compiler.compile_asset(name)[0] end - context "#category_backgrounds" do + describe "#category_backgrounds" do it "applies CDN to background category images" do expect(compile_css("color_definitions")).to_not include("body.category-") @@ -37,7 +37,7 @@ describe Stylesheet::Importer do end - context "#font" do + describe "#font" do it "includes font variable" do default_font = ":root{--font-family: Arial, sans-serif}" expect(compile_css("color_definitions")).to include(default_font) @@ -76,7 +76,7 @@ describe Stylesheet::Importer do end end - context "#import_color_definitions" do + describe "#import_color_definitions" do let(:scss) { ":root{--custom-color: green}" } let(:scss_child) { "$navy: #000080; :root{--custom-color: red; --custom-color-rgb: \#{hexToRGB($navy)}}" } @@ -115,7 +115,7 @@ describe Stylesheet::Importer do end end - context "#import_wcag_overrides" do + describe "#import_wcag_overrides" do it "should do nothing on a regular scheme" do scheme = ColorScheme.create_from_base(name: 'Regular') expect(Stylesheet::Importer.new({ color_scheme_id: scheme.id }).import_wcag_overrides).to eq("") diff --git a/spec/lib/system_message_spec.rb b/spec/lib/system_message_spec.rb index 0c1b73a1a23..9427773e875 100644 --- a/spec/lib/system_message_spec.rb +++ b/spec/lib/system_message_spec.rb @@ -5,7 +5,7 @@ require 'topic_subtype' describe SystemMessage do - context '#create' do + describe '#create' do fab!(:admin) { Fabricate(:admin) } fab!(:user) { Fabricate(:user) } diff --git a/spec/lib/theme_store/git_importer_spec.rb b/spec/lib/theme_store/git_importer_spec.rb index 78f6ce0e4db..0216edcd5b4 100644 --- a/spec/lib/theme_store/git_importer_spec.rb +++ b/spec/lib/theme_store/git_importer_spec.rb @@ -6,7 +6,7 @@ require 'theme_store/git_importer' describe ThemeStore::GitImporter do - context "#import" do + describe "#import" do let(:url) { "https://github.com/example/example.git" } let(:trailing_slash_url) { "https://github.com/example/example/" } diff --git a/spec/lib/topic_query_spec.rb b/spec/lib/topic_query_spec.rb index e1c93d0972d..d585ff3c15f 100644 --- a/spec/lib/topic_query_spec.rb +++ b/spec/lib/topic_query_spec.rb @@ -65,7 +65,7 @@ describe TopicQuery do end end - context "#list_topics_by" do + describe "#list_topics_by" do it "allows users to view their own invisible topics" do _topic = Fabricate(:topic, user: user) @@ -77,7 +77,7 @@ describe TopicQuery do end - context "#prioritize_pinned_topics" do + describe "#prioritize_pinned_topics" do it "does the pagination correctly" do num_topics = 15 per_page = 3 @@ -503,7 +503,7 @@ describe TopicQuery do end end - context "#list_top_for" do + describe "#list_top_for" do it "lists top for the week" do Fabricate(:topic, like_count: 1000, posts_count: 100) TopTopic.refresh! @@ -892,7 +892,7 @@ describe TopicQuery do end - context '#list_new' do + describe '#list_new' do context 'without a new topic' do it "has no new topics" do @@ -969,7 +969,7 @@ describe TopicQuery do end - context '#list_posted' do + describe '#list_posted' do let(:topics) { topic_query.list_posted.topics } it "returns blank when there are no posted topics" do @@ -1023,7 +1023,7 @@ describe TopicQuery do end end - context '#list_unseen' do + describe '#list_unseen' do it "returns an empty list when there aren't topics" do expect(topic_query.list_unseen.topics).to be_blank end @@ -1074,7 +1074,7 @@ describe TopicQuery do end end - context '#list_related_for' do + describe '#list_related_for' do let(:user) do Fabricate(:admin) diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rb index e30746fb36e..6f0d94d71e6 100644 --- a/spec/lib/topic_view_spec.rb +++ b/spec/lib/topic_view_spec.rb @@ -341,7 +341,7 @@ RSpec.describe TopicView do end end - context '.post_counts_by_user' do + describe '.post_counts_by_user' do it 'returns the two posters with their appropriate counts' do SiteSetting.enable_whispers = true Fabricate(:post, topic: topic, user: evil_trout, post_type: Post.types[:whisper]) @@ -361,13 +361,13 @@ RSpec.describe TopicView do end end - context '.participants' do + describe '.participants' 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]]) end end - context '.all_post_actions' do + describe '.all_post_actions' do it 'is blank at first' do expect(topic_view.all_post_actions).to be_blank end @@ -378,7 +378,7 @@ RSpec.describe TopicView do end end - context '.read?' do + describe '.read?' do it 'tracks correctly' do # anon is assumed to have read everything expect(TopicView.new(topic.id).read?(1)).to eq(true) @@ -395,7 +395,7 @@ RSpec.describe TopicView do end end - context "#bookmarks" do + describe "#bookmarks" do let!(:user) { Fabricate(:user) } let!(:bookmark1) { 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 - context "#bookmarks" do + describe "#bookmarks" do let!(:user) { Fabricate(: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) } @@ -452,13 +452,13 @@ RSpec.describe TopicView do end end - context '.topic_user' do + describe '.topic_user' do it 'returns nil when there is no user' do expect(TopicView.new(topic.id, nil).topic_user).to be_blank end end - context '#recent_posts' do + describe '#recent_posts' do before do 24.times do |t| # our let()s have already created 3 Fabricate(:post, topic: topic, user: first_poster, created_at: t.seconds.from_now) @@ -497,7 +497,7 @@ RSpec.describe TopicView do end end - context '#posts' do + describe '#posts' do # Create the posts in a different order than the sort_order let!(:p5) { Fabricate(:post, topic: topic, user: evil_trout) } diff --git a/spec/lib/twitter_api_spec.rb b/spec/lib/twitter_api_spec.rb index 96f129ed614..a123676dba9 100644 --- a/spec/lib/twitter_api_spec.rb +++ b/spec/lib/twitter_api_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe TwitterApi do - context '.link_handles_in' do + describe '.link_handles_in' do it 'correctly replaces handles' do expect(TwitterApi.send(:link_handles_in, "@foo @foobar")).to match_html <<~HTML @foo @foobar @@ -9,7 +9,7 @@ describe TwitterApi do end end - context '.link_hashtags_in' do + describe '.link_hashtags_in' do it 'correctly replaces hashtags' do expect(TwitterApi.send(:link_hashtags_in, "#foo #foobar")).to match_html <<~HTML #foo #foobar diff --git a/spec/lib/validators/post_validator_spec.rb b/spec/lib/validators/post_validator_spec.rb index be547dffa44..d97fcbcc85a 100644 --- a/spec/lib/validators/post_validator_spec.rb +++ b/spec/lib/validators/post_validator_spec.rb @@ -5,7 +5,7 @@ describe PostValidator do let(:post) { build(:post, topic: topic) } 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 post.raw = "" validator.post_body_validator(post) diff --git a/spec/models/badge_spec.rb b/spec/models/badge_spec.rb index c97ce3c6e02..081d0f37197 100644 --- a/spec/models/badge_spec.rb +++ b/spec/models/badge_spec.rb @@ -221,7 +221,7 @@ describe Badge do end end - context "#seed" do + describe "#seed" do let(:regular_badge) do Badge.find(Badge::Regular) diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 1eb38821284..4a0f4773067 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1089,13 +1089,13 @@ describe Category do SQL end - context "#depth_of_descendants" do + describe "#depth_of_descendants" do it "should produce max_depth" do expect(category.depth_of_descendants(3)).to eq(3) end end - context "#height_of_ancestors" do + describe "#height_of_ancestors" do it "should produce max_height" do expect(category.height_of_ancestors(3)).to eq(3) end @@ -1107,13 +1107,13 @@ describe Category do category.parent_category_id = category.id end - context "#depth_of_descendants" do + describe "#depth_of_descendants" do it "should produce max_depth" do expect(category.depth_of_descendants(3)).to eq(3) end end - context "#height_of_ancestors" do + describe "#height_of_ancestors" do it "should produce max_height" do expect(category.height_of_ancestors(3)).to eq(3) end @@ -1125,20 +1125,20 @@ describe Category do category.parent_category_id = subcategory.id end - context "#depth_of_descendants" do + describe "#depth_of_descendants" do it "should produce max_depth" do expect(category.depth_of_descendants(3)).to eq(3) end end - context "#height_of_ancestors" do + describe "#height_of_ancestors" do it "should produce max_height" do expect(category.height_of_ancestors(3)).to eq(3) end end end - context "#depth_of_descendants" do + describe "#depth_of_descendants" do it "should be 0 when the category has no descendants" do expect(subcategory.depth_of_descendants).to eq(0) end @@ -1148,7 +1148,7 @@ describe Category do end end - context "#height_of_ancestors" do + describe "#height_of_ancestors" do it "should be 0 when the category has no ancestors" do expect(category.height_of_ancestors).to eq(0) end diff --git a/spec/models/category_user_spec.rb b/spec/models/category_user_spec.rb index 815f094d6c1..2a8b990c71c 100644 --- a/spec/models/category_user_spec.rb +++ b/spec/models/category_user_spec.rb @@ -12,7 +12,7 @@ describe CategoryUser do CategoryUser.notification_levels[:regular] end - context '#batch_set' do + describe '#batch_set' do fab!(:category) { Fabricate(:category) } def category_ids_at_level(level) diff --git a/spec/models/email_token_spec.rb b/spec/models/email_token_spec.rb index 39e64ac0c74..c086b0848fe 100644 --- a/spec/models/email_token_spec.rb +++ b/spec/models/email_token_spec.rb @@ -5,7 +5,7 @@ describe EmailToken do it { is_expected.to validate_presence_of :email } it { is_expected.to belong_to :user } - context '#create' do + describe '#create' do fab!(:user) { Fabricate(:user, active: false) } let!(:original_token) { user.email_tokens.first } let!(:email_token) { Fabricate(:email_token, user: user, email: 'bubblegum@adventuretime.ooo') } @@ -41,7 +41,7 @@ describe EmailToken do end end - context '#confirm' do + describe '#confirm' do fab!(:user) { Fabricate(:user, active: false) } let!(:email_token) { Fabricate(:email_token, user: user) } diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index 2f9dff38047..1deff1e81d2 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -65,7 +65,7 @@ describe Invite do end end - context '.generate' do + describe '.generate' do it 'saves an invites' do invite = Invite.generate(user, email: 'TEST@EXAMPLE.COM') expect(invite.invite_key).to be_present @@ -201,7 +201,7 @@ describe Invite do end end - context '#redeem' do + describe '#redeem' do fab!(:invite) { Fabricate(:invite) } it 'works' do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index e3ec7e75636..cf14dc1dd37 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -1491,7 +1491,7 @@ describe Post do expect(UploadReference.count).to eq(0) end - context "#link_post_uploads" do + describe "#link_post_uploads" do it "finds all the uploads in the post" do post.link_post_uploads @@ -1547,7 +1547,7 @@ describe Post do end end - context '#update_uploads_secure_status' do + describe '#update_uploads_secure_status' do fab!(:user) { Fabricate(:user, trust_level: 0) } let(:raw) do diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rb index 1080f181f3f..5ceacba0107 100644 --- a/spec/models/remote_theme_spec.rb +++ b/spec/models/remote_theme_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true 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") <<~JSON { @@ -201,7 +201,7 @@ describe RemoteTheme do ) end - context "#github_diff_link" do + describe "#github_diff_link" do it "is blank for non-github repos" do expect(gitlab_repo.github_diff_link).to be_blank end @@ -218,7 +218,7 @@ describe RemoteTheme do end end - context ".joined_remotes" do + describe ".joined_remotes" do it "finds records that are associated with themes" do github_repo gitlab_repo @@ -232,7 +232,7 @@ describe RemoteTheme do 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!(:theme) { Fabricate(:theme, remote_theme: remote) } @@ -252,7 +252,7 @@ describe RemoteTheme do 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!(:theme) { Fabricate(:theme, remote_theme: remote) } diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb index 36099af81f9..92fdbbdf9c3 100644 --- a/spec/models/reviewable_spec.rb +++ b/spec/models/reviewable_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Reviewable, type: :model do - context ".create" do + describe ".create" do fab!(:admin) { Fabricate(:admin) } fab!(:user) { Fabricate(:user) } @@ -31,7 +31,7 @@ RSpec.describe Reviewable, type: :model do end end - context ".needs_review!" do + describe ".needs_review!" do fab!(:admin) { Fabricate(:admin) } fab!(:user) { Fabricate(:user) } @@ -86,7 +86,7 @@ RSpec.describe Reviewable, type: :model do end end - context ".list_for" do + describe ".list_for" do fab!(:user) { Fabricate(:user) } it "returns an empty list for nil user" do @@ -381,7 +381,7 @@ RSpec.describe Reviewable, type: :model do 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 Reviewable.set_priorities(low: 40.0, high: 100.0) @@ -411,7 +411,7 @@ RSpec.describe Reviewable, type: :model do 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 SiteSetting.silence_new_user_sensitivity = Reviewable.sensitivity[:low] expect(Reviewable.spam_score_to_silence_new_user).to eq(7.5) @@ -434,7 +434,7 @@ RSpec.describe Reviewable, type: :model do 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 SiteSetting.auto_close_topic_sensitivity = Reviewable.sensitivity[:low] diff --git a/spec/models/reviewable_user_spec.rb b/spec/models/reviewable_user_spec.rb index 8debc148bad..ffd345db217 100644 --- a/spec/models/reviewable_user_spec.rb +++ b/spec/models/reviewable_user_spec.rb @@ -55,7 +55,7 @@ RSpec.describe ReviewableUser, type: :model do end end - context "#update_fields" do + describe "#update_fields" do fab!(:moderator) { Fabricate(:moderator) } fab!(:reviewable) { Fabricate(:reviewable) } diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb index 8590d31ac68..bf7d82aacdc 100644 --- a/spec/models/topic_embed_spec.rb +++ b/spec/models/topic_embed_spec.rb @@ -8,7 +8,7 @@ describe TopicEmbed do it { is_expected.to belong_to :post } it { is_expected.to validate_presence_of :embed_url } - context '.import' do + describe '.import' do fab!(:user) { Fabricate(:user) } let(:title) { "How to turn a fish from good to evil in 30 seconds" } @@ -173,7 +173,7 @@ describe TopicEmbed do end end - context '.topic_id_for_embed' do + describe '.topic_id_for_embed' do it "returns correct topic id irrespective of url protocol" do topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248") @@ -195,7 +195,7 @@ describe TopicEmbed do describe '.find_remote' do fab!(:embeddable_host) { Fabricate(:embeddable_host) } - context ".title_scrub" do + describe ".title_scrub" do let(:url) { 'http://eviltrout.com/123' } let(:contents) { "Through the Looking Glass - Classic Bookssome content here" } diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 5594c81e422..b5084857d59 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -17,7 +17,7 @@ describe Topic do context 'validations' do let(:topic) { Fabricate.build(:topic) } - context "#featured_link" do + describe "#featured_link" do describe 'when featured_link contains more than a URL' do it 'should not be valid' do topic.featured_link = 'http://meta.discourse.org TEST' @@ -33,7 +33,7 @@ describe Topic do end end - context "#external_id" do + describe "#external_id" do describe 'when external_id is too long' do it 'should not be valid' do topic.external_id = 'a' * (Topic::EXTERNAL_ID_MAX_LENGTH + 1) @@ -78,7 +78,7 @@ describe Topic do end end - context "#title" do + describe "#title" do it { is_expected.to validate_presence_of :title } describe 'censored words' do @@ -165,7 +165,7 @@ describe Topic do it { is_expected.to rate_limit } - context '#visible_post_types' do + describe '#visible_post_types' do let(:types) { Post.types } before do @@ -260,7 +260,7 @@ describe Topic do end end - context '#ascii_generator' do + describe '#ascii_generator' do before { SiteSetting.slug_generation_method = 'ascii' } context 'with ascii letters' do @@ -613,7 +613,7 @@ describe Topic do end end - context '.similar_to' do + describe '.similar_to' do fab!(:category) { Fabricate(:category_with_definition) } it 'returns an empty array with nil params' do diff --git a/spec/models/topic_tag_spec.rb b/spec/models/topic_tag_spec.rb index 9e18aa547f5..49d23b0befc 100644 --- a/spec/models/topic_tag_spec.rb +++ b/spec/models/topic_tag_spec.rb @@ -6,7 +6,7 @@ describe TopicTag do fab!(:tag) { Fabricate(: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 expect { @@ -24,7 +24,7 @@ describe TopicTag do end - context '#after_destroy' do + describe '#after_destroy' do it "tag topic_count should be decreased" do topic_tag diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index b360524063e..18e054dab6f 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -43,7 +43,7 @@ describe Upload do end end - context ".create_thumbnail!" do + describe ".create_thumbnail!" do it "does not create a thumbnail when disabled" do SiteSetting.create_thumbnails = false OptimizedImage.expects(:create_for).never @@ -118,7 +118,7 @@ describe Upload do expect(created_upload.valid?).to eq(false) end - context ".extract_url" do + describe ".extract_url" do let(:url) { 'https://example.com/uploads/default/original/1X/d1c2d40ab994e8410c.png' } it 'should return the right part of url' do @@ -126,7 +126,7 @@ describe Upload do end end - context ".get_from_url" do + describe ".get_from_url" do let(:sha1) { "10f73034616a796dfd70177dc54b6def44c4ba6f" } let(:upload) { Fabricate(:upload, sha1: sha1) } @@ -258,7 +258,7 @@ describe Upload do end end - context ".get_from_urls" do + describe ".get_from_urls" do let(:upload) { Fabricate(:upload, sha1: "10f73034616a796dfd70177dc54b6def44c4ba6f") } let(:upload2) { Fabricate(:upload, sha1: "2a7081e615f9075befd87a9a6d273935c0262cd5") } @@ -549,7 +549,7 @@ describe Upload do stub_upload(upload) end - context '.destroy' do + describe '.destroy' do it "can correctly clear information when destroying an upload" do upload = Fabricate(:upload) user = Fabricate(:user) @@ -568,7 +568,7 @@ describe Upload do end end - context ".signed_url_from_secure_media_url" do + describe ".signed_url_from_secure_media_url" do before do # must be done so signed_url_for_path exists enable_secure_media @@ -589,7 +589,7 @@ describe Upload do end end - context ".secure_media_url_from_upload_url" do + describe ".secure_media_url_from_upload_url" do before do # must be done so signed_url_for_path exists enable_secure_media @@ -603,7 +603,7 @@ describe Upload do 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 url = "//localhost:3000/secure-media-uploads/original/2X/f/f62055931bb702c7fd8f552fb901f977e0289a18.png" expect(Upload.secure_media_url?(url)).to eq(true) diff --git a/spec/models/user_api_key_spec.rb b/spec/models/user_api_key_spec.rb index 7a9964522f3..395f0bf348f 100644 --- a/spec/models/user_api_key_spec.rb +++ b/spec/models/user_api_key_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe UserApiKey do - context "#allow?" do + describe "#allow?" do def request_env(method, path, **path_parameters) ActionDispatch::TestRequest.create.tap do |request| request.request_method = method diff --git a/spec/models/user_avatar_spec.rb b/spec/models/user_avatar_spec.rb index 7fd999f2f18..d66317d50bb 100644 --- a/spec/models/user_avatar_spec.rb +++ b/spec/models/user_avatar_spec.rb @@ -120,7 +120,7 @@ describe UserAvatar do end end - context '.import_url_for_user' do + describe '.import_url_for_user' do it 'creates user_avatar record if missing' do user = Fabricate(:user) diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb index c82ab5a7fb1..01bd4677115 100644 --- a/spec/models/user_profile_spec.rb +++ b/spec/models/user_profile_spec.rb @@ -261,7 +261,7 @@ RSpec.describe UserProfile do end end - context '.import_url_for_user' do + describe '.import_url_for_user' do fab!(:user) { Fabricate(:user) } before do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 96e232450ae..0e7381c6834 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -289,7 +289,7 @@ RSpec.describe User do end end - context '.enqueue_welcome_message' do + describe '.enqueue_welcome_message' do fab!(:user) { Fabricate(:user) } it 'enqueues the system message' do @@ -333,7 +333,7 @@ RSpec.describe User do end end - context '.set_default_tags_preferences' do + describe '.set_default_tags_preferences' do let(:tag) { Fabricate(:tag) } it "should set default tag preferences when new user created" do @@ -2450,7 +2450,7 @@ RSpec.describe User do end end - context "#destroy!" do + describe "#destroy!" do it 'clears up associated data on destroy!' do user = Fabricate(:user) post = Fabricate(:post) diff --git a/spec/models/user_stat_spec.rb b/spec/models/user_stat_spec.rb index 4b810b36418..a376ff451d5 100644 --- a/spec/models/user_stat_spec.rb +++ b/spec/models/user_stat_spec.rb @@ -10,7 +10,7 @@ describe UserStat do expect(user.user_stat.new_since).to be_present end - context '#update_view_counts' do + describe '#update_view_counts' do let(:user) { Fabricate(:user) } let(:stat) { user.user_stat } diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb index 1352aa911b8..f4dc8ab1ae2 100644 --- a/spec/requests/about_controller_spec.rb +++ b/spec/requests/about_controller_spec.rb @@ -2,7 +2,7 @@ describe AboutController do - context '.index' do + describe '.index' do it "should display the about page for anonymous user when login_required is false" do SiteSetting.login_required = false diff --git a/spec/requests/admin/email_templates_controller_spec.rb b/spec/requests/admin/email_templates_controller_spec.rb index bd99a653b6f..f6110e61428 100644 --- a/spec/requests/admin/email_templates_controller_spec.rb +++ b/spec/requests/admin/email_templates_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Admin::EmailTemplatesController do I18n.reload! end - context "#index" do + describe "#index" do it "raises an error if you aren't logged in" do get '/admin/customize/email_templates.json' expect(response.status).to eq(404) @@ -63,7 +63,7 @@ RSpec.describe Admin::EmailTemplatesController do end end - context "#update" do + describe "#update" do it "raises an error if you aren't logged in" do put '/admin/customize/email_templates/some_id', params: { email_template: { subject: 'Subject', body: 'Body' } @@ -256,7 +256,7 @@ RSpec.describe Admin::EmailTemplatesController do end - context "#revert" do + describe "#revert" do it "raises an error if you aren't logged in" do delete '/admin/customize/email_templates/some_id', headers: headers expect(response.status).to eq(404) diff --git a/spec/requests/admin/groups_controller_spec.rb b/spec/requests/admin/groups_controller_spec.rb index fbfa72eb553..653eda77099 100644 --- a/spec/requests/admin/groups_controller_spec.rb +++ b/spec/requests/admin/groups_controller_spec.rb @@ -260,7 +260,7 @@ RSpec.describe Admin::GroupsController do end end - context "#destroy" do + describe "#destroy" do it 'should return the right response for an invalid group_id' do max_id = Group.maximum(:id).to_i delete "/admin/groups/#{max_id + 1}.json" diff --git a/spec/requests/admin/search_logs_spec.rb b/spec/requests/admin/search_logs_spec.rb index f67f6263a28..6f7c08d0c29 100644 --- a/spec/requests/admin/search_logs_spec.rb +++ b/spec/requests/admin/search_logs_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Admin::SearchLogsController do SearchLog.clear_debounce_cache! end - context "#index" do + describe "#index" do it "raises an error if you aren't logged in" do get '/admin/logs/search_logs.json' expect(response.status).to eq(404) @@ -37,7 +37,7 @@ RSpec.describe Admin::SearchLogsController do end end - context "#term" do + describe "#term" do it "raises an error if you aren't logged in" do get '/admin/logs/search_logs/term.json', params: { term: "ruby" diff --git a/spec/requests/admin/watched_words_controller_spec.rb b/spec/requests/admin/watched_words_controller_spec.rb index 09930880234..6def887c57a 100644 --- a/spec/requests/admin/watched_words_controller_spec.rb +++ b/spec/requests/admin/watched_words_controller_spec.rb @@ -116,7 +116,7 @@ RSpec.describe Admin::WatchedWordsController do end end - context '#clear_all' do + describe '#clear_all' do context 'non admins' do it "doesn't allow them to perform #clear_all" do word = Fabricate(:watched_word, action: WatchedWord.actions[:block]) diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb index 0c121739154..220ecbd6315 100644 --- a/spec/requests/categories_controller_spec.rb +++ b/spec/requests/categories_controller_spec.rb @@ -259,7 +259,7 @@ describe CategoriesController do end end - context '#create' do + describe '#create' do it "requires the user to be logged in" do post "/categories.json" expect(response.status).to eq(403) @@ -351,7 +351,7 @@ describe CategoriesController do end end - context '#show' do + describe '#show' do before do category.set_permissions(admins: :full) category.save! @@ -378,7 +378,7 @@ describe CategoriesController do end end - context '#destroy' do + describe '#destroy' do it "requires the user to be logged in" do delete "/categories/category.json" expect(response.status).to eq(403) @@ -407,7 +407,7 @@ describe CategoriesController do end end - context '#reorder' do + describe '#reorder' do it "reorders the categories" do sign_in(admin) @@ -444,7 +444,7 @@ describe CategoriesController do end end - context '#update' do + describe '#update' do before do Jobs.run_immediately! end @@ -647,7 +647,7 @@ describe CategoriesController do end end - context '#update_slug' do + describe '#update_slug' do it 'requires the user to be logged in' do put "/category/category/slug.json" expect(response.status).to eq(403) @@ -695,7 +695,7 @@ describe CategoriesController do end end - context '#categories_and_topics' do + describe '#categories_and_topics' do before do 10.times.each { Fabricate(:topic) } end diff --git a/spec/requests/clicks_controller_spec.rb b/spec/requests/clicks_controller_spec.rb index 146fb3bc072..aad034164db 100644 --- a/spec/requests/clicks_controller_spec.rb +++ b/spec/requests/clicks_controller_spec.rb @@ -6,7 +6,7 @@ describe ClicksController do let(:headers) { { REMOTE_ADDR: "192.168.0.1" } } 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 sign_in(Fabricate(:user)) diff --git a/spec/requests/composer_messages_controller_spec.rb b/spec/requests/composer_messages_controller_spec.rb index d763d7f97a1..330a31e2d66 100644 --- a/spec/requests/composer_messages_controller_spec.rb +++ b/spec/requests/composer_messages_controller_spec.rb @@ -4,7 +4,7 @@ describe ComposerMessagesController do 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) } - context '#index' do + describe '#index' do it 'requires you to be logged in' do get "/composer_messages.json" expect(response.status).to eq(403) diff --git a/spec/requests/email_controller_spec.rb b/spec/requests/email_controller_spec.rb index ba3268c4c23..015d5cd4d6a 100644 --- a/spec/requests/email_controller_spec.rb +++ b/spec/requests/email_controller_spec.rb @@ -152,7 +152,7 @@ describe EmailController do end end - context '#unsubscribe' do + describe '#unsubscribe' do it 'displays not found if key is not found' do navigate_to_unsubscribe(SecureRandom.hex) diff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rb index 637124071d4..6950c1c81a2 100644 --- a/spec/requests/embed_controller_spec.rb +++ b/spec/requests/embed_controller_spec.rb @@ -30,7 +30,7 @@ describe EmbedController do end end - context "#info" do + describe "#info" do context "without api key" do it "fails" do get '/embed/info.json' @@ -70,7 +70,7 @@ describe EmbedController do end end - context "#topics" do + describe "#topics" do it "raises an error when not enabled" do get '/embed/topics?embed_id=de-1234' expect(response.status).to eq(400) diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index 05d87ec5787..0a74c572571 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -1323,7 +1323,7 @@ describe GroupsController do end describe "membership edits" do - context '#add_members' do + describe '#add_members' do before do sign_in(admin) end @@ -1591,7 +1591,7 @@ describe GroupsController do end end - context '#join' do + describe '#join' do let(:public_group) { Fabricate(:public_group) } it 'should allow a user to join a public group' do @@ -1642,7 +1642,7 @@ describe GroupsController do end end - context '#remove_member' do + describe '#remove_member' do before do sign_in(admin) end @@ -1736,7 +1736,7 @@ describe GroupsController do end end - context '#remove_members' do + describe '#remove_members' do context "is able to remove several members from a group" do fab!(:user1) { Fabricate(:user) } fab!(:user2) { Fabricate(:user, username: "UsEr2") } @@ -1790,7 +1790,7 @@ describe GroupsController do end end - context '#leave' do + describe '#leave' do 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 diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb index da602dc3977..3bde1f0e7a8 100644 --- a/spec/requests/invites_controller_spec.rb +++ b/spec/requests/invites_controller_spec.rb @@ -4,7 +4,7 @@ describe InvitesController do fab!(:admin) { Fabricate(:admin) } fab!(:user) { Fabricate(:user, trust_level: SiteSetting.min_trust_level_to_allow_invite) } - context '#show' do + describe '#show' do fab!(:invite) { Fabricate(:invite) } it 'shows the accept invite page' do @@ -178,7 +178,7 @@ describe InvitesController do end end - context '#create' do + describe '#create' do it 'requires to be logged in' do post '/invites.json', params: { email: 'test@example.com' } expect(response.status).to eq(403) @@ -407,7 +407,7 @@ describe InvitesController do end end - context '#retrieve' do + describe '#retrieve' do it 'requires to be logged in' do get '/invites/retrieve.json', params: { email: 'test@example.com' } expect(response.status).to eq(403) @@ -437,7 +437,7 @@ describe InvitesController do end end - context '#update' do + describe '#update' do fab!(:invite) { Fabricate(:invite, invited_by: admin, email: 'test@example.com') } it 'requires to be logged in' do @@ -519,7 +519,7 @@ describe InvitesController do end end - context '#destroy' do + describe '#destroy' do it 'requires to be logged in' do delete '/invites.json', params: { email: 'test@example.com' } expect(response.status).to eq(403) @@ -555,7 +555,7 @@ describe InvitesController do end end - context '#perform_accept_invitation' do + describe '#perform_accept_invitation' do context 'with an invalid invite' do it 'redirects to the root' do put '/invites/show/doesntexist.json' @@ -721,7 +721,7 @@ describe InvitesController do end end - context '.post_process_invite' do + describe '.post_process_invite' do it 'sends a welcome message if set' do SiteSetting.send_welcome_message = true user.send_welcome_message = true @@ -971,7 +971,7 @@ describe InvitesController do end end - context '#destroy_all_expired' do + describe '#destroy_all_expired' do it 'removes all expired invites sent by a user' do SiteSetting.invite_expiry_days = 1 @@ -991,7 +991,7 @@ describe InvitesController do end end - context '#resend_invite' do + describe '#resend_invite' do it 'requires to be logged in' do post '/invites/reinvite.json', params: { email: 'first_name@example.com' } expect(response.status).to eq(403) @@ -1025,7 +1025,7 @@ describe InvitesController do end end - context '#resend_all_invites' do + describe '#resend_all_invites' do let(:admin) { Fabricate(:admin) } before do @@ -1067,7 +1067,7 @@ describe InvitesController do end end - context '#upload_csv' do + describe '#upload_csv' do it 'requires to be logged in' do post '/invites/upload_csv.json' expect(response.status).to eq(403) diff --git a/spec/requests/reviewables_controller_spec.rb b/spec/requests/reviewables_controller_spec.rb index 20804a5bbae..bb4c25ab53d 100644 --- a/spec/requests/reviewables_controller_spec.rb +++ b/spec/requests/reviewables_controller_spec.rb @@ -47,7 +47,7 @@ describe ReviewablesController do sign_in(admin) end - context "#index" do + describe "#index" do it "returns empty JSON when nothing to review" do get "/review.json" expect(response.code).to eq("200") @@ -254,7 +254,7 @@ describe ReviewablesController do end end - context "#show" do + describe "#show" do context "basics" do fab!(:reviewable) { Fabricate(:reviewable) } before do @@ -320,7 +320,7 @@ describe ReviewablesController do end end - context "#explain" do + describe "#explain" do context "basics" do fab!(:reviewable) { Fabricate(:reviewable) } @@ -344,7 +344,7 @@ describe ReviewablesController do end end - context "#perform" do + describe "#perform" do fab!(:reviewable) { Fabricate(:reviewable) } before do sign_in(Fabricate(:moderator)) @@ -490,7 +490,7 @@ describe ReviewablesController do end end - context "#topics" do + describe "#topics" do fab!(:post0) { Fabricate(:post) } fab!(:post1) { Fabricate(:post, topic: post0.topic) } fab!(:post2) { Fabricate(:post) } @@ -542,7 +542,7 @@ describe ReviewablesController do end end - context "#settings" do + describe "#settings" do it "renders the settings as JSON" do get "/review/settings.json" expect(response.code).to eq("200") @@ -572,7 +572,7 @@ describe ReviewablesController do end end - context "#update" do + describe "#update" do fab!(:reviewable) { Fabricate(:reviewable) } fab!(:reviewable_post) { Fabricate(:reviewable_queued_post) } fab!(:reviewable_topic) { Fabricate(:reviewable_queued_post_topic) } @@ -679,7 +679,7 @@ describe ReviewablesController do end - context "#destroy" do + describe "#destroy" do fab!(:user) { Fabricate(:user) } before do @@ -705,7 +705,7 @@ describe ReviewablesController do end end - context "#count" do + describe "#count" do fab!(:admin) { Fabricate(:admin) } before do diff --git a/spec/requests/search_controller_spec.rb b/spec/requests/search_controller_spec.rb index 23390dca193..c1336f39404 100644 --- a/spec/requests/search_controller_spec.rb +++ b/spec/requests/search_controller_spec.rb @@ -205,7 +205,7 @@ describe SearchController do end end - context "#query" do + describe "#query" do it "logs the search term" do SiteSetting.log_search_queries = true get "/search/query.json", params: { term: 'wookie' } @@ -317,7 +317,7 @@ describe SearchController do end end - context "#show" do + describe "#show" do it "doesn't raise an error when search term not specified" do get "/search" expect(response.status).to eq(200) @@ -601,7 +601,7 @@ describe SearchController do end end - context "#click" do + describe "#click" do after do SearchLog.clear_debounce_cache! end diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb index e03357f1e8e..890816c4367 100644 --- a/spec/requests/static_controller_spec.rb +++ b/spec/requests/static_controller_spec.rb @@ -3,7 +3,7 @@ describe StaticController do fab!(:upload) { Fabricate(:upload) } - context '#favicon' do + describe '#favicon' do let(:filename) { 'smallest.png' } let(:file) { file_from_fixtures(filename) } @@ -66,7 +66,7 @@ describe StaticController do end end - context '#brotli_asset' do + describe '#brotli_asset' do it 'returns a non brotli encoded 404 if asset is missing' do get "/brotli_asset/missing.js" @@ -133,7 +133,7 @@ describe StaticController do end end - context '#cdn_asset' do + describe '#cdn_asset' do let (:site) { RailsMultisite::ConnectionManagement.current_db } it 'can serve assets' do @@ -155,7 +155,7 @@ describe StaticController do end end - context '#show' do + describe '#show' do before do post = create_post SiteSetting.tos_topic_id = post.topic.id diff --git a/spec/requests/stylesheets_controller_spec.rb b/spec/requests/stylesheets_controller_spec.rb index 7ee0c518e7b..a82dbec3f99 100644 --- a/spec/requests/stylesheets_controller_spec.rb +++ b/spec/requests/stylesheets_controller_spec.rb @@ -59,7 +59,7 @@ describe StylesheetsController do expect(response.status).to eq(200) end - context "#color_scheme" do + describe "#color_scheme" do it 'works as expected' do scheme = ColorScheme.last get "/color-scheme-stylesheet/#{scheme.id}.json" diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb index 5fe847eb7b4..2b684316edd 100644 --- a/spec/requests/tags_controller_spec.rb +++ b/spec/requests/tags_controller_spec.rb @@ -965,7 +965,7 @@ describe TagsController do end end - context '#upload_csv' do + describe '#upload_csv' do it 'requires you to be logged in' do post "/tags/upload.json" expect(response.status).to eq(403) diff --git a/spec/requests/user_api_keys_controller_spec.rb b/spec/requests/user_api_keys_controller_spec.rb index 5551e72e948..b24fab398b5 100644 --- a/spec/requests/user_api_keys_controller_spec.rb +++ b/spec/requests/user_api_keys_controller_spec.rb @@ -290,7 +290,7 @@ describe UserApiKeysController do end end - context '#create-one-time-password' do + describe '#create-one-time-password' do let :otp_args do { auth_redirect: 'http://somewhere.over.the/rainbow', diff --git a/spec/serializers/current_user_serializer_spec.rb b/spec/serializers/current_user_serializer_spec.rb index 1e3288bb9c5..7063db3fdce 100644 --- a/spec/serializers/current_user_serializer_spec.rb +++ b/spec/serializers/current_user_serializer_spec.rb @@ -29,7 +29,7 @@ RSpec.describe CurrentUserSerializer do end end - context "#top_category_ids" do + describe "#top_category_ids" do fab!(:category1) { Fabricate(:category) } fab!(:category2) { Fabricate(:category) } fab!(:category3) { Fabricate(:category) } @@ -58,7 +58,7 @@ RSpec.describe CurrentUserSerializer do end end - context "#muted_tag" do + describe "#muted_tag" do fab!(:tag) { Fabricate(:tag) } let!(:tag_user) do @@ -75,7 +75,7 @@ RSpec.describe CurrentUserSerializer do end end - context "#second_factor_enabled" do + describe "#second_factor_enabled" do let(:guardian) { Guardian.new(user) } let(:json) { serializer.as_json } @@ -104,7 +104,7 @@ RSpec.describe CurrentUserSerializer do end end - context "#groups" do + describe "#groups" do it "should only show visible groups" do Fabricate.build(:group, visibility_level: Group.visibility_levels[:public]) hidden_group = Fabricate.build(:group, visibility_level: Group.visibility_levels[:owners]) @@ -121,7 +121,7 @@ RSpec.describe CurrentUserSerializer do end end - context "#has_topic_draft" do + describe "#has_topic_draft" do it "is not included by default" do payload = serializer.as_json expect(payload).not_to have_key(:has_topic_draft) @@ -144,7 +144,7 @@ RSpec.describe CurrentUserSerializer do end - context "#can_review" do + describe "#can_review" do let(:guardian) { Guardian.new(user) } let(:payload) { serializer.as_json } diff --git a/spec/services/user_authenticator_spec.rb b/spec/services/user_authenticator_spec.rb index 97d365a1afc..6ca314d126f 100644 --- a/spec/services/user_authenticator_spec.rb +++ b/spec/services/user_authenticator_spec.rb @@ -39,7 +39,7 @@ describe UserAuthenticator do end end - context "#finish" do + describe "#finish" do fab!(:group) { Fabricate(:group, automatic_membership_email_domains: "discourse.org") } it "confirms email and adds the user to appropriate groups based on email" do