Skip to content

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

DEV: Bump rubocop-discourse to 3.20.0 (#43365)

Alan Guo Xiang Tan14f29ac2106c
diff --git a/Gemfile.lock b/Gemfile.lock
index 12a3195f972..b2a2107368a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -637,7 +637,7 @@ GEM
rubocop-capybara (3.0.0)
lint_roller (~> 1.1)
rubocop (~> 1.81)
- rubocop-discourse (3.19.0)
+ rubocop-discourse (3.20.0)
activesupport (>= 6.1)
lint_roller (>= 1.1.0)
rubocop-capybara (>= 2.23.0)
@@ -1248,7 +1248,7 @@ CHECKSUMS
rubocop (1.90.0) sha256=9eb4c065b5c5154e4ef554c547972f3905a9eb6b53e657e580b6796b54bf8242
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
rubocop-capybara (3.0.0) sha256=7a64655238acda7f8f3c87e37ac825a64c615a79c17c253f1a28270dc3768c4b
- rubocop-discourse (3.19.0) sha256=8c441eae02dceb1962e2860b92eec1213f4ab8f3defeda2b89b1f2efaf121a31
+ rubocop-discourse (3.20.0) sha256=47086bcf9b937e469398e82615fc4a6b86bd40df73bf85611a9109a83a1e9c70
rubocop-discourse-base (1.0.0) sha256=a4121f0f2a8e32c3259fee22106af9fd35372cbeac14b0c69673bdee79b472b7
rubocop-factory_bot (2.28.0) sha256=4b17fc02124444173317e131759d195b0d762844a71a29fe8139c1105d92f0cb
rubocop-rails (2.37.0) sha256=6e1645add5060e0328f8ddda0d820f55697c591394398bf14bb9dccb62f14b7e
diff --git a/migrations/core/spec/lib/database/prepared_statement_cache_spec.rb b/migrations/core/spec/lib/database/prepared_statement_cache_spec.rb
index 96454f8e33b..0698013a957 100644
--- a/migrations/core/spec/lib/database/prepared_statement_cache_spec.rb
+++ b/migrations/core/spec/lib/database/prepared_statement_cache_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Migrations::Database::PreparedStatementCache do
instance_double(Extralite::Query, close: nil)
end
- it "should inherit behavior from LruRedux::Cache" do
+ it "inherits behavior from LruRedux::Cache" do
expect(described_class).to be < LruRedux::Cache
end
diff --git a/plugins/automation/spec/requests/discourse_automation_automations_spec.rb b/plugins/automation/spec/requests/discourse_automation_automations_spec.rb
index 4d3eaeb5f85..208d28b0a84 100644
--- a/plugins/automation/spec/requests/discourse_automation_automations_spec.rb
+++ b/plugins/automation/spec/requests/discourse_automation_automations_spec.rb
@@ -56,7 +56,7 @@ describe DiscourseAutomation::AdminAutomationsController do
let(:admin) { Fabricate(:admin) }
let(:api_key) { Fabricate(:api_key, user: admin) }
- it "works" do
+ it "enqueues the automation trigger with an admin API key" do
post "/automations/#{automation.id}/trigger.json",
params: {
context: {
diff --git a/plugins/automation/spec/scripts/add_user_to_group_through_custom_field_spec.rb b/plugins/automation/spec/scripts/add_user_to_group_through_custom_field_spec.rb
index c748d596875..d7341b28edd 100644
--- a/plugins/automation/spec/scripts/add_user_to_group_through_custom_field_spec.rb
+++ b/plugins/automation/spec/scripts/add_user_to_group_through_custom_field_spec.rb
@@ -20,7 +20,7 @@ describe "AddUserToGroupThroughCustomField" do
end
context "with no matching user custom fields" do
- it "works" do
+ it "leaves both users outside the target group" do
expect(user_1.in_any_groups?([target_group.id])).to eq(false)
expect(user_2.in_any_groups?([target_group.id])).to eq(false)
@@ -40,7 +40,7 @@ describe "AddUserToGroupThroughCustomField" do
)
end
- it "works" do
+ it "adds only the matching user to the target group" do
expect(user_1.in_any_groups?([target_group.id])).to eq(false)
expect(user_2.in_any_groups?([target_group.id])).to eq(false)
@@ -70,7 +70,7 @@ describe "AddUserToGroupThroughCustomField" do
context "when group is already present" do
before { target_group.add(user_1) }
- it "works" do
+ it "preserves existing group membership" do
expect(user_1.in_any_groups?([target_group.id])).to eq(true)
expect(user_2.in_any_groups?([target_group.id])).to eq(false)
diff --git a/plugins/automation/spec/scripts/auto_responder_spec.rb b/plugins/automation/spec/scripts/auto_responder_spec.rb
index 1718fb117e8..2a6ca518085 100644
--- a/plugins/automation/spec/scripts/auto_responder_spec.rb
+++ b/plugins/automation/spec/scripts/auto_responder_spec.rb
@@ -160,7 +160,7 @@ describe "AutoResponder" do
end
end
- context "when post contains two keywords" do
+ context "when post contains two keywords with different letter casing" do
it "creates an answer with both answers" do
post = create_post(topic: topic, raw: "this is a post with FOO and bar")
automation.trigger!("post" => post)
@@ -169,7 +169,7 @@ describe "AutoResponder" do
end
end
- context "when post doesn’t contain a keyword" do
+ context "when post contains no keyword" do
it "doesn’t create an answer" do
post = create_post(topic: topic, raw: "this is a post with no keyword")
@@ -186,7 +186,7 @@ describe "AutoResponder" do
end
end
- context "when post doesn’t contain a keyword" do
+ context "when post only contains a keyword as part of another word" do
it "doesn’t create an answer" do
post = create_post(topic: topic, raw: "this is a post bfoo with no keyword fooa")
diff --git a/plugins/automation/spec/scripts/auto_tag_topic_spec.rb b/plugins/automation/spec/scripts/auto_tag_topic_spec.rb
index d1330db26cd..91a842c6cae 100644
--- a/plugins/automation/spec/scripts/auto_tag_topic_spec.rb
+++ b/plugins/automation/spec/scripts/auto_tag_topic_spec.rb
@@ -21,7 +21,7 @@ describe "AutoTagTopic" do
context "when there are tags" do
before { automation.upsert_field!("tags", "tags", { value: %w[tag1 tag2] }) }
- it "works" do
+ it "adds the configured tags" do
post = create_post(topic: topic)
automation.trigger!("post" => post)
@@ -46,7 +46,7 @@ describe "AutoTagTopic" do
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: ["restricted"])
end
- it "works" do
+ it "adds a restricted tag" do
post = create_post(topic: topic)
automation.trigger!("post" => post)
expect(topic.reload.tags.pluck(:name).sort).to match_array(["restricted"])
@@ -60,7 +60,7 @@ describe "AutoTagTopic" do
CategoryTag.create!(category: restricted_category, tag: restricted_tag)
end
- it "works" do
+ it "adds a tag restricted to the topic category" do
topic.update!(category: restricted_category)
post = create_post(topic: topic)
automation.trigger!("post" => post)
@@ -95,7 +95,7 @@ describe "AutoTagTopic" do
)
end
- it "works" do
+ it "adds the configured tags after an automatic closure" do
automation.trigger!("topic" => topic, "status" => :automatically)
expect(topic.reload.tags.pluck(:name)).to match_array(%w[tag1 tag2])
diff --git a/plugins/automation/spec/scripts/close_topic_spec.rb b/plugins/automation/spec/scripts/close_topic_spec.rb
index 543508a2331..688d1b4667a 100644
--- a/plugins/automation/spec/scripts/close_topic_spec.rb
+++ b/plugins/automation/spec/scripts/close_topic_spec.rb
@@ -9,7 +9,7 @@ describe "CloseTopic" do
before { automation.upsert_field!("topic", "text", { value: topic.id }, target: "script") }
context "with default params" do
- it "works" do
+ it "closes the topic with an empty closing post" do
expect(topic.closed).to be_falsey
automation.trigger!
@@ -32,7 +32,7 @@ describe "CloseTopic" do
)
end
- it "works" do
+ it "closes the topic with the configured message" do
expect(topic.closed).to be_falsey
automation.trigger!
diff --git a/plugins/automation/spec/scripts/pin_topic_spec.rb b/plugins/automation/spec/scripts/pin_topic_spec.rb
index ee96c464026..3716d605dd0 100644
--- a/plugins/automation/spec/scripts/pin_topic_spec.rb
+++ b/plugins/automation/spec/scripts/pin_topic_spec.rb
@@ -11,7 +11,7 @@ describe "PinTopic" do
end
context "when not pinned globally" do
- it "works" do
+ it "pins the topic locally" do
expect(topic.pinned_at).to be_nil
automation.trigger!
@@ -26,7 +26,7 @@ describe "PinTopic" do
context "when pinned globally" do
before { automation.upsert_field!("pinned_globally", "boolean", { value: true }) }
- it "works" do
+ it "pins the topic globally" do
expect(topic.pinned_at).to be_nil
automation.trigger!
@@ -44,7 +44,7 @@ describe "PinTopic" do
automation.upsert_field!("pinned_until", "date_time", { value: 10.days.from_now })
end
- it "works" do
+ it "schedules the topic to be unpinned" do
expect(topic.pinned_at).to be_nil
automation.trigger!
diff --git a/plugins/automation/spec/scripts/topic_required_words_spec.rb b/plugins/automation/spec/scripts/topic_required_words_spec.rb
index 8e9703415f3..9876445c09a 100644
--- a/plugins/automation/spec/scripts/topic_required_words_spec.rb
+++ b/plugins/automation/spec/scripts/topic_required_words_spec.rb
@@ -60,7 +60,7 @@ describe "TopicRequiredWords" do
fab!(:post) { Fabricate(:post, topic: topic, raw: "this is quite cool #bar") }
fab!(:destination_topic) { Fabricate(:post).topic }
- it "works" do
+ it "moves the post to the destination topic" do
expect do
topic.move_posts(admin, [post.id], destination_topic_id: destination_topic.id)
end.to_not raise_error
diff --git a/plugins/automation/spec/system/smoke_test_spec.rb b/plugins/automation/spec/system/smoke_test_spec.rb
index d869626265c..bdb83e390c9 100644
--- a/plugins/automation/spec/system/smoke_test_spec.rb
+++ b/plugins/automation/spec/system/smoke_test_spec.rb
@@ -53,7 +53,7 @@ describe "DiscourseAutomation | smoke test" do
end
end
- it "works" do
+ it "creates an enabled group membership automation" do
visit("/admin/plugins/automation")
find(".admin-config-area-empty-list__cta-button").click
diff --git a/plugins/automation/spec/triggers/after_post_cook_spec.rb b/plugins/automation/spec/triggers/after_post_cook_spec.rb
index bae83ab787c..0386d0c11b9 100644
--- a/plugins/automation/spec/triggers/after_post_cook_spec.rb
+++ b/plugins/automation/spec/triggers/after_post_cook_spec.rb
@@ -25,13 +25,13 @@ describe DiscourseAutomation::Triggers::AFTER_POST_COOK do
automation.reload
end
- it "should not fire when tag is missing" do
+ it "does not fire when the tag is missing" do
captured = capture_contexts { post.rebake! }
expect(captured).to be_blank
end
- it "should fire when tag is present" do
+ it "fires when the tag is present" do
topic.tags << filtered_tag
topic.save!
diff --git a/plugins/automation/spec/triggers/post_created_edited_spec.rb b/plugins/automation/spec/triggers/post_created_edited_spec.rb
index 7a1228ca9e9..4619b3c1436 100644
--- a/plugins/automation/spec/triggers/post_created_edited_spec.rb
+++ b/plugins/automation/spec/triggers/post_created_edited_spec.rb
@@ -415,7 +415,7 @@ describe "PostCreatedEdited" do
expect(list[0]["kind"]).to eq("post_created_edited")
end
- it "will not fire on unrelated categories" do
+ it "does not fire on unrelated categories" do
list =
capture_contexts do
PostCreator.create(user, basic_topic_params.merge({ category: another_category.id }))
diff --git a/plugins/automation/spec/triggers/topic_tags_changed_spec.rb b/plugins/automation/spec/triggers/topic_tags_changed_spec.rb
index 037b6ce0dd2..8d269fb921f 100644
--- a/plugins/automation/spec/triggers/topic_tags_changed_spec.rb
+++ b/plugins/automation/spec/triggers/topic_tags_changed_spec.rb
@@ -46,7 +46,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
)
end
- it "should fire the trigger if the tag is added" do
+ it "fires the trigger if the tag is added" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
list =
@@ -59,7 +59,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["user"]).to eq(user)
end
- it "should fire the trigger if the tag is removed" do
+ it "fires the trigger if the tag is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -70,7 +70,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["user"]).to eq(user)
end
- it "should not fire if the tag is not present" do
+ it "does not fire if the tag is not present" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
list =
@@ -96,7 +96,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
automation.reload
end
- it "should fire the trigger if any tag is added" do
+ it "fires the trigger if any tag is added" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
list =
@@ -108,7 +108,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should fire the trigger if any tag is removed" do
+ it "fires the trigger if any tag is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -118,7 +118,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should not fire if the tag is not present" do
+ it "does not fire if the tag is not present" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
list =
@@ -129,7 +129,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list.length).to eq(0)
end
- it "should fire the trigger if a tag is add and one is removed" do
+ it "fires the trigger if one tag is added and another is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -153,7 +153,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
automation.reload
end
- it "should fire the trigger if the tag is added" do
+ it "fires the trigger if the tag is added" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
topic_1 = Fabricate(:topic, user: user, tags: [], category: Fabricate(:category))
@@ -167,7 +167,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should fire the trigger if the tag is removed" do
+ it "fires the trigger if the tag is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -176,7 +176,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should not fire if not the watching category" do
+ it "does not fire outside the watched category" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: Fabricate(:category))
list =
@@ -202,7 +202,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
automation.reload
end
- it "should fire the trigger if any tag is added" do
+ it "fires the trigger if any tag is added" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
topic_1 = Fabricate(:topic, user: user, tags: [], category: category_2)
@@ -216,7 +216,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should fire the trigger if any tag is removed" do
+ it "fires the trigger if any tag is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -225,7 +225,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should not fire if not the watching category" do
+ it "does not fire outside the watched category" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: Fabricate(:category))
list =
@@ -238,7 +238,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
end
context "when without any watching tags or categories" do
- it "should fire the trigger if the tag is added" do
+ it "fires the trigger if the tag is added" do
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
list =
@@ -250,7 +250,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should fire the trigger if the tag is removed" do
+ it "fires the trigger if the tag is removed" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -260,7 +260,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should send the correct removed tags in context" do
+ it "sends the removed tags in the context" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -278,7 +278,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["removed_tags"]).to eq([cool_tag.name])
end
- it "should send the correct added tags in context" do
+ it "sends the added tags in the context" do
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
list =
@@ -296,7 +296,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["removed_tags"]).to eq([])
end
- it "should not fire the trigger on PMs by default" do
+ it "does not fire the trigger on private messages by default" do
pm = Fabricate(:private_message_topic)
list =
capture_contexts do
@@ -309,7 +309,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list.length).to eq(0)
end
- it "should fire the trigger on PMs if trigger_with_pms is set" do
+ it "fires the trigger on private messages when trigger_with_pms is set" do
automation.upsert_field!(
"trigger_with_pms",
"boolean",
@@ -330,7 +330,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
end
context "with TAGS_ADDED set in trigger_on field" do
- it "should fire if tag is added" do
+ it "fires if the tag is added" do
automation.upsert_field!(
"trigger_on",
"choices",
@@ -349,7 +349,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should not fire if tag is removed" do
+ it "does not fire if the tag is removed" do
automation.upsert_field!(
"trigger_on",
"choices",
@@ -367,7 +367,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
end
context "with TAGS_REMOVED set in trigger_on field" do
- it "should fire if tag is removed" do
+ it "fires if the tag is removed" do
automation.upsert_field!(
"trigger_on",
"choices",
@@ -384,7 +384,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
end
- it "should not fire if tag is added" do
+ it "does not fire if the tag is added" do
automation.upsert_field!(
"trigger_on",
"choices",
diff --git a/plugins/chat/spec/jobs/scheduled/periodical_updates_spec.rb b/plugins/chat/spec/jobs/scheduled/periodical_updates_spec.rb
index 5fa751779a3..658799e2991 100644
--- a/plugins/chat/spec/jobs/scheduled/periodical_updates_spec.rb
+++ b/plugins/chat/spec/jobs/scheduled/periodical_updates_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::Chat::PeriodicalUpdates do
- it "works" do
+ it "runs the periodic updates without raising an error" do
# does not blow up, no mocks, everything is called
Jobs::Chat::PeriodicalUpdates.new.execute(nil)
end
diff --git a/plugins/chat/spec/lib/chat/notifier_spec.rb b/plugins/chat/spec/lib/chat/notifier_spec.rb
index 4efdd5fccc6..53c8bcc1172 100644
--- a/plugins/chat/spec/lib/chat/notifier_spec.rb
+++ b/plugins/chat/spec/lib/chat/notifier_spec.rb
@@ -38,7 +38,7 @@ describe Chat::Notifier do
expect(to_notify[list_key]).to be_empty
end
- it "will never include someone who is not accepting channel-wide notifications" do
+ it "excludes users who ignore channel-wide notifications" do
user_2.user_option.update!(ignore_channel_wide_mention: true)
msg = build_cooked_msg(mention, user_1)
@@ -47,7 +47,7 @@ describe Chat::Notifier do
expect(to_notify[list_key]).to be_empty
end
- it "will never mention when channel is not accepting channel wide mentions" do
+ it "excludes mentions when the channel disables channel-wide mentions" do
channel.update!(allow_channel_wide_mentions: false)
msg = build_cooked_msg(mention, user_1)
@@ -56,7 +56,7 @@ describe Chat::Notifier do
expect(to_notify[list_key]).to be_empty
end
- it "will publish a mention warning" do
+ it "publishes a mention warning" do
channel.update!(allow_channel_wide_mentions: false)
msg = build_cooked_msg(mention, user_1)
@@ -73,7 +73,7 @@ describe Chat::Notifier do
)
end
- it "will respect user's locale on mention warning" do
+ it "uses the user's locale for the mention warning" do
SiteSetting.allow_user_locale = true
user_1.update!(locale: "pt_BR")
channel.update!(allow_channel_wide_mentions: false)
@@ -102,7 +102,7 @@ describe Chat::Notifier do
end
shared_examples "ensure only channel members are notified" do
- it "will never include someone outside the channel" do
+ it "excludes users outside the channel" do
user3 = Fabricate(:user)
@chat_group.add(user3)
another_channel = Fabricate(:category_channel)
@@ -114,7 +114,7 @@ describe Chat::Notifier do
expect(to_notify[list_key]).to contain_exactly(user_2.id)
end
- it "will never include someone not following the channel anymore" do
+ it "excludes users who no longer follow the channel" do
user3 = Fabricate(:user)
@chat_group.add(user3)
Fabricate(
@@ -130,7 +130,7 @@ describe Chat::Notifier do
expect(to_notify[list_key]).to contain_exactly(user_2.id)
end
- it "will never include someone who is suspended" do
+ it "excludes suspended users" do
user3 = Fabricate(:user, suspended_till: 2.years.from_now)
@chat_group.add(user3)
Fabricate(
diff --git a/plugins/chat/spec/lib/chat/statistics_spec.rb b/plugins/chat/spec/lib/chat/statistics_spec.rb
index 4c3832b84fb..b5187a176cd 100644
--- a/plugins/chat/spec/lib/chat/statistics_spec.rb
+++ b/plugins/chat/spec/lib/chat/statistics_spec.rb
@@ -1,342 +1,475 @@
# frozen_string_literal: true
describe Chat::Statistics do
- fab!(:frozen_time) { DateTime.parse("2022-07-08 09:30:00") }
-
- fab!(:user1, :user)
- fab!(:user2, :user)
- fab!(:user3, :user)
- fab!(:user4, :user)
- fab!(:user5, :user)
-
- fab!(:channel1) { Fabricate(:chat_channel, created_at: frozen_time - 1.hour) }
- fab!(:channel2) { Fabricate(:chat_channel, created_at: frozen_time - 2.days) }
- fab!(:channel3) { Fabricate(:chat_channel, created_at: frozen_time - 6.days) }
- fab!(:channel3) { Fabricate(:chat_channel, created_at: frozen_time - 20.days) }
- fab!(:channel4) { Fabricate(:chat_channel, created_at: frozen_time - 21.days, status: :closed) }
- fab!(:channel5) { Fabricate(:chat_channel, created_at: frozen_time - 24.days) }
- fab!(:channel6) { Fabricate(:chat_channel, created_at: frozen_time - 40.days) }
- fab!(:channel7) do
- Fabricate(:chat_channel, created_at: frozen_time - 100.days, status: :archived)
- end
-
- fab!(:membership1) do
- Fabricate(:user_chat_channel_membership, user: user1, chat_channel: channel1)
- end
- fab!(:membership2) do
- Fabricate(:user_chat_channel_membership, user: user2, chat_channel: channel1)
- end
- fab!(:membership3) do
- Fabricate(:user_chat_channel_membership, user: user3, chat_channel: channel1)
- end
-
- fab!(:message1) do
- Fabricate(
- :chat_message,
- chat_channel: channel1,
- created_at: frozen_time - 5.minutes,
- user: user1,
- )
- end
- fab!(:message2) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 2.days, user: user2)
- end
- fab!(:message3) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 6.days, user: user2)
- end
- fab!(:message4) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 11.days, user: user2)
- end
- fab!(:message5) do
- Fabricate(:chat_message, chat_channel: channel4, created_at: frozen_time - 12.days, user: user3)
- end
- fab!(:message6) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 13.days, user: user2)
- end
- fab!(:message7) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 16.days, user: user1)
- end
- fab!(:message8) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 42.days, user: user3)
- end
- fab!(:message9) do
- Fabricate(
- :chat_message,
- chat_channel: channel1,
- created_at: frozen_time - 42.days,
- user: user3,
- deleted_at: frozen_time - 10.days,
- deleted_by: user3,
- )
- end
- fab!(:message10) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 50.days, user: user4)
- end
- fab!(:message10) do
- Fabricate(:chat_message, chat_channel: channel1, created_at: frozen_time - 62.days, user: user4)
- end
+ context "when calculating summary metrics" do
+ fab!(:frozen_time) { DateTime.parse("2022-07-08 09:30:00") }
- before { freeze_time(DateTime.parse("2022-07-08 09:30:00")) }
+ fab!(:user1, :user)
+ fab!(:user2, :user)
+ fab!(:user3, :user)
+ fab!(:user4, :user)
+ fab!(:user5, :user)
- describe "#about_messages" do
- it "counts non-deleted messages created in all status channels in the time period accurately" do
- about_messages = described_class.about_messages
- expect(about_messages[:last_day]).to eq(1)
- expect(about_messages[:"7_days"]).to eq(3)
- expect(about_messages[:"30_days"]).to eq(7)
- expect(about_messages[:previous_30_days]).to eq(2)
- expect(about_messages[:count]).to eq(10)
+ fab!(:channel1) { Fabricate(:chat_channel, created_at: frozen_time - 1.hour) }
+ fab!(:channel2) { Fabricate(:chat_channel, created_at: frozen_time - 2.days) }
+ fab!(:channel3) { Fabricate(:chat_channel, created_at: frozen_time - 6.days) }
+ fab!(:channel3) { Fabricate(:chat_channel, created_at: frozen_time - 20.days) }
+ fab!(:channel4) { Fabricate(:chat_channel, created_at: frozen_time - 21.days, status: :closed) }
+ fab!(:channel5) { Fabricate(:chat_channel, created_at: frozen_time - 24.days) }
+ fab!(:channel6) { Fabricate(:chat_channel, created_at: frozen_time - 40.days) }
+ fab!(:channel7) do
+ Fabricate(:chat_channel, created_at: frozen_time - 100.days, status: :archived)
end
- end
- describe "#about_channels" do
- it "counts open channels created in the time period accurately" do
- about_channels = described_class.about_channels
- expect(about_channels[:last_day]).to eq(1)
- expect(about_channels[:"7_days"]).to eq(3)
- expect(about_channels[:"30_days"]).to eq(5)
- expect(about_channels[:previous_30_days]).to eq(1)
- expect(about_channels[:count]).to eq(6)
+ fab!(:membership1) do
+ Fabricate(:user_chat_channel_membership, user: user1, chat_channel: channel1)
end
- end
-
- describe "#about_users" do
- it "counts any users who have sent any message to a chat channel in the time periods accurately" do
- about_users = described_class.about_users
- expect(about_users[:last_day]).to eq(1)
- expect(about_users[:"7_days"]).to eq(2)
- expect(about_users[:"30_days"]).to eq(3)
- expect(about_users[:previous_30_days]).to eq(2)
- expect(about_users[:count]).to eq(4)
+ fab!(:membership2) do
+ Fabricate(:user_chat_channel_membership, user: user2, chat_channel: channel1)
end
- end
-
- describe "#monthly" do
- it "has the correct counts of users, messages, and channels created since the start of this month" do
- monthly = described_class.monthly
- expect(monthly[:messages]).to eq(3)
- expect(monthly[:channels]).to eq(3)
- expect(monthly[:users]).to eq(2)
- end
- end
-end
-
-describe Chat::Statistics do
- describe "#channel_messages" do
- now = Time.now
-
- fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
- fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
- fab!(:channel_3) { Fabricate(:chat_channel, status: :archived) }
-
- fab!(:message1) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour) }
- fab!(:message2) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days) }
- fab!(:message3) { Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 5.days) }
- fab!(:message4) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 10.days) }
- fab!(:message5) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 12.days) }
- fab!(:message6) { Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 27.days) }
- fab!(:message7) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 29.days) }
- fab!(:message8) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 30.days) }
- fab!(:message9) { Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 40.days) }
- fab!(:message10) do
- Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 50.days)
+ fab!(:membership3) do
+ Fabricate(:user_chat_channel_membership, user: user3, chat_channel: channel1)
end
- fab!(:dm_channel_1, :direct_message_channel)
- fab!(:dm_channel_2, :direct_message_channel)
- fab!(:dm_channel_3, :direct_message_channel)
-
- # these DM channel messages should be ignored when counting:
- fab!(:dm_message1) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
- end
- fab!(:dm_message2) do
- Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
- end
- fab!(:dm_message3) do
- Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 20.days)
- end
- fab!(:dm_message4) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
- end
-
- it "counts messages count accurately" do
- channel_messages = described_class.channel_messages
- expect(channel_messages[:last_day]).to eq(1)
- expect(channel_messages[:"7_days"]).to eq(3)
- expect(channel_messages[:"28_days"]).to eq(6)
- expect(channel_messages[:"30_days"]).to eq(7)
- expect(channel_messages[:count]).to eq(10)
- end
- end
-
- describe "#direct_messages" do
- now = Time.now
-
- fab!(:dm_channel_1) { Fabricate(:direct_message_channel, status: :open) }
- fab!(:dm_channel_2) { Fabricate(:direct_message_channel, status: :closed) }
- fab!(:dm_channel_3) { Fabricate(:direct_message_channel, status: :archived) }
-
fab!(:message1) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 5.minutes,
+ user: user1,
+ )
end
fab!(:message2) do
- Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 2.days,
+ user: user2,
+ )
end
fab!(:message3) do
- Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 5.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 6.days,
+ user: user2,
+ )
end
fab!(:message4) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 10.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 11.days,
+ user: user2,
+ )
end
fab!(:message5) do
- Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 12.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel4,
+ created_at: frozen_time - 12.days,
+ user: user3,
+ )
end
fab!(:message6) do
- Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 27.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 13.days,
+ user: user2,
+ )
end
fab!(:message7) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 29.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 16.days,
+ user: user1,
+ )
end
fab!(:message8) do
- Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 30.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 42.days,
+ user: user3,
+ )
end
fab!(:message9) do
- Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 40.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 42.days,
+ user: user3,
+ deleted_at: frozen_time - 10.days,
+ deleted_by: user3,
+ )
end
fab!(:message10) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 50.days,
+ user: user4,
+ )
end
-
- # these non DM channel messages should be ignored when counting:
- fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
- fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
- fab!(:channel_3) { Fabricate(:chat_channel, status: :archived) }
-
- fab!(:dm_message1) do
- Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour)
- end
- fab!(:dm_message2) do
- Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days)
- end
- fab!(:dm_message3) do
- Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 20.days)
- end
- fab!(:dm_message4) do
- Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 50.days)
- end
-
- it "counts messages count accurately" do
- direct_messages = described_class.direct_messages
- expect(direct_messages[:last_day]).to eq(1)
- expect(direct_messages[:"7_days"]).to eq(3)
- expect(direct_messages[:"28_days"]).to eq(6)
- expect(direct_messages[:"30_days"]).to eq(7)
- expect(direct_messages[:count]).to eq(10)
- end
- end
-
- describe "#open_channels_with_threads_enabled" do
- fab!(:open_channel_with_threads_enabled_1) do
- Fabricate(:chat_channel, threading_enabled: true, status: :open)
- end
- fab!(:open_channel_with_threads_enabled_2) do
- Fabricate(:chat_channel, threading_enabled: true, status: :open)
- end
-
- fab!(:channel3) { Fabricate(:chat_channel, threading_enabled: true, status: :closed) }
- fab!(:channel4) { Fabricate(:chat_channel, threading_enabled: true, status: :archived) }
- fab!(:channel5) { Fabricate(:chat_channel, threading_enabled: false, status: :open) }
- fab!(:channel6) { Fabricate(:chat_channel, threading_enabled: false, status: :closed) }
- fab!(:channel7) { Fabricate(:chat_channel, threading_enabled: false, status: :archived) }
-
- it "counts channels count accurately" do
- channels = described_class.open_channels_with_threads_enabled
- expect(channels[:count]).to eq(2)
- end
- end
-
- describe "#threaded_messages" do
- now = Time.now
-
- fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
- fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
-
- # note that fabricating a thread also fabricates the first message in that thread
- # so these two threads add up 2 messages
- fab!(:thread_1) { Fabricate(:chat_thread, channel: channel_1) }
- fab!(:thread_2) { Fabricate(:chat_thread, channel: channel_2) }
-
- fab!(:threaded_message1) do
- Fabricate(:chat_message, chat_channel: channel_1, thread: thread_1, created_at: now - 1.hour)
- end
- fab!(:threaded_message2) do
- Fabricate(:chat_message, chat_channel: channel_2, thread: thread_2, created_at: now - 3.days)
- end
- fab!(:threaded_message3) do
- Fabricate(:chat_message, chat_channel: channel_1, thread: thread_1, created_at: now - 5.days)
- end
- fab!(:threaded_message4) do
- Fabricate(:chat_message, chat_channel: channel_2, thread: thread_2, created_at: now - 10.days)
- end
- fab!(:threaded_message5) do
- Fabricate(:chat_message, chat_channel: channel_1, thread: thread_1, created_at: now - 12.days)
- end
- fab!(:threaded_message6) do
- Fabricate(:chat_message, chat_channel: channel_2, thread: thread_2, created_at: now - 27.days)
- end
- fab!(:threaded_message7) do
- Fabricate(:chat_message, chat_channel: channel_1, thread: thread_1, created_at: now - 29.days)
- end
- fab!(:threaded_message8) do
- Fabricate(:chat_message, chat_channel: channel_2, thread: thread_2, created_at: now - 30.days)
- end
- fab!(:threaded_message9) do
- Fabricate(:chat_message, chat_channel: channel_1, thread: thread_1, created_at: now - 40.days)
- end
- fab!(:threaded_message10) do
- Fabricate(:chat_message, chat_channel: channel_2, thread: thread_2, created_at: now - 50.days)
- end
-
- # these messages are not in a thread, so they should be ignored when counting:
- fab!(:message1) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour) }
- fab!(:message2) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days) }
- fab!(:message3) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 5.days) }
- fab!(:message4) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 10.days) }
- fab!(:message5) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 12.days) }
- fab!(:message6) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 20.days) }
- fab!(:message7) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 21.days) }
- fab!(:message8) { Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 30.days) }
- fab!(:message9) { Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 40.days) }
fab!(:message10) do
- Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 50.days)
- end
-
- fab!(:dm_channel_1, :direct_message_channel)
- fab!(:dm_channel_2, :direct_message_channel)
- fab!(:dm_channel_3, :direct_message_channel)
-
- # these DM channel messages should be ignored when counting:
- fab!(:dm_message1) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
- end
- fab!(:dm_message2) do
- Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
- end
- fab!(:dm_message3) do
- Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 20.days)
- end
- fab!(:dm_message4) do
- Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
+ Fabricate(
+ :chat_message,
+ chat_channel: channel1,
+ created_at: frozen_time - 62.days,
+ user: user4,
+ )
+ end
+
+ before { freeze_time(DateTime.parse("2022-07-08 09:30:00")) }
+
+ describe "#about_messages" do
+ it "counts non-deleted messages created in all status channels in the time period accurately" do
+ about_messages = described_class.about_messages
+ expect(about_messages[:last_day]).to eq(1)
+ expect(about_messages[:"7_days"]).to eq(3)
+ expect(about_messages[:"30_days"]).to eq(7)
+ expect(about_messages[:previous_30_days]).to eq(2)
+ expect(about_messages[:count]).to eq(10)
+ end
+ end
+
+ describe "#about_channels" do
+ it "counts open channels created in the time period accurately" do
+ about_channels = described_class.about_channels
+ expect(about_channels[:last_day]).to eq(1)
+ expect(about_channels[:"7_days"]).to eq(3)
+ expect(about_channels[:"30_days"]).to eq(5)
+ expect(about_channels[:previous_30_days]).to eq(1)
+ expect(about_channels[:count]).to eq(6)
+ end
+ end
+
+ describe "#about_users" do
+ it "counts any users who have sent any message to a chat channel in the time periods accurately" do
+ about_users = described_class.about_users
+ expect(about_users[:last_day]).to eq(1)
+ expect(about_users[:"7_days"]).to eq(2)
+ expect(about_users[:"30_days"]).to eq(3)
+ expect(about_users[:previous_30_days]).to eq(2)
+ expect(about_users[:count]).to eq(4)
+ end
+ end
+
+ describe "#monthly" do
+ it "has the correct counts of users, messages, and channels created since the start of this month" do
+ monthly = described_class.monthly
+ expect(monthly[:messages]).to eq(3)
+ expect(monthly[:channels]).to eq(3)
+ expect(monthly[:users]).to eq(2)
+ end
end
+ end
- it "counts messages count accurately" do
- threaded_messages = described_class.threaded_messages
- expect(threaded_messages[:last_day]).to eq(3)
- expect(threaded_messages[:"7_days"]).to eq(5)
- expect(threaded_messages[:"28_days"]).to eq(8)
- expect(threaded_messages[:"30_days"]).to eq(9)
- expect(threaded_messages[:count]).to eq(12)
+ context "when calculating channel message metrics" do
+ describe "#channel_messages" do
+ now = Time.now
+
+ fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
+ fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
+ fab!(:channel_3) { Fabricate(:chat_channel, status: :archived) }
+
+ fab!(:message1) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour)
+ end
+ fab!(:message2) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days)
+ end
+ fab!(:message3) do
+ Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 5.days)
+ end
+ fab!(:message4) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 10.days)
+ end
+ fab!(:message5) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 12.days)
+ end
+ fab!(:message6) do
+ Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 27.days)
+ end
+ fab!(:message7) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 29.days)
+ end
+ fab!(:message8) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 30.days)
+ end
+ fab!(:message9) do
+ Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 40.days)
+ end
+ fab!(:message10) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 50.days)
+ end
+
+ fab!(:dm_channel_1, :direct_message_channel)
+ fab!(:dm_channel_2, :direct_message_channel)
+ fab!(:dm_channel_3, :direct_message_channel)
+
+ # these DM channel messages should be ignored when counting:
+ fab!(:dm_message1) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
+ end
+ fab!(:dm_message2) do
+ Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
+ end
+ fab!(:dm_message3) do
+ Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 20.days)
+ end
+ fab!(:dm_message4) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
+ end
+
+ it "counts messages count accurately" do
+ channel_messages = described_class.channel_messages
+ expect(channel_messages[:last_day]).to eq(1)
+ expect(channel_messages[:"7_days"]).to eq(3)
+ expect(channel_messages[:"28_days"]).to eq(6)
+ expect(channel_messages[:"30_days"]).to eq(7)
+ expect(channel_messages[:count]).to eq(10)
+ end
+ end
+
+ describe "#direct_messages" do
+ now = Time.now
+
+ fab!(:dm_channel_1) { Fabricate(:direct_message_channel, status: :open) }
+ fab!(:dm_channel_2) { Fabricate(:direct_message_channel, status: :closed) }
+ fab!(:dm_channel_3) { Fabricate(:direct_message_channel, status: :archived) }
+
+ fab!(:message1) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
+ end
+ fab!(:message2) do
+ Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
+ end
+ fab!(:message3) do
+ Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 5.days)
+ end
+ fab!(:message4) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 10.days)
+ end
+ fab!(:message5) do
+ Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 12.days)
+ end
+ fab!(:message6) do
+ Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 27.days)
+ end
+ fab!(:message7) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 29.days)
+ end
+ fab!(:message8) do
+ Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 30.days)
+ end
+ fab!(:message9) do
+ Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 40.days)
+ end
+ fab!(:message10) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
+ end
+
+ # these non DM channel messages should be ignored when counting:
+ fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
+ fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
+ fab!(:channel_3) { Fabricate(:chat_channel, status: :archived) }
+
+ fab!(:dm_message1) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour)
+ end
+ fab!(:dm_message2) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days)
+ end
+ fab!(:dm_message3) do
+ Fabricate(:chat_message, chat_channel: channel_3, created_at: now - 20.days)
+ end
+ fab!(:dm_message4) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 50.days)
+ end
+
+ it "counts messages count accurately" do
+ direct_messages = described_class.direct_messages
+ expect(direct_messages[:last_day]).to eq(1)
+ expect(direct_messages[:"7_days"]).to eq(3)
+ expect(direct_messages[:"28_days"]).to eq(6)
+ expect(direct_messages[:"30_days"]).to eq(7)
+ expect(direct_messages[:count]).to eq(10)
+ end
+ end
+
+ describe "#open_channels_with_threads_enabled" do
+ fab!(:open_channel_with_threads_enabled_1) do
+ Fabricate(:chat_channel, threading_enabled: true, status: :open)
+ end
+ fab!(:open_channel_with_threads_enabled_2) do
+ Fabricate(:chat_channel, threading_enabled: true, status: :open)
+ end
+
+ fab!(:channel3) { Fabricate(:chat_channel, threading_enabled: true, status: :closed) }
+ fab!(:channel4) { Fabricate(:chat_channel, threading_enabled: true, status: :archived) }
+ fab!(:channel5) { Fabricate(:chat_channel, threading_enabled: false, status: :open) }
+ fab!(:channel6) { Fabricate(:chat_channel, threading_enabled: false, status: :closed) }
+ fab!(:channel7) { Fabricate(:chat_channel, threading_enabled: false, status: :archived) }
+
+ it "counts channels count accurately" do
+ channels = described_class.open_channels_with_threads_enabled
+ expect(channels[:count]).to eq(2)
+ end
+ end
+
+ describe "#threaded_messages" do
+ now = Time.now
+
+ fab!(:channel_1) { Fabricate(:chat_channel, status: :open) }
+ fab!(:channel_2) { Fabricate(:chat_channel, status: :closed) }
+
+ # note that fabricating a thread also fabricates the first message in that thread
+ # so these two threads add up 2 messages
+ fab!(:thread_1) { Fabricate(:chat_thread, channel: channel_1) }
+ fab!(:thread_2) { Fabricate(:chat_thread, channel: channel_2) }
+
+ fab!(:threaded_message1) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_1,
+ thread: thread_1,
+ created_at: now - 1.hour,
+ )
+ end
+ fab!(:threaded_message2) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_2,
+ thread: thread_2,
+ created_at: now - 3.days,
+ )
+ end
+ fab!(:threaded_message3) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_1,
+ thread: thread_1,
+ created_at: now - 5.days,
+ )
+ end
+ fab!(:threaded_message4) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_2,
+ thread: thread_2,
+ created_at: now - 10.days,
+ )
+ end
+ fab!(:threaded_message5) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_1,
+ thread: thread_1,
+ created_at: now - 12.days,
+ )
+ end
+ fab!(:threaded_message6) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_2,
+ thread: thread_2,
+ created_at: now - 27.days,
+ )
+ end
+ fab!(:threaded_message7) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_1,
+ thread: thread_1,
+ created_at: now - 29.days,
+ )
+ end
+ fab!(:threaded_message8) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_2,
+ thread: thread_2,
+ created_at: now - 30.days,
+ )
+ end
+ fab!(:threaded_message9) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_1,
+ thread: thread_1,
+ created_at: now - 40.days,
+ )
+ end
+ fab!(:threaded_message10) do
+ Fabricate(
+ :chat_message,
+ chat_channel: channel_2,
+ thread: thread_2,
+ created_at: now - 50.days,
+ )
+ end
+
+ # these messages are not in a thread, so they should be ignored when counting:
+ fab!(:message1) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 1.hour)
+ end
+ fab!(:message2) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 3.days)
+ end
+ fab!(:message3) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 5.days)
+ end
+ fab!(:message4) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 10.days)
+ end
+ fab!(:message5) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 12.days)
+ end
+ fab!(:message6) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 20.days)
+ end
+ fab!(:message7) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 21.days)
+ end
+ fab!(:message8) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 30.days)
+ end
+ fab!(:message9) do
+ Fabricate(:chat_message, chat_channel: channel_1, created_at: now - 40.days)
+ end
+ fab!(:message10) do
+ Fabricate(:chat_message, chat_channel: channel_2, created_at: now - 50.days)
+ end
+
+ fab!(:dm_channel_1, :direct_message_channel)
+ fab!(:dm_channel_2, :direct_message_channel)
+ fab!(:dm_channel_3, :direct_message_channel)
+
+ # these DM channel messages should be ignored when counting:
+ fab!(:dm_message1) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 1.hour)
+ end
+ fab!(:dm_message2) do
+ Fabricate(:chat_message, chat_channel: dm_channel_2, created_at: now - 3.days)
+ end
+ fab!(:dm_message3) do
+ Fabricate(:chat_message, chat_channel: dm_channel_3, created_at: now - 20.days)
+ end
+ fab!(:dm_message4) do
+ Fabricate(:chat_message, chat_channel: dm_channel_1, created_at: now - 50.days)
+ end
+
+ it "counts messages count accurately" do
+ threaded_messages = described_class.threaded_messages
+ expect(threaded_messages[:last_day]).to eq(3)
+ expect(threaded_messages[:"7_days"]).to eq(5)
+ expect(threaded_messages[:"28_days"]).to eq(8)
+ expect(threaded_messages[:"30_days"]).to eq(9)
+ expect(threaded_messages[:count]).to eq(12)
+ end
end
end
end
diff --git a/plugins/chat/spec/lib/chat_sdk/channel_spec.rb b/plugins/chat/spec/lib/chat_sdk/channel_spec.rb
index bf55b7ae2d7..5d7f1525c1b 100644
--- a/plugins/chat/spec/lib/chat_sdk/channel_spec.rb
+++ b/plugins/chat/spec/lib/chat_sdk/channel_spec.rb
@@ -23,7 +23,7 @@ describe ChatSDK::Channel do
context "when guardian can't see the channel" do
fab!(:channel_1, :private_category_channel)
- it "fails" do
+ it "rejects a guardian without access to the channel" do
params[:guardian] = Fabricate(:user).guardian
expect { described_class.messages(**params) }.to raise_error("Guardian can't view channel")
@@ -31,7 +31,7 @@ describe ChatSDK::Channel do
end
context "when target_message doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent target message" do
expect { described_class.messages(**params, target_message_id: -999) }.to raise_error(
"Target message doesn't exist",
)
@@ -39,7 +39,7 @@ describe ChatSDK::Channel do
end
context "when direction is invalid" do
- it "fails" do
+ it "rejects an invalid direction" do
expect { described_class.messages(**params, direction: "invalid") }.to raise_error(
"Direction is not included in the list",
)
@@ -65,7 +65,7 @@ describe ChatSDK::Channel do
end
context "when the channel doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent channel" do
params[:channel_id] = -999
expect { described_class.start_reply(**params) }.to raise_error(
@@ -75,7 +75,7 @@ describe ChatSDK::Channel do
end
context "when the thread doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent thread" do
params[:thread_id] = -999
expect { described_class.start_reply(**params) }.to raise_error(
@@ -113,7 +113,7 @@ describe ChatSDK::Channel do
end
context "when the channel doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent channel" do
params[:channel_id] = -999
expect { described_class.stop_reply(**params) }.to raise_error(
@@ -123,7 +123,7 @@ describe ChatSDK::Channel do
end
context "when the thread doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent thread" do
params[:thread_id] = -999
expect { described_class.stop_reply(**params) }.to raise_error(
diff --git a/plugins/chat/spec/lib/chat_sdk/message_spec.rb b/plugins/chat/spec/lib/chat_sdk/message_spec.rb
index 85b261fcb64..06d44db10cd 100644
--- a/plugins/chat/spec/lib/chat_sdk/message_spec.rb
+++ b/plugins/chat/spec/lib/chat_sdk/message_spec.rb
@@ -62,7 +62,7 @@ describe ChatSDK::Message do
before { channel_1.add(user) }
- it "fails" do
+ it "rejects messages with blocks from non-bot users" do
expect { described_class.create(**params) }.to raise_error(
"Only bots can create messages with blocks",
)
@@ -96,7 +96,7 @@ describe ChatSDK::Message do
end
context "when channel doesn’t exist" do
- it "fails" do
+ it "rejects a nonexistent channel" do
expect { described_class.create(**params, channel_id: -999) }.to raise_error(
"Couldn't find channel with id: `-999`",
)
@@ -104,7 +104,7 @@ describe ChatSDK::Message do
end
context "when user can't join channel" do
- it "fails" do
+ it "rejects users without channel membership" do
params[:guardian] = Fabricate(:user).guardian
expect { described_class.create(**params) }.to raise_error(
@@ -114,7 +114,7 @@ describe ChatSDK::Message do
end
context "when membership is enforced" do
- it "works" do
+ it "creates the message and enforces channel membership" do
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
params[:enforce_membership] = true
params[:guardian] = Fabricate(:user).guardian
@@ -126,7 +126,7 @@ describe ChatSDK::Message do
end
context "when thread doesn't exist" do
- it "fails" do
+ it "rejects a nonexistent thread" do
expect { described_class.create(**params, thread_id: -999) }.to raise_error(
"Couldn't find thread with id: `-999`",
)
@@ -134,7 +134,7 @@ describe ChatSDK::Message do
end
context "when params are invalid" do
- it "fails" do
+ it "rejects a missing channel and message body" do
expect { described_class.create(**params, raw: nil, channel_id: nil) }.to raise_error(
"Chat channel can't be blank, Message can't be blank",
)
@@ -182,7 +182,7 @@ describe ChatSDK::Message do
end
context "when user can't stop streaming" do
- it "fails" do
+ it "rejects users without permission to stop the stream" do
user = Fabricate(:user)
message_1.chat_channel.add(user)
@@ -197,7 +197,7 @@ describe ChatSDK::Message do
Fabricate(:chat_message, chat_channel: Fabricate(:private_category_channel))
end
- it "fails" do
+ it "rejects users outside the channel" do
user = Fabricate(:user)
expect {
diff --git a/plugins/chat/spec/lib/chat_sdk/thread_spec.rb b/plugins/chat/spec/lib/chat_sdk/thread_spec.rb
index 5240e22dc34..fb2873e337e 100644
--- a/plugins/chat/spec/lib/chat_sdk/thread_spec.rb
+++ b/plugins/chat/spec/lib/chat_sdk/thread_spec.rb
@@ -15,7 +15,7 @@ describe ChatSDK::Thread do
end
context "when missing param" do
- it "fails" do
+ it "raises a missing keyword error" do
params.delete(:thread_id)
expect { described_class.update_title(**params) }.to raise_error(
@@ -27,7 +27,7 @@ describe ChatSDK::Thread do
context "when guardian can't see the channel" do
fab!(:thread_1) { Fabricate(:chat_thread, channel: Fabricate(:private_category_channel)) }
- it "fails" do
+ it "raises a channel visibility error" do
params[:guardian] = Fabricate(:user).guardian
expect { described_class.update_title(**params) }.to raise_error(
@@ -37,7 +37,7 @@ describe ChatSDK::Thread do
end
context "when guardian can't edit the thread" do
- it "fails" do
+ it "raises a thread permission error" do
params[:guardian] = Fabricate(:user).guardian
expect { described_class.update_title(**params) }.to raise_error(
@@ -49,7 +49,7 @@ describe ChatSDK::Thread do
context "when the threading is not enabled" do
before { thread_1.channel.update!(threading_enabled: false) }
- it "fails" do
+ it "raises a threading-disabled error" do
expect { described_class.update_title(**params) }.to raise_error(
"Threading is not enabled for this channel",
)
@@ -57,7 +57,7 @@ describe ChatSDK::Thread do
end
context "when the thread doesn't exist" do
- it "fails" do
+ it "raises a missing-thread error" do
params[:thread_id] = -999
expect { described_class.update_title(**params) }.to raise_error(
"Couldn’t find thread with id: `-999`",
@@ -127,7 +127,7 @@ describe ChatSDK::Thread do
end
context "when target_message doesn’t exist" do
- it "fails" do
+ it "raises a missing-message error" do
expect { described_class.messages(**params, target_message_id: -999) }.to raise_error(
"Target message doesn't exist",
)
diff --git a/plugins/chat/spec/requests/chat/api/channel_messages_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channel_messages_controller_spec.rb
index b8a15e7f219..bf27c04434c 100644
--- a/plugins/chat/spec/requests/chat/api/channel_messages_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channel_messages_controller_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Chat::Api::ChannelMessagesController do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel) }
fab!(:message_2, :chat_message)
- it "works" do
+ it "returns messages from the requested channel" do
get "/chat/api/channels/#{channel.id}/messages"
expect(response.status).to eq(200)
@@ -81,7 +81,7 @@ RSpec.describe Chat::Api::ChannelMessagesController do
before { Discourse.enable_readonly_mode }
after { Discourse.disable_readonly_mode }
- it "works" do
+ it "returns messages in read-only mode" do
get "/chat/api/channels/#{channel.id}/messages"
expect(response.status).to eq(200)
@@ -456,7 +456,7 @@ RSpec.describe Chat::Api::ChannelMessagesController do
describe "#update" do
context "when message is updated" do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel, user: current_user) }
- it "works" do
+ it "updates the message" do
put "/chat/api/channels/#{channel.id}/messages/#{message_1.id}",
params: {
message: "abcdefg",
diff --git a/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
index 77c91649dae..d6a1df732c4 100644
--- a/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channel_thread_messages_controller_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Chat::Api::ChannelThreadMessagesController do
fab!(:message_1) { Fabricate(:chat_message, thread: thread, chat_channel: thread.channel) }
fab!(:message_2) { Fabricate(:chat_message, chat_channel: thread.channel) }
- it "works" do
+ it "returns the thread's messages" do
get "/chat/api/channels/#{thread.channel.id}/threads/#{thread.id}/messages"
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb
index f3245f0aaa4..80d44560f2b 100644
--- a/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channel_threads_controller_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe Chat::Api::ChannelThreadsController do
)
end
- it "works" do
+ it "returns the requested thread" do
get "/chat/api/channels/#{thread.channel_id}/threads/#{thread.id}"
expect(response.status).to eq(200)
expect(response.parsed_body["thread"]["id"]).to eq(thread.id)
diff --git a/plugins/chat/spec/requests/chat/api/channels_current_user_membership_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_current_user_membership_controller_spec.rb
index add0bfcc09c..e713333a1f0 100644
--- a/plugins/chat/spec/requests/chat/api/channels_current_user_membership_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_current_user_membership_controller_spec.rb
@@ -26,7 +26,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
context "when current user can’t see the channel" do
fab!(:channel_2) { Fabricate(:private_category_channel, group: Fabricate(:group)) }
- it "fails" do
+ it "forbids creating a channel membership" do
expect { post "/chat/api/channels/#{channel_2.id}/memberships/me" }.not_to change {
Chat::UserChatChannelMembership.where(user_id: current_user.id).count
}
@@ -50,7 +50,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
readonly_group_1.add(current_user)
end
- it "fails" do
+ it "forbids creating a channel membership" do
expect { post "/chat/api/channels/#{channel_2.id}/memberships/me" }.not_to change {
Chat::UserChatChannelMembership.where(user_id: current_user.id).count
}
@@ -73,7 +73,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
readonly_group_1.add(current_user)
end
- it "works" do
+ it "creates a channel membership" do
expect { post "/chat/api/channels/#{channel_2.id}/memberships/me" }.to change {
Chat::UserChatChannelMembership.where(user_id: current_user.id).count
}.by(1)
@@ -155,7 +155,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
describe "#destroy" do
describe "success" do
- it "works" do
+ it "allows leaving the channel" do
delete "/chat/api/channels/#{channel_1.id}/memberships/me"
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/requests/chat/api/channels_current_user_membership_follows_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_current_user_membership_follows_controller_spec.rb
index cf15d9659e9..df5d6951e8f 100644
--- a/plugins/chat/spec/requests/chat/api/channels_current_user_membership_follows_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_current_user_membership_follows_controller_spec.rb
@@ -14,7 +14,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
describe "for a category channel" do
fab!(:channel_1, :category_channel)
- it "works" do
+ it "unfollows the category channel" do
delete "/chat/api/channels/#{channel_1.id}/memberships/me/follows"
expect(response.status).to eq(200)
@@ -39,7 +39,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
Fabricate(:direct_message_channel, users: [current_user, other_user_1, other_user_2])
end
- it "works" do
+ it "unfollows the multi-user direct message channel" do
delete "/chat/api/channels/#{channel_1.id}/memberships/me/follows"
expect(response.status).to eq(200)
@@ -51,7 +51,7 @@ describe Chat::Api::ChannelsCurrentUserMembershipController do
fab!(:other_user_1, :user)
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [current_user, other_user_1]) }
- it "works" do
+ it "unfollows the direct message channel" do
delete "/chat/api/channels/#{channel_1.id}/memberships/me/follows"
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/requests/chat/api/channels_drafts_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_drafts_controller_spec.rb
index 6664feccd37..bc092862730 100644
--- a/plugins/chat/spec/requests/chat/api/channels_drafts_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_drafts_controller_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Chat::Api::ChannelsDraftsController do
describe "#create" do
describe "success" do
- it "works" do
+ it "creates the draft" do
post "/chat/api/channels/#{channel_1.id}/drafts", params: { data: { message: "a" } }
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/requests/chat/api/channels_invites_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_invites_controller_spec.rb
index d4ca0c36f7d..c8bade24d92 100644
--- a/plugins/chat/spec/requests/chat/api/channels_invites_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_invites_controller_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Chat::Api::ChannelsInvitesController do
describe "create" do
describe "success" do
- it "works" do
+ it "notifies the invited users" do
expect {
post "/chat/api/channels/#{channel_1.id}/invites?user_ids=#{user_1.id},#{user_2.id}"
}.to change {
@@ -42,7 +42,7 @@ RSpec.describe Chat::Api::ChannelsInvitesController do
describe "message_id param" do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
- it "works" do
+ it "includes the message in each notification" do
post "/chat/api/channels/#{channel_1.id}/invites?user_ids=#{user_1.id},#{user_2.id}&message_id=#{message_1.id}"
expect(JSON.parse(Notification.last.data)["chat_message_id"]).to eq(message_1.id)
diff --git a/plugins/chat/spec/requests/chat/api/channels_memberships_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_memberships_controller_spec.rb
index c578bec431d..1d55bc3b095 100644
--- a/plugins/chat/spec/requests/chat/api/channels_memberships_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_memberships_controller_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Chat::Api::ChannelsMembershipsController do
describe "#create" do
describe "success" do
- it "works" do
+ it "adds the requested user to the channel" do
add_users_to_channel(current_user, channel_1)
post "/chat/api/channels/#{channel_1.id}/memberships",
params: {
@@ -88,7 +88,7 @@ RSpec.describe Chat::Api::ChannelsMembershipsController do
let(:current_user) { Fabricate(:admin) }
describe "success" do
- it "works" do
+ it "removes the other user's membership" do
delete "/chat/api/channels/#{channel_1.id}/memberships/#{other_user.id}"
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/requests/chat/api/channels_messages_flags_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_messages_flags_controller_spec.rb
index a72622d9afd..3974de9adf4 100644
--- a/plugins/chat/spec/requests/chat/api/channels_messages_flags_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_messages_flags_controller_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe Chat::Api::ChannelsMessagesFlagsController do
end
describe "success" do
- it "works" do
+ it "flags the message" do
post "/chat/api/channels/#{message_1.chat_channel.id}/messages/#{message_1.id}/flags",
params: params
diff --git a/plugins/chat/spec/requests/chat/api/channels_read_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_read_controller_spec.rb
index 85bc9d0b5d1..bf99ad395a2 100644
--- a/plugins/chat/spec/requests/chat/api/channels_read_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_read_controller_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe Chat::Api::ChannelsReadController do
context "when message_id refers to deleted message" do
before { message_1.trash!(Discourse.system_user) }
- it "works" do
+ it "accepts the last read message update" do
put "/chat/api/channels/#{chat_channel.id}/read?message_id=#{message_1.id}"
expect(response.status).to eq(200)
end
diff --git a/plugins/chat/spec/requests/chat/api/channels_threads_drafts_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_threads_drafts_controller_spec.rb
index 5b402e5da04..d91002998f3 100644
--- a/plugins/chat/spec/requests/chat/api/channels_threads_drafts_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/channels_threads_drafts_controller_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Chat::Api::ChannelsThreadsDraftsController do
describe "#create" do
describe "success" do
- it "works" do
+ it "saves the thread draft" do
post "/chat/api/channels/#{channel_1.id}/threads/#{thread_1.id}/drafts",
params: {
data: {
diff --git a/plugins/chat/spec/requests/chat/api/current_user_threads_spec.rb b/plugins/chat/spec/requests/chat/api/current_user_threads_spec.rb
index c80fd071575..a6455045e3e 100644
--- a/plugins/chat/spec/requests/chat/api/current_user_threads_spec.rb
+++ b/plugins/chat/spec/requests/chat/api/current_user_threads_spec.rb
@@ -20,7 +20,7 @@ describe Chat::Api::CurrentUserThreadsController do
)
end
- it "works" do
+ it "returns the current user's threads" do
get "/chat/api/me/threads"
expect(response).to have_http_status :ok
diff --git a/plugins/chat/spec/requests/chat_controller_spec.rb b/plugins/chat/spec/requests/chat_controller_spec.rb
index 2ee529bca48..b15ce824460 100644
--- a/plugins/chat/spec/requests/chat_controller_spec.rb
+++ b/plugins/chat/spec/requests/chat_controller_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe Chat::ChatController do
describe "#rebake" do
fab!(:chat_message) { Fabricate(:chat_message, chat_channel: chat_channel, user: user) }
- it "works" do
+ it "rebakes the message" do
sign_in(admin)
put "/chat/#{chat_channel.id}/#{chat_message.id}/rebake.json"
expect(response.status).to eq(200)
diff --git a/plugins/chat/spec/serializer/chat/chat_message_serializer_spec.rb b/plugins/chat/spec/serializer/chat/chat_message_serializer_spec.rb
index f8b8e4d432a..ebbc4668683 100644
--- a/plugins/chat/spec/serializer/chat/chat_message_serializer_spec.rb
+++ b/plugins/chat/spec/serializer/chat/chat_message_serializer_spec.rb
@@ -10,7 +10,7 @@ describe Chat::MessageSerializer do
let(:guardian) { Guardian.new(guardian_user) }
- describe "#mentioned_users" do
+ describe "#mentioned_users with a configured mention limit" do
it "is limited by max_mentions_per_chat_message setting" do
Fabricate.times(2, :user_chat_mention, chat_message: message_1)
SiteSetting.max_mentions_per_chat_message = 1
@@ -284,7 +284,7 @@ describe Chat::MessageSerializer do
end
end
- describe "#mentioned_users" do
+ describe "#mentioned_users after a mentioned user is deleted" do
it "doesn't fail if mentioned user was deleted" do
mentioned_user = Fabricate(:user)
message =
diff --git a/plugins/chat/spec/services/chat/create_thread_spec.rb b/plugins/chat/spec/services/chat/create_thread_spec.rb
index 3082e4f0576..dc6b36ffdcc 100644
--- a/plugins/chat/spec/services/chat/create_thread_spec.rb
+++ b/plugins/chat/spec/services/chat/create_thread_spec.rb
@@ -159,7 +159,7 @@ RSpec.describe Chat::CreateThread do
it { is_expected.to fail_a_policy(:threading_enabled_for_channel) }
end
- context "when original message is not found" do
+ context "when the original message belongs to another channel" do
fab!(:channel_2) { Fabricate(:chat_channel, threading_enabled: true) }
before { params[:channel_id] = channel_2.id }
@@ -167,7 +167,7 @@ RSpec.describe Chat::CreateThread do
it { is_expected.to fail_to_find_a_model(:original_message) }
end
- context "when original message is not found" do
+ context "when the original message has been destroyed" do
before { message_1.destroy! }
it { is_expected.to fail_to_find_a_model(:original_message) }
diff --git a/plugins/chat/spec/services/chat/update_user_thread_last_read_spec.rb b/plugins/chat/spec/services/chat/update_user_thread_last_read_spec.rb
index 2b183e4ff36..3cf9895483c 100644
--- a/plugins/chat/spec/services/chat/update_user_thread_last_read_spec.rb
+++ b/plugins/chat/spec/services/chat/update_user_thread_last_read_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe Chat::UpdateUserThreadLastRead do
end
context "when the message doesn’t exist" do
- it "fails" do
+ it "fails to find the message" do
params[:message_id] = 999
is_expected.to fail_to_find_a_model(:message)
end
diff --git a/plugins/chat/spec/system/archive_channel_spec.rb b/plugins/chat/spec/system/archive_channel_spec.rb
index 3a306de9219..fdd1a7ddb2f 100644
--- a/plugins/chat/spec/system/archive_channel_spec.rb
+++ b/plugins/chat/spec/system/archive_channel_spec.rb
@@ -53,7 +53,7 @@ RSpec.describe "Archive channel" do
end
context "when archiving" do
- it "works" do
+ it "archives the channel and creates a topic" do
SiteSetting.tagging_enabled = true
tag = Fabricate(:tag, name: "archived")
Jobs.run_immediately!
diff --git a/plugins/chat/spec/system/browse_page_spec.rb b/plugins/chat/spec/system/browse_page_spec.rb
index 26019b1968d..89d7560742e 100644
--- a/plugins/chat/spec/system/browse_page_spec.rb
+++ b/plugins/chat/spec/system/browse_page_spec.rb
@@ -130,7 +130,7 @@ RSpec.describe "Browse page" do
context "when loading more" do
before { 25.times { Fabricate(:chat_channel, status: :open) } }
- it "works" do
+ it "loads the remaining channels" do
chat_page.visit_browse(:all)
scroll_to(find(".chat-channel-card:last-child"))
diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rb
index 10c0b9f60b5..35161d2ce75 100644
--- a/plugins/chat/spec/system/chat_composer_spec.rb
+++ b/plugins/chat/spec/system/chat_composer_spec.rb
@@ -233,7 +233,7 @@ RSpec.describe "Chat composer" do
context "when posting a message with length equal to minimum length" do
before { SiteSetting.chat_minimum_message_length = 1 }
- it "works" do
+ it "sends the minimum-length message" do
chat_page.visit_channel(channel_1)
channel_page.send_message("1")
diff --git a/plugins/chat/spec/system/message_thread_indicator_spec.rb b/plugins/chat/spec/system/message_thread_indicator_spec.rb
index 0ff7008b0d6..44ea32f1e15 100644
--- a/plugins/chat/spec/system/message_thread_indicator_spec.rb
+++ b/plugins/chat/spec/system/message_thread_indicator_spec.rb
@@ -56,7 +56,7 @@ describe "Thread indicator for chat messages" do
)
end
- it "it shows the reply count but no participant avatars when there is only one participant" do
+ it "shows the reply count but no participant avatars when there is only one participant" do
single_user_thread =
chat_thread_chain_bootstrap(channel: channel, users: [current_user], messages_count: 3)
diff --git a/plugins/chat/spec/system/reply_to_message/smoke_spec.rb b/plugins/chat/spec/system/reply_to_message/smoke_spec.rb
index 79407e14369..7a87a8b18eb 100644
--- a/plugins/chat/spec/system/reply_to_message/smoke_spec.rb
+++ b/plugins/chat/spec/system/reply_to_message/smoke_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "Reply to message - smoke" do
end
context "when two users create a thread on the same message" do
- it "works" do
+ it "opens the same thread for both users" do
sign_in(user_1)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
diff --git a/plugins/chat/spec/system/thread_list/full_page_spec.rb b/plugins/chat/spec/system/thread_list/full_page_spec.rb
index 8b56ba86724..48887e9d793 100644
--- a/plugins/chat/spec/system/thread_list/full_page_spec.rb
+++ b/plugins/chat/spec/system/thread_list/full_page_spec.rb
@@ -31,7 +31,7 @@ describe "Thread list in side panel | full page" do
before { chat_system_user_bootstrap(user: other_user, channel: channel) }
- it "it shows threads in the channel even if the user is not tracking them" do
+ it "shows threads in the channel even if the user is not tracking them" do
thread_1 =
Fabricate(
:chat_thread,
diff --git a/plugins/chat/spec/system/transcript_spec.rb b/plugins/chat/spec/system/transcript_spec.rb
index 828dfeaf6f4..92de99017cc 100644
--- a/plugins/chat/spec/system/transcript_spec.rb
+++ b/plugins/chat/spec/system/transcript_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe "Quoting chat message transcripts" do
message_1.rebake!
end
- it "works" do
+ it "pastes a transcript with the onebox content" do
chat_page.visit_channel(chat_channel_1)
clip_text = copy_messages_to_clipboard(message_1)
diff --git a/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb b/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb
index aab495124be..360b7b7d168 100644
--- a/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb
+++ b/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb
@@ -36,7 +36,7 @@ describe Jobs::DigestRagUpload do
describe "#execute" do
context "when processing an image upload" do
- it "will reject the indexing if the site setting is not enabled" do
+ it "rejects indexing if the site setting is disabled" do
SiteSetting.ai_rag_images_enabled = false
expect {
diff --git a/plugins/discourse-ai/spec/lib/agents/tool_runner/http_spec.rb b/plugins/discourse-ai/spec/lib/agents/tool_runner/http_spec.rb
index ef33e5196c3..e079052f016 100644
--- a/plugins/discourse-ai/spec/lib/agents/tool_runner/http_spec.rb
+++ b/plugins/discourse-ai/spec/lib/agents/tool_runner/http_spec.rb
@@ -190,7 +190,7 @@ RSpec.describe DiscourseAi::Agents::ToolRunner do
expect(result).to eq("Hello World")
end
- it "will not timeout on slow HTTP reqs" do
+ it "does not time out on slow HTTP requests" do
script = <<~JS
function invoke(params) {
result = http.get("https://example.com/" + params.query,
diff --git a/plugins/discourse-ai/spec/lib/agents/tools/google_spec.rb b/plugins/discourse-ai/spec/lib/agents/tools/google_spec.rb
index 3c361a494fc..b8d5b17b4b5 100644
--- a/plugins/discourse-ai/spec/lib/agents/tools/google_spec.rb
+++ b/plugins/discourse-ai/spec/lib/agents/tools/google_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe DiscourseAi::Agents::Tools::Google do
end
describe "#process" do
- it "will not explode if there are no results" do
+ it "returns safely when there are no results" do
json_text = { searchInformation: { totalResults: "0" } }.to_json
stub_request(
diff --git a/plugins/discourse-ai/spec/lib/completions/cancel_manager_spec.rb b/plugins/discourse-ai/spec/lib/completions/cancel_manager_spec.rb
index 784ec8d6065..cb3a1450766 100644
--- a/plugins/discourse-ai/spec/lib/completions/cancel_manager_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/cancel_manager_spec.rb
@@ -60,7 +60,7 @@ describe DiscourseAi::Completions::CancelManager do
waiter&.kill
end
- it "should do nothing when cancel manager is already cancelled" do
+ it "does nothing when the cancel manager is already cancelled" do
cancel_manager = DiscourseAi::Completions::CancelManager.new
cancel_manager.cancel!
@@ -75,7 +75,7 @@ describe DiscourseAi::Completions::CancelManager do
expect(result).to be_nil
end
- it "should be able to cancel a completion" do
+ it "cancels a completion" do
# Start an HTTP server that hangs indefinitely
server = TCPServer.new("127.0.0.1", 0)
port = server.addr[1]
diff --git a/plugins/discourse-ai/spec/lib/completions/dialects/chat_gpt_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/chat_gpt_spec.rb
index f57fa611108..5e76c111ca5 100644
--- a/plugins/discourse-ai/spec/lib/completions/dialects/chat_gpt_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/dialects/chat_gpt_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe DiscourseAi::Completions::Dialects::ChatGpt do
expect(translated).to contain_exactly(*open_ai_version)
end
- it "will retain usernames for unicode usernames, correctly in mixed mode" do
+ it "retains Unicode usernames correctly in mixed mode" do
prompt =
DiscourseAi::Completions::Prompt.new(
"You are a bot",
diff --git a/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
index c4b246ea74c..3d8ef933ad1 100644
--- a/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/dialects/dialect_spec.rb
@@ -87,7 +87,7 @@ RSpec.describe DiscourseAi::Completions::Dialects::Dialect do
describe "#trim_messages" do
let(:five_token_msg) { "This represents five tokens." }
- it "should trim tool messages if tool_calls are trimmed" do
+ it "trims tool messages when tool calls are trimmed" do
prompt = DiscourseAi::Completions::Prompt.new(five_token_msg)
prompt.push(type: :user, content: five_token_msg)
prompt.push(type: :tool_call, content: five_token_msg, id: 1)
diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb
index baaa29b8c6a..963a20e9773 100644
--- a/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb
@@ -1271,7 +1271,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic do
end
describe "max output tokens" do
- it "it respects max output tokens supplied to model unconditionally, even with thinking" do
+ it "respects the model's maximum output tokens even with thinking enabled" do
model.update!(
provider_params: {
enable_reasoning: true,
diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb
index 3422cfcc1f6..b45cda08041 100644
--- a/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::AwsBedrock do
before { enable_current_plugin }
- it "should provide accurate max token count" do
+ it "provides an accurate maximum token count" do
prompt = DiscourseAi::Completions::Prompt.new("hello")
dialect = DiscourseAi::Completions::Dialects::Claude.new(prompt, model)
endpoint = DiscourseAi::Completions::Endpoints::AwsBedrock.new(model)
diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/nova_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/nova_spec.rb
index 8c25f43d9df..903d7075970 100644
--- a/plugins/discourse-ai/spec/lib/completions/endpoints/nova_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/nova_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::AwsBedrock do
before { enable_current_plugin }
- it "should be able to make a simple request" do
+ it "makes a simple request" do
proxy = DiscourseAi::Completions::Llm.proxy(nova_model)
content = {
@@ -62,7 +62,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::AwsBedrock do
expect(log.response_tokens).to eq(119)
end
- it "should be able to make a streaming request" do
+ it "makes a streaming request" do
messages =
[
{ messageStart: { role: "assistant" } },
@@ -102,7 +102,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::AwsBedrock do
expect(log.response_tokens).to eq(18)
end
- it "should support native streaming tool calls" do
+ it "supports native streaming tool calls" do
#model.provider_params["disable_native_tools"] = true
#model.save!
diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb
index 7561f8a062d..5cd89ee4493 100644
--- a/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb
@@ -836,7 +836,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::OpenAi do
compliance.streaming_mode_simple_prompt(open_ai_mock)
end
- it "will automatically recover from a bad payload" do
+ it "recovers automatically from a bad payload" do
called = false
# this should not happen, but lets ensure nothing bad happens
diff --git a/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb b/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb
index 3dbb9ddcf4a..5d4893907fc 100644
--- a/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb
@@ -5,12 +5,12 @@ describe DiscourseAi::Completions::JsonStreamDecoder do
before { enable_current_plugin }
- it "should be able to parse simple messages" do
+ it "parses simple messages" do
result = decoder << "data: #{{ hello: "world" }.to_json}"
expect(result).to eq([{ hello: "world" }])
end
- it "should handle anthropic mixed stlye streams" do
+ it "handles Anthropic mixed-style streams" do
stream = <<~TEXT.split("|")
event: |message_start|
data: |{"hel|lo": "world"}|
@@ -30,7 +30,7 @@ describe DiscourseAi::Completions::JsonStreamDecoder do
expect(results.flatten.compact).to eq([{ hello: "world" }, { foo: "bar" }, { baz: "qux" }])
end
- it "should be able to handle complex overlaps" do
+ it "handles complex overlaps" do
stream = <<~TEXT.split("|")
data: |{"hel|lo": "world"}
diff --git a/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb b/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb
index 61b8b04f210..79fcaf14204 100644
--- a/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb
@@ -71,14 +71,14 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
expect(content[3]).to eq({ upload_id: 2 })
end
- it "should allow merging user messages" do
+ it "merges user messages" do
builder.push(type: :user, content: "Hello", id: "Alice")
builder.push(type: :user, content: "World", id: "Bob")
expect(builder.to_a).to eq([{ type: :user, content: "Alice: Hello\nBob: World" }])
end
- it "should allow adding uploads" do
+ it "adds uploads" do
builder.push(type: :user, content: "Hello", name: "Alice", upload_ids: [1, 2])
expect(builder.to_a).to eq(
@@ -86,7 +86,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
)
end
- it "should support function calls" do
+ it "supports function calls" do
builder.push(type: :user, content: "Echo 123 please", name: "Alice")
builder.push(type: :tool_call, content: "echo(123)", name: "echo", id: 1)
builder.push(type: :tool, content: "123", name: "echo", id: 1)
@@ -100,7 +100,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
expect(builder.to_a).to eq(expected)
end
- it "should drop a tool call if it is not followed by tool" do
+ it "drops a tool call that is not followed by a tool result" do
builder.push(type: :user, content: "Echo 123 please", id: "Alice")
builder.push(type: :tool_call, content: "echo(123)", name: "echo", id: 1)
builder.push(type: :user, content: "OK", id: "James")
@@ -109,7 +109,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
expect(builder.to_a).to eq(expected)
end
- it "should format messages for topic style" do
+ it "formats messages for topic style" do
# Create a topic with tags
topic = Fabricate(:topic, title: "This is an Example Topic")
@@ -752,7 +752,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
)
end
- it "handles uploads correctly in topic style messages (and times)" do
+ it "combines uploads and timestamps in topic-style messages" do
freeze_time 32.days.ago
# Use Discourse's upload format in the post raw content
@@ -962,7 +962,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
)
end
- it "handles uploads correctly in topic style messages (and times)" do
+ it "retains upload Markdown while attaching uploads to topic-style messages" do
freeze_time 32.days.ago
# Use Discourse's upload format in the post raw content
diff --git a/plugins/discourse-ai/spec/lib/completions/xml_tag_stripper_spec.rb b/plugins/discourse-ai/spec/lib/completions/xml_tag_stripper_spec.rb
index a7eabef2307..6ce2985cd91 100644
--- a/plugins/discourse-ai/spec/lib/completions/xml_tag_stripper_spec.rb
+++ b/plugins/discourse-ai/spec/lib/completions/xml_tag_stripper_spec.rb
@@ -5,7 +5,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder do
before { enable_current_plugin }
- it "should strip tags correctly in simple cases" do
+ it "strips tags correctly in simple cases" do
result = tag_stripper << "x<thinking>hello</thinki"
expect(result).to eq("x")
diff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb
index 49222a8f14d..626e2fe6bdc 100644
--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb
+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb
@@ -109,7 +109,7 @@ describe DiscourseAi::Automation::LlmTriage do
# nothing should happen, no classification, its a PM
end
- it "will triage PMs if automation allows it" do
+ it "triages PMs if automation allows it" do
# needs to be admin or it will not be able to just step in to
# PM
reply_user.update!(admin: true)
diff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb
index 1213a3c30ac..a447868e2f8 100644
--- a/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb
+++ b/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb
@@ -186,7 +186,7 @@ describe DiscourseAi::AiBot::EntryPoint do
end
end
- it "will include ai_search_discoveries field in the user_option if discover agent is enabled" do
+ it "includes ai_search_discoveries in user_option if the discover agent is enabled" do
user = Fabricate(:user)
group = Fabricate(:group)
group.add(user)
diff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb
index b7dd5e52afb..6656b069f64 100644
--- a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb
+++ b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
AiAgent.agent_cache.flush!
end
- describe "#title_playground" do
+ describe "#title_playground with a multipart model response" do
it "updates the topic title when the LLM returns multiple text blocks" do
DiscourseAi::Completions::Llm.with_prepared_responses(
[["A concise ", "conversation title"]],
@@ -416,7 +416,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
agent.update!(allow_chat_channel_mentions: true, default_llm_id: opus_model.id)
end
- it "should behave in a sane way when threading is enabled" do
+ it "creates the reply correctly when threading is enabled" do
channel.update!(threading_enabled: true)
message =
@@ -490,7 +490,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
expect(reply.message).to eq("world")
end
- it "should reply to a mention if properly enabled" do
+ it "replies to a mention when enabled" do
prompts = nil
ChatSDK::Message.create(
@@ -1511,7 +1511,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
describe "#canceling a completions" do
after { DiscourseAi::AiBot::PostStreamer.on_callback = nil }
- it "should be able to cancel a completion halfway through" do
+ it "cancels a completion halfway through" do
body = <<~STRING.strip
event: message_start
data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}
diff --git a/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb
index 89c281f39f2..423795fed49 100644
--- a/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb
+++ b/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb
@@ -6,7 +6,7 @@ describe DiscourseAi::AiHelper::EntryPoint do
before { enable_current_plugin }
- it "will correctly localize available prompts" do
+ it "localizes available prompts" do
assign_fake_provider_to(:ai_default_llm_model)
SiteSetting.default_locale = "en"
SiteSetting.allow_user_locale = true
diff --git a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
index ee1094e9b7e..da51d131a8f 100644
--- a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
+++ b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb
@@ -46,7 +46,7 @@ module DiscourseAi
before { enable_current_plugin }
if defined?(DiscourseSolved)
- it "will correctly denote solved topics" do
+ it "marks solved topics" do
Fabricate(:solved_topic, topic: topic_with_likes, answer_post: post_with_likes2)
context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)
@@ -56,7 +56,7 @@ module DiscourseAi
end
end
- it "will exclude non visible topics" do
+ it "excludes invisible topics" do
post_with_likes3.topic.update(visible: false)
context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)
diff --git a/plugins/discourse-ai/spec/lib/utils/diff_utils/hunk_diff_spec.rb b/plugins/discourse-ai/spec/lib/utils/diff_utils/hunk_diff_spec.rb
index 5739459a13e..888307f9f68 100644
--- a/plugins/discourse-ai/spec/lib/utils/diff_utils/hunk_diff_spec.rb
+++ b/plugins/discourse-ai/spec/lib/utils/diff_utils/hunk_diff_spec.rb
@@ -184,7 +184,7 @@ RSpec.describe DiscourseAi::Utils::DiffUtils::HunkDiff do
let(:original_text) { "hello" }
let(:diff) { "world" }
- it "will append to the end" do
+ it "appends to the end" do
expect(apply_hunk).to eq("hello\nworld")
end
end
diff --git a/plugins/discourse-ai/spec/models/ai_tool_spec.rb b/plugins/discourse-ai/spec/models/ai_tool_spec.rb
index fad5cf30e33..739b9981bd6 100644
--- a/plugins/discourse-ai/spec/models/ai_tool_spec.rb
+++ b/plugins/discourse-ai/spec/models/ai_tool_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe AiTool do
before { enable_current_plugin }
- it "it can run a basic tool" do
+ it "runs a basic tool" do
tool = create_tool
expect(tool.signature).to eq(
diff --git a/plugins/discourse-ai/spec/models/llm_model_spec.rb b/plugins/discourse-ai/spec/models/llm_model_spec.rb
index a19f1007e56..4a800397cf1 100644
--- a/plugins/discourse-ai/spec/models/llm_model_spec.rb
+++ b/plugins/discourse-ai/spec/models/llm_model_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe LlmModel do
before { ENV["DISCOURSE_AI_SEEDED_LLM_API_KEY_2"] = "blabla" }
- it "should use environment variable over database value if seeded LLM" do
+ it "uses the environment variable instead of the database value for a seeded LLM" do
expect(llm_model.api_key).to eq("blabla")
end
end
diff --git a/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb
index 694d9ddb2dc..9b3890ee895 100644
--- a/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb
+++ b/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb
@@ -935,7 +935,7 @@ RSpec.describe DiscourseAi::Admin::AiAgentsController do
end
end
- describe "DELETE #destroy" do
+ describe "DELETE #destroy with a parent agent" do
it "removes the deleted agent from parent subagent IDs" do
child = Fabricate(:ai_agent)
parent = Fabricate(:ai_agent, subagent_ids: [child.id])
diff --git a/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb
index 7bfe371ff98..022f0a0d4e9 100644
--- a/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb
+++ b/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe DiscourseAi::Admin::RagDocumentFragmentsController do
tempfile
end
- it "works" do
+ it "uploads the document fragment file" do
post "/admin/plugins/discourse-ai/rag-document-fragments/files/upload.json",
params: {
file: Rack::Test::UploadedFile.new(file_from_fixtures("spec.txt", "md")),
diff --git a/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb b/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb
index 3f0b8bdb0d3..42faa16a925 100644
--- a/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb
+++ b/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb
@@ -69,7 +69,7 @@ describe DiscourseAi::Embeddings::EmbeddingsController do
context "when rate limiting is enabled" do
before { RateLimiter.enable }
- it "will rate limit correctly" do
+ it "rate limits repeated requests" do
stub_const(described_class, :MAX_HYDE_SEARCHES_PER_MINUTE, 1) do
stub_const(described_class, :MAX_SEARCHES_PER_MINUTE, 2) do
query = "test #{SecureRandom.hex}"
diff --git a/plugins/discourse-ai/spec/requests/topic_spec.rb b/plugins/discourse-ai/spec/requests/topic_spec.rb
index abe3a6bb46d..3b5af62eade 100644
--- a/plugins/discourse-ai/spec/requests/topic_spec.rb
+++ b/plugins/discourse-ai/spec/requests/topic_spec.rb
@@ -20,7 +20,7 @@ describe ::TopicsController do
end
context "when a user is logged on" do
- it "includes related topics in payload when configured" do
+ it "includes related topics for anonymous and logged-in requests" do
get("#{topic.relative_url}.json")
expect(response.status).to eq(200)
json = response.parsed_body
@@ -37,7 +37,7 @@ describe ::TopicsController do
expect(json["related_topics"].length).to eq(2)
end
- it "includes related topics in payload when configured" do
+ it "includes related topics alongside lazy-loaded categories" do
SiteSetting.lazy_load_categories_groups = "#{Group::AUTO_GROUPS[:anonymous_users]}"
category = Fabricate(:category)
topic.update!(category: category)
diff --git a/plugins/discourse-ai/spec/system/admin_ai_agent_spec.rb b/plugins/discourse-ai/spec/system/admin_ai_agent_spec.rb
index 254b0e4c58e..234d4469a73 100644
--- a/plugins/discourse-ai/spec/system/admin_ai_agent_spec.rb
+++ b/plugins/discourse-ai/spec/system/admin_ai_agent_spec.rb
@@ -96,7 +96,7 @@ RSpec.describe "Admin AI agent configuration" do
expect(parent.reload.subagent_ids).to eq([])
end
- it "will not allow deletion or editing of system agents" do
+ it "prevents deletion or editing of system agents" do
visit "/admin/plugins/discourse-ai/ai-agents/#{DiscourseAi::Agents::Agent.system_agents.values.first}/edit"
expect(page).not_to have_selector(".ai-agent-editor__delete")
expect(form.field("system_prompt")).to be_disabled
@@ -215,7 +215,7 @@ RSpec.describe "Admin AI agent configuration" do
expect(agent_editor_page).to have_floating_actions
end
- it "will enable agent right away when you click on enable but does not save side effects" do
+ it "enables the agent immediately without saving other edits" do
agent = Fabricate(:ai_agent, enabled: false)
visit "/admin/plugins/discourse-ai/ai-agents/#{agent.id}/edit"
diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
index d03da1fa78d..857e72272b3 100644
--- a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
@@ -565,7 +565,7 @@ RSpec.describe "AI Composer helper" do
end
context "when triggering composer AI helper", mobile: true do
- it "should close the composer helper before showing the diff modal" do
+ it "closes the composer helper before showing the diff modal" do
visit("/latest")
page.find("#create-topic").click
composer.fill_content(input)
diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb
index 2299bd31518..ec01fda6bab 100644
--- a/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb
@@ -62,7 +62,7 @@ RSpec.describe "AI Post helper" do
expect(post_ai_helper).to have_post_ai_helper_options
end
- it "should not have the mobile post AI helper" do
+ it "does not display the mobile post AI helper" do
select_post_text(post)
post_ai_helper.click_ai_button
expect(post_ai_helper).to have_no_mobile_post_ai_helper
@@ -181,7 +181,7 @@ RSpec.describe "AI Post helper" do
end
context "when triggering post AI helper on mobile", mobile: true do
- it "should use the bottom modal instead of the popup menu" do
+ it "uses the bottom modal instead of the popup menu" do
select_post_text(post)
post_ai_helper.click_ai_button
expect(post_ai_helper).to have_mobile_post_ai_helper
diff --git a/plugins/discourse-ai/spec/system/ai_user_preferences_spec.rb b/plugins/discourse-ai/spec/system/ai_user_preferences_spec.rb
index 2ba72706db9..3e6ed03238e 100644
--- a/plugins/discourse-ai/spec/system/ai_user_preferences_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_user_preferences_spec.rb
@@ -21,7 +21,7 @@ describe "User AI preferences" do
context "when discoveries are enabled" do
before { enable_legacy_discover }
- it "should have the setting present in the user preferences page" do
+ it "shows the setting on the user preferences page" do
user_preferences_ai_page.visit(user)
expect(user_preferences_ai_page).to have_ai_preference("pref-ai-search-discoveries")
end
@@ -52,7 +52,7 @@ describe "User AI preferences" do
context "when discoveries are disabled" do
before { SiteSetting.ai_discover_enabled = false }
- it "should not have the setting present in the user preferences page" do
+ it "hides the setting from the user preferences page" do
user_preferences_ai_page.visit(user)
expect(user_preferences_ai_page).to have_no_ai_preference("pref-ai-search-discoveries")
end
diff --git a/plugins/discourse-apple-auth/spec/requests/auth_apple_spec.rb b/plugins/discourse-apple-auth/spec/requests/auth_apple_spec.rb
index 44868d2d9f9..a9d81da5148 100644
--- a/plugins/discourse-apple-auth/spec/requests/auth_apple_spec.rb
+++ b/plugins/discourse-apple-auth/spec/requests/auth_apple_spec.rb
@@ -111,7 +111,7 @@ describe "sign in with apple" do
end
end
- it "works" do
+ it "authenticates the Apple callback payload" do
# Like an OAuth2 callback, but with some apple-specific stuff per
# https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms
get "/auth/apple/callback",
diff --git a/plugins/discourse-assign/spec/components/topic_query_spec.rb b/plugins/discourse-assign/spec/components/topic_query_spec.rb
index f58a970042f..90aae656356 100644
--- a/plugins/discourse-assign/spec/components/topic_query_spec.rb
+++ b/plugins/discourse-assign/spec/components/topic_query_spec.rb
@@ -196,7 +196,7 @@ describe TopicQuery do
group_assigned_topic
end
- it "should return the right topics" do
+ it "returns messages assigned to the user or their group" do
expect(TopicQuery.new(user).list_private_messages_assigned(user).topics).to contain_exactly(
assigned_topic,
group_assigned_topic,
diff --git a/plugins/discourse-assign/spec/jobs/regular/remind_user_spec.rb b/plugins/discourse-assign/spec/jobs/regular/remind_user_spec.rb
index 8e6869ba747..bcd6908c14b 100644
--- a/plugins/discourse-assign/spec/jobs/regular/remind_user_spec.rb
+++ b/plugins/discourse-assign/spec/jobs/regular/remind_user_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Jobs::RemindUser do
describe "#execute" do
- it "should raise the right error when user_id is invalid" do
+ it "raises InvalidParameters when user_id is missing" do
expect do described_class.new.execute({}) end.to raise_error(Discourse::InvalidParameters)
end
end
diff --git a/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb b/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb
index c3a9afea8ec..42c13c89b54 100644
--- a/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb
+++ b/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe Jobs::UnassignNotification do
}.to change { user2.notifications.count }.by(-1)
end
- it "should publish the right message when private message" do
+ it "publishes the notification for a private message" do
user = pm.allowed_users.first
assign_allowed_group.add(user)
diff --git a/plugins/discourse-assign/spec/lib/assigner_spec.rb b/plugins/discourse-assign/spec/lib/assigner_spec.rb
index ca5a3d301cb..ddcb886dfc5 100644
--- a/plugins/discourse-assign/spec/lib/assigner_spec.rb
+++ b/plugins/discourse-assign/spec/lib/assigner_spec.rb
@@ -1079,7 +1079,7 @@ RSpec.describe Assigner do
}
end
- it "doesn't send an email if the assigner and assignee are not different" do
+ it "doesn't send an email when assigning a user to themself" do
SiteSetting.assign_mailer = AssignMailer.levels[:different_users]
expect { described_class.new(topic, moderator).assign(moderator_2) }.to change {
@@ -1087,7 +1087,7 @@ RSpec.describe Assigner do
}.by(1)
end
- it "doesn't send an email if the assigner and assignee are not different" do
+ it "doesn't send an email when assigning a group to one of its members" do
SiteSetting.assign_mailer = AssignMailer.levels[:different_users]
expect { described_class.new(topic, moderator).assign(moderator) }.not_to change {
diff --git a/plugins/discourse-assign/spec/requests/list_controller_spec.rb b/plugins/discourse-assign/spec/requests/list_controller_spec.rb
index 2a196a334e0..921172d9fe3 100644
--- a/plugins/discourse-assign/spec/requests/list_controller_spec.rb
+++ b/plugins/discourse-assign/spec/requests/list_controller_spec.rb
@@ -293,7 +293,7 @@ describe ListController do
after { SearchIndexer.disable }
- it "returns topics as per filter for #group_topics_assigned" do
+ it "filters group-assigned topics by title" do
topic1.title = "QUnit testing is love"
topic2.title = "RSpec testing is too fun"
topic3.title = "Testing is main part of programming"
@@ -327,7 +327,7 @@ describe ListController do
)
end
- it "returns topics as per filter for #group_topics_assigned" do
+ it "filters the user's assigned messages by title" do
topic1.title = "QUnit testing is love"
topic2.title = "RSpec testing is too fun"
topic3.title = "Testing is main part of programming"
@@ -415,7 +415,7 @@ describe ListController do
fab!(:post_2) { Fabricate(:post, topic: topic_2) }
fab!(:post_3) { Fabricate(:post, topic: topic_3) }
- describe "when user cannot assign" do
+ describe "when user cannot assign and filters by username" do
it "ignores the assign filter" do
assign_allowed_group.add(user)
@@ -566,7 +566,7 @@ describe ListController do
end
end
- describe "when user cannot assign" do
+ describe "when user cannot assign and filters by assignment status" do
it "ignores the assigned:* filter" do
assign_allowed_group.add(admin)
diff --git a/plugins/discourse-assign/spec/serializers/topic_list_serializer_spec.rb b/plugins/discourse-assign/spec/serializers/topic_list_serializer_spec.rb
index 37499f0de7f..d6ecebd8161 100644
--- a/plugins/discourse-assign/spec/serializers/topic_list_serializer_spec.rb
+++ b/plugins/discourse-assign/spec/serializers/topic_list_serializer_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe TopicListSerializer do
before { assigned_topic }
- it "should include right attribute" do
+ it "includes assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(1)
end
@@ -53,7 +53,7 @@ RSpec.describe TopicListSerializer do
describe "as an admin user" do
let(:guardian) { Guardian.new(Fabricate(:admin)) }
- it "should not include the attribute" do
+ it "omits assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(nil)
end
end
@@ -61,7 +61,7 @@ RSpec.describe TopicListSerializer do
describe "as an anon user" do
let(:guardian) { Guardian.new }
- it "should not include the attribute" do
+ it "omits assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(nil)
end
end
@@ -71,7 +71,7 @@ RSpec.describe TopicListSerializer do
describe "as an anon user" do
let(:guardian) { Guardian.new }
- it "should not include the attribute" do
+ it "omits assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(nil)
end
end
@@ -80,7 +80,7 @@ RSpec.describe TopicListSerializer do
let(:admin) { Fabricate(:admin) }
let(:guardian) { Guardian.new(admin) }
- it "should include the right attribute" do
+ it "includes assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(1)
end
end
@@ -88,7 +88,7 @@ RSpec.describe TopicListSerializer do
describe "as a normal user" do
let(:guardian) { Guardian.new(Fabricate(:user)) }
- it "should not include the attribute" do
+ it "omits assigned_messages_count" do
expect(serializer.as_json[:topic_list][:assigned_messages_count]).to eq(nil)
end
end
diff --git a/plugins/discourse-cakeday/spec/jobs/migrate_date_of_birth_to_users_table_spec.rb b/plugins/discourse-cakeday/spec/jobs/migrate_date_of_birth_to_users_table_spec.rb
index 9a84d6877f3..fc0cfd48fb4 100644
--- a/plugins/discourse-cakeday/spec/jobs/migrate_date_of_birth_to_users_table_spec.rb
+++ b/plugins/discourse-cakeday/spec/jobs/migrate_date_of_birth_to_users_table_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe Jobs::MigrateDateOfBirthToUsersTable do
end
context "when custom field date is invalid" do
- it "should ignore the error" do
+ it "continues after an error" do
user.custom_fields["date_of_birth"] = "02/13/1904"
user.save!
@@ -48,7 +48,7 @@ RSpec.describe Jobs::MigrateDateOfBirthToUsersTable do
end
context "when custom field date is blank" do
- it "should remove the custom field" do
+ it "removes the custom field" do
user.custom_fields["date_of_birth"] = ""
user.save!
diff --git a/plugins/discourse-captcha/spec/services/problem_check/hcaptcha_configuration_spec.rb b/plugins/discourse-captcha/spec/services/problem_check/hcaptcha_configuration_spec.rb
index c08b389e3e9..db65d899689 100644
--- a/plugins/discourse-captcha/spec/services/problem_check/hcaptcha_configuration_spec.rb
+++ b/plugins/discourse-captcha/spec/services/problem_check/hcaptcha_configuration_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe ProblemCheck::HcaptchaConfiguration do
it { expect(check).to be_chill_about_it }
end
- context "when discourse_captcha_provider siteSetting is HCaptcha" do
+ context "when hCaptcha is enabled and configured as the provider" do
before do
SiteSetting.discourse_captcha_enabled = true
SiteSetting.discourse_captcha_provider = DiscourseCaptcha::CaptchaProvider::HCAPTCHA
@@ -47,7 +47,7 @@ RSpec.describe ProblemCheck::HcaptchaConfiguration do
end
end
- context "when discourse_captcha_provider siteSetting is HCaptcha" do
+ context "when hCaptcha is configured as the provider but disabled" do
before { SiteSetting.discourse_captcha_provider = DiscourseCaptcha::CaptchaProvider::HCAPTCHA }
describe "`hcaptcha_site_key` is not set" do
diff --git a/plugins/discourse-chat-integration/spec/helpers/helper_spec.rb b/plugins/discourse-chat-integration/spec/helpers/helper_spec.rb
index 16f76a836eb..a45524aed10 100644
--- a/plugins/discourse-chat-integration/spec/helpers/helper_spec.rb
+++ b/plugins/discourse-chat-integration/spec/helpers/helper_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
# Not testing how filters are merged here, that's done in .smart_create_rule
# We just want to make sure the commands are being interpreted correctly
- it "should add a new rule correctly" do
+ it "adds a new category rule" do
response = DiscourseChatIntegration::Helper.process_command(chan1, ["watch", category.slug])
expect(response).to eq(I18n.t("chat_integration.provider.dummy.create.created"))
@@ -37,7 +37,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(rule.tags).to eq(nil)
end
- it "should work with all four filter types" do
+ it "supports all four filter types" do
response =
DiscourseChatIntegration::Helper.process_command(chan1, ["thread", category.slug])
@@ -76,7 +76,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
context "with tags enabled" do
before { SiteSetting.tagging_enabled = true }
- it "should add a new tag rule correctly" do
+ it "adds a new tag rule" do
response =
DiscourseChatIntegration::Helper.process_command(chan1, ["watch", "tag:#{tag1.name}"])
@@ -89,7 +89,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(rule.tags).to eq([tag1.name])
end
- it "should work with a category and multiple tags" do
+ it "supports a category with multiple tags" do
response =
DiscourseChatIntegration::Helper.process_command(
chan1,
@@ -144,21 +144,21 @@ RSpec.describe DiscourseChatIntegration::Manager do
end
describe "help command" do
- it "should return the right response" do
+ it "returns the help response" do
response = DiscourseChatIntegration::Helper.process_command(chan1, ["help"])
expect(response).to eq(I18n.t("chat_integration.provider.dummy.help"))
end
end
describe "status command" do
- it "should return the right response" do
+ it "returns the channel status" do
response = DiscourseChatIntegration::Helper.process_command(chan1, ["status"])
expect(response).to eq(DiscourseChatIntegration::Helper.status_for_channel(chan1))
end
end
describe "unknown command" do
- it "should return the right response" do
+ it "returns the unknown-command response" do
response = DiscourseChatIntegration::Helper.process_command(chan1, ["somerandomtext"])
expect(response).to eq(I18n.t("chat_integration.provider.dummy.parse_error"))
end
diff --git a/plugins/discourse-chat-integration/spec/integration/automation_spec.rb b/plugins/discourse-chat-integration/spec/integration/automation_spec.rb
index 081de477f40..953af90b219 100644
--- a/plugins/discourse-chat-integration/spec/integration/automation_spec.rb
+++ b/plugins/discourse-chat-integration/spec/integration/automation_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe "Triggering notifications" do
expect(validated_provider.sent_messages.length).to eq(0)
end
- it "should not trigger a provider notification on topic creation for topic_tags_changed script" do
+ it "does not trigger a provider notification when topic_tags_changed creates a topic" do
TopicCreator.create(
admin,
Guardian.new(admin),
diff --git a/plugins/discourse-chat-integration/spec/jobs/onceoff/migrate_from_slack_official_spec.rb b/plugins/discourse-chat-integration/spec/jobs/onceoff/migrate_from_slack_official_spec.rb
index 654f3006ca6..d19976ba9d3 100644
--- a/plugins/discourse-chat-integration/spec/jobs/onceoff/migrate_from_slack_official_spec.rb
+++ b/plugins/discourse-chat-integration/spec/jobs/onceoff/migrate_from_slack_official_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
SiteSetting.create!(value: User.last.username, data_type: 1, name: "slack_discourse_username")
end
- it "should migrate the site settings correctly" do
+ it "migrates the site settings correctly" do
described_class.new.execute_onceoff({})
expect(SiteSetting.find_by(name: "slack_enabled").value).to eq("f")
@@ -49,7 +49,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
describe "when slack_discourse_username is not valid" do
before { SiteSetting.find_by(name: "slack_discourse_username").update!(value: "someguy") }
- it "should default to the system user" do
+ it "defaults to the system user" do
described_class.new.execute_onceoff({})
expect(SiteSetting.chat_integration_discourse_username).to eq(
@@ -70,7 +70,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
)
end
- it "should create the right channels and rules" do
+ it "creates the expected channels and rules" do
described_class.new.execute_onceoff({})
expect(DiscourseChatIntegration::Channel.count).to eq(2)
@@ -113,7 +113,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
)
end
- it "should discard invalid tags" do
+ it "discards invalid tags" do
described_class.new.execute_onceoff({})
rule = DiscourseChatIntegration::Rule.first
@@ -132,7 +132,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
)
end
- it "should migrate the settings correctly" do
+ it "migrates the settings correctly" do
described_class.new.execute_onceoff({})
channel = DiscourseChatIntegration::Channel.first
@@ -158,7 +158,7 @@ RSpec.describe Jobs::DiscourseChatMigrateFromSlackOfficial do
)
end
- it "should not migrate the settings" do
+ it "does not migrate the settings" do
described_class.new.execute_onceoff({})
expect(DiscourseChatIntegration::Channel.count).to eq(0)
diff --git a/plugins/discourse-chat-integration/spec/jobs/regular/notify_chats_spec.rb b/plugins/discourse-chat-integration/spec/jobs/regular/notify_chats_spec.rb
index 04a77d725be..a459190695d 100644
--- a/plugins/discourse-chat-integration/spec/jobs/regular/notify_chats_spec.rb
+++ b/plugins/discourse-chat-integration/spec/jobs/regular/notify_chats_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe PostCreator do
describe "when plugin is enabled" do
before { SiteSetting.chat_integration_enabled = true }
- it "should schedule a chat notification job" do
+ it "schedules a chat notification job" do
freeze_time Time.now.beginning_of_day
post = PostCreator.new(topic.user, raw: "Some post content", topic_id: topic.id).create!
@@ -27,7 +27,7 @@ RSpec.describe PostCreator do
describe "when plugin is not enabled" do
before { SiteSetting.chat_integration_enabled = false }
- it "should not schedule a job for chat notifications" do
+ it "does not schedule a chat notification job" do
PostCreator.new(topic.user, raw: "Some post content", topic_id: topic.id).create!
expect(Jobs::NotifyChats.jobs).to eq([])
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller_spec.rb
index e5ebe1bbe40..ae1224abbf2 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_command_controller_spec.rb
@@ -14,7 +14,7 @@ describe "Mattermost Command Controller", type: :request do
end
describe "with plugin disabled" do
- it "should return a 404" do
+ it "returns a 404" do
post "/chat-integration/mattermost/command.json"
expect(response.status).to eq(404)
end
@@ -26,7 +26,7 @@ describe "Mattermost Command Controller", type: :request do
SiteSetting.chat_integration_mattermost_enabled = false
end
- it "should return a 404" do
+ it "returns a 404" do
post "/chat-integration/mattermost/command.json"
expect(response.status).to eq(404)
end
@@ -41,7 +41,7 @@ describe "Mattermost Command Controller", type: :request do
end
describe "when forum is private" do
- it "should not redirect to login page" do
+ it "does not redirect to the login page" do
SiteSetting.login_required = true
token = "sometoken"
SiteSetting.chat_integration_mattermost_incoming_webhook_token = token
@@ -53,14 +53,14 @@ describe "Mattermost Command Controller", type: :request do
end
describe "when the token is invalid" do
- it "should raise the right error" do
+ it "returns an error for a missing token" do
post "/chat-integration/mattermost/command.json", params: { text: "help" }
expect(response.status).to eq(400)
end
end
describe "when incoming webhook token has not been set" do
- it "should raise the right error" do
+ it "returns an error for an invalid token" do
post "/chat-integration/mattermost/command.json",
params: {
text: "help",
@@ -80,7 +80,7 @@ describe "Mattermost Command Controller", type: :request do
before { SiteSetting.chat_integration_mattermost_incoming_webhook_token = token }
describe "add new rule" do
- it "should add a new rule correctly" do
+ it "adds a new rule" do
post "/chat-integration/mattermost/command.json",
params: {
text: "watch #{category.slug}",
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
index 6f9dbf2a10d..bb8545bed73 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/mattermost/mattermost_provider_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe DiscourseChatIntegration::Provider::MattermostProvider do
end
describe "when mattermost icon has been configured" do
- it "should use the right icon" do
+ it "uses the configured icon URL" do
SiteSetting.chat_integration_mattermost_icon_url = "https://specific_logo"
message = described_class.mattermost_message(post, chan1)
expect(message[:icon_url]).to eq(SiteSetting.chat_integration_mattermost_icon_url)
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_command_controller_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_command_controller_spec.rb
index 8909e932d8d..32ef5b8b1da 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_command_controller_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_command_controller_spec.rb
@@ -11,7 +11,7 @@ describe "Slack Command Controller", type: :request do
end
describe "with plugin disabled" do
- it "should return a 404" do
+ it "returns a 404 response" do
post "/chat-integration/slack/command.json"
expect(response.status).to eq(404)
end
@@ -23,7 +23,7 @@ describe "Slack Command Controller", type: :request do
SiteSetting.chat_integration_slack_enabled = false
end
- it "should return a 404" do
+ it "returns a 404 response" do
post "/chat-integration/slack/command.json"
expect(response.status).to eq(404)
end
@@ -38,7 +38,7 @@ describe "Slack Command Controller", type: :request do
end
describe "when forum is private" do
- it "should not redirect to login page" do
+ it "does not redirect to the login page" do
SiteSetting.login_required = true
token = "sometoken"
SiteSetting.chat_integration_slack_incoming_webhook_token = token
@@ -50,14 +50,14 @@ describe "Slack Command Controller", type: :request do
end
describe "when the token is invalid" do
- it "should raise the right error" do
+ it "returns an invalid-token error" do
post "/chat-integration/slack/command.json", params: { text: "help" }
expect(response.status).to eq(400)
end
end
describe "backwards compatibility with discourse-slack-official" do
- it "should return the right response" do
+ it "accepts the legacy webhook token" do
token = "secret sauce"
SiteSetting.chat_integration_slack_incoming_webhook_token = token
@@ -69,7 +69,7 @@ describe "Slack Command Controller", type: :request do
end
describe "when incoming webhook token has not been set" do
- it "should raise the right error" do
+ it "returns a missing-token error" do
post "/chat-integration/slack/command.json", params: { text: "help", token: "some token" }
expect(response.status).to eq(403)
@@ -85,7 +85,7 @@ describe "Slack Command Controller", type: :request do
before { SiteSetting.chat_integration_slack_incoming_webhook_token = token }
describe "add new rule" do
- it "should add a new rule correctly" do
+ it "adds a new Slack rule" do
post "/chat-integration/slack/command.json",
params: {
text: "watch #{category.slug}",
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_message_formatter_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_message_formatter_spec.rb
index f621b5884b0..f32f45e3f18 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_message_formatter_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_message_formatter_spec.rb
@@ -3,14 +3,14 @@
RSpec.describe DiscourseChatIntegration::Provider::SlackProvider::SlackMessageFormatter do
describe ".format" do
context "with links" do
- it "should return the right message" do
+ it "returns the expected message" do
expect(described_class.format("<a href='http://somepath.com'>test</a>")).to eq(
"<http://somepath.com|test>",
)
end
describe "when text contains a link with an incomplete URL" do
- it "should return the right message" do
+ it "returns the expected message" do
expect(described_class.format("test <a href='//localhost:3000/some/path'></a>")).to eq(
"test <http://localhost:3000/some/path|>",
)
@@ -23,7 +23,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider::SlackMessageFo
end
end
- it "should not raise an error with unparseable urls" do
+ it "does not raise an error for unparseable URLs" do
expect(described_class.format("<a>test</a>")).to eq("<test.localhost|test>")
end
end
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
index 3b01fc75d54..4c41e7986a1 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/slack/slack_provider_spec.rb
@@ -7,13 +7,13 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
describe "when post contains emoijs" do
before { post.update!(raw: ":slight_smile: This is a test") }
- it "should return the right excerpt" do
+ it "returns the post excerpt" do
expect(described_class.excerpt(post)).to eq("🙂 This is a test")
end
end
describe "when post contains onebox" do
- it "should return the right excerpt" do
+ it "returns an excerpt without the onebox" do
post.update!(cooked: <<~COOKED)
<aside class=\"onebox whitelistedgeneric\">
<header class=\"source\">
@@ -47,7 +47,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
end
describe "when post contains an email" do
- it "should return the right excerpt" do
+ it "returns an excerpt containing the email address" do
post.update!(cooked: <<~COOKED)
The address is <a href=\"mailto:[email protected]\">my email</a>
COOKED
@@ -282,7 +282,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
end
describe ".create_slack_message" do
- it "should work with a simple message" do
+ it "creates a simple Slack message" do
content = "Simple message"
url = "http://example.com"
message = { channel: "#general", username: "Discourse", content: "#{content} - #{url}" }
@@ -303,7 +303,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
).to eq(message)
end
- it "should do the replacements" do
+ it "replaces the topic placeholders" do
topic = Fabricate(:topic)
topic.posts << Fabricate(:post, topic: topic)
tag1, tag2, tag3, tag4 = [Fabricate(:tag), Fabricate(:tag), Fabricate(:tag), Fabricate(:tag)]
@@ -330,7 +330,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
expect(text).to include("<#{tag3.full_url}|#{tag3.name}>, <#{tag4.full_url}|#{tag4.name}>")
end
- it "should do the replacements for ${ADDED_AND_REMOVED}" do
+ it "replaces the combined added-and-removed placeholder" do
topic = Fabricate(:topic)
topic.posts << Fabricate(:post, topic: topic)
tag1, tag2 = [Fabricate(:tag), Fabricate(:tag)]
@@ -397,7 +397,7 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider do
)
end
- it "should raise errors if tags are not present but uses in content" do
+ it "raises an error when tag placeholders lack tag data" do
topic = Fabricate(:topic)
topic.posts << Fabricate(:post, topic: topic)
content = "This should not work ${ADDED_TAGS}"
diff --git a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb
index 0dfa6def309..a31b32409f7 100644
--- a/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb
+++ b/plugins/discourse-chat-integration/spec/lib/discourse_chat_integration/provider/telegram/telegram_command_controller_spec.rb
@@ -18,7 +18,7 @@ describe "Telegram Command Controller", type: :request do
end
describe "with plugin disabled" do
- it "should return a 404" do
+ it "returns a 404" do
post "/chat-integration/telegram/command/abcd.json"
expect(response.status).to eq(404)
end
@@ -30,7 +30,7 @@ describe "Telegram Command Controller", type: :request do
SiteSetting.chat_integration_telegram_enabled = false
end
- it "should return a 404" do
+ it "returns a 404" do
post "/chat-integration/telegram/command/abcd.json"
expect(response.status).to eq(404)
end
@@ -51,7 +51,7 @@ describe "Telegram Command Controller", type: :request do
end
describe "when forum is private" do
- it "should not redirect to login page" do
+ it "does not redirect to the login page" do
SiteSetting.login_required = true
post "/chat-integration/telegram/command/shhh.json",
@@ -69,7 +69,7 @@ describe "Telegram Command Controller", type: :request do
end
describe "when the token is invalid" do
- it "should raise the right error" do
+ it "rejects an invalid command token" do
post "/chat-integration/telegram/command/blah.json",
params: {
message: {
@@ -85,7 +85,7 @@ describe "Telegram Command Controller", type: :request do
end
describe "when token has not been set" do
- it "should raise the right error" do
+ it "rejects commands when the access token is missing" do
SiteSetting.chat_integration_telegram_access_token = ""
post "/chat-integration/telegram/command/blah.json",
params: {
@@ -107,7 +107,7 @@ describe "Telegram Command Controller", type: :request do
before { SiteSetting.chat_integration_telegram_enable_slash_commands = true }
describe "add new rule" do
- it "should add a new rule correctly" do
+ it "adds a new rule" do
post "/chat-integration/telegram/command/shhh.json",
params: {
message: {
@@ -128,7 +128,7 @@ describe "Telegram Command Controller", type: :request do
expect(rule.tags).to eq(nil)
end
- it "should add a new rule correctly using group chat syntax" do
+ it "adds a new rule using group chat syntax" do
post "/chat-integration/telegram/command/shhh.json",
params: {
message: {
@@ -167,7 +167,7 @@ describe "Telegram Command Controller", type: :request do
end
end
- it "should respond only to a specific command in a broadcast channel" do
+ it "responds only to a specific command in a broadcast channel" do
post "/chat-integration/telegram/command/shhh.json",
params: {
channel_post: {
diff --git a/plugins/discourse-chat-integration/spec/models/channel_spec.rb b/plugins/discourse-chat-integration/spec/models/channel_spec.rb
index 9b8c33ea7db..766a30d0452 100644
--- a/plugins/discourse-chat-integration/spec/models/channel_spec.rb
+++ b/plugins/discourse-chat-integration/spec/models/channel_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe DiscourseChatIntegration::Channel do
include_context "with dummy provider"
include_context "with validated dummy provider"
- it "should save and load successfully" do
+ it "saves and loads successfully" do
expect(DiscourseChatIntegration::Channel.all.length).to eq(0)
chan = DiscourseChatIntegration::Channel.create(provider: "dummy")
@@ -18,7 +18,7 @@ RSpec.describe DiscourseChatIntegration::Channel do
expect(loadedChan.provider).to eq("dummy")
end
- it "should edit successfully" do
+ it "edits successfully" do
channel = DiscourseChatIntegration::Channel.create!(provider: "dummy2", data: { val: "hello" })
expect(channel.valid?).to eq(true)
channel.save!
diff --git a/plugins/discourse-chat-integration/spec/models/rule_spec.rb b/plugins/discourse-chat-integration/spec/models/rule_spec.rb
index 18e4b2353f7..9f2275cebb2 100644
--- a/plugins/discourse-chat-integration/spec/models/rule_spec.rb
+++ b/plugins/discourse-chat-integration/spec/models/rule_spec.rb
@@ -13,20 +13,20 @@ RSpec.describe DiscourseChatIntegration::Rule do
let(:group) { Fabricate(:group) }
describe ".alloc_key" do
- it "should return sequential numbers" do
+ it "returns sequential rule numbers" do
expect(DiscourseChatIntegration::Rule.create(channel: channel).key).to eq("rule:1")
expect(DiscourseChatIntegration::Rule.create(channel: channel).key).to eq("rule:2")
expect(DiscourseChatIntegration::Rule.create(channel: channel).key).to eq("rule:3")
end
end
- it "should convert between channel and channel_id successfully" do
+ it "resolves the channel and its ID" do
rule = DiscourseChatIntegration::Rule.create(channel: channel)
expect(rule.channel_id).to eq(channel.id)
expect(rule.channel.id).to eq(channel.id)
end
- it "should save and load successfully" do
+ it "saves and loads the rule" do
expect(DiscourseChatIntegration::Rule.all.length).to eq(0)
rule =
diff --git a/plugins/discourse-chat-integration/spec/requests/chat_controller_spec.rb b/plugins/discourse-chat-integration/spec/requests/chat_controller_spec.rb
index adeba586693..9b0859e8f97 100644
--- a/plugins/discourse-chat-integration/spec/requests/chat_controller_spec.rb
+++ b/plugins/discourse-chat-integration/spec/requests/chat_controller_spec.rb
@@ -20,14 +20,14 @@ RSpec.describe "Chat Controller", type: :request do
shared_examples "admin constraints" do |action, route|
context "when user is not signed in" do
- it "should raise the right error" do
+ it "raises the expected error" do
public_send(action, route)
expect(response.status).to eq(404)
end
end
context "when user is not an admin" do
- it "should raise the right error" do
+ it "raises the expected error" do
sign_in(Fabricate(:user))
public_send(action, route)
expect(response.status).to eq(404)
@@ -43,7 +43,7 @@ RSpec.describe "Chat Controller", type: :request do
context "when signed in as an admin" do
before { sign_in(admin) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/admin/plugins/discourse-chat-integration/providers.json"
expect(response.status).to eq(200)
@@ -300,7 +300,7 @@ RSpec.describe "Chat Controller", type: :request do
context "when signed in as an admin" do
before { sign_in(admin) }
- it "should return the right response" do
+ it "returns the expected response" do
post "/admin/plugins/discourse-chat-integration/test.json",
params: {
channel_id: channel.id,
@@ -310,7 +310,7 @@ RSpec.describe "Chat Controller", type: :request do
expect(response.status).to eq(200)
end
- it "should fail for invalid channel" do
+ it "fails for an invalid channel" do
post "/admin/plugins/discourse-chat-integration/test.json",
params: {
channel_id: 999,
@@ -330,7 +330,7 @@ RSpec.describe "Chat Controller", type: :request do
context "when signed in as an admin" do
before { sign_in(admin) }
- it "should return the right response" do
+ it "returns the expected response" do
rule =
DiscourseChatIntegration::Rule.create(
channel: channel,
@@ -369,7 +369,7 @@ RSpec.describe "Chat Controller", type: :request do
)
end
- it "should fail for invalid provider" do
+ it "fails for an invalid provider" do
get "/admin/plugins/discourse-chat-integration/channels.json",
params: {
provider: "someprovider",
@@ -387,7 +387,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able to add a new channel" do
+ it "adds a new channel" do
post "/admin/plugins/discourse-chat-integration/channels.json",
params: {
channel: {
@@ -404,7 +404,7 @@ RSpec.describe "Chat Controller", type: :request do
expect(channel.provider).to eq("dummy")
end
- it "should fail for invalid params" do
+ it "fails for invalid parameters" do
post "/admin/plugins/discourse-chat-integration/channels.json",
params: {
channel: {
@@ -432,7 +432,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able update a channel" do
+ it "updates a channel" do
put "/admin/plugins/discourse-chat-integration/channels/#{channel.id}.json",
params: {
channel: {
@@ -448,7 +448,7 @@ RSpec.describe "Chat Controller", type: :request do
expect(channel.data).to eq("val" => "something-else")
end
- it "should fail for invalid params" do
+ it "fails for invalid parameters" do
put "/admin/plugins/discourse-chat-integration/channels/#{channel.id}.json",
params: {
channel: {
@@ -473,7 +473,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able delete a channel" do
+ it "deletes a channel" do
delete "/admin/plugins/discourse-chat-integration/channels/#{channel.id}.json"
expect(response.status).to eq(200)
@@ -490,7 +490,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able to add a new rule" do
+ it "adds a new rule" do
post "/admin/plugins/discourse-chat-integration/rules.json",
params: {
rule: {
@@ -511,7 +511,7 @@ RSpec.describe "Chat Controller", type: :request do
expect(rule.tags).to eq([tag.name])
end
- it "should fail for invalid params" do
+ it "fails for invalid parameters" do
post "/admin/plugins/discourse-chat-integration/rules.json",
params: {
rule: {
@@ -544,7 +544,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able update a rule" do
+ it "updates a rule" do
put "/admin/plugins/discourse-chat-integration/rules/#{rule.id}.json",
params: {
rule: {
@@ -561,7 +561,7 @@ RSpec.describe "Chat Controller", type: :request do
expect(rule.category_id).to eq(category2.id)
end
- it "should fail for invalid params" do
+ it "fails for invalid parameters" do
put "/admin/plugins/discourse-chat-integration/rules/#{rule.id}.json",
params: {
rule: {
@@ -594,7 +594,7 @@ RSpec.describe "Chat Controller", type: :request do
context "as an admin" do
before { sign_in(admin) }
- it "should be able delete a rule" do
+ it "deletes a rule" do
delete "/admin/plugins/discourse-chat-integration/rules/#{rule.id}.json"
expect(response.status).to eq(200)
diff --git a/plugins/discourse-chat-integration/spec/requests/public_controller_spec.rb b/plugins/discourse-chat-integration/spec/requests/public_controller_spec.rb
index 5f5c187485f..a789bd4a44f 100644
--- a/plugins/discourse-chat-integration/spec/requests/public_controller_spec.rb
+++ b/plugins/discourse-chat-integration/spec/requests/public_controller_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "Public Controller", type: :request do
before { SiteSetting.chat_integration_enabled = true }
describe "loading a transcript" do
- it "should be able to load a transcript" do
+ it "loads a saved transcript" do
key = DiscourseChatIntegration::Helper.save_transcript("Some content here")
get "/chat-transcript/#{key}.json"
@@ -14,7 +14,7 @@ RSpec.describe "Public Controller", type: :request do
expect(response.body).to eq('{"content":"Some content here"}')
end
- it "should 404 for non-existent transcript" do
+ it "returns 404 for a missing transcript" do
key = "abcdefghijk"
get "/chat-transcript/#{key}.json"
diff --git a/plugins/discourse-chat-integration/spec/services/manager_spec.rb b/plugins/discourse-chat-integration/spec/services/manager_spec.rb
index c5180429272..d56d3fd4d59 100644
--- a/plugins/discourse-chat-integration/spec/services/manager_spec.rb
+++ b/plugins/discourse-chat-integration/spec/services/manager_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
SiteSetting.dummy_provider_enabled = true
end
- it "should fail gracefully when a provider throws an exception" do
+ it "continues when a provider raises an exception" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "watch",
@@ -54,7 +54,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(DiscourseChatIntegration::Channel.all.first.error_key.nil?).to be true
end
- it "should not send notifications when provider is disabled" do
+ it "does not notify a disabled provider" do
SiteSetting.dummy_provider_enabled = false
DiscourseChatIntegration::Rule.create!(
channel: chan1,
@@ -67,7 +67,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly
end
- it "should send a notification to watched and following channels for new topic" do
+ it "notifies watched and followed channels about a new topic" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "watch",
@@ -89,7 +89,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id, chan2.id)
end
- it "should send a notification only to watched for reply" do
+ it "notifies only watched channels about a reply" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "watch",
@@ -111,7 +111,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should respect wildcard category settings" do
+ it "applies wildcard category rules" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "watch", category_id: nil)
manager.trigger_notifications(first_post.id)
@@ -119,7 +119,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should respect mute over watch" do
+ it "gives mute rules precedence over watch rules" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "watch", category_id: nil) # Wildcard watch
DiscourseChatIntegration::Rule.create!(
channel: chan1,
@@ -132,7 +132,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly
end
- it "should respect watch over follow" do
+ it "gives watch rules precedence over follow rules" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "follow", category_id: nil) # Wildcard follow
DiscourseChatIntegration::Rule.create!(
channel: chan1,
@@ -145,7 +145,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should respect thread over watch" do
+ it "gives thread rules precedence over watch rules" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "watch", category_id: nil) # Wildcard watch
DiscourseChatIntegration::Rule.create!(
channel: chan1,
@@ -158,7 +158,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should not notify about private messages" do
+ it "does not notify about private messages" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "follow", category_id: nil) # Wildcard watch
private_post = Fabricate(:private_message_post)
@@ -168,7 +168,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly
end
- it "should work for group pms" do
+ it "notifies eligible group private messages" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "watch") # Wildcard watch
DiscourseChatIntegration::Rule.create!(
channel: chan2,
@@ -185,7 +185,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan2.id)
end
- it "should work for pms with multiple groups" do
+ it "notifies private messages shared with multiple groups" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
type: "group_message",
@@ -208,7 +208,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id, chan2.id)
end
- it "should work for group mentions" do
+ it "notifies group mentions" do
third_post =
Fabricate(:post, topic: topic, post_number: 3, raw: "let's mention @#{group.name}")
@@ -230,7 +230,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id, chan3.id)
end
- it "should give group rule precedence over normal rules" do
+ it "gives group rules precedence over normal rules" do
third_post =
Fabricate(:post, topic: topic, post_number: 3, raw: "let's mention @#{group.name}")
@@ -252,7 +252,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should not notify about mentions in private messages" do
+ it "does not notify about mentions in private messages" do
# Group 1 watching for messages on channel 1
DiscourseChatIntegration::Rule.create!(
channel: chan1,
@@ -286,7 +286,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
end
- it "should not notify about posts the chat_user cannot see" do
+ it "does not notify about posts hidden from the chat user" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "follow", category_id: nil) # Wildcard watch
# Create a group & user
@@ -326,7 +326,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
before(:each) { SiteSetting.tagging_enabled = true }
- it "should still work for rules without any tags specified" do
+ it "matches rules without specified tags" do
DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "follow", category_id: nil) # Wildcard watch
manager.trigger_notifications(first_post.id)
@@ -335,7 +335,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id, chan1.id)
end
- it "should only match tagged topics when rule has tags" do
+ it "only matches tagged topics when a rule specifies tags" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "follow",
@@ -356,7 +356,7 @@ RSpec.describe DiscourseChatIntegration::Manager do
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
end
- it "should notify about category changes" do
+ it "notifies about category changes" do
DiscourseChatIntegration::Rule.create!(
channel: chan1,
filter: "watch",
diff --git a/plugins/discourse-data-explorer/spec/data_explorer_spec.rb b/plugins/discourse-data-explorer/spec/data_explorer_spec.rb
index 4068091b940..6ea489e9868 100644
--- a/plugins/discourse-data-explorer/spec/data_explorer_spec.rb
+++ b/plugins/discourse-data-explorer/spec/data_explorer_spec.rb
@@ -76,7 +76,7 @@ describe DiscourseDataExplorer::DataExplorer do
describe ".run_query" do
fab!(:topic)
- it "should run a query that includes PG template patterns" do
+ it "runs a query that includes PostgreSQL template patterns" do
sql = <<~SQL
WITH query AS (
SELECT TO_CHAR(created_at, 'yyyy:mm:dd') AS date FROM topics
@@ -91,7 +91,7 @@ describe DiscourseDataExplorer::DataExplorer do
expect(result[:pg_result][0]["date"]).to eq(topic.created_at.strftime("%Y:%m:%d"))
end
- it "should run a query containing a question mark in the comment" do
+ it "runs a query containing a question mark in a comment" do
sql = <<~SQL
WITH query AS (
SELECT id FROM topics -- some SQL ? comment ?
diff --git a/plugins/discourse-data-explorer/spec/jobs/scheduled/delete_hidden_queries_spec.rb b/plugins/discourse-data-explorer/spec/jobs/scheduled/delete_hidden_queries_spec.rb
index fe99faf7c91..f06e5e3f0e1 100644
--- a/plugins/discourse-data-explorer/spec/jobs/scheduled/delete_hidden_queries_spec.rb
+++ b/plugins/discourse-data-explorer/spec/jobs/scheduled/delete_hidden_queries_spec.rb
@@ -6,7 +6,7 @@ describe Jobs::DeleteHiddenQueries do
SiteSetting.data_explorer_enabled = true
end
- it "will correctly destroy old hidden queries" do
+ it "destroys old hidden queries" do
DiscourseDataExplorer::Query.create!(
id: 1,
name: "A",
diff --git a/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb b/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
index 89e049134bd..6fc7bd72fff 100644
--- a/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
+++ b/plugins/discourse-data-explorer/spec/lib/parameter_spec.rb
@@ -138,7 +138,7 @@ RSpec.describe DiscourseDataExplorer::Parameter do
end
describe ".create_from_sql" do
- it "should not validate default value" do
+ it "does not validate the default value" do
TEST_SQL = <<~SQL
-- [params]
-- user_id :user_id = user_not_exists
diff --git a/plugins/discourse-data-explorer/spec/lib/query_runner_spec.rb b/plugins/discourse-data-explorer/spec/lib/query_runner_spec.rb
index ae3665cba83..7798a4a1c09 100644
--- a/plugins/discourse-data-explorer/spec/lib/query_runner_spec.rb
+++ b/plugins/discourse-data-explorer/spec/lib/query_runner_spec.rb
@@ -27,7 +27,7 @@ describe DiscourseDataExplorer::QueryRunner do
described_class.invalidate(query_with_internal_params.id)
end
- describe ".run" do
+ describe ".run caching behavior" do
it "runs the query and returns results" do
result = described_class.run(query, nil, current_user: admin)
@@ -110,7 +110,7 @@ describe DiscourseDataExplorer::QueryRunner do
end
end
- describe ".run" do
+ describe ".run limit handling" do
it "does not cache when a non-default limit is used" do
described_class.run(query, nil, current_user: admin, limit: 1)
diff --git a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
index a8465f89fa8..89c19ce0dbb 100644
--- a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
+++ b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb
@@ -518,7 +518,7 @@ describe DiscourseDataExplorer::QueryController do
create_post
end
- it "should limit the results in JSON response" do
+ it "limits the results in the JSON response" do
SiteSetting.data_explorer_query_result_limit = 2
query = make_query <<~SQL
SELECT id FROM posts
@@ -540,7 +540,7 @@ describe DiscourseDataExplorer::QueryController do
expect(response.status).to eq(400)
end
- it "should limit the results in CSV download" do
+ it "limits the results in the CSV download" do
query = make_query <<~SQL
SELECT id FROM posts
SQL
@@ -1187,7 +1187,7 @@ describe DiscourseDataExplorer::QueryController do
end
end
- describe "Admin" do
+ describe "Admin AI query generation" do
fab!(:admin)
before do
diff --git a/plugins/discourse-data-explorer/spec/system/query_editor_resize_spec.rb b/plugins/discourse-data-explorer/spec/system/query_editor_resize_spec.rb
index 16ab5b6cc19..7946391c128 100644
--- a/plugins/discourse-data-explorer/spec/system/query_editor_resize_spec.rb
+++ b/plugins/discourse-data-explorer/spec/system/query_editor_resize_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe "Data explorer query editor resizing" do
try_until_success { expect(query_runner.pane_overflow).to eq(0) }
end
- it "will not shrink the panes past the content they clip" do
+ it "does not shrink the panes past the content they clip" do
in_the_stacked_layout do
query_runner.visit_admin_query(query.id)
expect(page).to have_css(".query-editor .panels-flex")
@@ -32,7 +32,7 @@ RSpec.describe "Data explorer query editor resizing" do
end
end
- it "will not shrink past the shorter content left when the schema is hidden" do
+ it "does not shrink past the shorter content left when the schema is hidden" do
in_the_stacked_layout do
query_runner.visit_admin_query(query.id)
expect(page).to have_css(".query-editor .panels-flex")
diff --git a/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb b/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb
index 27be6319aef..5a7c4e60932 100644
--- a/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb
+++ b/plugins/discourse-data-explorer/spec/tasks/data_explorer_spec.rb
@@ -59,7 +59,7 @@ describe "Data Explorer rake tasks" do
end
context "when query does not exist in PluginStore" do
- it "should not hide the query" do
+ it "does not hide the query" do
DiscourseDataExplorer::Query.destroy_all
make_query("SELECT 1 as value", id: 1, name: "A")
make_query("SELECT 1 as value", id: 2, name: "B")
@@ -108,7 +108,7 @@ describe "Data Explorer rake tasks" do
end
context "when query does not exist in PluginStore" do
- it "should not unhide the query" do
+ it "does not unhide the query" do
DiscourseDataExplorer::Query.destroy_all
make_query("SELECT 1 as value", id: 1, name: "A", hidden: true)
make_query("SELECT 1 as value", id: 2, name: "B", hidden: true)
@@ -157,7 +157,7 @@ describe "Data Explorer rake tasks" do
end
context "when query does not exist in PluginStore" do
- it "should not hard delete the query" do
+ it "does not hard-delete the query" do
DiscourseDataExplorer::Query.destroy_all
make_query("SELECT 1 as value", id: 1, name: "A", hidden: true)
make_query("SELECT 1 as value", id: 2, name: "B", hidden: true)
@@ -172,7 +172,7 @@ describe "Data Explorer rake tasks" do
end
context "when query is not hidden" do
- it "should not hard delete the query" do
+ it "does not hard-delete the query" do
DiscourseDataExplorer::Query.destroy_all
make_query("SELECT 1 as value", id: 1, name: "A")
# rake data_explorer:hard_delete[1] => try to hard delete query with ID 1
diff --git a/plugins/discourse-events/spec/lib/discourse_events/events/chat_channel_sync_spec.rb b/plugins/discourse-events/spec/lib/discourse_events/events/chat_channel_sync_spec.rb
index a93d590c78f..30dc5370f13 100644
--- a/plugins/discourse-events/spec/lib/discourse_events/events/chat_channel_sync_spec.rb
+++ b/plugins/discourse-events/spec/lib/discourse_events/events/chat_channel_sync_spec.rb
@@ -23,7 +23,7 @@ describe DiscourseEvents::Events::ChatChannelSync do
expect(event.chat_channel.user_chat_channel_memberships.count).to eq(2)
end
- it "will simply do nothing if user has no permission to create channel" do
+ it "does nothing when the user cannot create a channel" do
post = Fabricate(:post, user: user)
event = Fabricate(:event, chat_enabled: true, post: post)
diff --git a/plugins/discourse-events/spec/requests/events_controller_spec.rb b/plugins/discourse-events/spec/requests/events_controller_spec.rb
index 25f6a7acb7d..d5d7e175d0d 100644
--- a/plugins/discourse-events/spec/requests/events_controller_spec.rb
+++ b/plugins/discourse-events/spec/requests/events_controller_spec.rb
@@ -10,7 +10,7 @@ module DiscourseEvents::Events
end
describe "#index" do
- it "should not result in N+1 queries problem when multiple events are returned" do
+ it "avoids N+1 queries when returning multiple events" do
# Warmup
get "/discourse-post-event/events.json"
@@ -30,7 +30,7 @@ module DiscourseEvents::Events
expect(queries_with_3_events.count).to eq(queries_with_1_event.count)
end
- it "should not show deleted events" do
+ it "excludes deleted events" do
active_event1 = Fabricate(:event, original_starts_at: 1.day.from_now)
active_event2 = Fabricate(:event, original_starts_at: 2.days.from_now)
deleted_event =
@@ -45,7 +45,7 @@ module DiscourseEvents::Events
expect(event_ids).to match_array([active_event1.id, active_event2.id])
end
- it "should not show closed events" do
+ it "excludes closed events" do
active_event1 = Fabricate(:event, original_starts_at: 1.day.from_now)
active_event2 = Fabricate(:event, original_starts_at: 2.days.from_now)
closed_event = Fabricate(:event, original_starts_at: 3.days.from_now, closed: true)
@@ -160,7 +160,7 @@ module DiscourseEvents::Events
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(private_event.id)
end
- it "should return events in ics format" do
+ it "returns events in ICS format" do
event1 = Fabricate(:event, original_starts_at: 1.day.from_now, name: "Test Event 1")
event2 = Fabricate(:event, original_starts_at: 2.days.from_now, name: "Test Event 2")
@@ -190,7 +190,7 @@ module DiscourseEvents::Events
expect(body).to include("SUMMARY:Test Event 2")
end
- it "should include location and description in ics format" do
+ it "includes the location and description in ICS format" do
event =
Fabricate(
:event,
@@ -247,7 +247,7 @@ module DiscourseEvents::Events
expect(response.body).not_to match(/^X-INJECTED:evil$/)
end
- it "should not HTML-encode ampersands in ics format" do
+ it "does not HTML-encode ampersands in ICS format" do
Fabricate(
:event,
original_starts_at: 1.day.from_now,
@@ -263,7 +263,7 @@ module DiscourseEvents::Events
expect(response.body).not_to include("&amp;")
end
- it "should not HTML-encode topic title used as ics summary" do
+ it "does not HTML-encode the topic title used as the ICS summary" do
event = Fabricate(:event, original_starts_at: 1.day.from_now)
event.post.topic.update!(title: "Rock & Roll Music Festival 2026")
@@ -272,7 +272,7 @@ module DiscourseEvents::Events
expect(response.body).to include("SUMMARY:Rock & Roll Music Festival 2026")
end
- it "should handle events without location and description in ics format" do
+ it "handles ICS events without a location or description" do
event = Fabricate(:event, original_starts_at: 1.day.from_now, name: "Simple Event")
get "/discourse-post-event/events.ics"
@@ -285,7 +285,7 @@ module DiscourseEvents::Events
expect(body).to include("END:VEVENT")
end
- it "should include post url in description when no custom description is set" do
+ it "includes the post URL when no custom description is set" do
event =
Fabricate(:event, original_starts_at: 1.day.from_now, name: "Event Without Description")
diff --git a/plugins/discourse-events/spec/system/livestream_calendar_event_spec.rb b/plugins/discourse-events/spec/system/livestream_calendar_event_spec.rb
index d22b20a3ff8..9215cac6275 100644
--- a/plugins/discourse-events/spec/system/livestream_calendar_event_spec.rb
+++ b/plugins/discourse-events/spec/system/livestream_calendar_event_spec.rb
@@ -49,7 +49,7 @@ describe "Discourse Livestream - Topic Livestream with events - Authenticated" d
expect(topic_page).to have_css("body.confirmed-event-assistance", wait: 25)
end
- it "clicks going to join the chat channel for livestream topics" do
+ it "toggles attendance for a normal event" do
topic_livestream.create_normal_event_topic(composer, topic_page)
find(".going-button", wait: 25).click
diff --git a/plugins/discourse-events/spec/system/upcoming_events_spec.rb b/plugins/discourse-events/spec/system/upcoming_events_spec.rb
index 1da58ea866b..4dcb2c66b8d 100644
--- a/plugins/discourse-events/spec/system/upcoming_events_spec.rb
+++ b/plugins/discourse-events/spec/system/upcoming_events_spec.rb
@@ -234,7 +234,7 @@ describe "Upcoming Events" do
end
end
- describe "recurring events" do
+ describe "recurring events shown in local time" do
describe "with local time enabled" do
it "displays multiple occurrences with correct local time",
timezone: "Australia/Brisbane",
@@ -367,7 +367,7 @@ describe "Upcoming Events" do
end
end
- describe "recurring events" do
+ describe "recurring events with an end date" do
it "displays recurring events until the specified end date",
time: Time.utc(2025, 6, 2, 19, 00) do
post =
diff --git a/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb b/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb
index cb6091994a5..2ee8d7c6e4e 100644
--- a/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb
+++ b/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb
@@ -11,7 +11,7 @@ describe Jobs::UpdateStaleLeaderboardPositions do
end
let(:leaderboard_positions) { DiscourseGamification::LeaderboardCachedView.new(leaderboard) }
- it "it updates all stale leaderboard positions" do
+ it "updates all stale leaderboard positions" do
DiscourseGamification::LeaderboardCachedView.new(leaderboard).create
expect(leaderboard_positions.scores.length).to eq(1)
diff --git a/plugins/discourse-gamification/spec/plugin_spec.rb b/plugins/discourse-gamification/spec/plugin_spec.rb
index cccfa02e4f3..a203a2ea35d 100644
--- a/plugins/discourse-gamification/spec/plugin_spec.rb
+++ b/plugins/discourse-gamification/spec/plugin_spec.rb
@@ -1,36 +1,38 @@
# frozen_string_literal: true
describe DiscourseGamification do
- fab!(:user)
- fab!(:leaderboard, :gamification_leaderboard)
+ context "with the user card integration" do
+ fab!(:user)
+ fab!(:leaderboard, :gamification_leaderboard)
- it "adds gamification_score to the UserCardSerializer" do
- serializer = UserCardSerializer.new(user)
- expect(serializer).to respond_to(:gamification_score)
- end
+ it "adds gamification_score to the UserCardSerializer" do
+ serializer = UserCardSerializer.new(user)
+ expect(serializer).to respond_to(:gamification_score)
+ end
- context "with leaderboard positions" do
- before { SiteSetting.discourse_gamification_enabled = true }
+ context "with leaderboard positions" do
+ before { SiteSetting.discourse_gamification_enabled = true }
- it "enqueues job to regenerate leaderboard positions for score ranking strategy changes" do
- expect do SiteSetting.score_ranking_strategy = "row_number" end.to change {
- Jobs::RegenerateLeaderboardPositions.jobs.size
- }.by(1)
+ it "enqueues job to regenerate leaderboard positions for score ranking strategy changes" do
+ expect do SiteSetting.score_ranking_strategy = "row_number" end.to change {
+ Jobs::RegenerateLeaderboardPositions.jobs.size
+ }.by(1)
+ end
end
end
-end
-describe DiscourseGamification do
- let(:guardian) { Guardian.new }
- let!(:default_gamification_leaderboard) { Fabricate(:gamification_leaderboard) }
-
- it "adds default_gamification_leaderboard_id to the SiteSettingSerializer" do
- site = Site.new(guardian)
- serializer = SiteSerializer.new(site)
- expect(serializer).to respond_to(:default_gamification_leaderboard_id)
- expect(serializer.default_gamification_leaderboard_id).to eq(
- default_gamification_leaderboard.id,
- )
+ context "with the site settings integration" do
+ let(:guardian) { Guardian.new }
+ let!(:default_gamification_leaderboard) { Fabricate(:gamification_leaderboard) }
+
+ it "adds default_gamification_leaderboard_id to the SiteSettingSerializer" do
+ site = Site.new(guardian)
+ serializer = SiteSerializer.new(site)
+ expect(serializer).to respond_to(:default_gamification_leaderboard_id)
+ expect(serializer.default_gamification_leaderboard_id).to eq(
+ default_gamification_leaderboard.id,
+ )
+ end
end
end
diff --git a/plugins/discourse-github/spec/jobs/create_github_linkback_spec.rb b/plugins/discourse-github/spec/jobs/create_github_linkback_spec.rb
index 5fab4a86ced..912fdb41e60 100644
--- a/plugins/discourse-github/spec/jobs/create_github_linkback_spec.rb
+++ b/plugins/discourse-github/spec/jobs/create_github_linkback_spec.rb
@@ -6,7 +6,7 @@ describe Jobs::CreateGithubLinkback do
SiteSetting.github_linkback_enabled = true
end
- it "shouldn't raise error if post not found" do
+ it "does not raise an error when the post is missing" do
post = Fabricate(:post)
post.destroy!
expect { Jobs::CreateGithubLinkback.new.execute(post_id: post.id) }.not_to raise_error
diff --git a/plugins/discourse-github/spec/lib/github_linkback_access_token_setting_validator_spec.rb b/plugins/discourse-github/spec/lib/github_linkback_access_token_setting_validator_spec.rb
index 64a98ec1a97..c111fe91977 100644
--- a/plugins/discourse-github/spec/lib/github_linkback_access_token_setting_validator_spec.rb
+++ b/plugins/discourse-github/spec/lib/github_linkback_access_token_setting_validator_spec.rb
@@ -16,7 +16,7 @@ describe GithubLinkbackAccessTokenSettingValidator do
)
end
- it "should fail" do
+ it "rejects the token" do
expect(validator.valid_value?(value)).to eq(false)
end
end
@@ -29,13 +29,13 @@ describe GithubLinkbackAccessTokenSettingValidator do
)
end
- it "should fail" do
+ it "rejects the token" do
expect(validator.valid_value?(value)).to eq(false)
end
end
context "when the token is accepted" do
- it "should pass, without repos defined" do
+ it "accepts the token when no repositories are defined" do
expect(validator.valid_value?(value)).to eq(true)
end
@@ -48,7 +48,7 @@ describe GithubLinkbackAccessTokenSettingValidator do
)
end
- it "should pass if all the repos are accessible" do
+ it "accepts the token when all repositories are accessible" do
expect(validator.valid_value?(value)).to eq(true)
end
end
diff --git a/plugins/discourse-github/spec/lib/github_linkback_spec.rb b/plugins/discourse-github/spec/lib/github_linkback_spec.rb
index 783dd46ce25..0a2fcdd5a96 100644
--- a/plugins/discourse-github/spec/lib/github_linkback_spec.rb
+++ b/plugins/discourse-github/spec/lib/github_linkback_spec.rb
@@ -171,7 +171,7 @@ describe GithubLinkback do
expect(links.size).to eq(0)
end
- it "should return the urls for the selected projects" do
+ it "returns the URLs for the selected projects" do
SiteSetting.github_linkback_projects =
"discourse/discourse|eviltrout/ember-performance|discourse/*"
links = GithubLinkback.new(post).github_links
@@ -273,21 +273,21 @@ describe GithubLinkback do
expect(post.custom_fields[field]).to be_present
end
- it "should create linkback for <= SiteSetting.github_linkback_maximum_links urls" do
+ it "creates linkbacks when the URL count is within the limit" do
SiteSetting.github_linkback_maximum_links = 2
post = Fabricate(:post, raw: "#{github_pr_link} #{github_issue_link}")
links = GithubLinkback.new(post).create
expect(links.size).to eq(2)
end
- it "should skip linkback for > SiteSetting.github_linkback_maximum_links urls" do
+ it "skips linkbacks when the URL count exceeds the limit" do
SiteSetting.github_linkback_maximum_links = 1
post = Fabricate(:post, raw: "#{github_pr_link} #{github_issue_link}")
links = GithubLinkback.new(post).create
expect(links.size).to eq(0)
end
- it "should create linkback for <= SiteSetting.github_linkback_maximum_links unique urls" do
+ it "counts unique URLs when applying the linkback limit" do
SiteSetting.github_linkback_maximum_links = 1
post = Fabricate(:post, raw: "#{github_pr_link} #{github_pr_link} #{github_pr_link}")
links = GithubLinkback.new(post).create
diff --git a/plugins/discourse-github/spec/lib/github_permalinks_spec.rb b/plugins/discourse-github/spec/lib/github_permalinks_spec.rb
index 5ac123de673..d12d5db0e51 100644
--- a/plugins/discourse-github/spec/lib/github_permalinks_spec.rb
+++ b/plugins/discourse-github/spec/lib/github_permalinks_spec.rb
@@ -6,7 +6,7 @@ describe GithubPermalinks do
context "when it doesn't contain github link to the file" do
let(:post) { Fabricate(:post, raw: "there is no github link") }
- it "it does not run the job" do
+ it "does not run the job" do
Jobs.expects(:cancel_scheduled_job).never
GithubPermalinks.replace_github_non_permalinks(post)
end
diff --git a/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb b/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb
index 2549c2f4b3d..da2366d1e3d 100644
--- a/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb
+++ b/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe "Local Dates" do
freeze_time DateTime.parse("2018-11-10 12:00")
end
- it "should work without timezone" do
+ it "renders a local date without a timezone" do
post = Fabricate(:post, raw: <<~MD)
[date=2018-05-08 time=22:00 format="L LTS" timezones="Europe/Paris|America/Los_Angeles"]
MD
@@ -24,7 +24,7 @@ RSpec.describe "Local Dates" do
expect(cooked).to include("05/08/2018 10:00:00 PM")
end
- it "should work with timezone" do
+ it "renders a local date with a timezone" do
post = Fabricate(:post, raw: <<~MD)
[date=2018-05-08 time=22:00 format="L LTS" timezone="Asia/Calcutta" timezones="Europe/Paris|America/Los_Angeles"]
MD
@@ -44,7 +44,7 @@ RSpec.describe "Local Dates" do
expect(cooked).to include("05/08/2018 4:30:00 PM")
end
- it "requires the right attributes to convert to a local date" do
+ it "preserves a date tag without attributes as plain text" do
post = Fabricate(:post, raw: <<~MD)
[date]
MD
@@ -55,7 +55,7 @@ RSpec.describe "Local Dates" do
expect(cooked).to_not include("data-date=")
end
- it "requires the right attributes to convert to a local date" do
+ it "omits date metadata for a date tag without attributes" do
post = Fabricate(:post, raw: <<~MD)
[date]
MD
@@ -66,7 +66,7 @@ RSpec.describe "Local Dates" do
expect(cooked).to_not include("data-date=")
end
- it "it works with only a date and time" do
+ it "renders a local date with only a date and time" do
raw = "[date=2018-11-01 time=12:00]"
cooked = Fabricate(:post, raw: raw).cooked
expect(cooked).to include('data-date="2018-11-01"')
diff --git a/plugins/discourse-local-dates/spec/models/post_spec.rb b/plugins/discourse-local-dates/spec/models/post_spec.rb
index 8a5ae218398..301e6ad9c8d 100644
--- a/plugins/discourse-local-dates/spec/models/post_spec.rb
+++ b/plugins/discourse-local-dates/spec/models/post_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Post do
before { Jobs.run_immediately! }
describe "#local_dates" do
- it "should have correct custom fields" do
+ it "stores the parsed dates in custom fields" do
post = Fabricate(:post, raw: <<~SQL)
[date=2018-09-17 time=01:39:00 format="LLL" timezone="Europe/Paris" timezones="Europe/Paris|America/Los_Angeles"]
SQL
@@ -22,7 +22,7 @@ RSpec.describe Post do
expect(post.local_dates).to eq([])
end
- it "should not contain dates from quotes" do
+ it "excludes dates from quotes" do
post = Fabricate(:post, raw: <<~SQL)
[quote]
[date=2018-09-17 time=01:39:00 format="LLL" timezone="Europe/Paris" timezones="Europe/Paris|America/Los_Angeles"]
@@ -33,7 +33,7 @@ RSpec.describe Post do
expect(post.local_dates.count).to eq(0)
end
- it "should not contain dates from examples" do
+ it "excludes dates from onebox examples" do
Oneboxer.stubs(:cached_onebox).with("https://example.com").returns(<<-HTML)
<aside class="onebox githubcommit">
<span class="discourse-local-date" data-format="ll" data-date="2020-01-20" data-time="15:06:58" data-timezone="UTC">03:06PM - 20 Jan 20 UTC</span>
diff --git a/plugins/discourse-login-with-amazon/spec/lib/validators/enable_login_with_amazon_validator_spec.rb b/plugins/discourse-login-with-amazon/spec/lib/validators/enable_login_with_amazon_validator_spec.rb
index 3c62581fb9f..42ea9970125 100644
--- a/plugins/discourse-login-with-amazon/spec/lib/validators/enable_login_with_amazon_validator_spec.rb
+++ b/plugins/discourse-login-with-amazon/spec/lib/validators/enable_login_with_amazon_validator_spec.rb
@@ -5,11 +5,11 @@ RSpec.describe EnableLoginWithAmazonValidator do
describe "#valid_value?" do
describe "when login_with_amazon_client_id and login_with_amazon_client_secret has not been set" do
- it "should return true when value is false" do
+ it "returns true when value is false" do
expect(validator.valid_value?("f")).to eq(true)
end
- it "should return false when value is true" do
+ it "returns false when value is true" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -32,11 +32,11 @@ RSpec.describe EnableLoginWithAmazonValidator do
SiteSetting.login_with_amazon_client_secret = "somesecretkey"
end
- it "should return true when value is false" do
+ it "returns true when value is false" do
expect(validator.valid_value?("f")).to eq(true)
end
- it "should return true when value is true" do
+ it "returns true when value is true" do
expect(validator.valid_value?("t")).to eq(true)
end
end
diff --git a/plugins/discourse-microsoft-auth/spec/lib/microsoft_auth_revoker_spec.rb b/plugins/discourse-microsoft-auth/spec/lib/microsoft_auth_revoker_spec.rb
index 3ab2a3137b6..52bb8ecd535 100644
--- a/plugins/discourse-microsoft-auth/spec/lib/microsoft_auth_revoker_spec.rb
+++ b/plugins/discourse-microsoft-auth/spec/lib/microsoft_auth_revoker_spec.rb
@@ -48,26 +48,26 @@ RSpec.describe MicrosoftAuthRevoker do
fab!(:api_key_for_user_2) { Fabricate(:api_key, created_by_id: user_2.id) }
fab!(:api_key_for_user_3) { Fabricate(:api_key, created_by_id: user_3.id) }
- it "should delete all microsoft provider `UserAssociatedAccount` records" do
+ it "deletes all Microsoft provider `UserAssociatedAccount` records" do
expect do MicrosoftAuthRevoker.revoke end.to change { UserAssociatedAccount.count }.by(-2)
expect(UserAssociatedAccount.where(provider_name: "microsoft_office365").count).to eq(0)
end
- it "should deactivate all users with microsoft provider `UserAssociatedAccount` records" do
+ it "deactivates all users with Microsoft provider `UserAssociatedAccount` records" do
expect do MicrosoftAuthRevoker.revoke end.to change { User.where(active: true).count }.by(-2)
expect(user_1.reload.active).to eq(false)
expect(user_2.reload.active).to eq(false)
expect(user_3.reload.active).to eq(true)
end
- it "should delete all `UserAuthToken` records for users with microsoft provider `UserAssociatedAccount` records" do
+ it "deletes all `UserAuthToken` records for users with Microsoft provider `UserAssociatedAccount` records" do
expect do MicrosoftAuthRevoker.revoke end.to change { UserAuthToken.count }.by(-2)
expect(UserAuthToken.where(user_id: user_1.id).count).to eq(0)
expect(UserAuthToken.where(user_id: user_2.id).count).to eq(0)
expect(UserAuthToken.where(user_id: user_3.id).count).to eq(1)
end
- it "should revoke all `UserApiKey` records for users with microsoft provider `UserAssociatedAccount` records" do
+ it "revokes all `UserApiKey` records for users with Microsoft provider `UserAssociatedAccount` records" do
expect do MicrosoftAuthRevoker.revoke end.to change {
UserApiKey.where(revoked_at: nil).count
}.by(-2)
@@ -77,7 +77,7 @@ RSpec.describe MicrosoftAuthRevoker do
expect(user_api_key_for_user_3.reload.revoked_at).to be_nil
end
- it "should revoke all `ApiKey` records created by users with microsoft provider `UserAssociatedAccount` records" do
+ it "revokes all `ApiKey` records created by users with Microsoft provider `UserAssociatedAccount` records" do
expect do MicrosoftAuthRevoker.revoke end.to change {
ApiKey.where(revoked_at: nil).count
}.by(-2)
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
index ffd935df4b3..a23c77353f1 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
narrative.set_data(user, state: :tutorial_poll, topic_id: topic.id, last_post_id: post.id)
end
- it "should create the right message" do
+ it "posts the timeout reminder" do
expect { narrative.notify_timeout(user) }.to change { Post.count }.by(1)
expect(Post.last.raw).to eq(
@@ -66,7 +66,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
let(:post) { Fabricate(:post, topic: topic) }
- it "should reset the bot" do
+ it "resets the bot to the editing tutorial" do
narrative.reset_bot(user, post)
expected_raw =
@@ -100,7 +100,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when trigger is not initiated in a PM" do
- it "should start the new track in a PM" do
+ it "starts the new track in a PM" do
narrative.reset_bot(user, other_post)
expected_raw =
@@ -132,7 +132,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(new_post.topic.id).to_not eq(topic.id)
end
- it "should not explode if title emojis are disabled" do
+ it "creates the tutorial topic when title emojis are disabled" do
SiteSetting.max_emojis_in_title = 0
narrative.reset_bot(user, other_post)
@@ -158,7 +158,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the editing tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -168,7 +168,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the post" do
- it "should create the right reply" do
+ it "reminds the user to edit the post" do
post
narrative.expects(:enqueue_timeout_job).with(user).once
@@ -184,7 +184,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the deletion tutorial instructions" do
post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -207,7 +207,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
context "when user edits the right post" do
let(:post_2) { Fabricate(:post, user: post.user, topic: post.topic) }
- it "should create the right reply" do
+ it "acknowledges the edit and starts the deletion tutorial" do
post_2
expect do
@@ -237,7 +237,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to delete a post" do
narrative.expects(:enqueue_timeout_job).with(user).once
narrative.input(:reply, user, post: post)
@@ -254,7 +254,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the recovery tutorial instructions" do
post.update!(raw: skip_trigger.upcase)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -275,7 +275,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user destroys a post in a different topic" do
- it "should not do anything" do
+ it "leaves the deletion tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -286,7 +286,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user deletes a post in the right topic" do
- it "should create the right reply" do
+ it "acknowledges the deletion and starts the recovery tutorial" do
post
expect { PostDestroyer.new(user, post).destroy }.to change { Post.count }.by(2)
@@ -302,7 +302,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user is an admin" do
- it "should create the right reply" do
+ it "reuses the last post to start the recovery tutorial" do
post
user.update!(admin: true)
@@ -334,7 +334,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
context "when posts are configured to be deleted immediately" do
before { SiteSetting.delete_removed_posts_after = 0 }
- it "should set up the tutorial correctly" do
+ it "preserves the deleted post stub for the recovery tutorial" do
narrative.set_data(
user,
state: :tutorial_delete,
@@ -355,7 +355,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to recover a post" do
narrative.set_data(
user,
narrative.get_data(user).merge(tutorial_recover: { post_id: "1" }),
@@ -377,7 +377,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the category hashtag tutorial instructions" do
parent_category = Fabricate(:category, name: "a")
_category = Fabricate(:category, parent_category: parent_category, name: "b")
@@ -402,7 +402,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user recovers a post in a different topic" do
- it "should not do anything" do
+ it "leaves the recovery tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -414,7 +414,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user recovers a post in the right topic" do
- it "should create the right reply" do
+ it "acknowledges recovery and starts the category hashtag tutorial" do
parent_category = Fabricate(:category, name: "a")
_category = Fabricate(:category, parent_category: parent_category, name: "b")
post
@@ -446,7 +446,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the category hashtag tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -457,7 +457,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to include a category hashtag" do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -472,7 +472,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the topic notification tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -494,7 +494,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the hashtag and starts the topic notification tutorial" do
category = Fabricate(:category)
post.update!(raw: "Check out this ##{category.slug}")
@@ -524,7 +524,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when notification level is changed for another topic" do
- it "should not do anything" do
+ it "leaves the topic notification tutorial unchanged" do
other_topic
user
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -544,7 +544,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to change the topic notification level" do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -561,7 +561,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the poll tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -582,7 +582,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user changed the topic notification level" do
- it "should create the right reply" do
+ it "acknowledges the notification change and starts the poll tutorial" do
TopicUser.change(
user.id,
topic.id,
@@ -601,7 +601,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user cannot create polls" do
- it "should create the right reply (polls disabled)" do
+ it "starts the details tutorial when polls are disabled" do
SiteSetting.poll_enabled = false
TopicUser.change(
@@ -620,7 +620,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_details)
end
- it "should create the right reply (insufficient trust level)" do
+ it "starts the details tutorial when the user's trust level is insufficient" do
user.change_trust_level!(TrustLevel[0])
TopicUser.change(
@@ -665,7 +665,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the poll tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -675,7 +675,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to create a poll" do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -686,7 +686,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the details tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -706,7 +706,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the poll and starts the details tutorial" do
post.update!(raw: "[poll]\n* 1\n* 2\n[/poll]\n")
narrative.input(:reply, user, post: post)
@@ -732,7 +732,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the details tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -742,7 +742,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to include details" do
narrative.input(:reply, user, post: post)
expect(Post.last.raw).to eq(
@@ -755,7 +755,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
context "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the final reply and ends the tutorial" do
post.update!(raw: skip_trigger)
expect do
@@ -767,7 +767,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- it "should create the right reply and issue the discobot certificate" do
+ it "acknowledges the details and issues the discobot certificate" do
post.update!(raw: "[details=\"This is a test\"]\nwooohoo\n[/details]")
narrative.input(:reply, user, post: post)
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
index a298c691925..83e49916c2d 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
narrative.set_data(user, state: :tutorial_images, topic_id: topic.id, last_post_id: post.id)
end
- it "should create the right message" do
+ it "posts and emails the timeout reminder" do
NotificationEmailer.enable
NotificationEmailer.expects(:process_notification).once
@@ -71,7 +71,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
let(:post) { Fabricate(:post, topic: topic) }
- it "should reset the bot" do
+ it "resets the bot to the bookmark tutorial" do
narrative.reset_bot(user, post)
expected_raw =
@@ -103,7 +103,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
context "when trigger is not initiated in a PM" do
- it "should start the new track in a PM" do
+ it "starts the new track in a PM" do
narrative.reset_bot(user, other_post)
expected_raw =
@@ -144,7 +144,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when an error occurs" do
before { narrative.set_data(user, state: :tutorial_flag, topic_id: topic.id) }
- it "should revert to the previous state" do
+ it "reverts to the previous state" do
narrative
.expects(:send)
.with("init_tutorial_search")
@@ -162,14 +162,14 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when input does not have a valid transition from current state" do
before { narrative.set_data(user, state: :begin) }
- it "should raise the right error" do
+ it "returns nil and preserves the current state" do
expect(narrative.input(:something, user, post: post)).to eq(nil)
expect(narrative.get_data(user)[:state].to_sym).to eq(:begin)
end
end
describe "when [:begin, :init]" do
- it "should create the right post" do
+ it "posts the welcome message and bookmark instructions" do
narrative.expects(:enqueue_timeout_job).never
narrative.input(:init, user, post: nil)
@@ -199,7 +199,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_bookmark, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "ignores bookmarks outside the tutorial topic" do
other_post.update!(user_id: -2)
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -209,7 +209,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when bookmark is not on bot's post" do
- it "should not do anything" do
+ it "ignores bookmarks on other users' posts" do
narrative.expects(:enqueue_timeout_job).with(user).never
post
@@ -219,7 +219,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to bookmark the post" do
narrative.expects(:enqueue_timeout_job).with(user).once
narrative.input(:reply, user, post: post)
@@ -234,7 +234,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when rate_limit_new_user_create_post site setting is disabled" do
before { SiteSetting.rate_limit_new_user_create_post = 0 }
- it "should create the right reply" do
+ it "posts the bookmark reminder" do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -245,7 +245,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the onebox tutorial instructions" do
post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -326,7 +326,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should skip tutorials in SiteSetting.discourse_narrative_bot_skip_tutorials" do
+ it "skips tutorials configured in discourse_narrative_bot_skip_tutorials" do
SiteSetting.discourse_narrative_bot_skip_tutorials = "tutorial_onebox"
post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
@@ -341,7 +341,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_onebox, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the onebox tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -351,7 +351,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain onebox" do
- it "should create the right reply" do
+ it "reminds the user to include a onebox" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -364,7 +364,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when user has not liked bot's post" do
- it "should create the right reply" do
+ it "posts the missing onebox reminder" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -378,7 +378,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the emoji tutorial instructions" do
post.update!(raw: skip_trigger.upcase)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -397,7 +397,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when emoji is disabled" do
before { SiteSetting.enable_emoji = false }
- it "should create the right reply" do
+ it "acknowledges the onebox and starts the mention tutorial" do
post.update!(raw: "https://en.wikipedia.org/wiki/Death_by_coconut")
narrative.input(:reply, user, post: post)
@@ -420,7 +420,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the onebox and starts the emoji tutorial" do
post.update!(raw: "https://en.wikipedia.org/wiki/Death_by_coconut")
narrative.expects(:enqueue_timeout_job).with(user)
@@ -453,7 +453,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the images tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -464,7 +464,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the flag tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -485,7 +485,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when allow_flagging_staff is false" do
- it "should go to the right state" do
+ it "skips to the search tutorial" do
SiteSetting.allow_flagging_staff = false
post.update!(raw: skip_trigger)
@@ -498,7 +498,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
context "when image is not found" do
- it "should create the right replies" do
+ it "prompts for an image and advances after receiving an image URL" do
PostActionCreator.like(user, post_2)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -551,7 +551,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right replies" do
+ it "prompts for an image and a like before advancing to flagging" do
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
@@ -629,7 +629,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the likes tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -640,7 +640,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the flag tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -661,7 +661,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when allow_flagging_staff is false" do
- it "should go to the right state" do
+ it "skips to the search tutorial" do
SiteSetting.allow_flagging_staff = false
post.update!(raw: skip_trigger)
@@ -672,7 +672,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "reminds the user to like the post" do
narrative.expects(:enqueue_timeout_job).with(user).once
narrative.input(:reply, user, post: post)
@@ -691,7 +691,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when the post is liked" do
- it "should create the right reply" do
+ it "acknowledges the like and starts the flag tutorial" do
PostActionCreator.like(user, post_2)
expected_raw = <<~RAW
@@ -717,7 +717,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_formatting, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the formatting tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -727,7 +727,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain any formatting" do
- it "should create the right reply" do
+ it "reminds the user to format their reply" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
@@ -740,7 +740,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the quoting tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -761,7 +761,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
["**bold**", "__italic__", "[b]bold[/b]", "[i]italic[/i]"].each do |raw|
- it "should create the right reply" do
+ it "acknowledges the formatting and starts the quoting tutorial" do
post.update!(raw: raw)
narrative.expects(:enqueue_timeout_job).with(user)
@@ -784,7 +784,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_quote, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the quoting tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -794,7 +794,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain any quotes" do
- it "should create the right reply" do
+ it "reminds the user to include a quote" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
@@ -807,7 +807,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the images tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -825,7 +825,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_images)
end
- it "should use correct path to images on subfolder installs" do
+ it "includes the subfolder in image paths" do
GlobalSetting.stubs(:relative_url_root).returns("/forum")
Discourse.stubs(:base_path).returns("/forum")
@@ -845,7 +845,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
Group.refresh_automatic_groups!
end
- it "should skip the images tutorial step" do
+ it "skips the images tutorial step" do
post.update!(
raw:
"[quote=\"#{post.user}, post:#{post.post_number}, topic:#{topic.id}\"]\n:monkey: :fries:\n[/quote]",
@@ -858,7 +858,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the quote and starts the images tutorial" do
post.update!(
raw:
"[quote=\"#{post.user}, post:#{post.post_number}, topic:#{topic.id}\"]\n:monkey: :fries:\n[/quote]",
@@ -884,7 +884,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_emoji, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the emoji tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -894,7 +894,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain any emoji" do
- it "should create the right reply" do
+ it "reminds the user to include an emoji" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
@@ -907,7 +907,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user replies to the topic" do
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the mention tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -931,7 +931,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
describe "when user mentions is disabled" do
before { SiteSetting.enable_mentions = false }
- it "should skip the mention tutorial step" do
+ it "skips the mention tutorial step" do
post.update!(raw: ":monkey: :fries:")
narrative.expects(:enqueue_timeout_job).with(user)
@@ -941,7 +941,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the emoji and starts the mention tutorial" do
post.update!(raw: ":monkey: :fries:")
narrative.expects(:enqueue_timeout_job).with(user)
@@ -969,7 +969,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_mention, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the mention tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -979,7 +979,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain any mentions" do
- it "should create the right reply" do
+ it "reminds the user to mention discobot" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
@@ -997,7 +997,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the formatting tutorial instructions" do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -1017,7 +1017,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges the mention and starts the formatting tutorial" do
post.update!(raw: "@disCoBot hello how are you doing today?")
narrative.expects(:enqueue_timeout_job).with(user)
@@ -1064,7 +1064,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post flagged is not for the right topic" do
- it "should not do anything" do
+ it "leaves the flag tutorial unchanged" do
narrative.expects(:enqueue_timeout_job).with(user).never
flag.update!(post: other_post)
@@ -1074,7 +1074,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post is flagged incorrectly" do
- it "should create the right reply and stay on the same step" do
+ it "posts the flag reminder and stays on the same step" do
narrative.expects(:enqueue_timeout_job).with(user).never
other_flag.update!(post: another_post)
new_post = Post.last
@@ -1087,7 +1087,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post being flagged does not belong to discobot " do
- it "should not do anything" do
+ it "ignores flags on posts that do not belong to discobot" do
narrative.expects(:enqueue_timeout_job).with(user).never
flag.update!(post: other_post)
@@ -1097,7 +1097,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when user replies to the topic" do
- it "should create the right reply" do
+ it "reminds the user to flag the post" do
narrative.input(:reply, user, post: other_post)
new_post = Post.last
@@ -1108,7 +1108,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when reply contains the skip trigger" do
- it "should create the right reply" do
+ it "posts the search tutorial instructions" do
other_post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -1128,7 +1128,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
end
- it "should create the right reply" do
+ it "acknowledges and removes the flag before starting the search tutorial" do
narrative.expects(:enqueue_timeout_job).with(user)
expect { narrative.input(:flag, user, post: flag.post) }.to change { PostAction.count }.by(
@@ -1158,7 +1158,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
before { narrative.set_data(user, state: :tutorial_search, topic_id: topic.id) }
describe "when post is not in the right topic" do
- it "should not do anything" do
+ it "leaves the search tutorial unchanged" do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -1168,7 +1168,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
end
describe "when post does not contain the right answer" do
- it "should create the right reply" do
+ it "reminds the user to find the search answer" do
narrative.expects(:enqueue_timeout_job).with(user)
narrative.input(:reply, user, post: post)
@@ -1200,7 +1200,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
)
end
- it "should clean up if the tutorial is skipped" do
+ it "cleans up if the tutorial is skipped" do
post.update!(raw: skip_trigger)
expect do
@@ -1211,7 +1211,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:end)
end
- it "should create the right reply" do
+ it "acknowledges the answer and awards the tutorial badge" do
post.update!(raw: "#{described_class.search_answer} this is a capybara")
expect do
@@ -1241,7 +1241,7 @@ RSpec.describe DiscourseNarrativeBot::NewUserNarrative do
).to eq(true)
end
- it "should accept a raw emoji" do
+ it "accepts a raw emoji" do
post.update!(
raw: "#{described_class.search_answer_emoji} this is the emoji you mentioned",
)
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/store_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/store_spec.rb
index 874af6ad672..acd78150dcd 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/store_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/store_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe DiscourseNarrativeBot::Store do
describe ".set" do
- it "should set the right value in the plugin store" do
+ it "sets the expected value in the plugin store" do
key = "somekey"
described_class.set(key, "yay")
plugin_store_row = PluginStoreRow.last
@@ -14,7 +14,7 @@ RSpec.describe DiscourseNarrativeBot::Store do
end
describe ".get" do
- it "should get the right value from the plugin store" do
+ it "gets the expected value from the plugin store" do
PluginStoreRow.create!(
plugin_name: DiscourseNarrativeBot::PLUGIN_NAME,
key: "somekey",
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
index 8306f8bc938..519d8f20d4f 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb
@@ -83,7 +83,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when bot is mentioned" do
- it "should select the right track" do
+ it "selects the expected track" do
post.update!(raw: "@discobot show me what you can do")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -95,7 +95,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when bot is replied to" do
- it "should select the right track" do
+ it "selects the expected track" do
post.update!(
raw: "show me what you can do",
reply_to_post_number: first_post.post_number,
@@ -131,7 +131,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
expect(Post.last.raw).to eq(expected_raw.chomp)
end
- it "should not enqueue any user email" do
+ it "does not enqueue any user email" do
NotificationEmailer.enable
user.user_option.update!(email_level: UserOption.email_level_types[:always])
@@ -151,7 +151,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when a non regular post is created" do
- it "should not do anything" do
+ it "does nothing" do
moderator_post = Fabricate(:moderator_post, user: user, topic: topic)
expect do
@@ -161,7 +161,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when user thank the bot" do
- it "should like the post" do
+ it "likes the post" do
post.update!(raw: "thanks!")
expect { described_class.new(:reply, user, post_id: post.id).select }.to change {
@@ -179,7 +179,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when reply contains a reset trigger" do
- it "should reset the track" do
+ it "resets the track" do
post.update!(
raw:
"#{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}",
@@ -193,7 +193,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when reset trigger in surrounded by quotes" do
- it "should reset the track" do
+ it "resets the track" do
post.update!(
raw:
"'#{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}'",
@@ -209,7 +209,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when reset trigger in a middle of a sentence" do
context "when post is less than reset trigger exact match limit" do
- it "should reset the track" do
+ it "resets the track" do
post.update!(
raw:
"I would like to #{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger} now",
@@ -224,7 +224,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when post exceeds reset trigger exact match limit" do
- it "should not reset the track" do
+ it "does not reset the track" do
post.update!(
raw:
"I would like to #{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger} now #{"a" * described_class::RESET_TRIGGER_EXACT_MATCH_LENGTH}",
@@ -245,7 +245,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when a new user is added into the topic" do
before { topic.allowed_users << Fabricate(:user) }
- it "should stop the new user track" do
+ it "stops the new user track" do
post
expect { described_class.new(:reply, user, post_id: post.id).select }.to_not change {
@@ -270,7 +270,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
Discourse.redis.del("#{described_class::GENERIC_REPLIES_COUNT_PREFIX}#{user.id}")
end
- it "should create the right generic do not understand responses" do
+ it "creates the expected generic misunderstanding responses" do
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -320,7 +320,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when discobot is mentioned at the end of a track" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "Show me what you can do @discobot")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -329,7 +329,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when asking discobot for help" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "show me what you can do @discobot display help")
described_class.new(:reply, user, post_id: post.id).select
@@ -337,7 +337,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "as an admin or moderator" do
- it "should include the commands to start the advanced user track" do
+ it "includes the commands that start the advanced user track" do
user.update!(moderator: true)
post.update!(raw: "Show me what you can do @discobot display help")
described_class.new(:reply, user, post_id: post.id).select
@@ -350,7 +350,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "as a user that has completed the new user track" do
- it "should include the commands to start the advanced user track" do
+ it "includes the commands that start the advanced user track" do
narrative.set_data(
user,
state: :end,
@@ -377,7 +377,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when discobot is asked to roll dice" do
before { narrative.set_data(user, state: :end, topic_id: topic.id) }
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "roll 2d1")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -390,7 +390,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when range of dice request is too high" do
before { srand(1) }
- it "should create the right reply" do
+ it "creates the expected reply" do
stub_request(
:get,
"https://www.wired.com/2016/05/mathematical-challenge-of-designing-the-worlds-most-complex-120-sided-dice",
@@ -413,7 +413,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when number of dice to roll is too high" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "roll #{DiscourseNarrativeBot::Dice::MAXIMUM_NUM_OF_DICE + 1}d1")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -429,7 +429,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when dice combination is invalid" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "roll 0d1")
described_class.new(:reply, user, post_id: post.id).select
@@ -442,7 +442,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when in a normal PM with discobot" do
context "when discobot is replied to" do
- it "should create the right reply" do
+ it "creates the expected reply" do
SiteSetting.discourse_narrative_bot_disable_public_replies = true
post.update!(raw: "Show me what you can do @discobot")
described_class.new(:reply, user, post_id: post.id).select
@@ -462,7 +462,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- it "should not rate limit help message" do
+ it "does not rate-limit the help message" do
post.update!(raw: "@discobot")
other_post = Fabricate(:post, raw: "discobot", topic: post.topic)
@@ -483,7 +483,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
before { SiteSetting.discourse_narrative_bot_disable_public_replies = true }
context "when discobot is mentioned" do
- it "should not reply" do
+ it "does not reply" do
post.update!(raw: "Show me what you can do @discobot")
expect do described_class.new(:reply, user, post_id: post.id).select end.to_not change {
@@ -494,7 +494,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when discobot is mentioned" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "Show me what you can do @discobot")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -513,7 +513,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
)
end
- it "should be case insensitive towards discobot's username" do
+ it "matches discobot's username case-insensitively" do
discobot_user.update!(username: "DisCoBot")
post.update!(raw: "Show me what you can do @discobot")
@@ -522,7 +522,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
expect(new_post.raw).to eq(random_mention_reply)
end
- it "should not like the public post" do
+ it "does not like the public post" do
post.update!(raw: "thanks @discobot!")
expect { described_class.new(:reply, user, post_id: post.id).select }.not_to change {
@@ -541,7 +541,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
after { Discourse.redis.flushdb }
context "when random reply massage has been displayed in the last 6 hours" do
- it "should not do anything" do
+ it "does nothing" do
Discourse.redis.set(
"#{described_class::PUBLIC_DISPLAY_BOT_HELP_KEY}:#{other_post.topic_id}",
post.post_number - 11,
@@ -559,7 +559,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when random reply message has not been displayed in the last 6 hours" do
- it "should create the right reply" do
+ it "creates the expected reply" do
Discourse.redis.set(
"#{described_class::PUBLIC_DISPLAY_BOT_HELP_KEY}:#{other_post.topic_id}",
post.post_number - 11,
@@ -577,7 +577,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when random reply message has been displayed in the last 10 replies" do
- it "should not do anything" do
+ it "does nothing" do
described_class.new(:reply, user, post_id: other_post.id).select
expect(Post.last.raw).to eq(random_mention_reply)
@@ -599,7 +599,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when asking discobot for help" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "@discobot display help")
described_class.new(:reply, user, post_id: post.id).select
@@ -609,7 +609,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when asking discobot to start new user track" do
context "with invalid text" do
- it "should not trigger the bot" do
+ it "does not trigger the bot" do
post.update!(
raw:
"`@discobot #{I18n.t("discourse_narrative_bot.track_selector.reset_trigger")} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}`",
@@ -623,7 +623,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when discobot is asked to roll dice" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "@discobot roll 2d1")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -633,7 +633,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
)
end
- it "should ignore extra whitespace proceeding the mention" do
+ it "ignores extra whitespace preceding the mention" do
post.update!(raw: "@discobot roll 2d1")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -644,7 +644,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when dice roll is requested incorrectly" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "roll 2d1 @discobot")
described_class.new(:reply, user, post_id: post.id).select
@@ -653,7 +653,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when roll dice command is present inside a quote" do
- it "should ignore the command" do
+ it "ignores the command" do
user
post.update!(raw: "[quote=\"Donkey, post:6, topic:1\"]\n@discobot roll 2d1\n[/quote]")
@@ -665,7 +665,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when a quote is requested" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "@discobot quote")
described_class.new(:reply, user, post_id: post.id).select
new_post = Post.last
@@ -674,7 +674,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when quote is requested incorrectly" do
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "quote @discobot")
described_class.new(:reply, user, post_id: post.id).select
@@ -683,7 +683,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when quote command is present inside a onebox or quote" do
- it "should ignore the command" do
+ it "ignores the command" do
user
post.update!(raw: "[quote=\"Donkey, post:6, topic:1\"]\n@discobot quote\n[/quote]")
@@ -697,7 +697,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when magic 8 ball is requested" do
before { srand(1) }
- it "should create the right reply" do
+ it "creates the expected reply" do
post.update!(raw: "@discobot fortune")
described_class.new(:reply, user, post_id: post.id).select
@@ -712,7 +712,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
context "when bot is asked to reset/start a track" do
context "when user likes a post containing a reset trigger" do
- it "should not start the track" do
+ it "does not start the track" do
another_post =
Fabricate(
:post,
@@ -747,7 +747,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
after { @overrides.each(&:destroy!) }
- it "should start the right track" do
+ it "starts the expected track" do
post.update!(
raw:
"@discobot #{I18n.t("discourse_narrative_bot.track_selector.reset_trigger")} #{DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}",
@@ -771,7 +771,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:other_post) { Fabricate(:post, topic: other_topic) }
context "when a new message is made" do
- it "should not do anything" do
+ it "does nothing" do
other_post
expect {
@@ -791,7 +791,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:other_post) { Fabricate(:post, topic: other_topic) }
context "when a new like is made" do
- it "should not do anything" do
+ it "does nothing" do
other_post
expect { described_class.new(:like, user, post_id: other_post.id).select }.to_not change {
Post.count
@@ -800,7 +800,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when a new message is made" do
- it "should create the right reply" do
+ it "creates the expected reply" do
described_class.new(:reply, user, post_id: other_post.id).select
expect(Post.last.raw).to eq(random_mention_reply)
@@ -808,7 +808,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context "when user thanks the bot" do
- it "should like the post" do
+ it "likes the post" do
other_post.update!(raw: "thanks!")
expect { described_class.new(:reply, user, post_id: other_post.id).select }.to change {
diff --git a/plugins/discourse-narrative-bot/spec/jobs/send_default_welcome_message_spec.rb b/plugins/discourse-narrative-bot/spec/jobs/send_default_welcome_message_spec.rb
index bc5263b5db8..c7b0cb2e13f 100644
--- a/plugins/discourse-narrative-bot/spec/jobs/send_default_welcome_message_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/jobs/send_default_welcome_message_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Jobs::SendDefaultWelcomeMessage do
let(:user) { Fabricate(:user) }
- it "should send the right welcome message" do
+ it "sends the default welcome message in a closed topic" do
described_class.new.execute(user_id: user.id)
topic = Topic.last
@@ -33,7 +33,7 @@ RSpec.describe Jobs::SendDefaultWelcomeMessage do
)
end
- it "should send the right welcome message" do
+ it "sends the invited user welcome message in a closed topic" do
described_class.new.execute(user_id: invited_user.user_id)
topic = Topic.last
diff --git a/plugins/discourse-narrative-bot/spec/lib/certificate_generator_spec.rb b/plugins/discourse-narrative-bot/spec/lib/certificate_generator_spec.rb
index 564ed44bfb4..2c99f1b981a 100644
--- a/plugins/discourse-narrative-bot/spec/lib/certificate_generator_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/lib/certificate_generator_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe DiscourseNarrativeBot::CertificateGenerator do
let(:date) { "2017-00-10" }
describe "when an invalid date is given" do
- it "should default to the current date" do
+ it "defaults to the current date" do
expect { described_class.new(user, date, avatar_url) }.to_not raise_error
end
end
@@ -15,7 +15,7 @@ RSpec.describe DiscourseNarrativeBot::CertificateGenerator do
describe "when SiteSetting.site_logo_small_url is blank" do
before { SiteSetting.logo_small = "" }
- it "should not try to fetch a image" do
+ it "does not fetch an image" do
expect(described_class.new(user, date, avatar_url).send(:logo_group, 1, 1, 1)).to eq(nil)
end
end
diff --git a/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb b/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
index 691ee1a2da2..549998671dc 100644
--- a/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/lib/site_setting_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe SiteSetting do
before { SiteSetting.discourse_narrative_bot_enabled = true }
- it "should update bot's `UserProfile#bio_raw` when `default_locale` site setting is changed" do
+ it "updates the bot profile biography when default_locale changes" do
expect(discobot_user.user_profile.bio_raw).to eq(
I18n.with_locale(:en) { I18n.t("discourse_narrative_bot.bio") },
)
diff --git a/plugins/discourse-narrative-bot/spec/requests/discobot_certificate_spec.rb b/plugins/discourse-narrative-bot/spec/requests/discobot_certificate_spec.rb
index 8d3f0908d93..17c3ff536c9 100644
--- a/plugins/discourse-narrative-bot/spec/requests/discobot_certificate_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/requests/discobot_certificate_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe "Discobot Certificate" do
describe "when viewing the certificate" do
describe "when no logged in" do
- it "should return the right response" do
+ it "returns the expected response" do
get "/discobot/certificate.svg", params: params
expect(response.status).to eq(404)
@@ -18,7 +18,7 @@ RSpec.describe "Discobot Certificate" do
describe "when logged in" do
before { sign_in(user) }
- it "should return the right text" do
+ it "returns the expected text" do
stub_request(:get, /letter_avatar_proxy/).to_return(
status: 200,
body: "http://test.localhost/cdn/avatar.png",
@@ -36,7 +36,7 @@ RSpec.describe "Discobot Certificate" do
end
describe "when params are missing" do
- it "should raise the right errors" do
+ it "raises the expected errors" do
params.each do |key, _|
get "/discobot/certificate.svg", params: params.except(key)
expect(response.status).to eq(400)
diff --git a/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb b/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
index 8b73087375c..d6ccc21db98 100644
--- a/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "Discobot welcome post" do
end
context "when discourse_narrative_bot_welcome_post_delay is 0" do
- it "should not delay the welcome post" do
+ it "sends the welcome post immediately" do
user
expect { sign_in(user) }.to_not change { Jobs::NarrativeInit.jobs.count }
end
@@ -19,7 +19,7 @@ RSpec.describe "Discobot welcome post" do
before { SiteSetting.discourse_narrative_bot_welcome_post_delay = 5 }
context "when user logs in normally" do
- it "should delay the welcome post until user logs in" do
+ it "delays the welcome post until the user logs in" do
expect { sign_in(user) }.to change { Jobs::NarrativeInit.jobs.count }.by(1)
expect(Jobs::NarrativeInit.jobs.first["args"].first["user_id"]).to eq(user.id)
end
@@ -30,7 +30,7 @@ RSpec.describe "Discobot welcome post" do
Fabricate(:invite, invited_by: Fabricate(:admin), email: "[email protected]")
end
- it "should delay the welcome post until the user logs in" do
+ it "delays the welcome post until the user logs in" do
expect do
put "/invites/show/#{invite.invite_key}.json",
params: {
@@ -51,7 +51,7 @@ RSpec.describe "Discobot welcome post" do
before { SiteSetting.discourse_narrative_bot_welcome_post_type = "welcome_message" }
- it "should not send welcome message" do
+ it "does not send a welcome message" do
expect { staged_user }.to_not change { Jobs::SendDefaultWelcomeMessage.jobs.count }
end
end
diff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rb
index 6f001f01a38..fadbca794b3 100644
--- a/plugins/discourse-narrative-bot/spec/user_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/user_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe User do
end
describe "when a user is created" do
- it "should initiate the bot" do
+ it "starts the bot tutorial" do
NotificationEmailer.expects(:process_notification).never
user
@@ -33,7 +33,7 @@ RSpec.describe User do
context "when disabled" do
before { SiteSetting.disable_discourse_narrative_bot_welcome_post = true }
- it "should not initiate the bot" do
+ it "does not start the bot tutorial" do
expect { user }.to_not change { Post.count }
end
end
@@ -70,7 +70,7 @@ RSpec.describe User do
describe "when send welcome message is selected" do
before { SiteSetting.discourse_narrative_bot_welcome_post_type = "welcome_message" }
- it "should send the right welcome message" do
+ it "sends the configured welcome message" do
expect { user }.to change { Topic.count }.by(1)
expect(Topic.last.title).to eq(
@@ -86,7 +86,7 @@ RSpec.describe User do
describe "when welcome message is configured to be delayed" do
before { SiteSetting.discourse_narrative_bot_welcome_post_delay = 100 }
- it "should delay the welcome post until user logs in" do
+ it "delays the welcome post until the user logs in" do
user
expect(Jobs::NarrativeInit.jobs.count).to eq(0)
@@ -98,7 +98,7 @@ RSpec.describe User do
context "when user is staged" do
let(:user) { Fabricate(:user, staged: true) }
- it "should not initiate the bot" do
+ it "does not start the bot tutorial" do
expect { user }.to_not change { Post.count }
end
end
@@ -106,7 +106,7 @@ RSpec.describe User do
context "when user skipped the new user tips" do
let(:user) { Fabricate(:user) }
- it "should not initiate the bot" do
+ it "does not start the bot tutorial" do
SiteSetting.default_other_skip_new_user_tips = true
expect { user }.to_not change { Post.count }
end
@@ -115,7 +115,7 @@ RSpec.describe User do
context "when user is anonymous?" do
before { SiteSetting.allow_anonymous_mode = true }
- it "should initiate bot for real user only" do
+ it "starts the bot only for the real user" do
user = Fabricate(:user, trust_level: 1)
Group.refresh_automatic_groups!
shadow = AnonymousShadowCreator.get(user)
@@ -131,7 +131,7 @@ RSpec.describe User do
before { SiteSetting.discourse_narrative_bot_ignored_usernames = "discourse|test" }
%w[discourse test].each do |username|
- it "should not initiate the bot" do
+ it "does not start the bot tutorial" do
expect { user.update!(username: username) }.to_not change { Post.count }
end
end
@@ -139,7 +139,7 @@ RSpec.describe User do
end
describe "when a user has been destroyed" do
- it "should clean up plugin's store" do
+ it "removes the user's plugin-store data" do
DiscourseNarrativeBot::Store.set(user.id, "test")
user.destroy!
diff --git a/plugins/discourse-oauth2-basic/spec/plugin_spec.rb b/plugins/discourse-oauth2-basic/spec/plugin_spec.rb
index 7ac0f9f768a..1dbff39858a 100644
--- a/plugins/discourse-oauth2-basic/spec/plugin_spec.rb
+++ b/plugins/discourse-oauth2-basic/spec/plugin_spec.rb
@@ -92,7 +92,7 @@ describe OAuth2BasicAuthenticator do
let(:fail_response) { { status: 403 } }
- it "works" do
+ it "supports GET and POST requests" do
stub_request(:get, SiteSetting.oauth2_user_json_url).to_return(success_response)
result = authenticator.after_authenticate(auth)
expect(result.email).to eq("[email protected]")
diff --git a/plugins/discourse-patreon/spec/integration/patreon_spec.rb b/plugins/discourse-patreon/spec/integration/patreon_spec.rb
index 7e702cc6378..43bba193c29 100644
--- a/plugins/discourse-patreon/spec/integration/patreon_spec.rb
+++ b/plugins/discourse-patreon/spec/integration/patreon_spec.rb
@@ -14,11 +14,11 @@ RSpec.describe Patreon do
context "with donation prompt enabled" do
before { SiteSetting.patreon_donation_prompt_enabled = true }
- it "should not show donation prompt to patrons" do
+ it "does not show the donation prompt to patrons" do
expect(described_class.show_donation_prompt_to_user?(user1)).to eq(false)
end
- it "should show donation prompt to non-patrons" do
+ it "shows the donation prompt to non-patrons" do
expect(described_class.show_donation_prompt_to_user?(user2)).to eq(true)
end
end
@@ -26,7 +26,7 @@ RSpec.describe Patreon do
context "with donation prompt disabled" do
before { SiteSetting.patreon_donation_prompt_enabled = false }
- it "should show donation prompt to non-patrons" do
+ it "shows the donation prompt to non-patrons" do
expect(described_class.show_donation_prompt_to_user?(user2)).to eq(false)
end
end
diff --git a/plugins/discourse-patreon/spec/jobs/patreon_update_tokens_spec.rb b/plugins/discourse-patreon/spec/jobs/patreon_update_tokens_spec.rb
index 29ccafce90a..f546d06dec3 100644
--- a/plugins/discourse-patreon/spec/jobs/patreon_update_tokens_spec.rb
+++ b/plugins/discourse-patreon/spec/jobs/patreon_update_tokens_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Jobs::PatreonUpdateTokens do
before { SiteSetting.patreon_enabled = true }
shared_examples "token refresh" do
- it "should update both access and refresh tokens from Patreon" do
+ it "updates both access and refresh tokens from Patreon" do
described_class.new.execute({})
expect(SiteSetting.patreon_creator_access_token).to eq("ACCESS TOKEN")
diff --git a/plugins/discourse-patreon/spec/lib/api_spec.rb b/plugins/discourse-patreon/spec/lib/api_spec.rb
index 1b7e82cf517..b7b5057db97 100644
--- a/plugins/discourse-patreon/spec/lib/api_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/api_spec.rb
@@ -15,13 +15,13 @@ RSpec.describe Patreon::Api do
before { SiteSetting.patreon_api_version = "1" }
- it "should add admin warning message for invalid api response" do
+ it "adds an admin warning for an invalid API response" do
stub_url(401, url)
described_class.campaign_data
expect(ProblemCheckTracker[:access_token_invalid].blips).to eq(1)
end
- it "should add warning log" do
+ it "logs a warning" do
stub_url(500, url)
Discourse.expects(:warn_exception).once
described_class.campaign_data
@@ -45,7 +45,7 @@ RSpec.describe Patreon::Api do
before { SiteSetting.patreon_api_version = "2" }
- it "should add admin warning message for invalid api response" do
+ it "adds an admin warning for an invalid API response" do
stub_url(401, url)
described_class.campaign_data
expect(ProblemCheckTracker[:access_token_invalid].blips).to eq(1)
@@ -54,7 +54,7 @@ RSpec.describe Patreon::Api do
)
end
- it "should not add admin warning message for valid api response" do
+ it "does not add an admin warning for a valid API response" do
stub_url(200, url)
described_class.campaign_data
@@ -62,7 +62,7 @@ RSpec.describe Patreon::Api do
expect(AdminNotice.find_by(identifier: :access_token_invalid)).to eq(nil)
end
- it "should clear an existing admin warning message once the api responds again" do
+ it "clears the admin warning when the API responds again" do
stub_url(401, url)
described_class.campaign_data
expect(AdminNotice.find_by(identifier: :access_token_invalid)).to be_present
@@ -75,7 +75,7 @@ RSpec.describe Patreon::Api do
expect(AdminNotice.find_by(identifier: :access_token_invalid)).to eq(nil)
end
- it "should add warning log" do
+ it "logs a warning" do
stub_url(500, url)
Discourse.expects(:warn_exception).once
expect(described_class.campaign_data).to eq(error: I18n.t(described_class::INVALID_RESPONSE))
diff --git a/plugins/discourse-patreon/spec/lib/campaign_spec.rb b/plugins/discourse-patreon/spec/lib/campaign_spec.rb
index a9bd59e1dd0..191a12810d4 100644
--- a/plugins/discourse-patreon/spec/lib/campaign_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/campaign_spec.rb
@@ -4,7 +4,7 @@ require_relative "../spec_helper"
RSpec.describe Patreon::Campaign do
shared_examples "campaign sync" do
- it "should update campaigns and group users data" do
+ it "updates campaigns and group membership data" do
expect { described_class.update! }.to change { Group.count }.by(1)
expect(Group.find_by(name: "patrons")).to be_present
diff --git a/plugins/discourse-patreon/spec/lib/patron_spec.rb b/plugins/discourse-patreon/spec/lib/patron_spec.rb
index fa369c62430..b9ec918acce 100644
--- a/plugins/discourse-patreon/spec/lib/patron_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/patron_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Patreon::Patron do
Patreon.set("reward-users", reward_users)
end
- it "should find local users matching Patreon user info" do
+ it "finds local users matching Patreon user information" do
Fabricate(:user, email: "[email protected]")
Fabricate(:patreon_user_info, provider_uid: "111112")
@@ -47,7 +47,7 @@ RSpec.describe Patreon::Patron do
end
end
- it "should find local users matching email address without case-sensitivity" do
+ it "finds local users matching the email address case-insensitively" do
patrons["111111"] = "[email protected]"
Patreon.set("users", patrons)
Fabricate(:user, email: "[email protected]")
@@ -66,14 +66,14 @@ RSpec.describe Patreon::Patron do
Patreon.set("filters", filters)
end
- it "should sync all Patreon users" do
+ it "syncs all Patreon users" do
user = Fabricate(:user, email: "[email protected]")
described_class.sync_groups
expect(group1.users.to_a - [patreon_user_info.user, user]).to eq([])
expect(group2.users.to_a - [patreon_user_info.user]).to eq([])
end
- it "should sync by Patreon id" do
+ it "syncs by Patreon ID" do
described_class.sync_groups_by(patreon_id: patreon_user_info.provider_uid)
expect(group1.users.to_a).to eq([patreon_user_info.user])
expect(group2.users.to_a).to eq([patreon_user_info.user])
diff --git a/plugins/discourse-patreon/spec/lib/seed_spec.rb b/plugins/discourse-patreon/spec/lib/seed_spec.rb
index 44aa3d09b98..c1c83fe3c91 100644
--- a/plugins/discourse-patreon/spec/lib/seed_spec.rb
+++ b/plugins/discourse-patreon/spec/lib/seed_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Patreon::Seed do
- it "should seed contents correctly" do
+ it "seeds the expected contents" do
described_class.seed_content!
group = Group.find_by(name: "patrons")
expect(group).to be_present
@@ -10,13 +10,13 @@ RSpec.describe Patreon::Seed do
expect(Patreon.get("filters")).to eq(group.id.to_s => ["0"])
end
- it "should not raise error if group already exists" do
+ it "does not raise an error when the group already exists" do
group = Fabricate(:group, name: "patrons")
described_class.seed_content!
expect(Patreon.get("filters")).to eq(group.id.to_s => ["0"])
end
- it "should not raise error if badge already exists" do
+ it "does not raise an error when the badge already exists" do
Badge.where(name: "Patron").first_or_create!(
badge_type_id: 1,
description: "test",
diff --git a/plugins/discourse-patreon/spec/requests/patreon_admin_controller_spec.rb b/plugins/discourse-patreon/spec/requests/patreon_admin_controller_spec.rb
index 7f0ba8a422e..abb42945851 100644
--- a/plugins/discourse-patreon/spec/requests/patreon_admin_controller_spec.rb
+++ b/plugins/discourse-patreon/spec/requests/patreon_admin_controller_spec.rb
@@ -17,7 +17,7 @@ describe Patreon::PatreonAdminController do
Patreon.set("rewards", rewards)
end
- it "should display list of patreon groups" do
+ it "returns the Patreon groups" do
get "/patreon/list.json"
result = JSON.parse(response.body)
@@ -34,14 +34,14 @@ describe Patreon::PatreonAdminController do
expect(response.parsed_body).to eq("unconfigured" => true)
end
- it "should display list of rewards" do
+ it "returns the Patreon rewards" do
get "/patreon/rewards.json"
rewards = JSON.parse(response.body)
expect(rewards.count).to eq(2)
end
- it "should update existing filter" do
+ it "updates an existing filter" do
ids = %w[1 2]
post "/patreon/list.json", params: { rewards_ids: ids, group_id: group1.id }
@@ -49,19 +49,19 @@ describe Patreon::PatreonAdminController do
expect(Patreon.get("filters")[group1.id.to_s]).to eq(ids)
end
- it "should delete an filter" do
+ it "deletes a filter" do
expect { delete "/patreon/list.json", params: { group_id: group1.id } }.to change {
Patreon.get("filters").count
}.by(-1)
expect(Patreon.get("filters")[group1.id.to_s]).to eq(nil)
end
- it "should sync patreon groups" do
+ it "synchronizes Patreon groups" do
Patreon::Patron.expects(:sync_groups)
post "/patreon/sync_groups.json"
end
- it "should enqueue job to sync patrons and groups" do
+ it "enqueues the patron and group synchronization job" do
expect_enqueued_with(job: :patreon_sync_patrons_to_groups) do
post "/patreon/update_data.json"
end
diff --git a/plugins/discourse-policy/spec/lib/check_policy_spec.rb b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
index df0782efc48..037f905f2de 100644
--- a/plugins/discourse-policy/spec/lib/check_policy_spec.rb
+++ b/plugins/discourse-policy/spec/lib/check_policy_spec.rb
@@ -216,7 +216,7 @@ describe Jobs::DiscoursePolicy::CheckPolicy do
end
end
- it "will correctly notify users with high priority notifications" do
+ it "sends high-priority notifications to users" do
Jobs.run_immediately!
freeze_time
@@ -297,7 +297,7 @@ describe Jobs::DiscoursePolicy::CheckPolicy do
end
end
- it "will delete the existing policy reminder notification before creating a new one" do
+ it "replaces the existing policy reminder notification" do
Jobs.run_immediately!
freeze_time
diff --git a/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb b/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb
index 09aa62fa961..8547d914af4 100644
--- a/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb
+++ b/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb
@@ -70,7 +70,7 @@ describe PostVoting::VoteManager do
end
describe ".remove_vote" do
- it "should remove a user's upvote" do
+ it "removes a user's upvote" do
vote = PostVoting::VoteManager.vote(post, user, direction: up)
message =
@@ -90,7 +90,7 @@ describe PostVoting::VoteManager do
expect(message.data[:post_voting_has_votes]).to eq(false)
end
- it "should remove a user's downvote" do
+ it "removes a user's downvote" do
vote = PostVoting::VoteManager.vote(post, Fabricate(:user), direction: up)
vote_2 = PostVoting::VoteManager.vote(post, Fabricate(:user), direction: up)
vote_3 = PostVoting::VoteManager.vote(post, user, direction: down)
diff --git a/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb b/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb
index c753e5ba7e4..5649fe51c60 100644
--- a/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb
+++ b/plugins/discourse-post-voting/spec/lib/topic_view_spec.rb
@@ -43,7 +43,7 @@ describe TopicView do
expect(topic_view.posts_user_voted).to eq(nil)
end
- it "should preload comments, comments count, user voted status for a given topic" do
+ it "preloads comments, comment count, and user vote status for a topic" do
PostVoting::VoteManager.vote(comment, user)
PostVoting::VoteManager.vote(comment_2, comment_3.user)
@@ -65,7 +65,7 @@ describe TopicView do
expect(topic_view.comments_user_voted).to eq({ comment.id => true })
end
- it "should respect Topic::PRELOAD_COMMENTS_COUNT when loading initial comments" do
+ it "respects Topic::PRELOAD_COMMENTS_COUNT when loading initial comments" do
stub_const(TopicView, "PRELOAD_COMMENTS_COUNT", 1) do
topic_view = TopicView.new(topic, user)
@@ -74,7 +74,7 @@ describe TopicView do
end
end
- it "should preload the right comments even if comments have been deleted" do
+ it "preloads the expected comments even when comments have been deleted" do
comment_4 = Fabricate(:post_voting_comment, post: answer)
comment.trash!
diff --git a/plugins/discourse-post-voting/spec/models/post_spec.rb b/plugins/discourse-post-voting/spec/models/post_spec.rb
index 64be20f0010..a99d48f1074 100644
--- a/plugins/discourse-post-voting/spec/models/post_spec.rb
+++ b/plugins/discourse-post-voting/spec/models/post_spec.rb
@@ -24,9 +24,9 @@ describe Post do
end
end
- it("should ignore vote_count") { expect(Post.ignored_columns.include?("vote_count")).to eq(true) }
+ it("ignores vote_count") { expect(Post.ignored_columns.include?("vote_count")).to eq(true) }
- it "should return last voted correctly" do
+ it "returns the last vote correctly" do
freeze_time do
expect(post.post_voting_last_voted(user1.id)).to eq(nil)
@@ -36,7 +36,7 @@ describe Post do
end
end
- it "should return post_voting_can_vote correctly" do
+ it "returns post_voting_can_vote correctly" do
expect(post.post_voting_can_vote(user1.id, PostVotingVote.directions[:up])).to eq(true)
PostVoting::VoteManager.vote(post, user1)
diff --git a/plugins/discourse-post-voting/spec/models/topic_spec.rb b/plugins/discourse-post-voting/spec/models/topic_spec.rb
index 9bc29f486d3..39274338d68 100644
--- a/plugins/discourse-post-voting/spec/models/topic_spec.rb
+++ b/plugins/discourse-post-voting/spec/models/topic_spec.rb
@@ -18,7 +18,7 @@ describe Topic do
describe "validations" do
describe "#subtype" do
- it "should not allow Post Voting formatted topics to be created when post_voting_enabled site setting is not enabled" do
+ it "rejects Post Voting topics when post_voting_enabled is disabled" do
SiteSetting.post_voting_enabled = false
topic =
@@ -30,7 +30,7 @@ describe Topic do
)
end
- it "should not allow topic to change to Post Voting subtype once it has been created" do
+ it "rejects changing an existing topic to the Post Voting subtype" do
topic_2 = Fabricate(:topic)
topic_2.subtype = Topic::POST_VOTING_SUBTYPE
@@ -40,7 +40,7 @@ describe Topic do
)
end
- it "should only allow Post Voting subtype to be set on regular topics" do
+ it "allows the Post Voting subtype only on regular topics" do
topic =
Fabricate.build(:topic, archetype: Archetype.default, subtype: Topic::POST_VOTING_SUBTYPE)
@@ -56,43 +56,43 @@ describe Topic do
end
end
- it "should return correct comments" do
+ it "returns the topic's comments" do
comment_ids = comments.map(&:id)
topic_comment_ids = topic.comments.pluck(:id)
expect(comment_ids).to eq(topic_comment_ids)
end
- it "should return correct answers" do
+ it "returns the topic's answers" do
answer_ids = answers.map(&:id)
topic_answer_ids = topic.answers.pluck(:id)
expect(answer_ids).to eq(topic_answer_ids)
end
- it "should return correct answer_count" do
+ it "returns the answer count" do
expect(topic.answers.size).to eq(answers.size)
end
- it "should return correct last_answered_at" do
+ it "returns the last answer's timestamp" do
expected = answers.last.created_at
expect(topic.last_answered_at).to eq_time(expected)
end
- it "should return correct last_commented_on" do
+ it "returns the last comment's timestamp" do
expected = comments.last.created_at
expect(topic.last_commented_on).to eq_time(expected)
end
- it "should return correct last_answer_post_number" do
+ it "returns the last answer's post number" do
expected = answers.last.post_number
expect(topic.last_answer_post_number).to eq(expected)
end
- it "should return correct last_answerer" do
+ it "returns the last answer's author" do
expected = answers.last.user.id
expect(topic.last_answerer.id).to eq(expected)
@@ -110,17 +110,17 @@ describe Topic do
end
describe ".post_voting_votes" do
- it "should return nil if user is blank" do
+ it "returns nil if user is blank" do
expect(Topic.post_voting_votes(topic, nil)).to eq(nil)
end
- it "should return nil if disabled" do
+ it "returns nil if disabled" do
SiteSetting.post_voting_enabled = false
expect(Topic.post_voting_votes(topic, user)).to eq(nil)
end
- it "should return voted post IDs" do
+ it "returns voted post IDs" do
expected =
answers
.first(3)
diff --git a/plugins/discourse-post-voting/spec/requests/list_controller_spec.rb b/plugins/discourse-post-voting/spec/requests/list_controller_spec.rb
index c2d85b5f255..88144f2f10b 100644
--- a/plugins/discourse-post-voting/spec/requests/list_controller_spec.rb
+++ b/plugins/discourse-post-voting/spec/requests/list_controller_spec.rb
@@ -15,7 +15,7 @@ describe ListController do
sign_in(user)
end
- it "should return the right attributes for Post Voting topics" do
+ it "returns the expected attributes for Post Voting topics" do
TopicUser.create!(user: user, topic: post_voting_topic, last_read_post_number: 2)
TopicUser.create!(user: user, topic: topic, last_read_post_number: 2)
@@ -31,7 +31,7 @@ describe ListController do
expect(non_post_voting["is_post_voting"]).to eq(nil)
end
- it "should return the right attributes when Post Voting is disabled" do
+ it "returns the expected attributes when Post Voting is disabled" do
SiteSetting.post_voting_enabled = false
TopicUser.create!(user: user, topic: post_voting_topic, last_read_post_number: 2)
diff --git a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb
index 9c0b3935ba3..2639f607391 100644
--- a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb
+++ b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe PostVoting::CommentsController do
end
describe "#update" do
- it "should return 403 for an anon user" do
+ it "returns 403 for an anonymous user" do
put "/post_voting/comments.json",
params: {
comment_id: comment.id,
@@ -197,7 +197,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(403)
end
- it "should return 404 when comment_id is not associated to a valid record" do
+ it "returns 404 when comment_id does not identify a comment" do
sign_in(comment.user)
put "/post_voting/comments.json",
@@ -209,7 +209,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(404)
end
- it "should return 403 when trying to update a comment on a post the user cannot see" do
+ it "returns 403 when updating a comment on an inaccessible post" do
sign_in(comment.user)
category.set_permissions(group => :readonly)
@@ -224,7 +224,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(403)
end
- it "should return 403 when a user is trying to update the comment of another user" do
+ it "returns 403 when updating another user's comment" do
sign_in(Fabricate(:user))
put "/post_voting/comments.json",
@@ -236,7 +236,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(403)
end
- it "should allow an admin to update the comment" do
+ it "allows an admin to update the comment" do
sign_in(admin)
put "/post_voting/comments.json",
@@ -253,7 +253,7 @@ RSpec.describe PostVoting::CommentsController do
expect(body["cooked"]).to eq("<p>this is some new raw</p>")
end
- it "should allow a moderator to update the comment" do
+ it "allows a moderator to update the comment" do
sign_in(moderator)
put "/post_voting/comments.json",
@@ -270,7 +270,7 @@ RSpec.describe PostVoting::CommentsController do
expect(body["cooked"]).to eq("<p>this is some new raw</p>")
end
- it "should allow users to update their own comment and publishes a MessageBus message" do
+ it "updates the user's own comment and publishes the change" do
sign_in(comment.user)
message =
@@ -298,8 +298,8 @@ RSpec.describe PostVoting::CommentsController do
end
end
- describe "#flag" do
- it "should return 403 with not_logged_in error for an anon user" do
+ describe "#flag authentication" do
+ it "returns 403 with not_logged_in for an anonymous user" do
put "/post_voting/comments/flag.json",
params: {
comment_id: comment.id,
@@ -312,13 +312,13 @@ RSpec.describe PostVoting::CommentsController do
end
describe "#destroy" do
- it "should return 403 for an anon user" do
+ it "returns 403 for an anonymous user" do
delete "/post_voting/comments.json", params: { comment_id: comment.id }
expect(response.status).to eq(403)
end
- it "should return 404 when comment_id param given does not exist" do
+ it "returns 404 when comment_id does not exist" do
sign_in(comment.user)
delete "/post_voting/comments.json", params: { comment_id: -99_999 }
@@ -326,7 +326,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(404)
end
- it "should return 403 when trying to delete a comment on a post the user cannot see" do
+ it "returns 403 when deleting a comment on an inaccessible post" do
sign_in(comment.user)
category.set_permissions(group => :readonly)
@@ -337,7 +337,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(403)
end
- it "should return 403 when a user is trying to delete another user's comment" do
+ it "returns 403 when deleting another user's comment" do
sign_in(Fabricate(:user))
delete "/post_voting/comments.json", params: { comment_id: comment.id }
@@ -345,7 +345,7 @@ RSpec.describe PostVoting::CommentsController do
expect(response.status).to eq(403)
end
- it "should allow an admin to delete a comment of another user" do
+ it "allows an admin to delete another user's comment" do
sign_in(admin)
delete "/post_voting/comments.json", params: { comment_id: comment.id }
@@ -359,7 +359,7 @@ RSpec.describe PostVoting::CommentsController do
).to eq(true)
end
- it "should allow a moderator to delete a comment of another user" do
+ it "allows a moderator to delete another user's comment" do
sign_in(moderator)
delete "/post_voting/comments.json", params: { comment_id: comment.id }
@@ -373,7 +373,7 @@ RSpec.describe PostVoting::CommentsController do
).to eq(true)
end
- it "should allow users to delete their own comment and publishes a message bus message" do
+ it "deletes the user's own comment and publishes the change" do
sign_in(comment.user)
message =
@@ -403,7 +403,7 @@ RSpec.describe PostVoting::CommentsController do
before { sign_in(flagger) }
- it "should return 403 when trying to flag a comment on a post the user cannot see" do
+ it "returns 403 when flagging a comment on an inaccessible post" do
category.set_permissions(group => :full)
category.save!
diff --git a/plugins/discourse-post-voting/spec/requests/post_voting/votes_controller_spec.rb b/plugins/discourse-post-voting/spec/requests/post_voting/votes_controller_spec.rb
index 1be7ccdcf23..11bf61623c9 100644
--- a/plugins/discourse-post-voting/spec/requests/post_voting/votes_controller_spec.rb
+++ b/plugins/discourse-post-voting/spec/requests/post_voting/votes_controller_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe PostVoting::VotesController do
expect(response.status).to eq(403)
end
- it "should be successful if post has never been voted" do
+ it "creates a vote when the user has not voted on the post" do
post "/post_voting/vote.json", params: { post_id: answer.id }
expect(response.status).to eq(200)
@@ -37,7 +37,7 @@ RSpec.describe PostVoting::VotesController do
expect(vote.user_id).to eq(user.id)
end
- it "should error if already voted" do
+ it "rejects a duplicate vote" do
post "/post_voting/vote.json", params: { post_id: answer.id }
expect(response.status).to eq(200)
@@ -71,13 +71,13 @@ RSpec.describe PostVoting::VotesController do
end
end
- it "should return 403 if user votes on a post by self" do
+ it "returns 403 when voting on the user's own post" do
post "/post_voting/vote.json", params: { post_id: answer_3.id }
expect(response.status).to eq(403)
end
- it "should return 403 after post_voting_undo_vote_action_window" do
+ it "returns 403 after the vote undo window expires" do
SiteSetting.post_voting_undo_vote_action_window = 1
post "/post_voting/vote.json", params: { post_id: answer.id }
@@ -102,7 +102,7 @@ RSpec.describe PostVoting::VotesController do
describe "#destroy" do
before { sign_in(user) }
- it "should success if has voted" do
+ it "removes an existing vote" do
post "/post_voting/vote.json", params: { post_id: answer.id }
expect(response.status).to eq(200)
@@ -118,13 +118,13 @@ RSpec.describe PostVoting::VotesController do
expect(PostVotingVote.exists?(id: vote.id)).to eq(false)
end
- it "should return the right response if user has never voted on post" do
+ it "returns 403 when the user has never voted on the post" do
delete "/post_voting/vote.json", params: { post_id: answer.id }
expect(response.status).to eq(403)
end
- it "should cant undo vote" do
+ it "rejects undoing a vote after the undo window expires" do
SiteSetting.post_voting_undo_vote_action_window = 1
post "/post_voting/vote.json", params: { post_id: answer.id }
@@ -145,13 +145,13 @@ RSpec.describe PostVoting::VotesController do
describe "#voters" do
fab!(:user)
- it "should return the right response for an anon user" do
+ it "returns 403 for an anonymous user" do
get "/post_voting/voters.json", params: { post_id: answer.id }
expect(response.status).to eq(403)
end
- it "should return the right response if post does not exist" do
+ it "returns 404 if the post does not exist" do
sign_in(user)
get "/post_voting/voters.json", params: { post_id: -1 }
@@ -184,7 +184,7 @@ RSpec.describe PostVoting::VotesController do
expect(voter_payload["direction"]).to eq(PostVotingVote.directions[:up])
end
- it "should return correct users respecting limits" do
+ it "returns voters within the requested limit" do
sign_in(user)
user_2 = Fabricate(:user)
@@ -220,7 +220,7 @@ RSpec.describe PostVoting::VotesController do
expect(parsed["total_voters_count"]).to eq(2)
end
- it "should return total_voters_count so the client can compute remaining voters correctly" do
+ it "returns total_voters_count for computing the remaining voters" do
sign_in(user)
user_2 = Fabricate(:user)
@@ -258,13 +258,13 @@ RSpec.describe PostVoting::VotesController do
let(:comment) { Fabricate(:post_voting_comment, post: answer) }
let(:comment_2) { Fabricate(:post_voting_comment, post: answer, user: user) }
- it "should return 403 for an anon user" do
+ it "returns 403 for an anonymous user" do
post "/post_voting/vote/comment.json", params: { comment_id: comment.id }
expect(response.status).to eq(403)
end
- it "should return 404 if comment_id param is not valid" do
+ it "returns 404 if comment_id is invalid" do
sign_in(user)
post "/post_voting/vote/comment.json", params: { comment_id: -999 }
@@ -272,7 +272,7 @@ RSpec.describe PostVoting::VotesController do
expect(response.status).to eq(404)
end
- it "should return 403 if user is not allowed to see comment" do
+ it "returns 403 if the user cannot see the comment" do
sign_in(user)
topic.update!(category: category)
@@ -283,7 +283,7 @@ RSpec.describe PostVoting::VotesController do
expect(response.status).to eq(403)
end
- it "should return 403 if user votes on a comment by self" do
+ it "returns 403 when voting on the user's own comment" do
sign_in(user)
post "/post_voting/vote/comment.json", params: { comment_id: comment_2.id }
@@ -307,13 +307,13 @@ RSpec.describe PostVoting::VotesController do
describe "#destroy_comment_vote" do
let(:comment) { Fabricate(:post_voting_comment, post: answer) }
- it "should return 403 for an anon user" do
+ it "returns 403 for an anonymous user" do
delete "/post_voting/vote/comment.json", params: { comment_id: comment.id }
expect(response.status).to eq(403)
end
- it "should return 404 if comment_id param is not valid" do
+ it "returns 404 if comment_id is invalid" do
sign_in(user)
delete "/post_voting/vote/comment.json", params: { comment_id: -999 }
@@ -321,7 +321,7 @@ RSpec.describe PostVoting::VotesController do
expect(response.status).to eq(404)
end
- it "should return 403 if user has not voted on comment" do
+ it "returns 403 if the user has not voted on the comment" do
sign_in(user)
delete "/post_voting/vote/comment.json", params: { comment_id: comment.id }
@@ -329,7 +329,7 @@ RSpec.describe PostVoting::VotesController do
expect(response.status).to eq(403)
end
- it "should be able to remove a user's vote from a comment" do
+ it "removes the user's vote from the comment" do
PostVoting::VoteManager.vote(comment, user, direction: PostVotingVote.directions[:up])
sign_in(user)
diff --git a/plugins/discourse-post-voting/spec/serializers/basic_category_serializer_spec.rb b/plugins/discourse-post-voting/spec/serializers/basic_category_serializer_spec.rb
index 989154055bb..4b2afca4304 100644
--- a/plugins/discourse-post-voting/spec/serializers/basic_category_serializer_spec.rb
+++ b/plugins/discourse-post-voting/spec/serializers/basic_category_serializer_spec.rb
@@ -16,7 +16,7 @@ describe BasicCategorySerializer do
context "with qa enabled" do
before { SiteSetting.post_voting_enabled = true }
- it "should return post_voting category attributes" do
+ it "returns post_voting category attributes" do
expect(serialized[:create_as_post_voting_default]).to eq(true)
end
end
@@ -24,7 +24,7 @@ describe BasicCategorySerializer do
context "with qa disabled" do
before { SiteSetting.post_voting_enabled = false }
- it "should not return qa category attributes" do
+ it "omits QA category attributes" do
expect(serialized.key?(:create_as_post_voting_default)).to eq(false)
end
end
diff --git a/plugins/discourse-post-voting/spec/serializers/post_voting/post_serializer_spec.rb b/plugins/discourse-post-voting/spec/serializers/post_voting/post_serializer_spec.rb
index 06d0af647d6..a1b7d9be2e8 100644
--- a/plugins/discourse-post-voting/spec/serializers/post_voting/post_serializer_spec.rb
+++ b/plugins/discourse-post-voting/spec/serializers/post_voting/post_serializer_spec.rb
@@ -19,7 +19,7 @@ describe PostVoting::PostSerializerExtension do
context "with qa enabled" do
before { SiteSetting.post_voting_enabled = true }
- it "should return the right attributes" do
+ it "returns the post-voting attributes" do
PostVoting::VoteManager.vote(answer, user, direction: up)
expect(serialized[:post_voting_vote_count]).to eq(1)
@@ -32,7 +32,7 @@ describe PostVoting::PostSerializerExtension do
context "with qa disabled" do
before { SiteSetting.post_voting_enabled = false }
- it "should not include dependent_keys" do
+ it "does not include dependent_keys" do
expect(serialized[:qa_vote_count]).to eq(nil)
expect(serialized[:qa_user_voted_direction]).to eq(nil)
expect(serialized[:comments_count]).to eq(nil)
diff --git a/plugins/discourse-post-voting/spec/serializers/post_voting/topic_view_serializer_spec.rb b/plugins/discourse-post-voting/spec/serializers/post_voting/topic_view_serializer_spec.rb
index 6cc8774f49f..a54a477788d 100644
--- a/plugins/discourse-post-voting/spec/serializers/post_voting/topic_view_serializer_spec.rb
+++ b/plugins/discourse-post-voting/spec/serializers/post_voting/topic_view_serializer_spec.rb
@@ -12,7 +12,7 @@ describe PostVoting::TopicViewSerializerExtension do
before { SiteSetting.post_voting_enabled = true }
- it "should return correct values" do
+ it "returns the topic's post-voting values" do
PostVoting::VoteManager.vote(topic_post, user)
PostVoting::VoteManager.vote(answer, user)
PostVoting::VoteManager.vote(answer, Fabricate(:user))
@@ -44,7 +44,7 @@ describe PostVoting::TopicViewSerializerExtension do
expect(posts.last[:comments_count]).to eq(1)
end
- it "should not include dependent_attrs when plugin is disabled" do
+ it "omits dependent_attrs when the plugin is disabled" do
SiteSetting.post_voting_enabled = false
payload = TopicViewSerializer.new(topic_view, scope: guardian, root: false).as_json
diff --git a/plugins/discourse-reactions/spec/models/post_mover_spec.rb b/plugins/discourse-reactions/spec/models/post_mover_spec.rb
index 645d3fb0fc7..1a8a5e3d7d7 100644
--- a/plugins/discourse-reactions/spec/models/post_mover_spec.rb
+++ b/plugins/discourse-reactions/spec/models/post_mover_spec.rb
@@ -18,7 +18,7 @@ describe PostMover do
before { enable_current_plugin }
- it "should create new post when topic's first post has no reactions" do
+ it "creates a new post when the topic's first post has no reactions" do
old_topic = Fabricate(:topic)
new_topic = Fabricate(:topic)
post = Fabricate(:post, topic: old_topic)
@@ -27,7 +27,7 @@ describe PostMover do
expect { post_mover.to_topic(new_topic) }.to change { new_topic.posts.count }.by(1)
end
- it "should create new post when first post has likes but no emoji reaction user" do
+ it "creates a new post when the first post has likes but no emoji reactions" do
old_topic = Fabricate(:topic)
new_topic = Fabricate(:topic)
post = Fabricate(:post, topic: old_topic)
@@ -46,7 +46,7 @@ describe PostMover do
expect(new_post.reactions_user.count).to eq(0)
end
- it "should add old post's reactions to new post when a topic's first post is moved" do
+ it "moves the first post's reactions to the new post" do
expect(post_1.reactions).to contain_exactly(reaction_1, reaction_2)
expect(topic_2.posts.count).to eq(0)
@@ -66,7 +66,7 @@ describe PostMover do
expect(reaction_user_ids).to match_array([user_reaction_1.user_id, user_reaction_2.user_id])
end
- it "should retain existing reactions after moving a post" do
+ it "retains existing reactions after moving a post" do
expect(post_2.reactions).to contain_exactly(reaction_3, reaction_4)
expect(topic_3.posts.count).to eq(0)
diff --git a/plugins/discourse-solved/spec/integration/solved_spec.rb b/plugins/discourse-solved/spec/integration/solved_spec.rb
index a6279479baf..90360751e5e 100644
--- a/plugins/discourse-solved/spec/integration/solved_spec.rb
+++ b/plugins/discourse-solved/spec/integration/solved_spec.rb
@@ -619,7 +619,7 @@ RSpec.describe "Managing Posts solved status" do
topic.reload
end
- it "should unmark the post as solved" do
+ it "unmarks the post as solved" do
expect do post "/solution/unaccept.json", params: { id: p1.id } end.to change {
topic.reload.public_topic_timer
}.to(nil)
@@ -657,7 +657,7 @@ RSpec.describe "Managing Posts solved status" do
topic.reload
end
- it "should unmark the post as solved only when last solution unaccepted" do
+ it "unmarks the post as solved only when the last solution is unaccepted" do
expect do post "/solution/unaccept.json", params: { id: p1.id } end.not_to change {
topic.reload.public_topic_timer
}
diff --git a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb
index 0025d12857f..d70c1cb4533 100644
--- a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb
+++ b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb
@@ -10,7 +10,7 @@ describe DiscourseSolved::GuardianExtensions do
before { SiteSetting.allow_solved_on_all_topics = true }
- describe ".can_unaccept_answer?" do
+ describe ".can_unaccept_answer? with a missing topic" do
it "returns false when topic is nil" do
admin = Fabricate(:admin, refresh_auto_groups: true)
expect(Guardian.new(admin).can_unaccept_answer?(nil, post)).to be_falsey
diff --git a/plugins/discourse-solved/spec/requests/topics_controller_spec.rb b/plugins/discourse-solved/spec/requests/topics_controller_spec.rb
index e3de6b186b9..80f6003813f 100644
--- a/plugins/discourse-solved/spec/requests/topics_controller_spec.rb
+++ b/plugins/discourse-solved/spec/requests/topics_controller_spec.rb
@@ -39,13 +39,13 @@ RSpec.describe TopicsController do
context "with solved enabled on every topic" do
before { SiteSetting.allow_solved_on_all_topics = true }
- it "should not include schema information for single-post topics without answers" do
+ it "omits schema information for single-post topics without answers" do
get "/t/#{topic.slug}/#{topic.id}"
expect(response.body).not_to include("QAPage")
end
- it "should include correct schema information when topic has an accepted answer" do
+ it "includes schema information for the accepted answer" do
Fabricate(:solved_topic, topic:, answer_post: p2)
get "/t/#{topic.slug}/#{topic.id}"
@@ -74,7 +74,7 @@ RSpec.describe TopicsController do
expect(schema_json).not_to include(hidden_text)
end
- it "should include quoted content in schema information" do
+ it "includes quoted content in schema information" do
Fabricate(:solved_topic, topic:, answer_post: p2)
post = topic.first_post
@@ -87,7 +87,7 @@ RSpec.describe TopicsController do
expect(response.body).to include('"text":"This is a quoted text."')
end
- it "should include user name in output with the corresponding site setting" do
+ it "includes the user name when enabled in site settings" do
SiteSetting.display_name_on_posts = true
SiteSetting.show_who_marked_solved = true
accepter = Fabricate(:user)
@@ -114,7 +114,7 @@ RSpec.describe TopicsController do
expect(response.parsed_body["accepted_answers"][0]["accepter_name"]).to eq(nil)
end
- it "should not include user name when site setting is disabled" do
+ it "omits the user name when disabled in site settings" do
SiteSetting.display_name_on_posts = false
Fabricate(:solved_topic, topic:, answer_post: p2)
@@ -166,7 +166,7 @@ RSpec.describe TopicsController do
let!(:second_topic_answer) { Fabricate(:topic_answer, solved_topic:, post: p3) }
let!(:unaccepted_post) { p4 }
- it "should include correct schema information " do
+ it "includes the expected schema information" do
get "/t/#{topic.slug}/#{topic.id}"
two_accepted_answers_json =
@@ -302,7 +302,7 @@ RSpec.describe TopicsController do
before { SiteSetting.solved_allow_multiple_solutions = true }
- it "should include two acceptedAnswers and a suggestedAnswer in qaschema" do
+ it "includes two acceptedAnswers and a suggestedAnswer in qaschema" do
get "/t/#{topic.slug}/#{topic.id}", env: crawler_env
doc = parsed_crawler_body
diff --git a/plugins/discourse-solved/spec/serializers/topic_answer_mixin_spec.rb b/plugins/discourse-solved/spec/serializers/topic_answer_mixin_spec.rb
index 4f436e5b03d..81568e7734d 100644
--- a/plugins/discourse-solved/spec/serializers/topic_answer_mixin_spec.rb
+++ b/plugins/discourse-solved/spec/serializers/topic_answer_mixin_spec.rb
@@ -7,7 +7,7 @@ describe DiscourseSolved::TopicAnswerMixin do
before { Fabricate(:solved_topic, topic: topic, answer_post: post) }
- it "should have true for `has_accepted_answer` field in each serializer" do
+ it "sets has_accepted_answer in each serializer" do
[
TopicListItemSerializer,
SearchTopicListItemSerializer,
diff --git a/plugins/discourse-solved/spec/system/solved_spec.rb b/plugins/discourse-solved/spec/system/solved_spec.rb
index 134d1163a29..fb224c91948 100644
--- a/plugins/discourse-solved/spec/system/solved_spec.rb
+++ b/plugins/discourse-solved/spec/system/solved_spec.rb
@@ -111,7 +111,7 @@ describe "Solved" do
end
end
- it "should collapse/expand the solution when clicking the toggle" do
+ it "collapses and expands the solution when clicking the toggle" do
solved_topic = Fabricate(:solved_topic, topic:)
Fabricate(:topic_answer, solved_topic:, post: solver_post, accepter:)
diff --git a/plugins/discourse-subscriptions/spec/jobs/refresh_subscriptions_campaign_data_spec.rb b/plugins/discourse-subscriptions/spec/jobs/refresh_subscriptions_campaign_data_spec.rb
index d2373df8105..999faca75d2 100644
--- a/plugins/discourse-subscriptions/spec/jobs/refresh_subscriptions_campaign_data_spec.rb
+++ b/plugins/discourse-subscriptions/spec/jobs/refresh_subscriptions_campaign_data_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Jobs::RefreshSubscriptionsCampaignData do
before { SiteSetting.discourse_subscriptions_campaign_enabled = true }
- it "should execute the job only if stripe is configured" do
+ it "executes the job only when Stripe is configured" do
DiscourseSubscriptions::Campaign.any_instance.expects(:refresh_data).once
described_class.new.execute({})
diff --git a/plugins/discourse-subscriptions/spec/requests/hooks_controller_spec.rb b/plugins/discourse-subscriptions/spec/requests/hooks_controller_spec.rb
index c9c6ef33f29..3d078c43ff0 100644
--- a/plugins/discourse-subscriptions/spec/requests/hooks_controller_spec.rb
+++ b/plugins/discourse-subscriptions/spec/requests/hooks_controller_spec.rb
@@ -475,7 +475,7 @@ RSpec.describe DiscourseSubscriptions::HooksController do
end
describe "completing the subscription" do
- it "does not add the user to the group" do
+ it "does not add the user to the group when the status remains incomplete" do
event_data[:object][:status] = "incomplete"
event_data[:previous_attributes] = { status: "incomplete" }
@@ -484,7 +484,7 @@ RSpec.describe DiscourseSubscriptions::HooksController do
expect(response.status).to eq 200
end
- it "does not add the user to the group" do
+ it "does not add the user to the group when the status becomes incomplete" do
event_data[:object][:status] = "incomplete"
event_data[:previous_attributes] = { status: "something-else" }
diff --git a/plugins/discourse-templates/spec/lib/topic_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_extension_spec.rb
index 34c77e1af4c..3f388702d5a 100644
--- a/plugins/discourse-templates/spec/lib/topic_extension_spec.rb
+++ b/plugins/discourse-templates/spec/lib/topic_extension_spec.rb
@@ -110,7 +110,7 @@ describe DiscourseTemplates::TopicExtension do
end
end
- it "won't leak state into the Category.subcategory_ids cache" do
+ it "does not leak state into the Category.subcategory_ids cache" do
category = Fabricate(:category_with_definition)
subcategory = Fabricate(:category_with_definition, parent_category: category)
topic = Fabricate(:template_item, category: subcategory)
diff --git a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb
index 423526a27ac..996de870670 100644
--- a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb
+++ b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb
@@ -186,7 +186,7 @@ describe DiscourseTemplates::TopicQueryExtension do
expect(topics.size).to eq(0)
end
- it "won't list private messages received as templates" do
+ it "does not list received private messages as templates" do
topics = topic_query.list_private_templates.topics
expect((topics.map(&:id) & private_messages_from_user_a.map(&:id)).any?).to eq(false)
end
diff --git a/plugins/discourse-templates/spec/requests/templates_controller_spec.rb b/plugins/discourse-templates/spec/requests/templates_controller_spec.rb
index a2cc6cb2c98..ab446414054 100644
--- a/plugins/discourse-templates/spec/requests/templates_controller_spec.rb
+++ b/plugins/discourse-templates/spec/requests/templates_controller_spec.rb
@@ -85,7 +85,7 @@ describe DiscourseTemplates::TemplatesController do
context "when a regular user is logged" do
before { sign_in(user) }
- it "should list topics in the category assigned as templates" do
+ it "lists topics in the templates category" do
SiteSetting.discourse_templates_categories = templates_sub_category_everyone.id.to_s
get "/discourse_templates"
@@ -116,7 +116,7 @@ describe DiscourseTemplates::TemplatesController do
expect(template["tags"]).to contain_exactly(everyone_tag.name)
end
- it "should list topics from multiple parent categories" do
+ it "lists topics from multiple parent categories" do
SiteSetting.discourse_templates_categories = [
templates_sub_category_everyone,
templates_other_parent_category,
@@ -135,7 +135,7 @@ describe DiscourseTemplates::TemplatesController do
expect(parsed["templates"]).to eq(expected_response)
end
- it "should list topics in the parent category and subcategories that the user can see" do
+ it "lists visible topics in the parent category and subcategories" do
SiteSetting.discourse_templates_categories = templates_parent_category.id.to_s
get "/discourse_templates"
@@ -157,7 +157,7 @@ describe DiscourseTemplates::TemplatesController do
expect(parsed["templates"]).to eq(expected_response)
end
- it "should not be able to use templates if can't see topics in the category" do
+ it "rejects templates when the user cannot see topics in the category" do
SiteSetting.discourse_templates_categories = templates_sub_category_moderators.id.to_s
get "/discourse_templates"
@@ -181,7 +181,7 @@ describe DiscourseTemplates::TemplatesController do
sign_in(moderator)
end
- it "should list topics in the parent category and subcategories that the moderator can see" do
+ it "lists topics in the parent category and subcategories visible to the moderator" do
SiteSetting.discourse_templates_categories = [
templates_parent_category,
templates_other_parent_category,
@@ -210,7 +210,7 @@ describe DiscourseTemplates::TemplatesController do
end
context "when an user belonging to a group is logged" do
- it "should list topics in the parent category and subcategories that the user can see" do
+ it "lists visible topics in the parent category and subcategories" do
SiteSetting.discourse_templates_categories = [
templates_parent_category,
templates_other_parent_category,
@@ -273,7 +273,7 @@ describe DiscourseTemplates::TemplatesController do
Group.refresh_automatic_groups!
end
- it "should list topics in the parent category and subcategories that the admin can see" do
+ it "lists topics in the parent category and subcategories visible to the admin" do
get "/discourse_templates"
expect(response.status).to eq(200)
@@ -297,7 +297,7 @@ describe DiscourseTemplates::TemplatesController do
expect(parsed["templates"]).to eq(expected_response)
end
- it "should not list delete, archived and unlisted topics" do
+ it "excludes deleted, archived, and unlisted topics" do
template_item0.trash!(admin)
expect(template_item0.deleted_at).not_to eq(nil)
@@ -330,7 +330,7 @@ describe DiscourseTemplates::TemplatesController do
end
context "when no user is signed in" do
- it "should return 404" do
+ it "returns 404" do
SiteSetting.discourse_templates_categories = templates_sub_category_everyone.id.to_s
get "/discourse_templates"
@@ -348,7 +348,7 @@ describe DiscourseTemplates::TemplatesController do
Group.refresh_automatic_groups!
end
- it "should return 422 when id does not belong to a valid topic" do
+ it "returns 422 when id does not identify a topic" do
# to avoid flaky testing we create a topic and immediately destroy it to obtain
# an invalid topic id
invalid_topic_id = Fabricate(:template_item).tap(&:destroy!).id
@@ -357,17 +357,17 @@ describe DiscourseTemplates::TemplatesController do
expect(response.status).to eq(422)
end
- it "should return 422 when topic does not belong to template category or its subcategories" do
+ it "returns 422 for topics outside the templates category and its subcategories" do
post "/discourse_templates/#{other_topic1.id}/use"
expect(response.status).to eq(422)
end
- it "should return 200 if the topic belongs to the templates category" do
+ it "returns 200 for a topic in the templates category" do
post "/discourse_templates/#{template_item0.id}/use"
expect(response.status).to eq(200)
end
- it "should return 200 if the topic belongs to the templates subcategories" do
+ it "returns 200 for a topic in a templates subcategory" do
post "/discourse_templates/#{template_item3.id}/use"
expect(response.status).to eq(200)
@@ -390,7 +390,7 @@ describe DiscourseTemplates::TemplatesController do
sign_in(moderator)
end
- it "should increment usage count" do
+ it "increments the usage count" do
get "/discourse_templates"
expect(response.status).to eq(200)
diff --git a/plugins/discourse-topic-voting/spec/serializers/basic_category_serializer_spec.rb b/plugins/discourse-topic-voting/spec/serializers/basic_category_serializer_spec.rb
index 6f8daec66ff..dced506001b 100644
--- a/plugins/discourse-topic-voting/spec/serializers/basic_category_serializer_spec.rb
+++ b/plugins/discourse-topic-voting/spec/serializers/basic_category_serializer_spec.rb
@@ -3,7 +3,7 @@
describe BasicCategorySerializer do
fab!(:category)
- it "does not return can_vote when voting disabled" do
+ it "omits can_vote when topic voting is globally disabled" do
SiteSetting.topic_voting_enabled = false
json = BasicCategorySerializer.new(category, root: false).as_json
@@ -11,7 +11,7 @@ describe BasicCategorySerializer do
expect(json[:can_vote]).to eq(nil)
end
- it "does not return can_vote when voting disabled" do
+ it "returns can_vote when voting is enabled for the category" do
SiteSetting.topic_voting_enabled = true
DiscourseTopicVoting::CategorySetting.create!(category: category)
diff --git a/plugins/discourse-user-notes/spec/user_warning_spec.rb b/plugins/discourse-user-notes/spec/user_warning_spec.rb
index 52a8126e011..a0a7bd86cb1 100644
--- a/plugins/discourse-user-notes/spec/user_warning_spec.rb
+++ b/plugins/discourse-user-notes/spec/user_warning_spec.rb
@@ -10,13 +10,13 @@ describe UserWarning do
context "when staff notes plugin is enabled" do
before { SiteSetting.user_notes_enabled = true }
- it "should create staff note for warning" do
+ it "creates a staff note for the warning" do
UserWarning.create(topic_id: topic.id, user_id: user.id, created_by_id: admin.id)
expect(PluginStore.get("user_notes", "notes:#{user.id}")).to be_present
end
- it "should use system language" do
+ it "uses the system language" do
freeze_time
warning = UserWarning.create!(topic_id: topic.id, user_id: user.id, created_by_id: admin.id)
@@ -30,7 +30,7 @@ describe UserWarning do
expect(notes[0]["raw"]).to eq(notes[1]["raw"])
end
- it "should trigger user_warning_created event" do
+ it "triggers the user_warning_created event" do
callback_called = false
event_handler = Proc.new { |warning| callback_called = true }
diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/node_execution_context_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/node_execution_context_spec.rb
index 1fdcfb9caef..02196ced2fe 100644
--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/node_execution_context_spec.rb
+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/node_execution_context_spec.rb
@@ -140,7 +140,7 @@ RSpec.describe DiscourseWorkflows::Executor::NodeExecutionContext do
end
end
- describe "#helpers" do
+ describe "#helpers item normalization" do
it "normalizes runtime-compatible items through execution helpers" do
ctx = described_class.new(input_items: [], resolver: nil)
@@ -495,7 +495,7 @@ RSpec.describe DiscourseWorkflows::Executor::NodeExecutionContext do
end
end
- describe "#helpers" do
+ describe "#helpers data table access" do
fab!(:admin)
fab!(:data_table, :discourse_workflows_data_table)
@@ -770,7 +770,7 @@ RSpec.describe DiscourseWorkflows::Executor::NodeExecutionContext do
end
end
- describe "#create_post" do
+ describe "#create_post authorization" do
fab!(:admin)
fab!(:user)
fab!(:first_post) { Fabricate(:post, user: user, raw: "First post", post_number: 1) }
@@ -1021,7 +1021,7 @@ RSpec.describe DiscourseWorkflows::Executor::NodeExecutionContext do
end
end
- describe "#create_post" do
+ describe "#create_post provenance" do
it "records bypass provenance custom fields on the created post" do
author = Fabricate(:user, trust_level: 0, refresh_auto_groups: true)
workflow = Fabricate(:discourse_workflows_workflow, published: true)
diff --git a/plugins/discourse-zendesk-plugin/spec/jobs/onceoff/migrate_zendesk_autogenerate_categories_site_settings_spec.rb b/plugins/discourse-zendesk-plugin/spec/jobs/onceoff/migrate_zendesk_autogenerate_categories_site_settings_spec.rb
index 7cea9d45921..6b00256d6e5 100644
--- a/plugins/discourse-zendesk-plugin/spec/jobs/onceoff/migrate_zendesk_autogenerate_categories_site_settings_spec.rb
+++ b/plugins/discourse-zendesk-plugin/spec/jobs/onceoff/migrate_zendesk_autogenerate_categories_site_settings_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::MigrateZendeskAutogenerateCategoriesSiteSettings do
- it "should migrate the site settings correctly" do
+ it "migrates the category site settings" do
category = Fabricate(:category)
category_2 = Fabricate(:category)
diff --git a/plugins/discourse-zendesk-plugin/spec/lib/discourse_zendesk_plugin/helper_spec.rb b/plugins/discourse-zendesk-plugin/spec/lib/discourse_zendesk_plugin/helper_spec.rb
index 5686f29af90..311a4a74d85 100644
--- a/plugins/discourse-zendesk-plugin/spec/lib/discourse_zendesk_plugin/helper_spec.rb
+++ b/plugins/discourse-zendesk-plugin/spec/lib/discourse_zendesk_plugin/helper_spec.rb
@@ -154,7 +154,7 @@ RSpec.describe DiscourseZendeskPlugin::Helper do
let(:zendesk_job_push_only_author_posts) { false }
context "with same author" do
- it "should be true" do
+ it "marks the post as eligible" do
expect(eligible).to be_truthy
end
end
@@ -162,7 +162,7 @@ RSpec.describe DiscourseZendeskPlugin::Helper do
context "with different author" do
let(:post_user) { other_user }
- it "should be true" do
+ it "marks the post as eligible" do
expect(eligible).to be_truthy
end
end
@@ -172,7 +172,7 @@ RSpec.describe DiscourseZendeskPlugin::Helper do
let(:zendesk_job_push_only_author_posts) { true }
context "with same author" do
- it "should be true" do
+ it "marks the post as eligible" do
expect(eligible).to be_truthy
end
end
@@ -180,7 +180,7 @@ RSpec.describe DiscourseZendeskPlugin::Helper do
context "with different author" do
let(:post_user) { other_user }
- it "should be false" do
+ it "marks the post as ineligible" do
expect(eligible).to be_falsey
end
end
diff --git a/plugins/poll/spec/controllers/polls_controller_spec.rb b/plugins/poll/spec/controllers/polls_controller_spec.rb
index 8c9fd21779a..d3db1b6da7f 100644
--- a/plugins/poll/spec/controllers/polls_controller_spec.rb
+++ b/plugins/poll/spec/controllers/polls_controller_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe DiscoursePoll::PollsController do
before { Group.refresh_automatic_groups! }
describe "#vote" do
- it "works" do
+ it "publishes the updated poll vote" do
channel = "/polls/#{poll.topic_id}"
message =
diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb
index 21cbecfd8fc..dc160e062ae 100644
--- a/plugins/poll/spec/controllers/posts_controller_spec.rb
+++ b/plugins/poll/spec/controllers/posts_controller_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe PostsController do
end
describe "polls" do
- it "works" do
+ it "creates the post and its poll" do
Group.refresh_automatic_groups!
post :create, params: { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json
@@ -63,7 +63,7 @@ RSpec.describe PostsController do
expect(job_args["poll_name"]).to eq(name)
end
- it "should have different options" do
+ it "requires different options" do
post :create, params: { title: title, raw: "[poll]\n- A\n- A\n[/poll]" }, format: :json
expect(response).not_to be_successful
@@ -84,7 +84,7 @@ RSpec.describe PostsController do
expect(response).to be_successful
end
- it "should have at least 1 options" do
+ it "requires at least one option" do
post :create, params: { title: title, raw: "[poll]\n[/poll]" }, format: :json
expect(response).not_to be_successful
@@ -92,7 +92,7 @@ RSpec.describe PostsController do
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_at_least_1_option"))
end
- it "should have at most 'SiteSetting.poll_maximum_options' options" do
+ it "allows at most SiteSetting.poll_maximum_options options" do
raw = +"[poll]\n"
(SiteSetting.poll_maximum_options + 1).times { |n| raw << "\n- #{n}" }
raw << "\n[/poll]"
@@ -106,7 +106,7 @@ RSpec.describe PostsController do
)
end
- it "should have valid parameters" do
+ it "requires valid parameters" do
post :create,
params: {
title: title,
@@ -304,7 +304,7 @@ RSpec.describe PostsController do
end
describe "named polls" do
- it "should have different options" do
+ it "requires different options" do
post :create,
params: {
title: title,
@@ -322,7 +322,7 @@ RSpec.describe PostsController do
)
end
- it "should have at least 1 option" do
+ it "requires at least one option" do
post :create, params: { title: title, raw: "[poll name='foo']\n[/poll]" }, format: :json
expect(response).not_to be_successful
@@ -334,7 +334,7 @@ RSpec.describe PostsController do
end
describe "multiple polls" do
- it "works" do
+ it "creates a post with multiple polls" do
post :create,
params: {
title: title,
@@ -348,7 +348,7 @@ RSpec.describe PostsController do
expect(Poll.where(post_id: json["id"]).count).to eq(2)
end
- it "should have a name" do
+ it "requires a name" do
post :create,
params: {
title: title,
@@ -361,7 +361,7 @@ RSpec.describe PostsController do
expect(json["errors"][0]).to eq(I18n.t("poll.multiple_polls_without_name"))
end
- it "should have unique name" do
+ it "requires a unique name" do
post :create,
params: {
title: title,
diff --git a/plugins/poll/spec/integration/poll_endpoints_spec.rb b/plugins/poll/spec/integration/poll_endpoints_spec.rb
index 9b82ff35919..ff2f5f2ef02 100644
--- a/plugins/poll/spec/integration/poll_endpoints_spec.rb
+++ b/plugins/poll/spec/integration/poll_endpoints_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe "DiscoursePoll endpoints" do
let(:ranked_choice_option_b) { { id: "e89dec30bbd9bf50fabf6a05b4324edf", rank: 1 } }
let(:ranked_choice_option_c) { { id: "a1a6e2779b52caadb93579c0c3db7c0c", rank: 0 } }
- it "should return the right response" do
+ it "returns the expected voters" do
DiscoursePoll::Poll.vote(user, post.id, DiscoursePoll::DEFAULT_POLL_NAME, [option_a])
get "/polls/voters.json",
@@ -47,7 +47,7 @@ RSpec.describe "DiscoursePoll endpoints" do
expect(option.first["username"]).to eq(user.username)
end
- it "should return the right response for a single option" do
+ it "returns voters for a single option" do
DiscoursePoll::Poll.vote(
user,
post_with_multiple_poll.id,
@@ -75,7 +75,7 @@ RSpec.describe "DiscoursePoll endpoints" do
expect(option.first["username"]).to eq(user.username)
end
- it "should return valid response for a ranked choice option" do
+ it "returns voters for a ranked-choice option" do
ranked_choice_poll = post_with_ranked_choice_poll.polls.first
ranked_choice_poll_options = ranked_choice_poll.poll_options
ranked_choice_votes = {
@@ -113,14 +113,14 @@ RSpec.describe "DiscoursePoll endpoints" do
end
describe "when post_id is blank" do
- it "should raise the right error" do
+ it "returns a bad request response" do
get "/polls/voters.json", params: { poll_name: DiscoursePoll::DEFAULT_POLL_NAME }
expect(response.status).to eq(400)
end
end
describe "when post_id is not valid" do
- it "should raise the right error" do
+ it "returns a bad request response" do
get "/polls/voters.json",
params: {
post_id: -1,
@@ -132,14 +132,14 @@ RSpec.describe "DiscoursePoll endpoints" do
end
describe "when poll_name is blank" do
- it "should raise the right error" do
+ it "returns a bad request response" do
get "/polls/voters.json", params: { post_id: post.id }
expect(response.status).to eq(400)
end
end
describe "when poll_name is not valid" do
- it "should raise the right error" do
+ it "returns a bad request response" do
get "/polls/voters.json", params: { post_id: post.id, poll_name: "wrongpoll" }
expect(response.status).to eq(400)
expect(response.body).to include("poll_name")
@@ -151,7 +151,7 @@ RSpec.describe "DiscoursePoll endpoints" do
Fabricate(:post, raw: "[poll type=number min=1 max=20 step=1 public=true]\n[/poll]")
end
- it "should return the right response" do
+ it "returns voters for the number poll" do
post
DiscoursePoll::Poll.vote(
diff --git a/plugins/poll/spec/integration/user_merger_spec.rb b/plugins/poll/spec/integration/user_merger_spec.rb
index c649886ed83..1d49f127ee3 100644
--- a/plugins/poll/spec/integration/user_merger_spec.rb
+++ b/plugins/poll/spec/integration/user_merger_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe UserMerger do
Fabricate(:poll_option, poll: poll_ranked_choice, html: "Option C")
end
- it "will end up with no votes from source user" do
+ it "leaves no votes from the source user" do
Fabricate(:poll_vote, poll: poll_regular, user: source_user, poll_option: poll_regular_option2)
Fabricate(
:poll_vote,
@@ -38,7 +38,7 @@ RSpec.describe UserMerger do
expect(PollVote.where(user: source_user).count).to eq(0)
end
- it "will not use source user's vote if target_user already voted in the same poll" do
+ it "keeps the target user's vote when both users voted in the same poll" do
Fabricate(:poll_vote, poll: poll_regular, user: target_user, poll_option: poll_regular_option1)
Fabricate(:poll_vote, poll: poll_regular, user: source_user, poll_option: poll_regular_option2)
@@ -69,7 +69,7 @@ RSpec.describe UserMerger do
)
end
- it "will use source user's vote if poll was the ranked choice type" do
+ it "uses the source user's vote for a ranked-choice poll" do
Fabricate(
:poll_vote,
poll: poll_ranked_choice,
diff --git a/plugins/poll/spec/jobs/regular/close_poll_spec.rb b/plugins/poll/spec/jobs/regular/close_poll_spec.rb
index 9f47cefca7a..395ab22ef9c 100644
--- a/plugins/poll/spec/jobs/regular/close_poll_spec.rb
+++ b/plugins/poll/spec/jobs/regular/close_poll_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Jobs::ClosePoll do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }
describe "missing arguments" do
- it "should raise the right error" do
+ it "raises InvalidParameters for missing poll_name or post_id" do
expect do Jobs::ClosePoll.new.execute(post_id: post.id) end.to raise_error(
Discourse::InvalidParameters,
"poll_name",
diff --git a/plugins/poll/spec/lib/new_post_manager_spec.rb b/plugins/poll/spec/lib/new_post_manager_spec.rb
index 940aa1fda66..a41998f541f 100644
--- a/plugins/poll/spec/lib/new_post_manager_spec.rb
+++ b/plugins/poll/spec/lib/new_post_manager_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe NewPostManager do
}
end
- it "should render the poll upon approval" do
+ it "renders the poll upon approval" do
result = NewPostManager.new(user, params).perform
expect(result.action).to eq(:enqueued)
expect(result.reviewable).to be_present
diff --git a/plugins/poll/spec/lib/poll_spec.rb b/plugins/poll/spec/lib/poll_spec.rb
index fb3c1d29ffd..6910e86bc8c 100644
--- a/plugins/poll/spec/lib/poll_spec.rb
+++ b/plugins/poll/spec/lib/poll_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe DiscoursePoll::Poll do
end
end
- it "should only allow one vote per user for a regular poll" do
+ it "allows one vote per user for a regular poll" do
poll = post_with_regular_poll.polls.first
expect do
@@ -67,7 +67,7 @@ RSpec.describe DiscoursePoll::Poll do
end.to raise_error(DiscoursePoll::Error, I18n.t("poll.one_vote_per_user"))
end
- it "should not allow a ranked vote with all abstentions" do
+ it "rejects a ranked vote with all abstentions" do
poll = post_with_ranked_choice_poll.polls.first
poll_options = poll.poll_options
@@ -97,7 +97,7 @@ RSpec.describe DiscoursePoll::Poll do
)
end
- it "should clean up bad votes for a regular poll" do
+ it "removes invalid votes from a regular poll" do
poll = post_with_regular_poll.polls.first
PollVote.create!(poll: poll, poll_option: poll.poll_options.first, user: user)
@@ -149,7 +149,7 @@ RSpec.describe DiscoursePoll::Poll do
)
end
- it "should respect the min/max votes per user for a multiple poll" do
+ it "enforces the minimum and maximum votes for a multiple poll" do
poll = post_with_multiple_poll.polls.first
expect do
@@ -171,7 +171,7 @@ RSpec.describe DiscoursePoll::Poll do
end.to raise_error(DiscoursePoll::Error, I18n.t("poll.min_vote_per_user", count: poll.min))
end
- it "should allow user to vote on a multiple poll even if min option is not configured" do
+ it "allows voting on a multiple poll without a minimum" do
post_with_multiple_poll = Fabricate(:post, raw: <<~RAW)
[poll type=multiple max=3]
* 1
@@ -196,7 +196,7 @@ RSpec.describe DiscoursePoll::Poll do
)
end
- it "should allow user to vote on a multiple poll even if max option is not configured" do
+ it "allows voting on a multiple poll without a maximum" do
post_with_multiple_poll = Fabricate(:post, raw: <<~RAW)
[poll type=multiple min=1]
* 1
diff --git a/plugins/spoiler-alert/spec/topic_excerpt_spec.rb b/plugins/spoiler-alert/spec/topic_excerpt_spec.rb
index 39ba1c86039..54d37d834a8 100644
--- a/plugins/spoiler-alert/spec/topic_excerpt_spec.rb
+++ b/plugins/spoiler-alert/spec/topic_excerpt_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
describe PrettyText do
- it "should remove spoilers from excerpts" do
+ it "removes spoilers from excerpts" do
expect(
PrettyText.excerpt("<div class='spoiler'><img src='http://cnn.com/a.gif'></div>", 100),
).to match_html ""
diff --git a/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb b/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb
index 7c3b9dde0a2..3c5daedc263 100644
--- a/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb
+++ b/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe BackfillThemeableSiteSettings do
after { ActiveRecord::Migration.verbose = @original_verbose }
- it "works" do
+ it "backfills themeable site settings" do
DB.exec(
"INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
VALUES ('enable_welcome_banner', :data_type, :value, NOW(), NOW())",
diff --git a/spec/db/migrate/20250902072941_sync_timerable_id_topic_id_spec.rb b/spec/db/migrate/20250902072941_sync_timerable_id_topic_id_spec.rb
index 24174efc3c2..5de5c9e676f 100644
--- a/spec/db/migrate/20250902072941_sync_timerable_id_topic_id_spec.rb
+++ b/spec/db/migrate/20250902072941_sync_timerable_id_topic_id_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe SyncTimerableIdTopicId do
after { ActiveRecord::Migration.verbose = @original_verbose }
- it "works" do
+ it "syncs timerable_id to topic_id" do
DB.exec("DROP TRIGGER IF EXISTS topic_timers_topic_id_trigger ON topic_timers")
Migration::ColumnDropper.drop_readonly(:topic_timers, :topic_id)
DB.exec("ALTER TABLE topic_timers ALTER COLUMN timerable_id DROP NOT NULL")
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 58562b61320..41332df2b57 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -262,7 +262,7 @@ RSpec.describe ApplicationHelper do
describe "render_sitelinks_search_tag" do
context "for non-subfolder install" do
context "when on homepage" do
- it "will return sitelinks search tag" do
+ it "returns the sitelinks search tag" do
helper.stubs(:current_page?).returns(false)
helper.stubs(:current_page?).with("/").returns(true)
@@ -290,7 +290,7 @@ RSpec.describe ApplicationHelper do
end
context "when not on homepage" do
- it "will not return sitelinks search tag" do
+ it "omits the sitelinks search tag" do
helper.stubs(:current_page?).returns(true)
helper.stubs(:current_page?).with("/").returns(false)
helper.stubs(:current_page?).with(Discourse.base_path).returns(false)
@@ -301,7 +301,7 @@ RSpec.describe ApplicationHelper do
context "for subfolder install" do
context "when on homepage" do
- it "will return sitelinks search tag" do
+ it "returns the sitelinks search tag" do
Discourse.stubs(:base_path).returns("/subfolder-base-path/")
helper.stubs(:current_page?).returns(false)
helper.stubs(:current_page?).with(Discourse.base_path).returns(true)
@@ -311,7 +311,7 @@ RSpec.describe ApplicationHelper do
end
context "when not on homepage" do
- it "will not return sitelinks search tag" do
+ it "omits the sitelinks search tag" do
Discourse.stubs(:base_path).returns("/subfolder-base-path/")
helper.stubs(:current_page?).returns(true)
helper.stubs(:current_page?).with("/").returns(false)
@@ -339,7 +339,7 @@ RSpec.describe ApplicationHelper do
before { helper.stubs(:mobile_device?).returns(false) }
context "when logo_dark is not set" do
- it "will return site_logo_url instead" do
+ it "returns site_logo_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_logo_url)
end
end
@@ -347,7 +347,7 @@ RSpec.describe ApplicationHelper do
context "when logo_dark is set" do
before { SiteSetting.logo_dark = Fabricate(:upload, url: "/images/logo-dark.png") }
- it "will return site_logo_dark_url" do
+ it "returns site_logo_dark_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_logo_dark_url)
end
end
@@ -357,7 +357,7 @@ RSpec.describe ApplicationHelper do
before { helper.stubs(:mobile_device?).returns(true) }
context "when mobile_logo_dark is not set" do
- it "will return site_mobile_logo_url instead" do
+ it "returns site_mobile_logo_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_mobile_logo_url)
end
end
@@ -367,7 +367,7 @@ RSpec.describe ApplicationHelper do
SiteSetting.mobile_logo_dark = Fabricate(:upload, url: "/images/mobile-logo-dark.png")
end
- it "will return site_mobile_logo_dark_url" do
+ it "returns site_mobile_logo_dark_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_mobile_logo_dark_url)
end
end
@@ -378,7 +378,7 @@ RSpec.describe ApplicationHelper do
describe "application_logo_dark_url" do
context "when dark theme is not present" do
context "when dark logo is not present" do
- it "should return nothing" do
+ it "returns no dark logo URL" do
expect(helper.application_logo_dark_url.present?).to eq(false)
end
end
@@ -396,7 +396,7 @@ RSpec.describe ApplicationHelper do
end
context "when dark logo is not present" do
- it "should return nothing" do
+ it "returns no dark logo URL" do
expect(helper.application_logo_dark_url.present?).to eq(false)
end
end
@@ -404,7 +404,7 @@ RSpec.describe ApplicationHelper do
context "when dark logo is present" do
before { SiteSetting.logo_dark = Fabricate(:upload, url: "/images/logo-dark.png") }
- it "should return correct url" do
+ it "returns site_logo_dark_url" do
expect(helper.application_logo_dark_url).to eq(SiteSetting.site_logo_dark_url)
end
end
@@ -423,7 +423,7 @@ RSpec.describe ApplicationHelper do
SiteSetting.logo_dark = Fabricate(:upload, url: "/images/logo-dark.png")
end
- it "should return nothing" do
+ it "returns no separate dark logo URL" do
expect(helper.application_logo_url).to eq(SiteSetting.site_logo_dark_url)
expect(helper.application_logo_dark_url.present?).to eq(false)
end
diff --git a/spec/helpers/user_notifications_helper_spec.rb b/spec/helpers/user_notifications_helper_spec.rb
index 94ef066d9ab..756b6509ce8 100644
--- a/spec/helpers/user_notifications_helper_spec.rb
+++ b/spec/helpers/user_notifications_helper_spec.rb
@@ -126,7 +126,7 @@ RSpec.describe UserNotificationsHelper do
before { SiteSetting.logo = upload }
- it "should return the right URL" do
+ it "returns the local upload URL" do
expect(helper.logo_url).to eq(
"http://test.localhost/#{upload_path}/original/1X/somesha1.png",
)
@@ -137,7 +137,7 @@ RSpec.describe UserNotificationsHelper do
GlobalSetting.expects(:cdn_url).returns("https://some.localcdn.com").at_least_once
end
- it "should return the right URL" do
+ it "returns the local CDN upload URL" do
expect(helper.logo_url).to eq(
"https://some.localcdn.com/#{upload_path}/original/1X/somesha1.png",
)
@@ -147,7 +147,7 @@ RSpec.describe UserNotificationsHelper do
describe "when logo is an SVG" do
let(:upload) { Fabricate(:upload, extension: "svg") }
- it "should return nil" do
+ it "returns nil" do
expect(helper.logo_url).to eq(nil)
end
end
@@ -161,14 +161,14 @@ RSpec.describe UserNotificationsHelper do
SiteSetting.logo = upload
end
- it "should return the right URL" do
+ it "returns the S3 upload URL" do
expect(helper.logo_url).to eq(
"http://s3-upload-bucket.s3.dualstack.#{SiteSetting.s3_region}.amazonaws.com/original/1X/somesha1.png",
)
end
describe "when global cdn path is configured" do
- it "should return the right url" do
+ it "preserves the S3 upload URL when a global CDN is configured" do
GlobalSetting.stubs(:cdn_url).returns("https://some.cdn.com/cluster")
expect(helper.logo_url).to eq(
@@ -180,7 +180,7 @@ RSpec.describe UserNotificationsHelper do
describe "when cdn path is configured" do
before { SiteSetting.s3_cdn_url = "https://some.cdn.com" }
- it "should return the right url" do
+ it "returns the S3 CDN upload URL" do
expect(helper.logo_url).to eq("https://some.cdn.com/original/1X/somesha1.png")
end
end
diff --git a/spec/import_export/importer_spec.rb b/spec/import_export/importer_spec.rb
index 00cc89203e6..6076720942a 100644
--- a/spec/import_export/importer_spec.rb
+++ b/spec/import_export/importer_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe ImportExport::Importer do
end
context "with categories and groups" do
- it "works" do
+ it "imports categories, their topics, and groups without adding users" do
data = import_data.dup
data[:topics] = nil
data[:users] = nil
diff --git a/spec/integration/activerecord_preventing_writes_spec.rb b/spec/integration/activerecord_preventing_writes_spec.rb
index 3de301a6c09..cc1c024b796 100644
--- a/spec/integration/activerecord_preventing_writes_spec.rb
+++ b/spec/integration/activerecord_preventing_writes_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "When ActiveRecord is preventing writes" do
- it "should not result in an error response when there is a theme field that needs to be baked" do
+ it "does not return an error when a theme field needs baking" do
theme_field =
Fabricate(
:theme_field,
diff --git a/spec/integration/multisite_cookies_spec.rb b/spec/integration/multisite_cookies_spec.rb
index 9a24b4d0e2d..dc3ee3d0617 100644
--- a/spec/integration/multisite_cookies_spec.rb
+++ b/spec/integration/multisite_cookies_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "multisite", type: %i[multisite request] do
- it "works" do
+ it "keeps cookies isolated between sites" do
get "http://test.localhost/session/csrf.json"
expect(response.status).to eq(200)
cookie = CGI.escape(response.cookies["_forum_session"])
diff --git a/spec/integration/multisite_spec.rb b/spec/integration/multisite_spec.rb
index a1f27013f6d..919b48e2645 100644
--- a/spec/integration/multisite_spec.rb
+++ b/spec/integration/multisite_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
RSpec.describe "multisite", type: %i[multisite request] do
- it "should always allow /srv/status through" do
+ it "allows /srv/status for an unknown host" do
get "http://unknown.com/srv/status"
expect(response.status).to eq(200)
expect(request.env["HTTP_HOST"]).to eq("test.localhost") # Rewritten by EnforceHostname middleware
end
- it "should 404 for unknown domains" do
+ it "returns 404 for unknown domains" do
get "http://unknown.com/about.json"
expect(response.status).to eq(404)
end
- it "should hit correct site otherwise" do
+ it "routes known hosts to the corresponding site" do
site_1_url =
Fabricate(:topic, title: "Site 1 Topic Title", user: Discourse.system_user).relative_url
diff --git a/spec/integration/rate_limiting_spec.rb b/spec/integration/rate_limiting_spec.rb
index 20b2dc21604..b3c601c4682 100644
--- a/spec/integration/rate_limiting_spec.rb
+++ b/spec/integration/rate_limiting_spec.rb
@@ -4,7 +4,7 @@
RSpec.describe "rate limiter integration" do
before { RateLimiter.enable }
- it "will rate limit message bus requests once queueing" do
+ it "rate-limits queued MessageBus requests" do
freeze_time
global_setting :reject_message_bus_queue_seconds, 0.1
@@ -18,7 +18,7 @@ RSpec.describe "rate limiter integration" do
expect(response.headers["Retry-After"].to_i).to be > 29
end
- it "will not rate limit when all is good" do
+ it "does not rate-limit valid requests" do
freeze_time
global_setting :reject_message_bus_queue_seconds, 0.1
@@ -31,7 +31,7 @@ RSpec.describe "rate limiter integration" do
expect(response.status).to eq(200)
end
- it "will clear the token cookie if invalid" do
+ it "clears an invalid token cookie" do
name = Auth::DefaultCurrentUserProvider::TOKEN_COOKIE
# we try 11 times because the rate limit is 10
diff --git a/spec/integration/same_ip_spammers_spec.rb b/spec/integration/same_ip_spammers_spec.rb
index 0e1aac03eab..4d3a74a3ab8 100644
--- a/spec/integration/same_ip_spammers_spec.rb
+++ b/spec/integration/same_ip_spammers_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe "spammers on same IP" do
let!(:first_post) { create_post(user: spammer1) }
let!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
- it "should not increase spam count" do
+ it "does not increase the spam count" do
expect(first_post.reload.spam_count).to eq(0)
expect(second_post.reload.spam_count).to eq(0)
end
@@ -28,7 +28,7 @@ RSpec.describe "spammers on same IP" do
context "when second spammer replies" do
let!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
- it "should increase spam count" do
+ it "increases the spam count" do
expect(first_post.reload.spam_count).to eq(1)
expect(second_post.reload.spam_count).to eq(1)
end
@@ -36,7 +36,7 @@ RSpec.describe "spammers on same IP" do
context "with third spam post" do
let!(:third_post) { create_post(user: spammer3, topic: first_post.topic) }
- it "should increase spam count" do
+ it "increases the spam count" do
expect(first_post.reload.spam_count).to eq(1)
expect(second_post.reload.spam_count).to eq(1)
expect(third_post.reload.spam_count).to eq(1)
@@ -56,7 +56,7 @@ RSpec.describe "spammers on same IP" do
context "with a reply by a new user at the same IP address" do
let!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
- it "should increase the spam count correctly" do
+ it "increases the spam count correctly" do
expect(first_post.reload.spam_count).to eq(0)
expect(second_post.reload.spam_count).to eq(1)
end
diff --git a/spec/integration/smtp_spec.rb b/spec/integration/smtp_spec.rb
index 62f81c74cf7..f5a52c45287 100644
--- a/spec/integration/smtp_spec.rb
+++ b/spec/integration/smtp_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe "SMTP Settings Integration" do
ActionMailer::Base.delivery_method = @original_action_mailer_delivery_method
end
- it "should disable starttls_auto when tls is enabled" do
+ it "disables starttls_auto when TLS is enabled" do
global_setting :smtp_address, "localhost"
global_setting :smtp_port, 465
global_setting :smtp_force_tls, true
@@ -20,7 +20,7 @@ RSpec.describe "SMTP Settings Integration" do
expect(GlobalSetting.smtp_settings[:enable_starttls_auto]).to be_falsey
end
- it "should leave starttls_auto enabled when tls is not enabled" do
+ it "leaves starttls_auto enabled when TLS is disabled" do
global_setting :smtp_address, "localhost"
global_setting :smtp_port, 587
global_setting :smtp_force_tls, false
@@ -28,7 +28,7 @@ RSpec.describe "SMTP Settings Integration" do
expect(GlobalSetting.smtp_settings[:enable_starttls_auto]).to be_truthy
end
- it "should attempt to send out an email without raising any SMTP argument errors" do
+ it "attempts to send an email without SMTP argument errors" do
global_setting :smtp_address, "192.0.2.1"
global_setting :smtp_port, 12_345
global_setting :smtp_open_timeout, 0.00001
diff --git a/spec/integration/spam_rules_spec.rb b/spec/integration/spam_rules_spec.rb
index f666b15aded..02f8e85df45 100644
--- a/spec/integration/spam_rules_spec.rb
+++ b/spec/integration/spam_rules_spec.rb
@@ -24,12 +24,12 @@ RSpec.describe "spam rules for users" do
before { PostActionCreator.create(user1, spam_post, :spam) }
- it "should not hide the post" do
+ it "does not hide the post" do
expect(spam_post.reload).to_not be_hidden
end
context "when spam posts are flagged enough times, but not by enough users" do
- it "should not hide the post" do
+ it "does not hide the post" do
PostActionCreator.create(user1, spam_post2, :spam)
expect(spam_post.reload).to_not be_hidden
@@ -44,7 +44,7 @@ RSpec.describe "spam rules for users" do
let!(:mod_pm_count) { moderator.private_topics_count }
let!(:reviewable) { PostActionCreator.spam(user2, spam_post).reviewable }
- it "should hide the posts" do
+ it "hides the posts" do
expect(Guardian.new(spammer).can_create_topic?(nil)).to be(false)
expect {
PostCreator.create(
@@ -69,7 +69,7 @@ RSpec.describe "spam rules for users" do
end
context "when a post is deleted" do
- it "should silence the spammer" do
+ it "silences the spammer" do
spam_post.trash!(moderator)
spammer.reload
expect(spammer.reload).to be_silenced
@@ -77,7 +77,7 @@ RSpec.describe "spam rules for users" do
end
context "when spammer becomes trust level 1" do
- it "should silence the spammer" do
+ it "silences the spammer" do
spammer.change_trust_level!(TrustLevel[1])
spammer.reload
expect(spammer.reload).to be_silenced
@@ -86,7 +86,7 @@ RSpec.describe "spam rules for users" do
end
context "with hide_post_sensitivity" do
- it "should silence the spammer" do
+ it "silences the spammer" do
Reviewable.set_priorities(high: 2.0)
SiteSetting.hide_post_sensitivity = Reviewable.sensitivities[:low]
PostActionCreator.create(user2, spam_post, :spam)
@@ -104,7 +104,7 @@ RSpec.describe "spam rules for users" do
let!(:spam_post) { Fabricate(:post, user: spammer) }
let!(:private_messages_count) { spammer.private_topics_count }
- it "should not allow spammer to create new posts" do
+ it "prevents the spammer from creating new posts" do
PostActionCreator.create(user1, spam_post, :spam)
PostActionCreator.create(user2, spam_post, :spam)
@@ -129,7 +129,7 @@ RSpec.describe "spam rules for users" do
let!(:spam_post) { Fabricate(:post, user: spammer) }
let!(:private_messages_count) { spammer.private_topics_count }
- it "should not hide the post" do
+ it "does not hide the post" do
PostActionCreator.create(user1, spam_post, :spam)
PostActionCreator.create(user2, spam_post, :spam)
diff --git a/spec/integration/tag_counts_spec.rb b/spec/integration/tag_counts_spec.rb
index 5c3fb032be0..6b44c406fb4 100644
--- a/spec/integration/tag_counts_spec.rb
+++ b/spec/integration/tag_counts_spec.rb
@@ -36,19 +36,19 @@ RSpec.describe "Updating tag counts" do
expect(tag2.pm_topic_count).to eq(1)
end
- it "should decrease Tag#public_topic_count for all tags when topic's category is changed from a public category to a read restricted category" do
+ it "decreases tag public topic counts when moving a public topic to a restricted category" do
expect { topic_in_public_category.change_category_to_id(private_category.id) }.to change {
tag1.reload.public_topic_count
}.by(-1).and change { tag2.reload.public_topic_count }.by(-1)
end
- it "should increase Tag#public_topic_count for all tags when topic's category is changed from a read restricted category to a public category" do
+ it "increases tag public topic counts when moving a restricted topic to a public category" do
expect { topic_in_private_category.change_category_to_id(public_category.id) }.to change {
tag1.reload.public_topic_count
}.by(1).and change { tag2.reload.public_topic_count }.by(1)
end
- it "should not change Tag#public_topic_count for all tags when topic's category is changed from a public category to another public category" do
+ it "preserves tag public topic counts when moving between public categories" do
expect do
topic_in_public_category.change_category_to_id(public_category2.id)
end.to not_change { tag1.reload.public_topic_count }.and not_change {
@@ -56,7 +56,7 @@ RSpec.describe "Updating tag counts" do
}
end
- it "should not change Tag#public_topic_count for all tags when topic's category is changed from a read restricted category to another read restricted category" do
+ it "preserves tag public topic counts when moving between restricted categories" do
expect do
topic_in_private_category.change_category_to_id(private_category2.id)
end.to not_change { tag1.reload.public_topic_count }.and not_change {
@@ -75,7 +75,7 @@ RSpec.describe "Updating tag counts" do
}.by(1)
end
- it "should not change Tag#public_topic_count for all tags when topic is converted from private message to a regular topic in a read restricted category" do
+ it "preserves tag public topic counts when converting a PM to a restricted topic" do
expect do
private_message.convert_to_public_topic(
Discourse.system_user,
@@ -86,7 +86,7 @@ RSpec.describe "Updating tag counts" do
}
end
- it "should decrease Tag#public_topic_count for all tags when regular topic in public category is converted to a private message" do
+ it "decreases tag public topic counts when converting a public topic to a PM" do
expect do
topic_in_public_category.convert_to_private_message(Discourse.system_user)
end.to change { tag1.reload.public_topic_count }.by(-1).and change {
@@ -94,7 +94,7 @@ RSpec.describe "Updating tag counts" do
}.by(-1)
end
- it "should not change Tag#public_topic_count for all tags when regular topic in read restricted category is converted to a private message" do
+ it "preserves tag public topic counts when converting a restricted topic to a PM" do
expect do
topic_in_private_category.convert_to_private_message(Discourse.system_user)
end.to not_change { tag1.reload.public_topic_count }.and not_change {
diff --git a/spec/integration/topic_auto_close_spec.rb b/spec/integration/topic_auto_close_spec.rb
index d4daaa070a6..145cf048fba 100644
--- a/spec/integration/topic_auto_close_spec.rb
+++ b/spec/integration/topic_auto_close_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Topic do
context "when uncategorized" do
let(:category) { nil }
- it "should not schedule the topic to auto-close" do
+ it "does not schedule the topic to auto-close" do
expect(topic.public_topic_timer).to eq(nil)
expect(job_klass.jobs).to eq([])
end
@@ -19,7 +19,7 @@ RSpec.describe Topic do
context "with category without default auto-close" do
let(:category) { Fabricate(:category, auto_close_hours: nil) }
- it "should not schedule the topic to auto-close" do
+ it "does not schedule the topic to auto-close" do
expect(topic.public_topic_timer).to eq(nil)
expect(job_klass.jobs).to eq([])
end
@@ -31,7 +31,7 @@ RSpec.describe Topic do
context "when category has a default auto-close" do
let(:category) { Fabricate(:category, auto_close_hours: 2.0) }
- it "should schedule the topic to auto-close" do
+ it "schedules the topic to auto-close" do
topic
topic_status_update = TopicTimer.last
@@ -44,7 +44,7 @@ RSpec.describe Topic do
let(:admin) { Fabricate(:admin) }
let(:staff_topic) { Fabricate(:topic, user: admin, category: category) }
- it "should schedule the topic to auto-close" do
+ it "schedules the topic to auto-close" do
staff_topic
topic_status_update = TopicTimer.last
@@ -55,7 +55,7 @@ RSpec.describe Topic do
end
context "when topic is closed manually" do
- it "should remove the schedule to auto-close the topic" do
+ it "removes the topic's auto-close schedule" do
topic_timer_id = staff_topic.public_topic_timer.id
staff_topic.update_status("closed", true, admin)
@@ -71,7 +71,7 @@ RSpec.describe Topic do
let(:regular_user) { Fabricate(:user) }
let(:regular_user_topic) { Fabricate(:topic, user: regular_user, category: category) }
- it "should schedule the topic to auto-close" do
+ it "schedules the topic to auto-close" do
regular_user_topic
topic_status_update = TopicTimer.last
diff --git a/spec/integration/watched_words_spec.rb b/spec/integration/watched_words_spec.rb
index c4fb2064ec8..decd57d8098 100644
--- a/spec/integration/watched_words_spec.rb
+++ b/spec/integration/watched_words_spec.rb
@@ -44,7 +44,7 @@ RSpec.describe WatchedWord do
expect(result.errors[:base]&.first).to eq(I18n.t("contains_blocked_word", word: "&lt;a&gt;"))
end
- it "should prevent the post from being created" do
+ it "prevents the post from being created" do
manager =
NewPostManager.new(
tl2_user,
@@ -65,7 +65,7 @@ RSpec.describe WatchedWord do
should_block_post(manager)
end
- it "should handle UTF-8 characters" do
+ it "matches UTF-8 characters" do
block_word = Fabricate(:watched_word, action: WatchedWord.actions[:block], word: "abc")
manager =
NewPostManager.new(tl2_user, title: "Hello world", raw: "abcódef", topic_id: topic.id)
@@ -73,7 +73,7 @@ RSpec.describe WatchedWord do
expect(manager.perform).to be_success
end
- it "should block the post from admin" do
+ it "blocks posts from an admin" do
manager =
NewPostManager.new(
admin,
@@ -83,7 +83,7 @@ RSpec.describe WatchedWord do
should_block_post(manager)
end
- it "should block the post from moderator" do
+ it "blocks posts from a moderator" do
manager =
NewPostManager.new(
moderator,
@@ -93,7 +93,7 @@ RSpec.describe WatchedWord do
should_block_post(manager)
end
- it "should block the post if it contains multiple blocked words" do
+ it "blocks posts containing multiple blocked words" do
manager =
NewPostManager.new(
moderator,
@@ -112,7 +112,7 @@ RSpec.describe WatchedWord do
}.to_not change { Post.count }
end
- it "should block in a private message too" do
+ it "blocks the word in private messages" do
manager =
NewPostManager.new(
tl2_user,
@@ -139,7 +139,7 @@ RSpec.describe WatchedWord do
end
context "with require_approval" do
- it "should queue the post for approval" do
+ it "queues the post for approval" do
manager =
NewPostManager.new(
tl2_user,
@@ -163,7 +163,7 @@ RSpec.describe WatchedWord do
expect(result.action).to eq(:enqueued)
end
- it "should not queue posts from admin" do
+ it "does not queue posts from an admin" do
manager =
NewPostManager.new(
admin,
@@ -175,7 +175,7 @@ RSpec.describe WatchedWord do
expect(result.action).to eq(:create_post)
end
- it "should not queue posts from moderator" do
+ it "does not queue posts from a moderator" do
manager =
NewPostManager.new(
moderator,
@@ -221,7 +221,7 @@ RSpec.describe WatchedWord do
expect { Jobs::ProcessPost.new.execute(post_id: post.id) }.to_not change { PostAction.count }
end
- it "should flag the post as inappropriate" do
+ it "flags the post as inappropriate" do
topic = Fabricate(:topic, user: tl2_user)
post = Fabricate(:post, raw: "I said.... #{flag_word.word}", topic: topic, user: tl2_user)
Jobs::ProcessPost.new.execute(post_id: post.id)
@@ -242,7 +242,7 @@ RSpec.describe WatchedWord do
).to be_present
end
- it "should flag the post if it contains multiple flagged words" do
+ it "flags posts containing multiple flagged words" do
topic = Fabricate(:topic, user: tl2_user)
post =
Fabricate(
@@ -272,7 +272,7 @@ RSpec.describe WatchedWord do
).to be_present
end
- it "should look at the title too" do
+ it "matches flagged words in the title" do
should_flag_post(
tl2_user,
"I thought the movie was not bad actually.",
@@ -280,7 +280,7 @@ RSpec.describe WatchedWord do
)
end
- it "shouldn't flag posts by admin" do
+ it "does not flag posts by an admin" do
should_not_flag_post(
admin,
"I thought the #{flag_word.word} was bad.",
@@ -288,7 +288,7 @@ RSpec.describe WatchedWord do
)
end
- it "shouldn't flag posts by moderator" do
+ it "does not flag posts by a moderator" do
should_not_flag_post(
moderator,
"I thought the #{flag_word.word} was bad.",
@@ -348,7 +348,7 @@ RSpec.describe WatchedWord do
).to eq(true)
end
- it "should not flag on rebake" do
+ it "does not flag a post when rebaking it" do
post =
Fabricate(
:post,
diff --git a/spec/jobs/activation_reminder_emails_spec.rb b/spec/jobs/activation_reminder_emails_spec.rb
index e70cc9abaa9..010b3787ef3 100644
--- a/spec/jobs/activation_reminder_emails_spec.rb
+++ b/spec/jobs/activation_reminder_emails_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Jobs::ActivationReminderEmails do
# should be between 2 and 3 days
let(:created_at) { 50.hours.ago }
- it "should email inactive users" do
+ it "emails inactive users" do
user = Fabricate(:user, active: false, created_at: created_at)
expect { described_class.new.execute({}) }.to change { ActionMailer::Base.deliveries.size }.by(
@@ -20,7 +20,7 @@ RSpec.describe Jobs::ActivationReminderEmails do
expect(user.reload.custom_fields["activation_reminder"]).to eq(nil)
end
- it "should not email active users" do
+ it "does not email active users" do
user = Fabricate(:user, active: true, created_at: created_at)
expect { described_class.new.execute({}) }.to not_change {
@@ -28,7 +28,7 @@ RSpec.describe Jobs::ActivationReminderEmails do
}.and not_change { user.email_tokens.count }
end
- it "should not email staged users" do
+ it "does not email staged users" do
user = Fabricate(:user, active: false, staged: true, created_at: created_at)
expect { described_class.new.execute({}) }.to not_change {
diff --git a/spec/jobs/backfill_sidebar_site_settings_spec.rb b/spec/jobs/backfill_sidebar_site_settings_spec.rb
index 22efce29cce..e597be3dd86 100644
--- a/spec/jobs/backfill_sidebar_site_settings_spec.rb
+++ b/spec/jobs/backfill_sidebar_site_settings_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::BackfillSidebarSiteSettings do
- it "should have a cluster concurrency of 1" do
+ it "has a cluster concurrency of 1" do
expect(Jobs::BackfillSidebarSiteSettings.get_cluster_concurrency).to eq(1)
end
end
diff --git a/spec/jobs/bookmark_reminder_notifications_spec.rb b/spec/jobs/bookmark_reminder_notifications_spec.rb
index 6f50fb51bf0..e03fda95ea3 100644
--- a/spec/jobs/bookmark_reminder_notifications_spec.rb
+++ b/spec/jobs/bookmark_reminder_notifications_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Jobs::BookmarkReminderNotifications do
expect(bookmark3.reminder_last_sent_at).not_to eq(nil)
end
- it "will not send a reminder for a bookmark in the future" do
+ it "does not remind the user about a future bookmark" do
freeze_time
bookmark4 = Fabricate(:bookmark, reminder_at: 1.day.from_now)
expect { job.execute }.to change { Notification.where(user: user).count }.by(3)
@@ -58,7 +58,7 @@ RSpec.describe Jobs::BookmarkReminderNotifications do
end
end
- it "will not send notification when topic is not available" do
+ it "does not notify when the topic is unavailable" do
bookmark1.bookmarkable.topic.destroy
bookmark2.bookmarkable.topic.destroy
bookmark3.bookmarkable.topic.destroy
diff --git a/spec/jobs/clean_up_inactive_users_spec.rb b/spec/jobs/clean_up_inactive_users_spec.rb
index 81f2e7d8ff0..bcbf5e8b1a8 100644
--- a/spec/jobs/clean_up_inactive_users_spec.rb
+++ b/spec/jobs/clean_up_inactive_users_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::CleanUpInactiveUsers do
- it "should clean up new users that have been inactive" do
+ it "removes new users who have been inactive" do
SiteSetting.clean_up_inactive_users_after_days = 0
user =
@@ -71,7 +71,7 @@ RSpec.describe Jobs::CleanUpInactiveUsers do
expect(User.exists?(moderator.id)).to eq(true)
end
- it "should clean up a user that has a deleted post" do
+ it "removes an inactive user whose post was deleted" do
SiteSetting.clean_up_inactive_users_after_days = 1
Fabricate(:active_user)
@@ -93,7 +93,7 @@ RSpec.describe Jobs::CleanUpInactiveUsers do
expect { described_class.new.execute({}) }.to change { User.count }.by(-1)
end
- it "should clean up user that has a deleted topic" do
+ it "removes an inactive user whose topic was deleted" do
SiteSetting.clean_up_inactive_users_after_days = 1
Fabricate(:active_user)
diff --git a/spec/jobs/clean_up_unused_user_api_keys_spec.rb b/spec/jobs/clean_up_unused_user_api_keys_spec.rb
index 28c24b046a6..bd3d22b771f 100644
--- a/spec/jobs/clean_up_unused_user_api_keys_spec.rb
+++ b/spec/jobs/clean_up_unused_user_api_keys_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Jobs::CleanUpUnusedUserApiKeys do
context "when user api key is unused in last 1 days" do
before { SiteSetting.revoke_user_api_keys_unused_days = 1 }
- it "should only revoke keys that are active and unused" do
+ it "revokes only active unused keys" do
freeze_time
key1.update!(last_used_at: 2.days.ago)
diff --git a/spec/jobs/clean_up_uploads_spec.rb b/spec/jobs/clean_up_uploads_spec.rb
index 6a81baa9243..8eff045c103 100644
--- a/spec/jobs/clean_up_uploads_spec.rb
+++ b/spec/jobs/clean_up_uploads_spec.rb
@@ -91,7 +91,7 @@ RSpec.describe Jobs::CleanUpUploads do
describe "when clean_up_uploads is disabled" do
before { SiteSetting.clean_up_uploads = false }
- it "should still delete invalid upload records" do
+ it "still deletes invalid upload records" do
upload2 = Fabricate(:upload, created_at: 2.hours.ago, url: "", retain_hours: nil)
expect do Jobs::CleanUpUploads.new.execute(nil) end.to change { Upload.count }.by(-1)
diff --git a/spec/jobs/clean_up_user_api_keys_max_life_spec.rb b/spec/jobs/clean_up_user_api_keys_max_life_spec.rb
index de60bfc8391..bc20d107543 100644
--- a/spec/jobs/clean_up_user_api_keys_max_life_spec.rb
+++ b/spec/jobs/clean_up_user_api_keys_max_life_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Jobs::CleanUpUserApiKeysMaxLife do
context "when user api key was created before the max life period" do
before { SiteSetting.revoke_user_api_keys_maxlife_days = 2 }
- it "should revoke active keys" do
+ it "revokes active keys past their maximum lifetime" do
freeze_time
expect { described_class.new.execute({}) }.to change { older_key.reload.revoked_at }.from(
diff --git a/spec/jobs/clean_up_user_export_topics_spec.rb b/spec/jobs/clean_up_user_export_topics_spec.rb
index 9bfc94f24dd..c5acf908ca9 100644
--- a/spec/jobs/clean_up_user_export_topics_spec.rb
+++ b/spec/jobs/clean_up_user_export_topics_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Jobs::CleanUpUserExportTopics do
fab!(:user)
- it "should delete ancient user export system messages" do
+ it "deletes old user-export system messages" do
post_en =
SystemMessage.create_from_system_user(
user,
diff --git a/spec/jobs/close_topic_spec.rb b/spec/jobs/close_topic_spec.rb
index d072deea088..e63e1a6ad79 100644
--- a/spec/jobs/close_topic_spec.rb
+++ b/spec/jobs/close_topic_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Jobs::CloseTopic do
fab!(:topic) { Fabricate(:topic_timer, user: admin).topic }
- it "should be able to close a topic" do
+ it "closes a topic" do
freeze_time(61.minutes.from_now) do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id, state: true)
@@ -27,7 +27,7 @@ RSpec.describe Jobs::CloseTopic do
end
describe "when trying to close a topic that has already been closed" do
- it "should delete the topic timer" do
+ it "deletes the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
topic.update!(closed: true)
@@ -39,7 +39,7 @@ RSpec.describe Jobs::CloseTopic do
end
describe "when trying to close a topic that has been deleted" do
- it "should delete the topic timer" do
+ it "deletes the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
topic.trash!
@@ -75,7 +75,7 @@ RSpec.describe Jobs::CloseTopic do
fab!(:topic) { Fabricate(:topic_timer, user: user).topic }
- it "should destroy the topic timer" do
+ it "destroys the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
expect do
@@ -85,7 +85,7 @@ RSpec.describe Jobs::CloseTopic do
expect(topic.reload.closed).to eq(false)
end
- it "should reconfigure topic timer if category's topics are set to autoclose" do
+ it "reconfigures the topic timer when the category's topics auto-close" do
category = Fabricate(:category, auto_close_based_on_last_post: true, auto_close_hours: 5)
topic = Fabricate(:topic, category: category)
diff --git a/spec/jobs/create_recent_post_search_indexes_spec.rb b/spec/jobs/create_recent_post_search_indexes_spec.rb
index 7738b20ad00..7cff2cf17a0 100644
--- a/spec/jobs/create_recent_post_search_indexes_spec.rb
+++ b/spec/jobs/create_recent_post_search_indexes_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Jobs::CreateRecentPostSearchIndexes do
before { SearchIndexer.enable }
describe "#execute" do
- it "should not create the index if required posts size has not been reached" do
+ it "does not create the index before the required post count is reached" do
SiteSetting.search_recent_posts_size = 1
SiteSetting.search_enable_recent_regular_posts_offset_size = 3
@@ -18,7 +18,7 @@ RSpec.describe Jobs::CreateRecentPostSearchIndexes do
}
end
- it "should create the right index" do
+ it "creates the expected index" do
SiteSetting.search_recent_posts_size = 1
SiteSetting.search_enable_recent_regular_posts_offset_size = 1
diff --git a/spec/jobs/create_user_reviewable_spec.rb b/spec/jobs/create_user_reviewable_spec.rb
index 3c9a2c2b37b..712ea35bf6c 100644
--- a/spec/jobs/create_user_reviewable_spec.rb
+++ b/spec/jobs/create_user_reviewable_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Jobs::CreateUserReviewable do
expect(reviewable.payload["email"]).to eq(user.email)
end
- it "should not raise an error if there is a reviewable already" do
+ it "does not raise an error when a reviewable already exists" do
SiteSetting.must_approve_users = true
described_class.new.execute(user_id: user.id)
described_class.new.execute(user_id: user.id)
diff --git a/spec/jobs/delete_topic_spec.rb b/spec/jobs/delete_topic_spec.rb
index 21f82329987..86e0ab3b84c 100644
--- a/spec/jobs/delete_topic_spec.rb
+++ b/spec/jobs/delete_topic_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Jobs::DeleteTopic do
expect(topic.reload.public_topic_timer).to eq(nil)
end
- it "should do nothing if topic is already deleted" do
+ it "does nothing when the topic is already deleted" do
first_post
topic.trash!
@@ -28,7 +28,7 @@ RSpec.describe Jobs::DeleteTopic do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end
- it "should do nothing if it's too early" do
+ it "does nothing when run too early" do
t = Fabricate(:topic_timer, user: admin, execute_at: 5.hours.from_now).topic
create_post(topic: t)
@@ -41,7 +41,7 @@ RSpec.describe Jobs::DeleteTopic do
describe "user isn't authorized to delete topics" do
let(:topic) { Fabricate(:topic_timer, user: Fabricate(:user)).topic }
- it "shouldn't delete the topic" do
+ it "does not delete the topic" do
create_post(topic: topic)
freeze_time 2.hours.from_now
diff --git a/spec/jobs/download_avatar_from_url_spec.rb b/spec/jobs/download_avatar_from_url_spec.rb
index b7da1d5f106..5ec1ba9b5b0 100644
--- a/spec/jobs/download_avatar_from_url_spec.rb
+++ b/spec/jobs/download_avatar_from_url_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Jobs::DownloadAvatarFromUrl do
fab!(:user)
describe "when url is invalid" do
- it "should not raise any error" do
+ it "does not raise an error" do
expect do
described_class.new.execute(url: "/assets/something/nice.jpg", user_id: user.id)
end.to_not raise_error
diff --git a/spec/jobs/download_backup_email_spec.rb b/spec/jobs/download_backup_email_spec.rb
index 01e58f9ed5d..81f120bbe24 100644
--- a/spec/jobs/download_backup_email_spec.rb
+++ b/spec/jobs/download_backup_email_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Jobs::DownloadBackupEmail do
before { SiteSetting.simple_email_subject = true }
- it "should work" do
+ it "emails a tokenized backup download link" do
described_class.new.execute(user_id: user.id, backup_file_path: "http://some.example.test/")
email = ActionMailer::Base.deliveries.last
diff --git a/spec/jobs/download_profile_background_from_url_spec.rb b/spec/jobs/download_profile_background_from_url_spec.rb
index 924d274673d..4f05e52f8b3 100644
--- a/spec/jobs/download_profile_background_from_url_spec.rb
+++ b/spec/jobs/download_profile_background_from_url_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Jobs::DownloadProfileBackgroundFromUrl do
fab!(:user)
describe "when url is invalid" do
- it "should not raise any error" do
+ it "handles a relative image URL without raising an error" do
expect do
described_class.new.execute(url: "/assets/something/nice.jpg", user_id: user.id)
end.to_not raise_error
diff --git a/spec/jobs/emit_web_hook_event_spec.rb b/spec/jobs/emit_web_hook_event_spec.rb
index 24b08590209..4cbe5f29e97 100644
--- a/spec/jobs/emit_web_hook_event_spec.rb
+++ b/spec/jobs/emit_web_hook_event_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Jobs::EmitWebHookEvent do
)
end
- it "should not destroy webhook event in case of error" do
+ it "retains the webhook event after an error" do
stub_request(:post, post_hook.payload_url).to_return(status: 500)
job.execute(
diff --git a/spec/jobs/ensure_s3_uploads_existence_spec.rb b/spec/jobs/ensure_s3_uploads_existence_spec.rb
index 8a5b116effd..d2aab2870b3 100644
--- a/spec/jobs/ensure_s3_uploads_existence_spec.rb
+++ b/spec/jobs/ensure_s3_uploads_existence_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Jobs::EnsureS3UploadsExistence do
context "when `s3_inventory_bucket` has been set" do
before { SiteSetting.s3_inventory_bucket = "some-bucket-name" }
- it "works" do
+ it "checks that the S3 uploads exist" do
S3Inventory.any_instance.expects(:backfill_etags_and_list_missing).once
job.execute({})
end
diff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rb
index 57ea2f204b4..d36465a87fd 100644
--- a/spec/jobs/export_csv_file_spec.rb
+++ b/spec/jobs/export_csv_file_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Jobs::ExportCsvFile do
end
end
- it "works" do
+ it "uploads the staff action export and sends the admin a download link" do
action_log
begin
diff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rb
index 71cf71a4c7d..944afd8e661 100644
--- a/spec/jobs/export_user_archive_spec.rb
+++ b/spec/jobs/export_user_archive_spec.rb
@@ -62,7 +62,7 @@ RSpec.describe Jobs::ExportUserArchive do
)
end
- it "works" do
+ it "creates the archive and sends its download link" do
expect do Jobs::ExportUserArchive.new.execute(user_id: user.id) end.to change {
Upload.count
}.by(1)
diff --git a/spec/jobs/feature_topic_users_spec.rb b/spec/jobs/feature_topic_users_spec.rb
index 5b746c08f13..7e8717032bf 100644
--- a/spec/jobs/feature_topic_users_spec.rb
+++ b/spec/jobs/feature_topic_users_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Jobs::FeatureTopicUsers do
let!(:second_post) { create_post(topic: topic, user: coding_horror) }
let!(:third_post) { create_post(topic: topic, user: evil_trout) }
- it "won't feature the OP" do
+ it "does not feature the original poster" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id)
expect(topic.reload.featured_user_ids.include?(topic.user_id)).to eq(false)
end
@@ -27,7 +27,7 @@ RSpec.describe Jobs::FeatureTopicUsers do
expect(topic.reload.featured_user_ids.include?(coding_horror.id)).to eq(true)
end
- it "won't feature the last poster" do
+ it "does not feature the last poster" do
Jobs::FeatureTopicUsers.new.execute(topic_id: topic.id)
expect(topic.reload.featured_user_ids.include?(evil_trout.id)).to eq(false)
end
@@ -37,7 +37,7 @@ RSpec.describe Jobs::FeatureTopicUsers do
let!(:post) { create_post }
let(:topic) { post.topic }
- it "it works as expected" do
+ it "updates the participant count independently of featured users" do
# It has 1 participant after creation
expect(topic.participant_count).to eq(1)
diff --git a/spec/jobs/fix_out_of_sync_user_uploaded_avatar_spec.rb b/spec/jobs/fix_out_of_sync_user_uploaded_avatar_spec.rb
index bd5a32a7458..dce1e62a8b7 100644
--- a/spec/jobs/fix_out_of_sync_user_uploaded_avatar_spec.rb
+++ b/spec/jobs/fix_out_of_sync_user_uploaded_avatar_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::FixOutOfSyncUserUploadedAvatar do
- it "should fix out of sync user uploaded avatars" do
+ it "repairs out-of-sync uploaded avatars" do
user_with_custom_upload = Fabricate(:user)
custom_upload1 = Fabricate(:upload, user: user_with_custom_upload)
gravatar_upload1 = Fabricate(:upload, user: user_with_custom_upload)
diff --git a/spec/jobs/fix_primary_emails_for_staged_users_spec.rb b/spec/jobs/fix_primary_emails_for_staged_users_spec.rb
index fbf4af96241..d2d175cf2db 100644
--- a/spec/jobs/fix_primary_emails_for_staged_users_spec.rb
+++ b/spec/jobs/fix_primary_emails_for_staged_users_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::FixPrimaryEmailsForStagedUsers do
- it "should clean up duplicated staged users" do
+ it "cleans up duplicate staged users" do
common_email = "test@reply"
staged_user = Fabricate(:user, staged: true, active: false)
diff --git a/spec/jobs/fix_s3_etags_spec.rb b/spec/jobs/fix_s3_etags_spec.rb
index 2f72829f089..243c42dc380 100644
--- a/spec/jobs/fix_s3_etags_spec.rb
+++ b/spec/jobs/fix_s3_etags_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Jobs::FixS3Etags do
let(:etag_with_quotes) { '"ETag"' }
let(:etag_without_quotes) { "ETag" }
- it "should remove double quotes from etags" do
+ it "removes double quotes from ETags" do
upload1 = Fabricate(:upload, etag: etag_with_quotes)
upload2 = Fabricate(:upload, etag: etag_without_quotes)
optimized = Fabricate(:optimized_image, etag: etag_with_quotes)
diff --git a/spec/jobs/grant_anniversary_badges_spec.rb b/spec/jobs/grant_anniversary_badges_spec.rb
index 57b54708c9b..ac446045eba 100644
--- a/spec/jobs/grant_anniversary_badges_spec.rb
+++ b/spec/jobs/grant_anniversary_badges_spec.rb
@@ -122,7 +122,7 @@ RSpec.describe Jobs::GrantAnniversaryBadges do
end
context "with repeated grants" do
- it "won't award twice in the same year" do
+ it "does not award twice in the same year" do
user = Fabricate(:user, created_at: 400.days.ago)
Fabricate(:post, user: user, created_at: 1.week.ago)
@@ -132,7 +132,7 @@ RSpec.describe Jobs::GrantAnniversaryBadges do
expect(badge.count).to eq(1)
end
- it "will award again if a year has passed" do
+ it "awards the badge again after a year has passed" do
user = Fabricate(:user, created_at: 800.days.ago)
Fabricate(:post, user: user, created_at: 450.days.ago)
diff --git a/spec/jobs/jobs_base_spec.rb b/spec/jobs/jobs_base_spec.rb
index 28f11902570..16435a36b24 100644
--- a/spec/jobs/jobs_base_spec.rb
+++ b/spec/jobs/jobs_base_spec.rb
@@ -166,7 +166,7 @@ RSpec.describe ::Jobs::Base do
FileUtils.rm(tmp_log_file_path)
end
- it "should log the job in the sidekiq log file" do
+ it "writes the job to the Sidekiq log" do
job = GoodJob.new
job.perform({ some_param: "some_value" })
diff --git a/spec/jobs/jobs_spec.rb b/spec/jobs/jobs_spec.rb
index cb20f3b7664..b1da84889ad 100644
--- a/spec/jobs/jobs_spec.rb
+++ b/spec/jobs/jobs_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe Jobs do
Jobs.enqueue(:process_post, post_id: 1)
end
- it "should enqueue with the correct database id when the current_site_id option is given" do
+ it "enqueues with the specified current_site_id" do
Sidekiq::Testing.fake! do
jobs = Jobs::ProcessPost.jobs
@@ -113,7 +113,7 @@ RSpec.describe Jobs do
Jobs::ProcessPost.any_instance.stubs(:execute).returns(true)
end
- it "should raise an exception" do
+ it "raises ArgumentError without executing the job or changing connections" do
Jobs::ProcessPost.any_instance.expects(:execute).never
RailsMultisite::ConnectionManagement.expects(:establish_connection).never
diff --git a/spec/jobs/notify_moved_posts_spec.rb b/spec/jobs/notify_moved_posts_spec.rb
index c60bd1e491c..e5a1f8a2720 100644
--- a/spec/jobs/notify_moved_posts_spec.rb
+++ b/spec/jobs/notify_moved_posts_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Jobs::NotifyMovedPosts do
Notification.where(notification_type: Notification.types[:moved_post])
end
- it "should create two notifications" do
+ it "creates two notifications" do
expect {
Jobs::NotifyMovedPosts.new.execute(post_ids: [p1.id, p2.id, p3.id], moved_by_id: admin.id)
}.to change(moved_post_notifications, :count).by(2)
diff --git a/spec/jobs/notify_reviewable_spec.rb b/spec/jobs/notify_reviewable_spec.rb
index 2abb7494e32..0eec7cc630c 100644
--- a/spec/jobs/notify_reviewable_spec.rb
+++ b/spec/jobs/notify_reviewable_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Jobs::NotifyReviewable do
)
end
- it "will notify users of new reviewable content for the user menu" do
+ it "notifies users of new reviewable content for the user menu" do
SiteSetting.navigation_menu = "sidebar"
SiteSetting.enable_category_group_moderation = true
@@ -103,7 +103,7 @@ RSpec.describe Jobs::NotifyReviewable do
expect(group_user_message.data[:unseen_reviewable_count]).to eq(1)
end
- it "won't notify a group when disabled" do
+ it "does not notify a group when disabled" do
SiteSetting.enable_category_group_moderation = false
GroupUser.create!(group_id: group.id, user_id: moderator.id)
diff --git a/spec/jobs/open_topic_spec.rb b/spec/jobs/open_topic_spec.rb
index 946c459fc98..d49c5a6c21c 100644
--- a/spec/jobs/open_topic_spec.rb
+++ b/spec/jobs/open_topic_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Jobs::OpenTopic do
before { topic.update!(closed: true) }
- it "should work" do
+ it "opens the topic when the timer expires" do
freeze_time(61.minutes.from_now) do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
@@ -35,7 +35,7 @@ RSpec.describe Jobs::OpenTopic do
fab!(:topic) { Fabricate(:topic, category: category, closed: true) }
- it "should restore the category's auto close timer" do
+ it "restores the category's auto close timer" do
Fabricate(:topic_timer, status_type: TopicTimer.types[:open], topic: topic, user: admin)
freeze_time(61.minutes.from_now) do
@@ -77,7 +77,7 @@ RSpec.describe Jobs::OpenTopic do
fab!(:topic) { Fabricate(:topic_timer, user: user).topic }
- it "should destroy the topic timer" do
+ it "destroys the topic timer" do
topic.update!(closed: true)
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
@@ -88,7 +88,7 @@ RSpec.describe Jobs::OpenTopic do
expect(topic.reload.open?).to eq(false)
end
- it "should reconfigure topic timer if category's topics are set to autoclose" do
+ it "reconfigures the timer when the category's topics close automatically" do
category = Fabricate(:category, auto_close_based_on_last_post: true, auto_close_hours: 5)
topic = Fabricate(:topic, category: category)
diff --git a/spec/jobs/periodical_updates_spec.rb b/spec/jobs/periodical_updates_spec.rb
index 811c8d9be9a..86200f831ed 100644
--- a/spec/jobs/periodical_updates_spec.rb
+++ b/spec/jobs/periodical_updates_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Jobs::PeriodicalUpdates do
)
end
- it "works" do
+ it "runs all periodic updates without an error" do
# does not blow up, no mocks, everything is called
Jobs::PeriodicalUpdates.new.execute(nil)
end
diff --git a/spec/jobs/post_update_topic_tracking_state_spec.rb b/spec/jobs/post_update_topic_tracking_state_spec.rb
index 574a82d7e37..620ed6ddaa7 100644
--- a/spec/jobs/post_update_topic_tracking_state_spec.rb
+++ b/spec/jobs/post_update_topic_tracking_state_spec.rb
@@ -5,18 +5,18 @@ RSpec.describe Jobs::PostUpdateTopicTrackingState do
fab!(:post)
- it "should publish messages" do
+ it "publishes messages" do
messages = MessageBus.track_publish { job.execute({ post_id: post.id }) }
expect(messages.size).not_to eq(0)
end
- it "should not publish messages for deleted topics" do
+ it "does not publish messages for deleted topics" do
post.topic.trash!
messages = MessageBus.track_publish { job.execute({ post_id: post.id }) }
expect(messages.size).to eq(0)
end
- it "should not update topic groups for small_action posts in private messages" do
+ it "does not update topic groups for small-action posts in private messages" do
user = Fabricate(:user, refresh_auto_groups: true)
recipient = Fabricate(:user)
pm =
diff --git a/spec/jobs/post_uploads_recovery_spec.rb b/spec/jobs/post_uploads_recovery_spec.rb
index 57c7633406e..570e1641313 100644
--- a/spec/jobs/post_uploads_recovery_spec.rb
+++ b/spec/jobs/post_uploads_recovery_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Jobs::PostUploadsRecovery do
describe "#grace_period" do
- it "should restrict the grace period to the right range" do
+ it "clamps the grace period to its valid range" do
SiteSetting.purge_deleted_uploads_grace_period_days = described_class::MIN_PERIOD - 1
expect(described_class.new.grace_period).to eq(30)
diff --git a/spec/jobs/publish_topic_to_category_spec.rb b/spec/jobs/publish_topic_to_category_spec.rb
index 1127534d736..65d2bf9317d 100644
--- a/spec/jobs/publish_topic_to_category_spec.rb
+++ b/spec/jobs/publish_topic_to_category_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Jobs::PublishTopicToCategory do
end
describe "when topic has been deleted" do
- it "should not publish the topic to the new category" do
+ it "does not publish the topic to the new category" do
created_at = freeze_time 1.hour.ago
topic
@@ -39,7 +39,7 @@ RSpec.describe Jobs::PublishTopicToCategory do
end
end
- it "should publish the topic to the new category" do
+ it "publishes the topic to the new category" do
freeze_time 1.hour.ago do
topic.update!(visible: false)
end
@@ -63,7 +63,7 @@ RSpec.describe Jobs::PublishTopicToCategory do
end
describe "when topic is a private message" do
- it "should publish the topic to the new category" do
+ it "publishes the topic to the new category" do
freeze_time 1.hour.ago do
expect { topic.convert_to_private_message(Discourse.system_user) }.to change {
topic.private_message?
@@ -127,7 +127,7 @@ RSpec.describe Jobs::PublishTopicToCategory do
end
describe "when new category has a default auto-close" do
- it "should apply the auto-close timer upon publishing" do
+ it "applies the auto-close timer when publishing" do
freeze_time
another_category.update!(auto_close_hours: 5)
diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb
index 73c2b26d6d6..e98e2863154 100644
--- a/spec/jobs/pull_hotlinked_images_spec.rb
+++ b/spec/jobs/pull_hotlinked_images_spec.rb
@@ -540,26 +540,26 @@ RSpec.describe Jobs::PullHotlinkedImages do
subject(:job) { described_class.new }
describe "when url is invalid" do
- it "should return false" do
+ it "rejects image URLs without a scheme or protocol-relative prefix" do
expect(job.should_download_image?("null")).to eq(false)
expect(job.should_download_image?("meta.discourse.org")).to eq(false)
end
end
describe "when url is valid" do
- it "should return true" do
+ it "accepts HTTP and protocol-relative image URLs" do
expect(job.should_download_image?("http://meta.discourse.org")).to eq(true)
expect(job.should_download_image?("//meta.discourse.org")).to eq(true)
end
end
describe "when url is an upload" do
- it "should return false for original" do
+ it "rejects an original upload URL" do
expect(job.should_download_image?(Fabricate(:upload).url)).to eq(false)
end
context "when secure uploads enabled" do
- it "should return false for secure-upload url" do
+ it "rejects a secure upload URL" do
setup_s3
SiteSetting.secure_uploads = true
@@ -570,7 +570,7 @@ RSpec.describe Jobs::PullHotlinkedImages do
end
end
- it "should return true for optimized" do
+ it "accepts an optimized image URL" do
src = Discourse.store.get_path_for_optimized_image(Fabricate(:optimized_image))
expect(job.should_download_image?(src)).to eq(true)
end
diff --git a/spec/jobs/rebake_custom_emoji_posts_spec.rb b/spec/jobs/rebake_custom_emoji_posts_spec.rb
index 49951a4660e..7cd98cc1e71 100644
--- a/spec/jobs/rebake_custom_emoji_posts_spec.rb
+++ b/spec/jobs/rebake_custom_emoji_posts_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::RebakeCustomEmojiPosts do
- it "should rebake posts that are using a given custom emoji" do
+ it "rebakes posts using the given custom emoji" do
upload = Fabricate(:upload)
custom_emoji = CustomEmoji.create!(name: "test", upload: upload)
Emoji.clear_cache
diff --git a/spec/jobs/regular/group_smtp_email_spec.rb b/spec/jobs/regular/group_smtp_email_spec.rb
index cbab0070282..8c1b9975912 100644
--- a/spec/jobs/regular/group_smtp_email_spec.rb
+++ b/spec/jobs/regular/group_smtp_email_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe Jobs::GroupSmtpEmail do
expect(email_text).not_to include(recipient_user.username)
end
- it "creates an EmailLog record with the correct details" do
+ it "stores delivery details in the EmailLog" do
job.execute(args)
email_log =
EmailLog.find_by(post_id: post.id, topic_id: post.topic_id, user_id: recipient_user.id)
@@ -121,7 +121,7 @@ RSpec.describe Jobs::GroupSmtpEmail do
expect(incoming_email.subject).to eq("Re: Help I need support")
end
- it "does not create a post reply key, it always replies to the group email_username" do
+ it "uses the group email address in the generated mail headers" do
job.execute(args)
expect(ActionMailer::Base.deliveries.count).to eq(1)
expect(ActionMailer::Base.deliveries.last.subject).to eq("Re: Help I need support")
diff --git a/spec/jobs/regular/site_setting_update_default_categories_spec.rb b/spec/jobs/regular/site_setting_update_default_categories_spec.rb
index fc43a5423b9..a40e25d5c53 100644
--- a/spec/jobs/regular/site_setting_update_default_categories_spec.rb
+++ b/spec/jobs/regular/site_setting_update_default_categories_spec.rb
@@ -23,7 +23,7 @@ describe Jobs::SiteSettingUpdateDefaultCategories do
)
end
- it "should update existing users user preference" do
+ it "updates existing users' category preferences" do
job.execute(
id: "default_categories_watching",
value: category_ids.last(2).join("|"),
@@ -73,7 +73,7 @@ describe Jobs::SiteSettingUpdateDefaultCategories do
)
end
- it "should publish a MessageBus informing the correct groups" do
+ it "publishes the affected groups through MessageBus" do
messages =
MessageBus.track_publish("/site_setting/default_categories_watching/process") do
job.execute(
diff --git a/spec/jobs/regular/site_setting_update_default_tags_spec.rb b/spec/jobs/regular/site_setting_update_default_tags_spec.rb
index 18330d4ddb7..63ac9a545bb 100644
--- a/spec/jobs/regular/site_setting_update_default_tags_spec.rb
+++ b/spec/jobs/regular/site_setting_update_default_tags_spec.rb
@@ -18,7 +18,7 @@ describe Jobs::SiteSettingUpdateDefaultTags do
TagUser.create!(tag_id: tags.last.id, notification_level: tracking, user: user2)
end
- it "should update existing users user preference" do
+ it "updates existing users' preferences" do
job.execute(
id: "default_tags_watching",
value: tags.last(2).pluck(:name).join("|"),
@@ -31,7 +31,7 @@ describe Jobs::SiteSettingUpdateDefaultTags do
)
end
- it "should publish a MessageBus informing the correct groups" do
+ it "publishes a MessageBus message for the affected groups" do
messages =
MessageBus.track_publish("/site_setting/default_tags_watching/process") do
job.execute(
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index 2e3ee9653ad..683304a63e4 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Jobs::ReindexSearch do
# Didn't check `topic` because topic doesn't have posts in fabrication
# thus no search data
%w[post category user].each do |m|
- it "should rebuild `#{m}` when default_locale changed" do
+ it "rebuilds `#{m}` when default_locale changes" do
SiteSetting.default_locale = "en"
model = Fabricate(m.to_sym)
SiteSetting.default_locale = locale
@@ -22,7 +22,7 @@ RSpec.describe Jobs::ReindexSearch do
expect(model.public_send("#{m}_search_data").locale).to eq locale
end
- it "should rebuild `#{m}` when INDEX_VERSION changed" do
+ it "rebuilds `#{m}` when INDEX_VERSION changes" do
model = Fabricate(m.to_sym)
# so that search data can be reindexed
search_data = model.public_send("#{m}_search_data")
@@ -59,7 +59,7 @@ RSpec.describe Jobs::ReindexSearch do
after { FakeIndexer.reset }
- it "should not reindex posts that belong to a deleted topic or have been trashed" do
+ it "does not reindex trashed posts or posts in deleted topics" do
post = Fabricate(:post)
post2 = Fabricate(:post)
post3 = Fabricate(:post)
@@ -72,7 +72,7 @@ RSpec.describe Jobs::ReindexSearch do
expect(FakeIndexer.posts).to contain_exactly(post)
end
- it "should not reindex posts with a developmental version" do
+ it "does not reindex posts with a development version" do
Fabricate(:post, version: SearchIndexer::POST_INDEX_VERSION + 1)
job.rebuild_posts(indexer: FakeIndexer)
@@ -80,7 +80,7 @@ RSpec.describe Jobs::ReindexSearch do
expect(FakeIndexer.posts).to eq([])
end
- it "should not reindex posts with empty raw" do
+ it "does not reindex posts with empty raw content" do
post = Fabricate(:post)
post.post_search_data.destroy!
@@ -193,7 +193,7 @@ RSpec.describe Jobs::ReindexSearch do
end
describe "#execute" do
- it "should clean up topic_search_data of trashed topics" do
+ it "removes topic search data for trashed topics" do
topic = Fabricate(:post).topic
topic2 = Fabricate(:post).topic
@@ -207,7 +207,7 @@ RSpec.describe Jobs::ReindexSearch do
expect(TopicSearchData.pluck(:topic_id)).to contain_exactly(topic2.topic_search_data.topic_id)
end
- it "should clean up post_search_data of posts with empty raw or posts from trashed topics" do
+ it "removes post search data for empty posts and trashed topics" do
post = Fabricate(:post)
post2 = Fabricate(:post, post_type: Post.types[:small_action])
post2.raw = ""
diff --git a/spec/jobs/reviewable_priorities_spec.rb b/spec/jobs/reviewable_priorities_spec.rb
index 1e85659d16a..436a12ff65e 100644
--- a/spec/jobs/reviewable_priorities_spec.rb
+++ b/spec/jobs/reviewable_priorities_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Jobs::ReviewablePriorities do
let(:high_threshold) { 13.0 }
let(:score_to_hide_post) { 8.66 }
- it "will set priorities based on the maximum score" do
+ it "sets priorities based on the maximum score" do
other_reviewable.destroy!
Jobs::ReviewablePriorities.new.execute({})
diff --git a/spec/jobs/send_system_message_spec.rb b/spec/jobs/send_system_message_spec.rb
index 4b2897abcc4..ff4f5ceda36 100644
--- a/spec/jobs/send_system_message_spec.rb
+++ b/spec/jobs/send_system_message_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Jobs::SendSystemMessage do
context "with valid parameters" do
fab!(:user)
- it "should call SystemMessage.create" do
+ it "creates the system message" do
SystemMessage.any_instance.expects(:create).with("welcome_invite", {})
Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: "welcome_invite")
end
diff --git a/spec/jobs/suspicious_login_spec.rb b/spec/jobs/suspicious_login_spec.rb
index e102311aa18..7b3a2337550 100644
--- a/spec/jobs/suspicious_login_spec.rb
+++ b/spec/jobs/suspicious_login_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Jobs::SuspiciousLogin do
DiscourseIpInfo.stubs(:get).with("1.1.2.1").returns(london)
end
- it "will correctly compute distance" do
+ it "computes the distance between login locations" do
def expect_distance(from, to, distance)
expect(UserAuthToken.distance(from.values, to.values).to_i).to eq(distance)
expect(UserAuthToken.distance(to.values, from.values).to_i).to eq(distance)
@@ -24,7 +24,7 @@ RSpec.describe Jobs::SuspiciousLogin do
expect_distance(bern, london, 747)
end
- it "will not send an email on first login" do
+ it "does not email the user on their first login" do
expect do
described_class.new.execute(user_id: user.id, client_ip: "1.1.1.1")
end.to_not change { Jobs::CriticalUserEmail.jobs.size }
@@ -32,7 +32,7 @@ RSpec.describe Jobs::SuspiciousLogin do
expect(UserAuthTokenLog.where(action: "suspicious").count).to eq(0)
end
- it "will not send an email when user log in from a known location" do
+ it "does not email the user after a login from a known location" do
UserAuthTokenLog.create!(action: "generate", user_id: user.id, client_ip: "1.1.1.1")
expect do
@@ -43,7 +43,7 @@ RSpec.describe Jobs::SuspiciousLogin do
expect(UserAuthTokenLog.where(action: "suspicious").count).to eq(0)
end
- it "will send an email when user logs in from a new location" do
+ it "emails the user after a login from a new location" do
UserAuthTokenLog.create!(action: "generate", user_id: user.id, client_ip: "1.1.1.1")
described_class.new.execute(user_id: user.id, client_ip: "1.1.2.1")
diff --git a/spec/jobs/toggle_topic_closed_spec.rb b/spec/jobs/toggle_topic_closed_spec.rb
index 5164add32df..35510ee8844 100644
--- a/spec/jobs/toggle_topic_closed_spec.rb
+++ b/spec/jobs/toggle_topic_closed_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
fab!(:topic) { Fabricate(:topic_timer, user: admin).topic }
- it "should be able to close a topic" do
+ it "closes a topic" do
topic
freeze_time(61.minutes.from_now) do
@@ -18,7 +18,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
end
describe "opening a topic" do
- it "should be work" do
+ it "opens a closed topic" do
topic.update!(closed: true)
freeze_time(61.minutes.from_now) do
@@ -37,7 +37,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
fab!(:topic) { Fabricate(:topic, category: category, closed: true) }
- it "should restore the category's auto close timer" do
+ it "restores the category's auto-close timer" do
Fabricate(:topic_timer, status_type: TopicTimer.types[:open], topic: topic, user: admin)
freeze_time(61.minutes.from_now) do
@@ -55,7 +55,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
end
describe "when trying to close a topic that has already been closed" do
- it "should delete the topic timer" do
+ it "deletes the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
topic.update!(closed: true)
@@ -67,7 +67,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
end
describe "when trying to close a topic that has been deleted" do
- it "should delete the topic timer" do
+ it "deletes the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
topic.trash!
@@ -83,7 +83,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
fab!(:topic) { Fabricate(:topic_timer, user: user).topic }
- it "should destroy the topic timer" do
+ it "destroys the topic timer" do
freeze_time(topic.public_topic_timer.execute_at + 1.minute)
expect do
@@ -93,7 +93,7 @@ RSpec.describe Jobs::ToggleTopicClosed do
expect(topic.reload.closed).to eq(false)
end
- it "should reconfigure topic timer if category's topics are set to autoclose" do
+ it "reconfigures the topic timer when the category's topics auto-close" do
category = Fabricate(:category, auto_close_based_on_last_post: true, auto_close_hours: 5)
topic = Fabricate(:topic, category: category)
diff --git a/spec/lib/admin_user_index_query_spec.rb b/spec/lib/admin_user_index_query_spec.rb
index fa0c919619e..44a2cfba1c0 100644
--- a/spec/lib/admin_user_index_query_spec.rb
+++ b/spec/lib/admin_user_index_query_spec.rb
@@ -219,7 +219,7 @@ RSpec.describe AdminUserIndexQuery do
describe "filtering" do
context "with exact email bypass" do
- it "can correctly bypass expensive ilike query" do
+ it "matches an exact email filter without ILIKE" do
user = Fabricate(:user, email: "[email protected]")
query = AdminUserIndexQuery.new(filter: "[email protected]").find_users_query
@@ -229,7 +229,7 @@ RSpec.describe AdminUserIndexQuery do
expect(query.to_sql.downcase).not_to include("ilike")
end
- it "can correctly bypass expensive ilike query" do
+ it "matches the email parameter exactly without ILIKE" do
user = Fabricate(:user, email: "[email protected]")
query = AdminUserIndexQuery.new(email: "[email protected]").find_users_query
diff --git a/spec/lib/asset_processor_spec.rb b/spec/lib/asset_processor_spec.rb
index 713cdee9784..a1a1428dcf6 100644
--- a/spec/lib/asset_processor_spec.rb
+++ b/spec/lib/asset_processor_spec.rb
@@ -649,7 +649,7 @@ RSpec.describe AssetProcessor do
expect(AssetProcessor.ember_version).to match(/\A\d+\.\d+\.\d+\z/)
end
- it "errors on missing relative imports" do
+ it "errors on missing relative imports for a plugin without a hyphenated name" do
mod_1 = <<~JS.chomp
import SomeModule from "../some-module";
console.log(SomeModule);
diff --git a/spec/lib/auth/default_current_user_provider_spec.rb b/spec/lib/auth/default_current_user_provider_spec.rb
index 366e18f734e..1f1efe2f634 100644
--- a/spec/lib/auth/default_current_user_provider_spec.rb
+++ b/spec/lib/auth/default_current_user_provider_spec.rb
@@ -184,7 +184,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
after { Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY) }
- it "should not update ApiKey#last_used_at" do
+ it "does not update ApiKey#last_used_at" do
api_key = ApiKey.create!(user_id: user.id, created_by_id: -1)
params = { "HTTP_API_KEY" => api_key.key }
@@ -251,7 +251,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
after { user.clear_last_seen_cache!(@orig) }
- it "should not update last seen for suspended users" do
+ it "does not update last seen for suspended users" do
provider2 = provider("/", "HTTP_COOKIE" => "_t=#{cookie}")
u = provider2.current_user
u.reload
@@ -277,7 +277,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
after { Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY) }
- it "should not update User#last_seen_at" do
+ it "does not update User#last_seen_at" do
provider2 = provider("/", "HTTP_COOKIE" => "_t=#{cookie}")
u = provider2.current_user
u.reload
@@ -286,7 +286,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
describe "when impersonating another user" do
- it "should not update User#last_seen_at" do
+ it "does not update User#last_seen_at" do
old_timestamp = 1.week.ago
user.update!(last_seen_at: old_timestamp)
User.any_instance.stubs(:is_impersonating).returns(true)
@@ -298,7 +298,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
end
- it "should not cache an invalid user when Rails hasn't set `path_parameters` on the request yet" do
+ it "does not cache an invalid user before Rails sets the request's path_parameters" do
SiteSetting.login_required = true
user = Fabricate(:user)
api_key = ApiKey.create!(user_id: user.id, created_by_id: Discourse.system_user)
@@ -394,12 +394,12 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
end
- it "should update last seen for non ajax" do
+ it "updates last seen for non-AJAX requests" do
expect(provider("/topic/anything/goes", method: "POST").should_update_last_seen?).to eq(true)
expect(provider("/topic/anything/goes", method: "GET").should_update_last_seen?).to eq(true)
end
- it "should update ajax reqs with discourse visible" do
+ it "updates last seen for AJAX requests with Discourse visible" do
expect(
provider(
"/topic/anything/goes",
@@ -410,7 +410,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
).to eq(true)
end
- it "should not update last seen for ajax calls without Discourse-Present header" do
+ it "does not update last seen for AJAX requests without the Discourse-Present header" do
expect(
provider(
"/topic/anything/goes",
@@ -420,7 +420,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
).to eq(false)
end
- it "should update last seen for API calls with Discourse-Present header" do
+ it "updates last seen for API calls with the Discourse-Present header" do
api_key = ApiKey.create!(user_id: user.id, created_by_id: -1)
params = {
:method => "POST",
@@ -749,7 +749,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
after { Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY) }
- it "should not update ApiKey#last_used_at" do
+ it "does not update ApiKey#last_used_at" do
params = { "REQUEST_METHOD" => "GET", "HTTP_USER_API_KEY" => api_key.key }
good_provider = provider("/", params)
@@ -833,7 +833,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
create_request_env(path: "/").merge({ :method => "GET", "HTTP_COOKIE" => "_t=#{cookie}" })
end
- it "should work when the current user was cached by a different provider instance" do
+ it "logs off a user cached by another provider instance" do
user_provider = TestProvider.new(env)
expect(user_provider.current_user).to eq(user)
expect(UserAuthToken.find_by(user_id: user.id)).to be_present
@@ -843,7 +843,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
expect(UserAuthToken.find_by(user_id: user.id)).to be_nil
end
- it "should trigger user_logged_out event" do
+ it "triggers the user_logged_out event" do
event_triggered_user = nil
event_handler = Proc.new { |user| event_triggered_user = user.id }
DiscourseEvent.on(:user_logged_out, &event_handler)
diff --git a/spec/lib/auth/github_authenticator_spec.rb b/spec/lib/auth/github_authenticator_spec.rb
index 5d55c9bf2ad..0f313c8680e 100644
--- a/spec/lib/auth/github_authenticator_spec.rb
+++ b/spec/lib/auth/github_authenticator_spec.rb
@@ -60,7 +60,7 @@ RSpec.describe Auth::GithubAuthenticator do
).to eq(user.username)
end
- it "should use primary email for new user creation over other available emails" do
+ it "uses the primary email when creating a user" do
hash = {
provider: "github",
extra: {
@@ -82,7 +82,7 @@ RSpec.describe Auth::GithubAuthenticator do
expect(result.email).to eq("[email protected]")
end
- it "should not error out if user already has a different old github account attached" do
+ it "handles a user with a different GitHub account already attached" do
# There is a rare case where an end user had
# 2 different github accounts and moved emails between the 2
@@ -114,7 +114,7 @@ RSpec.describe Auth::GithubAuthenticator do
expect(UserAssociatedAccount.where(user_id: user.id).pluck(:provider_uid)).to eq(["1001"])
end
- it "will not authenticate for already existing users with an unverified email" do
+ it "does not authenticate existing users with an unverified email" do
hash = {
provider: "github",
extra: {
@@ -160,7 +160,7 @@ RSpec.describe Auth::GithubAuthenticator do
expect(result.email_valid).to eq(hash[:info][:email].present?)
end
- it "will skip blocklisted domains for non existing users" do
+ it "skips blocklisted domains for new users" do
hash = {
provider: "github",
extra: {
@@ -187,7 +187,7 @@ RSpec.describe Auth::GithubAuthenticator do
expect(result.email_valid).to eq(true)
end
- it "will find allowlisted domains for non existing users" do
+ it "finds allowlisted domains for new users" do
hash = {
provider: "github",
extra: {
diff --git a/spec/lib/auth/managed_authenticator_spec.rb b/spec/lib/auth/managed_authenticator_spec.rb
index 8ade73aa523..aa6592472d8 100644
--- a/spec/lib/auth/managed_authenticator_spec.rb
+++ b/spec/lib/auth/managed_authenticator_spec.rb
@@ -206,7 +206,7 @@ RSpec.describe Auth::ManagedAuthenticator do
expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot")
end
- it "will ignore name when equal to email" do
+ it "ignores the name when it equals the email address" do
result = authenticator.after_authenticate(hash.deep_merge(info: { name: hash.info.email }))
expect(result.email).to eq(hash.info.email)
expect(result.name).to eq(nil)
diff --git a/spec/lib/backup_restore/database_restorer_spec.rb b/spec/lib/backup_restore/database_restorer_spec.rb
index e36d01c3181..f4f36114ab8 100644
--- a/spec/lib/backup_restore/database_restorer_spec.rb
+++ b/spec/lib/backup_restore/database_restorer_spec.rb
@@ -160,7 +160,7 @@ RSpec.describe BackupRestore::DatabaseRestorer do
end
describe "database connection" do
- it "it is not erroring for non-multisite" do
+ it "does not raise an error outside multisite mode" do
expect { execute_stubbed_restore }.not_to raise_error
end
end
diff --git a/spec/lib/backup_restore/s3_backup_store_spec.rb b/spec/lib/backup_restore/s3_backup_store_spec.rb
index 5975ea4281d..6324d8648d1 100644
--- a/spec/lib/backup_restore/s3_backup_store_spec.rb
+++ b/spec/lib/backup_restore/s3_backup_store_spec.rb
@@ -194,7 +194,7 @@ RSpec.describe BackupRestore::S3BackupStore do
end
describe "#create_multipart" do
- it "should set the ACL context when `s3_use_acls` site setting is enabled" do
+ it "sets the ACL context when s3_use_acls is enabled" do
SiteSetting.s3_use_acls = true
response = store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
@@ -208,7 +208,7 @@ RSpec.describe BackupRestore::S3BackupStore do
)
end
- it "should not set the ACL context when `s3_use_acls` site setting is disabled" do
+ it "omits the ACL context when s3_use_acls is disabled" do
SiteSetting.s3_use_acls = false
store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
@@ -220,7 +220,7 @@ RSpec.describe BackupRestore::S3BackupStore do
expect(create_multipart_upload_request[:context].params[:acl]).to eq(nil)
end
- it "should set the tagging context when `s3_enable_access_control_tags` site setting is enabled" do
+ it "sets the tagging context when s3_enable_access_control_tags is enabled" do
SiteSetting.s3_enable_access_control_tags = true
store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
@@ -241,7 +241,7 @@ RSpec.describe BackupRestore::S3BackupStore do
before { create_backups }
after { remove_backups }
- it "should set the ACL context when `s3_use_acls` site setting is enabled" do
+ it "sets the ACL context when s3_use_acls is enabled" do
store.move_existing_stored_upload(
existing_external_upload_key: "default/b.tar.gz",
original_filename: "b.tar.gz",
@@ -256,7 +256,7 @@ RSpec.describe BackupRestore::S3BackupStore do
)
end
- it "should not set the ACL context when `s3_use_acls` site setting is disabled" do
+ it "omits the ACL context when s3_use_acls is disabled" do
SiteSetting.s3_use_acls = false
store.move_existing_stored_upload(
@@ -271,7 +271,7 @@ RSpec.describe BackupRestore::S3BackupStore do
expect(copy_object_request[:context].params[:acl]).to eq(nil)
end
- it "should set the tagging context when `s3_enable_access_control_tags` site setting is enabled" do
+ it "sets the tagging context when s3_enable_access_control_tags is enabled" do
SiteSetting.s3_enable_access_control_tags = true
store.move_existing_stored_upload(
diff --git a/spec/lib/color_math_spec.rb b/spec/lib/color_math_spec.rb
index 82b12119848..d0dc06cdfaa 100644
--- a/spec/lib/color_math_spec.rb
+++ b/spec/lib/color_math_spec.rb
@@ -2,14 +2,14 @@
describe ColorMath do
describe "#brightness" do
- it "works" do
+ it "returns the brightness of grayscale colors" do
expect(ColorMath.brightness("000")).to eq(0)
expect(ColorMath.brightness("fff")).to eq(255)
end
end
describe "#scale_color_lightness" do
- it "works" do
+ it "scales the lightness of grayscale colors" do
expect(ColorMath.scale_color_lightness("000", 0.5)).to eq("808080")
expect(ColorMath.scale_color_lightness("fff", -0.5)).to eq("808080")
end
diff --git a/spec/lib/composer_messages_finder_spec.rb b/spec/lib/composer_messages_finder_spec.rb
index b65e27f3739..e56d8d1530c 100644
--- a/spec/lib/composer_messages_finder_spec.rb
+++ b/spec/lib/composer_messages_finder_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe ComposerMessagesFinder do
ComposerMessagesFinder.new(user, composer_action: "createTopic", topic_id: topic.id)
end
- it "should return an empty string" do
+ it "returns an empty string" do
expect(finder.check_education_message).to eq(nil)
end
end
@@ -60,7 +60,7 @@ RSpec.describe ComposerMessagesFinder do
ComposerMessagesFinder.new(user, composer_action: "reply", topic_id: topic.id)
end
- it "should return an empty string" do
+ it "returns an empty string" do
expect(finder.check_education_message).to eq(nil)
end
end
@@ -404,7 +404,7 @@ RSpec.describe ComposerMessagesFinder do
expect(finder.check_get_a_room(min_users_posted: 2)).to be_blank
end
- it "will notify you if it hasn't in the current topic" do
+ it "notifies the user if no notice was shown in the current topic" do
UserHistory.create!(
action: UserHistory.actions[:notified_about_get_a_room],
target_user_id: user.id,
@@ -413,7 +413,7 @@ RSpec.describe ComposerMessagesFinder do
expect(finder.check_get_a_room(min_users_posted: 2)).to be_present
end
- it "won't notify you if you haven't had enough posts" do
+ it "does not notify users with too few posts" do
SiteSetting.get_a_room_threshold = 10
expect(finder.check_get_a_room(min_users_posted: 2)).to be_blank
end
diff --git a/spec/lib/concern/cached_counting_spec.rb b/spec/lib/concern/cached_counting_spec.rb
index 8dd1482b807..29d48d85a47 100644
--- a/spec/lib/concern/cached_counting_spec.rb
+++ b/spec/lib/concern/cached_counting_spec.rb
@@ -15,7 +15,7 @@ class TestCachedCounting
end
RSpec.describe CachedCounting do
- it "should be default disabled in test" do
+ it "is disabled by default in the test environment" do
expect(CachedCounting.enabled?).to eq(false)
end
diff --git a/spec/lib/concern/has_custom_fields_spec.rb b/spec/lib/concern/has_custom_fields_spec.rb
index d054b9fa113..b377f61b71e 100644
--- a/spec/lib/concern/has_custom_fields_spec.rb
+++ b/spec/lib/concern/has_custom_fields_spec.rb
@@ -322,7 +322,7 @@ RSpec.describe HasCustomFields do
expect(item.custom_fields[field_type]).to eq(%w[a b])
end
- it "will not fail to load custom fields if json is corrupt" do
+ it "loads custom fields when their JSON is corrupt" do
field_type = "bad_json"
CustomFieldsTestItem.register_custom_field_type(field_type, :json)
diff --git a/spec/lib/concern/second_factor_manager_spec.rb b/spec/lib/concern/second_factor_manager_spec.rb
index 6e4c3449a81..679d7bd7737 100644
--- a/spec/lib/concern/second_factor_manager_spec.rb
+++ b/spec/lib/concern/second_factor_manager_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe SecondFactorManager do
let(:user_backup) { user_second_factor_backup.user }
describe "#totp" do
- it "should return the right data" do
+ it "returns the generated TOTP data" do
totp = nil
expect do totp = another_user.create_totp(enabled: true) end.to change {
@@ -32,7 +32,7 @@ RSpec.describe SecondFactorManager do
end
describe "#create_totp" do
- it "should create the right record" do
+ it "creates an enabled TOTP record" do
second_factor = another_user.create_totp(enabled: true)
expect(second_factor.method).to eq(UserSecondFactor.methods[:totp])
@@ -42,20 +42,20 @@ RSpec.describe SecondFactorManager do
end
describe "#totp_provisioning_uri" do
- it "should return the right uri" do
+ it "returns the TOTP provisioning URI" do
expect(user.user_second_factors.totps.first.totp_provisioning_uri).to eq(
"otpauth://totp/#{SiteSetting.title}:#{ERB::Util.url_encode(user.email)}?secret=#{user_second_factor_totp.data}&issuer=#{SiteSetting.title}",
)
end
- it "should handle a colon in the site title" do
+ it "removes a colon from the site title" do
SiteSetting.title = "Spaceballs: The Discourse"
expect(user.user_second_factors.totps.first.totp_provisioning_uri).to eq(
"otpauth://totp/Spaceballs%20The%20Discourse:#{ERB::Util.url_encode(user.email)}?secret=#{user_second_factor_totp.data}&issuer=Spaceballs%20The%20Discourse",
)
end
- it "should handle a two words before a colon in the title" do
+ it "preserves words before a colon in the site title" do
SiteSetting.title = "Our Spaceballs: The Discourse"
expect(user.user_second_factors.totps.first.totp_provisioning_uri).to eq(
"otpauth://totp/Our%20Spaceballs%20The%20Discourse:#{ERB::Util.url_encode(user.email)}?secret=#{user_second_factor_totp.data}&issuer=Our%20Spaceballs%20The%20Discourse",
@@ -64,7 +64,7 @@ RSpec.describe SecondFactorManager do
end
describe "#authenticate_totp" do
- it "should be able to authenticate a token" do
+ it "authenticates a token once" do
freeze_time do
expect(user.user_second_factors.totps.first.last_used).to eq(nil)
@@ -77,14 +77,14 @@ RSpec.describe SecondFactorManager do
end
describe "when token is blank" do
- it "should be false" do
+ it "rejects the token" do
expect(user.authenticate_totp(nil)).to eq(false)
expect(user.user_second_factors.totps.first.last_used).to eq(nil)
end
end
describe "when token is invalid" do
- it "should be false" do
+ it "rejects the token" do
expect(user.authenticate_totp("111111")).to eq(false)
expect(user.user_second_factors.totps.first.last_used).to eq(nil)
end
@@ -93,26 +93,26 @@ RSpec.describe SecondFactorManager do
describe "#totp_enabled?" do
describe "when user does not have a second factor record" do
- it "should return false" do
+ it "returns false" do
expect(another_user.totp_enabled?).to eq(false)
end
end
describe "when user's second factor record is disabled" do
- it "should return false" do
+ it "returns false" do
disable_totp
expect(user.totp_enabled?).to eq(false)
end
end
describe "when user's second factor record is enabled" do
- it "should return true" do
+ it "returns true" do
expect(user.totp_enabled?).to eq(true)
end
end
describe "when SSO is enabled" do
- it "should return false" do
+ it "returns false" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -122,7 +122,7 @@ RSpec.describe SecondFactorManager do
end
describe "when local login is disabled" do
- it "should return false" do
+ it "returns false" do
SiteSetting.enable_local_logins = false
expect(user.totp_enabled?).to eq(false)
@@ -565,7 +565,7 @@ RSpec.describe SecondFactorManager do
describe "backup codes" do
describe "#generate_backup_codes" do
- it "should generate and store 10 backup codes" do
+ it "generates and stores 10 backup codes" do
backup_codes = user.generate_backup_codes
expect(backup_codes.length).to be 10
@@ -578,7 +578,7 @@ RSpec.describe SecondFactorManager do
end
describe "#create_backup_codes" do
- it "should create 10 backup code records" do
+ it "creates 10 backup-code records" do
raw_codes = Array.new(10) { SecureRandom.hex(8) }
backup_codes = another_user.create_backup_codes(raw_codes)
@@ -587,7 +587,7 @@ RSpec.describe SecondFactorManager do
end
describe "#authenticate_backup_code" do
- it "should be able to authenticate a backup code" do
+ it "authenticates a backup code once" do
backup_code = "iAmValidBackupCode"
expect(user_backup.authenticate_backup_code(backup_code)).to eq(true)
@@ -595,13 +595,13 @@ RSpec.describe SecondFactorManager do
end
describe "when code is blank" do
- it "should be false" do
+ it "rejects the code" do
expect(user_backup.authenticate_backup_code(nil)).to eq(false)
end
end
describe "when code is invalid" do
- it "should be false" do
+ it "rejects the code" do
expect(user_backup.authenticate_backup_code("notValidBackupCode")).to eq(false)
end
end
@@ -609,26 +609,26 @@ RSpec.describe SecondFactorManager do
describe "#backup_codes_enabled?" do
describe "when user does not have a second factor backup enabled" do
- it "should return false" do
+ it "returns false" do
expect(another_user.backup_codes_enabled?).to eq(false)
end
end
describe "when user's second factor backup codes have been used" do
- it "should return false" do
+ it "returns false" do
user_backup.user_second_factors.backup_codes.update_all(enabled: false)
expect(user_backup.backup_codes_enabled?).to eq(false)
end
end
describe "when user's second factor code is available" do
- it "should return true" do
+ it "returns true" do
expect(user_backup.backup_codes_enabled?).to eq(true)
end
end
describe "when SSO is enabled" do
- it "should return false" do
+ it "returns false" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -638,7 +638,7 @@ RSpec.describe SecondFactorManager do
end
describe "when local login is disabled" do
- it "should return false" do
+ it "returns false" do
SiteSetting.enable_local_logins = false
expect(user_backup.backup_codes_enabled?).to eq(false)
diff --git a/spec/lib/cooked_post_processor_spec.rb b/spec/lib/cooked_post_processor_spec.rb
index 4ba03a9488b..9a1ee05efb9 100644
--- a/spec/lib/cooked_post_processor_spec.rb
+++ b/spec/lib/cooked_post_processor_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe CookedPostProcessor do
Oneboxer.invalidate(url)
end
- it "should respect SiteSetting.max_oneboxes_per_post" do
+ it "respects SiteSetting.max_oneboxes_per_post" do
SiteSetting.max_oneboxes_per_post = 2
SiteSetting.add_rel_nofollow_to_user_content = false
@@ -200,7 +200,7 @@ RSpec.describe CookedPostProcessor do
after { urls.each { |url| InlineOneboxer.invalidate(url) } }
- it "should convert the right links to inline oneboxes" do
+ it "converts eligible links to inline oneboxes" do
cpp.post_process
html = cpp.html
@@ -514,7 +514,7 @@ RSpec.describe CookedPostProcessor do
)
end
- it "should not add lightbox" do
+ it "does not add a lightbox" do
FastImage.expects(:size).returns([1750, 2000])
cpp.post_process
@@ -534,7 +534,7 @@ RSpec.describe CookedPostProcessor do
)
end
- it "should not add lightbox" do
+ it "does not add a lightbox" do
FastImage.expects(:size).returns([1750, 2000])
cpp.post_process
@@ -554,7 +554,7 @@ RSpec.describe CookedPostProcessor do
)
end
- it "should not add lightbox" do
+ it "does not add a lightbox" do
FastImage.expects(:size).returns([1750, 2000])
cpp.post_process
@@ -767,7 +767,7 @@ RSpec.describe CookedPostProcessor do
expect(cpp).to be_dirty
end
- it "should escape the filename" do
+ it "escapes the filename" do
upload.update!(original_filename: "><img src=x onerror=alert('haha')>.png")
cpp.post_process
@@ -1215,7 +1215,7 @@ RSpec.describe CookedPostProcessor do
expect(doc.css("img.animated").size).to eq(1)
end
- it "marks giphy images as animated" do
+ it "marks Tenor images as animated" do
post =
Fabricate(
:post,
@@ -2094,7 +2094,7 @@ RSpec.describe CookedPostProcessor do
test
MARKDOWN
- it "should not be marked as modified" do
+ it "leaves the quote unmarked as modified" do
cpp.post_process_quotes
expect(cpp.doc.css("aside.quote.quote-modified")).to be_blank
end
@@ -2108,7 +2108,7 @@ RSpec.describe CookedPostProcessor do
test
MARKDOWN
- it "should be marked as modified" do
+ it "marks the quote as modified" do
cpp.post_process_quotes
expect(cpp.doc.css("aside.quote.quote-modified")).to be_present
end
@@ -2122,7 +2122,7 @@ RSpec.describe CookedPostProcessor do
and this is a reply
MARKDOWN
- it "it should be marked as missing" do
+ it "marks the quoted post as missing" do
cpp.post_process_quotes
expect(cpp.doc.css("aside.quote.quote-post-not-found")).to be_present
end
@@ -2171,7 +2171,7 @@ RSpec.describe CookedPostProcessor do
before { SiteSetting.remove_full_quote = true }
- it "works" do
+ it "removes the full quote while preserving intervening hidden and action posts" do
hidden =
Fabricate(
:post,
diff --git a/spec/lib/db_helper_spec.rb b/spec/lib/db_helper_spec.rb
index f99956696c0..4b9da0f0a42 100644
--- a/spec/lib/db_helper_spec.rb
+++ b/spec/lib/db_helper_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe DbHelper do
let(:long_sidebar_url_name) { "a" * (sidebar_url_name_limit + 1) }
describe ".remap" do
- it "should remap columns properly" do
+ it "remaps the columns" do
post = Fabricate(:post, cooked: "this is a specialcode that I included")
post_attributes = post.reload.attributes
@@ -109,7 +109,7 @@ RSpec.describe DbHelper do
end
describe ".regexp_replace" do
- it "should remap columns correctly" do
+ it "remaps the columns" do
post = Fabricate(:post, raw: "this is a [img]test[/img] post")
DbHelper.regexp_replace("\\[img\\]test\\[/img\\]", "[img]something[/img]")
diff --git a/spec/lib/demon/sidekiq_spec.rb b/spec/lib/demon/sidekiq_spec.rb
index b7ca5c930e7..ee9172ce25a 100644
--- a/spec/lib/demon/sidekiq_spec.rb
+++ b/spec/lib/demon/sidekiq_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Demon::Sidekiq do
describe ".heartbeat_check" do
- it "should restart sidekiq daemons when daemon cannot be match to an entry in Sidekiq::ProcessSet or when heartbeat check has been missed" do
+ it "restarts Sidekiq daemons missing from Sidekiq::ProcessSet or with a missed heartbeat" do
running_sidekiq_daemon = described_class.new(1)
running_sidekiq_daemon.set_pid(1)
missing_sidekiq_daemon = described_class.new(2)
@@ -45,7 +45,7 @@ RSpec.describe Demon::Sidekiq do
end
describe ".rss_memory_check" do
- it "should restart sidekiq daemons when daemon's RSS memory exceeds the maximum allowed RSS memory" do
+ it "restarts Sidekiq daemons whose RSS memory exceeds the allowed maximum" do
stub_const(described_class, "SIDEKIQ_RSS_MEMORY_CHECK_INTERVAL_SECONDS", 0) do
# Set to a negative value to fake that the process has exceeded the maximum allowed RSS memory
stub_const(described_class, "DEFAULT_MAX_ALLOWED_SIDEKIQ_RSS_MEGABYTES", -1) do
diff --git a/spec/lib/discourse_hub_spec.rb b/spec/lib/discourse_hub_spec.rb
index ed97ed549e6..6a78f82a525 100644
--- a/spec/lib/discourse_hub_spec.rb
+++ b/spec/lib/discourse_hub_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe DiscourseHub do
describe ".discourse_version_check" do
- it "should return just return the json that the hub returns" do
+ it "returns the JSON received from the hub" do
hub_response = { "success" => "OK", "latest_version" => "0.8.1" }
stub_request(
@@ -18,7 +18,7 @@ RSpec.describe DiscourseHub do
end
describe ".discover_enrollment" do
- it "should trigger a POST request to hub" do
+ it "sends a POST request to the hub" do
stub_request(
:post,
(ENV["HUB_BASE_URL"] || "http://local.hub:3000/api") + "/discover/enroll",
@@ -34,7 +34,7 @@ RSpec.describe DiscourseHub do
end
describe ".discover_enrollment_payload" do
- it "should return the correct payload" do
+ it "returns the configured payload" do
payload = DiscourseHub.discover_enrollment_payload
expect(payload[:forum_url]).to eq(Discourse.base_url)
expect(payload[:forum_title]).to eq(SiteSetting.title)
@@ -44,7 +44,7 @@ RSpec.describe DiscourseHub do
describe ".version_check_payload" do
describe "when Discourse Hub has not fetched stats since past 7 days" do
- it "should include stats" do
+ it "includes site statistics" do
DiscourseHub.stats_fetched_at = 8.days.ago
json = JSON.parse(DiscourseHub.version_check_payload.to_json)
@@ -70,7 +70,7 @@ RSpec.describe DiscourseHub do
end
describe "when Discourse Hub has fetched stats in past 7 days" do
- it "should not include stats" do
+ it "omits site statistics" do
DiscourseHub.stats_fetched_at = 2.days.ago
json = JSON.parse(DiscourseHub.version_check_payload.to_json)
@@ -87,7 +87,7 @@ RSpec.describe DiscourseHub do
describe "when send_anonymize_stats is disabled" do
describe "when Discourse Hub has not fetched stats for the past year" do
- it "should not include stats" do
+ it "omits site statistics" do
DiscourseHub.stats_fetched_at = 1.year.ago
SiteSetting.share_anonymized_statistics = false
json = JSON.parse(DiscourseHub.version_check_payload.to_json)
@@ -112,7 +112,7 @@ RSpec.describe DiscourseHub do
after { Rails.logger.stop_broadcasting_to(fake_logger) }
- it "should log correctly on error" do
+ it "logs errors from the hub request" do
stub_request(:get, (ENV["HUB_BASE_URL"] || "http://local.hub:3000/api") + "/test").to_return(
status: 500,
body: "",
diff --git a/spec/lib/discourse_ip_info_spec.rb b/spec/lib/discourse_ip_info_spec.rb
index 43157313dfc..6e10a68d4e2 100644
--- a/spec/lib/discourse_ip_info_spec.rb
+++ b/spec/lib/discourse_ip_info_spec.rb
@@ -44,7 +44,7 @@ RSpec.describe DiscourseIpInfo do
describe ".mmdb_download" do
before { Discourse::Utils.stubs(:execute_command) }
- it "should download the MaxMind databases from MaxMind's download permalinks when `maxmind_license_key` and `maxmind_account_id` global setting has been set" do
+ it "downloads MaxMind databases from permalinks when the license key and account ID are set" do
global_setting :maxmind_license_key, "license_key"
global_setting :maxmind_account_id, "account_id"
@@ -68,7 +68,7 @@ RSpec.describe DiscourseIpInfo do
described_class.mmdb_download("GeoLite2-City")
end
- it "should download the MaxMind databases from MaxMind's undocumented download URL when `maxmind_license_key` global setting has been set but not `maxmind_account_id` for backwards compatibility reasons" do
+ it "uses the legacy MaxMind download URL when only the license key is set" do
global_setting :maxmind_license_key, "license_key"
stub_request(
@@ -79,7 +79,7 @@ RSpec.describe DiscourseIpInfo do
described_class.mmdb_download("GeoLite2-City")
end
- it "should download the MaxMind databases from the right URL when `maxmind_mirror_url` global setting has been configured" do
+ it "downloads MaxMind databases from the configured mirror" do
global_setting :maxmind_mirror_url, "https://b.www.example.com/mirror"
stub_request(:get, "https://b.www.example.com/mirror/GeoLite2-City.tar.gz").to_return(
@@ -90,7 +90,7 @@ RSpec.describe DiscourseIpInfo do
described_class.mmdb_download("GeoLite2-City")
end
- it "should download the MaxMind databases from the right URL when `maxmind_mirror_url` global setting has been configured and has a trailing slash" do
+ it "downloads MaxMind databases from a mirror URL with a trailing slash" do
global_setting :maxmind_mirror_url, "https://b.www.example.com/mirror/"
stub_request(:get, "https://b.www.example.com/mirror/GeoLite2-City.tar.gz").to_return(
@@ -101,7 +101,7 @@ RSpec.describe DiscourseIpInfo do
described_class.mmdb_download("GeoLite2-City")
end
- it "should not throw an error and instead log the exception when database file fails to download" do
+ it "logs database download exceptions without raising them" do
fake_logger = FakeLogger.new
Rails.logger.broadcast_to(fake_logger)
diff --git a/spec/lib/discourse_plugin_registry_spec.rb b/spec/lib/discourse_plugin_registry_spec.rb
index 18ade3fd201..f81c10da9de 100644
--- a/spec/lib/discourse_plugin_registry_spec.rb
+++ b/spec/lib/discourse_plugin_registry_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe DiscoursePluginRegistry do
end
describe ".define_filtered_register" do
- it "works" do
+ it "filters registered values by their enabled plugin" do
fresh_registry.define_filtered_register(:test_things)
expect(fresh_registry.test_things.length).to eq(0)
@@ -142,7 +142,7 @@ RSpec.describe DiscoursePluginRegistry do
expect(registry_instance.stylesheets[plugin_directory_name].include?("hello.css")).to eq(true)
end
- it "won't add the same file twice" do
+ it "does not add the same CSS file twice" do
expect { registry_instance.register_css("hello.css", plugin_directory_name) }.not_to change(
registry.stylesheets[plugin_directory_name],
:size,
@@ -157,7 +157,7 @@ RSpec.describe DiscoursePluginRegistry do
expect(registry_instance.javascripts.include?("hello.js")).to eq(true)
end
- it "won't add the same file twice" do
+ it "does not add the same JavaScript file twice" do
expect { registry_instance.register_js("hello.js") }.not_to change(
registry.javascripts,
:size,
@@ -189,7 +189,7 @@ RSpec.describe DiscoursePluginRegistry do
after { registry.reset! }
- it "should register the file once" do
+ it "registers the service worker file once" do
2.times { registry.register_service_worker("hello.js") }
expect(registry.service_workers.size).to eq(1)
diff --git a/spec/lib/discourse_redis_spec.rb b/spec/lib/discourse_redis_spec.rb
index c00cb95381e..62a607a7abd 100644
--- a/spec/lib/discourse_redis_spec.rb
+++ b/spec/lib/discourse_redis_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe DiscourseRedis do
describe "pipelined / multi" do
let(:redis) { DiscourseRedis.new }
- it "should support multi commands" do
+ it "supports multi commands" do
val =
redis.multi do |transaction|
transaction.set "foo", "bar"
@@ -32,7 +32,7 @@ RSpec.describe DiscourseRedis do
expect(val).to eq(%w[OK OK foo])
end
- it "should support pipelined commands" do
+ it "supports pipelined commands" do
set, incr = nil
val =
redis.pipelined do |pipeline|
@@ -52,7 +52,7 @@ RSpec.describe DiscourseRedis do
expect(redis.get("baz")).to eq("1")
end
- it "should noop pipelined commands against a readonly redis" do
+ it "ignores pipelined commands against read-only Redis" do
redis.without_namespace.expects(:pipelined).raises(Redis::ReadOnlyError)
set, incr = nil
@@ -68,7 +68,7 @@ RSpec.describe DiscourseRedis do
expect(redis.get("baz")).to eq(nil)
end
- it "should noop multi commands against a readonly redis" do
+ it "ignores multi commands against read-only Redis" do
redis.without_namespace.expects(:multi).raises(Redis::ReadOnlyError)
val =
@@ -87,7 +87,7 @@ RSpec.describe DiscourseRedis do
describe "when namespace is enabled" do
let(:redis) { DiscourseRedis.new }
- it "should append namespace to the keys" do
+ it "adds the namespace to keys" do
raw_redis.set("default:key", 1)
raw_redis.set("test:key2", 1)
raw_redis.set("default:key3", 1)
@@ -112,7 +112,7 @@ RSpec.describe DiscourseRedis do
end
describe "#sadd?" do
- it "should send the right command with the right key prefix to redis" do
+ it "sends the command with the namespaced key to Redis" do
redis = DiscourseRedis.new
redis.without_namespace.expects(:sadd?).with("default:testset", "1", anything)
@@ -122,7 +122,7 @@ RSpec.describe DiscourseRedis do
end
describe "#srem?" do
- it "should send the right command with the right key prefix to redis" do
+ it "sends the command with the namespaced key to Redis" do
redis = DiscourseRedis.new
redis.without_namespace.expects(:srem?).with("default:testset", "1", anything)
@@ -134,7 +134,7 @@ RSpec.describe DiscourseRedis do
describe "when namespace is disabled" do
let(:redis) { DiscourseRedis.new(nil, namespace: false) }
- it "should not append any namespace to the keys" do
+ it "does not add a namespace to keys" do
raw_redis.set("default:key", 1)
raw_redis.set("test:key2", 1)
@@ -150,7 +150,7 @@ RSpec.describe DiscourseRedis do
expect(redis.mget("key1", "key2")).to eq([nil, nil])
end
- it "should noop a readonly redis" do
+ it "ignores commands against read-only Redis" do
expect(Discourse.recently_readonly?).to eq(false)
redis.without_namespace.expects(:set).raises(Redis::ReadOnlyError)
@@ -194,7 +194,7 @@ RSpec.describe DiscourseRedis do
end
describe DiscourseRedis::EvalHelper do
- it "works" do
+ it "evaluates the Lua script" do
helper = DiscourseRedis::EvalHelper.new <<~LUA
return 'hello world'
LUA
diff --git a/spec/lib/discourse_spec.rb b/spec/lib/discourse_spec.rb
index 202f9ec00aa..d15be6b1935 100644
--- a/spec/lib/discourse_spec.rb
+++ b/spec/lib/discourse_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Discourse do
describe "running_in_rack" do
after { ENV.delete("DISCOURSE_RUNNING_IN_RACK") }
- it "should not be running in rack" do
+ it "is not running in Rack" do
expect(Discourse.running_in_rack?).to eq(false)
ENV["DISCOURSE_RUNNING_IN_RACK"] = "1"
expect(Discourse.running_in_rack?).to eq(true)
@@ -477,13 +477,13 @@ RSpec.describe Discourse do
after { Discourse.reset_job_exception_stats! }
- it "should not fail on incorrectly shaped hash" do
+ it "handles an incorrectly shaped hash" do
expect do
Discourse.handle_job_exception(FakeTestError.new, { job: "test" })
end.to raise_error(FakeTestError)
end
- it "should collect job exception stats" do
+ it "collects job exception statistics" do
# see MiniScheduler Manager which reports it like this
# https://github.com/discourse/mini_scheduler/blob/2b2c1c56b6e76f51108c2a305775469e24cf2b65/lib/mini_scheduler/manager.rb#L95
exception_context = {
@@ -517,7 +517,7 @@ RSpec.describe Discourse do
end
end
- it "should not fail when called" do
+ it "runs without an error" do
exception = StandardError.new
expect do Discourse.handle_job_exception(exception, nil, nil) end.to raise_error(
diff --git a/spec/lib/discourse_tagging_spec.rb b/spec/lib/discourse_tagging_spec.rb
index add10620f26..e8577b79332 100644
--- a/spec/lib/discourse_tagging_spec.rb
+++ b/spec/lib/discourse_tagging_spec.rb
@@ -597,17 +597,17 @@ RSpec.describe DiscourseTagging do
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name])
end
- it "should return staff tags to admin" do
+ it "returns staff tags to admins" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(admin)).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3, hidden_tag]))
end
- it "should return staff tags to moderator" do
+ it "returns staff tags to moderators" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(moderator), for_input: true).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3, hidden_tag]))
end
- it "should not return hidden tag to non-staff" do
+ it "hides staff tags from non-staff users" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(user)).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3]))
end
@@ -619,17 +619,17 @@ RSpec.describe DiscourseTagging do
Fabricate(:tag_group, permissions: { "admins" => 1 }, tag_names: [admin_only_tag.name])
end
- it "should return admin-only tags to admin" do
+ it "returns admin-only tags to admins" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(admin), for_input: true).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3, admin_only_tag]))
end
- it "should not return admin-only tags to moderator" do
+ it "hides admin-only tags from moderators" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(moderator), for_input: true).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3]))
end
- it "should not return admin-only tags to regular user" do
+ it "hides admin-only tags from regular users" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(user), for_input: true).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3]))
end
@@ -644,12 +644,12 @@ RSpec.describe DiscourseTagging do
before { group.add(user) }
- it "should return all tags to member of group" do
+ it "returns all tags to group members" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(user)).to_a
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3, hidden_tag]))
end
- it "should allow a tag group to have multiple group permissions" do
+ it "allows a tag group to have multiple group permissions" do
group2 = Fabricate(:group, name: "another-group")
user2 = Fabricate(:user)
user3 = Fabricate(:user)
@@ -666,12 +666,12 @@ RSpec.describe DiscourseTagging do
expect(sorted_tag_names(tags)).to eq(sorted_tag_names([tag1, tag2, tag3]))
end
- it "should not hide group tags to member of group" do
+ it "shows group tags to group members" do
tags = DiscourseTagging.hidden_tag_names(Guardian.new(user)).to_a
expect(sorted_tag_names(tags)).to eq([])
end
- it "should hide group tags to non-member of group" do
+ it "hides group tags from non-members" do
other_user = Fabricate(:user)
tags = DiscourseTagging.hidden_tag_names(Guardian.new(other_user)).to_a
expect(sorted_tag_names(tags)).to eq([hidden_tag.name])
@@ -1298,7 +1298,7 @@ RSpec.describe DiscourseTagging do
expect(topic.errors[:base]).to be_empty
end
- it "will return error if user is not in correct group" do
+ it "returns an error if the user is not in the required group" do
user2 = Fabricate(:user)
valid = DiscourseTagging.tag_topic_by_names(topic, Guardian.new(user2), ["alpha"])
expect(valid).to eq(false)
@@ -2106,7 +2106,7 @@ RSpec.describe DiscourseTagging do
# this test is to make sure that the parent tag is the only one returned when the child tag is also in a tag group
# allowed in the category
- it "Will only return the parent tag" do
+ it "returns only the parent tag" do
tags =
DiscourseTagging.filter_allowed_tags(
Guardian.new(user),
diff --git a/spec/lib/distributed_mutex_spec.rb b/spec/lib/distributed_mutex_spec.rb
index b1ba62cf505..1946acac8be 100644
--- a/spec/lib/distributed_mutex_spec.rb
+++ b/spec/lib/distributed_mutex_spec.rb
@@ -80,7 +80,7 @@ RSpec.describe DistributedMutex do
end
describe "executions" do
- it "should not allow critical sections to overlap" do
+ it "prevents critical sections from overlapping" do
connections = 3.times.map { DiscourseRedis.new }
scenario =
diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rb
index 9af50d188ee..bd257f48415 100644
--- a/spec/lib/email/receiver_spec.rb
+++ b/spec/lib/email/receiver_spec.rb
@@ -786,7 +786,7 @@ RSpec.describe Email::Receiver do
)
end
- it "works" do
+ it "publishes the topic_created event with incoming addresses" do
handler_calls = 0
handler =
proc do |topic|
@@ -1093,7 +1093,7 @@ RSpec.describe Email::Receiver do
SiteSetting.alternative_reply_by_email_addresses = ""
end
- it "it matches nothing if there is not reply_by_email_address" do
+ it "matches nothing when reply_by_email_address is blank" do
expect(Email::Receiver.reply_by_email_address_regex).to eq(/$a/)
end
@@ -1422,12 +1422,12 @@ RSpec.describe Email::Receiver do
before { SiteSetting.block_auto_generated_emails = true }
- it "should allow creating topic even when email is autogenerated" do
+ it "allows creating a topic from an autogenerated email" do
expect { process(:mailinglist) }.to change { Topic.count }
expect(IncomingEmail.last.is_auto_generated).to eq(false)
end
- it "should allow replying without reply key" do
+ it "allows replying without a reply key" do
process(:mailinglist)
topic = Topic.last
@@ -1467,12 +1467,12 @@ RSpec.describe Email::Receiver do
)
end
- it "should skip validations for staged users" do
+ it "skips validations for staged users" do
Fabricate(:user, email: "[email protected]", staged: true)
expect { process(:mailinglist_short_message) }.to change { Topic.count }
end
- it "should skip validations for regular users" do
+ it "skips validations for regular users" do
Fabricate(:user, email: "[email protected]", refresh_auto_groups: true)
expect { process(:mailinglist_short_message) }.to change { Topic.count }
end
@@ -1486,11 +1486,11 @@ RSpec.describe Email::Receiver do
Fabricate(:user, email: "[email protected]", refresh_auto_groups: true)
end
- it "should allow creating topic within read-only category" do
+ it "allows creating a topic in the read-only category" do
expect { process(:mailinglist) }.to change { Topic.count }
end
- it "should allow replying within read-only category" do
+ it "allows replying in the read-only category" do
process(:mailinglist)
topic = Topic.last
@@ -2006,7 +2006,7 @@ RSpec.describe Email::Receiver do
)
end
- it "works" do
+ it "creates the reply" do
expect { process(:reply_user_matching) }.to change { topic.posts.count }
end
@@ -2210,7 +2210,7 @@ RSpec.describe Email::Receiver do
)
end
- it "removes the translated 'Previous Replies' marker" do
+ it "removes the translated 'Previous Replies' marker from previous-replies email" do
expect { process(:previous_replies_de) }.to change { topic.posts.count }
expect(topic.posts.last.raw).to eq(
"This will not include the previous discussion that is present in this email.",
@@ -2224,7 +2224,7 @@ RSpec.describe Email::Receiver do
)
end
- it "removes the translated 'Previous Replies' marker" do
+ it "removes the translated 'Previous Replies' marker from reply-above email" do
expect { process(:reply_above_de) }.to change { topic.posts.count }
expect(topic.posts.last.raw).to eq(
"This will not include the previous discussion that is present in this email.",
diff --git a/spec/lib/email/sender_spec.rb b/spec/lib/email/sender_spec.rb
index bcde8ff146b..ca349c240e5 100644
--- a/spec/lib/email/sender_spec.rb
+++ b/spec/lib/email/sender_spec.rb
@@ -146,7 +146,7 @@ RSpec.describe Email::Sender do
context "when no plus addressing" do
before { SiteSetting.reply_by_email_address = "%{reply_key}@test.com" }
- it "should not set the return_path" do
+ it "leaves return_path unset" do
email_sender.send
expect(message.header[:return_path].to_s).to eq("")
end
@@ -155,7 +155,7 @@ RSpec.describe Email::Sender do
context "with plus addressing" do
before { SiteSetting.reply_by_email_address = "replies+%{reply_key}@test.com" }
- it "should set the return_path" do
+ it "sets return_path" do
email_sender.send
expect(message.header[:return_path].to_s).to eq(
"replies+verp-#{EmailLog.last.bounce_key}@test.com",
@@ -173,7 +173,7 @@ RSpec.describe Email::Sender do
message.header["X-Discourse-Topic-Id"] = topic.id
end
- it "should add the right header" do
+ it "adds the List-ID header" do
email_sender.send
expect(message.header["List-ID"]).to be_present
@@ -182,7 +182,7 @@ RSpec.describe Email::Sender do
end
context "when topic id is not present" do
- it "should add the right header" do
+ it "adds the Message-ID header" do
email_sender.send
expect(message.header["Message-ID"]).to be_present
@@ -238,14 +238,14 @@ RSpec.describe Email::Sender do
message.header["X-Discourse-Topic-Id"] = topic.id
end
- it "should add the right header" do
+ it "adds the Precedence header" do
email_sender.send
expect(message.header["Precedence"]).to be_present
end
end
describe "removes custom Discourse headers from digest/registration/other mails" do
- it "should remove the right headers" do
+ it "removes custom Discourse headers" do
email_sender.send
expect(message.header["X-Discourse-Topic-Id"]).not_to be_present
expect(message.header["X-Discourse-Topic-Ids"]).not_to be_present
@@ -398,7 +398,7 @@ RSpec.describe Email::Sender do
message.header["X-MC-Metadata"] = { foo: "bar" }.to_json
end
- it "should set the right header" do
+ it "adds the message ID to the Mandrill metadata" do
email_sender.send
expect(message.header["X-MC-Metadata"].to_s).to match(message.message_id)
end
@@ -410,7 +410,7 @@ RSpec.describe Email::Sender do
message.header["X-MSYS-API"] = { foo: "bar" }.to_json
end
- it "should set the right header" do
+ it "adds the message ID to the SparkPost metadata" do
email_sender.send
expect(message.header["X-MSYS-API"].to_s).to match(message.message_id)
end
@@ -419,7 +419,7 @@ RSpec.describe Email::Sender do
context "with email logs" do
let(:email_log) { EmailLog.last }
- it "should create the right log" do
+ it "creates an email log without a reply key" do
expect do email_sender.send end.to_not change { PostReplyKey.count }
expect(email_log).to be_present
@@ -489,7 +489,7 @@ RSpec.describe Email::Sender do
let(:email_log) { EmailLog.last }
- it "should create the right log" do
+ it "records the post and topic in the email log" do
email_sender.send
expect(email_log.post_id).to eq(post.id)
expect(email_log.topic_id).to eq(topic.id)
@@ -498,7 +498,7 @@ RSpec.describe Email::Sender do
end
context "with email parts" do
- it "should contain the right message" do
+ it "builds matching plain-text and HTML email parts" do
email_sender.send
expect(message).to be_multipart
@@ -880,7 +880,7 @@ RSpec.describe Email::Sender do
end
context "with a deleted post" do
- it "should skip sending the email" do
+ it "skips the email and records the deleted-post reason" do
post = Fabricate(:post, deleted_at: 1.day.ago)
message = Mail::Message.new to: "[email protected]", body: "some content"
@@ -897,7 +897,7 @@ RSpec.describe Email::Sender do
end
context "with a deleted topic" do
- it "should skip sending the email" do
+ it "skips the email and records the deleted-topic reason" do
post = Fabricate(:post, topic: Fabricate(:topic, deleted_at: 1.day.ago))
message = Mail::Message.new to: "[email protected]", body: "some content"
@@ -928,11 +928,11 @@ RSpec.describe Email::Sender do
@email_log = EmailLog.last
end
- it "should have the current user_id" do
+ it "records the current user ID" do
expect(@email_log.user_id).to eq(user.id)
end
- it "should have the smtp_transaction_response message" do
+ it "records the SMTP transaction response" do
expect(@email_log.smtp_transaction_response).to eq(mock_smtp_transaction_response)
end
@@ -945,7 +945,7 @@ RSpec.describe Email::Sender do
end
describe "when allow reply by email header is not present" do
- it "should not create a post reply key" do
+ it "does not create a post reply key" do
expect { email_sender.send }.to_not change { PostReplyKey.count }
end
end
@@ -955,7 +955,7 @@ RSpec.describe Email::Sender do
before { message.header[header] = "test-%{reply_key}@test.com" }
- it "should create a post reply key" do
+ it "creates a post reply key" do
expect { email_sender.send }.to change { PostReplyKey.count }.by(1)
post_reply_key = PostReplyKey.last
@@ -969,7 +969,7 @@ RSpec.describe Email::Sender do
expect { email_sender.send }.not_to change { PostReplyKey.count }
end
- it "should find existing key" do
+ it "reuses the existing post reply key" do
existing_post_reply_key = PostReplyKey.create(post_id: post.id, user_id: user.id)
expect { email_sender.send }.not_to change { PostReplyKey.count }
post_reply_key = PostReplyKey.last
diff --git a/spec/lib/email/styles_spec.rb b/spec/lib/email/styles_spec.rb
index c60839cbc0f..3e99b2b0fae 100644
--- a/spec/lib/email/styles_spec.rb
+++ b/spec/lib/email/styles_spec.rb
@@ -79,14 +79,14 @@ RSpec.describe Email::Styles do
expect(frag.at("a")["href"]).to eq(iframe_url)
end
- it "won't allow non URLs in iframe src, strips them with no link" do
+ it "strips non-URL iframe sources without adding a link" do
iframe_url = "alert('xss hole')"
frag = html_fragment("<iframe src=\"#{iframe_url}\"></iframe>")
expect(frag.at("iframe")).to be_blank
expect(frag.at("a")).to be_blank
end
- it "won't allow empty iframe src, strips them with no link" do
+ it "strips empty iframe sources without adding a link" do
frag = html_fragment("<iframe src=''></iframe>")
expect(frag.at("iframe")).to be_blank
expect(frag.at("a")).to be_blank
diff --git a/spec/lib/email_cook_spec.rb b/spec/lib/email_cook_spec.rb
index 3d1f025d87a..3eec9f806e4 100644
--- a/spec/lib/email_cook_spec.rb
+++ b/spec/lib/email_cook_spec.rb
@@ -135,7 +135,7 @@ RSpec.describe EmailCook do
)
end
- it "it works and does not interpret Markdown in plaintext and elided" do
+ it "leaves Markdown uninterpreted in plain-text and elided sections" do
long = <<~EMAIL
[plaintext]
*Lorem ipsum* dolor sit amet, consectetur adipiscing elit.
diff --git a/spec/lib/email_updater_spec.rb b/spec/lib/email_updater_spec.rb
index 2f1cc0218cf..f806891df47 100644
--- a/spec/lib/email_updater_spec.rb
+++ b/spec/lib/email_updater_spec.rb
@@ -270,7 +270,7 @@ RSpec.describe EmailUpdater do
end
context "when it was deleted before" do
- it "works" do
+ it "restores the deleted email after confirmation" do
expect_enqueued_with(
job: :critical_user_email,
args: {
diff --git a/spec/lib/excerpt_parser_spec.rb b/spec/lib/excerpt_parser_spec.rb
index ff4d62fba58..ea7833ad08d 100644
--- a/spec/lib/excerpt_parser_spec.rb
+++ b/spec/lib/excerpt_parser_spec.rb
@@ -139,7 +139,7 @@ RSpec.describe ExcerptParser do
end
describe "keep_quotes parameter" do
- it "should keep the quoted content in html" do
+ it "keeps quoted content in the HTML" do
html = <<~HTML.strip
<aside class="quote">
<blockquote>
diff --git a/spec/lib/file_helper_spec.rb b/spec/lib/file_helper_spec.rb
index b35d6e0816a..52cd446535c 100644
--- a/spec/lib/file_helper_spec.rb
+++ b/spec/lib/file_helper_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe FileHelper do
end
describe "when max_file_size is exceeded" do
- it "should return nil" do
+ it "returns nil" do
tmpfile =
FileHelper.download(
"//eviltrout.com/trout.png",
@@ -137,7 +137,7 @@ RSpec.describe FileHelper do
describe "when url is a jpeg" do
let(:url) { "https://eviltrout.com/trout.jpg" }
- it "should prioritize the content type returned by the response" do
+ it "prefers the response content type" do
stub_request(:get, url).to_return(body: png, headers: { "content-type": "image/png" })
tmpfile = FileHelper.download(url, max_file_size: 10_000, tmp_file_name: "trouttmp")
diff --git a/spec/lib/file_store/base_store_spec.rb b/spec/lib/file_store/base_store_spec.rb
index 3390b2c8c8a..f9f8df2a3b6 100644
--- a/spec/lib/file_store/base_store_spec.rb
+++ b/spec/lib/file_store/base_store_spec.rb
@@ -14,19 +14,19 @@ RSpec.describe FileStore::BaseStore do
context "with empty URL" do
before { upload.update!(url: "") }
- it "should return the right path" do
+ it "builds the original upload path from its SHA1" do
expect_correct_path("original/2X/4/4170ac2a2782a1516fe9e13d7322ae482c1bd594.png")
end
describe "when Upload#extension has not been set" do
- it "should return the right path" do
+ it "infers the extension when building the upload path" do
upload.update!(extension: nil)
expect_correct_path("original/2X/4/4170ac2a2782a1516fe9e13d7322ae482c1bd594.png")
end
end
describe "when id is negative" do
- it "should return the right depth" do
+ it "uses a single directory level" do
upload.update!(id: -999)
expect_correct_path("original/1X/4170ac2a2782a1516fe9e13d7322ae482c1bd594.png")
end
@@ -110,14 +110,14 @@ RSpec.describe FileStore::BaseStore do
let!(:optimized_path) { "optimized/1X/#{upload.sha1}_1_100x200.png" }
context "with empty URL" do
- it "should return the right path" do
+ it "builds the optimized image path" do
optimized = Fabricate.build(:optimized_image, upload: upload, version: 1)
expect(FileStore::BaseStore.new.get_path_for_optimized_image(optimized)).to eq(
optimized_path,
)
end
- it "should return the right path for `nil` version" do
+ it "defaults a nil version to version 1 in the image path" do
optimized = Fabricate.build(:optimized_image, upload: upload, version: nil)
expect(FileStore::BaseStore.new.get_path_for_optimized_image(optimized)).to eq(
optimized_path,
@@ -185,7 +185,7 @@ RSpec.describe FileStore::BaseStore do
let(:upload_s3) { Fabricate(:upload_s3) }
let(:store) { FileStore::BaseStore.new }
- it "should return consistent encodings for fresh and cached downloads" do
+ it "returns consistent encodings for fresh and cached downloads" do
first_encoding = File.read(store.download(upload_s3)).encoding
second_encoding = File.read(store.download(upload_s3)).encoding
@@ -193,14 +193,14 @@ RSpec.describe FileStore::BaseStore do
expect(second_encoding).to eq(Encoding::UTF_8)
end
- it "should return a file path" do
+ it "returns a file path" do
path = store.download(upload_s3)
expect(path).to be_a(String)
expect(File.exist?(path)).to eq(true)
end
- it "should return the path when s3 cdn enabled" do
+ it "returns the path when the S3 CDN is enabled" do
SiteSetting.s3_cdn_url = "https://cdn.s3.#{SiteSetting.s3_region}.amazonaws.com"
stub_request(:get, Discourse.store.cdn_url(upload_s3.url)).to_return(
status: 200,
@@ -213,7 +213,7 @@ RSpec.describe FileStore::BaseStore do
expect(File.exist?(path)).to eq(true)
end
- it "should return the path when secure uploads are enabled" do
+ it "returns the path when secure uploads are enabled" do
SiteSetting.login_required = true
SiteSetting.secure_uploads = true
diff --git a/spec/lib/file_store/s3_store_spec.rb b/spec/lib/file_store/s3_store_spec.rb
index cfd01ad93f4..1c44cafc49e 100644
--- a/spec/lib/file_store/s3_store_spec.rb
+++ b/spec/lib/file_store/s3_store_spec.rb
@@ -1069,7 +1069,7 @@ RSpec.describe FileStore::S3Store do
describe "#create_multipart" do
before { store.s3_helper.stub_client_responses! }
- it "should create a multipart upload with the ACL parameter set to private canned ACL when `s3_use_acls` site setting is enabled" do
+ it "creates a multipart upload with a private canned ACL when `s3_use_acls` is enabled" do
store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
create_multipart_request =
@@ -1082,7 +1082,7 @@ RSpec.describe FileStore::S3Store do
)
end
- it "should create a multipart upload with the ACL parameter set to nil when `s3_use_acls` site setting is disabled" do
+ it "creates a multipart upload without an ACL when `s3_use_acls` is disabled" do
SiteSetting.s3_use_acls = false
store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
@@ -1094,7 +1094,7 @@ RSpec.describe FileStore::S3Store do
expect(create_multipart_request[:context].params[:acl]).to eq(nil)
end
- it "should create a multipart upload with the tagging parameter set to visibility tags when `s3_enable_access_control_tags` site setting is enabled" do
+ it "creates a multipart upload with visibility tags when access-control tags are enabled" do
SiteSetting.s3_enable_access_control_tags = true
store.create_multipart("test_file.tar.gz", "application/gzip", metadata: {})
diff --git a/spec/lib/filter_best_posts_spec.rb b/spec/lib/filter_best_posts_spec.rb
index 4469d2ab6fc..ba18e6668ee 100644
--- a/spec/lib/filter_best_posts_spec.rb
+++ b/spec/lib/filter_best_posts_spec.rb
@@ -29,13 +29,13 @@ RSpec.describe FilterBestPosts do
describe "processing options" do
before { @filtered_posts = TopicView.new(topic.id, nil, best: 99).filtered_posts }
- it "should not get the status post" do
+ it "excludes the status post" do
best = FilterBestPosts.new(topic, @filtered_posts, 99)
expect(best.filtered_posts.size).to eq(3)
expect(best.posts.map(&:id)).to match_array([p2.id, p3.id])
end
- it "should get no results for trust level too low" do
+ it "returns no results below the minimum trust level" do
best =
FilterBestPosts.new(
topic,
@@ -46,17 +46,17 @@ RSpec.describe FilterBestPosts do
expect(best.posts.count).to eq(0)
end
- it "should filter out the posts with a score that is too low" do
+ it "excludes posts below the minimum score" do
best = FilterBestPosts.new(topic, @filtered_posts, 99, min_score: 99)
expect(best.posts.count).to eq(0)
end
- it "should filter out everything if min replies not met" do
+ it "returns no posts below the minimum reply count" do
best = FilterBestPosts.new(topic, @filtered_posts, 99, min_replies: 99)
expect(best.posts.count).to eq(0)
end
- it "should punch through posts if the score is high enough" do
+ it "includes posts whose score exceeds the threshold" do
p2.update_column(:score, 100)
best =
@@ -70,7 +70,7 @@ RSpec.describe FilterBestPosts do
expect(best.posts.count).to eq(1)
end
- it "should bypass trust level score" do
+ it "bypasses the trust-level score" do
best =
FilterBestPosts.new(
topic,
@@ -82,7 +82,7 @@ RSpec.describe FilterBestPosts do
expect(best.posts.count).to eq(0)
end
- it "should return none if restricted to posts a moderator liked" do
+ it "returns none when no posts were liked by a moderator" do
best = FilterBestPosts.new(topic, @filtered_posts, 99, only_moderator_liked: true)
expect(best.posts.count).to eq(0)
end
@@ -93,7 +93,7 @@ RSpec.describe FilterBestPosts do
expect(best.posts.count).to eq(0)
end
- it "should find the post liked by the moderator" do
+ it "returns a post liked by a moderator" do
PostActionCreator.like(moderator, p2)
best = FilterBestPosts.new(topic, @filtered_posts, 99, only_moderator_liked: true)
expect(best.posts.count).to eq(1)
diff --git a/spec/lib/final_destination_spec.rb b/spec/lib/final_destination_spec.rb
index 104aca4229e..41c259972d2 100644
--- a/spec/lib/final_destination_spec.rb
+++ b/spec/lib/final_destination_spec.rb
@@ -356,7 +356,7 @@ RSpec.describe FinalDestination do
end
context "when forcing GET" do
- it "will do a GET when forced" do
+ it "uses GET when forced" do
url = "https://force.get.com/posts?page=4"
get_stub = fd_stub_request(:get, url)
head_stub = fd_stub_request(:head, url)
@@ -368,7 +368,7 @@ RSpec.describe FinalDestination do
expect(head_stub).to_not have_been_requested
end
- it "will do a HEAD if not forced" do
+ it "uses HEAD when GET is not forced" do
url = "https://eviltrout.com/posts?page=2"
get_stub = fd_stub_request(:get, url)
head_stub = fd_stub_request(:head, url)
@@ -380,7 +380,7 @@ RSpec.describe FinalDestination do
expect(head_stub).to have_been_requested
end
- it "will do a GET when forced on a wildcard subdomain" do
+ it "uses GET for a matching wildcard subdomain" do
url = "https://any-subdomain.ihaveawildcard.com/some/other/content"
get_stub = fd_stub_request(:get, url)
head_stub = fd_stub_request(:head, url)
@@ -392,7 +392,7 @@ RSpec.describe FinalDestination do
expect(head_stub).to_not have_been_requested
end
- it "will do a HEAD if on a subdomain of a forced get domain without a wildcard" do
+ it "uses HEAD for subdomains when the forced GET domain has no wildcard" do
url = "https://particularly.eviltrout.com/has/a/secret/plan"
get_stub = fd_stub_request(:get, url)
head_stub = fd_stub_request(:head, url)
@@ -420,7 +420,7 @@ RSpec.describe FinalDestination do
context "when the status code is 405" do
before { fd_stub_request(:head, "https://eviltrout.com").to_return(status: 405) }
- it "will try a GET" do
+ it "tries a GET" do
final = FinalDestination.new("https://eviltrout.com", opts)
expect(final.resolve.to_s).to eq("https://discourse.org")
expect(final.status).to eq(:resolved)
@@ -431,7 +431,7 @@ RSpec.describe FinalDestination do
context "when the status code is 501" do
before { fd_stub_request(:head, "https://eviltrout.com").to_return(status: 501) }
- it "will try a GET" do
+ it "tries a GET" do
final = FinalDestination.new("https://eviltrout.com", opts)
expect(final.resolve.to_s).to eq("https://discourse.org")
expect(final.status).to eq(:resolved)
@@ -468,7 +468,7 @@ RSpec.describe FinalDestination do
end
end
- it "should use the correct format for cookies when there is only one cookie" do
+ it "formats a single cookie correctly" do
fd_stub_request(:head, "https://eviltrout.com").to_return(
status: 302,
headers: {
@@ -490,7 +490,7 @@ RSpec.describe FinalDestination do
expect(final.cookie).to eq("foo=219ffwef9w0f")
end
- it "should use the correct format for cookies when there are multiple cookies" do
+ it "formats multiple cookies correctly" do
fd_stub_request(:head, "https://eviltrout.com").to_return(
status: 302,
headers: {
@@ -728,7 +728,7 @@ RSpec.describe FinalDestination do
end
describe "https cache" do
- it "will cache https lookups" do
+ it "caches HTTPS lookups" do
FinalDestination.clear_https_cache!("wikipedia.com")
fd_stub_request(:head, "http://wikipedia.com/image.png").to_return(
diff --git a/spec/lib/flag_settings_spec.rb b/spec/lib/flag_settings_spec.rb
index deba079daed..4ef973c0e89 100644
--- a/spec/lib/flag_settings_spec.rb
+++ b/spec/lib/flag_settings_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe FlagSettings do
let(:settings) { FlagSettings.new }
describe "add" do
- it "will add a type" do
+ it "adds a type" do
settings.add(3, :off_topic)
expect(settings.flag_types).to include(:off_topic)
expect(settings.is_flag?(:off_topic)).to eq(true)
@@ -17,26 +17,26 @@ RSpec.describe FlagSettings do
expect(settings.auto_action_types).to be_empty
end
- it "will add a topic type" do
+ it "adds a topic type" do
settings.add(4, :inappropriate, topic_type: true)
expect(settings.flag_types).to include(:inappropriate)
expect(settings.topic_flag_types).to include(:inappropriate)
expect(settings.without_additional_message_types).to include(:inappropriate)
end
- it "will add a notify type" do
+ it "adds a notify type" do
settings.add(3, :off_topic, notify_type: true)
expect(settings.flag_types).to include(:off_topic)
expect(settings.notify_types).to include(:off_topic)
end
- it "will add an auto action type" do
+ it "adds an auto action type" do
settings.add(7, :notify_moderators, auto_action_type: true)
expect(settings.flag_types).to include(:notify_moderators)
expect(settings.auto_action_types).to include(:notify_moderators)
end
- it "will add a type which requires message" do
+ it "adds a type requiring a message" do
settings.add(7, :notify_user, require_message: true)
expect(settings.flag_types).to include(:notify_user)
expect(settings.additional_message_types).to include(:notify_user)
diff --git a/spec/lib/freedom_patches/fast_image_spec.rb b/spec/lib/freedom_patches/fast_image_spec.rb
index 89934252daa..919a8ba67ea 100644
--- a/spec/lib/freedom_patches/fast_image_spec.rb
+++ b/spec/lib/freedom_patches/fast_image_spec.rb
@@ -11,13 +11,13 @@ RSpec.describe FastImage do
FinalDestination::SSRFDetector.disallow_ip_lookups_in_test!
end
- it "should filter endpoint hostname through our SSRF detector and return null object" do
+ it "filters the endpoint hostname through the SSRF detector and returns a null object" do
stub_ip_lookup("example.com", %W[0.0.0.0])
expect(described_class.type("http://example.com")).to eq(nil)
end
- it "should send the right request if endpoint hostname resolves to a public ip address" do
+ it "sends the request when the endpoint resolves to a public IP address" do
stub_ip_lookup("example.com", %W[52.125.123.12])
success = Class.new(StandardError)
diff --git a/spec/lib/freedom_patches/translate_accelerator_spec.rb b/spec/lib/freedom_patches/translate_accelerator_spec.rb
index 6ab8d4d5b4e..2d44f4ae4a2 100644
--- a/spec/lib/freedom_patches/translate_accelerator_spec.rb
+++ b/spec/lib/freedom_patches/translate_accelerator_spec.rb
@@ -68,7 +68,7 @@ RSpec.describe "translate accelerator" do
end
describe ".overrides_by_locale" do
- it "should cache overrides for each locale" do
+ it "caches overrides for each locale" do
override_translation("en", "got", "summer")
override_translation("zh_TW", "got", "冬季")
@@ -269,7 +269,7 @@ RSpec.describe "translate accelerator" do
context "with existing translations in current locale and fallback locale" do
context "with overrides in both locales" do
- it "should return the override from the current locale" do
+ it "returns the override from the current locale" do
override_translation("de", "foo", "Override of foo in :de")
override_translation("en", "foo", "Override of foo in :en")
translation_should_equal("foo", "Override of foo in :de")
@@ -277,21 +277,21 @@ RSpec.describe "translate accelerator" do
end
context "with override only in current locale" do
- it "should return the override from the current locale" do
+ it "returns the override from the current locale" do
override_translation("de", "foo", "Override of foo in :de")
translation_should_equal("foo", "Override of foo in :de")
end
end
context "with override only in fallback locale" do
- it "should return the translation from the current locale" do
+ it "returns the translation from the current locale" do
override_translation("en", "foo", "Override of foo in :en")
translation_should_equal("foo", "Foo in :de")
end
end
context "with no overrides" do
- it "should return the translation from the current locale" do
+ it "returns the translation from the current locale" do
translation_should_equal("foo", "Foo in :de")
end
end
@@ -299,7 +299,7 @@ RSpec.describe "translate accelerator" do
context "with existing translation in fallback locale" do
context "with overrides in both locales" do
- it "should return the override from the current locale" do
+ it "returns the override from the current locale" do
override_translation("de", "fish", "Override of fish in :de")
override_translation("en", "fish", "Override of fish in :en")
translation_should_equal("fish", "Override of fish in :de")
@@ -307,21 +307,21 @@ RSpec.describe "translate accelerator" do
end
context "with override only in current locale" do
- it "should return the override from the current locale" do
+ it "returns the override from the current locale" do
override_translation("de", "fish", "Override of fish in :de")
translation_should_equal("fish", "Override of fish in :de")
end
end
context "with override only in fallback locale" do
- it "should return the translation from the current locale" do
+ it "returns the translation from the current locale" do
override_translation("en", "fish", "Override of fish in :en")
translation_should_equal("fish", "Override of fish in :en")
end
end
context "with no overrides" do
- it "should return the translation from the fallback locale" do
+ it "returns the translation from the fallback locale" do
translation_should_equal("fish", "original fish")
end
end
diff --git a/spec/lib/freedom_patches/web_push_spec.rb b/spec/lib/freedom_patches/web_push_spec.rb
index 6b4f9f9239d..0c706434dd6 100644
--- a/spec/lib/freedom_patches/web_push_spec.rb
+++ b/spec/lib/freedom_patches/web_push_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe klass do
FinalDestination::SSRFDetector.disallow_ip_lookups_in_test!
end
- it "should filter endpoint hostname through our SSRF detector" do
+ it "filters the endpoint hostname through the SSRF detector" do
klass::Request.any_instance.expects(:encrypt_payload)
klass::Request.any_instance.expects(:headers)
@@ -34,7 +34,7 @@ RSpec.describe klass do
end.to raise_error(FinalDestination::SSRFDetector::DisallowedIpError)
end
- it "should send the right request if endpoint hostname resolves to a public ip address" do
+ it "sends the expected request when the endpoint resolves to a public IP address" do
klass::Request.any_instance.expects(:encrypt_payload)
klass::Request.any_instance.expects(:headers)
diff --git a/spec/lib/global_path_spec.rb b/spec/lib/global_path_spec.rb
index 61c0cecd7c8..2caf6b27c58 100644
--- a/spec/lib/global_path_spec.rb
+++ b/spec/lib/global_path_spec.rb
@@ -16,12 +16,12 @@ RSpec.describe GlobalPath do
expect(cdn_relative_path("/test")).to eq("/test")
end
- it "returns path when a cdn is defined with a path" do
+ it "includes the path from a protocol-relative CDN URL" do
GlobalSetting.expects(:cdn_url).returns("//something.com/foo")
expect(cdn_relative_path("/test")).to eq("/foo/test")
end
- it "returns path when a cdn is defined with a path" do
+ it "includes the path from a CDN URL with a scheme and port" do
GlobalSetting.expects(:cdn_url).returns("https://something.com:221/foo")
expect(cdn_relative_path("/test")).to eq("/foo/test")
end
diff --git a/spec/lib/guardian/invite_guardian_spec.rb b/spec/lib/guardian/invite_guardian_spec.rb
index f77b40351ff..b8def41d4cc 100644
--- a/spec/lib/guardian/invite_guardian_spec.rb
+++ b/spec/lib/guardian/invite_guardian_spec.rb
@@ -171,16 +171,16 @@ RSpec.describe InviteGuardian do
let(:topic) { Fabricate(:topic, category: category) }
- it "should return true for an admin user" do
+ it "returns true for an admin" do
expect(Guardian.new(admin).can_invite_to?(topic)).to eq(true)
end
- it "should return true for a group owner" do
+ it "returns true for a group owner" do
group_owner.update!(trust_level: 2)
expect(Guardian.new(group_owner).can_invite_to?(topic)).to eq(true)
end
- it "should return false for a normal user" do
+ it "returns false for a regular user" do
expect(Guardian.new(user).can_invite_to?(topic)).to eq(false)
end
end
@@ -193,7 +193,7 @@ RSpec.describe InviteGuardian do
let(:group_owner) { Fabricate(:user).tap { |user| automatic_group.add_owner(user) } }
let(:topic) { Fabricate(:topic, category: category) }
- it "should return false for all type of users" do
+ it "returns false for every user type" do
expect(Guardian.new(admin).can_invite_to?(topic)).to eq(false)
expect(Guardian.new(group_owner).can_invite_to?(topic)).to eq(false)
expect(Guardian.new(user).can_invite_to?(topic)).to eq(false)
diff --git a/spec/lib/guardian/post_guardian_spec.rb b/spec/lib/guardian/post_guardian_spec.rb
index dce84101f60..feb7e8c7b23 100644
--- a/spec/lib/guardian/post_guardian_spec.rb
+++ b/spec/lib/guardian/post_guardian_spec.rb
@@ -320,7 +320,7 @@ RSpec.describe PostGuardian do
fab!(:post) { Fabricate(:post, user: user, topic: topic) }
describe "when post has been deleted" do
- it "should return the right value" do
+ it "allows a moderator to recover a post they deleted" do
expect(Guardian.new(moderator).can_recover_post?(post)).to be_falsey
PostDestroyer.new(moderator, post).destroy
@@ -329,7 +329,7 @@ RSpec.describe PostGuardian do
end
describe "when post's user has been deleted" do
- it "should return the right value" do
+ it "allows a moderator to recover a post whose author was deleted" do
PostDestroyer.new(moderator, post).destroy
post.user.destroy!
diff --git a/spec/lib/guardian/user_guardian_spec.rb b/spec/lib/guardian/user_guardian_spec.rb
index 22493d55279..a37aad8a007 100644
--- a/spec/lib/guardian/user_guardian_spec.rb
+++ b/spec/lib/guardian/user_guardian_spec.rb
@@ -39,12 +39,12 @@ RSpec.describe UserGuardian do
context "with anon user" do
let(:guardian) { Guardian.new }
- it "should return the right value for non-automatic requests" do
+ it "returns the expected value for non-automatic requests" do
SiteSetting.reviewable_claiming = "optional"
expect(guardian.can_claim_reviewable_topic?(topic)).to eq(false)
end
- it "should return the right value for automatic requests" do
+ it "returns the expected value for automatic requests" do
expect(guardian.can_claim_reviewable_topic?(topic, true)).to eq(false)
end
end
@@ -52,12 +52,12 @@ RSpec.describe UserGuardian do
context "with current user" do
let(:guardian) { Guardian.new(user) }
- it "should return the right value for non-automatic requests" do
+ it "returns the expected value for non-automatic requests" do
SiteSetting.reviewable_claiming = "optional"
expect(guardian.can_claim_reviewable_topic?(topic)).to eq(false)
end
- it "should return the right value for automatic requests" do
+ it "returns the expected value for automatic requests" do
expect(guardian.can_claim_reviewable_topic?(topic, true)).to eq(false)
end
end
@@ -65,12 +65,12 @@ RSpec.describe UserGuardian do
context "with moderator" do
let(:guardian) { Guardian.new(moderator) }
- it "should return the right value for non-automatic requests" do
+ it "returns the expected value for non-automatic requests" do
SiteSetting.reviewable_claiming = "optional"
expect(guardian.can_claim_reviewable_topic?(topic)).to eq(true)
end
- it "should return the right value for automatic requests" do
+ it "returns the expected value for automatic requests" do
expect(guardian.can_claim_reviewable_topic?(topic, true)).to eq(true)
end
end
@@ -78,12 +78,12 @@ RSpec.describe UserGuardian do
context "with admin" do
let(:guardian) { Guardian.new(admin) }
- it "should return the right value for non-automatic requests" do
+ it "returns the expected value for non-automatic requests" do
SiteSetting.reviewable_claiming = "optional"
expect(guardian.can_claim_reviewable_topic?(topic)).to eq(true)
end
- it "should return the right value for automatic requests" do
+ it "returns the expected value for automatic requests" do
expect(guardian.can_claim_reviewable_topic?(topic, true)).to eq(true)
end
end
@@ -145,7 +145,7 @@ RSpec.describe UserGuardian do
context "with anon user" do
let(:guardian) { Guardian.new }
- it "should return the right value" do
+ it "returns the expected value" do
expect(guardian.can_pick_avatar?(user_avatar, users_upload)).to eq(false)
end
end
diff --git a/spec/lib/guardian_spec.rb b/spec/lib/guardian_spec.rb
index 386090cf4e4..a10c9752992 100644
--- a/spec/lib/guardian_spec.rb
+++ b/spec/lib/guardian_spec.rb
@@ -373,13 +373,13 @@ RSpec.describe Guardian do
before { another_user.user_option.update!(allow_private_messages: false) }
context "for a normal user" do
- it "should return false" do
+ it "prevents the user from sending a private message" do
expect(Guardian.new(user).can_send_private_message?(another_user)).to eq(false)
end
end
context "for a staff user" do
- it "should return true" do
+ it "allows staff to send private messages" do
[admin, moderator].each do |staff_user|
expect(Guardian.new(staff_user).can_send_private_message?(another_user)).to eq(true)
end
@@ -790,7 +790,7 @@ RSpec.describe Guardian do
expect(Guardian.new(moderator).can_create?(Topic, category)).to be_falsey
end
- it "should check for full permissions" do
+ it "checks for full category permissions" do
category = plain_category
category.set_permissions(everyone: :create_post)
category.save
@@ -886,7 +886,7 @@ RSpec.describe Guardian do
context "as a moderator" do
describe "when post has been deleted" do
- it "should return the right value" do
+ it "allows recovery only after the topic is deleted" do
expect(Guardian.new(moderator).can_recover_topic?(topic)).to be_falsey
PostDestroyer.new(moderator, topic.first_post).destroy
@@ -896,7 +896,7 @@ RSpec.describe Guardian do
end
describe "when post's user has been deleted" do
- it "should return the right value" do
+ it "allows recovery after the topic's author is deleted" do
PostDestroyer.new(moderator, topic.first_post).destroy
topic.first_post.user.destroy!
@@ -1518,7 +1518,7 @@ RSpec.describe Guardian do
expect(Guardian.new(moderator).can_see_flags?(post)).to be_truthy
end
- it "allows moderators to see flags" do
+ it "allows admins to see flags" do
expect(Guardian.new(admin).can_see_flags?(post)).to be_truthy
end
end
@@ -2004,7 +2004,7 @@ RSpec.describe Guardian do
expect(Guardian.new(admin).can_grant_admin?(user)).to be_truthy
end
- it "should not allow an admin to grant admin access to a non real user" do
+ it "prevents granting admin access to a system user" do
Discourse.system_user.update!(admin: false)
expect(Guardian.new(admin).can_grant_admin?(Discourse.system_user)).to be(false)
ensure
@@ -2032,7 +2032,7 @@ RSpec.describe Guardian do
expect(Guardian.new(admin).can_revoke_admin?(another_admin)).to be_truthy
end
- it "should not allow an admin to revoke a no real user's admin access" do
+ it "prevents revoking a system user's admin access" do
expect(Guardian.new(admin).can_revoke_admin?(Discourse.system_user)).to be(false)
end
end
@@ -2046,7 +2046,7 @@ RSpec.describe Guardian do
expect(Guardian.new(user).can_grant_moderation?(moderator)).to be_falsey
end
- it "will allow an admin to grant their own moderator access" do
+ it "allows admins to grant themselves moderator access" do
expect(Guardian.new(admin).can_grant_moderation?(admin)).to be_truthy
end
@@ -2058,7 +2058,7 @@ RSpec.describe Guardian do
expect(Guardian.new(admin).can_grant_moderation?(user)).to be_truthy
end
- it "should not allow an admin to grant moderation to a non real user" do
+ it "prevents granting moderation to a system user" do
Discourse.system_user.update!(moderator: false)
expect(Guardian.new(admin).can_grant_moderation?(Discourse.system_user)).to be(false)
ensure
@@ -2092,7 +2092,7 @@ RSpec.describe Guardian do
expect(Guardian.new(admin).can_revoke_moderation?(admin)).to be_falsey
end
- it "should not allow an admin to revoke moderation from a non real user" do
+ it "prevents revoking moderation from a system user" do
expect(Guardian.new(admin).can_revoke_moderation?(Discourse.system_user)).to be(false)
end
end
@@ -2834,7 +2834,7 @@ RSpec.describe Guardian do
global_setting :allowed_theme_repos, " https://magic.com/repo.git, https://x.com/git"
end
- it "should respect theme allowlisting" do
+ it "respects theme allowlisting" do
r = RemoteTheme.create!(remote_url: "https://magic.com/repo.git")
theme.update!(remote_theme_id: r.id)
@@ -3289,14 +3289,14 @@ RSpec.describe Guardian do
end
describe "suspension reasons" do
- it "will be shown by default" do
+ it "shows suspension reasons by default" do
expect(Guardian.new.can_see_suspension_reason?(user)).to eq(true)
end
context "with hide suspension reason enabled" do
before { SiteSetting.hide_suspension_reasons = true }
- it "will not be shown to anonymous users" do
+ it "hides suspension reasons from anonymous users" do
expect(Guardian.new.can_see_suspension_reason?(user)).to eq(false)
end
@@ -3311,14 +3311,14 @@ RSpec.describe Guardian do
end
describe "silencing reasons" do
- it "will be shown by default" do
+ it "shows silencing reasons by default" do
expect(Guardian.new.can_see_silencing_reason?(user)).to eq(true)
end
context "with hide silencing reason enabled" do
before { SiteSetting.hide_silencing_reasons = true }
- it "will not be shown to anonymous users" do
+ it "hides silencing reasons from anonymous users" do
expect(Guardian.new.can_see_silencing_reason?(user)).to eq(false)
end
@@ -3360,7 +3360,7 @@ RSpec.describe Guardian do
describe "#can_remove_allowed_users?" do
context "with staff users" do
- it "should be true" do
+ it "allows moderators to remove allowed users" do
expect(Guardian.new(moderator).can_remove_allowed_users?(topic)).to eq(true)
end
end
@@ -3374,7 +3374,7 @@ RSpec.describe Guardian do
topic.allowed_users << another_user
end
- it "should be true" do
+ it "allows the topic creator to remove allowed users" do
expect(Guardian.new(topic_creator).can_remove_allowed_users?(topic)).to eq(true)
end
end
@@ -3387,19 +3387,19 @@ RSpec.describe Guardian do
topic.allowed_users << another_user
end
- it "should be false" do
+ it "prevents regular users from removing allowed users" do
expect(Guardian.new(user).can_remove_allowed_users?(topic)).to eq(false)
end
describe "target_user is the user" do
describe "when user is in a pm with another user" do
- it "should return true" do
+ it "allows the user to leave the PM" do
expect(Guardian.new(user).can_remove_allowed_users?(topic, user)).to eq(true)
end
end
describe "when user is the creator of the topic" do
- it "should return false" do
+ it "prevents the topic creator from leaving" do
expect(Guardian.new(topic.user).can_remove_allowed_users?(topic, topic.user)).to eq(
false,
)
@@ -3407,7 +3407,7 @@ RSpec.describe Guardian do
end
describe "when user is the only user in the topic" do
- it "should return false" do
+ it "prevents the last user from leaving" do
topic.remove_allowed_user(Discourse.system_user, another_user.username)
expect(Guardian.new(user).can_remove_allowed_users?(topic, user)).to eq(false)
@@ -3416,7 +3416,7 @@ RSpec.describe Guardian do
end
describe "target_user is not the user" do
- it "should return false" do
+ it "prevents removing another user" do
expect(Guardian.new(user).can_remove_allowed_users?(topic, moderator)).to eq(false)
end
end
@@ -3425,11 +3425,11 @@ RSpec.describe Guardian do
context "with anonymous users" do
fab!(:topic)
- it "should be false" do
+ it "prevents anonymous users from removing allowed users" do
expect(Guardian.new.can_remove_allowed_users?(topic)).to eq(false)
end
- it "should be false when the topic does not have a user (for example because the user was removed)" do
+ it "prevents removing allowed users when the topic has no author" do
DB.exec("UPDATE topics SET user_id=NULL WHERE id=#{topic.id}")
topic.reload
@@ -3535,12 +3535,12 @@ RSpec.describe Guardian do
end
describe "#can_mention_here?" do
- it "returns false if disabled" do
+ it "returns false when the maximum here mentions is zero" do
SiteSetting.max_here_mentioned = 0
expect(admin.guardian.can_mention_here?).to eq(false)
end
- it "returns false if disabled" do
+ it "returns false when the here mention is blank" do
SiteSetting.here_mention = ""
expect(admin.guardian.can_mention_here?).to eq(false)
end
@@ -3579,7 +3579,7 @@ RSpec.describe Guardian do
fab!(:category)
- it "should correctly detect category moderation" do
+ it "detects category moderation" do
group.add(user)
Fabricate(:category_moderation_group, category:, group:)
guardian = Guardian.new(user)
diff --git a/spec/lib/html_to_markdown_spec.rb b/spec/lib/html_to_markdown_spec.rb
index ffc6db2ceed..4320e99a7f4 100644
--- a/spec/lib/html_to_markdown_spec.rb
+++ b/spec/lib/html_to_markdown_spec.rb
@@ -465,7 +465,7 @@ RSpec.describe HtmlToMarkdown do
).to eq("> ```\n> var foo = 'bar';\n> ```")
end
- it "works" do
+ it "converts a blockquote nested in a list item" do
expect(
html_to_markdown(
"<ul><li><p>A list item with a blockquote:</p><blockquote><p>This is a <strong>blockquote</strong><br>inside a list item.</p></blockquote></li></ul>",
@@ -550,7 +550,7 @@ RSpec.describe HtmlToMarkdown do
)
end
- it "works" do
+ it "converts nested bold and italic text with line breaks" do
expect(html_to_markdown("<div>A <b> B <i> C <br> D </i> E <br> F </b> G</div>")).to eq(
"A __B *C*__\n__*D* E__\n**F** G",
)
diff --git a/spec/lib/i18n/i18n_interpolation_keys_finder_spec.rb b/spec/lib/i18n/i18n_interpolation_keys_finder_spec.rb
index 970b223984b..72a8bc38a3e 100644
--- a/spec/lib/i18n/i18n_interpolation_keys_finder_spec.rb
+++ b/spec/lib/i18n/i18n_interpolation_keys_finder_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe I18nInterpolationKeysFinder do
describe "#find" do
- it "should return the right keys" do
+ it "returns the interpolation keys" do
expect(described_class.find("%{first} %{second} {{third}}")).to eq(%w[first second third])
end
end
diff --git a/spec/lib/inline_oneboxer_spec.rb b/spec/lib/inline_oneboxer_spec.rb
index 57c9e7fbcab..e431016904f 100644
--- a/spec/lib/inline_oneboxer_spec.rb
+++ b/spec/lib/inline_oneboxer_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe InlineOneboxer do
- it "should return nothing with empty input" do
+ it "returns nothing for empty input" do
expect(InlineOneboxer.new([]).process).to be_blank
end
@@ -146,7 +146,7 @@ RSpec.describe InlineOneboxer do
expect(InlineOneboxer.lookup("/test")).to be_nil
end
- it "will return the fancy title" do
+ it "returns the fancy title" do
topic = Fabricate(:topic, title: "Hello :pizza: with an emoji")
onebox = InlineOneboxer.lookup(topic.url, skip_cache: true)
expect(onebox).to be_present
@@ -154,7 +154,7 @@ RSpec.describe InlineOneboxer do
expect(onebox[:title]).to eq("Hello 🍕 with an emoji")
end
- it "will append the post number post author's username to the title" do
+ it "appends the post number and author's username to the title" do
topic = Fabricate(:topic, title: "Inline oneboxer")
Fabricate(:post, topic: topic) # OP
Fabricate(:post, topic: topic)
@@ -182,13 +182,13 @@ RSpec.describe InlineOneboxer do
expect(lookup.call(99)).to eq("Inline oneboxer - #4 by #{posts[3].user.username}")
end
- it "will not crawl domains that aren't allowlisted" do
+ it "does not crawl domains that are not allowlisted" do
SiteSetting.enable_inline_onebox_on_all_domains = false
onebox = InlineOneboxer.lookup("https://eviltrout.com", skip_cache: true)
expect(onebox).to be_blank
end
- it "will crawl anything if allowed to" do
+ it "crawls any domain when configured to do so" do
SiteSetting.enable_inline_onebox_on_all_domains = true
stub_request(:get, "https://eviltrout.com/some-path").to_return(
@@ -203,7 +203,7 @@ RSpec.describe InlineOneboxer do
expect(onebox[:title]).to eq("a blog")
end
- it "will not return a onebox if it does not meet minimal length" do
+ it "does not return a onebox shorter than the minimum length" do
SiteSetting.enable_inline_onebox_on_all_domains = true
stub_request(:get, "https://eviltrout.com/some-path").to_return(
@@ -218,7 +218,7 @@ RSpec.describe InlineOneboxer do
expect(onebox[:title]).to eq(nil)
end
- it "will lookup allowlisted domains" do
+ it "looks up allowlisted domains" do
SiteSetting.allowed_inline_onebox_domains = "eviltrout.com"
RetrieveTitle.stubs(:crawl).returns("Evil Trout's Blog")
diff --git a/spec/lib/json_error_spec.rb b/spec/lib/json_error_spec.rb
index 8081e728cc0..f47527ef1d2 100644
--- a/spec/lib/json_error_spec.rb
+++ b/spec/lib/json_error_spec.rb
@@ -3,7 +3,7 @@
RSpec.shared_examples "a generic error" do
let(:result) { creator.create_errors_json(obj) }
- it "should have a result object" do
+ it "includes a result object" do
expect(result).to be_present
end
diff --git a/spec/lib/middleware/anonymous_cache_spec.rb b/spec/lib/middleware/anonymous_cache_spec.rb
index 12617a4d0bf..c51c39f84d0 100644
--- a/spec/lib/middleware/anonymous_cache_spec.rb
+++ b/spec/lib/middleware/anonymous_cache_spec.rb
@@ -292,7 +292,7 @@ RSpec.describe Middleware::AnonymousCache do
end
describe "background request rate limit" do
- it "will rate limit background requests" do
+ it "rate limits background requests" do
app = Middleware::AnonymousCache.new(lambda { |env| [200, {}, ["ok"]] })
global_setting :background_requests_max_queue_length, "0.5"
@@ -332,7 +332,7 @@ RSpec.describe Middleware::AnonymousCache do
describe "#force_anonymous!" do
before { RateLimiter.enable }
- it "will revert to anonymous once we reach the limit" do
+ it "reverts to anonymous when the limit is reached" do
is_anon = false
app =
@@ -485,7 +485,7 @@ RSpec.describe Middleware::AnonymousCache do
expect(@status).to eq(200)
end
- it "should never block robots.txt" do
+ it "allows robots.txt requests" do
SiteSetting.blocked_crawler_user_agents = "Googlebot"
get "/robots.txt",
@@ -496,7 +496,7 @@ RSpec.describe Middleware::AnonymousCache do
expect(@status).to eq(200)
end
- it "should never block srv/status" do
+ it "allows srv/status requests" do
SiteSetting.blocked_crawler_user_agents = "Googlebot"
get "/srv/status",
diff --git a/spec/lib/middleware/discourse_public_exceptions_spec.rb b/spec/lib/middleware/discourse_public_exceptions_spec.rb
index 85c2303879b..4f2fc04ffd1 100644
--- a/spec/lib/middleware/discourse_public_exceptions_spec.rb
+++ b/spec/lib/middleware/discourse_public_exceptions_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Middleware::DiscoursePublicExceptions do
}.merge(opts)
end
- it "should not log for invalid mime type requests" do
+ it "does not log invalid MIME type requests" do
ex = Middleware::DiscoursePublicExceptions.new("/test")
ex.call(
diff --git a/spec/lib/middleware/request_tracker_spec.rb b/spec/lib/middleware/request_tracker_spec.rb
index 186ac277006..bf4982d721e 100644
--- a/spec/lib/middleware/request_tracker_spec.rb
+++ b/spec/lib/middleware/request_tracker_spec.rb
@@ -1485,7 +1485,7 @@ RSpec.describe Middleware::RequestTracker do
after { Middleware::RequestTracker.unregister_ip_skipper }
- it "won't block if the ip is skipped" do
+ it "does not block skipped IP addresses" do
env1 = env("REMOTE_ADDR" => "1.1.1.2")
status, _ = middleware.call(env1)
status, _ = middleware.call(env1)
diff --git a/spec/lib/migration/column_dropper_spec.rb b/spec/lib/migration/column_dropper_spec.rb
index f14e21b34d3..84d672b86b2 100644
--- a/spec/lib/migration/column_dropper_spec.rb
+++ b/spec/lib/migration/column_dropper_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Migration::ColumnDropper do
end
end
- describe ".mark_readonly" do
+ describe ".mark_readonly schema lookup" do
it "only checks the public schema for default values" do
DB.exec <<~SQL
CREATE TABLE test_public_schema (id INTEGER, col TEXT);
@@ -55,7 +55,7 @@ RSpec.describe Migration::ColumnDropper do
end
end
- describe ".mark_readonly" do
+ describe ".mark_readonly enforcement" do
let(:table_name) { "table_with_readonly_column" }
before do
@@ -78,7 +78,7 @@ RSpec.describe Migration::ColumnDropper do
SQL
end
- it "should be droppable" do
+ it "allows the read-only column to be dropped" do
Migration::ColumnDropper.execute_drop(table_name, ["email"])
expect(has_trigger?(Migration::BaseDropper.readonly_trigger_name(table_name, "email"))).to eq(
@@ -88,7 +88,7 @@ RSpec.describe Migration::ColumnDropper do
expect(has_column?(table_name, "email")).to eq(false)
end
- it "should prevent updates to the readonly column" do
+ it "prevents updates to the read-only column" do
DB.exec <<~SQL
UPDATE #{table_name}
SET email = '[email protected]'
@@ -101,7 +101,7 @@ RSpec.describe Migration::ColumnDropper do
].each { |message| expect(e.message).to include(message) }
end
- it "should allow updates to the other columns" do
+ it "allows updates to other columns" do
DB.exec <<~SQL
UPDATE #{table_name}
SET topic_id = 2
@@ -112,7 +112,7 @@ RSpec.describe Migration::ColumnDropper do
end
- it "should prevent insertions to the readonly column" do
+ it "prevents insertions into the read-only column" do
expect do ActiveRecord::Base.connection.raw_connection.exec <<~SQL end.to raise_error(
INSERT INTO #{table_name} (topic_id, email)
VALUES (2, '[email protected]');
@@ -122,7 +122,7 @@ RSpec.describe Migration::ColumnDropper do
)
end
- it "should allow insertions to the other columns" do
+ it "allows insertions into other columns" do
DB.exec <<~SQL
INSERT INTO #{table_name} (topic_id)
VALUES (2);
diff --git a/spec/lib/migration/safe_migrate_spec.rb b/spec/lib/migration/safe_migrate_spec.rb
index 33ef910b068..af74a39772c 100644
--- a/spec/lib/migration/safe_migrate_spec.rb
+++ b/spec/lib/migration/safe_migrate_spec.rb
@@ -161,7 +161,7 @@ RSpec.describe Migration::SafeMigrate do
end
describe "for a post deployment migration" do
- it "should not ban unsafe migrations using up" do
+ it "does not ban unsafe migrations that use up" do
Migration::SafeMigrate::SafeMigration.enable_safe!
path = File.expand_path "#{Rails.root.join("spec/fixtures/db/post_migrate/drop_table")}"
@@ -171,7 +171,7 @@ RSpec.describe Migration::SafeMigrate do
expect(output).to include("drop_table(:email_logs)")
end
- it "should not ban unsafe migrations using change" do
+ it "does not ban unsafe migrations that use change" do
Migration::SafeMigrate::SafeMigration.enable_safe!
path = File.expand_path "#{Rails.root.join("spec/fixtures/db/post_migrate/change")}"
diff --git a/spec/lib/migration/table_dropper_spec.rb b/spec/lib/migration/table_dropper_spec.rb
index add89c3c153..028747584f2 100644
--- a/spec/lib/migration/table_dropper_spec.rb
+++ b/spec/lib/migration/table_dropper_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe Migration::TableDropper do
end
describe ".execute_drop" do
- it "should drop the table" do
+ it "drops the table" do
Migration::TableDropper.execute_drop(table_name)
expect(table_exists?(table_name)).to eq(false)
@@ -50,7 +50,7 @@ RSpec.describe Migration::TableDropper do
SQL
end
- it "should be droppable" do
+ it "allows the table to be dropped" do
Migration::TableDropper.execute_drop(table_name)
expect(has_trigger?(Migration::BaseDropper.readonly_trigger_name(table_name))).to eq(false)
@@ -58,7 +58,7 @@ RSpec.describe Migration::TableDropper do
expect(table_exists?(table_name)).to eq(false)
end
- it "should drop the read_only function" do
+ it "drops the read_only function" do
Migration::TableDropper.execute_drop(table_name)
schema_name, function_name =
@@ -67,7 +67,7 @@ RSpec.describe Migration::TableDropper do
expect(function_exists?(function_name, schema_name)).to eq(false)
end
- it "should prevent insertions to the table" do
+ it "prevents insertions into the table" do
DB.exec <<~SQL
INSERT INTO #{table_name} (topic_id) VALUES (2)
SQL
diff --git a/spec/lib/new_post_manager_spec.rb b/spec/lib/new_post_manager_spec.rb
index 095c3c7869b..a24ab2ab8b9 100644
--- a/spec/lib/new_post_manager_spec.rb
+++ b/spec/lib/new_post_manager_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe NewPostManager do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, user: user) }
- describe "default action" do
+ describe "default action for regular posts" do
it "creates the post by default" do
manager = NewPostManager.new(user, raw: "this is a new post", topic_id: topic.id)
result = manager.perform
@@ -18,7 +18,7 @@ RSpec.describe NewPostManager do
end
end
- describe "default action" do
+ describe "default action for private messages" do
fab!(:other_user, :user)
it "doesn't enqueue private messages" do
@@ -150,7 +150,7 @@ RSpec.describe NewPostManager do
topic.user.trust_level = 0
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
@@ -164,7 +164,7 @@ RSpec.describe NewPostManager do
topic.user.trust_level = 1
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
@@ -178,7 +178,7 @@ RSpec.describe NewPostManager do
user.update!(trust_level: 2)
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(result).to be_nil
end
@@ -206,7 +206,7 @@ RSpec.describe NewPostManager do
context "with a high trust level setting" do
before { SiteSetting.approve_unless_allowed_groups = Group::AUTO_GROUPS[:trust_level_4] }
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
@@ -220,7 +220,7 @@ RSpec.describe NewPostManager do
SiteSetting.approve_unless_allowed_groups = Group::AUTO_GROUPS[:trust_level_4]
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
npm =
NewPostManager.new(
user,
@@ -242,7 +242,7 @@ RSpec.describe NewPostManager do
user.update!(staged: true)
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
@@ -407,7 +407,7 @@ RSpec.describe NewPostManager do
SiteSetting.approve_new_topics_unless_allowed_groups = Group::AUTO_GROUPS[:trust_level_4]
end
- it "will return an enqueue result" do
+ it "returns an enqueue result" do
result = NewPostManager.default_handler(manager)
expect(NewPostManager.queue_enabled?).to eq(true)
expect(result.action).to eq(:enqueued)
@@ -872,7 +872,7 @@ RSpec.describe NewPostManager do
topic.user.trust_level = 0
end
- it "will store via_email and raw_email in the enqueued post" do
+ it "stores via_email and raw_email in the enqueued post" do
result = manager.perform
expect(result.action).to eq(:enqueued)
expect(result.reviewable).to be_present
diff --git a/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb b/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
index ca9e0048e11..67daf3241e9 100644
--- a/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
+++ b/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe Onebox::Engine::StackExchangeOnebox do
expect(described_class === URI("http://#{domain}/a/55503")).to eq(true)
end
- it "matches question with long URL on #{domain}" do
+ it "matches an answer URL with a fragment on #{domain}" do
expect(
described_class === URI("http://#{domain}/questions/55495/title-of-question/55503#55503"),
).to eq(true)
diff --git a/spec/lib/onebox/engine/trello_onebox_spec.rb b/spec/lib/onebox/engine/trello_onebox_spec.rb
index d3e8ce0ae27..e0134bddbbe 100644
--- a/spec/lib/onebox/engine/trello_onebox_spec.rb
+++ b/spec/lib/onebox/engine/trello_onebox_spec.rb
@@ -2,13 +2,13 @@
RSpec.describe Onebox::Engine::TrelloOnebox do
describe "Boards" do
- it "should onebox with SEF url corrrectly" do
+ it "oneboxes an SEF URL correctly" do
expect(
Onebox.preview("https://trello.com/b/nC8QJJoZ/trello-development-roadmap").to_s,
).to match('iframe src="https://trello.com/b/nC8QJJoZ.html"')
end
- it "should onebox without SEF url corrrectly" do
+ it "oneboxes a non-SEF URL correctly" do
expect(Onebox.preview("https://trello.com/b/nC8QJJoZ/").to_s).to match(
'iframe src="https://trello.com/b/nC8QJJoZ.html"',
)
@@ -21,7 +21,7 @@ RSpec.describe Onebox::Engine::TrelloOnebox do
end
describe "Cards" do
- it "should onebox with SEF url corrrectly" do
+ it "oneboxes an SEF URL correctly" do
expect(
Onebox.preview(
"https://trello.com/c/NIRpzVDM/1211-what-can-you-expect-from-this-board",
@@ -29,7 +29,7 @@ RSpec.describe Onebox::Engine::TrelloOnebox do
).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
end
- it "should onebox without SEF url corrrectly" do
+ it "oneboxes a non-SEF URL correctly" do
expect(Onebox.preview("https://trello.com/c/NIRpzVDM/").to_s).to match(
'iframe src="https://trello.com/c/NIRpzVDM.html"',
)
diff --git a/spec/lib/onebox/engine_spec.rb b/spec/lib/onebox/engine_spec.rb
index 19196dec634..b7e9d83556d 100644
--- a/spec/lib/onebox/engine_spec.rb
+++ b/spec/lib/onebox/engine_spec.rb
@@ -132,11 +132,11 @@ RSpec.describe Onebox::Engine do
let(:onebox_name) { ScopeForTemplateName::TemplateNameOnebox.onebox_name }
- it "should not include the scope" do
+ it "omits the scope" do
expect(onebox_name).not_to include("ScopeForTemplateName", "scopefortemplatename")
end
- it "should not include the word Onebox" do
+ it "omits the word Onebox" do
expect(onebox_name).not_to include("onebox", "Onebox")
end
end
diff --git a/spec/lib/onebox_spec.rb b/spec/lib/onebox_spec.rb
index d065f8b6393..824b1d696a1 100644
--- a/spec/lib/onebox_spec.rb
+++ b/spec/lib/onebox_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Onebox do
templates.each { |template| expect(File.read(template)).not_to match(text) }
end
- it "should not contain any script tags" do
+ it "contains no script tags" do
expect_templates_to_not_match(/<script/)
end
end
diff --git a/spec/lib/oneboxer_spec.rb b/spec/lib/oneboxer_spec.rb
index 236aaa780f8..2cd43c6e014 100644
--- a/spec/lib/oneboxer_spec.rb
+++ b/spec/lib/oneboxer_spec.rb
@@ -172,7 +172,7 @@ RSpec.describe Oneboxer do
expect(preview("/u/#{user.username}")).to include(user.name)
end
- it "should respect enable_names site setting" do
+ it "respects the enable_names site setting" do
user = Fabricate(:user)
user.user_stat.update!(post_count: 1)
@@ -386,7 +386,7 @@ RSpec.describe Oneboxer do
end
describe ".onebox_raw" do
- it "should escape the onebox URL before processing" do
+ it "escapes the onebox URL before processing" do
post = Fabricate(:post, raw: Discourse.base_url + "/new?'class=black")
cpp = CookedPostProcessor.new(post, invalidate_oneboxes: true)
cpp.post_process_oneboxes
diff --git a/spec/lib/plugin/filter_manager_spec.rb b/spec/lib/plugin/filter_manager_spec.rb
index 78275b0189d..87a25487dc7 100644
--- a/spec/lib/plugin/filter_manager_spec.rb
+++ b/spec/lib/plugin/filter_manager_spec.rb
@@ -11,15 +11,15 @@ RSpec.describe Plugin::FilterManager do
expect(instance.apply(:added_numbers, 1, 0)).to eq(5)
end
- it "should raise an exception if wrong arity is passed in" do
+ it "raises an exception for an invalid arity" do
expect do instance.register(:test) {} end.to raise_error(ArgumentError)
end
- it "should return the original if no filters exist" do
+ it "returns the original value when no filters exist" do
expect(instance.apply(:foo, nil, 42)).to eq(42)
end
- it "should raise an exception if no block is passed in" do
+ it "raises an exception when no block is provided" do
expect do instance.register(:test) end.to raise_error(ArgumentError)
end
end
diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb
index eb3a5d3086d..9656d5c2737 100644
--- a/spec/lib/plugin/instance_spec.rb
+++ b/spec/lib/plugin/instance_spec.rb
@@ -486,7 +486,7 @@ TEXT
end
describe ".register_seedfu_fixtures" do
- it "should add the new path to SeedFu's fixtures path" do
+ it "adds the new path to SeedFu's fixture paths" do
plugin = Plugin::Instance.new nil, "/tmp/test.rb"
plugin.register_seedfu_fixtures(["some_path"])
plugin.register_seedfu_fixtures("some_path2")
@@ -509,7 +509,7 @@ TEXT
plugin
end
- it "should add the right callback" do
+ it "adds the expected callback" do
called = 0
plugin_instance.add_model_callback(User, :after_create) { called += 1 }
@@ -523,7 +523,7 @@ TEXT
expect(called).to eq(1)
end
- it "should add the right callback with options" do
+ it "adds the expected callback with options" do
called = 0
plugin_instance.add_model_callback(User, :after_commit, on: :create) { called += 1 }
@@ -1369,7 +1369,7 @@ TEXT
describe "#add_request_rate_limiter" do
after { Middleware::RequestTracker.reset_rate_limiters_stack }
- it "should raise an error if `after` and `before` kwarg are provided" do
+ it "raises an error when both `after` and `before` are provided" do
plugin = Plugin::Instance.new
expect do
@@ -1383,7 +1383,7 @@ TEXT
end.to raise_error(ArgumentError, "only one of `after` or `before` can be provided")
end
- it "should raise an error if value of `after` kwarg is invalid" do
+ it "raises an error when `after` is invalid" do
plugin = Plugin::Instance.new
expect {
@@ -1399,7 +1399,7 @@ TEXT
)
end
- it "should raise an error if value of `before` kwarg is invalid" do
+ it "raises an error when `before` is invalid" do
plugin = Plugin::Instance.new
expect {
diff --git a/spec/lib/post_action_creator_spec.rb b/spec/lib/post_action_creator_spec.rb
index 13e6d3d443a..b9848a099a2 100644
--- a/spec/lib/post_action_creator_spec.rb
+++ b/spec/lib/post_action_creator_spec.rb
@@ -185,7 +185,7 @@ RSpec.describe PostActionCreator do
end
describe "flags" do
- it "will create a reviewable if one does not exist" do
+ it "creates a reviewable if one does not exist" do
result = PostActionCreator.create(user, post, :inappropriate)
expect(result.success?).to eq(true)
@@ -366,7 +366,7 @@ RSpec.describe PostActionCreator do
end
describe "take_action" do
- it "will hide the post" do
+ it "hides the post" do
PostActionCreator
.new(
Fabricate(:moderator, refresh_auto_groups: true),
@@ -384,7 +384,7 @@ RSpec.describe PostActionCreator do
PostActionCreator.create(Fabricate(:user, refresh_auto_groups: true), post, :inappropriate)
end
- it "will agree with the old reviewable" do
+ it "agrees with the old reviewable" do
reviewable =
PostActionCreator
.new(
diff --git a/spec/lib/post_action_destroyer_spec.rb b/spec/lib/post_action_destroyer_spec.rb
index a6d2275cbbf..03328470e85 100644
--- a/spec/lib/post_action_destroyer_spec.rb
+++ b/spec/lib/post_action_destroyer_spec.rb
@@ -71,7 +71,7 @@ RSpec.describe PostActionDestroyer do
end
context "when post action doesn’t exist" do
- it "fails" do
+ it "returns an error for an unsupported post action" do
result = PostActionDestroyer.destroy(user, post, :like)
expect(result.success).to eq(false)
expect(result.not_found).to eq(true)
diff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rb
index fd0157b54e1..c4ba5c26cb0 100644
--- a/spec/lib/post_creator_spec.rb
+++ b/spec/lib/post_creator_spec.rb
@@ -661,7 +661,7 @@ RSpec.describe PostCreator do
end
context "with regular expressions" do
- it "works" do
+ it "applies regular-expression tag rules" do
SiteSetting.watched_words_regular_expressions = true
Fabricate(
:watched_word,
@@ -1187,7 +1187,7 @@ RSpec.describe PostCreator do
expect(post.topic.topic_allowed_users.where(user_id: tl0_user.id).count).to eq(0)
end
- it "does not add whisperers to allowed users of the topic" do
+ it "does not add whisper authors to the topic's allowed users" do
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
unrelated_user.update!(admin: true)
@@ -1205,7 +1205,7 @@ RSpec.describe PostCreator do
)
end
- it "does not add whisperers to allowed users of the topic" do
+ it "does not add small-action authors to the topic's allowed users" do
unrelated_user.update!(admin: true)
PostCreator.create!(
@@ -1615,7 +1615,7 @@ RSpec.describe PostCreator do
end
describe "read credit for creator" do
- it "should give credit to creator" do
+ it "records reading credit for the creator" do
post = create_post
expect(
PostTiming.find_by(
@@ -1806,7 +1806,7 @@ RSpec.describe PostCreator do
end
describe "#create!" do
- it "should return the post if it was successfully created" do
+ it "returns the newly created post" do
title = "This is a valid title"
raw = "This is a really awesome post"
@@ -1818,7 +1818,7 @@ RSpec.describe PostCreator do
expect(post.raw).to eq(raw)
end
- it "should raise an error when post fails to be created" do
+ it "raises an error when the post cannot be created" do
post_creator = PostCreator.new(user, title: "", raw: "")
expect { post_creator.create! }.to raise_error(ActiveRecord::RecordNotSaved)
end
@@ -1894,7 +1894,7 @@ RSpec.describe PostCreator do
before { another_user.user_option.update!(allow_private_messages: false) }
- it "should not be valid" do
+ it "rejects the private message" do
post_creator =
PostCreator.new(
user,
@@ -1911,7 +1911,7 @@ RSpec.describe PostCreator do
)
end
- it "should not be valid if the name is downcased" do
+ it "rejects the private message when the username is lowercase" do
post_creator =
PostCreator.new(
user,
@@ -1929,7 +1929,7 @@ RSpec.describe PostCreator do
fab!(:muted_me) { evil_trout }
fab!(:another_user, :user)
- it "should fail" do
+ it "rejects the private message" do
updater = UserUpdater.new(muted_me, muted_me)
updater.update_muted_users("#{user.username}")
@@ -1975,7 +1975,7 @@ RSpec.describe PostCreator do
context "when post author is ignored" do
let!(:ignored_user) { Fabricate(:ignored_user, user: ignorer, ignored_user: user) }
- it "should fail" do
+ it "rejects the private message" do
pc =
PostCreator.new(
user,
@@ -2020,7 +2020,7 @@ RSpec.describe PostCreator do
Fabricate(:allowed_pm_user, user: allowed_user, allowed_pm_user: sender)
end
- it "should succeed" do
+ it "accepts the private message" do
allowed_user.user_option.update!(enable_allowed_pm_users: true)
pc =
@@ -2042,7 +2042,7 @@ RSpec.describe PostCreator do
Fabricate(:allowed_pm_user, user: allowed_user, allowed_pm_user: sender)
end
- it "should fail" do
+ it "rejects the private message" do
allowed_user.user_option.update!(allow_private_messages: false)
allowed_user.user_option.update!(enable_allowed_pm_users: true)
@@ -2073,7 +2073,7 @@ RSpec.describe PostCreator do
Fabricate(:allowed_pm_user, user: not_allowed_user, allowed_pm_user: allowed_user)
end
- it "should fail" do
+ it "rejects the private message" do
not_allowed_user.user_option.update!(enable_allowed_pm_users: true)
pc =
@@ -2091,7 +2091,7 @@ RSpec.describe PostCreator do
)
end
- it "should succeed when not enabled" do
+ it "accepts the private message when allow-list enforcement is disabled" do
not_allowed_user.user_option.update!(enable_allowed_pm_users: false)
pc =
@@ -2141,7 +2141,7 @@ RSpec.describe PostCreator do
Fabricate(:allowed_pm_user, user: allowed_user, allowed_pm_user: sender)
end
- it "should fail" do
+ it "rejects the private message" do
allowed_user.user_option.update!(enable_allowed_pm_users: true)
not_allowed_user.user_option.update!(enable_allowed_pm_users: true)
diff --git a/spec/lib/post_destroyer_spec.rb b/spec/lib/post_destroyer_spec.rb
index d0c91a334c5..a107d60a3e7 100644
--- a/spec/lib/post_destroyer_spec.rb
+++ b/spec/lib/post_destroyer_spec.rb
@@ -241,7 +241,7 @@ RSpec.describe PostDestroyer do
PostDestroyer.new(@user, @reply.reload).recover
end
- it "won't recover a non user-deleted post" do
+ it "does not recover a post that was not deleted by its author" do
PostRevisor.new(@reply).revise!(
admin,
{ raw: "this is a change to the post" },
@@ -251,7 +251,7 @@ RSpec.describe PostDestroyer do
expect(@reply.reload.raw).to eq("this is a change to the post")
end
- it "should increment the user's post count" do
+ it "increments the user's post count" do
PostDestroyer.new(@user, @reply).destroy
expect(@user.user_stat.topic_count).to eq(1)
expect(@user.user_stat.post_count).to eq(1)
@@ -283,7 +283,7 @@ RSpec.describe PostDestroyer do
end
context "when recovered by admin" do
- it "should set user_deleted to false" do
+ it "sets user_deleted to false" do
PostDestroyer.new(@user, @reply).destroy
expect(@reply.reload.user_deleted).to eq(true)
@@ -291,7 +291,7 @@ RSpec.describe PostDestroyer do
expect(@reply.reload.user_deleted).to eq(false)
end
- it "should increment the user's post count" do
+ it "increments the user's post count" do
PostDestroyer.new(moderator, @reply).destroy
expect(@user.reload.user_stat.topic_count).to eq(1)
expect(@user.user_stat.post_count).to eq(0)
@@ -883,7 +883,7 @@ RSpec.describe PostDestroyer do
expect(events[1][:params].first).to eq(first_post.topic)
end
- it "should not log a personal message view" do
+ it "does not log a personal message view" do
SiteSetting.log_personal_messages_views = true
Fabricate(:topic_web_hook)
StaffActionLogger.any_instance.expects(:log_check_personal_message).never
@@ -894,7 +894,7 @@ RSpec.describe PostDestroyer do
describe "deleting a post directly after a whisper" do
before { SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}" }
- it "should not set Topic#last_post_user_id to a whisperer" do
+ it "does not set Topic#last_post_user_id to a whisper's author" do
post_1 = create_post(topic: post.topic, user: moderator)
create_post(topic: post.topic, user: Fabricate(:user), post_type: Post.types[:whisper])
whisper_2 =
@@ -1042,7 +1042,7 @@ RSpec.describe PostDestroyer do
fab!(:coding_horror) { coding_horror }
fab!(:post) { Fabricate(:post, raw: "Hello @CodingHorror") }
- it "should feature the users again (in case they've changed)" do
+ it "enqueues an update of featured topic users" do
expect_enqueued_with(job: :feature_topic_users, args: { topic_id: post.topic_id }) do
PostDestroyer.new(moderator, post).destroy
end
@@ -1067,7 +1067,7 @@ RSpec.describe PostDestroyer do
).by(-1)
end
- it "should increase the post_number when there are deletion gaps" do
+ it "increases the post number across deletion gaps" do
PostDestroyer.new(moderator, reply).destroy
p = Fabricate(:post, user: post.user, topic: post.topic)
expect(p.post_number).to eq(3)
@@ -1094,7 +1094,7 @@ RSpec.describe PostDestroyer do
before { Jobs::SendSystemMessage.clear }
- it "should delete public post actions and agree with flags" do
+ it "deletes public post actions and agrees with flags" do
url = second_post.url
PostDestroyer.new(moderator, second_post).destroy
@@ -1127,14 +1127,14 @@ RSpec.describe PostDestroyer do
)
end
- it "should not send the flags_agreed_and_post_deleted message if it was deleted by system" do
+ it "does not send the flags_agreed_and_post_deleted message for system deletions" do
expect(ReviewableFlaggedPost.pending.count).to eq(1)
PostDestroyer.new(Discourse.system_user, second_post, context: "Automated testing").destroy
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
expect(ReviewableFlaggedPost.pending.count).to eq(0)
end
- it "should not send the flags_agreed_and_post_deleted message if it was deleted by author" do
+ it "does not send the flags_agreed_and_post_deleted message for author deletions" do
SiteSetting.delete_removed_posts_after = 0
expect(ReviewableFlaggedPost.pending.count).to eq(1)
PostDestroyer.new(second_post.user, second_post).destroy
@@ -1142,7 +1142,7 @@ RSpec.describe PostDestroyer do
expect(ReviewableFlaggedPost.pending.count).to eq(0)
end
- it "should not send the flags_agreed_and_post_deleted message if flags were ignored" do
+ it "does not send the flags_agreed_and_post_deleted message when flags were ignored" do
expect(ReviewableFlaggedPost.pending.count).to eq(1)
flag_result.reviewable.perform(moderator, :ignore_and_do_nothing)
second_post.reload
@@ -1152,7 +1152,7 @@ RSpec.describe PostDestroyer do
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
end
- it "should not send the flags_agreed_and_post_deleted message if defer_flags is true" do
+ it "does not send the flags_agreed_and_post_deleted message when flags are deferred" do
expect(ReviewableFlaggedPost.pending.count).to eq(1)
PostDestroyer.new(moderator, second_post, defer_flags: true).destroy
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
@@ -1187,7 +1187,7 @@ RSpec.describe PostDestroyer do
fab!(:custom_flag) { Fabricate(:flag, name: "custom flag", notify_type: true) }
let(:third_post) { Fabricate(:post, topic_id: post.topic_id) }
- it "should send message to user with correct translation" do
+ it "sends the user a translated message" do
PostActionCreator.new(
moderator,
third_post,
@@ -1221,7 +1221,7 @@ RSpec.describe PostDestroyer do
)
end
- it "should delete the user actions" do
+ it "deletes the user actions" do
like = create_user_action(UserAction::LIKE)
PostDestroyer.new(moderator, second_post).destroy
@@ -1237,12 +1237,12 @@ RSpec.describe PostDestroyer do
before { TopicLink.extract_from(second_post) }
- it "should destroy the topic links when moderator destroys the post" do
+ it "destroys topic links when a moderator destroys the post" do
PostDestroyer.new(moderator, second_post.reload).destroy
expect(topic.topic_links.count).to eq(0)
end
- it "should destroy the topic links when the user destroys the post" do
+ it "destroys topic links when the user destroys the post" do
PostDestroyer.new(second_post.user, second_post.reload).destroy
expect(topic.topic_links.count).to eq(0)
end
@@ -1260,7 +1260,7 @@ RSpec.describe PostDestroyer do
"http://#{base_url.host}/t/#{other_topic.slug}/#{other_topic.id}/#{other_post.post_number}"
end
- it "should destroy internal links when user deletes own post" do
+ it "destroys internal links when the author deletes the post" do
new_post = Post.create!(user: user, topic: topic, raw: "Link to other topic:\n\n#{url}\n")
TopicLink.extract_from(new_post)
@@ -1273,7 +1273,7 @@ RSpec.describe PostDestroyer do
expect(updated_link_counts.count).to eq(0)
end
- it "should destroy internal links when moderator deletes post" do
+ it "destroys internal links when a moderator deletes the post" do
new_post = create_post(user: user, topic: topic, raw: "Link to other topic:\n\n#{url}\n")
TopicLink.extract_from(new_post)
link_counts = TopicLink.counts_for(guardian, other_topic.reload, [other_post])
@@ -1522,7 +1522,7 @@ RSpec.describe PostDestroyer do
context "when deleting by the creator" do
before { PostDestroyer.new(user, last_reply).destroy }
- it "will reset the topic's bumped_at" do
+ it "resets the topic's bumped_at" do
topic.reload
expect(topic.bumped_at).to eq_time(second_last_reply.created_at)
@@ -1541,7 +1541,7 @@ RSpec.describe PostDestroyer do
context "when deleting by a staff user" do
before { PostDestroyer.new(moderator, last_reply).destroy }
- it "will reset the topic's bumped_at" do
+ it "resets the topic's bumped_at" do
topic.reload
expect(topic.bumped_at).to eq_time(second_last_reply.created_at)
diff --git a/spec/lib/post_merger_spec.rb b/spec/lib/post_merger_spec.rb
index f18ccdd038f..76e7ca253db 100644
--- a/spec/lib/post_merger_spec.rb
+++ b/spec/lib/post_merger_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe PostMerger do
let(:topic) { post.topic }
describe ".merge" do
- it "should merge posts into the latest post correctly" do
+ it "merges posts into the latest post" do
reply1 = create_post(topic: topic, raw: "The first reply", post_number: 2, user: user)
reply2 =
create_post(topic: topic, raw: "The second reply\nSecond line", post_number: 3, user: user)
@@ -36,7 +36,7 @@ RSpec.describe PostMerger do
)
end
- it "should not allow the first post in a topic to be merged" do
+ it "rejects merging the first post in a topic" do
post.update!(user: user)
reply1 = create_post(topic: topic, post_number: post.post_number, user: user)
reply2 = create_post(topic: topic, post_number: post.post_number, user: user)
@@ -46,7 +46,7 @@ RSpec.describe PostMerger do
)
end
- it "should only allow staff to merge posts" do
+ it "allows only staff to merge posts" do
reply1 = create_post(topic: topic, post_number: post.post_number, user: user)
reply2 = create_post(topic: topic, post_number: post.post_number, user: user)
@@ -78,7 +78,7 @@ RSpec.describe PostMerger do
expect(reply2.raw).to eq(merged_raw)
end
- it "should not allow posts from different topics to be merged" do
+ it "rejects merging posts from different topics" do
another_post = create_post(user: post.user)
expect { PostMerger.new(user, [another_post, post]).merge }.to raise_error(
@@ -87,7 +87,7 @@ RSpec.describe PostMerger do
)
end
- it "should not allow posts from different users to be merged" do
+ it "rejects merging posts from different users" do
another_post = create_post(user: user, topic_id: topic.id)
expect { PostMerger.new(user, [another_post, post]).merge }.to raise_error(
@@ -96,7 +96,7 @@ RSpec.describe PostMerger do
)
end
- it "should not allow posts with length greater than max_post_length" do
+ it "rejects merged posts exceeding max_post_length" do
SiteSetting.max_post_length = 60
reply1 = create_post(topic: topic, raw: "The first reply", post_number: 2, user: user)
diff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rb
index 8b1be486f33..d80aa019bb9 100644
--- a/spec/lib/post_revisor_spec.rb
+++ b/spec/lib/post_revisor_spec.rb
@@ -856,12 +856,12 @@ describe PostRevisor do
post.reload
end
- it "does create a new version after the edit window" do
+ it "increments the version after the edit window" do
expect(post.version).to eq(3)
expect(post.public_version).to eq(3)
end
- it "does create a new version after the edit window" do
+ it "records the revision time after the edit window" do
expect(post.last_version_at.to_i).to eq(new_revised_at.to_i)
end
end
@@ -877,7 +877,7 @@ describe PostRevisor do
let(:new_description) { "this is my new description." }
- it "should have no description by default" do
+ it "has no description by default" do
expect(category.description).to be_blank
end
@@ -1266,7 +1266,7 @@ describe PostRevisor do
describe "#publish_changes" do
let!(:post) { Fabricate(:post, topic: topic) }
- it "should publish topic changes to clients" do
+ it "publishes topic changes to clients" do
revisor = PostRevisor.new(topic.ordered_posts.first, topic)
message =
diff --git a/spec/lib/presence_channel_spec.rb b/spec/lib/presence_channel_spec.rb
index 3d5e41fe2ab..4119be619eb 100644
--- a/spec/lib/presence_channel_spec.rb
+++ b/spec/lib/presence_channel_spec.rb
@@ -165,7 +165,7 @@ RSpec.describe PresenceChannel do
expect(data[0]["leaving_user_ids"]).to contain_exactly(user.id)
end
- it "will return the messagebus last_id in the state payload" do
+ it "returns the MessageBus last_id in the state payload" do
channel = PresenceChannel.new("/test/public1")
channel.present(user_id: user.id, client_id: "a")
diff --git a/spec/lib/pretty_text/helpers_spec.rb b/spec/lib/pretty_text/helpers_spec.rb
index 6c623070af2..aabca6dbeab 100644
--- a/spec/lib/pretty_text/helpers_spec.rb
+++ b/spec/lib/pretty_text/helpers_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe PrettyText::Helpers do
expect(result["動画"][:url]).to eq(thumbnail.url)
end
- it "should return cdn url if available" do
+ it "returns the CDN URL when available" do
short_url = upload.short_url
result = PrettyText::Helpers.lookup_upload_urls([short_url])
expect(result[short_url][:url]).to eq(upload.url)
diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rb
index 4a3aec39c77..784911787f6 100644
--- a/spec/lib/pretty_text_spec.rb
+++ b/spec/lib/pretty_text_spec.rb
@@ -398,7 +398,7 @@ RSpec.describe PrettyText do
context "with letter avatar" do
context "with subfolder" do
- it "should have correct avatar url" do
+ it "uses the correct avatar URL" do
set_subfolder "/forum"
md = <<~MD
[quote="#{user.username}, post:123, topic:456, full:true"]
@@ -418,7 +418,7 @@ RSpec.describe PrettyText do
)
end
- it "should handle 3 mentions in a row" do
+ it "handles three consecutive mentions" do
expect(
PrettyText.cook("@hello @hello @hello"),
).to match_html "<p><span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span></p>"
@@ -508,16 +508,16 @@ RSpec.describe PrettyText do
context "when mentions are disabled" do
before { SiteSetting.enable_mentions = false }
- it "should not convert mentions to links" do
+ it "does not convert mentions to links" do
expect(PrettyText.cook("hi @user")).to eq("<p>hi @user</p>")
end
end
- it "can handle mentions inside a hyperlink" do
+ it "handles mentions inside an HTML hyperlink" do
expect(PrettyText.cook("<a> @inner</a> ")).to match_html "<p><a> @inner</a></p>"
end
- it "can handle mentions inside a hyperlink" do
+ it "handles mentions inside a Markdown hyperlink" do
expect(
PrettyText.cook("[link @inner](http://site.com)"),
).to match_html '<p><a href="http://site.com" rel="noopener nofollow ugc">link @inner</a></p>'
@@ -529,19 +529,19 @@ RSpec.describe PrettyText do
)
end
- it "should handle group mentions with a hyphen and without" do
+ it "handles group mentions with and without a hyphen" do
expect(
PrettyText.cook("@hello @hello-hello"),
).to match_html "<p><span class=\"mention\">@hello</span> <span class=\"mention\">@hello-hello</span></p>"
end
- it "should allow for @mentions to have punctuation" do
+ it "allows punctuation after mentions" do
expect(PrettyText.cook("hello @bob's @bob,@bob; @bob\"")).to match_html(
"<p>hello <span class=\"mention\">@bob</span>'s <span class=\"mention\">@bob</span>,<span class=\"mention\">@bob</span>; <span class=\"mention\">@bob</span>\"</p>",
)
end
- it "should not treat a medium link as a mention" do
+ it "does not treat a Medium link as a mention" do
expect(PrettyText.cook(". http://test/@sam")).not_to include("mention")
end
@@ -612,7 +612,7 @@ RSpec.describe PrettyText do
end
describe "code fences" do
- it "indents code correctly" do
+ it "indents code after preceding text" do
code = <<~MD
X
```
@@ -696,7 +696,7 @@ RSpec.describe PrettyText do
).to match_html("<pre data-code-foo='1'></pre>")
end
- it "indents code correctly" do
+ it "preserves indentation after a blank line" do
code = "X\n```\n\n #\n x\n```"
cooked = PrettyText.cook(code)
expect(cooked).to match_html(
@@ -713,7 +713,7 @@ RSpec.describe PrettyText do
Discourse.redis.flushdb
end
- it "strips out unicode bidirectional (bidi) override characters and replaces with a highlighted span" do
+ it "highlights Unicode bidirectional override characters while cooking" do
code = <<~MD
X
```auto
@@ -738,7 +738,7 @@ RSpec.describe PrettyText do
expect(cooked).to eq(html.strip)
end
- it "strips out unicode bidirectional (bidi) override characters and replaces with a highlighted span" do
+ it "highlights Unicode bidirectional override characters during cleanup" do
cooked = <<~HTML
<p>X</p>
<pre><code class="lang-auto">var isAdmin = false;
@@ -829,17 +829,17 @@ RSpec.describe PrettyText do
SiteSetting.exclude_rel_nofollow_domains = "foo.com|bar.com"
end
- it "should inject nofollow in all user provided links" do
+ it "injects nofollow into user-provided links" do
expect(PrettyText.cook('<a href="http://cnn.com">cnn</a>')).to match(/noopener nofollow ugc/)
end
- it "should not inject nofollow in all local links" do
+ it "does not inject nofollow into local links" do
expect(
PrettyText.cook("<a href='#{Discourse.base_url}/test.html'>cnn</a>") !~ /nofollow ugc/,
).to eq(true)
end
- it "should not inject nofollow in all subdomain links" do
+ it "does not inject nofollow into subdomain links" do
expect(
PrettyText.cook(
"<a href='#{Discourse.base_url.sub("http://", "http://bla.")}/test.html'>cnn</a>",
@@ -847,7 +847,7 @@ RSpec.describe PrettyText do
).to eq(true)
end
- it "should inject nofollow in all non subdomain links" do
+ it "injects nofollow into links outside the subdomain" do
expect(
PrettyText.cook(
"<a href='#{Discourse.base_url.sub("http://", "http://bla")}/test.html'>cnn</a>",
@@ -855,36 +855,36 @@ RSpec.describe PrettyText do
).to match(/nofollow ugc/)
end
- it "should not inject nofollow for foo.com" do
+ it "does not inject nofollow for foo.com" do
expect(PrettyText.cook("<a href='http://foo.com/test.html'>cnn</a>") !~ /nofollow ugc/).to eq(
true,
)
end
- it "should inject nofollow for afoo.com" do
+ it "injects nofollow for afoo.com" do
expect(PrettyText.cook("<a href='http://afoo.com/test.html'>cnn</a>")).to match(
/nofollow ugc/,
)
end
- it "should not inject nofollow for bar.foo.com" do
+ it "does not inject nofollow for bar.foo.com" do
expect(
PrettyText.cook("<a href='http://bar.foo.com/test.html'>cnn</a>") !~ /nofollow ugc/,
).to eq(true)
end
- it "should not inject nofollow if omit_nofollow option is given" do
+ it "does not inject nofollow when omit_nofollow is enabled" do
expect(
PrettyText.cook('<a href="http://cnn.com">cnn</a>', omit_nofollow: true) !~ /nofollow ugc/,
).to eq(true)
end
- it "adds the noopener attribute even if omit_nofollow option is given" do
+ it "adds noopener when omit_nofollow is enabled" do
raw_html = '<a href="https://www.mysite.com/" target="_blank">Check out my site!</a>'
expect(PrettyText.cook(raw_html, omit_nofollow: true)).to match(/noopener/)
end
- it "adds the noopener attribute even if omit_nofollow option is given" do
+ it "adds noopener when omit_nofollow is disabled" do
raw_html = '<a href="https://www.mysite.com/" target="_blank">Check out my site!</a>'
expect(PrettyText.cook(raw_html, omit_nofollow: false)).to match(/noopener nofollow ugc/)
end
@@ -901,12 +901,12 @@ RSpec.describe PrettyText do
end
context "with images" do
- it "should dump images" do
+ it "dumps images" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif'>", 100)).to eq("[image]")
end
context "with alt tags" do
- it "should keep alt tags" do
+ it "keeps alt attributes" do
expect(
PrettyText.excerpt(
"<img src='http://cnn.com/a.gif' alt='car' title='my big car'>",
@@ -916,7 +916,7 @@ RSpec.describe PrettyText do
end
describe "when alt tag is empty" do
- it "should not keep alt tags" do
+ it "does not keep alt attributes" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' alt>", 100)).to eq(
"[#{I18n.t("excerpt_image")}]",
)
@@ -925,14 +925,14 @@ RSpec.describe PrettyText do
end
context "with title tags" do
- it "should keep title tags" do
+ it "keeps title attributes" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' title='car'>", 100)).to eq(
"[car]",
)
end
describe "when title tag is empty" do
- it "should not keep title tags" do
+ it "does not keep title attributes" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' title>", 100)).to eq(
"[#{I18n.t("excerpt_image")}]",
)
@@ -940,7 +940,7 @@ RSpec.describe PrettyText do
end
end
- it "should convert images to markdown if the option is set" do
+ it "converts images to Markdown when configured" do
expect(
PrettyText.excerpt(
"<img src='http://cnn.com/a.gif' title='car'>",
@@ -956,13 +956,13 @@ RSpec.describe PrettyText do
).to match_html "▶ expand"
end
- it "should remove meta information" do
+ it "removes metadata" do
expect(
PrettyText.excerpt(wrapped_image, 100),
).to match_html "<a href='//localhost:3000/uploads/default/4399/33691397e78b4d75.png' class='lightbox' title='Screen Shot 2014-04-14 at 9.47.10 PM.png'>[image]</a>"
end
- it "should strip images when option is set" do
+ it "strips images when configured" do
expect(
PrettyText.excerpt("<img src='http://cnn.com/a.gif'>", 100, strip_images: true),
).to be_blank
@@ -975,7 +975,7 @@ RSpec.describe PrettyText do
).to eq("Hello world!")
end
- it "should strip images, but keep emojis when option is set" do
+ it "strips images but keeps emoji when configured" do
emoji_image =
"<img src='/images/emoji/twitter/heart.png?v=#{Emoji::EMOJI_VERSION}' title=':heart:' class='emoji' alt=':heart:' loading='lazy' width='20' height='20'>"
html = "<img src='http://cnn.com/a.gif'> Hello world #{emoji_image}"
@@ -988,7 +988,7 @@ RSpec.describe PrettyText do
end
context "with emojis" do
- it "should remove broken emoji" do
+ it "removes broken emoji" do
html = <<~HTML
<img src=\"//localhost:3000/images/emoji/twitter/bike.png?v=#{Emoji::EMOJI_VERSION}\" title=\":bike:\" class=\"emoji\" alt=\":bike:\" loading=\"lazy\" width=\"20\" height=\"20\"> <img src=\"//localhost:3000/images/emoji/twitter/cat.png?v=#{Emoji::EMOJI_VERSION}\" title=\":cat:\" class=\"emoji\" alt=\":cat:\" loading=\"lazy\" width=\"20\" height=\"20\"> <img src=\"//localhost:3000/images/emoji/twitter/discourse.png?v=#{Emoji::EMOJI_VERSION}\" title=\":discourse:\" class=\"emoji\" alt=\":discourse:\" loading=\"lazy\" width=\"20\" height=\"20\">
HTML
@@ -1003,38 +1003,38 @@ RSpec.describe PrettyText do
end
end
- it "should have an option to strip links" do
+ it "can strip links" do
expect(PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>", 100, strip_links: true)).to eq(
"cnn",
)
end
- it "should preserve links" do
+ it "preserves links" do
expect(
PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>", 100),
).to match_html "<a href='http://cnn.com'>cnn</a>"
end
- it "should deal with special keys properly" do
+ it "handles special keys" do
expect(PrettyText.excerpt("<pre><b></pre>", 100)).to eq("")
end
- it "should truncate stuff properly" do
+ it "truncates content correctly" do
expect(PrettyText.excerpt("hello world", 5)).to eq("hello&hellip;")
expect(PrettyText.excerpt("<p>hello</p><p>world</p>", 6)).to eq("hello w&hellip;")
end
- it "should insert a space between to Ps" do
+ it "inserts a space between paragraphs" do
expect(PrettyText.excerpt("<p>a</p><p>b</p>", 5)).to eq("a b")
end
- it "should strip quotes" do
+ it "strips quotes" do
expect(PrettyText.excerpt("<aside class='quote'><p>a</p><p>b</p></aside>boom", 5)).to eq(
"boom",
)
end
- it "should not count the surrounds of a link" do
+ it "does not count link markup" do
expect(
PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>", 3),
).to match_html "<a href='http://cnn.com'>cnn</a>"
@@ -1046,7 +1046,7 @@ RSpec.describe PrettyText do
).to match_html "<a href='http://cnn.com'>cn...</a>"
end
- it "should truncate links" do
+ it "truncates links" do
expect(
PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>", 2),
).to match_html "<a href='http://cnn.com'>cn&hellip;</a>"
@@ -1070,11 +1070,11 @@ RSpec.describe PrettyText do
PrettyText.extract_links(text).map(&:url).to_a
end
- it "should be able to extract links" do
+ it "extracts links" do
expect(extract_urls("<a href='http://cnn.com'>http://bla.com</a>")).to eq(["http://cnn.com"])
end
- it "should extract links to topics" do
+ it "extracts topic links" do
expect(extract_urls("<aside class=\"quote\" data-topic=\"321\">aside</aside>")).to eq(
["/t/321"],
)
@@ -1111,7 +1111,7 @@ RSpec.describe PrettyText do
end
context "when lazy-videos" do
- it "should extract youtube url" do
+ it "extracts YouTube URLs" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"yXEuEUQIP3Q\" data-video-title=\"Mister Rogers defending PBS to the US Senate\" data-provider-name=\"youtube\"></div>",
@@ -1119,7 +1119,7 @@ RSpec.describe PrettyText do
).to eq(["https://www.youtube.com/watch?v=yXEuEUQIP3Q"])
end
- it "should extract vimeo url" do
+ it "extracts Vimeo URLs" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"786646692\" data-video-title=\"Dear Rich\" data-provider-name=\"vimeo\"></div>",
@@ -1127,7 +1127,7 @@ RSpec.describe PrettyText do
).to eq(["https://vimeo.com/786646692"])
end
- it "should extract tiktok url" do
+ it "extracts TikTok URLs" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"6718335390845095173\" data-video-title=\"Scramble up ur name &amp;amp; I’ll try to guess it😍❤️ #foryoupage #petsoftiktok...\" data-provider-name=\"tiktok\"></div>",
@@ -1136,17 +1136,17 @@ RSpec.describe PrettyText do
end
end
- it "should extract links to posts" do
+ it "extracts post links" do
expect(
extract_urls("<aside class=\"quote\" data-topic=\"1234\" data-post=\"4567\">aside</aside>"),
).to eq(["/t/1234/4567"])
end
- it "should not extract links to anchors" do
+ it "does not extract anchor links" do
expect(extract_urls("<a href='#tos'>TOS</a>")).to eq([])
end
- it "should not extract links inside quotes" do
+ it "does not extract links inside quotes" do
links =
PrettyText.extract_links(
"
@@ -1168,7 +1168,7 @@ RSpec.describe PrettyText do
)
end
- it "should not extract links inside oneboxes" do
+ it "does not extract links inside oneboxes" do
onebox = <<~HTML
<aside class="onebox twitterstatus" data-onebox-src="https://twitter.com/EDBPostgres/status/1402528437441634306">
<header class="source">
@@ -1186,7 +1186,7 @@ RSpec.describe PrettyText do
)
end
- it "should not preserve tags in code blocks" do
+ it "does not preserve tags in code blocks" do
expect(
PrettyText.excerpt(
"<pre><code class='handlebars'>&lt;h3&gt;Hours&lt;/h3&gt;</code></pre>",
@@ -1195,7 +1195,7 @@ RSpec.describe PrettyText do
).to eq("&lt;h3&gt;Hours&lt;/h3&gt;")
end
- it "should handle nil" do
+ it "handles nil" do
expect(PrettyText.excerpt(nil, 100)).to eq("")
end
@@ -1252,7 +1252,7 @@ RSpec.describe PrettyText do
expect(PrettyText.excerpt("&#39;", 500, text_entities: true)).to eq("'")
end
- it "should have an option to preserve emoji images" do
+ it "can preserve emoji images" do
emoji_image =
"<img src='/images/emoji/twitter/heart.png?v=#{Emoji::EMOJI_VERSION}' title=':heart:' class='emoji' alt=':heart:' loading='lazy' width='20' height='20'>"
expect(PrettyText.excerpt(emoji_image, 100, keep_emoji_images: true)).to match_html(
@@ -1260,7 +1260,7 @@ RSpec.describe PrettyText do
)
end
- it "should have an option to remap emoji to code points" do
+ it "can remap emoji to code points" do
emoji_image =
"I <img src='/images/emoji/twitter/heart.png?v=#{Emoji::EMOJI_VERSION}' title=':heart:' class='emoji' alt=':heart:' loading='lazy' width='20' height='20'> you <img src='/images/emoji/twitter/heart.png?v=#{Emoji::EMOJI_VERSION}' title=':unknown:' class='emoji' alt=':unknown:' loading='lazy' width='20' height='20'> "
expect(PrettyText.excerpt(emoji_image, 100, remap_emoji: true)).to match_html(
@@ -1268,14 +1268,14 @@ RSpec.describe PrettyText do
)
end
- it "should have an option to preserve emoji codes" do
+ it "can preserve emoji codes" do
emoji_code =
"<img src='/images/emoji/twitter/heart.png?v=#{Emoji::EMOJI_VERSION}' title=':heart:' class='emoji' alt=':heart:' loading='lazy' width='20' height='20'>"
expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:")
end
context "with option to preserve onebox source" do
- it "should return the right excerpt" do
+ it "returns the expected excerpt" do
onebox =
"<aside class=\"onebox allowlistedgeneric\">\n <header class=\"source\">\n <a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>\n </header>\n <article class=\"onebox-body\">\n <img src=\"https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/gerhard/200/70381_1.png\" width=\"\" height=\"\" class=\"thumbnail\">\n\n<h3><a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">Infrequent translation updates in stable branch</a></h3>\n\n<p>Well, there's an Italian translation for \"New Topic\" in beta, it's been there since November 2014 and it works here on meta. Do you have any plugins installed? Try disabling them. I'm quite confident that it's either a plugin or a site...</p>\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n\n\n"
expected =
@@ -1288,7 +1288,7 @@ RSpec.describe PrettyText do
).to eq("#{expected}\n\n#{expected}")
end
- it "should continue to strip quotes" do
+ it "continues to strip quotes" do
expect(
PrettyText.excerpt(
"<aside class='quote'><p>a</p><p>b</p></aside>boom",
@@ -1299,7 +1299,7 @@ RSpec.describe PrettyText do
end
end
- it "should strip audio/video" do
+ it "strips audio and video" do
html = <<~HTML
<audio controls>
<source src="https://awebsite.com/audio.mp3"><a href="https://awebsite.com/audio.mp3">https://awebsite.com/audio.mp3</a></source>
@@ -1904,7 +1904,7 @@ RSpec.describe PrettyText do
)
end
- it "should not treat a non emoji as an emoji" do
+ it "does not treat a non-emoji as an emoji" do
expect(PrettyText.cook(":email,class_name:")).not_to include("emoji")
end
@@ -2126,7 +2126,7 @@ HTML
expect(PrettyText.cook(":smile::sunny:")).to eq(expected.strip)
end
- it "handles emoji boundaries correctly" do
+ it "handles skin-tone emoji boundaries" do
cooked = PrettyText.cook("a,:man:t2:,b")
expected =
"<p>a,<img src=\"/images/emoji/twitter/man/2.png?v=#{Emoji::EMOJI_VERSION}\" title=\":man:t2:\" class=\"emoji\" alt=\":man:t2:\" loading=\"lazy\" width=\"20\" height=\"20\">,b</p>"
@@ -2144,7 +2144,7 @@ HTML
expect(cooked.split("img").length - 1).to eq(3)
end
- it "handles emoji boundaries correctly" do
+ it "handles translated emoji boundaries" do
expect(PrettyText.cook(",:)")).to include("emoji")
expect(PrettyText.cook(":-)\n")).to include("emoji")
expect(PrettyText.cook("a :)")).to include("emoji")
@@ -2184,7 +2184,7 @@ HTML
)
end
- it "won't break links by censoring them." do
+ it "does not break links while censoring them" do
expect_cooked_match(
"The link still works. [whiz](http://www.whiz.com)",
'<p>The link still works. <a href="http://www.whiz.com" rel="noopener nofollow ugc">■■■■</a></p>',
@@ -2598,7 +2598,7 @@ HTML
expect(cooked).to eq(html)
end
- it "should sanitize the html" do
+ it "sanitizes unknown HTML elements" do
expect(PrettyText.cook("<test>alert(42)</test>")).to eq "<p>alert(42)</p>"
end
@@ -2613,15 +2613,15 @@ HTML
)
end
- it "should not onebox magically linked urls" do
+ it "does not onebox magically linked URLs" do
expect(PrettyText.cook("[url]site.com[/url]")).not_to include("onebox")
end
- it "should sanitize the html" do
+ it "sanitizes HTML attributes" do
expect(PrettyText.cook("<p class='hi'>hi</p>")).to eq "<p>hi</p>"
end
- it "should strip SCRIPT" do
+ it "strips script elements" do
expect(PrettyText.cook("<script>alert(42)</script>")).to eq ""
expect(PrettyText.cook("<div><script>alert(42)</script></div>")).to eq "<div></div>"
@@ -2635,7 +2635,7 @@ HTML
).to eq "<div></div>"
end
- it "should allow sanitize bypass" do
+ it "allows sanitization to be bypassed" do
expect(
PrettyText.cook("<test>alert(42)</test>", sanitize: false),
).to eq "<p><test>alert(42)</test></p>"
diff --git a/spec/lib/rate_limiter/limit_exceeded_spec.rb b/spec/lib/rate_limiter/limit_exceeded_spec.rb
index a9cfa38649f..77c239f8042 100644
--- a/spec/lib/rate_limiter/limit_exceeded_spec.rb
+++ b/spec/lib/rate_limiter/limit_exceeded_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe RateLimiter::LimitExceeded do
describe "#description" do
- it "should return the right description" do
+ it "returns the rate-limit description" do
[
[3, I18n.t("rate_limiter.short_time")],
[59, I18n.t("rate_limiter.seconds", count: 59)],
diff --git a/spec/lib/rate_limiter_spec.rb b/spec/lib/rate_limiter_spec.rb
index 4db2905b51e..9cbe9a6f2e4 100644
--- a/spec/lib/rate_limiter_spec.rb
+++ b/spec/lib/rate_limiter_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe RateLimiter do
rate_limiter.performed!
end
- it "should be disabled" do
+ it "is disabled" do
expect(RateLimiter.disabled?).to eq(true)
end
@@ -108,7 +108,7 @@ RSpec.describe RateLimiter do
end
context "when never done" do
- it "should perform right away" do
+ it "allows performing immediately" do
expect(rate_limiter.can_perform?).to eq(true)
end
@@ -128,7 +128,7 @@ RSpec.describe RateLimiter do
end
context "when max is less than or equal to zero" do
- it "should raise the right error" do
+ it "rejects nonpositive and missing limits" do
[-1, 0, nil].each do |max|
expect do RateLimiter.new(user, "a", max, 60).performed! end.to raise_error(
RateLimiter::LimitExceeded,
diff --git a/spec/lib/retrieve_title_spec.rb b/spec/lib/retrieve_title_spec.rb
index 74815cbdf9f..cec5180c8d4 100644
--- a/spec/lib/retrieve_title_spec.rb
+++ b/spec/lib/retrieve_title_spec.rb
@@ -2,19 +2,19 @@
RSpec.describe RetrieveTitle do
describe ".extract_title" do
- it "will extract the value from the title tag" do
+ it "extracts the title tag's value" do
title = RetrieveTitle.extract_title("<html><title>My Cool Title</title></html>")
expect(title).to eq("My Cool Title")
end
- it "will strip whitespace" do
+ it "strips surrounding whitespace" do
title = RetrieveTitle.extract_title("<html><title> Another Title\n\n </title></html>")
expect(title).to eq("Another Title")
end
- it "will pick og:title if title is missing" do
+ it "uses og:title when the title tag is missing" do
title = RetrieveTitle.extract_title(<<~HTML)
<html>
<meta property="og:title" content="Good Title"
@@ -24,7 +24,7 @@ RSpec.describe RetrieveTitle do
expect(title).to eq("Good Title")
end
- it "will prefer the title over the opengraph tag" do
+ it "prefers the title tag over og:title" do
title = RetrieveTitle.extract_title(<<~HTML)
<html>
<title>Good Title</title>
@@ -35,7 +35,7 @@ RSpec.describe RetrieveTitle do
expect(title).to eq("Good Title")
end
- it "will parse a YouTube url from javascript" do
+ it "parses a YouTube URL from JavaScript" do
title = RetrieveTitle.extract_title(<<~HTML)
<html>
<title>YouTube</title>
@@ -45,7 +45,7 @@ RSpec.describe RetrieveTitle do
expect(title).to eq("Video Title")
end
- it "will not exception out for invalid html" do
+ it "handles invalid HTML" do
attributes = (1..1000).map { |x| " attr#{x}='1' " }.join
title = RetrieveTitle.extract_title <<~HTML
<html>
@@ -190,13 +190,13 @@ RSpec.describe RetrieveTitle do
expect(RetrieveTitle.crawl("https://example.com")).to eq(nil)
end
- it "it raises errors other than Net::ReadTimeout, e.g. NoMethodError" do
+ it "raises errors other than Net::ReadTimeout" do
stub_request(:get, "https://example.com").to_raise(NoMethodError)
expect { RetrieveTitle.crawl("https://example.com") }.to raise_error(NoMethodError)
end
- it "it ignores Net::ReadTimeout errors" do
+ it "ignores Net::ReadTimeout errors" do
stub_request(:get, "https://example.com").to_raise(Net::ReadTimeout)
expect(RetrieveTitle.crawl("https://example.com")).to eq(nil)
diff --git a/spec/lib/s3_helper_spec.rb b/spec/lib/s3_helper_spec.rb
index 2a142279ffa..0c20b77638a 100644
--- a/spec/lib/s3_helper_spec.rb
+++ b/spec/lib/s3_helper_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe "S3Helper" do
end
end
- it "should prefix bucket folder path only if not exists" do
+ it "prefixes the bucket folder path only when it is missing" do
s3_helper = S3Helper.new("bucket/folder_path", "", client: client)
object1 = s3_helper.object("original/1X/def.xyz")
@@ -86,7 +86,7 @@ RSpec.describe "S3Helper" do
expect(object1.key).to eq(object2.key)
end
- it "should not prefix the bucket folder path if the key begins with the temporary upload prefix" do
+ it "does not prefix keys that begin with the temporary upload prefix" do
s3_helper = S3Helper.new("bucket/folder_path", "", client: client)
object1 = s3_helper.object("original/1X/def.xyz")
@@ -241,7 +241,7 @@ RSpec.describe "S3Helper" do
describe "#delete_objects" do
let(:s3_helper) { S3Helper.new("test-bucket", "", client: client) }
- it "works" do
+ it "deletes the object from S3" do
# The S3::Client with `stub_responses: true` includes validation of requests.
# If the request were invalid, this spec would raise an error
s3_helper.delete_objects(%w[object/one.txt object/two.txt])
diff --git a/spec/lib/s3_inventory_spec.rb b/spec/lib/s3_inventory_spec.rb
index 333cfcd0062..091e11564f6 100644
--- a/spec/lib/s3_inventory_spec.rb
+++ b/spec/lib/s3_inventory_spec.rb
@@ -19,13 +19,13 @@ RSpec.describe S3Inventory do
inventory.stubs(:cleanup!)
end
- it "should raise error if an inventory file is not found" do
+ it "raises an error when an inventory file is missing" do
inventory.s3_client.stub_responses(:list_objects, contents: [])
output = capture_stdout { inventory.backfill_etags_and_list_missing }
expect(output).to eq("Failed to list inventory from S3\n")
end
- it "should forward custom s3 options to the S3Helper when initializing" do
+ it "forwards custom S3 options to S3Helper during initialization" do
inventory =
S3Inventory.new(
:upload,
@@ -75,7 +75,7 @@ RSpec.describe S3Inventory do
inventory.expects(:inventory_date).times(2).returns(Time.now)
end
- it "should display missing uploads correctly" do
+ it "displays missing uploads correctly" do
output = capture_stdout { inventory.backfill_etags_and_list_missing }
expect(output).to eq(
@@ -84,7 +84,7 @@ RSpec.describe S3Inventory do
expect(Discourse.stats.get("missing_s3_uploads")).to eq(6)
end
- it "should detect when a url match exists with a different etag" do
+ it "detects a URL match with a different ETag" do
upload_with_differing_tag_1 = Upload.find_by(etag: "defcaac0b4aca535c284e95f30d608d0")
upload_with_differing_tag_1.update_columns(etag: "somethingelse")
@@ -140,7 +140,7 @@ RSpec.describe S3Inventory do
end
end
- it "should backfill etags to uploads table correctly" do
+ it "backfills ETags in the uploads table" do
files = [
[
"#{Discourse.store.absolute_base_url}/uploads/default/original/1X/0184537a4f419224404d013414e913a4f56018f2.jpg",
@@ -176,7 +176,7 @@ RSpec.describe S3Inventory do
BackupMetadata.update_last_restore_date(Time.now)
end
- it "should run if inventory files are at least #{described_class::WAIT_AFTER_RESTORE_DAYS.days} days older than the last restore date" do
+ it "runs when inventory files are old enough relative to the last restore" do
inventory.s3_client.stub_responses(
:list_objects_v2,
{
@@ -196,7 +196,7 @@ RSpec.describe S3Inventory do
capture_stdout { inventory.backfill_etags_and_list_missing }
end
- it "should not run if inventory files are not at least #{described_class::WAIT_AFTER_RESTORE_DAYS.days} days older than the last restore date and reset stats count" do
+ it "does not run for newer inventory files and resets the statistics count" do
Discourse.stats.set("missing_s3_uploads", 2)
inventory.s3_client.stub_responses(
@@ -220,7 +220,7 @@ RSpec.describe S3Inventory do
end
end
- it "should work when passed preloaded data" do
+ it "uses preloaded data when provided" do
freeze_time
CSV.foreach(csv_filename, headers: false) do |row|
diff --git a/spec/lib/schema_settings_object_validator_spec.rb b/spec/lib/schema_settings_object_validator_spec.rb
index 24bebb0611f..827735c0b57 100644
--- a/spec/lib/schema_settings_object_validator_spec.rb
+++ b/spec/lib/schema_settings_object_validator_spec.rb
@@ -63,7 +63,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
describe ".validate_objects" do
- it "should return the right array of humanized error messages for objects that are invalid" do
+ it "returns humanized error messages for invalid objects" do
schema = {
name: "section",
properties: {
@@ -133,7 +133,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
describe "#validate" do
- it "should return the right hash of error messages when properties are required but missing" do
+ it "returns errors when required properties are missing" do
schema = {
name: "section",
properties: {
@@ -231,13 +231,13 @@ RSpec.describe SchemaSettingsObjectValidator do
property
end
- it "should not return any error messages when the value of the property is in the enum" do
+ it "returns no errors when the value is in the enum" do
expect(
described_class.new(schema: schema, object: { enum_property: "choice 1" }).validate,
).to eq({})
end
- it "should return the right hash of error messages when value of property is not in the enum" do
+ it "returns errors when the value is not in the enum" do
errors =
described_class.new(schema: schema, object: { enum_property: "random_value" }).validate
@@ -248,11 +248,11 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should not return any error messages when enum property is not present but is not required" do
+ it "returns no errors when an optional enum property is missing" do
expect(described_class.new(schema: schema(required: false), object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when enum property is not present and is required" do
+ it "returns errors when a required enum property is missing" do
errors = described_class.new(schema: schema(required: true), object: {}).validate
expect(errors.keys).to eq(["/enum_property"])
@@ -264,7 +264,7 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for boolean properties" do
let(:schema) { { name: "section", properties: { boolean_property: { type: "boolean" } } } }
- it "should not return any error messages when the value of the property is of type boolean" do
+ it "returns no errors for a boolean value" do
expect(
described_class.new(schema: schema, object: { boolean_property: true }).validate,
).to eq({})
@@ -274,7 +274,7 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should return the right hash of error messages when value of property is not of type boolean" do
+ it "returns errors for a non-boolean value" do
errors =
described_class.new(schema: schema, object: { boolean_property: "string" }).validate
@@ -286,7 +286,7 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for float properties" do
let(:schema) { { name: "section", properties: { float_property: { type: "float" } } } }
- it "should not return any error messages when the value of the property is of type integer or float" do
+ it "returns no errors for an integer or float value" do
expect(described_class.new(schema: schema, object: { float_property: 1.5 }).validate).to eq(
{},
)
@@ -296,11 +296,11 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when an optional value is missing" do
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when a required value is missing" do
schema = {
name: "section",
properties: {
@@ -316,14 +316,14 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/float_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not of type float" do
+ it "returns errors for a non-float value" do
errors = described_class.new(schema: schema, object: { float_property: "string" }).validate
expect(errors.keys).to eq(["/float_property"])
expect(errors["/float_property"].full_messages).to contain_exactly("must be a float")
end
- it "should return the right hash of error messages when integer property does not satisfy min or max validations" do
+ it "returns errors when the number fails minimum or maximum validation" do
schema = {
name: "section",
properties: {
@@ -358,17 +358,17 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for integer properties" do
let(:schema) { { name: "section", properties: { integer_property: { type: "integer" } } } }
- it "should not return any error messages when the value of the property is of type integer" do
+ it "returns no errors for an integer value" do
expect(described_class.new(schema: schema, object: { integer_property: 1 }).validate).to eq(
{},
)
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional integer is missing" do
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required integer is missing" do
schema = {
name: "section",
properties: {
@@ -384,7 +384,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/integer_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not of type integer" do
+ it "returns errors for a non-integer value" do
errors =
described_class.new(schema: schema, object: { integer_property: "string" }).validate
@@ -397,7 +397,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/integer_property"].full_messages).to contain_exactly("must be an integer")
end
- it "should not return any error messages when the value of the integer property satisfies min and max validations" do
+ it "returns no errors when the integer satisfies range validation" do
schema = {
name: "section",
properties: {
@@ -416,7 +416,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when integer property does not satisfy min or max validations" do
+ it "returns errors when the integer fails range validation" do
schema = {
name: "section",
properties: {
@@ -451,17 +451,17 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for string properties" do
let(:schema) { { name: "section", properties: { string_property: { type: "string" } } } }
- it "should not return any error messages when the value of the property is of type string" do
+ it "returns no errors for a string value" do
expect(
described_class.new(schema: schema, object: { string_property: "string" }).validate,
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional string is missing" do
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required string is missing" do
schema = {
name: "section",
properties: {
@@ -477,7 +477,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/string_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not of type string" do
+ it "returns errors for a non-string value" do
schema = { name: "section", properties: { string_property: { type: "string" } } }
errors = described_class.new(schema: schema, object: { string_property: 1 }).validate
@@ -485,7 +485,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/string_property"].full_messages).to contain_exactly("must be a string")
end
- it "should not return an empty hash when string property satisfy url validation" do
+ it "returns no errors when the string is a valid URL" do
schema = {
name: "section",
properties: {
@@ -517,7 +517,7 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should return the right hash of error messages when string property does not statisfy url validation" do
+ it "returns errors when the string is not a valid URL" do
schema = {
name: "section",
properties: {
@@ -537,7 +537,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/string_property"].full_messages).to contain_exactly("must be a valid URL")
end
- it "should not return any error messages when the value of the string property satisfies min_length and max_length validations" do
+ it "returns no errors when the string satisfies length validation" do
schema = {
name: "section",
properties: {
@@ -556,7 +556,7 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should return the right hash of error messages when string property does not satisfy min_length or max_length validations" do
+ it "returns errors when the string fails length validation" do
schema = {
name: "section",
properties: {
@@ -590,7 +590,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
context "for topic properties" do
- it "should not return any error message when the value of the property is a valid id of a topic record" do
+ it "returns no errors for a valid topic ID" do
topic = Fabricate(:topic)
schema = { name: "section", properties: { topic_property: { type: "topic" } } }
@@ -600,12 +600,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional topic ID is missing" do
schema = { name: "section", properties: { topic_property: { type: "topic" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required topic ID is missing" do
schema = {
name: "section",
properties: {
@@ -621,7 +621,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/topic_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not an integer" do
+ it "returns errors when the topic ID is not an integer" do
schema = { name: "section", properties: { topic_property: { type: "topic" } } }
errors = described_class.new(schema: schema, object: { topic_property: "string" }).validate
@@ -633,7 +633,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property is not a valid id of a topic record" do
+ it "returns errors for an unknown topic ID" do
schema = {
name: "section",
properties: {
@@ -682,7 +682,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
context "for upload properties" do
- it "should not return any error message when the value of the property is a valid id of a upload record" do
+ it "returns no errors for a valid upload ID" do
upload = Fabricate(:upload)
schema = { name: "section", properties: { upload_property: { type: "upload" } } }
@@ -692,12 +692,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional upload ID is missing" do
schema = { name: "section", properties: { upload_property: { type: "upload" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required upload ID is missing" do
schema = {
name: "section",
properties: {
@@ -713,7 +713,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/upload_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not an integer" do
+ it "returns errors when the upload ID is not an integer" do
schema = { name: "section", properties: { upload_property: { type: "upload" } } }
errors = described_class.new(schema: schema, object: { upload_property: "string" }).validate
@@ -725,7 +725,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value is an invalid URL string" do
+ it "returns errors when the upload value is an invalid URL" do
schema = { name: "section", properties: { upload_property: { type: "upload" } } }
errors =
@@ -743,7 +743,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property is not a valid id of a upload record" do
+ it "returns errors for an unknown upload ID" do
schema = {
name: "section",
properties: {
@@ -796,7 +796,7 @@ RSpec.describe SchemaSettingsObjectValidator do
fab!(:tag_2, :tag)
fab!(:tag_3, :tag)
- it "should not return any error message when the value of the property is an array of valid tag names" do
+ it "returns no errors for valid tag names" do
schema = { name: "section", properties: { tags_property: { type: "tags" } } }
expect(
@@ -809,12 +809,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional tag list is missing" do
schema = { name: "section", properties: { tags_property: { type: "tags" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required tag list is missing" do
schema = {
name: "section",
properties: {
@@ -830,7 +830,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/tags_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not an array of tag names" do
+ it "returns errors when the tag value is not an array" do
schema = { name: "section", properties: { tags_property: { type: "tags" } } }
errors = described_class.new(schema: schema, object: { tags_property: "string" }).validate
@@ -842,7 +842,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when number of tag names does not satisfy min or max validations" do
+ it "returns errors when the tag count fails range validation" do
schema = {
name: "section",
properties: {
@@ -879,7 +879,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property contain tag names which are invalid" do
+ it "returns errors when the list contains invalid tag names" do
schema = {
name: "section",
properties: {
@@ -930,7 +930,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
context "for groups properties" do
- it "should not return any error message when the value of the property is an array of valid group record ids" do
+ it "returns no errors for valid group IDs" do
group = Fabricate(:group)
schema = { name: "section", properties: { groups_property: { type: "groups" } } }
@@ -940,12 +940,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional group list is missing" do
schema = { name: "section", properties: { groups_property: { type: "groups" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required group list is missing" do
schema = {
name: "section",
properties: {
@@ -961,7 +961,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/groups_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not an array of valid group ids" do
+ it "returns errors when the group value is not an array of valid IDs" do
schema = { name: "section", properties: { groups_property: { type: "groups" } } }
errors = described_class.new(schema: schema, object: { groups_property: "string" }).validate
@@ -973,7 +973,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when number of groups ids does not satisfy min or max validations" do
+ it "returns errors when the group count fails range validation" do
group_1 = Fabricate(:group)
group_2 = Fabricate(:group)
group_3 = Fabricate(:group)
@@ -1014,7 +1014,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property is an array containing invalid group ids" do
+ it "returns errors when the list contains invalid group IDs" do
schema = {
name: "section",
properties: {
@@ -1063,7 +1063,7 @@ RSpec.describe SchemaSettingsObjectValidator do
end
context "for post properties" do
- it "should not return any error message when the value of the property is a valid id of a post record" do
+ it "returns no errors for a valid post ID" do
post = Fabricate(:post)
schema = { name: "section", properties: { post_property: { type: "post" } } }
@@ -1073,12 +1073,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional post ID is missing" do
schema = { name: "section", properties: { post_property: { type: "post" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required post ID is missing" do
schema = {
name: "section",
properties: {
@@ -1094,7 +1094,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/post_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not an integer" do
+ it "returns errors when the post ID is not an integer" do
schema = { name: "section", properties: { post_property: { type: "post" } } }
errors = described_class.new(schema: schema, object: { post_property: "string" }).validate
@@ -1104,7 +1104,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/post_property"].full_messages).to contain_exactly("must be a valid post id")
end
- it "should return the right hash of error messages when value of property is not a valid id of a post record" do
+ it "returns errors for an unknown post ID" do
schema = {
name: "section",
properties: {
@@ -1156,7 +1156,7 @@ RSpec.describe SchemaSettingsObjectValidator do
fab!(:category_1, :category)
fab!(:category_2, :category)
- it "should not return any error message when the value of the property is an array of valid category ids" do
+ it "returns no errors for valid category IDs" do
schema = { name: "section", properties: { category_property: { type: "categories" } } }
expect(
@@ -1169,12 +1169,12 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional category list is missing" do
schema = { name: "section", properties: { category_property: { type: "categories" } } }
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is present but empty and it's required" do
+ it "returns errors when the required category list is empty" do
schema = {
name: "section",
properties: {
@@ -1190,7 +1190,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/category_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required category list is missing" do
schema = {
name: "section",
properties: {
@@ -1206,7 +1206,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/category_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property contains an array where not all values are integers" do
+ it "returns errors when the category list contains non-integers" do
schema = { name: "section", properties: { category_property: { type: "categories" } } }
errors =
@@ -1219,7 +1219,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when number of category ids does not satisfy min or max validations" do
+ it "returns errors when the category count fails range validation" do
schema = {
name: "section",
properties: {
@@ -1242,7 +1242,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property is not an array of valid category ids" do
+ it "returns errors when the category list contains invalid IDs" do
schema = {
name: "section",
properties: {
@@ -1304,7 +1304,7 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for datetime properties" do
let(:schema) { { name: "section", properties: { datetime_property: { type: "datetime" } } } }
- it "should not return any error messages when the value of the property is a valid UTC datetime" do
+ it "returns no errors for a valid UTC datetime" do
expect(
described_class.new(
schema: schema,
@@ -1324,7 +1324,7 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is an ISO 8601 datetime with timezone offset" do
+ it "returns no errors for an ISO 8601 datetime with a timezone offset" do
expect(
described_class.new(
schema: schema,
@@ -1335,17 +1335,17 @@ RSpec.describe SchemaSettingsObjectValidator do
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional datetime is missing" do
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should not return any error messages when the value is an empty string and it's not required" do
+ it "returns no errors when the optional datetime is blank" do
expect(
described_class.new(schema: schema, object: { datetime_property: "" }).validate,
).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required datetime is missing" do
schema = {
name: "section",
properties: {
@@ -1361,7 +1361,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/datetime_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not a valid datetime" do
+ it "returns errors for an invalid datetime" do
errors =
described_class.new(
schema: schema,
@@ -1376,7 +1376,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value is a date-only string" do
+ it "returns errors for a date-only string" do
errors =
described_class.new(schema: schema, object: { datetime_property: "2024-12-29" }).validate
@@ -1386,7 +1386,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value is datetime without timezone" do
+ it "returns errors for a datetime without a timezone" do
errors =
described_class.new(
schema: schema,
@@ -1401,7 +1401,7 @@ RSpec.describe SchemaSettingsObjectValidator do
)
end
- it "should return the right hash of error messages when value of property is not a string" do
+ it "returns errors when the datetime is not a string" do
errors = described_class.new(schema: schema, object: { datetime_property: 123 }).validate
expect(errors.keys).to eq(["/datetime_property"])
@@ -1414,17 +1414,17 @@ RSpec.describe SchemaSettingsObjectValidator do
context "for icon properties" do
let(:schema) { { name: "section", properties: { icon_property: { type: "icon" } } } }
- it "should not return any error messages when the value of the property is of type string" do
+ it "returns no errors for an icon string" do
expect(
described_class.new(schema: schema, object: { icon_property: "heart" }).validate,
).to eq({})
end
- it "should not return any error messages when the value is not present and it's not required in the schema" do
+ it "returns no errors when the optional icon is missing" do
expect(described_class.new(schema: schema, object: {}).validate).to eq({})
end
- it "should return the right hash of error messages when value of property is not present and it's required" do
+ it "returns errors when the required icon is missing" do
schema = {
name: "section",
properties: {
@@ -1440,7 +1440,7 @@ RSpec.describe SchemaSettingsObjectValidator do
expect(errors["/icon_property"].full_messages).to contain_exactly("must be present")
end
- it "should return the right hash of error messages when value of property is not of type icon" do
+ it "returns errors for an invalid icon" do
errors = described_class.new(schema: schema, object: { icon_property: 1 }).validate
expect(errors.keys).to eq(["/icon_property"])
diff --git a/spec/lib/score_calculator_spec.rb b/spec/lib/score_calculator_spec.rb
index db24c7dbe2c..21602d3fdde 100644
--- a/spec/lib/score_calculator_spec.rb
+++ b/spec/lib/score_calculator_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe ScoreCalculator do
end
describe "summary" do
- it "won't update the site settings when the site settings don't match" do
+ it "leaves the summary flag unset when the topic does not qualify" do
ScoreCalculator.new(reads: 3).calculate
topic.reload
expect(topic.has_summary).to eq(false)
@@ -56,7 +56,7 @@ RSpec.describe ScoreCalculator do
expect(topic.has_summary).to eq(true)
end
- it "won't update the site settings when the site settings don't match" do
+ it "sets the summary flag when the topic meets the configured thresholds" do
SiteSetting.expects(:summary_likes_required).returns(0)
SiteSetting.expects(:summary_posts_required).returns(1)
SiteSetting.expects(:summary_score_threshold).returns(100)
diff --git a/spec/lib/scss_checker_spec.rb b/spec/lib/scss_checker_spec.rb
index 84345c5eb04..7602de0da05 100644
--- a/spec/lib/scss_checker_spec.rb
+++ b/spec/lib/scss_checker_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Stylesheet::Manager::ScssChecker do
fab!(:theme)
describe "#has_scss" do
- it "should return true when theme has scss" do
+ it "returns true when the theme has SCSS" do
scss_theme = Fabricate(:theme, component: true)
scss_theme.set_field(target: :common, name: "scss", value: ".scss{color: red;}")
scss_theme.save!
@@ -30,7 +30,7 @@ RSpec.describe Stylesheet::Manager::ScssChecker do
expect(embedded_theme_checker.has_scss(embedded_scss_theme.id)).to eq(true)
end
- it "should return false when theme does not have scss" do
+ it "returns false when the theme does not have SCSS" do
expect(described_class.new(:desktop_theme, [theme.id]).has_scss(theme.id)).to eq(false)
end
end
diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb
index c61c2d5c6b9..718ddbc3307 100644
--- a/spec/lib/search_spec.rb
+++ b/spec/lib/search_spec.rb
@@ -168,7 +168,7 @@ RSpec.describe Search do
after { SearchIndexer.disable }
- it "should apply the custom ranking weights correctly" do
+ it "applies the custom ranking weights" do
expect(Search.execute("start").posts).to eq([post2, post1])
SiteSetting.search_ranking_weights = "{0.00001,0.2,0.4,1.0}"
@@ -271,21 +271,21 @@ RSpec.describe Search do
before { SearchIndexer.index(suspended_user, force: true) }
- it "should list suspended users to regular users if the setting is enabled" do
+ it "lists suspended users to regular users when enabled" do
SiteSetting.enable_listing_suspended_users_on_search = true
result = Search.execute("revolver_ocelot", guardian: Guardian.new(user))
expect(result.users).to contain_exactly(suspended_user)
end
- it "shouldn't list suspended users to regular users if the setting is disabled" do
+ it "hides suspended users from regular users when disabled" do
SiteSetting.enable_listing_suspended_users_on_search = false
result = Search.execute("revolver_ocelot", guardian: Guardian.new(user))
expect(result.users).to be_empty
end
- it "should list suspended users to admins regardless of the setting" do
+ it "lists suspended users to admins regardless of the setting" do
SiteSetting.enable_listing_suspended_users_on_search = false
result = Search.execute("revolver_ocelot", guardian: Guardian.new(Fabricate(:admin)))
@@ -352,7 +352,7 @@ RSpec.describe Search do
end
end
- describe "categories" do
+ describe "nested category filters" do
it "finds topics in sub-sub-categories" do
SiteSetting.max_category_nesting = 3
@@ -401,7 +401,7 @@ RSpec.describe Search do
end
let!(:post2) { Fabricate(:post, topic: topic, user: user) }
- it "should index correctly" do
+ it "indexes the post's searchable text" do
search_data = post.post_search_data.search_data
expect(search_data).to match(/fun/)
@@ -415,7 +415,7 @@ RSpec.describe Search do
expect(post.post_search_data.reload.search_data).to match(/harpi/)
end
- it "should update posts index when topic category changes" do
+ it "updates the post index when the topic's category changes" do
expect do topic.update!(category: Fabricate(:category)) end.to change {
post.reload.post_search_data.version
}.from(SearchIndexer::POST_INDEX_VERSION).to(SearchIndexer::REINDEX_VERSION).and change {
@@ -423,7 +423,7 @@ RSpec.describe Search do
}.from(SearchIndexer::POST_INDEX_VERSION).to(SearchIndexer::REINDEX_VERSION)
end
- it "should update posts index when topic tags changes" do
+ it "updates the post index when the topic's tags change" do
SiteSetting.tagging_enabled = true
tag = Fabricate(:tag)
@@ -446,7 +446,7 @@ RSpec.describe Search do
@indexed = @user.user_search_data.search_data
end
- it "should pick up on data" do
+ it "indexes the user's name" do
expect(@indexed).to match(/fred/)
expect(@indexed).to match(/jone/)
end
@@ -459,11 +459,11 @@ RSpec.describe Search do
let!(:post2) { Fabricate(:post, topic: topic) }
let!(:post3) { Fabricate(:post) }
- it "should index correctly" do
+ it "indexes the category name" do
expect(category.category_search_data.search_data).to match(/america/)
end
- it "should update posts index when category name changes" do
+ it "updates the post index when the category name changes" do
expect do category.update!(name: "some new name") end.to change {
post.reload.post_search_data.version
}.from(SearchIndexer::POST_INDEX_VERSION).to(SearchIndexer::REINDEX_VERSION).and change {
@@ -577,7 +577,7 @@ RSpec.describe Search do
expect { Search.execute("evil trout") }.not_to raise_error
end
- describe "users" do
+ describe "user type filter" do
let!(:user) { Fabricate(:user) }
let(:result) { Search.execute("bruce", type_filter: "user") }
@@ -1661,7 +1661,7 @@ RSpec.describe Search do
expect(search.posts.map(&:id)).to contain_exactly(post2.id, child_post.id)
end
- it "should return the right categories" do
+ it "returns matching categories and filters posts by category" do
search = Search.execute("monkey")
expect(search.categories).to contain_exactly(category, ignored_category)
@@ -1733,7 +1733,7 @@ RSpec.describe Search do
describe "categories with different priorities" do
let(:category2) { Fabricate(:category_with_definition) }
- it "should return posts in the right order" do
+ it "returns posts in ranked order" do
raw = "The pure genuine evian"
post = Fabricate(:post, topic: category.topic, raw: raw)
post2 = Fabricate(:post, topic: category2.topic, raw: raw)
@@ -2310,7 +2310,7 @@ RSpec.describe Search do
let!(:post) { Fabricate(:post, raw: "hi this is a test 123 123", topic: topic, user: user) }
let!(:post_2) { Fabricate(:post, user: user_2) }
- it "should not return any posts if group does not exist" do
+ it "returns no posts if the group does not exist" do
group.update!(
visibility_level: Group.visibility_levels[:public],
members_visibility_level: Group.visibility_levels[:public],
@@ -2319,7 +2319,7 @@ RSpec.describe Search do
expect(Search.execute("group:99999").posts).to eq([])
end
- it "should return the right posts for a public group" do
+ it "returns matching posts for a public group" do
group.update!(
visibility_level: Group.visibility_levels[:public],
members_visibility_level: Group.visibility_levels[:public],
@@ -2329,7 +2329,7 @@ RSpec.describe Search do
expect(Search.execute("group:#{group.id}").posts).to contain_exactly(post)
end
- it "should return the right posts for a public group with members' visibility restricted to logged on users" do
+ it "respects member visibility for a public group" do
group.update!(
visibility_level: Group.visibility_levels[:public],
members_visibility_level: Group.visibility_levels[:logged_on_users],
@@ -2341,7 +2341,7 @@ RSpec.describe Search do
).to contain_exactly(post)
end
- it "should return the right posts for a group with visibility restricted to logged on users with members' visibility restricted to members" do
+ it "respects group and member visibility restrictions" do
group.update!(
visibility_level: Group.visibility_levels[:logged_on_users],
members_visibility_level: Group.visibility_levels[:members],
@@ -3097,7 +3097,7 @@ RSpec.describe Search do
expect(results.posts).to eq([])
end
- it "won't work for users that can't see unlisted topics" do
+ it "excludes unlisted topics the user cannot see" do
topic = Fabricate(:topic, title: "I am testing a search", visible: false)
_post = Fabricate(:post, topic: topic, raw: "this is the first post", post_number: 1)
@@ -3341,7 +3341,7 @@ RSpec.describe Search do
fab!(:group) { Fabricate(:group, name: "bruce-world-fans") }
fab!(:topic) { Fabricate(:topic, title: "Bruce topic not a result") }
- it "works" do
+ it "returns matching users, categories, groups, and tags without posts" do
category = Fabricate(:category_with_definition, name: "bruceland", user: user)
tag = Fabricate(:tag, name: "brucealicious")
diff --git a/spec/lib/sidekiq/discourse_event_spec.rb b/spec/lib/sidekiq/discourse_event_spec.rb
index 7febd368202..a10142c052d 100644
--- a/spec/lib/sidekiq/discourse_event_spec.rb
+++ b/spec/lib/sidekiq/discourse_event_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Sidekiq::DiscourseEvent do
describe "#call" do
- it "should trigger the `sidekiq_job_ran` discourse event when successfully executing the block" do
+ it "triggers sidekiq_job_ran after the block succeeds" do
called = false
events =
@@ -24,7 +24,7 @@ RSpec.describe Sidekiq::DiscourseEvent do
expect(event[:params][3]).to be_a(Float)
end
- it "should trigger `sidekiq_job_error` discourse event when an error occurs while executing the block" do
+ it "triggers sidekiq_job_error when the block raises an error" do
called = false
events =
diff --git a/spec/lib/signal_trap_logger_spec.rb b/spec/lib/signal_trap_logger_spec.rb
index 634e4a028ec..372323e65ec 100644
--- a/spec/lib/signal_trap_logger_spec.rb
+++ b/spec/lib/signal_trap_logger_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe SignalTrapLogger do
describe "#log" do
- it "should queue up messages to be logged which will then be logged by the logging thread" do
+ it "queues messages for the logging thread" do
fake_logger = FakeLogger.new
SignalTrapLogger.instance.log(fake_logger, "message 1", level: :error)
diff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rb
index 727b327dd5c..6a5fc6f717e 100644
--- a/spec/lib/site_setting_extension_spec.rb
+++ b/spec/lib/site_setting_extension_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "will reset to default if provider vanishes" do
+ it "resets to the default if the provider vanishes" do
settings.setting(:hello, 1)
settings.hello = 100
expect(settings.hello).to eq(100)
@@ -83,7 +83,7 @@ RSpec.describe SiteSettingExtension do
expect(settings.hello).to eq(1)
end
- it "will set to new value if provider changes" do
+ it "uses the new value if the provider changes" do
settings.setting(:hello, 1)
settings.hello = 100
expect(settings.hello).to eq(100)
@@ -244,11 +244,11 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should have a key in all_settings" do
+ it "includes the setting in all_settings" do
expect(settings.all_settings.detect { |s| s[:setting] == :test_setting }).to be_present
end
- it "should have the correct desc" do
+ it "interpolates the base path in the setting description" do
I18n.backend.store_translations(
:en,
site_settings: {
@@ -265,7 +265,7 @@ RSpec.describe SiteSettingExtension do
)
end
- it "should have the correct default" do
+ it "returns the integer default" do
expect(settings.test_setting).to eq(77)
end
@@ -274,22 +274,22 @@ RSpec.describe SiteSettingExtension do
settings.remove_override!(:test_setting)
end
- it "should have the correct override" do
+ it "returns the overridden value" do
settings.test_setting = 100
expect(settings.test_setting).to eq(100)
end
- it "should coerce correct string to int" do
+ it "coerces a numeric string to an integer" do
settings.test_setting = "101"
expect(settings.test_setting).to eq(101)
end
- it "should coerce incorrect string to 0" do
+ it "coerces a nonnumeric string to zero" do
settings.test_setting = "pie"
expect(settings.test_setting).to eq(0)
end
- it "should not set default when reset" do
+ it "preserves the override when the setting is redefined" do
settings.test_setting = 100
settings.setting(:test_setting, 77)
settings.refresh!
@@ -301,7 +301,7 @@ RSpec.describe SiteSettingExtension do
expect(settings.test_setting).to eq(12)
end
- it "should publish changes to clients" do
+ it "publishes changes to clients" do
settings.setting("test_setting", 100)
settings.setting("test_setting", nil, client: true)
@@ -340,7 +340,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should have the correct default" do
+ it "returns the string default" do
expect(settings.test_str).to eq("str")
end
@@ -349,7 +349,7 @@ RSpec.describe SiteSettingExtension do
settings.remove_override!(:test_str)
end
- it "should coerce int to string" do
+ it "coerces an integer to a string" do
settings.test_str = 100
expect(settings.test_str).to eq("100")
end
@@ -384,29 +384,29 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should have the correct default" do
+ it "returns the boolean default" do
expect(settings.test_hello?).to eq(false)
end
context "when overridden" do
after { settings.remove_override!(:test_hello?) }
- it "should have the correct override" do
+ it "returns the overridden boolean" do
settings.test_hello = true
expect(settings.test_hello?).to eq(true)
end
- it "should coerce true strings to true" do
+ it "coerces true strings to true" do
settings.test_hello = "true"
expect(settings.test_hello?).to be(true)
end
- it "should coerce all other strings to false" do
+ it "coerces all other strings to false" do
settings.test_hello = "f"
expect(settings.test_hello?).to be(false)
end
- it "should not set default when reset" do
+ it "preserves the override when the setting is redefined" do
settings.test_hello = true
settings.setting(:test_hello?, false)
settings.refresh!
@@ -431,7 +431,7 @@ RSpec.describe SiteSettingExtension do
end
end
- it "should coerce correctly" do
+ it "coerces an enum string to an integer" do
settings.setting(:test_int_enum, 1, enum: TestIntEnumClass)
settings.test_int_enum = "2"
settings.refresh!
@@ -462,15 +462,15 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should have the correct default" do
+ it "returns the enum default" do
expect(settings.test_enum).to eq("en")
end
- it "should not hose all_settings" do
+ it "includes the enum in all_settings" do
expect(settings.all_settings.detect { |s| s[:setting] == :test_enum }).to be_present
end
- it "should report error when being set other values" do
+ it "rejects values outside the enum" do
expect { settings.test_enum = "not_in_enum" }.to raise_error(Discourse::InvalidParameters)
end
@@ -498,7 +498,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should return the category in all_settings" do
+ it "returns the category in all_settings" do
expect(settings.all_settings.find { |s| s[:setting] == :test_setting }[:category]).to eq(
:tests,
)
@@ -509,12 +509,12 @@ RSpec.describe SiteSettingExtension do
settings.remove_override!(:test_setting)
end
- it "should have the correct override" do
+ it "returns the overridden value" do
settings.test_setting = 101
expect(settings.test_setting).to eq(101)
end
- it "should still have the correct category" do
+ it "preserves the category after overriding the value" do
settings.test_setting = 102
expect(settings.all_settings.find { |s| s[:setting] == :test_setting }[:category]).to eq(
:tests,
@@ -531,7 +531,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should allow to filter by area" do
+ it "filters settings by area" do
expect(settings.all_settings(filter_area: "flags").map { |s| s[:setting].to_sym }).to eq(
%i[default_locale test_setting test_setting2],
)
@@ -679,7 +679,7 @@ RSpec.describe SiteSettingExtension do
expect(UserHistory.last.new_value).to eq("[FILTERED]")
end
- it "works" do
+ it "updates the setting and logs its previous and new values" do
settings.set_and_log("title", "Discourse v2")
expect(settings.title).to eq("Discourse v2")
expect(UserHistory.last.previous_value).to eq("Discourse v1")
@@ -958,7 +958,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should not add the key to the shadowed_settings collection" do
+ it "does not add the key to shadowed_settings" do
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(false)
end
@@ -980,7 +980,7 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should return default cause nothing is set" do
+ it "returns the default when no value is set" do
expect(settings.nada).to eq("nothing")
end
end
@@ -992,11 +992,11 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should return default cause nothing is set" do
+ it "returns the default when no value is set" do
expect(settings.bool).to eq(false)
end
- it "should not trigger any message bus work if you try to set it" do
+ it "does not publish MessageBus updates when assigned" do
m =
MessageBus.track_publish("/site_settings") do
settings.bool = true
@@ -1013,16 +1013,16 @@ RSpec.describe SiteSettingExtension do
settings.refresh!
end
- it "should return the global setting instead of default" do
+ it "returns the global setting instead of the default" do
expect(settings.trout_api_key).to eq("purringcat")
end
- it "should return the global setting after a refresh" do
+ it "returns the global setting after a refresh" do
settings.refresh!
expect(settings.trout_api_key).to eq("purringcat")
end
- it "should add the key to the hidden_settings collection" do
+ it "adds the key to hidden_settings" do
expect(settings.hidden_settings.include?(:trout_api_key)).to eq(true)
["", nil].each_with_index do |setting, index|
@@ -1033,7 +1033,7 @@ RSpec.describe SiteSettingExtension do
end
end
- it "should add the key to the shadowed_settings collection" do
+ it "adds the key to shadowed_settings" do
expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(true)
end
end
@@ -1199,7 +1199,7 @@ RSpec.describe SiteSettingExtension do
end
describe "uploads settings" do
- it "should return the right values" do
+ it "returns upload URLs for the current and default values" do
negative_upload_id = [(Upload.minimum(:id) || 0) - 1, -10].min
system_upload = Fabricate(:upload, id: negative_upload_id)
settings.setting(:logo, system_upload.id, type: :upload)
@@ -1220,7 +1220,7 @@ RSpec.describe SiteSettingExtension do
end
describe "objects settings with uploads" do
- it "should hydrate upload IDs to URLs" do
+ it "hydrates upload IDs to URLs" do
upload1 = Fabricate(:upload)
upload2 = Fabricate(:upload)
upload3 = Fabricate(:upload)
@@ -1269,7 +1269,7 @@ RSpec.describe SiteSettingExtension do
expect(value[0]["links"][0]["link_image"]).to eq(upload3.url)
end
- it "should batch uploads query" do
+ it "batches the uploads query" do
upload1 = Fabricate(:upload)
upload2 = Fabricate(:upload)
upload3 = Fabricate(:upload)
@@ -1346,7 +1346,7 @@ RSpec.describe SiteSettingExtension do
end
describe ".client_settings_json_uncached" do
- it "should return the right json value" do
+ it "serializes client settings and upload URLs as JSON" do
upload = Fabricate(:upload)
settings.setting(:upload_type, upload.id.to_s, type: :upload, client: true)
settings.setting(:string_type, "haha", client: true)
@@ -1452,7 +1452,7 @@ RSpec.describe SiteSettingExtension do
fab!(:upload)
fab!(:upload2, :upload)
- it "should return the upload record" do
+ it "returns the upload record" do
settings.setting(:some_upload, upload.id.to_s, type: :upload)
expect(settings.some_upload).to eq(upload)
diff --git a/spec/lib/site_settings/type_supervisor_spec.rb b/spec/lib/site_settings/type_supervisor_spec.rb
index 3186ec9fc0c..36b5b76c507 100644
--- a/spec/lib/site_settings/type_supervisor_spec.rb
+++ b/spec/lib/site_settings/type_supervisor_spec.rb
@@ -495,7 +495,7 @@ RSpec.describe SiteSettings::TypeSupervisor do
expect(settings.type_supervisor.to_rb_value(:type_custom, "2|3")).to eq "2|3"
end
- it "should not modify the types of settings" do
+ it "does not modify setting types" do
types = SiteSettings::TypeSupervisor.types
settings.type_supervisor.to_rb_value(:default_locale, "fr", types[:enum])
expect(settings.type_supervisor.to_db_value(:default_locale, "en")).to eq(
@@ -511,7 +511,7 @@ RSpec.describe SiteSettings::TypeSupervisor do
settings.setting(:type_upload, "", type: :upload)
end
- it "should return the right type that has been registered" do
+ it "returns the registered type" do
expect(settings.type_supervisor.get_type(:type_null)).to eq(:null)
expect(settings.type_supervisor.get_type(:type_upload)).to eq(:upload)
end
diff --git a/spec/lib/site_settings/validations_spec.rb b/spec/lib/site_settings/validations_spec.rb
index 3f3a050e527..1bdd3e0165b 100644
--- a/spec/lib/site_settings/validations_spec.rb
+++ b/spec/lib/site_settings/validations_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe SiteSettings::Validations do
}.not_to raise_error
end
- it "won't allow you to input junk categories" do
+ it "rejects invalid category IDs" do
expect { validations.validate_default_categories_watching("junk") }.to raise_error(
Discourse::InvalidParameters,
)
@@ -45,22 +45,22 @@ RSpec.describe SiteSettings::Validations do
SiteSetting.set(other_setting_name, value)
end
- it "shouldn't raise an error when both buckets are blank" do
+ it "accepts two blank buckets" do
change_bucket_value("")
validate("")
end
- it "shouldn't raise an error when only one bucket is set" do
+ it "accepts a single configured bucket" do
change_bucket_value("")
validate("my-awesome-bucket")
end
- it "shouldn't raise an error when both buckets are equal, but use a different path" do
+ it "accepts the same bucket with different paths" do
change_bucket_value("my-awesome-bucket/foo")
validate("my-awesome-bucket/bar")
end
- it "should raise an error when both buckets are equal" do
+ it "rejects identical bucket locations" do
change_bucket_value("my-awesome-bucket")
expect { validate("my-awesome-bucket") }.to raise_error(
Discourse::InvalidParameters,
@@ -68,7 +68,7 @@ RSpec.describe SiteSettings::Validations do
)
end
- it "should raise an error when both buckets are equal except for a trailing slash" do
+ it "rejects identical bucket locations with a trailing slash" do
change_bucket_value("my-awesome-bucket/")
expect { validate("my-awesome-bucket") }.to raise_error(
Discourse::InvalidParameters,
@@ -92,7 +92,7 @@ RSpec.describe SiteSettings::Validations do
it_behaves_like "s3 bucket validation"
- it "shouldn't raise an error when the 's3_backup_bucket' is a subdirectory of 's3_upload_bucket'" do
+ it "accepts a backup bucket below the upload bucket" do
SiteSetting.s3_upload_bucket = "my-awesome-bucket"
validate("my-awesome-bucket/backups")
@@ -110,7 +110,7 @@ RSpec.describe SiteSettings::Validations do
it_behaves_like "s3 bucket validation"
- it "should raise an error when the 's3_upload_bucket' is a subdirectory of 's3_backup_bucket'" do
+ it "rejects an upload bucket below the backup bucket" do
SiteSetting.s3_backup_bucket = "my-awesome-bucket"
expect { validate("my-awesome-bucket/uploads") }.to raise_error(
Discourse::InvalidParameters,
@@ -144,7 +144,7 @@ RSpec.describe SiteSettings::Validations do
before { SiteSetting.enable_local_logins = false }
- it "should raise an error" do
+ it "rejects enforcement when local logins are disabled" do
expect { validations.validate_enforce_second_factor("t") }.to raise_error(
Discourse::InvalidParameters,
error_message,
@@ -155,7 +155,7 @@ RSpec.describe SiteSettings::Validations do
context "when local logins are enabled" do
before { SiteSetting.enable_local_logins = true }
- it "should be ok" do
+ it "allows enforcement with local logins enabled" do
expect { validations.validate_enforce_second_factor("t") }.not_to raise_error
end
end
@@ -173,7 +173,7 @@ RSpec.describe SiteSettings::Validations do
SiteSetting.enable_discourse_connect = true
end
- it "should raise an error" do
+ it "rejects enforcement when SSO is enabled" do
expect { validations.validate_enforce_second_factor("t") }.to raise_error(
Discourse::InvalidParameters,
error_message,
@@ -191,7 +191,7 @@ RSpec.describe SiteSettings::Validations do
context "when enforce second factor is enabled" do
before { SiteSetting.enforce_second_factor = "all" }
- it "should raise an error" do
+ it "rejects disabling local logins" do
expect { validations.validate_enable_local_logins("f") }.to raise_error(
Discourse::InvalidParameters,
error_message,
@@ -202,14 +202,14 @@ RSpec.describe SiteSettings::Validations do
context "when enforce second factor is disabled" do
before { SiteSetting.enforce_second_factor = "no" }
- it "should be ok" do
+ it "allows disabling local logins" do
expect { validations.validate_enable_local_logins("f") }.not_to raise_error
end
end
end
context "when the new value is true" do
- it "should be ok" do
+ it "allows enabling local logins" do
expect { validations.validate_enable_local_logins("t") }.not_to raise_error
end
end
@@ -221,7 +221,7 @@ RSpec.describe SiteSettings::Validations do
end
context "when the new value has trailing slash" do
- it "should raise an error" do
+ it "rejects an origin with a trailing slash" do
expect { validations.validate_cors_origins("https://www.rainbows.com/") }.to raise_error(
Discourse::InvalidParameters,
error_message,
@@ -303,7 +303,7 @@ RSpec.describe SiteSettings::Validations do
context "when s3 uploads are not already globally enabled" do
before { GlobalSetting.stubs(:use_s3?).returns(false) }
- it "should be ok" do
+ it "allows enabling S3 uploads" do
expect { validations.validate_enable_s3_uploads("t") }.not_to raise_error
end
end
@@ -324,7 +324,7 @@ RSpec.describe SiteSettings::Validations do
context "when the s3_upload_bucket is not blank" do
before { SiteSetting.s3_upload_bucket = "some-bucket" }
- it "should be ok" do
+ it "allows enabling S3 uploads" do
expect { validations.validate_enable_s3_uploads("t") }.not_to raise_error
end
end
@@ -403,7 +403,7 @@ RSpec.describe SiteSettings::Validations do
context "when composer_media_optimization_image_enabled is enabled" do
before { SiteSetting.composer_media_optimization_image_enabled = true }
- it "should raise an error" do
+ it "rejects disabling metadata stripping" do
expect { validations.validate_strip_image_metadata("f") }.to raise_error(
Discourse::InvalidParameters,
error_message,
@@ -414,14 +414,14 @@ RSpec.describe SiteSettings::Validations do
context "when composer_media_optimization_image_enabled is disabled" do
before { SiteSetting.composer_media_optimization_image_enabled = false }
- it "should be ok" do
+ it "allows disabling metadata stripping" do
expect { validations.validate_strip_image_metadata("f") }.not_to raise_error
end
end
end
context "when the new value is true" do
- it "should be ok" do
+ it "allows enabling metadata stripping" do
expect { validations.validate_strip_image_metadata("t") }.not_to raise_error
end
end
diff --git a/spec/lib/spam_handler_spec.rb b/spec/lib/spam_handler_spec.rb
index e4b9ef9eebf..b4b8cd2f2eb 100644
--- a/spec/lib/spam_handler_spec.rb
+++ b/spec/lib/spam_handler_spec.rb
@@ -4,7 +4,7 @@ require "spam_handler"
RSpec.describe SpamHandler do
describe "#should_prevent_registration_from_ip?" do
- it "works" do
+ it "flags spam and silences the user" do
# max_new_accounts_per_registration_ip = 0 disables the check
SiteSetting.max_new_accounts_per_registration_ip = 0
diff --git a/spec/lib/stylesheet/importer_spec.rb b/spec/lib/stylesheet/importer_spec.rb
index 6fbcaad3217..f102ce8692e 100644
--- a/spec/lib/stylesheet/importer_spec.rb
+++ b/spec/lib/stylesheet/importer_spec.rb
@@ -68,12 +68,12 @@ RSpec.describe Stylesheet::Importer do
end
end
- it "should include color definitions in the theme" do
+ it "includes color definitions from the theme" do
styles = Stylesheet::Importer.new({ theme_id: theme.id }).import_color_definitions
expect(styles).to include(output_scss)
end
- it "should include color definitions from components" do
+ it "includes color definitions from components" do
theme.add_relative_theme!(:child, child)
theme.save!
@@ -83,7 +83,7 @@ RSpec.describe Stylesheet::Importer do
expect(styles).to include("--custom-color-rgb: 0, 0, 128")
end
- it "should include default theme color definitions" do
+ it "includes default theme color definitions" do
SiteSetting.default_theme_id = theme.id
styles = Stylesheet::Importer.new({}).import_color_definitions
expect(styles).to include(output_scss)
@@ -91,14 +91,14 @@ RSpec.describe Stylesheet::Importer do
end
describe "#import_wcag_overrides" do
- it "should do nothing on a regular scheme" do
+ it "does nothing for 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(
"",
)
end
- it "should include WCAG overrides for WCAG based scheme" do
+ it "includes WCAG overrides for a WCAG-based scheme" do
scheme =
ColorScheme.create_from_base(
name: "WCAG New",
diff --git a/spec/lib/system_message_spec.rb b/spec/lib/system_message_spec.rb
index 53fedd0f181..0bf960c9f80 100644
--- a/spec/lib/system_message_spec.rb
+++ b/spec/lib/system_message_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe SystemMessage do
before { SiteSetting.site_contact_username = admin.username }
- it "should create a post correctly" do
+ it "creates the expected post" do
system_message = SystemMessage.new(user)
post = system_message.create(:welcome_invite)
topic = post.topic
diff --git a/spec/lib/text_sentinel_spec.rb b/spec/lib/text_sentinel_spec.rb
index b3864068c56..0a12604d94e 100644
--- a/spec/lib/text_sentinel_spec.rb
+++ b/spec/lib/text_sentinel_spec.rb
@@ -96,11 +96,11 @@ RSpec.describe TextSentinel do
expect(TextSentinel.new(valid_string.upcase)).to be_valid
end
- it "enforces the minimum entropy" do
+ it "accepts text at the minimum entropy" do
expect(TextSentinel.new(valid_string, min_entropy: 16)).to be_valid
end
- it "enforces the minimum entropy" do
+ it "rejects text below the minimum entropy" do
expect(TextSentinel.new(valid_string, min_entropy: 17)).not_to be_valid
end
diff --git a/spec/lib/theme_settings_parser_spec.rb b/spec/lib/theme_settings_parser_spec.rb
index be17a4b4b4f..5132b02d921 100644
--- a/spec/lib/theme_settings_parser_spec.rb
+++ b/spec/lib/theme_settings_parser_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe ThemeSettingsParser do
end
describe "enum setting" do
- it "should never have less than 1 choices" do
+ it "retains at least one choice" do
choices = loader.find_by_name(:enum_setting)[:opts][:choices]
expect(choices.class).to eq(Array)
expect(choices.length).to eq(3)
diff --git a/spec/lib/topic_creator_spec.rb b/spec/lib/topic_creator_spec.rb
index 06df9dc61b9..6d1b515e00a 100644
--- a/spec/lib/topic_creator_spec.rb
+++ b/spec/lib/topic_creator_spec.rb
@@ -32,11 +32,11 @@ RSpec.describe TopicCreator do
SiteSetting.duplicate_topic_titles = "allowed"
end
- it "should be possible for an admin to create a topic" do
+ it "allows an admin to create a topic" do
expect(TopicCreator.create(admin, Guardian.new(admin), valid_attrs)).to be_valid
end
- it "should be possible for a moderator to create a topic" do
+ it "allows a moderator to create a topic" do
expect(TopicCreator.create(moderator, Guardian.new(moderator), valid_attrs)).to be_valid
end
@@ -51,11 +51,11 @@ RSpec.describe TopicCreator do
context "with regular user" do
before { SiteSetting.create_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_0] }
- it "should be possible for a regular user to create a topic" do
+ it "allows a regular user to create a topic" do
expect(TopicCreator.create(user, Guardian.new(user), valid_attrs)).to be_valid
end
- it "should be possible for a regular user to create a topic with blank auto_close_time" do
+ it "allows a regular user to create a topic with a blank auto_close_time" do
expect(
TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(auto_close_time: "")),
).to be_valid
@@ -555,7 +555,7 @@ RSpec.describe TopicCreator do
SiteSetting.enable_staged_users = true
end
- it "should be possible for a regular user to send private message" do
+ it "allows a regular user to send a private message" do
expect(TopicCreator.create(user, Guardian.new(user), pm_valid_attrs)).to be_valid
end
@@ -577,7 +577,7 @@ RSpec.describe TopicCreator do
end
context "with failure cases" do
- it "should be rollback the changes when email is invalid" do
+ it "rolls back the changes when the email is invalid" do
SiteSetting.manual_polling_enabled = true
SiteSetting.reply_by_email_address = "sam+%{reply_key}@sam.com"
SiteSetting.reply_by_email_enabled = true
diff --git a/spec/lib/topic_publisher_spec.rb b/spec/lib/topic_publisher_spec.rb
index 6ff75c7f8f8..deb9855f70b 100644
--- a/spec/lib/topic_publisher_spec.rb
+++ b/spec/lib/topic_publisher_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe TopicPublisher do
op.reload
end
- it "will publish the topic properly" do
+ it "publishes the topic" do
published_at = 1.hour.from_now.change(usec: 0)
freeze_time(published_at) do
TopicPublisher.new(topic, moderator, shared_draft.category_id).publish!
@@ -54,7 +54,7 @@ RSpec.describe TopicPublisher do
end
end
- it "will notify users watching tag" do
+ it "notifies users watching the tag" do
Jobs.run_immediately!
TagUser.create!(
diff --git a/spec/lib/topic_query/private_message_lists_spec.rb b/spec/lib/topic_query/private_message_lists_spec.rb
index d28de251c50..cd30b0d874a 100644
--- a/spec/lib/topic_query/private_message_lists_spec.rb
+++ b/spec/lib/topic_query/private_message_lists_spec.rb
@@ -118,7 +118,7 @@ RSpec.describe TopicQuery::PrivateMessageLists do
end
describe "#list_private_messages_group" do
- it "should return the right list for a group user" do
+ it "returns the group's messages for a group member" do
group.add(user_2)
topics =
@@ -127,7 +127,7 @@ RSpec.describe TopicQuery::PrivateMessageLists do
expect(topics).to contain_exactly(group_message)
end
- it "should return the right list for an admin not part of the group" do
+ it "returns the group's messages for an admin outside the group" do
group.update!(name: group.name.capitalize)
topics =
@@ -139,7 +139,7 @@ RSpec.describe TopicQuery::PrivateMessageLists do
expect(topics).to contain_exactly(group_message)
end
- it "should not allow a moderator not part of the group to view the group's messages" do
+ it "prevents moderators outside the group from viewing its messages" do
topics =
TopicQuery
.new(nil, group_name: group.name)
@@ -149,7 +149,7 @@ RSpec.describe TopicQuery::PrivateMessageLists do
expect(topics).to eq([])
end
- it "should not allow a user not part of the group to view the group's messages" do
+ it "prevents users outside the group from viewing its messages" do
topics =
TopicQuery
.new(nil, group_name: group.name)
diff --git a/spec/lib/topic_query_spec.rb b/spec/lib/topic_query_spec.rb
index 3c93e10b25d..61e546f147d 100644
--- a/spec/lib/topic_query_spec.rb
+++ b/spec/lib/topic_query_spec.rb
@@ -780,12 +780,12 @@ RSpec.describe TopicQuery do
before { SiteSetting.mute_all_categories_by_default = true }
- it "should remove all topics from new and latest lists by default" do
+ it "removes all topics from new and latest lists by default" do
expect(topic_query.list_new.topics.map(&:id)).not_to include(topic.id)
expect(topic_query.list_latest.topics.map(&:id)).not_to include(topic.id)
end
- it "should include tracked category topics in new and latest lists" do
+ it "includes tracked-category topics in new and latest lists" do
topic = Fabricate(:topic, category: category)
CategoryUser.create!(
user_id: user.id,
@@ -796,17 +796,17 @@ RSpec.describe TopicQuery do
expect(topic_query.list_latest.topics.map(&:id)).to include(topic.id)
end
- it "should include default watched category topics in latest list for anonymous users" do
+ it "includes default watched-category topics for anonymous users" do
SiteSetting.default_categories_watching = category.id.to_s
expect(TopicQuery.new.list_latest.topics.map(&:id)).to include(topic.id)
end
- it "should include default regular category topics in latest list for anonymous users" do
+ it "includes default regular-category topics for anonymous users" do
SiteSetting.default_categories_normal = category.id.to_s
expect(TopicQuery.new.list_latest.topics.map(&:id)).to include(topic.id)
end
- it "should include topics when filtered by category" do
+ it "includes topics when filtered by category" do
topic_query = TopicQuery.new(user, category: topic.category_id)
expect(topic_query.list_latest.topics.map(&:id)).to include(topic.id)
end
@@ -1190,7 +1190,7 @@ RSpec.describe TopicQuery do
expect(topic_ids - [topic_category.id]).to eq([topic_in_cat1.id, topic_in_cat2.id])
end
- it "should apply default sort order to latest and unseen filters only" do
+ it "applies the default sort order only to latest and unseen filters" do
category.update!(sort_order: "created", sort_ascending: true)
topic1 =
@@ -1591,11 +1591,11 @@ RSpec.describe TopicQuery do
let(:topic) { Fabricate(:topic) }
let!(:new_topic) { Fabricate(:post, user: creator).topic }
- it "should return the new topic" do
+ it "returns the new topic" do
expect(TopicQuery.new.list_suggested_for(topic).topics).to eq([new_topic])
end
- it "should return the nothing when random topics excluded" do
+ it "returns nothing when random topics are excluded" do
expect(TopicQuery.new.list_suggested_for(topic, include_random: false).topics).to eq([])
end
end
@@ -1607,7 +1607,7 @@ RSpec.describe TopicQuery do
let!(:archived_topic) { Fabricate(:topic, user: creator, archived: true) }
let!(:invisible_topic) { Fabricate(:topic, user: creator, visible: false) }
- it "should omit the closed/archived/invisible topics from suggested" do
+ it "omits closed, archived, and invisible topics from suggestions" do
expect(TopicQuery.new.list_suggested_for(topic).topics).to eq([regular_topic])
end
end
@@ -1636,7 +1636,7 @@ RSpec.describe TopicQuery do
let(:plugin) { plugin_class.new }
- it "should return suggested defined by the custom provider" do
+ it "returns suggestions from the custom provider" do
DiscoursePluginRegistry.register_list_suggested_for_provider(
plugin_class.method(:custom_suggested_topics),
plugin,
@@ -1656,7 +1656,7 @@ RSpec.describe TopicQuery do
after { clear_cache! }
context "when there are no new topics for user" do
- it "should return random topics excluding topics that are muted by user and not older than `suggested_topics_max_days_old` site setting" do
+ it "returns recent random topics that are not muted by the user" do
topic2 = Fabricate(:topic, user: user)
topic3 = Fabricate(:topic, user: user)
_topic4 = Fabricate(:topic, user: user, created_at: 8.days.ago)
@@ -1739,7 +1739,7 @@ RSpec.describe TopicQuery do
before { topic.update!(category:) }
- it "should return new topics for user ordered by topics that user has created first, in the same category as the topic and then topic's bumped at" do
+ it "orders new topics by authorship, category, and bumped_at" do
expect(
topic_query.list_suggested_for(topic, include_random: false).topics.map(&:id),
).to eq(
@@ -1784,7 +1784,7 @@ RSpec.describe TopicQuery do
suggested_for(tt)
end
- it "should return empty results when there is nothing to find" do
+ it "returns empty results when nothing matches" do
expect(suggested_topics).to be_blank
end
@@ -1860,7 +1860,7 @@ RSpec.describe TopicQuery do
context "as user not part of group" do
let!(:user) { Fabricate(:user) }
- it "should not return topics by the group user" do
+ it "does not return topics by the group user" do
expect(suggested_topics).to eq([private_message.id])
end
end
@@ -1868,7 +1868,7 @@ RSpec.describe TopicQuery do
context "as user part of group" do
let!(:user) { group_user }
- it "should return the group topics" do
+ it "returns the group's topics" do
expect(suggested_topics).to match_array([private_group_topic.id, private_message.id])
end
@@ -1877,7 +1877,7 @@ RSpec.describe TopicQuery do
SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:trust_level_4]
end
- it "should not return topics by the group user" do
+ it "does not return topics by the group user" do
expect(suggested_topics).to eq(nil)
end
end
@@ -1887,7 +1887,7 @@ RSpec.describe TopicQuery do
let(:tag) { Fabricate(:tag) }
let!(:user) { group_user }
- it "should return only tagged topics" do
+ it "returns only tagged topics" do
Fabricate(:topic_tag, topic: private_message, tag: tag)
Fabricate(:topic_tag, topic: private_group_topic)
@@ -1995,13 +1995,13 @@ RSpec.describe TopicQuery do
let!(:topic5) { Fabricate(:topic, user: user, visible: false) }
let!(:topic6) { Fabricate(:topic, user: user2) }
- it "should return the right lists for anon user" do
+ it "returns the expected lists for an anonymous user" do
topics = TopicQuery.new.list_group_topics(group).topics
expect(topics).to contain_exactly(topic1, topic2, topic6)
end
- it "should return the right list for users in the same group" do
+ it "returns the expected list for users in the same group" do
topics = TopicQuery.new(user).list_group_topics(group).topics
expect(topics).to contain_exactly(topic1, topic2, topic3, topic6)
@@ -2011,7 +2011,7 @@ RSpec.describe TopicQuery do
expect(topics).to contain_exactly(topic1, topic2, topic3, topic6)
end
- it "should return the right list for user no in the group" do
+ it "returns the expected list for a user outside the group" do
topics = TopicQuery.new(user3).list_group_topics(group).topics
expect(topics).to contain_exactly(topic1, topic2, topic6)
@@ -2467,13 +2467,13 @@ RSpec.describe TopicQuery do
)
end
- it "should not return any topics if the user is anonymous" do
+ it "returns no topics when the user is anonymous" do
expect(
TopicQuery.new(nil, state: "watching_first_post").list_latest.topics.map(&:id),
).to eq([])
end
- it "should return the union of topics in watched categories and topics with watched tags" do
+ it "returns the union of watched-category and watched-tag topics" do
ids = TopicQuery.new(test_user, state: "watching_first_post").list_latest.topics.map(&:id)
expect(ids).to contain_exactly(
@@ -2483,7 +2483,7 @@ RSpec.describe TopicQuery do
)
end
- it "should work when combined with other filters" do
+ it "combines with other filters" do
topic_in_watched_category.update!(closed: true)
ids =
diff --git a/spec/lib/topic_retriever_spec.rb b/spec/lib/topic_retriever_spec.rb
index 7ebf56fae20..c1021255a9d 100644
--- a/spec/lib/topic_retriever_spec.rb
+++ b/spec/lib/topic_retriever_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe TopicRetriever do
end
describe "#retrieve" do
- context "when host is invalid" do
+ context "when the URL itself is invalid" do
before { topic_retriever.stubs(:invalid_url?).returns(true) }
it "does not perform_retrieve" do
diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rb
index a7c2b96b71c..fba4853eda7 100644
--- a/spec/lib/topic_view_spec.rb
+++ b/spec/lib/topic_view_spec.rb
@@ -310,7 +310,7 @@ RSpec.describe TopicView do
fab!(:p2) { Fabricate(:post, topic: topic, user: evil_trout, percent_rank: 0.5) }
fab!(:p3) { Fabricate(:post, topic: topic, user: first_poster, percent_rank: 0) }
- it "it can find the best responses" do
+ it "finds the best responses" do
best2 = TopicView.new(topic.id, evil_trout, best: 2)
expect(best2.posts.count).to eq(2)
expect(best2.posts[0].id).to eq(p2.id)
@@ -510,7 +510,7 @@ RSpec.describe TopicView do
before { TopicView.stubs(:chunk_size).returns(2) }
- it "should return the next page" do
+ it "returns the next page" do
expect(TopicView.new(topic.id, user, { post_number: post.post_number }).next_page).to eql(3)
end
end
@@ -581,7 +581,7 @@ RSpec.describe TopicView do
end
end
- describe "#bookmarks" do
+ describe "#bookmarks for regular bookmarks" do
let!(:user) { Fabricate(:user) }
let!(:bookmark1) do
Fabricate(:bookmark, bookmarkable: Fabricate(:post, topic: topic), user: user)
@@ -602,7 +602,7 @@ RSpec.describe TopicView do
end
end
- describe "#bookmarks" do
+ describe "#bookmarks for next-business-day reminders" do
let!(:user) { Fabricate(:user) }
let!(:bookmark1) do
Fabricate(:bookmark_next_business_day_reminder, bookmarkable: topic.first_post, user: user)
@@ -718,7 +718,7 @@ RSpec.describe TopicView do
end
describe "contains_gaps?" do
- it "works" do
+ it "returns the requested topic view" do
# does not contain contains_gaps with default filtering
expect(topic_view.contains_gaps?).to eq(false)
# contains contains_gaps when filtered by username" do
@@ -768,7 +768,7 @@ RSpec.describe TopicView do
describe "ascending" do
let(:asc) { true }
- it "should return the right posts" do
+ it "returns the expected posts" do
topic_view = create_topic_view(p3.post_number)
expect(topic_view.posts).to eq([p5])
@@ -781,7 +781,7 @@ RSpec.describe TopicView do
describe "descending" do
let(:asc) { false }
- it "should return the right posts" do
+ it "returns the expected posts" do
topic_view = create_topic_view(p7.post_number)
expect(topic_view.posts).to eq([p5, p3, p2])
@@ -1056,12 +1056,12 @@ RSpec.describe TopicView do
let!(:post2) { Fabricate(:post, topic: topic, user: evil_trout, created_at: 6.hours.ago) }
let!(:post3) { Fabricate(:post, topic: topic, user: first_poster) }
- it "should return the right columns" do
+ it "returns the expected columns" do
expect(topic_view.filtered_post_stream).to eq([[post.id, 1], [post2.id, 0], [post3.id, 0]])
end
describe "for mega topics" do
- it "should return the right columns" do
+ it "returns the expected columns" do
stub_const(TopicView, "MEGA_TOPIC_POSTS_COUNT", 2) do
expect(topic_view.filtered_post_stream).to eq([post.id, post2.id, post3.id])
end
@@ -1070,7 +1070,7 @@ RSpec.describe TopicView do
end
describe "#filtered_post_id" do
- it "should return the right id" do
+ it "returns the expected ID" do
post = Fabricate(:post, topic: topic)
expect(topic_view.filtered_post_id(nil)).to eq(nil)
@@ -1085,7 +1085,7 @@ RSpec.describe TopicView do
before { [p1, p2, p3].each_with_index { |post, index| post.update!(sort_order: index + 1) } }
- it "should return the right id" do
+ it "returns the expected ID" do
expect(topic_view.last_post_id).to eq(p3.id)
end
end
@@ -1102,7 +1102,7 @@ RSpec.describe TopicView do
topic_view.topic.reload
end
- it "should return the right read time" do
+ it "returns the expected read time" do
SiteSetting.read_time_word_count = 500
expect(topic_view.read_time).to eq(1)
diff --git a/spec/lib/topics_filter_spec.rb b/spec/lib/topics_filter_spec.rb
index 4d564226f70..f905443e5ba 100644
--- a/spec/lib/topics_filter_spec.rb
+++ b/spec/lib/topics_filter_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe TopicsFilter do
describe "#option_info" do
let(:options) { TopicsFilter.option_info(Guardian.new) }
- it "should return a correct hash with name and description keys for all" do
+ it "returns name and description keys for every option" do
expect(options).to be_an(Array)
expect(options).to all(be_a(Hash))
expect(options).to all(include(:name, :description))
@@ -17,7 +17,7 @@ RSpec.describe TopicsFilter do
expect(options.length).to be > 10
end
- it "should include nothing about tags when disabled" do
+ it "does not include tag options when tagging is disabled" do
SiteSetting.tagging_enabled = false
tag_options = options.find { |o| o[:name].include? "tag" }
@@ -30,7 +30,7 @@ RSpec.describe TopicsFilter do
expect(tag_options).not_to be_nil
end
- it "should advertise the - prefix for the group: option" do
+ it "advertises the - prefix for the group: option" do
group_option = options.find { |o| o[:name] == "group:" }
expect(group_option[:prefixes]).to contain_exactly(
@@ -38,7 +38,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should not include user-specific options for anonymous users" do
+ it "does not include user-specific options for anonymous users" do
anon_options = TopicsFilter.option_info(Guardian.new)
logged_in_options = TopicsFilter.option_info(user.guardian)
@@ -63,7 +63,7 @@ RSpec.describe TopicsFilter do
user_specific_options.each { |option| expect(logged_in_option_names).to include(option) }
end
- it "should apply the topics_filter_options modifier for authenticated users" do
+ it "applies the topics_filter_options modifier for authenticated users" do
plugin_instance = Plugin::Instance.new
DiscoursePluginRegistry.register_modifier(
plugin_instance,
@@ -354,7 +354,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_with_tag2) { Fabricate(:topic, tags: [tag2]) }
fab!(:closed_topic_with_tag2) { Fabricate(:topic, tags: [tag2], closed: true) }
- it "should return the right topics when query string is `status:closed tags:tag1,tag2`" do
+ it "returns matching topics for `status:closed tags:tag1,tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -376,7 +376,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `in:pinned`" do
- it "should return topics that are pinned" do
+ it "returns pinned topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -385,7 +385,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(pinned_topic.id)
end
- it "should not return pinned topics that have expired" do
+ it "does not return expired pinned topics" do
freeze_time(2.hours.from_now) do
expect(
TopicsFilter
@@ -481,7 +481,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should not return any topics when user is anonymous" do
+ it "returns no topics for an anonymous user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -490,7 +490,7 @@ RSpec.describe TopicsFilter do
).to eq([])
end
- it "should return topics that are bookmarked" do
+ it "returns bookmarked topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -501,7 +501,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `in:bookmarked in:pinnned`" do
- it "should return topics that are bookmarked and pinned" do
+ it "returns topics that are bookmarked and pinned" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -535,7 +535,7 @@ RSpec.describe TopicsFilter do
end
end
- it "should not return any topics if the user is anonymous" do
+ it "returns no topics when the user is anonymous" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -544,7 +544,7 @@ RSpec.describe TopicsFilter do
).to eq([])
end
- it "should return topics that the user has notification level set to #{notification_level}" do
+ it "returns topics set to the #{notification_level} notification level" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -587,7 +587,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `in:muted,invalid`" do
- it "should ignore the invalid notification level" do
+ it "ignores the invalid notification level" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -598,7 +598,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `in:muted in:tracking`" do
- it "should return topics that the user is tracking or has muted" do
+ it "returns topics that the user is tracking or has muted" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -609,7 +609,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `in:muted,tracking" do
- it "should return topics that the user is tracking or has muted" do
+ it "returns tracked or muted topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -649,7 +649,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should not return any topics if the user is anonymous" do
+ it "returns no topics when the user is anonymous" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -658,7 +658,7 @@ RSpec.describe TopicsFilter do
).to be_empty
end
- it "should return the union of topics in watched categories and topics with watched tags" do
+ it "returns the union of watched-category and watched-tag topics" do
ids =
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -672,7 +672,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should work when combined with other filters" do
+ it "combines with other filters" do
topic_in_watched_category.update!(closed: true)
ids =
@@ -684,7 +684,7 @@ RSpec.describe TopicsFilter do
expect(ids).to contain_exactly(topic_in_watched_category.id)
end
- it "should work with comma-separated notification levels" do
+ it "accepts comma-separated notification levels" do
user_watching_topic =
Fabricate(:topic).tap do |topic|
TopicUser.change(
@@ -766,7 +766,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_in_category2_subcategory) { Fabricate(:topic, category: category2_subcategory) }
describe "when query string is `category:category`" do
- it "should return topics from specified category and its subcategories" do
+ it "returns topics from the specified category and its subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -775,7 +775,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_in_category.id, topic_in_category_subcategory.id)
end
- it "should return topics from specified category, its subcategories and sub-subcategories" do
+ it "returns topics from the specified category and all descendant categories" do
SiteSetting.max_category_nesting = 3
category_subcategory_subcategory =
@@ -802,7 +802,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category,category2`" do
- it "should return topics from any of the specified categories and its subcategories" do
+ it "returns topics from any specified category and its subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -818,7 +818,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category category:category2`" do
- it "should return topics from any of the specified categories and its subcategories" do
+ it "returns topics from any specified category and its descendants" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -834,7 +834,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category =category:category2`" do
- it "should return topics and subcategory topics from category but only topics from category2" do
+ it "includes descendants only for categories marked with the subcategory option" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -849,7 +849,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-category:category`" do
- it "should not return any topics from specified category or its subcategories" do
+ it "excludes topics from the specified category and its subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -860,7 +860,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-category:category2,category`" do
- it "should not return any topics from either specified categories or their subcategories" do
+ it "excludes topics from either specified category and their subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -871,7 +871,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-category:category -category:category2-subcategory`" do
- it "should not return any topics from either specified category or their subcategories" do
+ it "excludes topics from each specified category and its descendants" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -882,7 +882,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-=category:category`" do
- it "should not return any topics from the specified category only" do
+ it "excludes topics only from the specified category" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -897,7 +897,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-=category:category,category2`" do
- it "should not return any topics from the specified categories only" do
+ it "excludes topics only from the specified categories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -908,7 +908,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `=category:category`" do
- it "should not return topics from subcategories`" do
+ it "does not return topics from subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -919,7 +919,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `=category:category,category2`" do
- it "should not return topics from subcategories" do
+ it "excludes subcategory topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -930,7 +930,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category2 -=category:category2-subcategory`" do
- it "should return topics from category2 and its subcategories but not from the category2-subcategory" do
+ it "returns category2 descendants except the excluded subcategory" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -953,7 +953,7 @@ RSpec.describe TopicsFilter do
before { SiteSetting.max_category_nesting = 3 }
- it "should return topics from category2, category2's sub-categories and category2's sub-sub-categories but not from the category2-subcategory only" do
+ it "returns category2 descendants except topics directly in the excluded subcategory" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -976,7 +976,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:日本語`" do
- it 'should return topics from category with slug "日本語"' do
+ it 'returns topics from the category with slug "日本語"' do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -989,7 +989,7 @@ RSpec.describe TopicsFilter do
describe "when query string is `category:日本語:안녕하세요`" do
before { category_subcategory.update!(name: "안녕하세요 ", slug: "안녕하세요 ") }
- it "should return topics from category with slug '안녕하세요'" do
+ it "returns topics from the category with slug '안녕하세요'" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1013,7 +1013,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_in_category2_subcategory) { Fabricate(:topic, category: category2_subcategory) }
describe "when query string is `category:subcategory`" do
- it "should return topics from subcategories of both categories" do
+ it "returns topics from subcategories of both categories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1027,7 +1027,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category:subcategory`" do
- it "should return topics from subcategories of the specified category" do
+ it "returns topics from subcategories of the specified category" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1038,7 +1038,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category2:subcategory`" do
- it "should return topics from subcategories of the specified category" do
+ it "returns matching topics from the specified category's subcategories" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1049,7 +1049,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `category:category:subcategory,category2:subcategory`" do
- it "should return topics from either subcategory" do
+ it "returns topics from either subcategory" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1188,7 +1188,7 @@ RSpec.describe TopicsFilter do
end
end
- it "should only return topics that have not been closed or archived when query string is `status:open`" do
+ it "returns only open topics for `status:open`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1197,7 +1197,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic.id)
end
- it "should only return topics that have been deleted when query string is `status:deleted` and user can see deleted topics" do
+ it "returns only deleted topics for authorized users with `status:deleted`" do
expect(
TopicsFilter
.new(guardian: Guardian.new(admin))
@@ -1206,7 +1206,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(deleted_topic_id)
end
- it "should ignore status filter when query string is `status:deleted` and user cannot see deleted topics" do
+ it "ignores `status:deleted` when the user cannot see deleted topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1215,7 +1215,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic.id, closed_topic.id, archived_topic.id, foobar_topic.id)
end
- it "should only return topics that have been archived when query string is `status:archived`" do
+ it "returns only archived topics for `status:archived`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1224,7 +1224,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(archived_topic.id)
end
- it "should only return topics that are visible when query string is `status:listed`" do
+ it "returns only visible topics for `status:listed`" do
Topic.update_all(visible: false)
topic.update!(visible: true)
@@ -1236,7 +1236,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic.id)
end
- it "should only return topics that are not visible when query string is `status:unlisted`" do
+ it "returns only unlisted topics for `status:unlisted`" do
Topic.update_all(visible: true)
topic.update!(visible: false)
@@ -1248,7 +1248,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic.id)
end
- it "should only return topics that are not in any read-restricted category when query string is `status:public`" do
+ it "returns only unrestricted topics for `status:public`" do
private_category = Fabricate(:private_category, group: group)
topic_in_private_category = Fabricate(:topic, category: private_category)
@@ -1267,7 +1267,7 @@ RSpec.describe TopicsFilter do
describe "when query string is `status:closed status:unlisted`" do
fab!(:closed_and_unlisted_topic) { Fabricate(:topic, closed: true, visible: false) }
- it "should only return topics that have been closed and are not visible" do
+ it "returns only closed and unlisted topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1281,7 +1281,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_without_replies) { Fabricate(:topic, posts_count: 1) }
fab!(:topic_with_replies) { Fabricate(:topic, posts_count: 2) }
- it "should only return topics that have no replies" do
+ it "returns only topics without replies" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1295,7 +1295,7 @@ RSpec.describe TopicsFilter do
fab!(:single_user_topic) { Fabricate(:topic, participant_count: 1) }
fab!(:multi_user_topic) { Fabricate(:topic, participant_count: 2) }
- it "should only return topics that have a single participant" do
+ it "returns only topics with one participant" do
topic_ids =
TopicsFilter
.new(guardian: Guardian.new)
@@ -1334,7 +1334,7 @@ RSpec.describe TopicsFilter do
fab!(:tag_synonym) { Fabricate(:tag, name: "synonym1", target_tag_id: tag.id) }
describe "when filtering by a tag synonym" do
- it "should return topics tagged with the target tag when query string is `tag:synonym1`" do
+ it "returns topics with the target tag for `tag:synonym1`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1343,7 +1343,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id)
end
- it "should return topics tagged with the target tag or other tags when query string is `tags:synonym1,tag2`" do
+ it "returns topics with the target or other tags for `tags:synonym1,tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1352,7 +1352,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id, topic_with_tag2.id)
end
- it "should exclude topics tagged with the target tag when query string is `-tag:synonym1`" do
+ it "excludes topics with the target tag for `-tag:synonym1`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1366,7 +1366,7 @@ RSpec.describe TopicsFilter do
end
end
- it "should not filter any topics by tags when tagging is disabled" do
+ it "does not filter topics by tag when tagging is disabled" do
SiteSetting.tagging_enabled = false
expect(
@@ -1384,7 +1384,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `tag:tag1+tag2`" do
- it "should only return topics that are tagged with all of the specified tags" do
+ it "returns only topics with all specified tags" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1394,7 +1394,7 @@ RSpec.describe TopicsFilter do
end
end
- it "should only return topics that are tagged with all of the specified tags when query string is `tags:tag1+tag2`" do
+ it "returns only topics with all tags for `tags:tag1+tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1403,7 +1403,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag_and_tag2.id)
end
- it "should return topics tagged with period-delimited tag names" do
+ it "returns topics with period-delimited tag names" do
tag_with_period = Fabricate(:tag, name: "node.js")
topic_with_period_tag = Fabricate(:topic, tags: [tag_with_period])
@@ -1415,7 +1415,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_period_tag.id)
end
- it "should only return topics that are tagged with tag1 and tag2 when query string is `tags:tag1 tags:tag2`" do
+ it "returns only topics with tag1 and tag2 for repeated tag filters" do
topic_with_tag_and_tag2_and_tag3 = Fabricate(:topic, tags: [tag, tag2, tag3])
expect(
@@ -1432,7 +1432,7 @@ RSpec.describe TopicsFilter do
fab!(:pri_high) { Fabricate(:tag, name: "pri-high") }
fab!(:pri_low) { Fabricate(:tag, name: "pri-low") }
- it "should only return topics that are tagged with front-end+pri-high, front-end+pri-low, back-end+pri-high, back-end+pri-low" do
+ it "returns topics matching each requested tag combination" do
topic_with_front_end_pri_high = Fabricate(:topic, tags: [front_end, pri_high])
topic_with_front_end_pri_low = Fabricate(:topic, tags: [front_end, pri_low])
topic_with_back_end_pri_high = Fabricate(:topic, tags: [back_end, pri_high])
@@ -1456,7 +1456,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should return topics that are tagged with front-end+back-end+pri-low or front-end+back-end+pri-high" do
+ it "returns topics matching either requested tag combination" do
topic_with_front_end_back_end_pri_low =
Fabricate(:topic, tags: [front_end, back_end, pri_low])
topic_with_front_end_back_end_pri_high =
@@ -1484,7 +1484,7 @@ RSpec.describe TopicsFilter do
fab!(:pri_high) { Fabricate(:tag, name: "pri-high") }
fab!(:pri_low) { Fabricate(:tag, name: "pri-low") }
- it "should only return topics tagged with front-end and or pri-high or pri-low" do
+ it "returns topics with front-end and either priority tag" do
topic_with_front_end_pri_high = Fabricate(:topic, tags: [front_end, pri_high])
topic_with_front_end_pri_low = Fabricate(:topic, tags: [front_end, pri_low])
topic_with_front_end_pri_high_pri_low =
@@ -1522,7 +1522,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `tags:tag1,tag2,tag3`" do
- it "should only return topics that are tagged with either tag1, tag2 or tag3" do
+ it "returns only topics with tag1, tag2, or tag3" do
topic_with_tag3 = Fabricate(:topic, tags: [tag3])
expect(
@@ -1540,7 +1540,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `tags:tag1+tag2+tag3`" do
- it "should only return topics that are tagged with tag1, tag2 and tag3" do
+ it "returns only topics with tag1, tag2, and tag3" do
topic_with_tag_tag2_tag3 = Fabricate(:topic, tags: [tag, tag2, tag3])
expect(
@@ -1552,7 +1552,7 @@ RSpec.describe TopicsFilter do
end
end
- it "should only return topics that are tagged with tag1 and tag2 but not tag3 when query string is `tags:tag1 tags:tag2 -tags:tag3`" do
+ it "returns topics with tag1 and tag2 but without tag3" do
_topic_with_tag_and_tag2_and_tag3 = Fabricate(:topic, tags: [tag, tag2, tag3])
expect(
@@ -1563,7 +1563,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag_and_tag2.id)
end
- it "should only return topics that are tagged with any of the specified tags when query string is `tags:tag1,tag2`" do
+ it "returns topics with any specified tag for `tags:tag1,tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1572,7 +1572,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id, topic_with_tag2.id)
end
- it "should not return any topics when query string is `tags:tag1+tag2+invalid`" do
+ it "returns no topics when an AND tag filter includes an invalid tag" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1581,7 +1581,7 @@ RSpec.describe TopicsFilter do
).to eq([])
end
- it "should still filter topics by specificed tags when query string is `tags:tag1,tag2,invalid`" do
+ it "filters by valid tags when an OR tag filter includes an invalid tag" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1590,7 +1590,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag_and_tag2.id, topic_with_tag.id, topic_with_tag2.id)
end
- it "should not return any topics when query string is `tags:group-only-tag` because specified tag is hidden to user" do
+ it "returns no topics when the specified tag is hidden from the user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1599,7 +1599,7 @@ RSpec.describe TopicsFilter do
).to eq([])
end
- it "should return the right topics when query string is `tags:group-only-tag` and user has access to specified tag" do
+ it "returns matching topics when the user can access the specified tag" do
group.add(admin)
expect(
@@ -1610,7 +1610,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_group_only_tag.id)
end
- it "should only return topics that are not tagged with specified tag when query string is `-tags:tag1`" do
+ it "returns only topics without the specified tag for `-tags:tag1`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1619,7 +1619,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_without_tag.id, topic_with_tag2.id, topic_with_group_only_tag.id)
end
- it "should only return topics that are not tagged with all of the specified tags when query string is `-tags:tag1+tag2`" do
+ it "excludes topics with all specified tags for `-tags:tag1+tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1633,7 +1633,7 @@ RSpec.describe TopicsFilter do
)
end
- it "should only return topics that are not tagged with any of the specified tags when query string is `-tags:tag1,tag2`" do
+ it "excludes topics with any specified tag for `-tags:tag1,tag2`" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1645,7 +1645,7 @@ RSpec.describe TopicsFilter do
describe "when query string is tag:日べé1" do
before { tag.update!(name: "日べé1") }
- it "should return topics that are tagged with the specified tag" do
+ it "returns topics with the specified tag" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1658,7 +1658,7 @@ RSpec.describe TopicsFilter do
describe "when query string is `tags:tag_name`" do
before { tag.update!(name: "tag_with_underscore") }
- it "should return topics even when tag contains underscore" do
+ it "returns topics when the tag contains an underscore" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1674,7 +1674,7 @@ RSpec.describe TopicsFilter do
tag2.update!(name: "tag_two")
end
- it "should return topics when filtering with comma-separated underscore tags" do
+ it "returns topics for comma-separated tags containing underscores" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1683,7 +1683,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id, topic_with_tag2.id)
end
- it "should return topics when filtering with plus-separated underscore tags" do
+ it "returns topics for plus-separated tags containing underscores" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1722,7 +1722,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_with_staff_only_tag) { Fabricate(:topic, tags: [staff_only_tag]) }
- it "should only return topics that are tagged with any of the specified tag_group when query string is tag_group:tag_group_name" do
+ it "returns topics with any tag in the specified tag group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1731,7 +1731,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id, topic_with_tag_and_tag2.id, topic_with_tag2.id)
end
- it "should only return topics that are not excluded by the specified tag_group when query string is -tag_group:tag_group_name" do
+ it "excludes topics with tags in the specified excluded tag group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1740,7 +1740,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag3.id, topic_without_tag.id, topic_with_staff_only_tag.id)
end
- it "should return the right topics when query string is `tag_group:staff_tag_group` and user has access to specified tag" do
+ it "returns matching topics when the user can access the tag group" do
group.add(admin)
expect(
@@ -1751,7 +1751,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_staff_only_tag.id)
end
- it "should not return any topics when query string is `tag_group:staff_tag_group` because specified tag is hidden to user" do
+ it "returns no topics when the tag group is hidden from the user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1775,7 +1775,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_with_tag) { Fabricate(:topic, tags: [tag]) }
fab!(:topic_without_tag, :topic)
- it "should filter by tag group name with spaces using double quotes" do
+ it "filters a double-quoted tag group name containing spaces" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1784,7 +1784,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id)
end
- it "should filter by tag group name with spaces using single quotes" do
+ it "filters a single-quoted tag group name containing spaces" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1793,7 +1793,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id)
end
- it "should filter by tag group name with ampersand" do
+ it "filters a tag group name containing an ampersand" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1802,7 +1802,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id)
end
- it "should filter by tag group name with parentheses" do
+ it "filters a tag group name containing parentheses" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1811,7 +1811,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id)
end
- it "should perform case-insensitive tag group lookup" do
+ it "looks up tag groups case-insensitively" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1820,7 +1820,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_with_tag.id)
end
- it "should handle exclude prefix with quoted tag group names" do
+ it "handles the exclusion prefix with quoted tag group names" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1829,7 +1829,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_without_tag.id)
end
- it "should maintain backward compatibility with unquoted tag group names" do
+ it "supports unquoted tag group names" do
simple_tag = Fabricate(:tag, name: "simple-tag")
_simple_group = Fabricate(:tag_group, name: "simple", tag_names: [simple_tag.name])
topic_simple = Fabricate(:topic, tags: [simple_tag])
@@ -1850,7 +1850,7 @@ RSpec.describe TopicsFilter do
fab!(:no_locale_topic, :topic)
describe "when query string is `locale:en`" do
- it "should only return topics with locale en" do
+ it "returns only topics with the en locale" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1861,7 +1861,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `locale:ja,es`" do
- it "should return topics with locale ja or es" do
+ it "returns topics with the ja or es locale" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1872,7 +1872,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `locale:ja locale:es`" do
- it "should return topics with locale ja or es" do
+ it "returns topics matching either ja or es locale filter" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1883,7 +1883,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-locale:en`" do
- it "should return topics without locale en" do
+ it "returns topics without the en locale" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1894,7 +1894,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `-locale:en,ja`" do
- it "should return topics without locale en or ja" do
+ it "returns topics without the en or ja locale" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1905,7 +1905,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `locale:invalid`" do
- it "should return no topics" do
+ it "returns no topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1918,7 +1918,7 @@ RSpec.describe TopicsFilter do
describe "when combining with other filters" do
before { en_topic.update!(closed: true) }
- it "should work with status:closed" do
+ it "combines with status:closed" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1936,7 +1936,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_by_user2) { Fabricate(:topic, user: user2) }
describe "when query string is `created-by:@username`" do
- it "should return the topics created by the specified user" do
+ it "returns topics created by the specified user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1947,7 +1947,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:@username2`" do
- it "should return the topics created by the specified user" do
+ it "returns topics created by the named user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1958,7 +1958,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:@username created-by:@username2`" do
- it "should return the topics created by either of the specified users" do
+ it "returns topics created by either specified user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1971,7 +1971,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:@username,invalid`" do
- it "should only return the topics created by the user with the valid username" do
+ it "returns only topics created by the user with a valid username" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1982,7 +1982,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:@username,@username2`" do
- it "should return the topics created by either of the specified users" do
+ it "returns topics created by any valid specified user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -1993,7 +1993,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:@invalid`" do
- it "should not return any topics" do
+ it "returns no topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2004,7 +2004,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:me`" do
- it "should return the topics created by the current user" do
+ it "returns topics created by the current user" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -2013,7 +2013,7 @@ RSpec.describe TopicsFilter do
).to contain_exactly(topic_by_user.id, topic2_by_user.id)
end
- it "should not return any topics when there is no current user" do
+ it "returns no topics when there is no current user" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2042,7 +2042,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_by_both_groups_user) { Fabricate(:topic, user: user_in_both_groups) }
describe "when query string is `created-by:group1`" do
- it "should return topics created by users in the specified group" do
+ it "returns topics created by users in the specified group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2053,7 +2053,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:group2`" do
- it "should return topics created by users in the specified group" do
+ it "returns topics from members of the named group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2064,7 +2064,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:group1,group2`" do
- it "should return topics created by users in any of the specified groups" do
+ it "returns topics created by users in any specified group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2079,7 +2079,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:invalid`" do
- it "should not return any topics" do
+ it "returns no topics" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2090,7 +2090,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `created-by:group1,invalid`" do
- it "should only return topics created by users in the valid group" do
+ it "returns only topics created by users in the valid group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2124,7 +2124,7 @@ RSpec.describe TopicsFilter do
fab!(:topic_by_super_private_group_user) do
Fabricate(:topic, user: user_in_super_private_group)
end
- it "should not return topics when user cannot see the group" do
+ it "returns no topics when the user cannot see the group" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2133,7 +2133,7 @@ RSpec.describe TopicsFilter do
).to eq([])
end
- it "should return topics when user is a member of the private group" do
+ it "returns topics when the user belongs to the private group" do
private_group.add(user)
expect(
@@ -2169,7 +2169,7 @@ RSpec.describe TopicsFilter do
shared_examples "filtering for topics by counts" do |filter|
describe "when query string is `#{filter}-min:1`" do
- it "should only return topics with at least 1 #{filter}" do
+ it "returns only topics with at least one #{filter}" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2180,7 +2180,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-min:3`" do
- it "should only return topics with at least 3 #{filter}" do
+ it "returns only topics with at least three #{filter}" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2191,7 +2191,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-max:1`" do
- it "should only return topics with at most 1 #{filter}" do
+ it "returns only topics with at most one #{filter}" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2202,7 +2202,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-max:3`" do
- it "should only return topics with at most 3 #{filter}" do
+ it "returns only topics with at most three #{filter}" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2213,7 +2213,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-min:1 #{filter}-max:2`" do
- it "should only return topics with at least 1 like and at most 2 #{filter}" do
+ it "returns topics with at least one like and at most two #{filter}" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2224,7 +2224,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-min:3 #{filter}-min:2 #{filter}-max:1 #{filter}-max:3`" do
- it "should only return topics with at least 2 #{filter} and at most 3 #{filter} as it ignores earlier filters which are duplicated" do
+ it "uses the last duplicate filters to constrain the #{filter} count" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2237,7 +2237,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-min:invalid #{filter}-max:invalid`" do
- it "should ignore the filters with invalid values" do
+ it "ignores filters with invalid values" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2304,7 +2304,7 @@ RSpec.describe TopicsFilter do
fab!(:topic2) { Fabricate(:topic, column => Time.zone.local(2023, 5, 12)) }
describe "when query string is `#{filter}-after:invalid-date-test`" do
- it "should ignore the filter" do
+ it "ignores the filter" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2315,7 +2315,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-after:2022-01-01`" do
- it "should only return topics with #{description} after 2022-01-01" do
+ it "returns only topics with #{description} after 2022-01-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2326,7 +2326,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-after:2023-01-1`" do
- it "should only return topics with #{description} after 2023-01-01" do
+ it "returns only topics with #{description} after 2023-01-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2337,7 +2337,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-after:2023-6-01`" do
- it "should only return topics with #{description} after 2023-06-01" do
+ it "returns only topics with #{description} after 2023-06-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2348,7 +2348,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-before:2023-01-01`" do
- it "should only return topics with #{description} before 2023-01-01" do
+ it "returns only topics with #{description} before 2023-01-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2359,7 +2359,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-before:2023-1-1`" do
- it "should only return topics with #{description} before 2023-01-01" do
+ it "returns only matching topics with #{description} before 2023-01-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2370,7 +2370,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-before:2000-01-01`" do
- it "should only return topics with #{description} before 2000-01-01" do
+ it "returns only topics with #{description} before 2000-01-01" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2381,7 +2381,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-after:1`" do
- it "should only return topics with #{description} after 1 day ago" do
+ it "returns only topics with #{description} after one day ago" do
freeze_time do
_old_topic = Fabricate(:topic, column => 2.days.ago)
recent_topic = Fabricate(:topic, column => Time.zone.now)
@@ -2397,7 +2397,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-before:1`" do
- it "should only return topics with #{description} before 1 day ago" do
+ it "returns only topics with #{description} before one day ago" do
freeze_time do
old_topic = Fabricate(:topic, column => 2.days.ago)
recent_topic = Fabricate(:topic, column => Time.zone.now)
@@ -2415,7 +2415,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `#{filter}-after:0`" do
- it "should only return topics with #{description} after today" do
+ it "returns only topics with #{description} after today" do
freeze_time do
_old_topic = Fabricate(:topic, column => 2.days.ago)
recent_topic = Fabricate(:topic, column => Time.zone.now)
@@ -2622,7 +2622,7 @@ RSpec.describe TopicsFilter do
# when ordered by the given filter in descending order.
shared_examples "ordering topics filters" do |order, order_description|
describe "when query string is `order:#{order}`" do
- it "should return topics ordered by #{order_description} in descending order" do
+ it "returns topics ordered by #{order_description} descending" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2633,7 +2633,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `order:#{order}-asc`" do
- it "should return topics ordered by #{order_description} in ascending order" do
+ it "returns topics ordered by #{order_description} ascending" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2644,7 +2644,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `order:#{order}-invalid`" do
- it "should return topics ordered by the database's default order" do
+ it "returns topics in the database's default order" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2763,7 +2763,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `order:read`" do
- it "should return topics ordered by last visited date in descending order for logged in users" do
+ it "orders topics by last visit descending for logged-in users" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -2772,7 +2772,7 @@ RSpec.describe TopicsFilter do
).to eq([topic2.id, topic.id, topic3.id])
end
- it "should not apply any special ordering for anonymous users" do
+ it "does not apply special ordering for anonymous users" do
topics =
TopicsFilter
.new(guardian: Guardian.new)
@@ -2784,7 +2784,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `order:read-asc`" do
- it "should return topics ordered by last visited date in ascending order for logged in users" do
+ it "orders topics by last visit ascending for logged-in users" do
expect(
TopicsFilter
.new(guardian: Guardian.new(user))
@@ -2801,7 +2801,7 @@ RSpec.describe TopicsFilter do
fab!(:topic3) { Fabricate(:topic, created_at: Time.zone.local(2024, 1, 1), views: 1) }
describe "when query string is `order:created,views`" do
- it "should return topics ordered by creation date in descending order and then number of views in descending order" do
+ it "orders topics by creation date and view count descending" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
@@ -2812,7 +2812,7 @@ RSpec.describe TopicsFilter do
end
describe "when query string is `order:created order:views`" do
- it "should return topics ordered by creation date in descending order and then number of views in descending order" do
+ it "uses creation date and view count as descending tie-breakers" do
expect(
TopicsFilter
.new(guardian: Guardian.new)
diff --git a/spec/lib/truncate_logs_formatter_spec.rb b/spec/lib/truncate_logs_formatter_spec.rb
index c1df6ea0f86..6aab6539a03 100644
--- a/spec/lib/truncate_logs_formatter_spec.rb
+++ b/spec/lib/truncate_logs_formatter_spec.rb
@@ -6,23 +6,23 @@ RSpec.describe TruncateLogsFormatter do
let(:formatter) { TruncateLogsFormatter.new(log_line_max_chars: 10) }
describe "when the messages is 5 characters long" do
- it "should not carry out any truncation of the message" do
+ it "does not truncate the message" do
expect(formatter.call(nil, nil, nil, "abcde")).to eq("abcde")
end
end
describe "when the message is 10 characters long" do
- it "should not carry out any truncation of the message" do
+ it "does not truncate the message" do
expect(formatter.call(nil, nil, nil, "aaaaaaaaaa")).to eq("aaaaaaaaaa")
end
end
describe "when the message is 11 characters long" do
- it "should truncate the message with the right postfix" do
+ it "truncates the message with the configured postfix" do
expect(formatter.call(nil, nil, nil, "aaaaaaaaaaa")).to eq("aaaaaaaaaa...(truncated)")
end
- it "should truncate the message with the right postfix while preserving newlines" do
+ it "truncates the message while preserving newlines" do
expect(formatter.call(nil, nil, nil, "aaaaaaaaaaa\n")).to eq("aaaaaaaaaa...(truncated)\n")
end
end
diff --git a/spec/lib/turbo_tests/flaky/manager_spec.rb b/spec/lib/turbo_tests/flaky/manager_spec.rb
index c6cc28e651c..e66392da309 100644
--- a/spec/lib/turbo_tests/flaky/manager_spec.rb
+++ b/spec/lib/turbo_tests/flaky/manager_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe TurboTests::Flaky::Manager do
end
describe ".potential_flaky_tests" do
- it "should return the failed examples' `location_rerun_argument`" do
+ it "returns the failed examples' location_rerun_argument" do
with_fake_path do
TurboTests::Flaky::Manager.log_potential_flaky_tests([fake_example_1, fake_example_2])
@@ -69,7 +69,7 @@ RSpec.describe TurboTests::Flaky::Manager do
end
describe ".log_potential_flaky_tests" do
- it "should log the failed examples correctly" do
+ it "logs the failed examples" do
with_fake_path do
TurboTests::Flaky::Manager.log_potential_flaky_tests([fake_example_1, fake_example_2])
@@ -105,7 +105,7 @@ RSpec.describe TurboTests::Flaky::Manager do
end
describe ".remove_example" do
- it "should remove the from the log file" do
+ it "removes the examples from the log file" do
with_fake_path do
TurboTests::Flaky::Manager.log_potential_flaky_tests([fake_example_1, fake_example_2])
TurboTests::Flaky::Manager.remove_example([rspec_example_1])
@@ -117,7 +117,7 @@ RSpec.describe TurboTests::Flaky::Manager do
end
end
- it "should delete the log file if there are no more examples" do
+ it "deletes the log file when no examples remain" do
with_fake_path do
TurboTests::Flaky::Manager.log_potential_flaky_tests([fake_example_1, fake_example_2])
TurboTests::Flaky::Manager.remove_example([rspec_example_1, rspec_example_2])
diff --git a/spec/lib/unread_spec.rb b/spec/lib/unread_spec.rb
index c5409fe9a23..ea73a21adc7 100644
--- a/spec/lib/unread_spec.rb
+++ b/spec/lib/unread_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Unread do
end
describe "staff counts" do
- it "should correctly return based on staff post number" do
+ it "calculates unread posts from the staff post number" do
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
user.grant_admin!
@@ -34,7 +34,7 @@ RSpec.describe Unread do
end
describe "unread_posts" do
- it "should have 0 unread posts if the user has read all posts" do
+ it "returns zero unread posts when the user has read every post" do
topic_user.last_read_post_number = 13
expect(unread.unread_posts).to eq(0)
end
@@ -57,7 +57,7 @@ RSpec.describe Unread do
expect(unread.unread_posts).to eq(5)
end
- it "should have 0 unread posts if the user has read more posts than exist (deleted)" do
+ it "returns zero unread posts when deleted posts exceed the remaining unread count" do
topic_user.last_read_post_number = 14
expect(unread.unread_posts).to eq(0)
end
diff --git a/spec/lib/upload_creator_spec.rb b/spec/lib/upload_creator_spec.rb
index c9af39f403b..90e539511c9 100644
--- a/spec/lib/upload_creator_spec.rb
+++ b/spec/lib/upload_creator_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe UploadCreator do
let(:filename) { "utf-8.txt" }
let(:file) { file_from_fixtures(filename, "encodings") }
- it "should store the upload with the right extension" do
+ it "stores the upload with the expected extension" do
expect do UploadCreator.new(file, "utf-8\n.txt").create_for(user.id) end.to change {
Upload.count
}.by(1)
@@ -125,7 +125,7 @@ RSpec.describe UploadCreator do
let(:longextension) { "fake.long-FileExtension" }
let(:file2) { file_from_fixtures(longextension) }
- it "should truncate long extension names" do
+ it "truncates long extension names" do
expect do
UploadCreator.new(file2, "fake.long-FileExtension").create_for(user.id)
end.to change { Upload.count }.by(1)
@@ -143,7 +143,7 @@ RSpec.describe UploadCreator do
before { SiteSetting.authorized_extensions = "jpg" }
- it "should create the right upload" do
+ it "creates the expected upload" do
upload =
UploadCreator.new(file, filename, for_site_setting: true).create_for(
Discourse.system_user.id,
@@ -180,7 +180,7 @@ RSpec.describe UploadCreator do
let(:filename) { "tiff_as.bin" }
let(:file) { file_from_fixtures(filename) }
- it "should not correct the coerce filename" do
+ it "does not correct the coerced filename" do
expect do UploadCreator.new(file, filename).create_for(user.id) end.to change {
Upload.count
}.by(1)
@@ -317,7 +317,7 @@ RSpec.describe UploadCreator do
let(:filename) { "pngquant.png" }
let(:file) { file_from_fixtures(filename) }
- it "should apply pngquant to optimized images" do
+ it "applies pngquant to optimized images" do
upload =
UploadCreator.new(file, filename, pasted: true, force_optimize: true).create_for(user.id)
@@ -354,7 +354,7 @@ RSpec.describe UploadCreator do
before { SiteSetting.png_to_jpg_quality = 1 }
- it "should not store file as jpeg if it does not meet absolute byte saving requirements" do
+ it "does not store a JPEG when the absolute byte savings are insufficient" do
# logo.png is 2297 bytes, converting to jpeg saves 30% but does not meet
# the absolute savings required of 25_000 bytes, if you save less than that
# skip this
@@ -375,7 +375,7 @@ RSpec.describe UploadCreator do
expect(upload.original_filename).to eq("logo.png")
end
- it "should store the upload with the right extension" do
+ it "stores the upload with the expected extension" do
expect do
UploadCreator.new(file, filename, pasted: true, force_optimize: true).create_for(user.id)
end.to change { Upload.count }.by(1)
@@ -389,7 +389,7 @@ RSpec.describe UploadCreator do
expect(FastImage.size(Discourse.store.path_for(upload))).to eq([303, 231])
end
- it "should not convert to jpeg when the image is uploaded from site setting" do
+ it "does not convert site-setting images to JPEG" do
upload =
UploadCreator.new(
large_file,
@@ -403,7 +403,7 @@ RSpec.describe UploadCreator do
expect(upload.original_filename).to eq("large_and_unoptimized.png")
end
- it "should not convert to jpeg for admin asset upload types" do
+ it "does not convert admin asset uploads to JPEG" do
upload =
UploadCreator.new(
large_file,
@@ -424,7 +424,7 @@ RSpec.describe UploadCreator do
SiteSetting.image_preview_jpg_quality = 10
end
- it "should alter the image quality" do
+ it "alters the image quality" do
upload = UploadCreator.new(file, filename, force_optimize: true).create_for(user.id)
expect(image_quality(upload.url)).to eq(SiteSetting.recompress_original_jpg_quality)
@@ -437,7 +437,7 @@ RSpec.describe UploadCreator do
)
end
- it "should not convert animated images" do
+ it "does not convert animated images" do
expect do
UploadCreator.new(animated_file, animated_filename, force_optimize: true).create_for(
user.id,
@@ -458,7 +458,7 @@ RSpec.describe UploadCreator do
SiteSetting.image_preview_jpg_quality = 10
end
- it "should not convert to jpeg when png_to_jpg_quality is 100" do
+ it "does not convert to JPEG when png_to_jpg_quality is 100" do
upload =
UploadCreator.new(large_file, large_filename, force_optimize: true).create_for(
user.id,
@@ -469,7 +469,7 @@ RSpec.describe UploadCreator do
expect(upload.original_filename).to eq("large_and_unoptimized.png")
end
- it "should not convert pasted images to jpeg when png_to_jpg_quality is 100" do
+ it "does not convert pasted images when png_to_jpg_quality is 100" do
upload =
UploadCreator.new(
large_file,
@@ -484,7 +484,7 @@ RSpec.describe UploadCreator do
end
end
- it "should not convert animated WEBP images" do
+ it "does not convert animated WebP images" do
expect do
UploadCreator.new(
animated_webp_file,
@@ -506,7 +506,7 @@ RSpec.describe UploadCreator do
let(:filename) { "should_be_jpeg.heic" }
let(:file) { file_from_fixtures(filename, "images") }
- it "should store the upload with the right extension" do
+ it "stores the upload with the expected extension" do
expect do
UploadCreator.new(file, filename, force_optimize: true).create_for(user.id)
end.to change { Upload.count }.by(1)
@@ -532,14 +532,14 @@ RSpec.describe UploadCreator do
SiteSetting.authorized_extensions = "pdf|svg|jpg"
end
- it "should mark attachments as secure" do
+ it "marks attachments as secure" do
upload = UploadCreator.new(file, filename, opts).create_for(user.id)
stored_upload = Upload.last
expect(stored_upload.secure?).to eq(true)
end
- it "should not mark theme uploads as secure" do
+ it "does not mark theme uploads as secure" do
fname = "custom-theme-icon-sprite.svg"
upload = UploadCreator.new(file_from_fixtures(fname), fname, for_theme: true).create_for(-1)
@@ -570,7 +570,7 @@ RSpec.describe UploadCreator do
stub_s3_store
end
- it "should store the file and return etag" do
+ it "stores the file and returns its ETag" do
expect { UploadCreator.new(file, filename).create_for(user.id) }.to change {
Upload.count
}.by(1)
@@ -580,7 +580,7 @@ RSpec.describe UploadCreator do
expect(upload.etag).to eq("ETag")
end
- it "should return signed URL for secure attachments in S3" do
+ it "returns a signed URL for secure S3 attachments" do
SiteSetting.authorized_extensions = "pdf"
SiteSetting.secure_uploads = true
@@ -593,7 +593,7 @@ RSpec.describe UploadCreator do
expect(signed_url).to match(/Amz-Credential/)
end
- it "should return CDN URL when enabled" do
+ it "returns the CDN URL when enabled" do
SiteSetting.s3_use_cdn_url_for_all_uploads = true
SiteSetting.authorized_extensions = "pdf"
SiteSetting.s3_cdn_url = "https://example-cdn.com"
@@ -795,7 +795,7 @@ RSpec.describe UploadCreator do
let(:animated_filename) { "animated.gif" }
let(:animated_file) { file_from_fixtures(animated_filename) }
- it "should not be cropped if animated" do
+ it "does not crop animated images" do
upload =
UploadCreator.new(
animated_file,
@@ -858,7 +858,7 @@ RSpec.describe UploadCreator do
let(:zero_sized_svg_filename) { "zero_sized.svg" }
let(:zero_sized_svg_file) { file_from_fixtures(zero_sized_svg_filename) }
- it "should be viewable when a dimension is a fraction of a unit" do
+ it "remains viewable when a dimension is fractional" do
upload =
UploadCreator.new(tiny_svg_file, tiny_svg_filename, force_optimize: true).create_for(
user.id,
@@ -871,7 +871,7 @@ RSpec.describe UploadCreator do
expect(upload.thumbnail_height).to be <= SiteSetting.max_image_height
end
- it "should not be larger than the maximum thumbnail size" do
+ it "does not exceed the maximum thumbnail size" do
upload =
UploadCreator.new(massive_svg_file, massive_svg_filename, force_optimize: true).create_for(
user.id,
@@ -884,7 +884,7 @@ RSpec.describe UploadCreator do
expect(upload.thumbnail_height).to be <= SiteSetting.max_image_height
end
- it "should handle zero dimension files" do
+ it "handles files with a zero dimension" do
upload =
UploadCreator.new(
zero_sized_svg_file,
diff --git a/spec/lib/url_helper_spec.rb b/spec/lib/url_helper_spec.rb
index 2d29593db6d..142dc8f3acf 100644
--- a/spec/lib/url_helper_spec.rb
+++ b/spec/lib/url_helper_spec.rb
@@ -176,7 +176,7 @@ RSpec.describe UrlHelper do
let(:url) { "/#{Discourse.store.upload_path}/1X/575bcc2886bf7a39684b57ca90be85f7d399bbc7.png" }
let(:asset_host) { "//my.awesome.cdn" }
- it "should return correct cdn url for local relative urls" do
+ it "returns CDN URLs for local relative URLs" do
set_cdn_url asset_host
cdn_url = UrlHelper.local_cdn_url(url)
expect(cdn_url).to eq("#{asset_host}#{url}")
@@ -271,42 +271,42 @@ RSpec.describe UrlHelper do
end
describe ".is_valid_url?" do
- it "should return true for a valid HTTP URL" do
+ it "accepts a valid HTTP URL" do
expect(described_class.is_valid_url?("http://www.example.com")).to eq(true)
end
- it "should return true for a valid HTTPS URL" do
+ it "accepts a valid HTTPS URL" do
expect(described_class.is_valid_url?("https://www.example.com")).to eq(true)
end
- it "should return true for a valid FTP URL" do
+ it "accepts a valid FTP URL" do
expect(described_class.is_valid_url?("ftp://example.com")).to eq(true)
end
- it "should return true for a valid mailto URL" do
+ it "accepts a valid mailto URL" do
expect(described_class.is_valid_url?("mailto:[email protected]")).to eq(true)
end
- it "should return true for a valid LDAP URL" do
+ it "accepts a valid LDAP URL" do
expect(described_class.is_valid_url?("ldap://ldap.example.com/dc=example;dc=com?quer")).to eq(
true,
)
end
- it "should return true for a path" do
+ it "accepts a path" do
expect(described_class.is_valid_url?("/some/path")).to eq(true)
end
- it "should return true for a path with query params" do
+ it "accepts a path with query parameters" do
expect(described_class.is_valid_url?("/some/path?query=param")).to eq(true)
end
- it "should return true for anchor links" do
+ it "accepts anchor links" do
expect(described_class.is_valid_url?("#anchor")).to eq(true)
expect(described_class.is_valid_url?("#")).to eq(true)
end
- it "should return false for invalid urls" do
+ it "rejects invalid URLs" do
expect(described_class.is_valid_url?("")).to eq(false)
expect(described_class.is_valid_url?("http//www.example.com")).to eq(false)
expect(described_class.is_valid_url?("http:/www.example.com")).to eq(false)
diff --git a/spec/lib/user_name_suggester_spec.rb b/spec/lib/user_name_suggester_spec.rb
index cdfea5d5a09..fd79e663a8e 100644
--- a/spec/lib/user_name_suggester_spec.rb
+++ b/spec/lib/user_name_suggester_spec.rb
@@ -122,7 +122,7 @@ RSpec.describe UserNameSuggester do
expect(UserNameSuggester.suggest("Darth_-_Vader")).to eq("Darth_Vader")
end
- it "should handle typical facebook usernames" do
+ it "handles typical Facebook usernames" do
expect(UserNameSuggester.suggest("roger.nelson.3344913")).to eq("roger.nelson.33")
end
diff --git a/spec/lib/validators/allowed_ip_address_validator_spec.rb b/spec/lib/validators/allowed_ip_address_validator_spec.rb
index 69c3fb3b23a..f217c28ecd4 100644
--- a/spec/lib/validators/allowed_ip_address_validator_spec.rb
+++ b/spec/lib/validators/allowed_ip_address_validator_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe AllowedIpAddressValidator do
let(:validator) { described_class.new(attributes: :ip_address) }
context "when ip address should be blocked" do
- it "should add an error" do
+ it "adds an error" do
ScreenedIpAddress.stubs(:should_block?).returns(true)
validate
expect(record.errors[:ip_address]).to be_present
@@ -18,7 +18,7 @@ RSpec.describe AllowedIpAddressValidator do
end
context "when ip address isn't allowed for registration" do
- it "should add an error" do
+ it "adds an error" do
SpamHandler.stubs(:should_prevent_registration_from_ip?).returns(true)
validate
expect(record.errors[:ip_address]).to be_present
@@ -31,7 +31,7 @@ RSpec.describe AllowedIpAddressValidator do
end
context "when ip address should not be blocked" do
- it "shouldn't add an error" do
+ it "does not add an error" do
ScreenedIpAddress.stubs(:should_block?).returns(false)
validate
expect(record.errors[:ip_address]).not_to be_present
@@ -39,7 +39,7 @@ RSpec.describe AllowedIpAddressValidator do
end
context "when ip_address is nil" do
- it "shouldn't add an error" do
+ it "does not add an error" do
ScreenedIpAddress.expects(:should_block?).never
record.ip_address = nil
validate
diff --git a/spec/lib/validators/category_search_priority_weights_validator_spec.rb b/spec/lib/validators/category_search_priority_weights_validator_spec.rb
index 3bafa112add..15b0a874ad6 100644
--- a/spec/lib/validators/category_search_priority_weights_validator_spec.rb
+++ b/spec/lib/validators/category_search_priority_weights_validator_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe CategorySearchPriorityWeightsValidator do
- it "should validate the results correctly" do
+ it "validates category search priority weights" do
[1, 1.1].each do |value|
expect do SiteSetting.category_search_priority_low_weight = value end.to raise_error(
Discourse::InvalidParameters,
diff --git a/spec/lib/validators/email_address_validator_spec.rb b/spec/lib/validators/email_address_validator_spec.rb
index a51d6373ac5..52225017544 100644
--- a/spec/lib/validators/email_address_validator_spec.rb
+++ b/spec/lib/validators/email_address_validator_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe EmailAddressValidator do
- it "should match valid emails" do
+ it "matches valid email addresses" do
[
@@ -10,7 +10,7 @@ RSpec.describe EmailAddressValidator do
].each { |email| expect(EmailAddressValidator.valid_value?(email)).to eq(true) }
end
- it "should not match invalid emails" do
+ it "rejects invalid email addresses" do
[
"testdiscourse.org",
"frank@invalid_host.contoso.com",
diff --git a/spec/lib/validators/enable_discourse_id_validator_spec.rb b/spec/lib/validators/enable_discourse_id_validator_spec.rb
index ec6fd3eaf8d..99174f74a2b 100644
--- a/spec/lib/validators/enable_discourse_id_validator_spec.rb
+++ b/spec/lib/validators/enable_discourse_id_validator_spec.rb
@@ -11,13 +11,13 @@ RSpec.describe EnableDiscourseIdValidator do
end
describe "when value is false" do
- it "should be valid" do
+ it "accepts disabling Discourse ID" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should be valid" do
+ it "accepts enabling Discourse ID" do
expect(validator.valid_value?("t")).to eq(true)
end
end
@@ -27,20 +27,20 @@ RSpec.describe EnableDiscourseIdValidator do
before { SiteSetting.discourse_id_client_id = "" }
describe "when value is false" do
- it "should be valid" do
+ it "accepts disabling Discourse ID" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should automatically register" do
+ it "registers automatically" do
allow(DiscourseId::Register).to receive(:call).and_return(
instance_double(Service::Base::Context, success?: true),
)
expect(validator.valid_value?("t")).to eq(true)
end
- it "should show an appropriate error message when something went wrong" do
+ it "returns the registration error message" do
failed_context = Service::Base::Context.new
failed_context.fail(error: "an error")
allow(DiscourseId::Register).to receive(:call).and_return(failed_context)
@@ -66,7 +66,7 @@ RSpec.describe EnableDiscourseIdValidator do
before { SiteSetting.discourse_id_client_secret = "" }
describe "when value is false" do
- it "should be valid" do
+ it "accepts disabling Discourse ID" do
expect(validator.valid_value?("f")).to eq(true)
end
end
diff --git a/spec/lib/validators/enable_local_logins_via_email_validator_spec.rb b/spec/lib/validators/enable_local_logins_via_email_validator_spec.rb
index ff68d47a608..a3be95a830a 100644
--- a/spec/lib/validators/enable_local_logins_via_email_validator_spec.rb
+++ b/spec/lib/validators/enable_local_logins_via_email_validator_spec.rb
@@ -8,13 +8,13 @@ RSpec.describe EnableLocalLoginsViaEmailValidator do
before { SiteSetting.enable_local_logins = false }
describe "when val is false" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should not be valid" do
+ it "rejects the setting value" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -28,13 +28,13 @@ RSpec.describe EnableLocalLoginsViaEmailValidator do
before { SiteSetting.enable_local_logins = true }
describe "when val is false" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("t")).to eq(true)
end
end
diff --git a/spec/lib/validators/enable_sso_validator_spec.rb b/spec/lib/validators/enable_sso_validator_spec.rb
index eb218792f20..eb89f680f4b 100644
--- a/spec/lib/validators/enable_sso_validator_spec.rb
+++ b/spec/lib/validators/enable_sso_validator_spec.rb
@@ -8,13 +8,13 @@ RSpec.describe EnableSsoValidator do
before { SiteSetting.discourse_connect_url = "" }
describe "when val is false" do
- it "should be valid" do
+ it "accepts disabling DiscourseConnect" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should not be valid" do
+ it "rejects enabling DiscourseConnect without a URL" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -31,13 +31,13 @@ RSpec.describe EnableSsoValidator do
end
describe "when value is false" do
- it "should be valid" do
+ it "accepts disabling DiscourseConnect" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should be valid" do
+ it "accepts enabling DiscourseConnect" do
expect(validator.valid_value?("t")).to eq(true)
end
end
@@ -47,13 +47,13 @@ RSpec.describe EnableSsoValidator do
before { SiteSetting.discourse_connect_url = "https://www.example.com/sso" }
describe "when val is false" do
- it "should be valid" do
+ it "accepts disabling DiscourseConnect" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should not be valid" do
+ it "rejects enabling DiscourseConnect without a secret" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -70,7 +70,7 @@ RSpec.describe EnableSsoValidator do
end
describe "when value is true" do
- it "should not be valid" do
+ it "rejects enabling DiscourseConnect with a short secret" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -86,13 +86,13 @@ RSpec.describe EnableSsoValidator do
SiteSetting.discourse_connect_secret = "x" * 10
end
- it "should be invalid" do
+ it "rejects enabling DiscourseConnect when second factor is enforced" do
SiteSetting.enforce_second_factor = "all"
expect(validator.valid_value?("t")).to eq(false)
end
- it "should be valid" do
+ it "accepts enabling DiscourseConnect when second factor is optional" do
SiteSetting.enforce_second_factor = "no"
expect(validator.valid_value?("t")).to eq(true)
diff --git a/spec/lib/validators/ip_address_format_validator_spec.rb b/spec/lib/validators/ip_address_format_validator_spec.rb
index d0c5abc71bb..371d5cffb5f 100644
--- a/spec/lib/validators/ip_address_format_validator_spec.rb
+++ b/spec/lib/validators/ip_address_format_validator_spec.rb
@@ -7,20 +7,20 @@ RSpec.describe IpAddressFormatValidator do
let(:validator) { described_class.new(attributes: :ip_address) }
%w[99.232.23.123 99.232.0.0/16 fd12:db8::ff00:42:8329 fc00::/7].each do |arg|
- it "should not add an error for #{arg}" do
+ it "accepts #{arg}" do
record.ip_address = arg
validate
expect(record.errors[:ip_address]).not_to be_present
end
end
- it "should add an error for nil IP address" do
+ it "adds an error for a nil IP address" do
record.ip_address = nil
validate
expect(record.errors[:ip_address]).to be_present
end
- it "should add an error for invalid IP address" do
+ it "adds an error for an invalid IP address" do
record.ip_address = "99.99.99"
validate
expect(record.errors[:ip_address]).to be_present
diff --git a/spec/lib/validators/linkedin_oidc_credentials_validator_spec.rb b/spec/lib/validators/linkedin_oidc_credentials_validator_spec.rb
index e3419dbe181..63f7f088e16 100644
--- a/spec/lib/validators/linkedin_oidc_credentials_validator_spec.rb
+++ b/spec/lib/validators/linkedin_oidc_credentials_validator_spec.rb
@@ -11,13 +11,13 @@ RSpec.describe LinkedinOidcCredentialsValidator do
end
describe "when val is false" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("t")).to eq(true)
end
end
@@ -30,13 +30,13 @@ RSpec.describe LinkedinOidcCredentialsValidator do
end
describe "when value is false" do
- it "should be valid" do
+ it "accepts the setting value" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should not be valid" do
+ it "rejects the setting value" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
diff --git a/spec/lib/validators/post_validator_spec.rb b/spec/lib/validators/post_validator_spec.rb
index 3bc1490255c..8cbdb3c74af 100644
--- a/spec/lib/validators/post_validator_spec.rb
+++ b/spec/lib/validators/post_validator_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe PostValidator do
let(:validator) { PostValidator.new({}) }
describe "post_body_validator" do
- it "should not allow a post with an empty raw" do
+ it "rejects a post with an empty body" do
post.raw = ""
validator.post_body_validator(post)
expect(post.errors).to_not be_empty
@@ -15,7 +15,7 @@ RSpec.describe PostValidator do
context "when empty raw can bypass validation" do
let(:validator) { PostValidator.new(skip_post_body: true) }
- it "should be allowed for empty raw based on site setting" do
+ it "accepts an empty body when enabled in site settings" do
post.raw = ""
validator.post_body_validator(post)
expect(post.errors).to be_empty
@@ -36,7 +36,7 @@ RSpec.describe PostValidator do
)
end
- it "should allow a post with an empty raw" do
+ it "accepts a post with an empty body" do
post = Fabricate.build(:post, topic: topic)
post.raw = ""
validator.post_body_validator(post)
@@ -138,20 +138,20 @@ RSpec.describe PostValidator do
end
describe "max_posts_validator" do
- it "should be invalid when the user has posted too much" do
+ it "rejects new posts when the user exceeds the posting limit" do
post.user.expects(:posted_too_much_in_topic?).returns(true)
validator.max_posts_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be allowed to edit when the user has posted too much" do
+ it "allows edits when the user exceeds the posting limit" do
post.user.stubs(:posted_too_much_in_topic?).returns(true)
post.expects(:new_record?).returns(false)
validator.max_posts_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid when the user hasn't posted too much" do
+ it "accepts posts within the user's posting limit" do
post.user.expects(:posted_too_much_in_topic?).returns(false)
validator.max_posts_validator(post)
expect(post.errors.count).to be(0)
@@ -183,12 +183,12 @@ RSpec.describe PostValidator do
context "when post is unique" do
let(:new_post) { Fabricate.build(:post, user: user, raw: "unique content", topic: topic) }
- it "should not add an error" do
+ it "does not add a validation error" do
validator.unique_post_validator(new_post)
expect(new_post.errors.count).to eq(0)
end
- it "should not add an error when changing an existing post" do
+ it "does not add an error when changing an existing post" do
post.raw = "changing raw"
validator.unique_post_validator(post)
@@ -206,21 +206,21 @@ RSpec.describe PostValidator do
)
end
- it "should add an error for post dupes" do
+ it "adds an error for duplicate posts" do
new_post = build_post(is_pm: false, raw: post.raw)
validator.unique_post_validator(new_post)
expect(new_post.errors.to_hash.keys).to contain_exactly(:raw)
end
- it "should add an error for pm dupes" do
+ it "adds an error for duplicate PMs" do
new_post = build_post(is_pm: true, raw: pm_post.raw)
validator.unique_post_validator(new_post)
expect(new_post.errors.to_hash.keys).to contain_exactly(:raw)
end
- it "should not add an error for cross PM / topic dupes" do
+ it "allows duplicate content across PMs and topics" do
new_post = build_post(is_pm: true, raw: post.raw)
validator.unique_post_validator(new_post)
@@ -232,7 +232,7 @@ RSpec.describe PostValidator do
expect(new_post.errors.count).to eq(0)
end
- it "should not add an error if post.skip_unique_check is true" do
+ it "skips duplicate validation when post.skip_unique_check is true" do
new_post = build_post(is_pm: false, raw: post.raw)
new_post.skip_unique_check = true
@@ -248,28 +248,28 @@ RSpec.describe PostValidator do
SiteSetting.max_mentions_per_post = 3
end
- it "should be invalid when new user exceeds max mentions limit" do
+ it "rejects new users exceeding the mention limit" do
post.acting_user = build(:newuser)
post.expects(:raw_mentions).returns(%w[jake finn jake_old])
validator.max_mention_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be invalid when leader user exceeds max mentions limit" do
+ it "rejects leader users exceeding the mention limit" do
post.acting_user = build(:trust_level_4)
post.expects(:raw_mentions).returns(%w[jake finn jake_old jake_new])
validator.max_mention_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be valid when new user does not exceed max mentions limit" do
+ it "accepts new users within the mention limit" do
post.acting_user = build(:newuser)
post.expects(:raw_mentions).returns(%w[jake finn])
validator.max_mention_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid when new user exceeds max mentions limit in PM" do
+ it "accepts new users exceeding the mention limit in a PM" do
post.acting_user = build(:newuser)
post.topic.expects(:private_message?).returns(true)
post.expects(:raw_mentions).returns(%w[jake finn jake_old])
@@ -277,21 +277,21 @@ RSpec.describe PostValidator do
expect(post.errors.count).to be(0)
end
- it "should be valid when leader user does not exceed max mentions limit" do
+ it "accepts leader users within the mention limit" do
post.acting_user = build(:trust_level_4)
post.expects(:raw_mentions).returns(%w[jake finn jake_old])
validator.max_mention_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid for moderator in all cases" do
+ it "exempts moderators from the mention limit" do
post.acting_user = build(:moderator)
post.expects(:raw_mentions).never
validator.max_mention_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid for admin in all cases" do
+ it "exempts admins from the mention limit" do
post.acting_user = build(:admin)
post.expects(:raw_mentions).never
validator.max_mention_validator(post)
@@ -348,21 +348,21 @@ RSpec.describe PostValidator do
SiteSetting.newuser_max_embedded_media = 2
end
- it "should be invalid when new user exceeds max mentions limit" do
+ it "rejects new users exceeding the mention limit" do
post.acting_user = new_user
post.expects(:embedded_media_count).returns(3)
validator.max_embedded_media_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be valid when new user does not exceed max mentions limit" do
+ it "accepts new users within the mention limit" do
post.acting_user = new_user
post.expects(:embedded_media_count).returns(2)
validator.max_embedded_media_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be invalid when user trust level is not sufficient" do
+ it "rejects users with insufficient trust level" do
SiteSetting.embedded_media_post_allowed_groups = Group::AUTO_GROUPS[:trust_level_4]
post.acting_user = Fabricate(:leader, groups: [])
post.expects(:embedded_media_count).returns(2)
@@ -370,14 +370,14 @@ RSpec.describe PostValidator do
expect(post.errors.count).to be > 0
end
- it "should be valid for moderator in all cases" do
+ it "accepts moderator posts" do
post.acting_user = Fabricate(:moderator)
post.expects(:embedded_media_count).never
validator.max_embedded_media_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid for admin in all cases" do
+ it "accepts admin posts" do
post.acting_user = Fabricate(:admin)
post.expects(:embedded_media_count).never
validator.max_embedded_media_validator(post)
@@ -390,28 +390,28 @@ RSpec.describe PostValidator do
before { SiteSetting.newuser_max_attachments = 2 }
- it "should be invalid when new user exceeds max attachments limit" do
+ it "rejects new users exceeding the attachment limit" do
post.acting_user = new_user
post.expects(:attachment_count).returns(3)
validator.max_attachments_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be valid when new user does not exceed max attachments limit" do
+ it "accepts new users within the attachment limit" do
post.acting_user = new_user
post.expects(:attachment_count).returns(2)
validator.max_attachments_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid for moderator in all cases" do
+ it "exempts moderators from the attachment limit" do
post.acting_user = Fabricate(:moderator)
post.expects(:attachment_count).never
validator.max_attachments_validator(post)
expect(post.errors.count).to be(0)
end
- it "should be valid for admin in all cases" do
+ it "exempts admins from the attachment limit" do
post.acting_user = Fabricate(:admin)
post.expects(:attachment_count).never
validator.max_attachments_validator(post)
@@ -424,14 +424,14 @@ RSpec.describe PostValidator do
before { SiteSetting.newuser_max_links = 2 }
- it "should be invalid when new user exceeds max links limit" do
+ it "rejects new users exceeding the link limit" do
post.acting_user = new_user
post.stubs(:link_count).returns(3)
validator.max_links_validator(post)
expect(post.errors.count).to be > 0
end
- it "should be valid when new user does not exceed max links limit" do
+ it "accepts new users within the link limit" do
post.acting_user = new_user
post.stubs(:link_count).returns(2)
validator.max_links_validator(post)
@@ -446,7 +446,7 @@ RSpec.describe PostValidator do
before { SiteSetting.max_consecutive_replies = 2 }
- it "should always allow original poster to post" do
+ it "allows the original poster to post" do
[user, user, user, other_user, user, user, user].each_with_index do |u, i|
post = Post.new(user: u, topic: topic, raw: "post number #{i}")
validator.force_edit_last_validator(post)
@@ -455,7 +455,7 @@ RSpec.describe PostValidator do
end
end
- it "should allow category moderators to post more than 2 consecutive replies" do
+ it "allows category moderators to post more than two consecutive replies" do
SiteSetting.enable_category_group_moderation = true
group = Fabricate(:group)
GroupUser.create(group: group, user: user)
@@ -472,7 +472,7 @@ RSpec.describe PostValidator do
expect(post.errors.count).to eq(0)
end
- it "should not allow posting more than 2 consecutive replies" do
+ it "rejects more than two consecutive replies" do
Post.create!(user: user, topic: topic, raw: "post number 2", post_number: 2)
Post.create!(user: user, topic: topic, raw: "post number 3", post_number: 3)
Post.create!(user: other_user, topic: topic, raw: "post number 1", post_number: 1)
@@ -482,7 +482,7 @@ RSpec.describe PostValidator do
expect(post.errors.count).to eq(1)
end
- it "should always allow editing" do
+ it "allows editing regardless of consecutive replies" do
post = Fabricate(:post, user: user, topic: topic)
post = Fabricate(:post, user: user, topic: topic)
@@ -490,7 +490,7 @@ RSpec.describe PostValidator do
revisor.revise!(post.user, raw: "hello world123456789")
end
- it "should allow posting more than 2 replies" do
+ it "allows posting more than two replies" do
3.times do
post = Fabricate(:post, user: user, topic: topic)
Fabricate(:post, user: other_user, topic: topic)
diff --git a/spec/lib/validators/regex_presence_validator_spec.rb b/spec/lib/validators/regex_presence_validator_spec.rb
index cac2332a2aa..5dc8ec7ded1 100644
--- a/spec/lib/validators/regex_presence_validator_spec.rb
+++ b/spec/lib/validators/regex_presence_validator_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe RegexPresenceValidator do
end
describe "when value is empty" do
- it "should not be valid" do
+ it "is invalid" do
expect(validator.valid_value?("")).to eq(false)
expect(validator.error_message).to eq(I18n.t("site_settings.errors.must_include_latest"))
diff --git a/spec/lib/validators/sso_overrides_email_validator_spec.rb b/spec/lib/validators/sso_overrides_email_validator_spec.rb
index 14cb29b36f7..92e4fa18ec0 100644
--- a/spec/lib/validators/sso_overrides_email_validator_spec.rb
+++ b/spec/lib/validators/sso_overrides_email_validator_spec.rb
@@ -13,13 +13,13 @@ RSpec.describe SsoOverridesEmailValidator do
end
describe "when val is false" do
- it "should be valid" do
+ it "is valid" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should not be valid" do
+ it "is invalid" do
expect(validator.valid_value?("t")).to eq(false)
expect(validator.error_message).to eq(
@@ -38,13 +38,13 @@ RSpec.describe SsoOverridesEmailValidator do
end
describe "when value is false" do
- it "should be valid" do
+ it "is valid" do
expect(validator.valid_value?("f")).to eq(true)
end
end
describe "when value is true" do
- it "should be valid" do
+ it "is valid" do
expect(validator.valid_value?("t")).to eq(true)
end
end
diff --git a/spec/lib/wizard/step_updater_spec.rb b/spec/lib/wizard/step_updater_spec.rb
index 1252fda6091..5ed99754898 100644
--- a/spec/lib/wizard/step_updater_spec.rb
+++ b/spec/lib/wizard/step_updater_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Wizard::StepUpdater do
expect(wizard.completed_steps?("setup")).to eq(true)
end
- it "won't allow updates to the default value when required" do
+ it "prevents updates to a required default value" do
updater =
wizard.create_updater(
"setup",
diff --git a/spec/lib/wizard/wizard_builder_spec.rb b/spec/lib/wizard/wizard_builder_spec.rb
index b333cf8a4ee..361ef1f8289 100644
--- a/spec/lib/wizard/wizard_builder_spec.rb
+++ b/spec/lib/wizard/wizard_builder_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe Wizard::Builder do
describe "setup step" do
let(:setup_step) { wizard.steps.find { |s| s.id == "setup" } }
- it "should not prefill default site setting values" do
+ it "does not prefill default site setting values" do
fields = setup_step.fields
title_field = fields.first
@@ -43,7 +43,7 @@ RSpec.describe Wizard::Builder do
expect(title_field.value).to eq("")
end
- it "should prefill overridden site setting values" do
+ it "prefills overridden site setting values" do
SiteSetting.title = "foobar"
fields = setup_step.fields
@@ -53,7 +53,7 @@ RSpec.describe Wizard::Builder do
expect(title_field.value).to eq("foobar")
end
- it "should set the right default value for privacy fields" do
+ it "sets the default privacy field values" do
SiteSetting.login_required = true
SiteSetting.invite_only = false
SiteSetting.must_approve_users = true
diff --git a/spec/mailers/test_mailer_spec.rb b/spec/mailers/test_mailer_spec.rb
index f612d283dfd..e1f993736d3 100644
--- a/spec/mailers/test_mailer_spec.rb
+++ b/spec/mailers/test_mailer_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe TestMailer do
describe "send_test" do
- it "works" do
+ it "builds the test email" do
test_mailer = TestMailer.send_test("[email protected]")
expect(test_mailer.from).to eq([SiteSetting.notification_email])
diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb
index af18031a1f4..26c6dc80439 100644
--- a/spec/mailers/user_notifications_spec.rb
+++ b/spec/mailers/user_notifications_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe UserNotifications do
let(:email_html) { Email::Renderer.new(email).html }
- it "works" do
+ it "addresses the signup email to the user with a subject and body" do
expect(email.to).to eq([user.email])
expect(email.subject).to be_present
expect(email.from).to eq([SiteSetting.notification_email])
@@ -80,7 +80,7 @@ RSpec.describe UserNotifications do
describe ".forgot_password" do
subject(:email) { UserNotifications.forgot_password(user) }
- it "works" do
+ it "addresses the password reset email to the user with a subject and body" do
expect(email.to).to eq([user.email])
expect(email.subject).to be_present
expect(email.from).to eq([SiteSetting.notification_email])
@@ -103,7 +103,7 @@ RSpec.describe UserNotifications do
describe ".post_approved" do
fab!(:post)
- it "works" do
+ it "addresses the post approval email to the user with a subject and body" do
subject =
UserNotifications.post_approved(user, { notification_data_hash: { post_url: post.url } })
@@ -225,7 +225,7 @@ RSpec.describe UserNotifications do
let!(:another_post) { Fabricate(:post, topic: another_popular_topic, post_number: 1) }
- it "works" do
+ it "builds the digest with content, topic headers, and unsubscribe headers" do
expect(email.to).to eq([user.email])
expect(email.subject).to be_present
expect(email.from).to eq([SiteSetting.notification_email])
@@ -660,7 +660,7 @@ RSpec.describe UserNotifications do
describe "max_tags_per_email_subject siteSetting enabled" do
before { SiteSetting.enable_max_tags_per_email_subject = true }
- it "should match max_tags_per_email_subject" do
+ it "limits subject tags to max_tags_per_email_subject" do
SiteSetting.email_subject =
"[%{site_name}] %{optional_pm}%{optional_cat}%{optional_tags}%{topic_title}"
SiteSetting.max_tags_per_topic = 1
@@ -683,7 +683,7 @@ RSpec.describe UserNotifications do
describe "max_tags_per_email_subject siteSetting disabled" do
before { SiteSetting.enable_max_tags_per_email_subject = false }
- it "should match max_tags_per_topic" do
+ it "limits subject tags to max_tags_per_topic" do
SiteSetting.email_subject =
"[%{site_name}] %{optional_pm}%{optional_cat}%{optional_tags}%{topic_title}"
SiteSetting.max_tags_per_topic = 2
@@ -705,7 +705,7 @@ RSpec.describe UserNotifications do
end
describe "optional placeholders in email body" do
- it "should render optional_tags, optional_cat, optional_pm, and optional_re in body templates" do
+ it "renders optional_tags, optional_cat, optional_pm, and optional_re in body templates" do
custom_body = <<~BODY
You got a reply!
@@ -1142,7 +1142,7 @@ RSpec.describe UserNotifications do
shared_examples "supports reply by email" do
context "with reply_by_email" do
- it "should have allow_reply_by_email set when that feature is enabled" do
+ it "sets allow_reply_by_email when the feature is enabled" do
expects_build_with(has_entry(:allow_reply_by_email, true))
end
end
@@ -1271,23 +1271,23 @@ RSpec.describe UserNotifications do
expects_build_with(has_key(:topic_id))
end
- it "should have user name as from_alias" do
+ it "uses the user's name as from_alias" do
SiteSetting.enable_names = true
SiteSetting.display_name_on_posts = true
expects_build_with(has_entry(:from_alias, user.name))
end
- it "should not have user name as from_alias if display_name_on_posts is disabled" do
+ it "omits the user's name from from_alias when display_name_on_posts is disabled" do
SiteSetting.enable_names = false
SiteSetting.display_name_on_posts = false
expects_build_with(has_entry(:from_alias, "walterwhite"))
end
- it "should explain how to respond" do
+ it "explains how to respond" do
expects_build_with(Not(has_entry(:include_respond_instructions, false)))
end
- it "should not explain how to respond if the user is suspended" do
+ it "omits response instructions for suspended users" do
User.any_instance.stubs(:suspended?).returns(true)
expects_build_with(has_entry(:include_respond_instructions, false))
end
@@ -1314,7 +1314,7 @@ RSpec.describe UserNotifications do
)
end
- it "shouldn't use the default html_override" do
+ it "does not use the default html_override" do
expects_build_with(Not(has_key(:html_override)))
end
end
@@ -1401,7 +1401,7 @@ RSpec.describe UserNotifications do
notification.save!
end
- it "should include the group name" do
+ it "includes the group name" do
expects_build_with(has_entry(:group_name, group.name))
end
@@ -1450,7 +1450,7 @@ RSpec.describe UserNotifications do
)
end
- it "sends the email as the inviter" do
+ it "uses the inviter's username when names are disabled" do
SiteSetting.enable_names = false
expect(mailer.message.to_s).to include(
@@ -1458,7 +1458,7 @@ RSpec.describe UserNotifications do
)
end
- it "sends the email as the inviter" do
+ it "uses the inviter's name as the sender" do
expect(mailer.message.to_s).to include(
"From: #{inviter.name} <#{SiteSetting.notification_email}>",
)
diff --git a/spec/mailers/version_mailer_spec.rb b/spec/mailers/version_mailer_spec.rb
index 9e2da3c2203..ca507178618 100644
--- a/spec/mailers/version_mailer_spec.rb
+++ b/spec/mailers/version_mailer_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe VersionMailer do
context "when contact_email is set" do
before { SiteSetting.contact_email = "[email protected]" }
- it "works" do
+ it "addresses the version email with a subject" do
expect(mail.to).to eq(["[email protected]"])
expect(mail.subject).to be_present
expect(mail.from).to eq([SiteSetting.notification_email])
diff --git a/spec/models/api_key_scope_spec.rb b/spec/models/api_key_scope_spec.rb
index f6a917e93a2..81f81026c18 100644
--- a/spec/models/api_key_scope_spec.rb
+++ b/spec/models/api_key_scope_spec.rb
@@ -2,13 +2,13 @@
RSpec.describe ApiKeyScope do
describe ".find_urls" do
- it "should return the right urls" do
+ it "returns the URL and method for creating posts" do
expect(ApiKeyScope.find_urls(actions: ["posts#create"], methods: [])).to contain_exactly(
"/posts (POST)",
)
end
- it "should return logster urls" do
+ it "returns Logster URLs" do
expect(ApiKeyScope.find_urls(actions: [Logster::Web], methods: [])).to contain_exactly(
"/logs/messages.json (POST)",
"/logs/show/:id.json (GET)",
diff --git a/spec/models/category_featured_topic_spec.rb b/spec/models/category_featured_topic_spec.rb
index 79b55fbc3d0..e6ba81b885f 100644
--- a/spec/models/category_featured_topic_spec.rb
+++ b/spec/models/category_featured_topic_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe CategoryFeaturedTopic do
expect(CategoryFeaturedTopic.where(topic_id: post2.topic_id).count).to eq(1)
end
- it "should feature topics for a secure category" do
+ it "features topics for a secure category" do
# so much dancing, I am thinking fixures make sense here.
user.change_trust_level!(TrustLevel[1])
@@ -49,7 +49,7 @@ RSpec.describe CategoryFeaturedTopic do
expect(CategoryFeaturedTopic.count).to be(1)
end
- it "should not include invisible topics" do
+ it "does not include invisible topics" do
invisible_post =
PostCreator.create(
user,
@@ -62,7 +62,7 @@ RSpec.describe CategoryFeaturedTopic do
expect(CategoryFeaturedTopic.count).to be(1)
end
- it "should feature stuff in the correct order" do
+ it "features topics in the correct order" do
category = Fabricate(:category, num_featured_topics: 2)
_t5 = Fabricate(:topic, category_id: category.id, bumped_at: 12.minutes.ago)
t4 = Fabricate(:topic, category_id: category.id, bumped_at: 10.minutes.ago)
diff --git a/spec/models/category_list_spec.rb b/spec/models/category_list_spec.rb
index a7f3aceb8c4..023744cad7b 100644
--- a/spec/models/category_list_spec.rb
+++ b/spec/models/category_list_spec.rb
@@ -191,7 +191,7 @@ RSpec.describe CategoryList do
let(:topic) { Fabricate(:topic, category: topic_category) }
let(:category) { category_list.categories.find { |c| c.id == topic_category.id } }
- it "should return the category" do
+ it "returns the topic's category" do
expect(category).to be_present
expect(category.id).to eq(topic_category.id)
expect(category.featured_topics.include?(topic)).to eq(true)
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index d93f37620f7..0fab201507b 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -123,7 +123,7 @@ RSpec.describe Category do
expect { Fabricate(:category) }.to change { CategorySetting.count }.by(1)
end
- it "should delete associated sidebar_section_links when category is destroyed" do
+ it "deletes associated sidebar_section_links when the category is destroyed" do
category_sidebar_section_link = Fabricate(:category_sidebar_section_link)
category_sidebar_section_link_2 =
Fabricate(:category_sidebar_section_link, linkable: category_sidebar_section_link.linkable)
@@ -730,13 +730,13 @@ RSpec.describe Category do
expect(permalink.url).to eq(old_url[1..-1])
end
- it "should not set its description topic to auto-close" do
+ it "does not set its description topic to auto-close" do
category = Fabricate(:category_with_definition, name: "Closing Topics", auto_close_hours: 1)
expect(category.topic.public_topic_timer).to eq(nil)
end
describe "creating a new category with the same slug" do
- it "should have a blank slug if at the same level" do
+ it "has a blank slug at the same level" do
category = Fabricate(:category_with_definition, name: "Amazing Categóry")
expect(category.slug).to be_blank
expect(category.slug_for_url).to eq("#{category.id}-category")
@@ -786,7 +786,7 @@ RSpec.describe Category do
end
describe "update" do
- it "should enforce uniqueness of slug" do
+ it "enforces slug uniqueness" do
Fabricate(:category_with_definition, slug: "the-slug")
c2 = Fabricate(:category_with_definition, slug: "different-slug")
c2.slug = "the-slug"
@@ -824,7 +824,7 @@ RSpec.describe Category do
end
describe "latest" do
- it "should be updated correctly" do
+ it "updates correctly" do
category = freeze_time(1.minute.ago) { Fabricate(:category_with_definition) }
post = create_post(category: category.id, created_at: 15.seconds.ago)
@@ -1017,14 +1017,14 @@ RSpec.describe Category do
end
describe ".query_parent_category" do
- it "should return the parent category id given a parent slug" do
+ it "returns the parent category ID for a parent slug" do
parent_category.name = "Amazing Category"
expect(parent_category.id).to eq(Category.query_parent_category(parent_category.slug))
end
end
describe ".query_category" do
- it "should return the category" do
+ it "returns the category" do
category =
Fabricate(
:category_with_definition,
@@ -1125,7 +1125,7 @@ RSpec.describe Category do
end
describe "auto bump" do
- it "should correctly automatically bump topics" do
+ it "automatically bumps topics correctly" do
freeze_time
category = Fabricate(:category_with_definition, created_at: 1.minute.ago)
category.clear_auto_bump_cache!
@@ -1169,7 +1169,7 @@ RSpec.describe Category do
expect(Category.auto_bump_topic!).to eq(false)
end
- it "should not auto-bump the same topic within the cooldown" do
+ it "does not auto-bump the same topic during the cooldown" do
freeze_time
category =
Fabricate(
@@ -1203,7 +1203,7 @@ RSpec.describe Category do
expect(Topic.where(bumped_at: time).count).to eq(1)
end
- it "should not automatically bump topics with a bump scheduled" do
+ it "does not auto-bump topics with a scheduled bump" do
freeze_time
category = Fabricate(:category_with_definition, created_at: 1.second.ago)
category.clear_auto_bump_cache!
@@ -1251,7 +1251,7 @@ RSpec.describe Category do
end
context "when changing subcategory permissions" do
- it "it is not valid if permissions are less restrictive" do
+ it "is invalid when permissions are less restrictive" do
subcategory.set_permissions(group => :readonly)
subcategory.save!
@@ -1347,13 +1347,13 @@ RSpec.describe Category do
SQL
describe "#depth_of_descendants" do
- it "should produce max_depth" do
+ it "produces max_depth" do
expect(category.depth_of_descendants(3)).to eq(3)
end
end
describe "#height_of_ancestors" do
- it "should produce max_height" do
+ it "produces max_height" do
expect(category.height_of_ancestors(3)).to eq(3)
end
end
@@ -1363,13 +1363,13 @@ RSpec.describe Category do
before { category.parent_category_id = category.id }
describe "#depth_of_descendants" do
- it "should produce max_depth" do
+ it "produces max_depth" do
expect(category.depth_of_descendants(3)).to eq(3)
end
end
describe "#height_of_ancestors" do
- it "should produce max_height" do
+ it "produces max_height" do
expect(category.height_of_ancestors(3)).to eq(3)
end
end
@@ -1379,34 +1379,34 @@ RSpec.describe Category do
before { category.parent_category_id = subcategory.id }
describe "#depth_of_descendants" do
- it "should produce max_depth" do
+ it "produces max_depth" do
expect(category.depth_of_descendants(3)).to eq(3)
end
end
describe "#height_of_ancestors" do
- it "should produce max_height" do
+ it "produces max_height" do
expect(category.height_of_ancestors(3)).to eq(3)
end
end
end
describe "#depth_of_descendants" do
- it "should be 0 when the category has no descendants" do
+ it "is 0 when the category has no descendants" do
expect(subcategory.depth_of_descendants).to eq(0)
end
- it "should be 1 when the category has a descendant" do
+ it "is 1 when the category has a descendant" do
expect(category.depth_of_descendants).to eq(1)
end
end
describe "#height_of_ancestors" do
- it "should be 0 when the category has no ancestors" do
+ it "is 0 when the category has no ancestors" do
expect(category.height_of_ancestors).to eq(0)
end
- it "should be 1 when the category has an ancestor" do
+ it "is 1 when the category has an ancestor" do
expect(subcategory.height_of_ancestors).to eq(1)
end
end
@@ -1512,7 +1512,7 @@ RSpec.describe Category do
fab!(:category)
describe "when category is uncategorized" do
- it "should return the reason" do
+ it "returns the reason" do
category = Category.find(SiteSetting.uncategorized_category_id)
expect(category.cannot_delete_reason).to eq(I18n.t("category.cannot_delete.uncategorized"))
@@ -1520,7 +1520,7 @@ RSpec.describe Category do
end
describe "when category has subcategories" do
- it "should return the right reason" do
+ it "returns the expected reason" do
category.subcategories << Fabricate(:category)
expect(category.cannot_delete_reason).to eq(
@@ -1530,7 +1530,7 @@ RSpec.describe Category do
end
describe "when category has topics" do
- it "should return the right reason" do
+ it "returns the expected reason" do
topic =
Fabricate(
:topic,
@@ -1555,7 +1555,7 @@ RSpec.describe Category do
describe "#deleting the general category" do
fab!(:category)
- it "should empty out the general_category_id site_setting" do
+ it "clears the general_category_id site setting" do
SiteSetting.general_category_id = category.id
category.destroy
diff --git a/spec/models/category_user_spec.rb b/spec/models/category_user_spec.rb
index 16e9aafad39..c2293b89b6a 100644
--- a/spec/models/category_user_spec.rb
+++ b/spec/models/category_user_spec.rb
@@ -30,13 +30,13 @@ RSpec.describe CategoryUser do
).pluck(:category_id)
end
- it "should add new records where required" do
+ it "adds missing category notification records" do
CategoryUser.batch_set(user, :watching, [category.id])
expect(category_ids_at_level(:watching)).to eq([category.id])
end
- it "should change existing records where required" do
+ it "updates existing category notification records" do
CategoryUser.create!(
user_id: user.id,
category_id: category.id,
@@ -49,7 +49,7 @@ RSpec.describe CategoryUser do
expect(category_ids_at_level(:muted)).to eq([])
end
- it "should delete extraneous records where required" do
+ it "deletes extraneous category notification records" do
CategoryUser.create!(
user_id: user.id,
category_id: category.id,
@@ -61,18 +61,18 @@ RSpec.describe CategoryUser do
expect(category_ids_at_level(:watching)).to eq([])
end
- it "should return true when something changed" do
+ it "returns true when something changes" do
expect(CategoryUser.batch_set(user, :watching, [category.id])).to eq(true)
end
- it "should return false when nothing changed" do
+ it "returns false when nothing changes" do
CategoryUser.batch_set(user, :watching, [category.id])
expect(CategoryUser.batch_set(user, :watching, [category.id])).to eq(false)
end
end
- it "should correctly auto_track" do
+ it "automatically tracks topics according to category preferences" do
tracking_user = Fabricate(:user)
topic = Fabricate(:post).topic
@@ -128,7 +128,7 @@ RSpec.describe CategoryUser do
NotificationEmailer.enable
end
- it "should operate correctly" do
+ it "applies watched, muted, and tracked category preferences to topics" do
watched_category = Fabricate(:category)
muted_category = Fabricate(:category)
tracked_category = Fabricate(:category)
diff --git a/spec/models/discourse_connect_spec.rb b/spec/models/discourse_connect_spec.rb
index 784d0df9b78..fdd3623944d 100644
--- a/spec/models/discourse_connect_spec.rb
+++ b/spec/models/discourse_connect_spec.rb
@@ -497,7 +497,7 @@ RSpec.describe DiscourseConnect do
expect(user.username).to eq "testuser"
end
- it "should preserve username when several users login with the same username" do
+ it "preserves usernames when several users log in with the same username" do
SiteSetting.auth_overrides_username = true
# if several users have username "bill" on the external site,
diff --git a/spec/models/draft_sequence_spec.rb b/spec/models/draft_sequence_spec.rb
index f2c2d731644..f185bba67b9 100644
--- a/spec/models/draft_sequence_spec.rb
+++ b/spec/models/draft_sequence_spec.rb
@@ -6,12 +6,12 @@ RSpec.describe DraftSequence do
let!(:topic_draft_key) { Draft::NEW_TOPIC + "_0001" }
describe ".next" do
- it "should produce next sequence for a key" do
+ it "produces the next sequence for a key" do
expect(DraftSequence.next!(user, topic_draft_key)).to eq 1
expect(DraftSequence.next!(user, topic_draft_key)).to eq 2
end
- it "should not produce next sequence for non-human user" do
+ it "does not produce a sequence for a non-human user" do
user.id = -99_999
2.times { expect(DraftSequence.next!(user, "test")).to eq(0) }
end
@@ -43,16 +43,16 @@ RSpec.describe DraftSequence do
end
describe ".current" do
- it "should return 0 by default" do
+ it "returns zero by default" do
expect(DraftSequence.current(user, "test")).to eq 0
end
- it "should return nil for non-human user" do
+ it "returns nil for a non-human user" do
user.id = -99_999
expect(DraftSequence.current(user, "test")).to eq(0)
end
- it "should return the right sequence" do
+ it "returns the current sequence" do
expect(DraftSequence.next!(user, "test")).to eq(1)
expect(DraftSequence.current(user, "test")).to eq(1)
end
diff --git a/spec/models/draft_spec.rb b/spec/models/draft_spec.rb
index 18286de9989..52999a34c48 100644
--- a/spec/models/draft_spec.rb
+++ b/spec/models/draft_spec.rb
@@ -68,26 +68,26 @@ RSpec.describe Draft do
expect(Draft.get(Fabricate(:user), "test", 0)).to eq nil
end
- it "should overwrite draft data correctly" do
+ it "overwrites draft data correctly" do
seq = Draft.set(user, "test", 0, "data")
seq = Draft.set(user, "test", seq, "new data")
expect(Draft.get(user, "test", seq)).to eq "new data"
end
- it "should increase the sequence on every save" do
+ it "increments the sequence on every save" do
seq = Draft.set(user, "test", 0, "data")
expect(seq).to eq(0)
seq = Draft.set(user, "test", 0, "data")
expect(seq).to eq(1)
end
- it "should clear drafts on request" do
+ it "clears drafts on request" do
Draft.set(user, "test", 0, "data")
Draft.clear(user, "test", 0)
expect(Draft.get(user, "test", 0)).to eq nil
end
- it "should cross check with DraftSequence table" do
+ it "cross-checks the DraftSequence table" do
Draft.set(user, "test", 0, "old")
expect(Draft.get(user, "test", 0)).to eq "old"
@@ -111,7 +111,7 @@ RSpec.describe Draft do
)
end
- it "should disregard old draft if sequence decreases" do
+ it "disregards an old draft when the sequence decreases" do
Draft.set(user, "test", 0, "data")
DraftSequence.next!(user, "test")
Draft.set(user, "test", 1, "hello")
@@ -123,7 +123,7 @@ RSpec.describe Draft do
expect(Draft.get(user, "test", 1)).to eq "hello"
end
- it "should disregard draft sequence if force_save is true" do
+ it "disregards the draft sequence when force_save is true" do
Draft.set(user, "test", 0, "data")
DraftSequence.next!(user, "test")
Draft.set(user, "test", 1, "hello")
@@ -193,19 +193,19 @@ RSpec.describe Draft do
let(:stream) { Draft.stream(user: user) }
- it "should include the correct number of drafts in the stream" do
+ it "includes the correct number of drafts in the stream" do
Draft.set(user, "test", 0, '{"reply":"hey.","action":"createTopic","title":"Hey"}')
Draft.set(user, "test2", 0, '{"reply":"howdy"}')
expect(stream.count).to eq(2)
end
- it "should include the right topic id in a draft reply in the stream" do
+ it "includes the expected topic ID for a draft reply in the stream" do
Draft.set(user, "topic_#{public_topic.id}", 0, '{"reply":"hi"}')
draft_row = stream.first
expect(draft_row.topic_id).to eq(public_topic.id)
end
- it "should include the right draft username in the stream" do
+ it "includes the expected draft username in the stream" do
Draft.set(user, "topic_#{public_topic.id}", 0, '{"reply":"hey"}')
draft_row = stream.first
expect(draft_row.user.username).to eq(user.username)
diff --git a/spec/models/email_change_request_spec.rb b/spec/models/email_change_request_spec.rb
index 273d2a5b0cd..0f2eae9f143 100644
--- a/spec/models/email_change_request_spec.rb
+++ b/spec/models/email_change_request_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe EmailChangeRequest do
describe "Validations" do
describe "#new_email" do
describe "when email is invalid" do
- it "should not be valid" do
+ it "is invalid" do
email_change_request =
Fabricate.build(:email_change_request, new_email: "testdiscourse.org")
expect(email_change_request).to_not be_valid
diff --git a/spec/models/email_log_spec.rb b/spec/models/email_log_spec.rb
index 90f738aeace..b62aa72d1ec 100644
--- a/spec/models/email_log_spec.rb
+++ b/spec/models/email_log_spec.rb
@@ -116,7 +116,7 @@ RSpec.describe EmailLog do
end
describe "#bounce_key" do
- it "should format the bounce_key correctly" do
+ it "formats the bounce_key correctly" do
hex = SecureRandom.hex
email_log = Fabricate(:email_log, user: user, bounce_key: hex)
diff --git a/spec/models/email_token_spec.rb b/spec/models/email_token_spec.rb
index 3f1de4eadf5..7e0edce999b 100644
--- a/spec/models/email_token_spec.rb
+++ b/spec/models/email_token_spec.rb
@@ -10,11 +10,11 @@ RSpec.describe EmailToken do
let!(:original_token) { user.email_tokens.first }
let!(:email_token) { Fabricate(:email_token, user: user, email: "[email protected]") }
- it "should create the email token" do
+ it "creates the email token" do
expect(email_token).to be_present
end
- it "should downcase the email" do
+ it "downcases the email address" do
token = Fabricate(:email_token, user: user, email: "[email protected]")
expect(token.email).to eq "[email protected]"
end
@@ -99,7 +99,7 @@ RSpec.describe EmailToken do
expect(email_token).to be_confirmed
end
- it "will not confirm again" do
+ it "does not confirm the email again" do
expect(EmailToken.confirm(email_token.token)).to be_blank
end
end
diff --git a/spec/models/emoji_spec.rb b/spec/models/emoji_spec.rb
index f0e006ef83c..0dc6f01f259 100644
--- a/spec/models/emoji_spec.rb
+++ b/spec/models/emoji_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe Emoji do
end
end
- describe ".lookup_unicode" do
+ describe ".lookup_unicode for ZWJ sequences" do
before { Emoji.clear_cache }
it "returns correct unicode for skin tone and gendered ZWJ sequences" do
@@ -110,7 +110,7 @@ RSpec.describe Emoji do
end
end
- describe ".lookup_unicode" do
+ describe ".lookup_unicode for names and aliases" do
it "returns unicode for emoji, aliases, and skin tones" do
expect(Emoji.lookup_unicode("trade_mark")).to eq("™")
expect(Emoji.lookup_unicode("blonde_man")).to eq("👱‍♂️")
diff --git a/spec/models/form_template_spec.rb b/spec/models/form_template_spec.rb
index c1ef5703cc0..a62c6896b4c 100644
--- a/spec/models/form_template_spec.rb
+++ b/spec/models/form_template_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe FormTemplate, type: :model do
)
end
- it "should update validation limits when the site setting has been changed" do
+ it "updates validation limits when the site setting changes" do
SiteSetting.max_form_template_content_length = 100
SiteSetting.max_form_template_title_length = 100
diff --git a/spec/models/group_archived_message_spec.rb b/spec/models/group_archived_message_spec.rb
index 58e31093060..b25665dd9a0 100644
--- a/spec/models/group_archived_message_spec.rb
+++ b/spec/models/group_archived_message_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe GroupArchivedMessage do
end
describe ".move_to_inbox!" do
- it "should unarchive the topic correctly" do
+ it "unarchives the topic correctly" do
described_class.archive!(group.id, group_message)
messages =
@@ -57,7 +57,7 @@ RSpec.describe GroupArchivedMessage do
end
describe ".archive!" do
- it "should archive the topic correctly" do
+ it "archives the topic correctly" do
messages =
MessageBus.track_publish(PrivateMessageTopicTrackingState.group_channel(group.id)) do
described_class.archive!(group.id, group_message)
diff --git a/spec/models/group_history_spec.rb b/spec/models/group_history_spec.rb
index 387820be131..eab92b8196b 100644
--- a/spec/models/group_history_spec.rb
+++ b/spec/models/group_history_spec.rb
@@ -12,11 +12,11 @@ RSpec.describe GroupHistory do
end
describe ".with_filters" do
- it "should return the right records" do
+ it "returns the expected records" do
expect(described_class.with_filters(group_history.group)).to eq([group_history])
end
- it "should filter by action correctly" do
+ it "filters by action correctly" do
other_group_history
expect(
@@ -24,7 +24,7 @@ RSpec.describe GroupHistory do
).to eq([other_group_history])
end
- it "should filter by subject correctly" do
+ it "filters by subject correctly" do
other_group_history.update!(subject: "test")
expect(described_class.with_filters(group_history.group, subject: "test")).to eq(
@@ -32,7 +32,7 @@ RSpec.describe GroupHistory do
)
end
- it "should filter by multiple filters correctly" do
+ it "combines multiple filters correctly" do
group_history.update!(action: GroupHistory.actions[:remove_user_from_group])
other_group_history.update!(subject: "test")
@@ -45,7 +45,7 @@ RSpec.describe GroupHistory do
).to eq([other_group_history])
end
- it "should filter by target_user and acting_user correctly" do
+ it "filters by target_user and acting_user correctly" do
group_history
other_group_history
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 61d08bbf12f..c537972d42a 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Group do
describe "#grant_trust_level" do
describe "when trust level is not valid" do
- it "should not be valid" do
+ it "is invalid" do
group.grant_trust_level = 123_456
expect(group.valid?).to eq(false)
@@ -28,7 +28,7 @@ RSpec.describe Group do
describe "#name" do
context "when a user with a similar name exists" do
- it "should not be valid" do
+ it "is invalid" do
new_group = Fabricate.build(:group, name: admin.username.upcase)
expect(new_group).to_not be_valid
@@ -40,7 +40,7 @@ RSpec.describe Group do
end
context "when a group with a similar name exists" do
- it "should not be valid" do
+ it "is invalid" do
new_group = Fabricate.build(:group, name: group.name.upcase)
expect(new_group).to_not be_valid
@@ -52,7 +52,7 @@ RSpec.describe Group do
end
context "when a group with a reserved name is created" do
- it "should not be valid" do
+ it "is invalid" do
new_group = Fabricate.build(:group, name: "by-id")
expect(new_group).to_not be_valid
@@ -217,7 +217,7 @@ RSpec.describe Group do
context "when a group has no owners" do
describe "group has not been persisted" do
- it "should not allow membership requests" do
+ it "does not allow membership requests" do
group = Fabricate.build(:group, allow_membership_requests: true)
expect(group.valid?).to eq(false)
@@ -232,7 +232,7 @@ RSpec.describe Group do
end
end
- it "should not allow membership requests" do
+ it "does not allow membership requests" do
group.allow_membership_requests = true
expect(group.valid?).to eq(false)
@@ -731,7 +731,7 @@ RSpec.describe Group do
before { group.add(user) }
- it "it deleted correctly" do
+ it "deletes the group and its associations" do
group.destroy!
expect(User.where(id: user.id).count).to eq 1
expect(GroupUser.where(group_id: group.id).count).to eq 0
@@ -983,7 +983,7 @@ RSpec.describe Group do
before { user.user_stat.update!(topics_entered: 999, posts_read_count: 999, time_read: 999) }
- it "should not demote the user" do
+ it "does not demote the user" do
group.add(user)
group2.add(user)
@@ -1034,7 +1034,7 @@ RSpec.describe Group do
end
end
- it "should cook the bio" do
+ it "cooks the group biography" do
group = Fabricate(:group)
group.update!(bio_raw: "This is a group for :unicorn: lovers")
@@ -1334,7 +1334,7 @@ RSpec.describe Group do
before { group.update!(public_exit: true) }
- it "should publish category removal when category is read-restricted to the group" do
+ it "publishes category removal when the group loses read access" do
category.set_permissions(group => :full)
category.save!
group.update!(categories: [category])
@@ -1346,7 +1346,7 @@ RSpec.describe Group do
expect(message.user_ids).to eq([user.id])
end
- it "should publish updated category permissions when category is readable by everyone" do
+ it "publishes updated permissions for a publicly readable category" do
category.set_permissions(:everyone => :readonly, group => :full)
category.save!
group.update!(categories: [category])
@@ -1360,7 +1360,7 @@ RSpec.describe Group do
end
describe "when group belongs to more than #{Group::PUBLISH_CATEGORIES_LIMIT} categories" do
- it "should publish a message to refresh the user's client" do
+ it "publishes a client refresh for the user" do
group.categories += Fabricate.times(Group::PUBLISH_CATEGORIES_LIMIT + 1, :category)
message = MessageBus.track_publish { group.remove(user) }.first
@@ -1429,7 +1429,7 @@ RSpec.describe Group do
context "when adding a user into a public group" do
fab!(:category)
- it "should publish the group's categories to the client" do
+ it "publishes the group's categories to the client" do
group.update!(public_admission: true, categories: [category])
message = MessageBus.track_publish("/categories") { group.add(user) }.first
@@ -1440,7 +1440,7 @@ RSpec.describe Group do
end
describe "when group belongs to more than #{Group::PUBLISH_CATEGORIES_LIMIT} categories" do
- it "should publish a message to refresh the user's client" do
+ it "publishes a client refresh for the user" do
group.categories += Fabricate.times(Group::PUBLISH_CATEGORIES_LIMIT + 1, :category)
message = MessageBus.track_publish { group.add(user) }.first
@@ -1458,7 +1458,7 @@ RSpec.describe Group do
Group.search_groups(name, sort: :auto).map(&:name)
end
- it "should return the right groups" do
+ it "returns the matching groups" do
Group.delete_all
group_name =
@@ -1475,7 +1475,7 @@ RSpec.describe Group do
expect(search_group_names("test2")).to eq([])
end
- it "should prioritize prefix matches on group's name or fullname" do
+ it "prioritizes prefix matches on the group's name or full name" do
Fabricate(:group, name: "pears_11", full_name: "fred apple")
Fabricate(:group, name: "apples", full_name: "jane orange")
Fabricate(:group, name: "oranges2", full_name: "nothing")
@@ -1800,7 +1800,7 @@ RSpec.describe Group do
describe "#automatic_group_membership" do
let(:group) { Fabricate(:group, automatic_membership_email_domains: "example.com") }
- it "should be triggered on create and update" do
+ it "runs on create and update" do
expect { group }.to change { Jobs::AutomaticGroupMembership.jobs.size }.by(1)
job = Jobs::AutomaticGroupMembership.jobs.last
@@ -1822,7 +1822,7 @@ RSpec.describe Group do
describe "Unicode usernames and group names" do
before { SiteSetting.unicode_usernames = true }
- it "should normalize the name" do
+ it "normalizes the group name" do
group = Fabricate(:group, name: "Bücherwurm") # NFD
expect(group.name).to eq("Bücherwurm") # NFC
end
diff --git a/spec/models/invite_redeemer_spec.rb b/spec/models/invite_redeemer_spec.rb
index 052f99a496c..7d0d4e8f3d5 100644
--- a/spec/models/invite_redeemer_spec.rb
+++ b/spec/models/invite_redeemer_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe InviteRedeemer do
end
describe ".create_user_from_invite" do
- it "should be created correctly" do
+ it "creates the user correctly" do
invite = Fabricate(:invite, email: "[email protected]")
user =
InviteRedeemer.create_user_from_invite(
@@ -153,7 +153,7 @@ RSpec.describe InviteRedeemer do
expect(error.record.errors.errors[0].attribute).to eq :"user_password.password"
end
- it "should unstage user" do
+ it "unstages the user" do
staged_user =
Fabricate(
:staged,
@@ -305,7 +305,7 @@ RSpec.describe InviteRedeemer do
context "when must_approve_users setting is enabled" do
before { SiteSetting.must_approve_users = true }
- it "should redeem an invite but not approve the user when invite is created by a staff user" do
+ it "redeems a staff invite without approving the user" do
inviter = invite.invited_by
inviter.update!(admin: true)
user = invite_redeemer.redeem
@@ -318,7 +318,7 @@ RSpec.describe InviteRedeemer do
expect(inviter.notifications.count).to eq(1)
end
- it "should redeem the invite but not approve the user when invite is created by a regular user" do
+ it "redeems a regular-user invite without approving the user" do
inviter = invite.invited_by
user = invite_redeemer.redeem
@@ -330,7 +330,7 @@ RSpec.describe InviteRedeemer do
expect(inviter.notifications.count).to eq(1)
end
- it "should redeem the invite and approve the user when user email is in auto_approve_email_domains setting" do
+ it "redeems the invite and approves an email from an auto-approved domain" do
SiteSetting.auto_approve_email_domains = "example.com"
user = invite_redeemer.redeem
@@ -341,7 +341,7 @@ RSpec.describe InviteRedeemer do
end
end
- it "should redeem the invite if invited by non staff and approve if staff not required to approve" do
+ it "redeems and approves a non-staff invite when staff approval is not required" do
inviter = invite.invited_by
user = invite_redeemer.redeem
@@ -352,7 +352,7 @@ RSpec.describe InviteRedeemer do
expect(user.approved).to eq(false)
end
- it "should delete invite if invited_by user has been removed" do
+ it "deletes the invite when its inviter has been removed" do
invite.invited_by.destroy!
expect { invite.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
@@ -491,7 +491,7 @@ RSpec.describe InviteRedeemer do
expect(another_user).to eq(nil)
end
- it "should correctly update the invite redeemed_at date" do
+ it "updates the invite redeemed_at date" do
SiteSetting.invite_expiry_days = 2
invite.update!(created_at: 10.days.ago)
@@ -626,7 +626,7 @@ RSpec.describe InviteRedeemer do
)
end
- it "should redeem the invite if InvitedUser record does not exists for email" do
+ it "redeems the invite without an InvitedUser record for the email" do
invite_redeemer.redeem
invite_link.reload
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index 929126fe9b0..bbb4c2fcecf 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -244,7 +244,7 @@ RSpec.describe Invite do
context "when adding to another topic" do
fab!(:another_topic) { Fabricate(:topic, user: topic.user) }
- it "should be the same invite" do
+ it "returns the same invite" do
new_invite = Invite.generate(topic.user, email: "[email protected]", topic: another_topic)
expect(invite).to eq(new_invite)
expect(invite.topics).to contain_exactly(topic, another_topic)
@@ -390,7 +390,7 @@ RSpec.describe Invite do
describe "#redeem" do
fab!(:invite)
- it "works" do
+ it "redeems the invite" do
user = invite.redeem
expect(invite.invited_users.map(&:user)).to contain_exactly(user)
expect(user.is_a?(User)).to eq(true)
@@ -443,14 +443,14 @@ RSpec.describe Invite do
end
context "as a moderator" do
- it "will give the user a moderator flag" do
+ it "gives the user a moderator flag" do
invite.update!(moderator: true, invited_by: Fabricate(:admin))
user = invite.redeem
expect(user).to be_moderator
end
- it "will not give the user a moderator flag if the inviter is not staff" do
+ it "does not give the user a moderator flag when the inviter is not staff" do
# update_columns skips the ensure_valid_moderator_invite validation so we
# can exercise the redeemer's own inviter check in isolation
invite.update_columns(moderator: true)
@@ -473,7 +473,7 @@ RSpec.describe Invite do
expect(user.groups).to contain_exactly(group)
end
- it "should not raise error when both group & site tag preferences same" do
+ it "does not raise an error when group and site tag preferences match" do
tag = Fabricate(:tag)
group.tracking_tags = [tag.name]
group.save!
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
index 4399cde5b2a..26c5c4a8fb9 100644
--- a/spec/models/notification_spec.rb
+++ b/spec/models/notification_spec.rb
@@ -1,977 +1,997 @@
# frozen_string_literal: true
RSpec.describe Notification do
- fab!(:user)
- fab!(:coding_horror)
-
- before { NotificationEmailer.enable }
-
- it { is_expected.to validate_presence_of :notification_type }
- it { is_expected.to validate_presence_of :data }
-
- it { is_expected.to belong_to :user }
- it { is_expected.to belong_to :topic }
-
- describe "#types" do
- subject(:types) { Notification.types }
-
- context "when verifying enum sequence" do
- it "has a correct position for each type" do
- expect(types[:mentioned]).to eq(1)
- expect(types[:replied]).to eq(2)
- expect(types[:quoted]).to eq(3)
- expect(types[:edited]).to eq(4)
- expect(types[:liked]).to eq(5)
- expect(types[:private_message]).to eq(6)
- expect(types[:invited_to_private_message]).to eq(7)
- expect(types[:invitee_accepted]).to eq(8)
- expect(types[:posted]).to eq(9)
- expect(types[:moved_post]).to eq(10)
- expect(types[:linked]).to eq(11)
- expect(types[:granted_badge]).to eq(12)
- expect(types[:invited_to_topic]).to eq(13)
- expect(types[:custom]).to eq(14)
- expect(types[:group_mentioned]).to eq(15)
- expect(types[:group_message_summary]).to eq(16)
- expect(types[:watching_first_post]).to eq(17)
- expect(types[:topic_reminder]).to eq(18)
- expect(types[:liked_consolidated]).to eq(19)
- expect(types[:post_approved]).to eq(20)
- expect(types[:code_review_commit_approved]).to eq(21)
- expect(types[:membership_request_accepted]).to eq(22)
- expect(types[:membership_request_consolidated]).to eq(23)
- expect(types[:bookmark_reminder]).to eq(24)
- expect(types[:reaction]).to eq(25)
- expect(types[:votes_released]).to eq(26)
- expect(types[:event_reminder]).to eq(27)
- expect(types[:event_invitation]).to eq(28)
- expect(types[:chat_mention]).to eq(29)
- expect(types[:chat_message]).to eq(30)
- expect(types[:assigned]).to eq(34)
+ context "with the notification observer enabled" do
+ fab!(:user)
+ fab!(:coding_horror)
+
+ before { NotificationEmailer.enable }
+
+ it { is_expected.to validate_presence_of :notification_type }
+ it { is_expected.to validate_presence_of :data }
+
+ it { is_expected.to belong_to :user }
+ it { is_expected.to belong_to :topic }
+
+ describe "#types" do
+ subject(:types) { Notification.types }
+
+ context "when verifying enum sequence" do
+ it "has a correct position for each type" do
+ expect(types[:mentioned]).to eq(1)
+ expect(types[:replied]).to eq(2)
+ expect(types[:quoted]).to eq(3)
+ expect(types[:edited]).to eq(4)
+ expect(types[:liked]).to eq(5)
+ expect(types[:private_message]).to eq(6)
+ expect(types[:invited_to_private_message]).to eq(7)
+ expect(types[:invitee_accepted]).to eq(8)
+ expect(types[:posted]).to eq(9)
+ expect(types[:moved_post]).to eq(10)
+ expect(types[:linked]).to eq(11)
+ expect(types[:granted_badge]).to eq(12)
+ expect(types[:invited_to_topic]).to eq(13)
+ expect(types[:custom]).to eq(14)
+ expect(types[:group_mentioned]).to eq(15)
+ expect(types[:group_message_summary]).to eq(16)
+ expect(types[:watching_first_post]).to eq(17)
+ expect(types[:topic_reminder]).to eq(18)
+ expect(types[:liked_consolidated]).to eq(19)
+ expect(types[:post_approved]).to eq(20)
+ expect(types[:code_review_commit_approved]).to eq(21)
+ expect(types[:membership_request_accepted]).to eq(22)
+ expect(types[:membership_request_consolidated]).to eq(23)
+ expect(types[:bookmark_reminder]).to eq(24)
+ expect(types[:reaction]).to eq(25)
+ expect(types[:votes_released]).to eq(26)
+ expect(types[:event_reminder]).to eq(27)
+ expect(types[:event_invitation]).to eq(28)
+ expect(types[:chat_mention]).to eq(29)
+ expect(types[:chat_message]).to eq(30)
+ expect(types[:assigned]).to eq(34)
+ end
end
end
- end
- describe "post" do
- let(:topic) { Fabricate(:topic) }
- let(:post_args) { { user: topic.user, topic: topic } }
+ describe "post" do
+ let(:topic) { Fabricate(:topic) }
+ let(:post_args) { { user: topic.user, topic: topic } }
- describe "replies" do
- def process_alerts(post)
- PostAlerter.post_created(post)
- end
+ describe "replies" do
+ def process_alerts(post)
+ PostAlerter.post_created(post)
+ end
- let(:post) { process_alerts(Fabricate(:post, post_args.merge(raw: "Hello @CodingHorror"))) }
+ let(:post) { process_alerts(Fabricate(:post, post_args.merge(raw: "Hello @CodingHorror"))) }
- it "notifies the poster on reply" do
- expect {
- reply = Fabricate(:basic_reply, user: coding_horror, topic: post.topic)
- process_alerts(reply)
- }.to change(post.user.notifications, :count).by(1)
- end
+ it "notifies the poster on reply" do
+ expect {
+ reply = Fabricate(:basic_reply, user: coding_horror, topic: post.topic)
+ process_alerts(reply)
+ }.to change(post.user.notifications, :count).by(1)
+ end
- it "doesn't notify the poster when they reply to their own post" do
- expect {
- reply = Fabricate(:basic_reply, user: post.user, topic: post.topic)
- process_alerts(reply)
- }.not_to change(post.user.notifications, :count)
+ it "doesn't notify the poster when they reply to their own post" do
+ expect {
+ reply = Fabricate(:basic_reply, user: post.user, topic: post.topic)
+ process_alerts(reply)
+ }.not_to change(post.user.notifications, :count)
+ end
end
- end
- describe "watching" do
- it "does notify watching users of new posts" do
- post = PostAlerter.post_created(Fabricate(:post, post_args))
- user2 = coding_horror
- post_args[:topic].notify_watch!(user2)
- expect {
- PostAlerter.post_created(Fabricate(:post, user: post.user, topic: post.topic))
- }.to change(user2.notifications, :count).by(1)
+ describe "watching" do
+ it "does notify watching users of new posts" do
+ post = PostAlerter.post_created(Fabricate(:post, post_args))
+ user2 = coding_horror
+ post_args[:topic].notify_watch!(user2)
+ expect {
+ PostAlerter.post_created(Fabricate(:post, user: post.user, topic: post.topic))
+ }.to change(user2.notifications, :count).by(1)
+ end
end
- end
- describe "muting" do
- it "does not notify users of new posts" do
- post = Fabricate(:post, post_args)
- user = post_args[:user]
- user2 = coding_horror
+ describe "muting" do
+ it "does not notify users of new posts" do
+ post = Fabricate(:post, post_args)
+ user = post_args[:user]
+ user2 = coding_horror
- post_args[:topic].notify_muted!(user)
- expect {
- Fabricate(:post, user: user2, topic: post.topic, raw: "hello @" + user.username)
- }.not_to change(user.notifications, :count)
+ post_args[:topic].notify_muted!(user)
+ expect {
+ Fabricate(:post, user: user2, topic: post.topic, raw: "hello @" + user.username)
+ }.not_to change(user.notifications, :count)
+ end
end
end
- end
- describe "high priority creation" do
- fab!(:user)
+ describe "high priority creation" do
+ fab!(:user)
- it "automatically marks the notification as high priority if it is a high priority type" do
- notif =
- Notification.create(
- user: user,
- notification_type: Notification.types[:bookmark_reminder],
- data: {
- },
- )
- expect(notif.high_priority).to eq(true)
- notif =
- Notification.create(
- user: user,
- notification_type: Notification.types[:private_message],
- data: {
- },
- )
- expect(notif.high_priority).to eq(true)
- notif =
- Notification.create(user: user, notification_type: Notification.types[:liked], data: {})
- expect(notif.high_priority).to eq(false)
- end
+ it "automatically marks the notification as high priority if it is a high priority type" do
+ notif =
+ Notification.create(
+ user: user,
+ notification_type: Notification.types[:bookmark_reminder],
+ data: {
+ },
+ )
+ expect(notif.high_priority).to eq(true)
+ notif =
+ Notification.create(
+ user: user,
+ notification_type: Notification.types[:private_message],
+ data: {
+ },
+ )
+ expect(notif.high_priority).to eq(true)
+ notif =
+ Notification.create(user: user, notification_type: Notification.types[:liked], data: {})
+ expect(notif.high_priority).to eq(false)
+ end
- it "allows manually specifying a notification is high priority" do
- notif =
- Notification.create(
- user: user,
- notification_type: Notification.types[:liked],
- data: {
- },
- high_priority: true,
- )
- expect(notif.high_priority).to eq(true)
+ it "allows manually specifying a notification is high priority" do
+ notif =
+ Notification.create(
+ user: user,
+ notification_type: Notification.types[:liked],
+ data: {
+ },
+ high_priority: true,
+ )
+ expect(notif.high_priority).to eq(true)
+ end
end
- end
- describe "unread counts" do
- fab!(:user)
+ describe "unread counts" do
+ fab!(:user)
- context "with a regular notification" do
- it "increases unread_notifications" do
- expect {
- Fabricate(:notification, user: user)
- user.reload
- }.to change(user, :unread_notifications)
- end
+ context "with a regular notification" do
+ it "increases unread_notifications" do
+ expect {
+ Fabricate(:notification, user: user)
+ user.reload
+ }.to change(user, :unread_notifications)
+ end
- it "increases total_unread_notifications" do
- expect {
- Fabricate(:notification, user: user)
- user.reload
- }.to change(user, :total_unread_notifications)
- end
+ it "increases total_unread_notifications" do
+ expect {
+ Fabricate(:notification, user: user)
+ user.reload
+ }.to change(user, :total_unread_notifications)
+ end
- it "doesn't increase unread_high_priority_notifications" do
- expect {
- Fabricate(:notification, user: user)
- user.reload
- }.not_to change(user, :unread_high_priority_notifications)
+ it "doesn't increase unread_high_priority_notifications" do
+ expect {
+ Fabricate(:notification, user: user)
+ user.reload
+ }.not_to change(user, :unread_high_priority_notifications)
+ end
end
- end
- context "with a private message" do
- it "doesn't increase unread_notifications" do
- expect {
- Fabricate(:private_message_notification, user: user)
- user.reload
- }.not_to change(user, :unread_notifications)
- end
+ context "with a private message" do
+ it "doesn't increase unread_notifications" do
+ expect {
+ Fabricate(:private_message_notification, user: user)
+ user.reload
+ }.not_to change(user, :unread_notifications)
+ end
+
+ it "increases total_unread_notifications" do
+ expect {
+ Fabricate(:notification, user: user)
+ user.reload
+ }.to change(user, :total_unread_notifications)
+ end
- it "increases total_unread_notifications" do
- expect {
- Fabricate(:notification, user: user)
- user.reload
- }.to change(user, :total_unread_notifications)
+ it "increases unread_high_priority_notifications" do
+ expect {
+ Fabricate(:private_message_notification, user: user)
+ user.reload
+ }.to change(user, :unread_high_priority_notifications)
+ end
end
- it "increases unread_high_priority_notifications" do
- expect {
- Fabricate(:private_message_notification, user: user)
- user.reload
- }.to change(user, :unread_high_priority_notifications)
+ context "with a bookmark reminder message" do
+ it "doesn't increase unread_notifications" do
+ expect {
+ Fabricate(:bookmark_reminder_notification, user: user)
+ user.reload
+ }.not_to change(user, :unread_notifications)
+ end
+
+ it "increases total_unread_notifications" do
+ expect {
+ Fabricate(:notification, user: user)
+ user.reload
+ }.to change(user, :total_unread_notifications)
+ end
+
+ it "increases unread_high_priority_notifications" do
+ expect {
+ Fabricate(:bookmark_reminder_notification, user: user)
+ user.reload
+ }.to change(user, :unread_high_priority_notifications)
+ end
end
end
- context "with a bookmark reminder message" do
- it "doesn't increase unread_notifications" do
- expect {
- Fabricate(:bookmark_reminder_notification, user: user)
- user.reload
- }.not_to change(user, :unread_notifications)
- end
+ describe "message bus" do
+ fab!(:user) { Fabricate(:user, last_seen_at: 1.day.ago) }
- it "increases total_unread_notifications" do
- expect {
- Fabricate(:notification, user: user)
- user.reload
- }.to change(user, :total_unread_notifications)
+ it "updates the notification count on create" do
+ Notification.any_instance.expects(:refresh_notification_count).returns(nil)
+ Fabricate(:notification)
end
- it "increases unread_high_priority_notifications" do
- expect {
- Fabricate(:bookmark_reminder_notification, user: user)
- user.reload
- }.to change(user, :unread_high_priority_notifications)
+ it "publishes the updated unread count for each new notification" do
+ messages =
+ MessageBus.track_publish do
+ user.notifications.create!(
+ notification_type: Notification.types[:mentioned],
+ data: "{}",
+ )
+ user.notifications.create!(
+ notification_type: Notification.types[:mentioned],
+ data: "{}",
+ )
+ end
+
+ expect(messages.size).to eq(2)
+ expect(messages[0].channel).to eq("/notification/#{user.id}")
+ expect(messages[0].data[:unread_notifications]).to eq(1)
+ expect(messages[1].channel).to eq("/notification/#{user.id}")
+ expect(messages[1].data[:unread_notifications]).to eq(2)
end
- end
- end
- describe "message bus" do
- fab!(:user) { Fabricate(:user, last_seen_at: 1.day.ago) }
+ it "works for partial model instances" do
+ NotificationEmailer.disable
+ partial_user = User.select(:id).find_by(id: user.id)
+ partial_user.notifications.create!(
+ notification_type: Notification.types[:mentioned],
+ data: "{}",
+ )
+ end
- it "updates the notification count on create" do
- Notification.any_instance.expects(:refresh_notification_count).returns(nil)
- Fabricate(:notification)
- end
+ context "when destroying" do
+ let!(:notification) { Fabricate(:notification) }
- it "works" do
- messages =
- MessageBus.track_publish do
- user.notifications.create!(notification_type: Notification.types[:mentioned], data: "{}")
- user.notifications.create!(notification_type: Notification.types[:mentioned], data: "{}")
+ it "updates the notification count on destroy" do
+ Notification.any_instance.expects(:refresh_notification_count).returns(nil)
+ notification.destroy!
end
-
- expect(messages.size).to eq(2)
- expect(messages[0].channel).to eq("/notification/#{user.id}")
- expect(messages[0].data[:unread_notifications]).to eq(1)
- expect(messages[1].channel).to eq("/notification/#{user.id}")
- expect(messages[1].data[:unread_notifications]).to eq(2)
+ end
end
- it "works for partial model instances" do
- NotificationEmailer.disable
- partial_user = User.select(:id).find_by(id: user.id)
- partial_user.notifications.create!(
- notification_type: Notification.types[:mentioned],
- data: "{}",
- )
- end
+ describe "private message" do
+ let(:topic) { Fabricate(:private_message_topic) }
+ let(:post) { Fabricate(:post, topic:, user: topic.user) }
+ let(:target) do
+ post.topic.topic_allowed_users.reject { |a| a.user_id == post.user_id }[0].user
+ end
- context "when destroying" do
- let!(:notification) { Fabricate(:notification) }
+ before do
+ TopicUser.change(
+ target.id,
+ topic.id,
+ notification_level: TopicUser.notification_levels[:watching],
+ )
- it "updates the notification count on destroy" do
- Notification.any_instance.expects(:refresh_notification_count).returns(nil)
- notification.destroy!
+ PostAlerter.post_created(post)
end
- end
- end
- describe "private message" do
- let(:topic) { Fabricate(:private_message_topic) }
- let(:post) { Fabricate(:post, topic:, user: topic.user) }
- let(:target) { post.topic.topic_allowed_users.reject { |a| a.user_id == post.user_id }[0].user }
-
- before do
- TopicUser.change(
- target.id,
- topic.id,
- notification_level: TopicUser.notification_levels[:watching],
- )
+ it "creates and rolls up private message notifications" do
+ expect(target.notifications.first.notification_type).to eq(
+ Notification.types[:private_message],
+ )
+ expect(post.user.unread_notifications).to eq(0)
+ expect(post.user.total_unread_notifications).to eq(0)
+ expect(target.unread_high_priority_notifications).to eq(1)
- PostAlerter.post_created(post)
+ Fabricate(:post, topic:, user: topic.user)
+ target.reload
+ expect(target.unread_high_priority_notifications).to eq(1)
+ end
end
- it "should create and roll up private message notifications" do
- expect(target.notifications.first.notification_type).to eq(
- Notification.types[:private_message],
- )
- expect(post.user.unread_notifications).to eq(0)
- expect(post.user.total_unread_notifications).to eq(0)
- expect(target.unread_high_priority_notifications).to eq(1)
-
- Fabricate(:post, topic:, user: topic.user)
- target.reload
- expect(target.unread_high_priority_notifications).to eq(1)
- end
- end
+ describe ".post" do
+ let(:post) { Fabricate(:post) }
+ let!(:notification) do
+ Fabricate(:notification, user: post.user, topic: post.topic, post_number: post.post_number)
+ end
- describe ".post" do
- let(:post) { Fabricate(:post) }
- let!(:notification) do
- Fabricate(:notification, user: post.user, topic: post.topic, post_number: post.post_number)
+ it "returns the post" do
+ expect(notification.post).to eq(post)
+ end
end
- it "returns the post" do
- expect(notification.post).to eq(post)
- end
- end
+ describe "#url" do
+ fab!(:topic)
+ fab!(:post) { Fabricate(:post, topic: topic, post_number: 5) }
- describe "#url" do
- fab!(:topic)
- fab!(:post) { Fabricate(:post, topic: topic, post_number: 5) }
+ it "returns the relative topic url for a regular reply notification" do
+ notification =
+ Fabricate(
+ :notification,
+ notification_type: Notification.types[:replied],
+ topic: topic,
+ post_number: 5,
+ data: { topic_title: topic.title, display_username: "u" }.to_json,
+ )
- it "returns the relative topic url for a regular reply notification" do
- notification =
- Fabricate(
- :notification,
- notification_type: Notification.types[:replied],
- topic: topic,
- post_number: 5,
- data: { topic_title: topic.title, display_username: "u" }.to_json,
- )
-
- expect(notification.url).to eq(topic.relative_url(5))
- end
+ expect(notification.url).to eq(topic.relative_url(5))
+ end
- it "returns the topic root with sort=new&collapse_replies=true for a consolidated topic-bucket notification" do
- notification =
- Fabricate(
- :notification,
- notification_type: Notification.types[:replied],
- topic: topic,
- post_number: 7,
- data: {
- topic_title: topic.title,
- display_username: "3 replies",
- reply_to_post_number: 1,
- consolidated_count: 3,
- }.to_json,
+ it "returns the topic root with sort=new&collapse_replies=true for a consolidated topic-bucket notification" do
+ notification =
+ Fabricate(
+ :notification,
+ notification_type: Notification.types[:replied],
+ topic: topic,
+ post_number: 7,
+ data: {
+ topic_title: topic.title,
+ display_username: "3 replies",
+ reply_to_post_number: 1,
+ consolidated_count: 3,
+ }.to_json,
+ )
+
+ expect(notification.url).to eq(
+ "/t/#{topic.slug}/#{topic.id}?sort=new&collapse_replies=true",
)
+ end
- expect(notification.url).to eq("/t/#{topic.slug}/#{topic.id}?sort=new&collapse_replies=true")
- end
-
- it "returns the bucket parent's context with sort=new&collapse_replies=true for a consolidated per-post-bucket notification" do
- notification =
- Fabricate(
- :notification,
- notification_type: Notification.types[:replied],
- topic: topic,
- post_number: 7,
- data: {
- topic_title: topic.title,
- display_username: "2 replies",
- reply_to_post_number: 4,
- consolidated_count: 2,
- }.to_json,
+ it "returns the bucket parent's context with sort=new&collapse_replies=true for a consolidated per-post-bucket notification" do
+ notification =
+ Fabricate(
+ :notification,
+ notification_type: Notification.types[:replied],
+ topic: topic,
+ post_number: 7,
+ data: {
+ topic_title: topic.title,
+ display_username: "2 replies",
+ reply_to_post_number: 4,
+ consolidated_count: 2,
+ }.to_json,
+ )
+
+ expect(notification.url).to eq(
+ "/t/#{topic.slug}/#{topic.id}/4?sort=new&collapse_replies=true",
)
+ end
- expect(notification.url).to eq(
- "/t/#{topic.slug}/#{topic.id}/4?sort=new&collapse_replies=true",
- )
+ it "uses the canonical specific-post URL for a singular nested-bucket notification" do
+ notification =
+ Fabricate(
+ :notification,
+ notification_type: Notification.types[:replied],
+ topic: topic,
+ post_number: 5,
+ data: {
+ topic_title: topic.title,
+ display_username: "u",
+ reply_to_post_number: 1,
+ }.to_json,
+ )
+
+ expect(notification.url).to eq(topic.relative_url(5))
+ end
end
- it "uses the canonical specific-post URL for a singular nested-bucket notification" do
- notification =
- Fabricate(
- :notification,
- notification_type: Notification.types[:replied],
- topic: topic,
- post_number: 5,
- data: {
- topic_title: topic.title,
- display_username: "u",
- reply_to_post_number: 1,
- }.to_json,
- )
-
- expect(notification.url).to eq(topic.relative_url(5))
- end
- end
+ describe "data" do
+ let(:notification) { Fabricate.build(:notification) }
- describe "data" do
- let(:notification) { Fabricate.build(:notification) }
+ it "provides a data hash" do
+ expect(notification.data_hash).to be_present
+ end
- it "should have a data hash" do
- expect(notification.data_hash).to be_present
+ it "parses the JSON notification data" do
+ expect(notification.data_hash[:poison]).to eq("ivy")
+ end
end
- it "should have the data within the json" do
- expect(notification.data_hash[:poison]).to eq("ivy")
- end
- end
+ describe "saw_regular_notification_id" do
+ it "correctly updates the read state" do
+ t = Fabricate(:topic)
- describe "saw_regular_notification_id" do
- it "correctly updates the read state" do
- t = Fabricate(:topic)
-
- Notification.create!(
- read: false,
- user_id: user.id,
- topic_id: t.id,
- post_number: 1,
- data: "{}",
- notification_type: Notification.types[:private_message],
- )
-
- Notification.create!(
- read: false,
- user_id: user.id,
- topic_id: t.id,
- post_number: 1,
- data: "{}",
- notification_type: Notification.types[:bookmark_reminder],
- )
-
- other =
Notification.create!(
read: false,
user_id: user.id,
topic_id: t.id,
post_number: 1,
data: "{}",
- notification_type: Notification.types[:mentioned],
+ notification_type: Notification.types[:private_message],
)
- user.bump_last_seen_notification!
- user.reload
-
- expect(user.unread_notifications).to eq(0)
- expect(user.total_unread_notifications).to eq(3)
- expect(user.unread_high_priority_notifications).to eq(2)
- end
- end
-
- describe "mark_posts_read" do
- it "marks multiple posts as read if needed" do
- (1..3).map do |i|
Notification.create!(
read: false,
user_id: user.id,
- topic_id: 2,
- post_number: i,
+ topic_id: t.id,
+ post_number: 1,
data: "{}",
- notification_type: 1,
+ notification_type: Notification.types[:bookmark_reminder],
)
- end
- Notification.create!(
- read: true,
- user_id: user.id,
- topic_id: 2,
- post_number: 4,
- data: "{}",
- notification_type: 1,
- )
-
- expect { Notification.mark_posts_read(user, 2, [1, 2, 3, 4]) }.to change {
- Notification.where(read: true).count
- }.by(3)
- end
- end
-
- describe "#ensure_consistency!" do
- it "deletes notifications if post is missing or deleted" do
- NotificationEmailer.disable
-
- p = Fabricate(:post)
- p2 = Fabricate(:post)
-
- Notification.create!(
- read: false,
- user_id: p.user_id,
- topic_id: p.topic_id,
- post_number: p.post_number,
- data: "[]",
- notification_type: Notification.types[:private_message],
- )
- Notification.create!(
- read: false,
- user_id: p2.user_id,
- topic_id: p2.topic_id,
- post_number: p2.post_number,
- data: "[]",
- notification_type: Notification.types[:private_message],
- )
- Notification.create!(
- read: false,
- user_id: p2.user_id,
- topic_id: p2.topic_id,
- post_number: p2.post_number,
- data: "[]",
- notification_type: Notification.types[:bookmark_reminder],
- )
-
- Notification.create!(
- read: false,
- user_id: p2.user_id,
- topic_id: p2.topic_id,
- post_number: p2.post_number,
- data: "[]",
- notification_type: Notification.types[:liked],
- )
- p2.trash!(p.user)
-
- # we may want to make notification "trashable" but for now we nuke pm notifications from deleted topics/posts
- Notification.ensure_consistency!
-
- expect(Notification.count).to eq(2)
- end
- it "does not delete notifications that do not have a topic_id" do
- Notification.create!(
- read: false,
- user_id: user.id,
- topic_id: nil,
- post_number: nil,
- data: "[]",
- notification_type: Notification.types[:chat_mention],
- high_priority: true,
- )
- expect { Notification.ensure_consistency! }.to_not change { Notification.count }
+ other =
+ Notification.create!(
+ read: false,
+ user_id: user.id,
+ topic_id: t.id,
+ post_number: 1,
+ data: "{}",
+ notification_type: Notification.types[:mentioned],
+ )
+
+ user.bump_last_seen_notification!
+ user.reload
+
+ expect(user.unread_notifications).to eq(0)
+ expect(user.total_unread_notifications).to eq(3)
+ expect(user.unread_high_priority_notifications).to eq(2)
+ end
end
- end
- describe "do not disturb" do
- it "calls NotificationEmailer.process_notification when user is not in 'do not disturb'" do
- notification =
- Notification.new(
- read: false,
+ describe "mark_posts_read" do
+ it "marks multiple posts as read if needed" do
+ (1..3).map do |i|
+ Notification.create!(
+ read: false,
+ user_id: user.id,
+ topic_id: 2,
+ post_number: i,
+ data: "{}",
+ notification_type: 1,
+ )
+ end
+ Notification.create!(
+ read: true,
user_id: user.id,
topic_id: 2,
- post_number: 1,
+ post_number: 4,
data: "{}",
notification_type: 1,
)
- NotificationEmailer.expects(:process_notification).with(notification)
- notification.save!
- end
- it "doesn't call NotificationEmailer.process_notification when user is in 'do not disturb'" do
- freeze_time
- Fabricate(
- :do_not_disturb_timing,
- user: user,
- starts_at: Time.zone.now,
- ends_at: 1.day.from_now,
- )
-
- notification =
- Notification.new(
- read: false,
- user_id: user.id,
- topic_id: 2,
- post_number: 1,
- data: "{}",
- notification_type: 1,
- )
- NotificationEmailer.expects(:process_notification).with(notification).never
- notification.save!
+ expect { Notification.mark_posts_read(user, 2, [1, 2, 3, 4]) }.to change {
+ Notification.where(read: true).count
+ }.by(3)
+ end
end
- end
-end
-# pulling this out cause I don't want an observer
-RSpec.describe Notification do
- fab!(:user)
+ describe "#ensure_consistency!" do
+ it "deletes notifications if post is missing or deleted" do
+ NotificationEmailer.disable
- describe ".prioritized_list" do
- def create(**opts)
- opts[:user] = user if !opts[:user]
- Fabricate(:notification, user: user, **opts)
- end
+ p = Fabricate(:post)
+ p2 = Fabricate(:post)
- fab!(:unread_high_priority_1) do
- create(high_priority: true, read: false, created_at: 8.minutes.ago)
- end
- fab!(:read_high_priority_1) do
- create(high_priority: true, read: true, created_at: 7.minutes.ago)
- end
- fab!(:unread_regular_1) { create(high_priority: false, read: false, created_at: 6.minutes.ago) }
- fab!(:read_regular_1) { create(high_priority: false, read: true, created_at: 5.minutes.ago) }
- fab!(:unread_like) do
- create(
- high_priority: false,
- read: false,
- created_at: 130.seconds.ago,
- notification_type: Notification.types[:liked],
- )
- end
+ Notification.create!(
+ read: false,
+ user_id: p.user_id,
+ topic_id: p.topic_id,
+ post_number: p.post_number,
+ data: "[]",
+ notification_type: Notification.types[:private_message],
+ )
+ Notification.create!(
+ read: false,
+ user_id: p2.user_id,
+ topic_id: p2.topic_id,
+ post_number: p2.post_number,
+ data: "[]",
+ notification_type: Notification.types[:private_message],
+ )
+ Notification.create!(
+ read: false,
+ user_id: p2.user_id,
+ topic_id: p2.topic_id,
+ post_number: p2.post_number,
+ data: "[]",
+ notification_type: Notification.types[:bookmark_reminder],
+ )
- fab!(:unread_high_priority_2) do
- create(high_priority: true, read: false, created_at: 1.minute.ago)
- end
- fab!(:read_high_priority_2) do
- create(high_priority: true, read: true, created_at: 2.minutes.ago)
- end
- fab!(:unread_regular_2) { create(high_priority: false, read: false, created_at: 3.minutes.ago) }
- fab!(:read_regular_2) { create(high_priority: false, read: true, created_at: 4.minutes.ago) }
-
- it "puts unread high_priority on top followed by unread normal notifications and then everything else in reverse chronological order" do
- expect(Notification.prioritized_list(user).map(&:id)).to eq(
- [
- unread_high_priority_2,
- unread_high_priority_1,
- unread_regular_2,
- unread_regular_1,
- read_high_priority_2,
- unread_like,
- read_regular_2,
- read_regular_1,
- read_high_priority_1,
- ].map(&:id),
- )
- end
+ Notification.create!(
+ read: false,
+ user_id: p2.user_id,
+ topic_id: p2.topic_id,
+ post_number: p2.post_number,
+ data: "[]",
+ notification_type: Notification.types[:liked],
+ )
+ p2.trash!(p.user)
- it "doesn't include notifications from other users" do
- another_user_notification = create(high_priority: true, read: false, user: Fabricate(:user))
- expect(Notification.prioritized_list(user).map(&:id)).to contain_exactly(
- *[
- unread_high_priority_2,
- unread_high_priority_1,
- unread_regular_2,
- unread_regular_1,
- read_high_priority_2,
- unread_like,
- read_regular_2,
- read_regular_1,
- read_high_priority_1,
- ].map(&:id),
- )
- expect(
- Notification.prioritized_list(another_user_notification.user).map(&:id),
- ).to contain_exactly(another_user_notification.id)
- end
+ # we may want to make notification "trashable" but for now we nuke pm notifications from deleted topics/posts
+ Notification.ensure_consistency!
- it "doesn't include notifications from deleted topics" do
- unread_high_priority_1.topic.trash!
- unread_regular_2.topic.trash!
- read_regular_1.topic.trash!
- expect(Notification.prioritized_list(user).map(&:id)).to contain_exactly(
- *[
- unread_high_priority_2,
- unread_regular_1,
- read_high_priority_2,
- unread_like,
- read_regular_2,
- read_high_priority_1,
- ].map(&:id),
- )
- end
+ expect(Notification.count).to eq(2)
+ end
- it "doesn't include like notifications if the user doesn't want like notifications" do
- user.user_option.update!(
- like_notification_frequency: UserOption.like_notification_frequency_type[:never],
- )
- unread_regular_1.update!(notification_type: Notification.types[:liked])
- read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
- expect(Notification.prioritized_list(user).map(&:id)).to eq(
- [
- unread_high_priority_2,
- unread_high_priority_1,
- unread_regular_2,
- read_high_priority_2,
- read_regular_1,
- read_high_priority_1,
- ].map(&:id),
- )
+ it "does not delete notifications that do not have a topic_id" do
+ Notification.create!(
+ read: false,
+ user_id: user.id,
+ topic_id: nil,
+ post_number: nil,
+ data: "[]",
+ notification_type: Notification.types[:chat_mention],
+ high_priority: true,
+ )
+ expect { Notification.ensure_consistency! }.to_not change { Notification.count }
+ end
end
- it "respects the count param" do
- expect(Notification.prioritized_list(user, count: 1).map(&:id)).to eq(
- [unread_high_priority_2].map(&:id),
- )
-
- expect(Notification.prioritized_list(user, count: 3).map(&:id)).to eq(
- [unread_high_priority_2, unread_high_priority_1, unread_regular_2].map(&:id),
- )
- end
+ describe "do not disturb" do
+ it "calls NotificationEmailer.process_notification when user is not in 'do not disturb'" do
+ notification =
+ Notification.new(
+ read: false,
+ user_id: user.id,
+ topic_id: 2,
+ post_number: 1,
+ data: "{}",
+ notification_type: 1,
+ )
+ NotificationEmailer.expects(:process_notification).with(notification)
+ notification.save!
+ end
- it "can filter the list by specific types" do
- unread_regular_1.update!(notification_type: Notification.types[:liked])
- read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
- expect(
- Notification.prioritized_list(
- user,
- types: [Notification.types[:liked], Notification.types[:liked_consolidated]],
- ).map(&:id),
- ).to eq([unread_like, unread_regular_1, read_regular_2].map(&:id))
- end
+ it "doesn't call NotificationEmailer.process_notification when user is in 'do not disturb'" do
+ freeze_time
+ Fabricate(
+ :do_not_disturb_timing,
+ user: user,
+ starts_at: Time.zone.now,
+ ends_at: 1.day.from_now,
+ )
- it "includes like notifications when filtering by like types even if the user doesn't want like notifications" do
- user.user_option.update!(
- like_notification_frequency: UserOption.like_notification_frequency_type[:never],
- )
- unread_regular_1.update!(notification_type: Notification.types[:liked])
- read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
- expect(
- Notification.prioritized_list(
- user,
- types: [Notification.types[:liked], Notification.types[:liked_consolidated]],
- ).map(&:id),
- ).to eq([unread_like, unread_regular_1, read_regular_2].map(&:id))
- expect(
- Notification.prioritized_list(user, types: [Notification.types[:liked]]).map(&:id),
- ).to contain_exactly(unread_like.id, unread_regular_1.id)
+ notification =
+ Notification.new(
+ read: false,
+ user_id: user.id,
+ topic_id: 2,
+ post_number: 1,
+ data: "{}",
+ notification_type: 1,
+ )
+ NotificationEmailer.expects(:process_notification).with(notification).never
+ notification.save!
+ end
end
end
- describe "#recent_report" do
- let(:post) { Fabricate(:post) }
- let(:vars) { { i: 0 } }
-
- def fab(type, read)
- vars[:i] += 1
- Notification.create!(
- read: read,
- user_id: user.id,
- topic_id: post.topic_id,
- post_number: post.post_number,
- data: "[]",
- notification_type: type,
- created_at: vars[:i].days.from_now,
- )
- end
-
- def unread_pm
- fab(Notification.types[:private_message], false)
- end
-
- def unread_bookmark_reminder
- fab(Notification.types[:bookmark_reminder], false)
- end
+ # pulling this out cause I don't want an observer
+ context "with the notification observer disabled" do
+ fab!(:user)
- def pm
- fab(Notification.types[:private_message], true)
- end
+ describe ".prioritized_list" do
+ def create(**opts)
+ opts[:user] = user if !opts[:user]
+ Fabricate(:notification, user: user, **opts)
+ end
- def regular
- fab(Notification.types[:liked], true)
- end
+ fab!(:unread_high_priority_1) do
+ create(high_priority: true, read: false, created_at: 8.minutes.ago)
+ end
+ fab!(:read_high_priority_1) do
+ create(high_priority: true, read: true, created_at: 7.minutes.ago)
+ end
+ fab!(:unread_regular_1) do
+ create(high_priority: false, read: false, created_at: 6.minutes.ago)
+ end
+ fab!(:read_regular_1) { create(high_priority: false, read: true, created_at: 5.minutes.ago) }
+ fab!(:unread_like) do
+ create(
+ high_priority: false,
+ read: false,
+ created_at: 130.seconds.ago,
+ notification_type: Notification.types[:liked],
+ )
+ end
- def liked_consolidated
- fab(Notification.types[:liked_consolidated], true)
- end
+ fab!(:unread_high_priority_2) do
+ create(high_priority: true, read: false, created_at: 1.minute.ago)
+ end
+ fab!(:read_high_priority_2) do
+ create(high_priority: true, read: true, created_at: 2.minutes.ago)
+ end
+ fab!(:unread_regular_2) do
+ create(high_priority: false, read: false, created_at: 3.minutes.ago)
+ end
+ fab!(:read_regular_2) { create(high_priority: false, read: true, created_at: 4.minutes.ago) }
+
+ it "puts unread high_priority on top followed by unread normal notifications and then everything else in reverse chronological order" do
+ expect(Notification.prioritized_list(user).map(&:id)).to eq(
+ [
+ unread_high_priority_2,
+ unread_high_priority_1,
+ unread_regular_2,
+ unread_regular_1,
+ read_high_priority_2,
+ unread_like,
+ read_regular_2,
+ read_regular_1,
+ read_high_priority_1,
+ ].map(&:id),
+ )
+ end
- it "correctly finds visible notifications" do
- pm
- expect(Notification.visible.count).to eq(1)
- post.topic.trash!
- expect(Notification.visible.count).to eq(0)
- end
+ it "doesn't include notifications from other users" do
+ another_user_notification = create(high_priority: true, read: false, user: Fabricate(:user))
+ expect(Notification.prioritized_list(user).map(&:id)).to contain_exactly(
+ *[
+ unread_high_priority_2,
+ unread_high_priority_1,
+ unread_regular_2,
+ unread_regular_1,
+ read_high_priority_2,
+ unread_like,
+ read_regular_2,
+ read_regular_1,
+ read_high_priority_1,
+ ].map(&:id),
+ )
+ expect(
+ Notification.prioritized_list(another_user_notification.user).map(&:id),
+ ).to contain_exactly(another_user_notification.id)
+ end
- it "orders stuff by creation descending, bumping unread high priority (pms, bookmark reminders) to top" do
- # note we expect the final order to read bottom-up for this list of variables,
- # with unread pm + bookmark reminder at the top of that list
- a = unread_pm
- regular
- b = unread_bookmark_reminder
- c = pm
- d = regular
-
- notifications = Notification.recent_report(user, 4)
- expect(notifications.map { |n| n.id }).to eq([b.id, a.id, d.id, c.id])
- end
+ it "doesn't include notifications from deleted topics" do
+ unread_high_priority_1.topic.trash!
+ unread_regular_2.topic.trash!
+ read_regular_1.topic.trash!
+ expect(Notification.prioritized_list(user).map(&:id)).to contain_exactly(
+ *[
+ unread_high_priority_2,
+ unread_regular_1,
+ read_high_priority_2,
+ unread_like,
+ read_regular_2,
+ read_high_priority_1,
+ ].map(&:id),
+ )
+ end
- describe "for a user that does not want to be notify on liked" do
- before do
+ it "doesn't include like notifications if the user doesn't want like notifications" do
user.user_option.update!(
like_notification_frequency: UserOption.like_notification_frequency_type[:never],
)
+ unread_regular_1.update!(notification_type: Notification.types[:liked])
+ read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
+ expect(Notification.prioritized_list(user).map(&:id)).to eq(
+ [
+ unread_high_priority_2,
+ unread_high_priority_1,
+ unread_regular_2,
+ read_high_priority_2,
+ read_regular_1,
+ read_high_priority_1,
+ ].map(&:id),
+ )
end
- it "should not return any form of liked notifications" do
- notification = pm
- regular
- liked_consolidated
+ it "respects the count param" do
+ expect(Notification.prioritized_list(user, count: 1).map(&:id)).to eq(
+ [unread_high_priority_2].map(&:id),
+ )
- expect(Notification.recent_report(user)).to contain_exactly(notification)
+ expect(Notification.prioritized_list(user, count: 3).map(&:id)).to eq(
+ [unread_high_priority_2, unread_high_priority_1, unread_regular_2].map(&:id),
+ )
+ end
+
+ it "can filter the list by specific types" do
+ unread_regular_1.update!(notification_type: Notification.types[:liked])
+ read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
+ expect(
+ Notification.prioritized_list(
+ user,
+ types: [Notification.types[:liked], Notification.types[:liked_consolidated]],
+ ).map(&:id),
+ ).to eq([unread_like, unread_regular_1, read_regular_2].map(&:id))
+ end
+
+ it "includes like notifications when filtering by like types even if the user doesn't want like notifications" do
+ user.user_option.update!(
+ like_notification_frequency: UserOption.like_notification_frequency_type[:never],
+ )
+ unread_regular_1.update!(notification_type: Notification.types[:liked])
+ read_regular_2.update!(notification_type: Notification.types[:liked_consolidated])
+ expect(
+ Notification.prioritized_list(
+ user,
+ types: [Notification.types[:liked], Notification.types[:liked_consolidated]],
+ ).map(&:id),
+ ).to eq([unread_like, unread_regular_1, read_regular_2].map(&:id))
+ expect(
+ Notification.prioritized_list(user, types: [Notification.types[:liked]]).map(&:id),
+ ).to contain_exactly(unread_like.id, unread_regular_1.id)
end
end
- describe "#consolidate_membership_requests" do
- fab!(:group) { Fabricate(:group, name: "XXsssssddd") }
- fab!(:user)
- fab!(:post)
+ describe "#recent_report" do
+ let(:post) { Fabricate(:post) }
+ let(:vars) { { i: 0 } }
- def create_membership_request_notification
- Notification.consolidate_or_create!(
- notification_type: Notification.types[:private_message],
+ def fab(type, read)
+ vars[:i] += 1
+ Notification.create!(
+ read: read,
user_id: user.id,
- data: {
- topic_title: I18n.t("groups.request_membership_pm.title", group_name: group.name),
- original_post_id: post.id,
- }.to_json,
- updated_at: Time.zone.now,
- created_at: Time.zone.now,
+ topic_id: post.topic_id,
+ post_number: post.post_number,
+ data: "[]",
+ notification_type: type,
+ created_at: vars[:i].days.from_now,
)
end
- before do
- PostCustomField.create!(post_id: post.id, name: "requested_group_id", value: group.id)
- 2.times { create_membership_request_notification }
+ def unread_pm
+ fab(Notification.types[:private_message], false)
end
- it "should consolidate membership requests to a new notification" do
- original_notification = create_membership_request_notification
- starting_count = SiteSetting.notification_consolidation_threshold
+ def unread_bookmark_reminder
+ fab(Notification.types[:bookmark_reminder], false)
+ end
- consolidated_notification = create_membership_request_notification
- expect { original_notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ def pm
+ fab(Notification.types[:private_message], true)
+ end
- expect(consolidated_notification.notification_type).to eq(
- Notification.types[:membership_request_consolidated],
- )
+ def regular
+ fab(Notification.types[:liked], true)
+ end
- data = consolidated_notification.data_hash
- expect(data[:group_name]).to eq(group.name)
- expect(data[:count]).to eq(starting_count + 1)
+ def liked_consolidated
+ fab(Notification.types[:liked_consolidated], true)
+ end
- updated_consolidated_notification = create_membership_request_notification
+ it "correctly finds visible notifications" do
+ pm
+ expect(Notification.visible.count).to eq(1)
+ post.topic.trash!
+ expect(Notification.visible.count).to eq(0)
+ end
- expect(updated_consolidated_notification.data_hash[:count]).to eq(starting_count + 2)
+ it "orders stuff by creation descending, bumping unread high priority (pms, bookmark reminders) to top" do
+ # note we expect the final order to read bottom-up for this list of variables,
+ # with unread pm + bookmark reminder at the top of that list
+ a = unread_pm
+ regular
+ b = unread_bookmark_reminder
+ c = pm
+ d = regular
+
+ notifications = Notification.recent_report(user, 4)
+ expect(notifications.map { |n| n.id }).to eq([b.id, a.id, d.id, c.id])
end
- it 'consolidates membership requests with "processed" false if user is in DND' do
- user.do_not_disturb_timings.create(starts_at: Time.now, ends_at: 3.days.from_now)
+ describe "for a user that does not want to be notify on liked" do
+ before do
+ user.user_option.update!(
+ like_notification_frequency: UserOption.like_notification_frequency_type[:never],
+ )
+ end
- create_membership_request_notification
- create_membership_request_notification
+ it "excludes all types of like notifications" do
+ notification = pm
+ regular
+ liked_consolidated
- notification = Notification.last
- expect(notification.notification_type).to eq(
- Notification.types[:membership_request_consolidated],
- )
- expect(notification.shelved_notification).to be_present
+ expect(Notification.recent_report(user)).to contain_exactly(notification)
+ end
end
- end
- end
- describe "purge_old!" do
- fab!(:user)
- fab!(:notification1) { Fabricate(:notification, user: user) }
- fab!(:notification2) { Fabricate(:notification, user: user) }
- fab!(:notification3) { Fabricate(:notification, user: user) }
- fab!(:notification4) { Fabricate(:notification, user: user) }
+ describe "#consolidate_membership_requests" do
+ fab!(:group) { Fabricate(:group, name: "XXsssssddd") }
+ fab!(:user)
+ fab!(:post)
+
+ def create_membership_request_notification
+ Notification.consolidate_or_create!(
+ notification_type: Notification.types[:private_message],
+ user_id: user.id,
+ data: {
+ topic_title: I18n.t("groups.request_membership_pm.title", group_name: group.name),
+ original_post_id: post.id,
+ }.to_json,
+ updated_at: Time.zone.now,
+ created_at: Time.zone.now,
+ )
+ end
- it "does nothing if set to 0" do
- SiteSetting.max_notifications_per_user = 0
- Notification.purge_old!
+ before do
+ PostCustomField.create!(post_id: post.id, name: "requested_group_id", value: group.id)
+ 2.times { create_membership_request_notification }
+ end
- expect(Notification.where(user_id: user.id).count).to eq(4)
- end
+ it "consolidates membership requests into a new notification" do
+ original_notification = create_membership_request_notification
+ starting_count = SiteSetting.notification_consolidation_threshold
- it "correctly limits" do
- SiteSetting.max_notifications_per_user = 2
- Notification.purge_old!
+ consolidated_notification = create_membership_request_notification
+ expect { original_notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
- expect(Notification.where(user_id: user.id).pluck(:id)).to contain_exactly(
- notification4.id,
- notification3.id,
- )
- end
- end
+ expect(consolidated_notification.notification_type).to eq(
+ Notification.types[:membership_request_consolidated],
+ )
- describe "do not disturb" do
- fab!(:user)
+ data = consolidated_notification.data_hash
+ expect(data[:group_name]).to eq(group.name)
+ expect(data[:count]).to eq(starting_count + 1)
- it "creates a shelved_notification record when created while user is in DND" do
- user.do_not_disturb_timings.create(starts_at: Time.now, ends_at: 3.days.from_now)
- notification =
- Notification.create(
- read: false,
- user_id: user.id,
- topic_id: 2,
- post_number: 1,
- data: "{}",
- notification_type: 1,
- )
- expect(notification.shelved_notification).to be_present
- end
+ updated_consolidated_notification = create_membership_request_notification
- it "doesn't create a shelved_notification record when created while user is isn't DND" do
- notification =
- Notification.create(
- read: false,
- user_id: user.id,
- topic_id: 2,
- post_number: 1,
- data: "{}",
- notification_type: 1,
- )
- expect(notification.shelved_notification).to be_nil
- end
- end
+ expect(updated_consolidated_notification.data_hash[:count]).to eq(starting_count + 2)
+ end
- describe ".populate_acting_user" do
- SiteSetting.enable_names = true
-
- fab!(:user1, :user)
- fab!(:user2, :user)
- fab!(:user3, :user)
- fab!(:user4, :user)
- fab!(:user5, :user)
- fab!(:user6, :user)
- fab!(:notification1) do
- Fabricate(:notification, user: user, data: { username: user1.username }.to_json)
- end
- fab!(:notification2) do
- Fabricate(:notification, user: user, data: { display_username: user2.username }.to_json)
- end
- fab!(:notification3) do
- Fabricate(:notification, user: user, data: { mentioned_by_username: user3.username }.to_json)
- end
- fab!(:notification4) do
- Fabricate(:notification, user: user, data: { invited_by_username: user4.username }.to_json)
- end
- fab!(:notification5) do
- Fabricate(:notification, user: user, data: { original_username: user5.username }.to_json)
- end
- fab!(:notification6) do
- Fabricate(:notification, user: user, data: { original_username: user6.username }.to_json)
- end
+ it 'consolidates membership requests with "processed" false if user is in DND' do
+ user.do_not_disturb_timings.create(starts_at: Time.now, ends_at: 3.days.from_now)
- it "Sets the acting_user correctly for each notification" do
- SiteSetting.prioritize_full_name_in_ux = true
- Notification.populate_acting_user(
- [notification1, notification2, notification3, notification4, notification5],
- )
- expect(notification1.acting_user).to eq(user1)
- expect(notification2.acting_user).to eq(user2)
- expect(notification3.acting_user).to eq(user3)
- expect(notification4.acting_user).to eq(user4)
- expect(notification5.acting_user).to eq(user5)
- expect(notification5.data_hash[:original_name]).to eq user5.name
- end
+ create_membership_request_notification
+ create_membership_request_notification
- context "with SiteSettings.enable_names=false" do
- it "doesn't set the :original_name property" do
- SiteSetting.enable_names = false
- Notification.populate_acting_user([notification6])
- expect(notification6.data_hash[:original_name]).to be_nil
- SiteSetting.enable_names = true
+ notification = Notification.last
+ expect(notification.notification_type).to eq(
+ Notification.types[:membership_request_consolidated],
+ )
+ expect(notification.shelved_notification).to be_present
+ end
end
end
- end
- describe ".filter_disabled_badge_notifications" do
- fab!(:enabled_badge) { Fabricate(:badge, enabled: true) }
- fab!(:disabled_badge) { Fabricate(:badge, enabled: false) }
+ describe "purge_old!" do
+ fab!(:user)
+ fab!(:notification1) { Fabricate(:notification, user: user) }
+ fab!(:notification2) { Fabricate(:notification, user: user) }
+ fab!(:notification3) { Fabricate(:notification, user: user) }
+ fab!(:notification4) { Fabricate(:notification, user: user) }
+
+ it "does nothing if set to 0" do
+ SiteSetting.max_notifications_per_user = 0
+ Notification.purge_old!
- fab!(:enabled_badge_notification) do
- BadgeGranter.send_notification(user.id, user.username, user.locale, enabled_badge)
+ expect(Notification.where(user_id: user.id).count).to eq(4)
+ end
+
+ it "correctly limits" do
+ SiteSetting.max_notifications_per_user = 2
+ Notification.purge_old!
+
+ expect(Notification.where(user_id: user.id).pluck(:id)).to contain_exactly(
+ notification4.id,
+ notification3.id,
+ )
+ end
end
- fab!(:disabled_badge_notification) do
- BadgeGranter.send_notification(user.id, user.username, user.locale, disabled_badge)
+ describe "do not disturb" do
+ fab!(:user)
+
+ it "creates a shelved_notification record when created while user is in DND" do
+ user.do_not_disturb_timings.create(starts_at: Time.now, ends_at: 3.days.from_now)
+ notification =
+ Notification.create(
+ read: false,
+ user_id: user.id,
+ topic_id: 2,
+ post_number: 1,
+ data: "{}",
+ notification_type: 1,
+ )
+ expect(notification.shelved_notification).to be_present
+ end
+
+ it "doesn't create a shelved_notification record when created while user is isn't DND" do
+ notification =
+ Notification.create(
+ read: false,
+ user_id: user.id,
+ topic_id: 2,
+ post_number: 1,
+ data: "{}",
+ notification_type: 1,
+ )
+ expect(notification.shelved_notification).to be_nil
+ end
end
- fab!(:regular_notification) { Fabricate(:notification, user: user) }
+ describe ".populate_acting_user" do
+ SiteSetting.enable_names = true
- it "filters all badge notifications when enable_badges is false" do
- SiteSetting.enable_badges = false
+ fab!(:user1, :user)
+ fab!(:user2, :user)
+ fab!(:user3, :user)
+ fab!(:user4, :user)
+ fab!(:user5, :user)
+ fab!(:user6, :user)
+ fab!(:notification1) do
+ Fabricate(:notification, user: user, data: { username: user1.username }.to_json)
+ end
+ fab!(:notification2) do
+ Fabricate(:notification, user: user, data: { display_username: user2.username }.to_json)
+ end
+ fab!(:notification3) do
+ Fabricate(
+ :notification,
+ user: user,
+ data: { mentioned_by_username: user3.username }.to_json,
+ )
+ end
+ fab!(:notification4) do
+ Fabricate(:notification, user: user, data: { invited_by_username: user4.username }.to_json)
+ end
+ fab!(:notification5) do
+ Fabricate(:notification, user: user, data: { original_username: user5.username }.to_json)
+ end
+ fab!(:notification6) do
+ Fabricate(:notification, user: user, data: { original_username: user6.username }.to_json)
+ end
- result =
- Notification.filter_disabled_badge_notifications(
- [enabled_badge_notification, disabled_badge_notification, regular_notification],
+ it "Sets the acting_user correctly for each notification" do
+ SiteSetting.prioritize_full_name_in_ux = true
+ Notification.populate_acting_user(
+ [notification1, notification2, notification3, notification4, notification5],
)
+ expect(notification1.acting_user).to eq(user1)
+ expect(notification2.acting_user).to eq(user2)
+ expect(notification3.acting_user).to eq(user3)
+ expect(notification4.acting_user).to eq(user4)
+ expect(notification5.acting_user).to eq(user5)
+ expect(notification5.data_hash[:original_name]).to eq user5.name
+ end
- expect(result).to contain_exactly(regular_notification)
+ context "with SiteSettings.enable_names=false" do
+ it "doesn't set the :original_name property" do
+ SiteSetting.enable_names = false
+ Notification.populate_acting_user([notification6])
+ expect(notification6.data_hash[:original_name]).to be_nil
+ SiteSetting.enable_names = true
+ end
+ end
end
- it "filters badge notifications for badges that are disabled" do
- result =
- Notification.filter_disabled_badge_notifications(
- [enabled_badge_notification, disabled_badge_notification, regular_notification],
- )
+ describe ".filter_disabled_badge_notifications" do
+ fab!(:enabled_badge) { Fabricate(:badge, enabled: true) }
+ fab!(:disabled_badge) { Fabricate(:badge, enabled: false) }
- expect(result).to contain_exactly(enabled_badge_notification, regular_notification)
- end
+ fab!(:enabled_badge_notification) do
+ BadgeGranter.send_notification(user.id, user.username, user.locale, enabled_badge)
+ end
+
+ fab!(:disabled_badge_notification) do
+ BadgeGranter.send_notification(user.id, user.username, user.locale, disabled_badge)
+ end
- it "filters badge notifications for badges that do not exist" do
- enabled_badge.destroy!
+ fab!(:regular_notification) { Fabricate(:notification, user: user) }
- result = Notification.filter_disabled_badge_notifications([enabled_badge_notification])
+ it "filters all badge notifications when enable_badges is false" do
+ SiteSetting.enable_badges = false
- expect(result).to eq([])
+ result =
+ Notification.filter_disabled_badge_notifications(
+ [enabled_badge_notification, disabled_badge_notification, regular_notification],
+ )
+
+ expect(result).to contain_exactly(regular_notification)
+ end
+
+ it "filters badge notifications for badges that are disabled" do
+ result =
+ Notification.filter_disabled_badge_notifications(
+ [enabled_badge_notification, disabled_badge_notification, regular_notification],
+ )
+
+ expect(result).to contain_exactly(enabled_badge_notification, regular_notification)
+ end
+
+ it "filters badge notifications for badges that do not exist" do
+ enabled_badge.destroy!
+
+ result = Notification.filter_disabled_badge_notifications([enabled_badge_notification])
+
+ expect(result).to eq([])
+ end
end
end
end
diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb
index 4884f0fdcff..1dcccfc880b 100644
--- a/spec/models/optimized_image_spec.rb
+++ b/spec/models/optimized_image_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe OptimizedImage do
before { upload.id = 42 }
describe ".crop" do
- it "should produce cropped images (requires ImageMagick 7)" do
+ it "produces cropped images with ImageMagick 7" do
tmp_path = "/tmp/cropped.png"
desired_width = 5
desired_height = 5
@@ -54,7 +54,7 @@ RSpec.describe OptimizedImage do
end
end
- it "should correctly crop images horizontally" do
+ it "crops images horizontally" do
tmp_path = "/tmp/cropped.png"
desired_width = 244
desired_height = 500
@@ -91,7 +91,7 @@ RSpec.describe OptimizedImage do
end
describe ".resize" do
- it "should work correctly when extension is bad" do
+ it "handles an invalid extension" do
original_path = Dir::Tmpname.create(%w[origin .bin]) { nil }
begin
@@ -112,7 +112,7 @@ RSpec.describe OptimizedImage do
end
end
- it "should work correctly" do
+ it "optimizes the image" do
file = File.open("#{Rails.root.join("spec/fixtures/images/resized.png")}")
upload = UploadCreator.new(file, "test.bin").create_for(-1)
@@ -144,7 +144,7 @@ RSpec.describe OptimizedImage do
end
describe "when an svg with a href is masked as a png" do
- it "should not trigger the external request" do
+ it "does not trigger an external request" do
tmp_path = "/tmp/resized.png"
begin
@@ -165,7 +165,7 @@ RSpec.describe OptimizedImage do
end
describe ".downsize" do
- it "should downsize logo (requires ImageMagick 7)" do
+ it "downsizes the logo with ImageMagick 7" do
tmp_path = "/tmp/downsized.png"
begin
@@ -327,7 +327,7 @@ RSpec.describe OptimizedImage do
OptimizedImage.create_for(upload, 100, 200)
end
- it "works" do
+ it "creates the optimized image" do
oi = OptimizedImage.create_for(upload, 100, 200)
expect(oi.sha1).to eq("da39a3ee5e6b4b0d3255bfef95601890afd80709")
expect(oi.extension).to eq(".png")
@@ -401,7 +401,7 @@ RSpec.describe OptimizedImage do
describe "#destroy" do
describe "when upload_id is no longer valid" do
- it "should still destroy the record" do
+ it "still destroys the record" do
image = Fabricate(:optimized_image)
image.upload.delete
image.reload.destroy
diff --git a/spec/models/optimized_video_spec.rb b/spec/models/optimized_video_spec.rb
index 180cf0a63f9..df5bfd63fbe 100644
--- a/spec/models/optimized_video_spec.rb
+++ b/spec/models/optimized_video_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe OptimizedVideo do
end
describe "#destroy" do
- it "should destroy the optimized video and its associated upload" do
+ it "destroys the optimized video and its associated upload" do
optimized_video = Fabricate(:optimized_video)
expect { optimized_video.destroy }.to change(OptimizedVideo, :count).by(-1)
expect(Upload.exists?(optimized_video.optimized_upload_id)).to be(false)
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index ba94ec4e6d6..e64db73a816 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -155,7 +155,7 @@ RSpec.describe PostAction do
describe "when a user likes something" do
before { PostActionNotifier.enable }
- it "should generate and remove notifications correctly" do
+ it "creates and removes notifications" do
PostActionCreator.like(codinghorror, post)
expect(Notification.count).to eq(1)
@@ -179,7 +179,7 @@ RSpec.describe PostAction do
expect(notification.notification_type).to eq(Notification.types[:liked])
end
- it "should not notify when never is selected" do
+ it "does not notify when never is selected" do
post.user.user_option.update!(
like_notification_frequency: UserOption.like_notification_frequency_type[:never],
)
@@ -269,7 +269,7 @@ RSpec.describe PostAction do
)
end
- it "should consolidate likes notification when the threshold is reached" do
+ it "consolidates like notifications at the threshold" do
SiteSetting.notification_consolidation_threshold = 2
expect do
@@ -325,7 +325,7 @@ RSpec.describe PostAction do
)
end
- it "should consolidate liked notifications when threshold is reached" do
+ it "consolidates liked notifications at the threshold" do
SiteSetting.notification_consolidation_threshold = 2
post = Fabricate(:post, user: likee)
@@ -363,14 +363,14 @@ RSpec.describe PostAction do
end
end
- it "should not generate a notification if liker has been muted" do
+ it "does not notify when the liker is muted" do
mutee = Fabricate(:user)
MutedUser.create!(user_id: post.user.id, muted_user_id: mutee.id)
expect do PostActionCreator.like(mutee, post) end.to_not change { Notification.count }
end
- it "should not generate a notification if liker has the topic muted" do
+ it "does not notify when the liker muted the topic" do
post = Fabricate(:post, user: eviltrout)
TopicUser.create!(
@@ -382,7 +382,7 @@ RSpec.describe PostAction do
expect do PostActionCreator.like(codinghorror, post) end.to_not change { Notification.count }
end
- it "should generate a notification if liker is an admin irregardless of \
+ it "notifies when the liker is an admin regardless of \
muting" do
MutedUser.create!(user_id: post.user.id, muted_user_id: admin.id)
@@ -394,7 +394,7 @@ RSpec.describe PostAction do
expect(notification.notification_type).to eq(Notification.types[:liked])
end
- it "should not increase topic like count when liking a whisper" do
+ it "does not increase the topic like count for a whisper" do
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
post.revise(admin, post_type: Post.types[:whisper])
@@ -404,7 +404,7 @@ RSpec.describe PostAction do
expect(post.topic.like_count).to eq(0)
end
- it "should increase the `like_count` and `like_score` when a user likes something" do
+ it "increases like_count and like_score when a user likes a post" do
freeze_time Date.today
PostActionCreator.like(codinghorror, post)
@@ -437,7 +437,7 @@ RSpec.describe PostAction do
expect(post.topic.like_count).to eq(0)
end
- it "shouldn't change given_likes unless likes are given or removed" do
+ it "changes given_likes only when likes are added or removed" do
freeze_time
PostActionCreator.like(codinghorror, post)
@@ -473,7 +473,7 @@ RSpec.describe PostAction do
expect(PostActionCreator.spam(eviltrout, post)).to be_success
end
- it "should update counts when you clear flags" do
+ it "updates counts when flags are cleared" do
reviewable = PostActionCreator.spam(eviltrout, post).reviewable
expect(post.reload.spam_count).to eq(1)
@@ -483,7 +483,7 @@ RSpec.describe PostAction do
expect(post.reload.spam_count).to eq(0)
end
- it "will not allow regular users to auto hide staff posts" do
+ it "does not let regular users automatically hide staff posts" do
mod = Fabricate(:moderator)
post = Fabricate(:post, user: mod)
@@ -515,7 +515,7 @@ RSpec.describe PostAction do
expect(post.hidden_at).to be_present
end
- it "will not trigger auto hide on like" do
+ it "does not trigger automatic hiding for likes" do
mod = Fabricate(:moderator)
post = Fabricate(:post, user: mod)
@@ -528,7 +528,7 @@ RSpec.describe PostAction do
expect(post.hidden).to eq(false)
end
- it "should follow the rules for automatic hiding workflow" do
+ it "follows the automatic hiding workflow" do
post = create_post
walterwhite = Fabricate(:walter_white, refresh_auto_groups: true)
@@ -631,7 +631,7 @@ RSpec.describe PostAction do
expect(result.reviewable.payload["targets_topic"]).to eq(true)
end
- it "will flag the first post if you flag a topic but there is only one post in the topic" do
+ it "flags the first post when it is the topic's only post" do
post = create_post
result =
PostActionCreator.new(
@@ -645,7 +645,7 @@ RSpec.describe PostAction do
expect(result.reviewable.payload["targets_topic"]).to eq(false)
end
- it "will unhide the post when a moderator undoes the flag on which s/he took action" do
+ it "unhides the post when a moderator undoes the handled flag" do
Discourse.stubs(:site_contact_user).returns(admin)
post = create_post
@@ -677,7 +677,7 @@ RSpec.describe PostAction do
SiteSetting.num_hours_to_close_topic = 1
end
- it "will automatically pause a topic due to large community flagging" do
+ it "automatically pauses a topic after extensive community flagging" do
freeze_time
# reaching `num_flaggers_to_close_topic` isn't enough
@@ -714,7 +714,7 @@ RSpec.describe PostAction do
fab!(:staff_user) { Fabricate(:user, moderator: true) }
fab!(:topic) { Fabricate(:topic, user: staff_user) }
- it "will not close topics opened by staff" do
+ it "does not close topics opened by staff" do
[flagger1, flagger2].each do |flagger|
[post1, post2, post3].each { |post| PostActionCreator.inappropriate(flagger, post) }
end
@@ -723,7 +723,7 @@ RSpec.describe PostAction do
end
end
- it "will keep the topic in closed status until the community flags are handled" do
+ it "keeps the topic closed until community flags are handled" do
freeze_time
SiteSetting.num_flaggers_to_close_topic = 1
@@ -754,7 +754,7 @@ RSpec.describe PostAction do
expect(topic.reload.closed).to eq(false)
end
- it "will reopen topic after the flags are auto handled" do
+ it "reopens the topic after flags are handled automatically" do
freeze_time
[flagger1, flagger2].each do |flagger|
[post1, post2, post3].each { |post| PostActionCreator.inappropriate(flagger, post) }
@@ -841,7 +841,7 @@ RSpec.describe PostAction do
flag_with_message.destroy!
end
- it "should raise the right errors when it fails to create a post" do
+ it "returns the post-creation errors" do
user = Fabricate(:user)
UserSilencer.new(user, Discourse.system_user).silence
@@ -849,7 +849,7 @@ RSpec.describe PostAction do
expect(result).to be_failed
end
- it "should succeed even with low max title length" do
+ it "succeeds with a low maximum title length" do
SiteSetting.max_topic_title_length = 50
post.topic.title = "This is a test topic " * 2
post.topic.save!
@@ -871,7 +871,7 @@ RSpec.describe PostAction do
end
describe "#add_moderator_post_if_needed" do
- it "should not add a moderator post when it's disabled" do
+ it "does not add a moderator post when disabled" do
post = create_post
result = PostActionCreator.create(moderator, post, :spam, message: "WAT")
@@ -883,7 +883,7 @@ RSpec.describe PostAction do
expect(topic.reload.posts.count).to eq(1)
end
- it "should create a notification in the related topic" do
+ it "creates a notification in the related topic" do
Jobs.run_immediately!
user = Fabricate(:user, refresh_auto_groups: true)
stub_image_size
@@ -900,7 +900,7 @@ RSpec.describe PostAction do
end
%i[agree_and_keep disagree ignore_and_do_nothing].each do |disposition|
- it "should bump the topic when performing #{disposition}" do
+ it "bumps the topic when performing #{disposition}" do
SiteSetting.auto_respond_to_flag_actions = true
user = Fabricate(:user, refresh_auto_groups: true)
result = PostActionCreator.create(user, post, :spam, message: "WAT")
@@ -938,7 +938,7 @@ RSpec.describe PostAction do
action.post_action_rate_limiter
end
- it "should scale up likes limits depending on trust level" do
+ it "scales the like limit by trust level" do
expect(limiter(0, :like).max).to eq SiteSetting.max_likes_per_day
expect(limiter(1, :like).max).to eq SiteSetting.max_likes_per_day
expect(limiter(2, :like).max).to eq (
@@ -961,7 +961,7 @@ RSpec.describe PostAction do
expect(limiter(2, :like).max).to eq SiteSetting.max_likes_per_day
end
- it "should scale up flag limits depending on trust level" do
+ it "scales the flag limit by trust level" do
%i[off_topic inappropriate spam notify_moderators].each do |type|
SiteSetting.tl2_additional_flags_per_day_multiplier = 1.5
@@ -991,7 +991,7 @@ RSpec.describe PostAction do
describe "#is_flag?" do
describe "when post action is a flag" do
- it "should return true" do
+ it "returns true" do
PostActionType.notify_flag_types.each do |_type, id|
post_action = PostAction.new(user: codinghorror, post_action_type_id: id)
@@ -1001,7 +1001,7 @@ RSpec.describe PostAction do
end
describe "when post action is not a flag" do
- it "should return false" do
+ it "returns false" do
post_action = PostAction.new(user: codinghorror, post_action_type_id: 99)
expect(post_action.is_flag?).to eq(false)
diff --git a/spec/models/post_action_type_spec.rb b/spec/models/post_action_type_spec.rb
index 5eb4ea0c1f1..28d0450e928 100644
--- a/spec/models/post_action_type_spec.rb
+++ b/spec/models/post_action_type_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe PostActionType do
describe "Callbacks" do
describe "#expiry_cache" do
- it "should clear the cache on save" do
+ it "clears the cache on save" do
Discourse.cache.write("post_action_types_#{I18n.locale}", "test")
Discourse.cache.write("post_action_flag_types_#{I18n.locale}", "test2")
diff --git a/spec/models/post_analyzer_spec.rb b/spec/models/post_analyzer_spec.rb
index 274b6c2d1da..f5d89270825 100644
--- a/spec/models/post_analyzer_spec.rb
+++ b/spec/models/post_analyzer_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe PostAnalyzer do
expect(cooked).to eq("<p><em>this is italic</em></p>")
end
- it "should respect SiteSetting.max_oneboxes_per_post" do
+ it "respects SiteSetting.max_oneboxes_per_post" do
SiteSetting.max_oneboxes_per_post = 2
Oneboxer.expects(:cached_onebox).with(url).returns("something").twice
@@ -146,7 +146,7 @@ RSpec.describe PostAnalyzer do
expect(post_analyzer.linked_hosts).to eq("disneyland.disney.go.com" => 1, "reddit.com" => 1)
end
- it "it counts properly with more than one link on the same host" do
+ it "counts each host once when multiple links share a host" do
post_analyzer = PostAnalyzer.new(raw_three_links, default_topic_id)
expect(post_analyzer.linked_hosts).to eq("discourse.org" => 1, "www.imdb.com" => 1)
end
@@ -242,7 +242,7 @@ RSpec.describe PostAnalyzer do
expect(post_analyzer.link_count).to eq(0)
end
- it "returns 0 links for a post with mentions" do
+ it "returns zero links for a post with hashtags" do
SiteSetting.tagging_enabled = true
post_analyzer = PostAnalyzer.new(raw_post_with_hashtags, default_topic_id)
expect(post_analyzer.link_count).to eq(0)
diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb
index c3d09598870..e0e09f4fefe 100644
--- a/spec/models/post_mover_spec.rb
+++ b/spec/models/post_mover_spec.rb
@@ -173,7 +173,7 @@ RSpec.describe PostMover do
context "with post replies" do
describe "when a post with replies is moved" do
- it "should update post replies correctly" do
+ it "updates post replies correctly" do
topic.move_posts(
user,
[p2.id],
@@ -198,7 +198,7 @@ RSpec.describe PostMover do
end
describe "when replies of a post have been moved" do
- it "should update post replies correctly" do
+ it "updates post replies correctly" do
p5 =
Fabricate(
:post,
@@ -221,7 +221,7 @@ RSpec.describe PostMover do
end
context "when only one reply is left behind" do
- it "should update post replies correctly" do
+ it "updates post replies correctly" do
p5 =
Fabricate(
:post,
diff --git a/spec/models/post_reply_key_spec.rb b/spec/models/post_reply_key_spec.rb
index e93c0b4442d..4f832ad94e2 100644
--- a/spec/models/post_reply_key_spec.rb
+++ b/spec/models/post_reply_key_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe PostReplyKey do
describe "#reply_key" do
- it "should format the reply_key correctly" do
+ it "formats the reply key" do
hex = SecureRandom.hex
post_reply_key = Fabricate(:post_reply_key, reply_key: hex)
diff --git a/spec/models/post_reply_spec.rb b/spec/models/post_reply_spec.rb
index f61d13ac792..3cc5f46a88b 100644
--- a/spec/models/post_reply_spec.rb
+++ b/spec/models/post_reply_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe PostReply do
fab!(:other_post) { Fabricate(:post, topic: topic) }
describe "Validations" do
- it "should ensure that the posts belong in the same topic" do
+ it "requires both posts to belong to the same topic" do
expect(PostReply.new(post: post, reply: other_post)).to be_valid
other_topic = Fabricate(:topic)
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 0dd656fc7e9..56c608d4b99 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -148,7 +148,7 @@ RSpec.describe Post do
post
end
- it "will have its notice cleared when post is trashed" do
+ it "clears its notice when trashed" do
expect { post.trash! }.to change { post.custom_fields }.to({})
end
end
@@ -532,7 +532,7 @@ RSpec.describe Post do
expect(two_links.linked_hosts).to eq("disneyland.disney.go.com" => 1, "reddit.com" => 1)
end
- it "it counts properly with more than one link on the same host" do
+ it "counts multiple links on the same host correctly" do
expect(three_links.linked_hosts).to eq("discourse.org" => 1, "www.imdb.com" => 1)
end
end
@@ -635,7 +635,7 @@ RSpec.describe Post do
expect(post_one_link).not_to be_valid
end
- it "will skip the check for allowlisted domains" do
+ it "skips the check for allowlisted domains" do
SiteSetting.allowed_link_domains = "www.bbc.co.uk"
SiteSetting.post_links_allowed_groups = "12"
post_two_links.user.change_trust_level!(TrustLevel[1])
@@ -793,7 +793,7 @@ RSpec.describe Post do
context "with grace period editing & edit windows" do
before { SiteSetting.editing_grace_period = 1.minute.to_i }
- it "works" do
+ it "updates the post's link counts" do
revised_at = post.updated_at + 2.minutes
new_revised_at = revised_at + 2.minutes
@@ -894,7 +894,7 @@ RSpec.describe Post do
)
end
- it "should not cook the post if raw has not been changed" do
+ it "does not cook the post when raw is unchanged" do
post.save!
expect(post.cooked).to eq(cooked)
end
@@ -1132,7 +1132,7 @@ RSpec.describe Post do
)
end
- it "should unconditionally follow links for staff" do
+ it "always follows links for staff" do
SiteSetting.tl3_links_no_follow = true
post.user.trust_level = 1
post.user.moderator = true
@@ -1141,7 +1141,7 @@ RSpec.describe Post do
expect(post.cooked).not_to match(/nofollow/)
end
- it "should add nofollow to links in the post for trust levels below 3" do
+ it "adds nofollow to links for trust levels below 3" do
post.user.trust_level = 2
post.save
expect(post.cooked).to match(/noopener nofollow ugc/)
@@ -1200,7 +1200,7 @@ RSpec.describe Post do
before { Jobs.run_immediately! }
describe "when user can not mention a group" do
- it "should not create the mention with the notify class" do
+ it "does not add the notify class to the mention" do
post = Fabricate(:post, raw: "hello @#{group.name}")
post.trigger_post_process
post.reload
@@ -1214,7 +1214,7 @@ RSpec.describe Post do
describe "when user can mention a group" do
before { group.add(post.user) }
- it "should create the mention" do
+ it "creates the mention" do
post.update!(raw: "hello @#{group.name}")
post.trigger_post_process
post.reload
@@ -1231,7 +1231,7 @@ RSpec.describe Post do
group.add_owner(post.user)
end
- it "should create the mention" do
+ it "creates the mention" do
post.update!(raw: "hello @#{group.name}")
post.trigger_post_process
post.reload
@@ -1343,7 +1343,7 @@ RSpec.describe Post do
end
describe "#rebake!" do
- it "will rebake a post correctly" do
+ it "rebakes a post correctly" do
post = create_post
expect(post.baked_at).not_to eq(nil)
first_baked = post.baked_at
@@ -1504,7 +1504,7 @@ RSpec.describe Post do
fab!(:admin)
fab!(:new_user, :user)
- it "will change owner of a post correctly" do
+ it "changes a post's owner correctly" do
post.set_owner(coding_horror, Discourse.system_user)
post.reload
@@ -1563,7 +1563,7 @@ RSpec.describe Post do
end
describe ".rebake_old" do
- it "will catch posts it needs to rebake" do
+ it "finds posts that need rebaking" do
post = create_post
post.update_columns(baked_at: Time.new(2000, 1, 1), baked_version: -1)
Post.rebake_old(100)
@@ -1577,7 +1577,7 @@ RSpec.describe Post do
expect(post.baked_at).to eq_time(baked)
end
- it "will rate limit globally" do
+ it "rate-limits globally" do
post1 = create_post
post2 = create_post
post3 = create_post
@@ -1602,7 +1602,7 @@ RSpec.describe Post do
after { Discourse.redis.flushdb }
- it "should not run post validations" do
+ it "does not run post validations" do
PostValidator.any_instance.expects(:validate).never
expect { post.hide!(PostActionType.types[:off_topic]) }.to change { post.reload.hidden }.from(
@@ -1610,7 +1610,7 @@ RSpec.describe Post do
).to(true)
end
- it "should inform the user when custom flag" do
+ it "informs the user about a custom flag" do
custom_flag = Fabricate(:flag, name: "custom flag")
post.hide!(PostActionType.types[:custom_custom_flag])
@@ -1623,13 +1623,13 @@ RSpec.describe Post do
custom_flag.destroy!
end
- it "should decrease user_stat topic_count for first post" do
+ it "decreases user_stat topic_count for the first post" do
expect do post.hide!(PostActionType.types[:off_topic]) end.to change {
post.user.user_stat.reload.topic_count
}.from(1).to(0)
end
- it "should decrease user_stat post_count" do
+ it "decreases user_stat post_count" do
post_2 = Fabricate(:post, topic: post.topic, user: post.user)
expect do post_2.hide!(PostActionType.types[:off_topic]) end.to change {
@@ -1689,7 +1689,7 @@ RSpec.describe Post do
before { SiteSetting.unique_posts_mins = 5 }
- it "will unhide the first post & make the topic visible" do
+ it "unhides the first post and makes the topic visible" do
hidden_topic = Fabricate(:topic, visible: false)
post = create_post(topic: hidden_topic)
@@ -1710,7 +1710,7 @@ RSpec.describe Post do
expect(hidden_topic.visibility_reason_id).to eq(Topic.visibility_reasons[:op_unhidden])
end
- it "will not unhide the topic if the topic visibility_reason_id is not op_flag_threshold_reached" do
+ it "does not unhide the topic for another visibility reason" do
hidden_topic =
Fabricate(
:topic,
@@ -1728,13 +1728,13 @@ RSpec.describe Post do
expect(hidden_topic.visible).to eq(false)
end
- it "should increase user_stat topic_count for first post" do
+ it "increases user_stat topic_count for the first post" do
post.hide!(PostActionType.types[:off_topic])
expect do post.unhide! end.to change { post.user.user_stat.reload.topic_count }.from(0).to(1)
end
- it "should decrease user_stat post_count" do
+ it "decreases user_stat post_count" do
post_2 = Fabricate(:post, topic: post.topic, user: post.user)
post_2.hide!(PostActionType.types[:off_topic])
@@ -1826,7 +1826,7 @@ RSpec.describe Post do
end
end
- it "will unhide the post but will keep the topic invisible/unlisted" do
+ it "unhides the post but keeps the topic unlisted" do
hidden_topic = Fabricate(:topic, visible: false)
create_post(topic: hidden_topic)
second_post = create_post(topic: hidden_topic)
@@ -2141,7 +2141,7 @@ RSpec.describe Post do
result
end
- it "will update topic updated_at for all topic related events" do
+ it "updates topic updated_at for all topic-related events" do
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
post =
@@ -2160,7 +2160,7 @@ RSpec.describe Post do
end
describe "have_uploads" do
- it "should find all posts with the upload" do
+ it "finds all posts containing the upload" do
ids = []
ids << Fabricate(
:post,
@@ -2326,7 +2326,7 @@ RSpec.describe Post do
expect(sha1s).to contain_exactly(sha1)
end
- it "should skip external urls with upload url in query string" do
+ it "skips external URLs containing an upload URL in the query string" do
setup_s3
urls = []
@@ -2341,7 +2341,7 @@ RSpec.describe Post do
expect(urls).to be_empty
end
- it "should skip external URLs following the `/uploads/short-url` pattern if a host is present and the host is not the configured host" do
+ it "skips short upload URLs hosted outside the configured host" do
upload = Fabricate(:upload)
raw = <<~RAW
diff --git a/spec/models/private_message_topic_tracking_state_spec.rb b/spec/models/private_message_topic_tracking_state_spec.rb
index 5a7f5c7e577..0189eddabd1 100644
--- a/spec/models/private_message_topic_tracking_state_spec.rb
+++ b/spec/models/private_message_topic_tracking_state_spec.rb
@@ -105,7 +105,7 @@ RSpec.describe PrivateMessageTopicTrackingState do
end
describe ".publish_new" do
- it "should publish the right message_bus message" do
+ it "publishes the expected MessageBus message" do
messages = MessageBus.track_publish { described_class.publish_new(private_message) }
expect(messages.map(&:channel)).to contain_exactly(described_class.user_channel(user_2.id))
@@ -120,7 +120,7 @@ RSpec.describe PrivateMessageTopicTrackingState do
expect(data["payload"]["created_by_user_id"]).to eq(private_message.user_id)
end
- it "should publish the right message_bus message for a group message" do
+ it "publishes the expected MessageBus message for a group message" do
messages = MessageBus.track_publish { described_class.publish_new(group_message) }
expect(messages.map(&:channel)).to contain_exactly(described_class.group_channel(group.id))
@@ -137,7 +137,7 @@ RSpec.describe PrivateMessageTopicTrackingState do
end
describe ".publish_unread" do
- it "should publish the right message_bus message" do
+ it "publishes the expected MessageBus message" do
messages =
MessageBus.track_publish { described_class.publish_unread(private_message.first_post) }
@@ -181,7 +181,7 @@ RSpec.describe PrivateMessageTopicTrackingState do
end
describe ".publish_group_archived" do
- it "should publish the right message_bus message" do
+ it "publishes the expected MessageBus message" do
user_3 = Fabricate(:user)
group.add(user_3)
@@ -207,7 +207,7 @@ RSpec.describe PrivateMessageTopicTrackingState do
end
describe ".publish_read" do
- it "should publish the right message_bus message" do
+ it "publishes the expected MessageBus message" do
message =
MessageBus
.track_publish(described_class.user_channel(user.id)) do
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 71fe1060e7a..64a16673a1b 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -364,7 +364,7 @@ RSpec.describe Report do
let(:report) { Report.find("page_view_legacy_total_reqs") }
context "with no data" do
- it "works" do
+ it "returns no legacy page-view requests" do
expect(report.data).to be_empty
end
end
@@ -407,7 +407,7 @@ RSpec.describe Report do
let(:report) { Report.find("page_view_total_reqs") }
context "with no data" do
- it "works" do
+ it "returns no page-view requests" do
expect(report.data).to be_empty
end
end
@@ -1472,7 +1472,7 @@ RSpec.describe Report do
let(:user) { Fabricate(:user) }
context "with data" do
- it "it works" do
+ it "returns each user's flagging ratio" do
topic = Fabricate(:topic, user: user)
2.times do
post_disagreed = Fabricate(:post, topic: topic, user: user)
@@ -1510,7 +1510,7 @@ RSpec.describe Report do
let(:robin) { Fabricate(:user, username: "robin") }
context "with data" do
- it "works" do
+ it "returns suspicious logins in reverse chronological order" do
SiteSetting.verbose_auth_token_logging = true
UserAuthToken.log(action: "suspicious", user_id: joffrey.id, created_at: 2.hours.ago)
@@ -1533,7 +1533,7 @@ RSpec.describe Report do
let(:james) { Fabricate(:user, username: "james") }
context "with data" do
- it "works" do
+ it "returns administrator login details" do
freeze_time_safe
ip = [81, 2, 69, 142]
@@ -1600,7 +1600,7 @@ RSpec.describe Report do
)
end
- it "works" do
+ it "returns upload details" do
expect(report.data.length).to eq(2)
expect_uploads_report_data_to_be_equal(report.data, khalil, khalil_upload)
expect_uploads_report_data_to_be_equal(report.data, tarek, tarek_upload)
@@ -1635,7 +1635,7 @@ RSpec.describe Report do
Fabricate(:ignored_user, user: tarek, ignored_user: matt)
end
- it "works" do
+ it "returns ignored-user counts" do
expect(report.data.length).to eq(2)
expect_ignored_users_report_data_to_be_equal(report.data, john, 1, 0)
@@ -1648,7 +1648,7 @@ RSpec.describe Report do
Fabricate(:muted_user, user: tarek, muted_user: matt)
end
- it "works" do
+ it "returns ignore and mute counts" do
expect(report.data.length).to eq(2)
expect_ignored_users_report_data_to_be_equal(report.data, john, 1, 1)
expect_ignored_users_report_data_to_be_equal(report.data, matt, 1, 1)
@@ -1680,7 +1680,7 @@ RSpec.describe Report do
let(:reports) { Report.find("consolidated_page_views_browser_detection") }
context "with no data" do
- it "works" do
+ it "returns empty browser-detection series" do
reports.data.each { |report| expect(report[:data]).to be_empty }
end
end
@@ -1699,7 +1699,7 @@ RSpec.describe Report do
CachedCounting.disable
end
- it "works" do
+ it "returns consolidated browser-detection data" do
3.times { ApplicationRequest.increment!(:page_view_crawler) }
8.times { ApplicationRequest.increment!(:page_view_logged_in) }
6.times { ApplicationRequest.increment!(:page_view_logged_in_browser) }
@@ -1792,7 +1792,7 @@ RSpec.describe Report do
let(:reports) { Report.find("site_traffic") }
context "with no data" do
- it "works" do
+ it "returns empty site-traffic series" do
reports.data.each { |report| expect(report[:data]).to be_empty }
end
end
@@ -1902,7 +1902,7 @@ RSpec.describe Report do
let(:reports) { Report.find("consolidated_page_views") }
context "with no data" do
- it "works" do
+ it "returns empty page-view series" do
reports.data.each { |report| expect(report[:data]).to be_empty }
end
end
@@ -1920,7 +1920,7 @@ RSpec.describe Report do
CachedCounting.disable
end
- it "works" do
+ it "returns consolidated page-view data" do
3.times { ApplicationRequest.increment!(:page_view_crawler) }
2.times { ApplicationRequest.increment!(:page_view_logged_in) }
ApplicationRequest.increment!(:page_view_anon)
@@ -1952,7 +1952,7 @@ RSpec.describe Report do
let(:reports) { Report.find("consolidated_api_requests") }
context "with no data" do
- it "works" do
+ it "returns empty API-request series" do
reports.data.each { |report| expect(report[:data]).to be_empty }
end
end
@@ -1969,7 +1969,7 @@ RSpec.describe Report do
CachedCounting.disable
end
- it "works" do
+ it "returns consolidated API-request data" do
2.times { ApplicationRequest.increment!(:api) }
ApplicationRequest.increment!(:user_api)
@@ -1996,7 +1996,7 @@ RSpec.describe Report do
let(:reports) { Report.find("trust_level_growth") }
context "with no data" do
- it "works" do
+ it "returns empty trust-level series" do
reports.data.each { |report| expect(report[:data]).to be_empty }
end
end
@@ -2020,7 +2020,7 @@ RSpec.describe Report do
)
end
- it "works" do
+ it "returns trust-level growth data" do
tl1_reached = reports.data.find { |r| r[:req] == "tl1_reached" }
tl2_reached = reports.data.find { |r| r[:req] == "tl2_reached" }
tl3_reached = reports.data.find { |r| r[:req] == "tl3_reached" }
@@ -2108,7 +2108,7 @@ RSpec.describe Report do
describe "top_uploads" do
context "with no data" do
- it "works" do
+ it "returns no uploads" do
report = Report.find("top_uploads")
expect(report.data).to be_empty
@@ -2119,7 +2119,7 @@ RSpec.describe Report do
fab!(:jpg_upload) { Fabricate(:upload, extension: :jpg) }
fab!(:png_upload) { Fabricate(:upload, extension: :png) }
- it "works" do
+ it "returns uploads grouped by extension" do
report = Report.find("top_uploads")
expect(report.data.length).to eq(2)
@@ -2322,7 +2322,7 @@ RSpec.describe Report do
)
end
- it "works" do
+ it "returns topic view statistics" do
expect(report.data.length).to eq(2)
expect(report.data[0]).to include(
topic_id: topic_2.id,
diff --git a/spec/models/reviewable_flagged_post_spec.rb b/spec/models/reviewable_flagged_post_spec.rb
index 8cc428533f7..34151ee2f73 100644
--- a/spec/models/reviewable_flagged_post_spec.rb
+++ b/spec/models/reviewable_flagged_post_spec.rb
@@ -125,7 +125,7 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
expect(reviewable.actions_for(guardian).has?(:disagree_and_restore)).to eq(true)
end
- it "won't return the penalty options if the user is not regular" do
+ it "omits penalty options for a non-regular user" do
post.user.update(moderator: true)
expect(reviewable.actions_for(guardian).has?(:agree_and_silence)).to eq(false)
expect(reviewable.actions_for(guardian).has?(:agree_and_suspend)).to eq(false)
@@ -446,7 +446,7 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
expect(pending_count).to eq(1)
end
- it "should reset counts when a topic is deleted" do
+ it "resets counts when a topic is deleted" do
PostActionCreator.off_topic(user, post)
expect(pending_count).to eq(1)
@@ -454,14 +454,14 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
expect(pending_count).to eq(0)
end
- it "should not review non-human users" do
+ it "does not review non-human users" do
post = create_post(user: Discourse.system_user)
reviewable = PostActionCreator.off_topic(user, post).reviewable
expect(reviewable).to be_blank
expect(pending_count).to eq(0)
end
- it "should ignore handled flags" do
+ it "ignores handled flags" do
post = create_post
reviewable = PostActionCreator.off_topic(user, post).reviewable
expect(post.hidden).to eq(false)
diff --git a/spec/models/reviewable_history_spec.rb b/spec/models/reviewable_history_spec.rb
index 3784dfb1923..6b3dc5b1d92 100644
--- a/spec/models/reviewable_history_spec.rb
+++ b/spec/models/reviewable_history_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe ReviewableHistory, type: :model do
expect(history[2].created_by).to eq(admin)
end
- it "won't log a transition to the same state" do
+ it "does not log a transition to the current state" do
p0 = Fabricate(:post)
reviewable = PostActionCreator.spam(Fabricate(:user, refresh_auto_groups: true), p0).reviewable
expect(reviewable.reviewable_histories.size).to eq(1)
diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb
index 0b6dfcbe557..7134c50af4f 100644
--- a/spec/models/reviewable_queued_post_spec.rb
+++ b/spec/models/reviewable_queued_post_spec.rb
@@ -231,7 +231,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
context "when the topic is nil in the case of a new topic being created" do
let(:reviewable) { Fabricate(:reviewable_queued_post_topic) }
- it "works" do
+ it "sends revision feedback for the rejected new topic" do
args = { revise_reason: "Duplicate", revise_feedback: "This is old news" }
expect { reviewable.perform(moderator, :revise_and_reject_post, args) }.to change {
Topic.where(archetype: Archetype.private_message).count
diff --git a/spec/models/reviewable_score_spec.rb b/spec/models/reviewable_score_spec.rb
index 28e97b05c1c..be5c994aaf0 100644
--- a/spec/models/reviewable_score_spec.rb
+++ b/spec/models/reviewable_score_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe ReviewableScore, type: :model do
fab!(:user)
let(:user_stat) { user.user_stat }
- it "returns 0 for a user with no flags" do
+ it "returns zero when there are no reviewed flags" do
expect(ReviewableScore.user_accuracy_bonus(user)).to eq(0.0)
end
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index 615a4948823..003846e2bef 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Reviewable, type: :model do
fab!(:admin)
fab!(:user)
- it "will return a new reviewable the first them, and re-use the second time" do
+ it "creates a reviewable on the first call and reuses it on the second" do
r0 = ReviewableUser.needs_review!(target: user, created_by: admin)
expect(r0).to be_present
@@ -53,14 +53,14 @@ RSpec.describe Reviewable, type: :model do
expect(r1.pending?).to eq(true)
end
- it "will add a topic and category from a post" do
+ it "adds the topic and category from the post" do
post = Fabricate(:post)
reviewable = ReviewableFlaggedPost.needs_review!(target: post, created_by: Fabricate(:user))
expect(reviewable.topic).to eq(post.topic)
expect(reviewable.category).to eq(post.topic.category)
end
- it "will update the category if the topic category changes" do
+ it "updates the category when the topic's category changes" do
post = Fabricate(:post)
moderator = Fabricate(:moderator, refresh_auto_groups: true)
reviewable = PostActionCreator.spam(moderator, post).reviewable
@@ -96,7 +96,7 @@ RSpec.describe Reviewable, type: :model do
expect(r0.pending?).to eq(false)
end
- it "will create a new reviewable when an existing reviewable exists the same target with different type" do
+ it "creates a new reviewable when the target has a reviewable of another type" do
r0 = Fabricate(:reviewable_queued_post)
r0.perform(admin, :approve_post)
@@ -104,7 +104,7 @@ RSpec.describe Reviewable, type: :model do
expect(r1.pending?).to eq(true)
end
- it "will not resurrect an approved queued reviewable when reusing a flagged reviewable for the same target" do
+ it "preserves an approved queued reviewable when reusing the target's flagged reviewable" do
r0 = Fabricate(:reviewable_queued_post)
r0.perform(admin, :approve_post)
expect(r0.reload.status).to eq("approved")
@@ -681,7 +681,7 @@ RSpec.describe Reviewable, type: :model do
end
describe ".score_required_to_hide_post" do
- it "will return the default visibility if it's higher" do
+ it "returns the default visibility when it is higher" do
described_class.set_priorities(low: 40.0, high: 100.0)
SiteSetting.hide_post_sensitivity = described_class.sensitivities[:high]
expect(described_class.score_required_to_hide_post).to eq(40.0)
@@ -799,7 +799,7 @@ RSpec.describe Reviewable, type: :model do
expect(Reviewable.min_score_for_priority(:high)).to eq(123.45)
end
- it "will return the default priority if none supplied" do
+ it "returns the default priority when none is supplied" do
Reviewable.set_priorities(medium: 12.3, high: 45.6)
expect(Reviewable.min_score_for_priority).to eq(0.0)
SiteSetting.reviewable_default_visibility = "medium"
@@ -893,7 +893,7 @@ RSpec.describe Reviewable, type: :model do
end
context "when listing for a moderator with a custom filter that joins tables with same named columns" do
- it "should not error" do
+ it "handles joins with matching column names without error" do
first_reviewable = Fabricate(:reviewable)
second_reviewable = Fabricate(:reviewable)
custom_filter = [
diff --git a/spec/models/reviewable_user_spec.rb b/spec/models/reviewable_user_spec.rb
index cdb0e86caac..6f8ac09034e 100644
--- a/spec/models/reviewable_user_spec.rb
+++ b/spec/models/reviewable_user_spec.rb
@@ -230,7 +230,7 @@ RSpec.describe ReviewableUser, type: :model do
end
context "when a user is deleted" do
- it "should reject the reviewable" do
+ it "rejects the reviewable" do
SiteSetting.must_approve_users = true
Jobs::CreateUserReviewable.new.execute(user_id: user.id)
reviewable = Reviewable.find_by(target: user)
@@ -459,7 +459,7 @@ RSpec.describe ReviewableUser, type: :model do
end
describe "changing must_approve_users" do
- it "will approve any existing users" do
+ it "approves existing users" do
user = Fabricate(:user)
expect(user).not_to be_approved
SiteSetting.must_approve_users = true
diff --git a/spec/models/screened_ip_address_spec.rb b/spec/models/screened_ip_address_spec.rb
index 0dae714f128..4e66246b5b2 100644
--- a/spec/models/screened_ip_address_spec.rb
+++ b/spec/models/screened_ip_address_spec.rb
@@ -116,7 +116,7 @@ RSpec.describe ScreenedIpAddress do
describe "#watch" do
context "when ip_address is not being watched" do
- it "should create a new record" do
+ it "creates a new record" do
record = described_class.watch(ip_address)
expect(record).not_to be_new_record
expect(record.action_type).to eq(described_class.actions[:block])
@@ -142,7 +142,7 @@ RSpec.describe ScreenedIpAddress do
context "when ip_address is already being watched" do
shared_examples "exact match of ip address" do
- it "should not create a new record" do
+ it "does not create a new record" do
expect { described_class.watch(ip_address_arg) }.to_not change { described_class.count }
end
diff --git a/spec/models/search_log_spec.rb b/spec/models/search_log_spec.rb
index 35d965333af..939edc7f1ae 100644
--- a/spec/models/search_log_spec.rb
+++ b/spec/models/search_log_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe SearchLog, type: :model do
end
end
- describe ".log" do
+ describe ".log crawler detection" do
it "flags an anonymous search from a known crawler user agent" do
_status, id =
SearchLog.log(
@@ -364,7 +364,7 @@ RSpec.describe SearchLog, type: :model do
end
describe ".term_details" do
- it "should only use the date for the period" do
+ it "uses only the date for the period" do
time = Time.utc(2019, 5, 23, 18, 15, 30)
freeze_time(time)
@@ -511,7 +511,7 @@ RSpec.describe SearchLog, type: :model do
end
describe "clean_up" do
- it "will remove old logs" do
+ it "removes old logs" do
SearchLog.log(term: "jawa", search_type: :header, ip_address: "127.0.0.1")
SearchLog.log(term: "jedi", search_type: :header, ip_address: "127.0.0.1")
SearchLog.log(term: "rey", search_type: :header, ip_address: "127.0.0.1")
diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rb
index fbafd07bf5e..e66a20633b4 100644
--- a/spec/models/site_setting_spec.rb
+++ b/spec/models/site_setting_spec.rb
@@ -247,7 +247,7 @@ RSpec.describe SiteSetting do
end
describe "cached settings" do
- it "should recalculate cached setting when dependent settings are changed" do
+ it "recalculates a cached setting when its dependencies change" do
SiteSetting.blocked_attachment_filenames = "foo"
expect(SiteSetting.blocked_attachment_filenames_regex).to eq(/foo/)
diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb
index a4a81576f4b..1bc6302d143 100644
--- a/spec/models/site_spec.rb
+++ b/spec/models/site_spec.rb
@@ -122,7 +122,7 @@ RSpec.describe Site do
expect(Site.new(guardian).categories).not_to include(sub_category)
end
- it "should clear the cache when custom fields are updated" do
+ it "clears the cache when custom fields change" do
Site.preloaded_category_custom_fields << "enable_marketplace"
categories = Site.new(Guardian.new).categories
diff --git a/spec/models/skipped_email_log_spec.rb b/spec/models/skipped_email_log_spec.rb
index a6fe6b55d59..5c9b692db3f 100644
--- a/spec/models/skipped_email_log_spec.rb
+++ b/spec/models/skipped_email_log_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe SkippedEmailLog, type: :model do
describe "#reason_type" do
describe "when reason_type is not valid" do
- it "should not be valid" do
+ it "is invalid" do
skipped_email_log.reason_type = 999_999
expect(skipped_email_log.valid?).to eq(false)
@@ -26,7 +26,7 @@ RSpec.describe SkippedEmailLog, type: :model do
describe "#custom_reason" do
describe "when log is a custom reason type" do
describe "when custom reason is blank" do
- it "should not be valid" do
+ it "is invalid" do
expect(custom_skipped_email_log.valid?).to eq(false)
expect(custom_skipped_email_log.errors.messages).to include(:custom_reason)
@@ -34,7 +34,7 @@ RSpec.describe SkippedEmailLog, type: :model do
end
describe "when custom reason is not blank" do
- it "should be valid" do
+ it "is valid" do
custom_skipped_email_log.custom_reason = "test"
expect(custom_skipped_email_log.valid?).to eq(true)
@@ -44,13 +44,13 @@ RSpec.describe SkippedEmailLog, type: :model do
describe "when log is not a custom reason type" do
describe "when custom reason is blank" do
- it "should be valid" do
+ it "is valid" do
expect(skipped_email_log.valid?).to eq(true)
end
end
describe "when custom reason is not blank" do
- it "should not be valid" do
+ it "is invalid" do
skipped_email_log.custom_reason = "test"
expect(skipped_email_log.valid?).to eq(false)
@@ -63,7 +63,7 @@ RSpec.describe SkippedEmailLog, type: :model do
describe ".reason_types" do
describe "verify enum sequence" do
- it "should return the right sequence" do
+ it "returns the next sequence number" do
expect(SkippedEmailLog.reason_types[:custom]).to eq(1)
expect(SkippedEmailLog.reason_types[:user_email_already_read]).to eq(15)
end
@@ -72,14 +72,14 @@ RSpec.describe SkippedEmailLog, type: :model do
describe "#reason" do
describe "for a custom log" do
- it "should return the right output" do
+ it "returns the serialized log entries" do
custom_skipped_email_log.custom_reason = "test"
expect(custom_skipped_email_log.reason).to eq("test")
end
end
describe "for a non custom log" do
- it "should return the right output" do
+ it "returns an empty collection when no entries exist" do
expect(skipped_email_log.reason).to eq(
"
#{I18n.t("skipped_email_log.exceeded_emails_limit")}
diff --git a/spec/models/stylesheet_cache_spec.rb b/spec/models/stylesheet_cache_spec.rb
index 01046d2f5a9..05c5d10e14c 100644
--- a/spec/models/stylesheet_cache_spec.rb
+++ b/spec/models/stylesheet_cache_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe StylesheetCache do
expect(StylesheetCache.first.content).to eq "c"
end
- it "it retains stylesheets for competing targets" do
+ it "retains stylesheets for competing targets" do
StylesheetCache.destroy_all
StylesheetCache.add("desktop", SecureRandom.hex, "body { }", "map", max_to_keep: 2)
diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb
index 774d1174480..6f354ff8f00 100644
--- a/spec/models/tag_spec.rb
+++ b/spec/models/tag_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Tag do
end
describe "Associations" do
- it "should delete associated sidebar_section_links when tag is destroyed" do
+ it "deletes associated sidebar_section_links when the tag is destroyed" do
tag_sidebar_section_link = Fabricate(:tag_sidebar_section_link)
tag_sidebar_section_link_2 =
Fabricate(:tag_sidebar_section_link, linkable: tag_sidebar_section_link.linkable)
@@ -362,7 +362,7 @@ RSpec.describe Tag do
end
describe ".ensure_consistency!" do
- it "should exclude private message topics" do
+ it "excludes private-message topics" do
topic
Fabricate(:private_message_topic, tags: [tag])
Tag.ensure_consistency!
@@ -371,7 +371,7 @@ RSpec.describe Tag do
expect(tag.public_topic_count).to eq(1)
end
- it "should update Tag#topic_count and Tag#public_topic_count correctly" do
+ it "updates Tag#topic_count and Tag#public_topic_count correctly" do
tag = Fabricate(:tag, name: "tag1")
tag2 = Fabricate(:tag, name: "tag2")
tag3 = Fabricate(:tag, name: "tag3")
diff --git a/spec/models/theme_setting_spec.rb b/spec/models/theme_setting_spec.rb
index 2f369a9f7f2..2506d48f50a 100644
--- a/spec/models/theme_setting_spec.rb
+++ b/spec/models/theme_setting_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe ThemeSetting do
end
context "for validations" do
- it "should be invalid when json_value size is greater than the maximum allowed size" do
+ it "rejects json_value exceeding the maximum size" do
json_value = { "key" => "value" }
bytesize = json_value.to_json.bytesize
diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb
index b9963804d32..052e6437b57 100644
--- a/spec/models/theme_spec.rb
+++ b/spec/models/theme_spec.rb
@@ -119,14 +119,14 @@ RSpec.describe Theme do
)
end
- it "should correct bad html in body_tag_baked and head_tag_baked" do
+ it "corrects malformed HTML in body_tag_baked and head_tag_baked" do
theme.set_field(target: :common, name: "head_tag", value: "<b>I am bold")
theme.save!
expect(Theme.lookup_field(theme.id, :desktop, "head_tag")).to eq("<b>I am bold</b>")
end
- it "should create body_tag_baked on demand if needed" do
+ it "creates body_tag_baked on demand" do
theme.set_field(target: :common, name: :body_tag, value: "<b>test")
theme.save
diff --git a/spec/models/top_topic_spec.rb b/spec/models/top_topic_spec.rb
index b91d4520e20..73fa458aaf2 100644
--- a/spec/models/top_topic_spec.rb
+++ b/spec/models/top_topic_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe TopTopic do
context "after calculating" do
before { TopTopic.refresh! }
- it "should have top topics" do
+ it "returns the top topics" do
expect(TopTopic.pluck(:topic_id)).to match_array([t1.id, t2.id])
end
end
@@ -80,7 +80,7 @@ RSpec.describe TopTopic do
# Note: all topics has 10 posts so we can skip "0 - ((10 - topics.posts_count) / 20) * #{period}_op_likes_count" calculation
- it "should compute top score" do
+ it "computes the top score" do
# Default Formula: log(views_count) * {2} + op_likes_count * {0.5} + LEAST(likes_count / posts_count, {3}) + 10 + log(posts_count)
#
# topic_1 => 0 + 14 + 3 + 10 + 0 => 27
diff --git a/spec/models/topic_converter_spec.rb b/spec/models/topic_converter_spec.rb
index 660613b6749..d29d66a8cdc 100644
--- a/spec/models/topic_converter_spec.rb
+++ b/spec/models/topic_converter_spec.rb
@@ -96,7 +96,7 @@ RSpec.describe TopicConverter do
category.update!(read_restricted: false)
end
- it "should convert private message into the right category" do
+ it "moves the private message into the destination category" do
topic = TopicConverter.new(first_post.topic, admin).convert_to_public_topic
topic.reload
@@ -116,7 +116,7 @@ RSpec.describe TopicConverter do
end
context "when a custom category_id is given" do
- it "should convert private message into the right category" do
+ it "moves the private message into the destination category" do
topic = TopicConverter.new(first_post.topic, admin).convert_to_public_topic(category.id)
expect(topic.reload.category).to eq(category)
@@ -386,7 +386,7 @@ RSpec.describe TopicConverter do
context "when user already exists in topic_allowed_users table" do
before { topic.topic_allowed_users.create!(user_id: admin.id) }
- it "works" do
+ it "converts the topic to a public topic" do
topic.convert_to_private_message(admin)
expect(topic.reload.archetype).to eq("private_message")
diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb
index 42ee9d76652..d86562da841 100644
--- a/spec/models/topic_embed_spec.rb
+++ b/spec/models/topic_embed_spec.rb
@@ -160,13 +160,13 @@ RSpec.describe TopicEmbed do
expect(post.reload.cook_method).to eq(Post.cook_methods[:regular])
end
- it "Should leave uppercase Feed Entry URL untouched in content" do
+ it "leaves an uppercase feed entry URL untouched in content" do
cased_url = "http://eviltrout.com/ABCD"
post = TopicEmbed.import(user, cased_url, title, "some random content")
expect(post.cooked).to match(/#{cased_url}/)
end
- it "Should leave lowercase Feed Entry URL untouched in content" do
+ it "leaves a lowercase feed entry URL untouched in content" do
cased_url = "http://eviltrout.com/abcd"
post = TopicEmbed.import(user, cased_url, title, "some random content")
expect(post.cooked).to match(/#{cased_url}/)
@@ -331,7 +331,7 @@ RSpec.describe TopicEmbed do
expect(imported_post.topic.title).to eq("MODIFIED: #{title}")
end
- it "will revert to defaults if the modifier returns nil" do
+ it "reverts to defaults when the modifier returns nil" do
plugin = Plugin::Instance.new
plugin.register_modifier(:topic_embed_import_create_args) { |args| nil }
diff --git a/spec/models/topic_group_spec.rb b/spec/models/topic_group_spec.rb
index 68c3e52e019..03c133e25e8 100644
--- a/spec/models/topic_group_spec.rb
+++ b/spec/models/topic_group_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe TopicGroup do
expect(created_topic_group2.last_read_post_number).to eq topic2.highest_post_number
end
- it "will not raise an error if a topic group already exists" do
+ it "does not raise an error when a topic group already exists" do
TopicGroup.create_topic_group(user, topic.id, 3, [])
expect(TopicGroup.find_by(group: group, topic:).last_read_post_number).to eq(3)
TopicGroup.create_topic_group(user, topic.id, 10, [])
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index 8d6ae783ff6..fe0f0cd0535 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -129,7 +129,7 @@ RSpec.describe TopicLink do
let(:post) { Fabricate(:post, topic: other_topic, user: user, raw: "some content") }
- it "works" do
+ it "preserves internal topic links and reflections across repeated extraction" do
# ensure other_topic has a post
post
@@ -413,7 +413,7 @@ RSpec.describe TopicLink do
end
describe "internal link from pm" do
- it "works" do
+ it "records the PM's outgoing link without adding a public backlink" do
pm = Fabricate(:topic, user: user, category_id: nil, archetype: "private_message")
Fabricate(:post, topic: pm, user: user, raw: "some content")
@@ -430,7 +430,7 @@ RSpec.describe TopicLink do
end
describe "internal link from unlisted topic" do
- it "works" do
+ it "records the unlisted topic's outgoing link without adding a public backlink" do
unlisted_topic = Fabricate(:topic, user: user, visible: false)
url = "http://#{test_uri.host}/t/topic-slug/#{topic.id}"
@@ -582,7 +582,7 @@ RSpec.describe TopicLink do
expect(array[1].clicks).to eq(1)
end
- it "secures internal links correctly" do
+ it "hides restricted internal links from users without category access" do
category = Fabricate(:category)
secret_topic = Fabricate(:topic, category: category)
@@ -614,7 +614,7 @@ RSpec.describe TopicLink do
expect(TopicLink.topic_map(Guardian.new, post.topic_id).count).to eq(0)
end
- it "secures internal links correctly" do
+ it "excludes links to topics muted by the user" do
other_topic = Fabricate(:topic)
other_user = Fabricate(:user)
@@ -642,7 +642,7 @@ RSpec.describe TopicLink do
Fabricate(:post, user: user, raw: "Check out this topic #{post.topic.url}/122131")
end
- it "should return the right response" do
+ it "returns metadata for the duplicate internal link" do
TopicLink.extract_from(post_with_internal_link)
result = TopicLink.duplicate_lookup(post_with_internal_link.topic)
diff --git a/spec/models/topic_list_spec.rb b/spec/models/topic_list_spec.rb
index f7f533c2fde..5092b7a01c4 100644
--- a/spec/models/topic_list_spec.rb
+++ b/spec/models/topic_list_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe TopicList do
after { TopicList.preloaded_custom_fields.clear }
describe ".preloaded_custom_fields" do
- it "should return a unique set of values" do
+ it "returns unique values" do
TopicList.preloaded_custom_fields << "test"
TopicList.preloaded_custom_fields << "test"
TopicList.preloaded_custom_fields << "apple"
@@ -69,7 +69,7 @@ RSpec.describe TopicList do
end
describe "#top_tags" do
- it "should return the right tags" do
+ it "returns the topic tags" do
tag = Fabricate(:tag, topics: [topic])
other_tag = Fabricate(:tag, topics: [topic], name: "use-anywhere")
expect(topic_list.top_tags).to eq(
@@ -96,7 +96,7 @@ RSpec.describe TopicList do
)
end
- it "should return tags used in the category" do
+ it "returns tags used in the category" do
expect(topic_list.top_tags).to eq(
[
{ id: tag.id, name: tag.name, slug: tag.slug },
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb
index c853ef70bd9..875fa8935cd 100644
--- a/spec/models/topic_spec.rb
+++ b/spec/models/topic_spec.rb
@@ -21,14 +21,14 @@ RSpec.describe Topic do
describe "#featured_link" do
describe "when featured_link contains more than a URL" do
- it "should not be valid" do
+ it "rejects an invalid featured link" do
topic.featured_link = "http://meta.discourse.org TEST"
expect(topic).to_not be_valid
end
end
describe "when featured_link is a valid URL" do
- it "should be valid" do
+ it "accepts a valid featured link" do
topic.featured_link = "http://meta.discourse.org"
expect(topic).to be_valid
end
@@ -37,28 +37,28 @@ RSpec.describe Topic do
describe "#external_id" do
describe "when external_id is too long" do
- it "should not be valid" do
+ it "rejects an external ID exceeding the length limit" do
topic.external_id = "a" * (Topic::EXTERNAL_ID_MAX_LENGTH + 1)
expect(topic).to_not be_valid
end
end
describe "when external_id has invalid characters" do
- it "should not be valid" do
+ it "rejects unsupported characters in the external ID" do
topic.external_id = "a*&^!@()#"
expect(topic).to_not be_valid
end
end
describe "when external_id is an empty string" do
- it "should not be valid" do
+ it "rejects an empty external ID" do
topic.external_id = ""
expect(topic).to_not be_valid
end
end
describe "when external_id has already been used" do
- it "should not be valid" do
+ it "rejects a duplicate external ID" do
topic2 = Fabricate(:topic, external_id: "asdf")
topic.external_id = "asdf"
expect(topic).to_not be_valid
@@ -66,14 +66,14 @@ RSpec.describe Topic do
end
describe "when external_id is nil" do
- it "should be valid" do
+ it "accepts a nil external ID" do
topic.external_id = nil
expect(topic).to be_valid
end
end
describe "when external_id is valid" do
- it "should be valid" do
+ it "accepts alphanumeric external IDs with underscores and hyphens" do
topic.external_id = "abc_123-ZXY"
expect(topic).to be_valid
end
@@ -89,7 +89,7 @@ RSpec.describe Topic do
describe "when title contains censored words" do
after { WordWatcher.clear_cache! }
- it "should not be valid" do
+ it "rejects titles containing censored words" do
%w[pineapple pen].each do |w|
Fabricate(:watched_word, word: w, action: WatchedWord.actions[:censor])
end
@@ -105,7 +105,7 @@ RSpec.describe Topic do
end
describe "titles with censored words not on boundaries" do
- it "should be valid" do
+ it "accepts titles with censored words embedded in other words" do
Fabricate(:watched_word, word: "apple", action: WatchedWord.actions[:censor])
topic.title = "Pineapples are great fruit! Applebee's is a great restaurant"
expect(topic).to be_valid
@@ -113,7 +113,7 @@ RSpec.describe Topic do
end
describe "when title does not contain censored words" do
- it "should be valid" do
+ it "accepts titles without censored words" do
topic.title = "The cake is a lie"
expect(topic).to be_valid
@@ -127,7 +127,7 @@ RSpec.describe Topic do
end
end
- it "should not be valid" do
+ it "rejects titles matching censored word patterns" do
topic.title = "I have a co(onut a**le"
expect(topic.valid?).to eq(false)
@@ -143,7 +143,7 @@ RSpec.describe Topic do
describe "when title contains watched words" do
after { WordWatcher.clear_cache! }
- it "should not be valid" do
+ it "rejects titles containing blocked words" do
Fabricate(:watched_word, word: "pineapple", action: WatchedWord.actions[:block])
topic.title = "pen PinEapple apple pen is a complete sentence"
@@ -411,15 +411,15 @@ RSpec.describe Topic do
before { SiteSetting.duplicate_topic_titles = "disallowed" }
- it "won't allow another topic to be created with the same name" do
+ it "rejects another topic with the same title" do
expect(new_topic).not_to be_valid
end
- it "won't even allow another topic to be created with the same name but different category" do
+ it "rejects the same title in another category" do
expect(new_topic_different_cat).not_to be_valid
end
- it "won't allow another topic with an upper case title to be created" do
+ it "rejects duplicate titles regardless of case" do
new_topic.title = new_topic.title.upcase
expect(new_topic).not_to be_valid
end
@@ -451,7 +451,7 @@ RSpec.describe Topic do
expect(attempt).to be_valid
end
- it "won't allow the title when the author is a member of the restricted group" do
+ it "rejects the title when the author belongs to the restricted group" do
group_member = Fabricate(:user)
group.add(group_member)
attempt =
@@ -464,19 +464,19 @@ RSpec.describe Topic do
expect(attempt).not_to be_valid
end
- it "won't allow the title when the author is an admin" do
+ it "rejects the title when the author is an admin" do
attempt =
Fabricate.build(:topic, title: secure_topic.title, category: category1, user: admin)
expect(attempt).not_to be_valid
end
- it "won't allow a topic to be moved into the restricted category holding the duplicate" do
+ it "rejects moving the topic into the restricted category containing the duplicate" do
public_topic = Fabricate(:topic, title: secure_topic.title, category: category1)
public_topic.category_id = secure_category.id
expect(public_topic).not_to be_valid
end
- it "won't allow the title when the acting user can see the duplicate but the author can't" do
+ it "rejects the title when only the acting user can see the duplicate" do
topic.acting_user = admin
topic.title = secure_topic.title
expect(topic).not_to be_valid
@@ -498,13 +498,13 @@ RSpec.describe Topic do
expect(attempt).to be_valid
end
- it "won't allow the title when the author can see unlisted topics" do
+ it "rejects the title when the author can see unlisted topics" do
attempt =
Fabricate.build(:topic, title: unlisted_topic.title, category: category1, user: admin)
expect(attempt).not_to be_valid
end
- it "won't allow the title in the same category even when the author can't see unlisted topics" do
+ it "rejects the title in the same category even when the author cannot see unlisted topics" do
attempt = Fabricate.build(:topic, title: unlisted_topic.title, category: category2)
expect(attempt).not_to be_valid
end
@@ -514,7 +514,7 @@ RSpec.describe Topic do
context "when duplicate_topic_titles is allowed" do
before { SiteSetting.duplicate_topic_titles = "allowed" }
- it "will allow another topic to be created with the same name" do
+ it "allows another topic with the same title" do
expect(new_topic).to be_valid
end
end
@@ -522,11 +522,11 @@ RSpec.describe Topic do
context "when duplicate_topic_titles is allowed_across_categories" do
before { SiteSetting.duplicate_topic_titles = "allowed_across_categories" }
- it "will allow another topic to be created with the same name but different category" do
+ it "allows the same title in another category" do
expect(new_topic_different_cat).to be_valid
end
- it "won't allow another topic to be created with the same name in same category" do
+ it "rejects the same title in the same category" do
expect(new_topic).not_to be_valid
end
end
@@ -670,7 +670,7 @@ RSpec.describe Topic do
after { Discourse.disable_readonly_mode }
- it "should not attempt to update `fancy_title`" do
+ it "does not attempt to update fancy_title" do
topic.save!
expect(topic.fancy_title).to eq(
"&ldquo;this topic&rdquo; &ndash; has &ldquo;fancy stuff&rdquo;",
@@ -916,7 +916,7 @@ RSpec.describe Topic do
).to be_blank
end
- it "should return the cat since the user can see it" do
+ it "returns the category visible to the user" do
group.add(user)
expect(
@@ -1026,7 +1026,7 @@ RSpec.describe Topic do
end
describe "when username_or_email is not valid" do
- it "should return the right value" do
+ it "returns nil without adding an allowed user" do
expect do expect(topic.invite(user, "somerandomstring")).to eq(nil) end.to_not change {
topic.allowed_users
}
@@ -1034,7 +1034,7 @@ RSpec.describe Topic do
end
describe "when user is already allowed" do
- it "should raise the right error" do
+ it "raises UserExists when the user is already allowed" do
topic.allowed_users << user1
expect { topic.invite(user, user1.username) }.to raise_error(Topic::UserExists)
@@ -1046,7 +1046,7 @@ RSpec.describe Topic do
fab!(:topic) { Fabricate(:private_message_topic, user: trust_level_2) }
describe "by username" do
- it "should be able to invite a user" do
+ it "invites a user to the PM" do
expect(topic.invite(user, user1.username)).to eq(true)
expect(topic.allowed_users).to include(user1)
expect(Post.last.action_code).to eq("invited_user")
@@ -1062,7 +1062,7 @@ RSpec.describe Topic do
expect(Post.last.action_code).to eq("removed_user")
end
- it "should not create a small action if user is already invited through a group" do
+ it "omits a small action when the user already has access through a group" do
group = Fabricate(:group, users: [user, user1])
expect(topic.invite_group(user, group)).to eq(true)
@@ -1104,7 +1104,7 @@ RSpec.describe Topic do
SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:trust_level_4]
end
- it "should raise error" do
+ it "raises UserExists when PM access is restricted" do
expect { topic.invite(user, user1.username) }.to raise_error(Topic::UserExists)
end
end
@@ -1128,19 +1128,19 @@ RSpec.describe Topic do
expect(topic.invite(user, user1.username)).to eq(true)
end
- it "should raise error when inviter not in allowed list" do
+ it "rejects an inviter outside the recipient's allowed list" do
AllowedPmUser.create!(user: user1, allowed_pm_user: user2)
expect { topic.invite(user, user1.username) }.to raise_error(
Topic::NotAllowed,
).with_message(I18n.t("topic_invite.receiver_does_not_allow_pm"))
end
- it "should succeed for staff even when not allowed" do
+ it "allows inviting staff outside the allowed list" do
AllowedPmUser.create!(user: user1, allowed_pm_user: user2)
expect(topic.invite(user1, admin.username)).to eq(true)
end
- it "should raise error when target_user is not in inviters allowed list" do
+ it "rejects a recipient outside the inviter's allowed list" do
user.user_option.update!(enable_allowed_pm_users: true)
AllowedPmUser.create!(user: user1, allowed_pm_user: user)
expect { topic.invite(user, user1.username) }.to raise_error(
@@ -1156,7 +1156,7 @@ RSpec.describe Topic do
end
describe "by email" do
- it "should be able to invite a user" do
+ it "invites an existing user by email" do
expect(topic.invite(user, user1.email)).to eq(true)
expect(topic.allowed_users).to include(user1)
@@ -1166,7 +1166,7 @@ RSpec.describe Topic do
end
describe "when user is not found" do
- it "should create the right invite" do
+ it "creates an email invitation" do
expect(topic.invite(user, "[email protected]")).to eq(true)
invite = Invite.last
@@ -1178,7 +1178,7 @@ RSpec.describe Topic do
describe "when user does not have sufficient trust level" do
before { user.change_trust_level!(TrustLevel[1]) }
- it "should not create an invite" do
+ it "does not create an invitation" do
expect do expect(topic.invite(user, "[email protected]")).to eq(nil) end.to_not change {
Invite.count
}
@@ -1204,14 +1204,14 @@ RSpec.describe Topic do
end
describe "by username" do
- it "should invite user into a topic" do
+ it "invites and notifies the user by username" do
topic.invite(user, user1.username)
expect_the_right_notification_to_be_created(user, user1)
end
end
describe "by email" do
- it "should be able to invite a user" do
+ it "invites and notifies the user by email" do
expect(topic.invite(user, user1.email)).to eq(true)
expect_the_right_notification_to_be_created(user, user1)
end
@@ -1229,7 +1229,7 @@ RSpec.describe Topic do
fab!(:invitee, :user)
describe "as a group owner" do
- it "should be able to invite a user" do
+ it "invites the user with group membership" do
expect do
expect(topic.invite(inviter, invitee.email, [group.id])).to eq(true)
end.to change { Notification.count } & change { GroupHistory.count }
@@ -1245,7 +1245,7 @@ RSpec.describe Topic do
end
describe "when group ids are not given" do
- it "should not invite the user" do
+ it "does not invite the user" do
expect do
expect(topic.invite(inviter, invitee.email)).to eq(false)
end.to_not change { Notification.count }
@@ -1254,7 +1254,7 @@ RSpec.describe Topic do
end
describe "as a normal user" do
- it "should not be able to invite a user" do
+ it "rejects the invitation from an unauthorized user" do
expect do
expect(topic.invite(Fabricate(:user), invitee.email, [group.id])).to eq(false)
end.to_not change { Notification.count }
@@ -1282,7 +1282,7 @@ RSpec.describe Topic do
describe "when user can invite via email" do
before { user.change_trust_level!(TrustLevel[2]) }
- it "should create an invite" do
+ it "creates an email invitation" do
Jobs.run_immediately!
expect(topic.invite(user, "[email protected]")).to eq(true)
@@ -1312,7 +1312,7 @@ RSpec.describe Topic do
.topic
end
- it "should integrate correctly" do
+ it "limits PM visibility to its participants" do
expect(Guardian.new(topic.user).can_see?(topic)).to eq(true)
expect(Guardian.new.can_see?(topic)).to eq(false)
expect(Guardian.new(evil_trout).can_see?(topic)).to eq(false)
@@ -1464,7 +1464,7 @@ RSpec.describe Topic do
end
context "with user actions" do
- it "should set up actions correctly" do
+ it "records sent and received private message actions" do
UserActionManager.enable
post = create_post(archetype: "private_message", target_usernames: [user.username])
@@ -1553,7 +1553,7 @@ RSpec.describe Topic do
context "when moderator post fails to be created" do
before { user.update_column(:silenced_till, 1.year.from_now) }
- it "should not increment moderator_posts_count" do
+ it "does not increment moderator_posts_count" do
expect(topic.moderator_posts_count).to eq(0)
topic.add_moderator_post(user, "winter is never coming")
@@ -1576,7 +1576,7 @@ RSpec.describe Topic do
let(:category) { Fabricate(:category_with_definition) }
context "when disabled" do
- it "should not be visible and have correct counts" do
+ it "unlists the topic and updates its counts" do
topic.update_status("visible", false, user)
topic.reload
expect(topic).not_to be_visible
@@ -1614,7 +1614,7 @@ RSpec.describe Topic do
topic.reload
end
- it "should be visible with correct counts" do
+ it "lists the topic and updates its counts" do
topic.update_status("visible", true, user)
expect(topic).to be_visible
@@ -1659,7 +1659,7 @@ RSpec.describe Topic do
topic.reload
end
- it "should enable correctly" do
+ it "pins the topic without changing bumped_at" do
expect(topic.pinned_at).to be_present
expect(topic.bumped_at).to eq_time(original_bumped_at)
expect(topic.moderator_posts_count).to eq(1)
@@ -1668,7 +1668,7 @@ RSpec.describe Topic do
end
context "with archived" do
- it "should create a staff action log entry" do
+ it "logs the topic archive action" do
expect { topic.update_status("archived", true, user) }.to change {
UserHistory.where(action: UserHistory.actions[:topic_archived]).count
}.by(1)
@@ -1683,7 +1683,7 @@ RSpec.describe Topic do
archived_topic.reload
end
- it "should archive correctly" do
+ it "unarchives the topic without changing bumped_at" do
expect(archived_topic).not_to be_archived
expect(archived_topic.bumped_at).to eq_time(original_bumped_at)
expect(archived_topic.moderator_posts_count).to eq(1)
@@ -1697,7 +1697,7 @@ RSpec.describe Topic do
topic.reload
end
- it "should be archived" do
+ it "archives the topic and records a moderator post" do
expect(topic).to be_archived
expect(topic.moderator_posts_count).to eq(1)
expect(topic.bumped_at).to eq_time(original_bumped_at)
@@ -1715,7 +1715,7 @@ RSpec.describe Topic do
closed_topic.reload
end
- it "should not be pinned" do
+ it "opens the topic and records a moderator post" do
expect(closed_topic).not_to be_closed
expect(closed_topic.moderator_posts_count).to eq(1)
expect(closed_topic.bumped_at).not_to eq_time(original_bumped_at)
@@ -1729,7 +1729,7 @@ RSpec.describe Topic do
topic.reload
end
- it "should be closed" do
+ it "closes the topic without changing bumped_at" do
expect(topic).to be_closed
expect(topic.bumped_at).to eq_time(original_bumped_at)
expect(topic.moderator_posts_count).to eq(1)
@@ -1743,7 +1743,7 @@ RSpec.describe Topic do
it_behaves_like "a status that closes a topic"
- it "should archive group message" do
+ it "archives the group message" do
group.add(user)
topic = Fabricate(:private_message_topic, allowed_groups: [group])
@@ -1753,7 +1753,7 @@ RSpec.describe Topic do
).by(1)
end
- it "should create a staff action log entry" do
+ it "logs the topic close action" do
expect { topic.update_status(status, true, user) }.to change {
UserHistory.where(action: UserHistory.actions[:topic_closed]).count
}.by(1)
@@ -1901,14 +1901,14 @@ RSpec.describe Topic do
describe "with category" do
fab!(:category, :category_with_definition)
- it "should not increase the topic_count with no category" do
+ it "does not increase a category's topic count for an uncategorized topic" do
expect {
Fabricate(:topic, user: category.user)
category.reload
}.not_to change(category, :topic_count)
end
- it "should increase the category's topic_count" do
+ it "increases the category's topic count" do
expect {
Fabricate(:topic, user: category.user, category_id: category.id)
category.reload
@@ -1951,7 +1951,7 @@ RSpec.describe Topic do
expect(category.topic_count).to eq(1)
end
- it "should not change the topic_count when not changed" do
+ it "preserves topic counts when the category is unchanged" do
expect {
topic.change_category_to_id(topic.category.id)
category.reload
@@ -2006,7 +2006,7 @@ RSpec.describe Topic do
Fabricate(:category_with_definition, user: user, name: "2nd category")
end
- it "should work" do
+ it "moves the topic and updates both category counts" do
topic.change_category_to_id(new_category.id)
expect(topic.reload.category).to eq(new_category)
@@ -2044,7 +2044,7 @@ RSpec.describe Topic do
)
end
- it "should generate the notification for the topic" do
+ it "generates the topic notification" do
expect do topic.change_category_to_id(new_category.id) end.to change {
Notification.count
}.by(2)
@@ -2068,7 +2068,7 @@ RSpec.describe Topic do
).to eq(true)
end
- it "should not generate a notification if SiteSetting.disable_category_edit_notifications is enabled" do
+ it "omits the notification when category edit notifications are disabled" do
SiteSetting.disable_category_edit_notifications = true
expect do topic.change_category_to_id(new_category.id) end.not_to change {
@@ -2078,7 +2078,7 @@ RSpec.describe Topic do
expect(topic.category_id).to eq(new_category.id)
end
- it "should not generate a notification if options: silent is true" do
+ it "omits the notification when silent is true" do
expect do topic.change_category_to_id(new_category.id, silent: true) end.not_to change {
Notification.count
}
@@ -2086,7 +2086,7 @@ RSpec.describe Topic do
expect(topic.category_id).to eq(new_category.id)
end
- it "should generate the modified notification for the topic if already seen" do
+ it "generates the modified notification when the topic was already seen" do
TopicUser.create!(
topic_id: topic.id,
last_read_post_number: topic.posts.first.post_number,
@@ -2116,7 +2116,7 @@ RSpec.describe Topic do
).to eq(true)
end
- it "should not generate a notification for unlisted topic" do
+ it "omits notifications for unlisted topics" do
topic.update_column(:visible, false)
expect do topic.change_category_to_id(new_category.id) end.not_to change {
@@ -2132,7 +2132,7 @@ RSpec.describe Topic do
topic.user.update!(admin: true)
end
- it "should set a topic timer" do
+ it "sets a topic timer" do
now = Time.zone.now
expect { topic.change_category_to_id(new_category.id) }.to change {
@@ -2151,7 +2151,7 @@ RSpec.describe Topic do
describe "when topic is already closed" do
before { topic.update_status("closed", true, Discourse.system_user) }
- it "should not set a topic timer" do
+ it "does not set a topic timer" do
expect { topic.change_category_to_id(new_category.id) }.not_to change {
TopicTimer.with_deleted.count
}
@@ -2164,7 +2164,7 @@ RSpec.describe Topic do
describe "when topic has an existing topic timer" do
let(:topic_timer) { Fabricate(:topic_timer, topic: topic) }
- it "should not inherit category's auto close hours" do
+ it "does not inherit the category's auto close hours" do
topic_timer
topic.change_category_to_id(new_category.id)
@@ -2463,7 +2463,7 @@ RSpec.describe Topic do
expect(closing_topic.reload.public_topic_timer.execute_at).to eq_time(2.days.from_now)
end
- it "should not delete topic_timer of another status_type" do
+ it "preserves topic timers with another status type" do
freeze_time
closing_topic.set_or_create_timer(TopicTimer.types[:open], nil)
topic_timer = closing_topic.public_topic_timer
@@ -2472,7 +2472,7 @@ RSpec.describe Topic do
expect(topic_timer.status_type).to eq(TopicTimer.types[:close])
end
- it "should allow status_type to be updated" do
+ it "allows updating the status type" do
freeze_time
topic_timer =
@@ -2509,7 +2509,7 @@ RSpec.describe Topic do
let(:category) { Fabricate(:category_with_definition, auto_close_hours: 4) }
let(:topic) { Fabricate(:topic, category: category) }
- it "should be able to override category's default auto close" do
+ it "overrides the category's default auto close" do
freeze_time
Jobs.run_immediately!
@@ -2754,7 +2754,7 @@ RSpec.describe Topic do
end
describe ".secured" do
- it "should return the right topics" do
+ it "returns only topics visible to the guardian" do
category = Fabricate(:category_with_definition, read_restricted: true)
topic = Fabricate(:topic, category: category, created_at: 1.day.ago)
group.add(user)
@@ -3186,14 +3186,14 @@ RSpec.describe Topic do
before { SiteSetting.minimum_topics_similar = 20 }
context "when Topic count is greater than minimum_topics_similar" do
- it "should be true" do
+ it "returns true when the topic count exceeds the minimum" do
Topic.stubs(:count).returns(30)
expect(Topic.count_exceeds_minimum?).to be_truthy
end
end
context "when topic's count is less than minimum_topics_similar" do
- it "should be false" do
+ it "returns false when the topic count is below the minimum" do
Topic.stubs(:count).returns(10)
expect(Topic.count_exceeds_minimum?).to_not be_truthy
end
@@ -3275,7 +3275,7 @@ RSpec.describe Topic do
expect(topic.message_archived?(user)).to eq(false)
end
- it "will trigger :topic_status_updated" do
+ it "triggers topic_status_updated" do
topic = Fabricate(:topic)
user = topic.user
user.admin = true
@@ -3382,18 +3382,18 @@ RSpec.describe Topic do
end
describe "#time_to_first_response" do
- it "should have no results if no topics in range" do
+ it "returns no results when no topics fall within the range" do
expect(Topic.time_to_first_response_per_day(5.days.ago, Time.zone.now).count).to eq(0)
end
- it "should have no results if there is only a topic with no replies" do
+ it "returns no results for topics without replies" do
topic = Fabricate(:topic, created_at: 1.hour.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1)
expect(Topic.time_to_first_response_per_day(5.days.ago, Time.zone.now).count).to eq(0)
expect(Topic.time_to_first_response_total).to eq(0)
end
- it "should have no results if reply is from first poster" do
+ it "ignores replies from the original poster" do
topic = Fabricate(:topic, created_at: 1.hour.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1)
Fabricate(:post, topic: topic, user: topic.user, post_number: 2)
@@ -3401,7 +3401,7 @@ RSpec.describe Topic do
expect(Topic.time_to_first_response_total).to eq(0)
end
- it "should have results if there's a topic with replies" do
+ it "measures the time to the first reply" do
topic = Fabricate(:topic, created_at: 3.hours.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1, created_at: 3.hours.ago)
Fabricate(:post, topic: topic, post_number: 2, created_at: 2.hours.ago)
@@ -3411,7 +3411,7 @@ RSpec.describe Topic do
expect(Topic.time_to_first_response_total).to eq(1)
end
- it "should have results if there's a topic with replies" do
+ it "includes replies in nested subcategories" do
SiteSetting.max_category_nesting = 3
category = Fabricate(:category_with_definition)
@@ -3427,7 +3427,7 @@ RSpec.describe Topic do
).to eq(1)
end
- it "should only count regular posts as the first response" do
+ it "counts only regular posts as the first response" do
topic = Fabricate(:topic, created_at: 5.hours.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1, created_at: 5.hours.ago)
Fabricate(
@@ -3548,13 +3548,13 @@ RSpec.describe Topic do
end
describe "when PM is between a human and a non human user" do
- it "should return true" do
+ it "recognizes a PM between a human and a bot" do
expect(topic.pm_with_non_human_user?).to be(true)
end
end
describe "when PM contains 2 human users and a non human user" do
- it "should return false" do
+ it "returns false when the PM contains multiple humans" do
Fabricate(:topic_allowed_user, topic: topic, user: Fabricate(:user))
expect(topic.pm_with_non_human_user?).to be(false)
@@ -3562,7 +3562,7 @@ RSpec.describe Topic do
end
describe "when PM only contains a user" do
- it "should return true" do
+ it "returns true when only one user remains" do
topic.topic_allowed_users.first.destroy!
expect(topic.reload.pm_with_non_human_user?).to be(true)
@@ -3570,7 +3570,7 @@ RSpec.describe Topic do
end
describe "when PM contains a group" do
- it "should return false" do
+ it "returns false when the PM includes a group" do
Fabricate(:topic_allowed_group, topic: topic)
expect(topic.pm_with_non_human_user?).to be(false)
@@ -3578,7 +3578,7 @@ RSpec.describe Topic do
end
describe "when topic is not a PM" do
- it "should return false" do
+ it "returns false for a public topic" do
topic.convert_to_public_topic(Fabricate(:admin))
expect(topic.pm_with_non_human_user?).to be(false)
@@ -3601,7 +3601,7 @@ RSpec.describe Topic do
end
describe "removing oneself" do
- it "should remove oneself" do
+ it "allows the user to remove themselves" do
topic.allowed_users << user1
expect(topic.remove_allowed_user(user1, user1)).to eq(true)
@@ -3614,7 +3614,7 @@ RSpec.describe Topic do
expect(post.action_code).to eq("user_left")
end
- it "should show a small action when user removes themselves from pm" do
+ it "records a small action when the user leaves the PM" do
expect do private_topic.remove_allowed_user(user1, user1) end.to change {
private_topic.posts.where(action_code: "user_left").count
}.by(1)
@@ -3721,7 +3721,7 @@ RSpec.describe Topic do
https://meta.discourse.org/?filter=test
https://meta.discourse.org/t/中國/1
].each do |featured_link|
- it "should extract the root domain from #{featured_link} correctly" do
+ it "extracts the root domain from #{featured_link}" do
topic.featured_link = featured_link
expect(topic.featured_link_root_domain).to eq("discourse.org")
end
@@ -4095,7 +4095,7 @@ RSpec.describe Topic do
fab!(:post2) { Fabricate(:post, topic: topic, user: user2) }
fab!(:like1) { Fabricate(:like, post: post1, user: user2) }
- it "it is triggered when a post publishes a message of type :liked or :unliked" do
+ it "is triggered when a post publishes a liked or unliked message" do
%i[liked unliked].each do |action|
messages =
MessageBus.track_publish("/topic/#{topic.id}") do
@@ -4108,7 +4108,7 @@ RSpec.describe Topic do
end
end
- it "it is triggered when a post publishes a message of type :created, :destroyed, :deleted, :recovered" do
+ it "is triggered when a post publishes a created, destroyed, deleted, or recovered message" do
freeze_time Date.today
%i[created destroyed deleted recovered].each do |action|
@@ -4127,7 +4127,7 @@ RSpec.describe Topic do
end
end
- it "it is not triggered when a post publishes an unhandled kind of message" do
+ it "is not triggered when a post publishes an unhandled message type" do
%i[unhandled unknown dont_care].each do |action|
messages =
MessageBus.track_publish("/topic/#{topic.id}") do
diff --git a/spec/models/topic_tag_spec.rb b/spec/models/topic_tag_spec.rb
index 803c839eae7..982ba9d8423 100644
--- a/spec/models/topic_tag_spec.rb
+++ b/spec/models/topic_tag_spec.rb
@@ -9,13 +9,13 @@ RSpec.describe TopicTag do
let(:topic_tag) { Fabricate(:topic_tag, topic: topic, tag: tag) }
describe "#after_create" do
- it "should increase Tag#staff_topic_count and Tag#public_topic_count for a regular topic in a public category" do
+ it "increases staff and public tag counts for a topic in a public category" do
expect { topic_tag }.to change { tag.reload.staff_topic_count }.by(1).and change {
tag.reload.public_topic_count
}.by(1)
end
- it "should only increase Tag#staff_topic_count for a regular topic in a read restricted category" do
+ it "increases only the staff tag count for a topic in a restricted category" do
expect { Fabricate(:topic_tag, topic: topic_in_private_category, tag: tag) }.to change {
tag.reload.staff_topic_count
}.by(1)
@@ -23,7 +23,7 @@ RSpec.describe TopicTag do
expect(tag.reload.public_topic_count).to eq(0)
end
- it "should increase Tag#pm_topic_count for a private message topic" do
+ it "increases the PM tag count for a private message" do
topic.archetype = Archetype.private_message
expect { topic_tag }.to change { tag.reload.pm_topic_count }.by(1)
@@ -31,7 +31,7 @@ RSpec.describe TopicTag do
end
describe "#after_destroy" do
- it "should decrease Tag#staff_topic_count and Tag#public_topic_count for a regular topic in a public category" do
+ it "decreases staff and public tag counts for a topic in a public category" do
topic_tag
expect { topic_tag.destroy! }.to change { tag.reload.staff_topic_count }.by(-1).and change {
@@ -39,14 +39,14 @@ RSpec.describe TopicTag do
}.by(-1)
end
- it "should only decrease Topic#topic_count for a regular topic in a read restricted category" do
+ it "decreases only the staff tag count for a topic in a restricted category" do
topic_tag = Fabricate(:topic_tag, topic: topic_in_private_category, tag: tag)
expect { topic_tag.destroy! }.to change { tag.reload.staff_topic_count }.by(-1)
expect(tag.reload.public_topic_count).to eq(0)
end
- it "should decrease Tag#pm_topic_count for a private message topic" do
+ it "decreases the PM tag count for a private message" do
topic.archetype = Archetype.private_message
topic_tag
diff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rb
index e67b28703e8..62bec827e86 100644
--- a/spec/models/topic_timer_spec.rb
+++ b/spec/models/topic_timer_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe TopicTimer, type: :model do
end
describe "#status_type" do
- it "should ensure that only one active public topic status update exists" do
+ it "allows only one active public topic status update" do
topic_timer.update!(topic: topic)
Fabricate(:topic_timer, deleted_at: Time.zone.now, topic: topic)
@@ -52,7 +52,7 @@ RSpec.describe TopicTimer, type: :model do
describe "#execute_at" do
describe "when #execute_at is greater than #created_at" do
- it "should be valid" do
+ it "is valid" do
topic_timer =
Fabricate.build(
:topic_timer,
@@ -66,7 +66,7 @@ RSpec.describe TopicTimer, type: :model do
end
describe "when #execute_at is smaller than #created_at" do
- it "should not be valid" do
+ it "is invalid" do
topic_timer =
Fabricate.build(
:topic_timer,
@@ -84,7 +84,7 @@ RSpec.describe TopicTimer, type: :model do
describe "#category_id" do
describe "when #status_type is publish_to_category" do
describe "when #category_id is not present" do
- it "should not be valid" do
+ it "is invalid" do
topic_timer =
Fabricate.build(:topic_timer, status_type: TopicTimer.types[:publish_to_category])
@@ -94,7 +94,7 @@ RSpec.describe TopicTimer, type: :model do
end
describe "when #category_id is present" do
- it "should be valid" do
+ it "is valid" do
topic_timer =
Fabricate.build(
:topic_timer,
@@ -113,7 +113,7 @@ RSpec.describe TopicTimer, type: :model do
describe "Callbacks" do
describe "when #execute_at and #user_id are not changed" do
- it "should not schedule another to update topic" do
+ it "does not schedule another topic update" do
Jobs.expects(:enqueue_at).never
topic_timer.update!(topic: Fabricate(:topic))
@@ -128,7 +128,7 @@ RSpec.describe TopicTimer, type: :model do
before { Jobs.run_immediately! }
- it "should close the topic" do
+ it "closes the topic" do
topic_timer.send(:schedule_auto_open_job)
expect(topic.reload.closed).to eq(true)
end
@@ -142,7 +142,7 @@ RSpec.describe TopicTimer, type: :model do
before { Jobs.run_immediately! }
- it "should open the topic" do
+ it "opens the topic" do
topic_timer.send(:schedule_auto_close_job)
expect(topic.reload.closed).to eq(false)
end
diff --git a/spec/models/topic_tracking_state_spec.rb b/spec/models/topic_tracking_state_spec.rb
index 98469315ede..186c99fd347 100644
--- a/spec/models/topic_tracking_state_spec.rb
+++ b/spec/models/topic_tracking_state_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe TopicTrackingState do
let(:topic) { post.topic }
shared_examples "does not publish message for private topics" do |method|
- it "should not publish any message for a private topic" do
+ it "does not publish a message for a private topic" do
messages =
MessageBus.track_publish { described_class.public_send(method, private_message_topic) }
@@ -33,7 +33,7 @@ RSpec.describe TopicTrackingState do
Fabricate(:topic, category: read_restricted_category_with_no_groups)
end
- it "should publish message to everyone for a topic in a category that is not read restricted" do
+ it "publishes to everyone for a publicly readable category" do
message =
MessageBus
.track_publish(message_bus_channel) do
@@ -48,7 +48,7 @@ RSpec.describe TopicTrackingState do
expect(message.user_ids).to eq(nil)
end
- it "should publish message only to admin group and groups that have permission to read a category when topic is in category that is restricted to certain groups" do
+ it "publishes only to administrators and groups with category access" do
message =
MessageBus
.track_publish(message_bus_channel) do
@@ -63,7 +63,7 @@ RSpec.describe TopicTrackingState do
expect(message.user_ids).to eq(nil)
end
- it "should publish message only to admin group when topic is in category that is read restricted but no groups have been granted access" do
+ it "publishes only to administrators when no group has category access" do
message =
MessageBus
.track_publish(message_bus_channel) do
@@ -319,7 +319,7 @@ RSpec.describe TopicTrackingState do
)
end
- it "should not publish any message" do
+ it "does not publish a message" do
messages =
MessageBus.track_publish { TopicTrackingState.publish_unread(private_message_post) }
@@ -369,14 +369,14 @@ RSpec.describe TopicTrackingState do
expect(muted_message.data["message_type"]).to eq(described_class::MUTED_MESSAGE_TYPE)
end
- it "should not publish any message when notification level is not muted" do
+ it "does not publish when the notification level is not muted" do
messages = MessageBus.track_publish("/latest") { TopicTrackingState.publish_muted(topic) }
muted_messages = messages.select { |message| message.data["message_type"] == "muted" }
expect(muted_messages).to eq([])
end
- it "should not publish any message when the user was not seen in the last 7 days" do
+ it "does not publish when the user was absent for seven days" do
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 0)
post.user.update(last_seen_at: 8.days.ago)
messages = MessageBus.track_publish("/latest") { TopicTrackingState.publish_muted(topic) }
@@ -408,7 +408,7 @@ RSpec.describe TopicTrackingState do
expect(unmuted_message.data["message_type"]).to eq(described_class::UNMUTED_MESSAGE_TYPE)
end
- it "should not publish any message when notification level is not muted" do
+ it "does not publish when the notification level is not muted" do
SiteSetting.mute_all_categories_by_default = true
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 0)
messages = MessageBus.track_publish("/latest") { TopicTrackingState.publish_unmuted(topic) }
@@ -417,7 +417,7 @@ RSpec.describe TopicTrackingState do
expect(unmuted_messages).to eq([])
end
- it "should not publish any message when the user was not seen in the last 7 days" do
+ it "does not publish when the user was absent for seven days" do
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 1)
post.user.update(last_seen_at: 8.days.ago)
messages = MessageBus.track_publish("/latest") { TopicTrackingState.publish_unmuted(topic) }
diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb
index 5950d2fda81..dd696d659b9 100644
--- a/spec/models/topic_user_spec.rb
+++ b/spec/models/topic_user_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe TopicUser do
end
describe "notifications" do
- it "should trigger the right DiscourseEvent" do
+ it "triggers the notification-level Discourse event" do
called = false
blk = Proc.new { called = true }
begin
@@ -93,7 +93,7 @@ RSpec.describe TopicUser do
end
end
- it "should be set to tracking if auto_track_topics is enabled" do
+ it "uses tracking when auto_track_topics is enabled" do
user.user_option.update_column(:auto_track_topics_after_msecs, 0)
ensure_topic_user
expect(TopicUser.get(topic, user).notification_level).to eq(
@@ -101,14 +101,14 @@ RSpec.describe TopicUser do
)
end
- it "should reset regular topics to tracking topics if auto track is changed" do
+ it "changes regular topics to tracking when auto tracking changes" do
ensure_topic_user
user.user_option.auto_track_topics_after_msecs = 0
user.user_option.save
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
end
- it 'should be set to "regular" notifications, by default on non creators' do
+ it 'uses "regular" notifications by default for non-creators' do
ensure_topic_user
expect(TopicUser.get(topic, user).notification_level).to eq(
TopicUser.notification_levels[:regular],
@@ -122,7 +122,7 @@ RSpec.describe TopicUser do
)
end
- it "should have the correct reason for a user change when watched" do
+ it "records the user-change reason when watched" do
topic.notify_watch!(user)
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:watching])
expect(topic_user.notifications_reason_id).to eq(
@@ -131,7 +131,7 @@ RSpec.describe TopicUser do
expect(topic_user.notifications_changed_at).not_to eq(nil)
end
- it "should have the correct reason for a user change when set to regular" do
+ it "records the user-change reason when changed from watched to regular" do
topic.notify_regular!(user)
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:regular])
expect(topic_user.notifications_reason_id).to eq(
@@ -140,7 +140,7 @@ RSpec.describe TopicUser do
expect(topic_user.notifications_changed_at).not_to eq(nil)
end
- it "should have the correct reason for a user change when set to regular" do
+ it "records the user-change reason when changed from tracking to regular" do
topic.notify_muted!(user)
expect(topic_user.notification_level).to eq(TopicUser.notification_levels[:muted])
expect(topic_user.notifications_reason_id).to eq(
@@ -149,7 +149,7 @@ RSpec.describe TopicUser do
expect(topic_user.notifications_changed_at).not_to eq(nil)
end
- it "should watch topics a user created" do
+ it "watches topics created by the user" do
expect(topic_creator_user.notification_level).to eq(TopicUser.notification_levels[:watching])
expect(topic_creator_user.notifications_reason_id).to eq(
TopicUser.notification_reasons[:created_topic],
@@ -196,7 +196,7 @@ RSpec.describe TopicUser do
context "without auto tracking" do
let(:topic_user) { TopicUser.get(topic, user) }
- it "should create a new record for a visit" do
+ it "creates a record for the first visit" do
freeze_time yesterday
TopicUser.update_last_read(user, topic.id, 1, 1, 0)
@@ -206,7 +206,7 @@ RSpec.describe TopicUser do
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
end
- it "should update the record for repeat visit" do
+ it "updates the record for a repeat visit" do
today = Time.zone.now
freeze_time today
@@ -246,7 +246,7 @@ RSpec.describe TopicUser do
let(:topic) { post.topic }
- it "should ensure recipients and senders are watching" do
+ it "makes private-message recipients and senders watch the topic" do
expect(TopicUser.get(topic, post.user).notification_level).to eq(
TopicUser.notification_levels[:watching],
)
@@ -256,7 +256,7 @@ RSpec.describe TopicUser do
)
end
- it "should ensure invited user is watching once visited" do
+ it "makes an invited user watch after visiting" do
another_user = Fabricate(:user)
topic.invite(target_user, another_user.username)
TopicUser.track_visit!(topic.id, another_user.id)
@@ -273,7 +273,7 @@ RSpec.describe TopicUser do
)
end
- it "should publish the right message_bus message" do
+ it "publishes the notification change through MessageBus" do
TopicUser.update_last_read(user, topic.id, 1, 1, 0)
Fabricate(:post, topic: topic, user: user)
@@ -291,7 +291,7 @@ RSpec.describe TopicUser do
Fabricate(:group, default_notification_level: NotificationLevels.topic_levels[:tracking])
end
- it "should use group's default notification level" do
+ it "uses the group's default notification level" do
another_user = Fabricate(:user, refresh_auto_groups: true)
group.add(another_user)
@@ -320,7 +320,7 @@ RSpec.describe TopicUser do
before { TopicUser.update_last_read(new_user, topic.id, 2, 2, 0) }
- it "should automatically track topics you reply to" do
+ it "automatically tracks topics the user replies to" do
post_creator.create
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:tracking])
expect(topic_new_user.notifications_reason_id).to eq(
@@ -328,7 +328,7 @@ RSpec.describe TopicUser do
)
end
- it "should update tracking state when you reply" do
+ it "updates the tracking state after a reply" do
new_user.user_option.update_column(:notification_level_when_replying, 3)
post_creator.create
DB.exec(
@@ -349,7 +349,7 @@ RSpec.describe TopicUser do
expect(tu.notification_level).to eq(TopicUser.notification_levels[:watching])
end
- it "should not update tracking state when you reply" do
+ it "does not update the tracking state after a reply" do
new_user.user_option.update_column(:notification_level_when_replying, 3)
post_creator.create
DB.exec(
@@ -369,7 +369,7 @@ RSpec.describe TopicUser do
expect(tu.notification_level).to eq(TopicUser.notification_levels[:watching])
end
- it "should not update tracking state when state manually set to normal you reply" do
+ it "preserves a manually selected regular state after a reply" do
new_user.user_option.update_column(:notification_level_when_replying, 3)
post_creator.create
DB.exec(
@@ -389,7 +389,7 @@ RSpec.describe TopicUser do
expect(tu.notification_level).to eq(TopicUser.notification_levels[:regular])
end
- it "should not update tracking state when state manually set to muted you reply" do
+ it "preserves a manually selected muted state after a reply" do
new_user.user_option.update_column(:notification_level_when_replying, 3)
post_creator.create
DB.exec(
@@ -409,7 +409,7 @@ RSpec.describe TopicUser do
expect(tu.notification_level).to eq(TopicUser.notification_levels[:muted])
end
- it "should not automatically track topics you reply to and have set state manually" do
+ it "does not track replied-to topics with a manual state" do
post_creator.create
TopicUser.change(
new_user,
@@ -422,7 +422,7 @@ RSpec.describe TopicUser do
)
end
- it "should automatically track topics after they are read for long enough" do
+ it "tracks topics after the user reads them long enough" do
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:regular])
TopicUser.update_last_read(
new_user,
@@ -436,7 +436,7 @@ RSpec.describe TopicUser do
)
end
- it "should not automatically track topics after they are read for long enough if changed manually" do
+ it "does not track sufficiently read topics with a manual state" do
TopicUser.change(
new_user,
topic,
@@ -452,7 +452,7 @@ RSpec.describe TopicUser do
expect(topic_new_user.notification_level).to eq(TopicUser.notification_levels[:regular])
end
- it "should not automatically track PMs" do
+ it "does not automatically track private messages" do
new_user.user_option.update!(auto_track_topics_after_msecs: 0)
another_user = Fabricate(:user, refresh_auto_groups: true)
@@ -542,7 +542,7 @@ RSpec.describe TopicUser do
end
describe "mailing_list_mode" do
- it "will receive email notification for every topic" do
+ it "receives an email notification for every topic" do
user1 = Fabricate(:user)
Jobs.run_immediately!
diff --git a/spec/models/translation_override_spec.rb b/spec/models/translation_override_spec.rb
index 0210f77c9b0..6c7ba083239 100644
--- a/spec/models/translation_override_spec.rb
+++ b/spec/models/translation_override_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe TranslationOverride do
end
describe "when interpolation keys are missing" do
- it "should not be valid" do
+ it "is invalid" do
translation_override =
TranslationOverride.upsert!(
I18n.locale,
@@ -46,7 +46,7 @@ RSpec.describe TranslationOverride do
user_notifications.visit_link_to_respond
user_notifications.visit_link_to_respond_pm
].each do |i18n_key|
- it "should validate keys for #{i18n_key}" do
+ it "validates keys for #{i18n_key}" do
interpolation_key_names =
described_class.custom_interpolation_keys("user_notifications.user_")
@@ -70,7 +70,7 @@ RSpec.describe TranslationOverride do
end
end
- it "should validate keys that shouldn't be used outside of user_notifications" do
+ it "validates keys reserved for user_notifications" do
I18n.backend.store_translations(:en, "not_a_notification" => "Test %{key1}")
translation_override =
TranslationOverride.upsert!(
@@ -90,7 +90,7 @@ RSpec.describe TranslationOverride do
end
describe "with valid custom interpolation keys" do
- it "works" do
+ it "creates a valid translation override" do
translation_override =
TranslationOverride.upsert!(
I18n.locale,
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index d9f85d5885b..20d772bfd55 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -278,7 +278,7 @@ RSpec.describe Upload do
expect(created_upload.extension).to eq("png")
end
- it "should create an invalid upload when the filename is blank" do
+ it "creates an invalid upload when the filename is blank" do
SiteSetting.authorized_extensions = "*"
created_upload = UploadCreator.new(attachment, nil).create_for(user_id)
expect(created_upload.valid?).to eq(false)
@@ -287,7 +287,7 @@ RSpec.describe Upload 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
+ it "extracts the original upload path" do
expect(Upload.extract_url(url).to_s).to eq("/original/1X/d1c2d40ab994e8410c.png")
end
end
@@ -306,12 +306,12 @@ RSpec.describe Upload do
upload.reload
end
- it "should return the right upload" do
+ it "finds the upload by its extensionless URL" do
expect(Upload.get_from_url(upload.url)).to eq(upload)
end
end
- it "should return the right upload as long as the upload's URL matches" do
+ it "finds an upload only when its full path matches" do
upload.update!(url: "/uploads/default/12345/971308e535305c51.png")
expect(Upload.get_from_url(upload.url)).to eq(upload)
@@ -327,7 +327,7 @@ RSpec.describe Upload do
)
end
- it "should return the right upload" do
+ it "finds the upload by its nested directory URL" do
expect(Upload.get_from_url(upload.url)).to eq(upload)
end
end
@@ -341,7 +341,7 @@ RSpec.describe Upload do
Rails.configuration.action_controller.asset_host = original_asset_host
end
- it "should return the right upload when using the full URL" do
+ it "finds the upload by its full URL" do
expect(
Upload.get_from_url(URI.join("http://discourse.some.com:3000/", upload.url).to_s),
).to eq(upload)
@@ -365,7 +365,7 @@ RSpec.describe Upload do
expect(upload.content).to eq("hello")
end
- it "should return the right upload when using base url (not CDN) for s3" do
+ it "finds the S3 upload by its base URL" do
upload
expect(Upload.get_from_url(upload.url)).to eq(upload)
end
@@ -375,7 +375,7 @@ RSpec.describe Upload do
before { SiteSetting.s3_cdn_url = s3_cdn_url }
- it "should return the right upload" do
+ it "finds the matching upload" do
upload
expect(Upload.get_from_url(URI.join(s3_cdn_url, path).to_s)).to eq(upload)
end
@@ -383,14 +383,14 @@ RSpec.describe Upload do
describe "when upload bucket contains subfolder" do
before { SiteSetting.s3_upload_bucket = "s3-upload-bucket/path/path2" }
- it "should return the right upload" do
+ it "finds the matching upload" do
upload
expect(Upload.get_from_url(URI.join(s3_cdn_url, path).to_s)).to eq(upload)
end
end
end
- it "should return the right upload when using one CDN for both s3 and assets" do
+ it "finds the upload when S3 and assets share a CDN" do
original_asset_host = Rails.configuration.action_controller.asset_host
cdn_url = "http://my.cdn.com"
Rails.configuration.action_controller.asset_host = cdn_url
@@ -455,13 +455,13 @@ RSpec.describe Upload do
end
describe ".generate_digest" do
- it "should return the right digest" do
+ it "returns the upload's digest" do
expect(Upload.generate_digest(image.path)).to eq("bc975735dfc6409c1c2aa5ebf2239949bcbdbd65")
end
end
describe ".short_url" do
- it "should generate a correct short url" do
+ it "generates the short URL" do
upload = Upload.new(sha1: "bda2c513e1da04f7b4e99230851ea2aafeb8cc4e", extension: "png")
expect(upload.short_url).to eq("upload://r3AYqESanERjladb4vBB7VsMBm6.png")
@@ -471,7 +471,7 @@ RSpec.describe Upload do
end
describe ".sha1_from_short_url" do
- it "should be able to look up sha1" do
+ it "looks up the SHA1" do
sha1 = "bda2c513e1da04f7b4e99230851ea2aafeb8cc4e"
expect(Upload.sha1_from_short_url("upload://r3AYqESanERjladb4vBB7VsMBm6.png")).to eq(sha1)
@@ -479,14 +479,14 @@ RSpec.describe Upload do
expect(Upload.sha1_from_short_url("r3AYqESanERjladb4vBB7VsMBm6")).to eq(sha1)
end
- it "should be able to look up sha1 even with leading zeros" do
+ it "looks up the SHA1 with leading zeros" do
sha1 = "0000c513e1da04f7b4e99230851ea2aafeb8cc4e"
expect(Upload.sha1_from_short_url("upload://1Eg9p8rrCURq4T3a6iJUk0ri6.png")).to eq(sha1)
end
end
describe ".sha1_from_long_url" do
- it "should be able to get the sha1 from a regular upload URL" do
+ it "extracts the SHA1 from a regular upload URL" do
expect(
Upload.sha1_from_long_url(
"https://cdn.test.com/test/original/4X/7/6/5/1b6453892473a467d07372d45eb05abc2031647a.png",
@@ -494,7 +494,7 @@ RSpec.describe Upload do
).to eq("1b6453892473a467d07372d45eb05abc2031647a")
end
- it "should be able to get the sha1 from a secure upload URL" do
+ it "extracts the SHA1 from a secure upload URL" do
expect(
Upload.sha1_from_long_url(
"#{Discourse.base_url}\/secure-uploads/original/1X/1b6453892473a467d07372d45eb05abc2031647a.png",
@@ -512,14 +512,14 @@ RSpec.describe Upload do
end
describe "#base62_sha1" do
- it "should return the right value" do
+ it "encodes the SHA1 in base 62" do
upload.update!(sha1: "0000c513e1da04f7b4e99230851ea2aafeb8cc4e")
expect(upload.base62_sha1).to eq("1Eg9p8rrCURq4T3a6iJUk0ri6")
end
end
describe ".sha1_from_short_path" do
- it "should be able to lookup sha1" do
+ it "looks up the SHA1 from a short path with or without an extension" do
path = "/uploads/short-url/3UjQ4jHoyeoQndk5y3qHzm3QVTQ.png"
sha1 = "1b6453892473a467d07372d45eb05abc2031647a"
@@ -529,13 +529,13 @@ RSpec.describe Upload do
end
describe "#to_s" do
- it "should return the right value" do
+ it "returns the upload URL" do
expect(upload.to_s).to eq(upload.url)
end
end
describe ".migrate_to_new_scheme" do
- it "should not migrate system uploads" do
+ it "does not migrate system uploads" do
SiteSetting.migrate_to_new_scheme = true
expect { Upload.migrate_to_new_scheme }.to_not change { Upload.pluck(:url) }
@@ -1096,7 +1096,7 @@ RSpec.describe Upload do
end
describe ".mark_invalid_s3_uploads_as_missing" do
- it "should update all upload records with a `verification_status` of `invalid_etag` to `s3_file_missing`" do
+ it "changes invalid_etag verification statuses to s3_file_missing" do
upload_1 =
Fabricate(:upload_s3, verification_status: Upload.verification_statuses[:invalid_etag])
diff --git a/spec/models/user_action_spec.rb b/spec/models/user_action_spec.rb
index 490a6bf8a21..44b61f5b055 100644
--- a/spec/models/user_action_spec.rb
+++ b/spec/models/user_action_spec.rb
@@ -170,7 +170,7 @@ RSpec.describe UserAction do
private_post.save!
end
- it "should include the right attributes in the stream" do
+ it "includes the expected attributes in the stream" do
expect(stream.count).to eq(1)
user_action_row = stream.first
@@ -247,7 +247,7 @@ RSpec.describe UserAction do
before { PostActionCreator.like(liker, post) }
- it "should result in correct data assignment" do
+ it "assigns the expected data" do
expect(liker_action).not_to eq(nil)
expect(likee_action).not_to eq(nil)
expect(likee.user_stat.reload.likes_received).to eq(1)
@@ -263,7 +263,7 @@ RSpec.describe UserAction do
let(:likee) { post.topic.topic_allowed_users.first.user }
let(:liker) { post.topic.topic_allowed_users.last.user }
- it "should not increase user stats" do
+ it "does not increase user statistics" do
expect(liker_action).not_to eq(nil)
expect(liker.user_stat.reload.likes_given).to eq(0)
expect(likee_action).not_to eq(nil)
@@ -328,13 +328,13 @@ RSpec.describe UserAction do
describe "topic action" do
let(:action) { post.user.user_actions.find_by(action_type: UserAction::NEW_TOPIC) }
- it "should exist" do
+ it "creates the user action" do
expect(action).not_to eq(nil)
expect(action.created_at).to eq_time(post.topic.created_at)
end
end
- it "should not log a post user action" do
+ it "does not log a post user action" do
expect(post.user.user_actions.find_by(action_type: UserAction::REPLY)).to eq(nil)
end
@@ -353,7 +353,7 @@ RSpec.describe UserAction do
before { PostAlerter.post_created(response) }
- it "should log user actions correctly" do
+ it "logs user actions correctly" do
expect(response.user.user_actions.find_by(action_type: UserAction::REPLY)).not_to eq(nil)
expect(post.user.user_actions.find_by(action_type: UserAction::RESPONSE)).not_to eq(nil)
expect(mentioned.user_actions.find_by(action_type: UserAction::MENTION)).not_to eq(nil)
@@ -362,7 +362,7 @@ RSpec.describe UserAction do
).to eq(1)
end
- it "should not log a double notification for a post edit" do
+ it "does not log two notifications for a post edit" do
response.raw = "here it goes again"
response.save!
expect(response.user.user_actions.where(action_type: UserAction::REPLY).count).to eq(1)
diff --git a/spec/models/user_auth_token_spec.rb b/spec/models/user_auth_token_spec.rb
index ac0ea1bbf0b..b79dd488b28 100644
--- a/spec/models/user_auth_token_spec.rb
+++ b/spec/models/user_auth_token_spec.rb
@@ -378,7 +378,7 @@ RSpec.describe UserAuthToken do
expect(user.user_auth_token_logs.last.client_ip).to eq("1.1.2.3")
end
- it "will not mark token unseen when prev and current are the same" do
+ it "does not mark the token unseen when previous and current match" do
token =
UserAuthToken.generate!(user_id: user.id, user_agent: "some user agent", client_ip: "1.1.2.3")
diff --git a/spec/models/user_avatar_spec.rb b/spec/models/user_avatar_spec.rb
index 9de7854265d..fd3eef5db9f 100644
--- a/spec/models/user_avatar_spec.rb
+++ b/spec/models/user_avatar_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe UserAvatar do
end
describe "when user has an existing custom upload" do
- it "should not change the user's uploaded avatar" do
+ it "does not change the user's uploaded avatar" do
user.update!(uploaded_avatar: upload)
avatar.update!(custom_upload: upload, gravatar_upload: Fabricate(:upload, user: user))
@@ -58,7 +58,7 @@ RSpec.describe UserAvatar do
end
describe "when user has an existing gravatar" do
- it "should update the user's uploaded avatar correctly" do
+ it "updates the user's uploaded avatar" do
user.update!(uploaded_avatar: upload)
avatar.update!(gravatar_upload: upload)
@@ -105,7 +105,7 @@ RSpec.describe UserAvatar do
end
end
- it "should not raise an error when there's no primary_email" do
+ it "does not raise an error without a primary email" do
avatar.user.primary_email.destroy
avatar.user.reload
@@ -158,7 +158,7 @@ RSpec.describe UserAvatar do
end
describe "when avatar url returns an invalid status code" do
- it "should not do anything" do
+ it "leaves the uploaded avatar unchanged" do
stub_request(:get, "http://thisfakesomething.something.com/").to_return(
status: 500,
body: "",
@@ -213,7 +213,7 @@ RSpec.describe UserAvatar do
)
end
- it "will clean up dangling avatars" do
+ it "removes dangling avatars" do
upload1 = Fabricate(:upload)
upload2 = Fabricate(:upload)
diff --git a/spec/models/user_export_spec.rb b/spec/models/user_export_spec.rb
index ac358222c12..c6e65990152 100644
--- a/spec/models/user_export_spec.rb
+++ b/spec/models/user_export_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe UserExport do
fab!(:user)
describe ".remove_old_exports" do
- it "should remove the right records" do
+ it "removes the expected records" do
csv_file_1 = Fabricate(:upload, created_at: 3.days.ago)
topic_1 = Fabricate(:topic, created_at: 3.days.ago)
post_1 = Fabricate(:post, topic: topic_1)
@@ -41,7 +41,7 @@ RSpec.describe UserExport do
end
describe "#retain_hours" do
- it "should return the correct number of hours" do
+ it "returns the correct number of hours" do
csv_file_1 = Fabricate(:upload, created_at: 1.day.ago)
topic_1 = Fabricate(:topic, created_at: 1.day.ago)
Fabricate(:post, topic: topic_1)
diff --git a/spec/models/user_option_spec.rb b/spec/models/user_option_spec.rb
index 765fc0d3f38..88356aaaf52 100644
--- a/spec/models/user_option_spec.rb
+++ b/spec/models/user_option_spec.rb
@@ -17,17 +17,17 @@ RSpec.describe UserOption do
describe "defaults" do
fab!(:user)
- it "should be redirected to top when there is a reason to" do
+ it "redirects to top when a reason exists" do
user.user_option.expects(:redirected_to_top).returns(reason: "42")
expect(user.user_option.should_be_redirected_to_top).to eq(true)
end
- it "should not be redirected to top when there is no reason to" do
+ it "does not redirect to top when no reason exists" do
user.user_option.expects(:redirected_to_top).returns(nil)
expect(user.user_option.should_be_redirected_to_top).to eq(false)
end
- it "should not hide the profile and presence by default" do
+ it "does not hide profile and presence by default" do
expect(user.user_option.hide_profile).to eq(false)
expect(user.user_option.hide_presence).to eq(false)
end
@@ -37,45 +37,45 @@ RSpec.describe UserOption do
expect(user.user_option.understood_languages).to eq([])
end
- it "should correctly set digest frequency" do
+ it "sets the digest frequency correctly" do
SiteSetting.default_email_digest_frequency = 1440
user = Fabricate(:user)
expect(user.user_option.email_digests).to eq(true)
expect(user.user_option.digest_after_minutes).to eq(1440)
end
- it "should correctly set digest frequency when disabled" do
+ it "sets the disabled digest frequency correctly" do
SiteSetting.default_email_digest_frequency = 0
user = Fabricate(:user)
expect(user.user_option.email_digests).to eq(false)
expect(user.user_option.digest_after_minutes).to eq(0)
end
- it "should correctly set sidebar_link_to_filtered_list when `default_sidebar_link_to_filtered_list` site setting is enabled" do
+ it "enables sidebar_link_to_filtered_list from its default site setting" do
SiteSetting.default_sidebar_link_to_filtered_list = true
user = Fabricate(:user)
expect(user.user_option.sidebar_link_to_filtered_list).to eq(true)
end
- it "should correctly set sidebar_link_to_filtered_list when `default_sidebar_link_to_filtered_list` site setting is disabled" do
+ it "disables sidebar_link_to_filtered_list from its default site setting" do
SiteSetting.default_sidebar_link_to_filtered_list = false
user = Fabricate(:user)
expect(user.user_option.sidebar_link_to_filtered_list).to eq(false)
end
- it "should correctly set sidebar_show_count_of_new_items when `default_sidebar_show_count_of_new_items` site setting is enabled" do
+ it "enables sidebar_show_count_of_new_items from its default site setting" do
SiteSetting.default_sidebar_show_count_of_new_items = true
user = Fabricate(:user)
expect(user.user_option.sidebar_show_count_of_new_items).to eq(true)
end
- it "should correctly set sidebar_show_count_of_new_items when `default_sidebar_show_count_of_new_items` site setting is disabled" do
+ it "disables sidebar_show_count_of_new_items from its default site setting" do
SiteSetting.default_sidebar_show_count_of_new_items = false
user = Fabricate(:user)
expect(user.user_option.sidebar_show_count_of_new_items).to eq(false)
end
- it "should correctly set composition_mode when `default_composition_mode` site setting is set" do
+ it "sets composition_mode from the default site setting" do
SiteSetting.default_composition_mode = UserOption.composition_mode_types[:markdown]
user = Fabricate(:user)
expect(user.user_option.composition_mode).to eq(UserOption.composition_mode_types[:markdown])
@@ -104,7 +104,7 @@ RSpec.describe UserOption do
end
describe "site settings" do
- it "should apply defaults from site settings" do
+ it "applies defaults from site settings" do
SiteSetting.default_other_enable_quoting = false
SiteSetting.default_other_enable_smart_lists = false
SiteSetting.default_other_enable_markdown_monospace_font = false
@@ -134,13 +134,13 @@ RSpec.describe UserOption do
mailing_list_user.user_option.update(mailing_list_mode: true)
end
- it "should return false when `SiteSetting.disable_mailing_list_mode` is enabled" do
+ it "returns false when mailing-list mode is disabled" do
SiteSetting.disable_mailing_list_mode = true
expect(forum_user.user_option.mailing_list_mode).to eq(false)
expect(mailing_list_user.user_option.mailing_list_mode).to eq(false)
end
- it "should return the stored value when `SiteSetting.disable_mailing_list_mode` is disabled" do
+ it "returns the stored value when mailing-list mode is allowed" do
SiteSetting.disable_mailing_list_mode = false
expect(forum_user.user_option.mailing_list_mode).to eq(false)
expect(mailing_list_user.user_option.mailing_list_mode).to eq(true)
@@ -150,7 +150,7 @@ RSpec.describe UserOption do
describe ".redirected_to_top" do
fab!(:user)
- it "should have no reason when `SiteSetting.redirect_users_to_top_page` is disabled" do
+ it "has no reason when redirect_users_to_top_page is disabled" do
SiteSetting.redirect_users_to_top_page = false
expect(user.user_option.redirected_to_top).to eq(nil)
end
@@ -158,7 +158,7 @@ RSpec.describe UserOption do
context "when `SiteSetting.redirect_users_to_top_page` is enabled" do
before { SiteSetting.redirect_users_to_top_page = true }
- it "should have no reason when top is not in the `SiteSetting.top_menu`" do
+ it "has no reason when top is absent from the top menu" do
SiteSetting.top_menu = "latest"
expect(user.user_option.redirected_to_top).to eq(nil)
end
@@ -166,7 +166,7 @@ RSpec.describe UserOption do
context "when top is in the `SiteSetting.top_menu`" do
before { SiteSetting.top_menu = "latest|top" }
- it "should have no reason when there are not enough topics" do
+ it "has no reason when there are too few topics" do
SiteSetting.expects(:min_redirected_to_top_period).returns(nil)
expect(user.user_option.redirected_to_top).to eq(nil)
end
@@ -182,7 +182,7 @@ RSpec.describe UserOption do
after { Discourse.redis.flushdb }
- it "should have a reason for the first visit" do
+ it "has a reason for the first visit" do
freeze_time do
delay = SiteSetting.active_user_rate_limit_secs / 2
@@ -202,7 +202,7 @@ RSpec.describe UserOption do
end
end
- it "should not have a reason for next visits" do
+ it "has no reason for later visits" do
user.user_option.expects(:last_redirected_to_top_at).returns(10.minutes.ago)
user.user_option.expects(:update_last_redirected_to_top!).never
@@ -213,7 +213,7 @@ RSpec.describe UserOption do
describe "an older user" do
before { user.stubs(:trust_level).returns(1) }
- it "should have a reason when the user hasn't been seen in a month" do
+ it "has a reason when the user has been absent for a month" do
user.last_seen_at = 2.months.ago
user.user_option.expects(:update_last_redirected_to_top!).once
diff --git a/spec/models/user_password_spec.rb b/spec/models/user_password_spec.rb
index ae015adaf59..f94f11b4474 100644
--- a/spec/models/user_password_spec.rb
+++ b/spec/models/user_password_spec.rb
@@ -104,7 +104,7 @@ RSpec.describe UserPassword do
end
context "for validations" do
- it "should validate presence of user_id" do
+ it "requires user_id" do
user_password = Fabricate.build(:user_password, user: nil)
expect(user_password).not_to be_valid
diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb
index 040e9a8ff11..5a948bcc410 100644
--- a/spec/models/user_profile_spec.rb
+++ b/spec/models/user_profile_spec.rb
@@ -137,7 +137,7 @@ RSpec.describe UserProfile do
context "with website validation" do
let(:user_profile) { Fabricate.build(:user_profile, user: Fabricate(:user)) }
- it "should not allow invalid URLs" do
+ it "rejects invalid URLs" do
user_profile.website = "http://https://google.com"
expect(user_profile).to_not be_valid
end
@@ -192,7 +192,7 @@ RSpec.describe UserProfile do
user.user_profile.reload
end
- it "should markdown the raw_bio and put it in cooked_bio" do
+ it "cooks raw_bio into cooked_bio" do
expect(user.user_profile.bio_cooked).to eq("<p><strong>turtle power!</strong></p>")
end
end
@@ -328,7 +328,7 @@ RSpec.describe UserProfile do
end
describe "when profile_background_url returns an invalid status code" do
- it "should not do anything" do
+ it "leaves the featured topic unchanged" do
url = "http://thisfakesomething.something.com/"
UserProfile.import_url_for_user(url, user, is_card_background: false)
@@ -340,7 +340,7 @@ RSpec.describe UserProfile do
end
describe "when card_background_url returns an invalid status code" do
- it "should not do anything" do
+ it "leaves the featured topic unchanged" do
url = "http://thisfakesomething.something.com/"
UserProfile.import_url_for_user(url, user, is_card_background: true)
diff --git a/spec/models/user_profile_view_spec.rb b/spec/models/user_profile_view_spec.rb
index 89563f2235f..539c2de242f 100644
--- a/spec/models/user_profile_view_spec.rb
+++ b/spec/models/user_profile_view_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe UserProfileView do
described_class.add(user_profile_id, ip, user_id, at, true)
end
- it "should increase user's profile view count" do
+ it "increases the user's profile view count" do
expect { add(user_profile_id, "1.1.1.1") }.to change { described_class.count }.by(1)
expect(user.user_profile.reload.views).to eq(1)
expect { add(user_profile_id, "1.1.1.1", other_user.id) }.to change {
@@ -21,7 +21,7 @@ RSpec.describe UserProfileView do
expect(user_profile.user_profile_views).to eq(described_class.all)
end
- it "should not create duplicated profile view for anon user" do
+ it "does not create duplicate anonymous profile views" do
time = Time.zone.now
2.times do
@@ -30,7 +30,7 @@ RSpec.describe UserProfileView do
end
end
- it "should not create duplicated profile view or log IP for signed in user" do
+ it "does not duplicate profile views or log IPs for signed-in users" do
time = Time.zone.now
%w[1.1.1.1 2.2.2.2].each do |ip|
@@ -40,7 +40,7 @@ RSpec.describe UserProfileView do
end
end
- it "should not create a profile view for the system user" do
+ it "does not create a profile view for the system user" do
add(user_profile_id, "1.1.1.1", Discourse::SYSTEM_USER_ID)
expect(described_class.count).to eq(0)
end
diff --git a/spec/models/user_search_spec.rb b/spec/models/user_search_spec.rb
index 3e3453f1d3d..87f28ab9086 100644
--- a/spec/models/user_search_spec.rb
+++ b/spec/models/user_search_spec.rb
@@ -55,7 +55,7 @@ RSpec.describe UserSearch do
expect(results).to eq [user.username]
end
- it "will lookup the category from the topic id" do
+ it "finds the category from the topic ID" do
topic = Fabricate(:topic, category: category)
Fabricate(:post, user: topic.user, topic: topic)
@@ -64,13 +64,13 @@ RSpec.describe UserSearch do
expect(results).to eq [topic.user, user].map(&:username)
end
- it "will raise an error if the user cannot see the category" do
+ it "raises an error when the user cannot see the category" do
expect do
search_for("", searching_user: Fabricate(:user), category_id: category.id)
end.to raise_error(Discourse::InvalidAccess)
end
- it "will respect the group member visibility setting" do
+ it "respects the group member visibility setting" do
group.update(members_visibility_level: Group.visibility_levels[:owners])
results = search_for("", searching_user: searching_user, category_id: category.id)
expect(results).to be_blank
diff --git a/spec/models/user_second_factor_spec.rb b/spec/models/user_second_factor_spec.rb
index 2189ec2d3d4..c1347ba64e9 100644
--- a/spec/models/user_second_factor_spec.rb
+++ b/spec/models/user_second_factor_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe UserSecondFactor do
fab!(:user)
describe ".methods" do
- it "should retain the right order" do
+ it "retains the expected order" do
expect(described_class.methods[:totp]).to eq(1)
expect(described_class.methods[:backup_codes]).to eq(2)
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index e594f4da202..7495ceef4cd 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -30,11 +30,11 @@ RSpec.describe User do
expect(user.in_any_groups?([group.id, Group::AUTO_GROUPS[:everyone]])).to eq(true)
end
- it "returns true if any of the group IDs are the 'logged_in_users' auto group" do
+ it "recognizes membership in the logged_in_users automatic group" do
expect(user.in_any_groups?([Group::AUTO_GROUPS[:logged_in_users]])).to eq(true)
end
- it "never returns true for the 'anonymous_users' auto group — logged-in users are not anonymous" do
+ it "excludes regular users from the anonymous_users automatic group" do
GroupUser.where(user_id: Discourse::SYSTEM_USER_ID).delete_all
Discourse.system_user.reload
expect(user.in_any_groups?([Group::AUTO_GROUPS[:anonymous_users]])).to eq(false)
@@ -67,11 +67,11 @@ RSpec.describe User do
expect(Discourse.system_user.in_any_groups?([Group::AUTO_GROUPS[:admins]])).to eq(true)
end
- it "returns true if any of the group IDs are the 'logged_in_users' auto group" do
+ it "accepts logged_in_users as the sole requested group" do
expect(user.in_any_groups?([Group::AUTO_GROUPS[:logged_in_users]])).to eq(true)
end
- it "never returns true for the 'anonymous_users' auto group — logged-in users are not anonymous" do
+ it "excludes the system user from the anonymous_users automatic group" do
GroupUser.where(user_id: Discourse::SYSTEM_USER_ID).delete_all
Discourse.system_user.reload
expect(user.in_any_groups?([Group::AUTO_GROUPS[:anonymous_users]])).to eq(false)
@@ -109,7 +109,7 @@ RSpec.describe User do
end
describe "Associations" do
- it "should delete sidebar_section_links when a user is destroyed" do
+ it "deletes sidebar_section_links when the user is destroyed" do
Fabricate(:category_sidebar_section_link, user: user)
Fabricate(:tag_sidebar_section_link, user: user)
@@ -155,27 +155,27 @@ RSpec.describe User do
).to contain_exactly(tag.id, hidden_tag.id)
end
- it "should not create any sidebar section link records for staged users" do
+ it "does not create sidebar section links for staged users" do
user = Fabricate(:user, staged: true)
expect(SidebarSectionLink.exists?(user: user)).to eq(false)
end
- it "should create sidebar section link records when user has been unstaged" do
+ it "creates sidebar section links when the user is unstaged" do
user = Fabricate(:user, staged: true)
user.unstage!
expect(SidebarSectionLink.exists?(user: user)).to eq(true)
end
- it "should not create any sidebar section link records for non human users" do
+ it "does not create sidebar section links for non-human users" do
id = -Time.now.to_i
user = Fabricate(:user, id: id)
expect(SidebarSectionLink.exists?(user: user)).to eq(false)
end
- it "should not create any tag sidebar section link records when tagging is disabled" do
+ it "does not create tag sidebar section links when tagging is disabled" do
SiteSetting.tagging_enabled = false
user = Fabricate(:user)
@@ -248,7 +248,7 @@ RSpec.describe User do
it { is_expected.to validate_presence_of :username }
describe "when username already exists" do
- it "should not be valid" do
+ it "rejects a username already used by another user" do
new_user = Fabricate.build(:user, username: user.username.upcase)
expect(new_user).to_not be_valid
@@ -260,7 +260,7 @@ RSpec.describe User do
describe "when group with a same name already exists" do
fab!(:group)
- it "should not be valid" do
+ it "rejects a username already used by a group" do
new_user = Fabricate.build(:user, username: group.name.upcase)
expect(new_user).to_not be_valid
@@ -321,7 +321,7 @@ RSpec.describe User do
let(:user) { Fabricate.build(:user) }
describe "when record has a valid email" do
- it "should be valid" do
+ it "accepts a valid email address" do
user.email = "[email protected]"
expect(user).to be_valid
@@ -329,7 +329,7 @@ RSpec.describe User do
end
describe "when record has an invalid email" do
- it "should not be valid" do
+ it "rejects a malformed email address" do
user.email = "test@gmailcom"
expect(user).to_not be_valid
@@ -338,7 +338,7 @@ RSpec.describe User do
end
describe "when record has an email that as already been taken" do
- it "should not be valid" do
+ it "rejects an email already used by another user" do
user2 = Fabricate(:user)
user.email = user2.email.upcase
@@ -351,7 +351,7 @@ RSpec.describe User do
end
describe "when user is staged" do
- it "should still validate presence of primary_email" do
+ it "requires a primary email for staged users" do
user.staged = true
user.email = nil
@@ -361,7 +361,7 @@ RSpec.describe User do
end
describe "when primary_email is being reassigned to another user" do
- it "should not be valid" do
+ it "rejects assigning another user's primary email record" do
user2 = Fabricate.build(:user, email: nil)
user.save!
user2.primary_email = user.primary_email
@@ -575,7 +575,7 @@ RSpec.describe User do
end
let(:value) { nil }
- it "works" do
+ it "saves a nil user field value" do
user.save!
expect(user_field_value).to eq nil
end
@@ -655,7 +655,7 @@ RSpec.describe User do
describe ".set_default_tags_preferences" do
let(:tag) { Fabricate(:tag) }
- it "should set default tag preferences when new user created" do
+ it "sets default tag preferences for new users" do
SiteSetting.default_tags_watching = tag.name
user = Fabricate(:user)
expect(
@@ -709,7 +709,7 @@ RSpec.describe User do
expect(ReviewableUser.find_by(target: user)).to be_blank
end
- it "will reject a reviewable if the user is deactivated" do
+ it "rejects the reviewable when the user is deactivated" do
SiteSetting.must_approve_users = true
user
@@ -1000,18 +1000,18 @@ RSpec.describe User do
fab!(:user)
fab!(:user2, :user)
- it "should have a sane email hash" do
+ it "hashes the email address" do
expect(user.email_hash).to match(/^[0-9a-f]{32}$/)
end
- it "should use downcase email" do
+ it "lowercases the email before hashing" do
user.email = "[email protected]"
user2.email = "[email protected]"
expect(user.email_hash).to eq(user2.email_hash)
end
- it "should trim whitespace before hashing" do
+ it "trims whitespace before hashing" do
user.email = "[email protected]"
user2.email = " [email protected] "
@@ -1022,7 +1022,7 @@ RSpec.describe User do
describe "associated_accounts" do
fab!(:user)
- it "should correctly find social associations" do
+ it "finds social associations" do
expect(user.associated_accounts).to eq([])
UserAssociatedAccount.create(
@@ -1118,7 +1118,7 @@ RSpec.describe User do
expect(user.valid?).to eq(true)
end
- it "should be SiteSetting.min_username_length chars or longer" do
+ it "requires at least SiteSetting.min_username_length characters" do
SiteSetting.min_username_length = 5
assert_bad("abcd")
assert_good("abcde")
@@ -1189,12 +1189,12 @@ RSpec.describe User do
let!(:codinghorror) { Fabricate.build(:coding_horror) }
- it "should not allow saving if username is reused" do
+ it "rejects saving a reused username" do
codinghorror.username = user.username
expect(codinghorror.save).to eq(false)
end
- it "should not allow saving if username is reused in different casing" do
+ it "rejects reused usernames regardless of case" do
codinghorror.username = user.username.upcase
expect(codinghorror.save).to eq(false)
end
@@ -1258,7 +1258,7 @@ RSpec.describe User do
expect(User.reserved_username?("test")).to eq(true)
end
- it "should not allow usernames matched against an expression" do
+ it "rejects usernames matching a reserved expression" do
SiteSetting.reserved_usernames = "test)|*admin*|foo*|*bar|abc.def|löwe|ka\u0308fer"
expect(User.reserved_username?("test")).to eq(false)
@@ -1287,35 +1287,35 @@ RSpec.describe User do
end
describe "email_validator" do
- it "should allow good emails" do
+ it "accepts valid email addresses" do
user = Fabricate.build(:user, email: "[email protected]")
expect(user).to be_valid
end
- it "should reject some emails based on the blocked_email_domains site setting" do
+ it "rejects addresses from a blocked domain" do
SiteSetting.blocked_email_domains = "mailinator.com"
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should reject some emails based on the blocked_email_domains site setting" do
+ it "rejects addresses from multiple blocked domains" do
SiteSetting.blocked_email_domains = "mailinator.com|trashmail.net"
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should not reject partial matches" do
+ it "accepts partial matches of blocked domains" do
SiteSetting.blocked_email_domains = "mail.com"
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should reject some emails based on the blocked_email_domains site setting ignoring case" do
+ it "matches blocked email domains regardless of case" do
SiteSetting.blocked_email_domains = "trashmail.net"
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
end
- it "should reject emails based on the blocked_email_domains site setting matching subdomain" do
+ it "rejects subdomains of blocked email domains" do
SiteSetting.blocked_email_domains = "domain.com"
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
end
@@ -1333,18 +1333,18 @@ RSpec.describe User do
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should not interpret a period as a wildcard" do
+ it "treats periods literally in email domain restrictions" do
SiteSetting.blocked_email_domains = "trashmail.net"
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should not be used to validate existing records" do
+ it "does not apply domain restrictions to unchanged existing emails" do
u = Fabricate(:user, email: "[email protected]")
SiteSetting.blocked_email_domains = "fakemail.com"
expect(u).to be_valid
end
- it "should be used when email is being changed" do
+ it "applies domain restrictions when the email changes" do
SiteSetting.blocked_email_domains = "mailinator.com"
u = Fabricate(:user, email: "[email protected]")
u.email = "[email protected]"
@@ -1359,7 +1359,7 @@ RSpec.describe User do
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should reject some emails based on the allowed_email_domains site setting when allowlisting multiple domains" do
+ it "rejects emails outside multiple allowed domains" do
SiteSetting.allowed_email_domains = "vaynermedia.com|gmail.com"
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
expect(Fabricate.build(:user, email: "[email protected]")).not_to be_valid
@@ -1367,7 +1367,7 @@ RSpec.describe User do
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
- it "should accept some emails based on the allowed_email_domains site setting ignoring case" do
+ it "accepts allowed email domains regardless of case" do
SiteSetting.allowed_email_domains = "vaynermedia.com"
expect(Fabricate.build(:user, email: "[email protected]")).to be_valid
end
@@ -1404,7 +1404,7 @@ RSpec.describe User do
describe "passwords" do
let(:user) { Fabricate.build(:user, active: false) }
- it "should not have an active account with a good password" do
+ it "keeps the account inactive despite a valid password" do
user.password = "ilovepasta"
user.save!
@@ -1439,7 +1439,7 @@ RSpec.describe User do
after { reset_last_seen_cache!(user) }
- it "should act correctly" do
+ it "records the previous visit when a later visit starts" do
expect(user.previous_visit_at).to eq(nil)
# first visit
@@ -1470,18 +1470,18 @@ RSpec.describe User do
after { reset_last_seen_cache!(user) }
- it "should update the last seen value" do
+ it "updates the last seen value" do
expect(user.last_seen_at).to eq nil
user.update_last_seen!(first_visit_date)
expect(user.reload.last_seen_at).to eq_time(first_visit_date)
end
- it "should update the first seen value if it doesn't exist" do
+ it "sets the first seen value when missing" do
user.update_last_seen!(first_visit_date)
expect(user.reload.first_seen_at).to eq_time(first_visit_date)
end
- it "should not update the first seen value if it doesn't exist" do
+ it "preserves the existing first seen value" do
user.update_last_seen!(first_visit_date)
user.update_last_seen!(second_visit_date)
expect(user.reload.first_seen_at).to eq_time(first_visit_date)
@@ -1544,11 +1544,11 @@ RSpec.describe User do
describe "last_seen_at" do
fab!(:user)
- it "should have a blank last seen on creation" do
+ it "has a blank last seen value on creation" do
expect(user.last_seen_at).to eq(nil)
end
- it "should have 0 for days_visited" do
+ it "starts with zero days visited" do
expect(user.user_stat.days_visited).to eq(0)
end
@@ -1566,14 +1566,14 @@ RSpec.describe User do
expect(user.last_seen_at).to eq_time(date)
end
- it "should have 0 for days_visited" do
+ it "has zero days visited" do
user.update_last_seen!
user.reload
expect(user.user_stat.days_visited).to eq(1)
end
- it "should log a user_visit with the date" do
+ it "logs a user visit with the date" do
date = freeze_time
user.update_last_seen!
@@ -1592,7 +1592,7 @@ RSpec.describe User do
end
describe "after 3 days" do
- it "should log a second visited_at record when we log an update later" do
+ it "logs a second visit when updated on a later date" do
user.update_last_seen!
freeze_time(3.days.from_now)
user.update_last_seen!
@@ -1645,13 +1645,13 @@ RSpec.describe User do
fab!(:user)
context "when email has not been confirmed yet" do
- it "should return false" do
+ it "returns false before email confirmation" do
expect(user.email_confirmed?).to eq(false)
end
end
context "when email has been confirmed" do
- it "should return true" do
+ it "returns true after email confirmation" do
token = Fabricate(:email_token, user: user)
EmailToken.confirm(token.token)
expect(user.email_confirmed?).to eq(true)
@@ -1659,7 +1659,7 @@ RSpec.describe User do
end
context "when user has no email tokens for some reason" do
- it "should return false" do
+ it "returns true when no email tokens remain" do
user.email_tokens.each { |t| t.destroy }
user.reload
expect(user.email_confirmed?).to eq(true)
@@ -2099,7 +2099,7 @@ RSpec.describe User do
user.reload
end
- it "should allow us to use it as a primary group" do
+ it "allows using the group as the primary group" do
expect(user.primary_group_id).to eq(group.id)
# If we remove the user from the group
@@ -2183,7 +2183,7 @@ RSpec.describe User do
end
describe "real users" do
- it "should find system user if you allow it" do
+ it "finds the system user when allowed" do
ids =
User
.real(allowed_bot_user_ids: [Discourse.system_user.id])
@@ -2249,7 +2249,7 @@ RSpec.describe User do
)
end
- it "should only remove old, unactivated users that haven't been manually deactivated" do
+ it "removes only old unactivated users that were not manually deactivated" do
User.purge_unactivated
expect(User.real.all).to match_array(
[
@@ -2640,7 +2640,7 @@ RSpec.describe User do
describe "#logged_out" do
fab!(:user)
- it "should publish the right message" do
+ it "publishes the user ID on the logout channel" do
message = MessageBus.track_publish("/logout/#{user.id}") { user.logged_out }.first
expect(message.data).to eq(user.id)
@@ -2652,20 +2652,20 @@ RSpec.describe User do
fab!(:notification, :private_message_notification)
describe "when first notification has not been seen" do
- it "should return the right value" do
+ it "returns false before the first notification is seen" do
expect(user.read_first_notification?).to eq(false)
end
end
describe "when first notification has been seen" do
- it "should return the right value" do
+ it "returns true after the first notification is seen" do
user.update!(seen_notification_id: notification.id)
expect(user.reload.read_first_notification?).to eq(true)
end
end
describe "when user is trust level 1" do
- it "should return the right value" do
+ it "returns false for a trust level 1 user" do
user.update!(trust_level: TrustLevel[1])
expect(user.read_first_notification?).to eq(false)
@@ -2673,7 +2673,7 @@ RSpec.describe User do
end
describe "when user skipped new user tips" do
- it "should return the right value" do
+ it "returns true when new user tips are skipped" do
user.user_option.update!(skip_new_user_tips: true)
expect(user.read_first_notification?).to eq(true)
@@ -2708,7 +2708,7 @@ RSpec.describe User do
)
end
- it "should display badges in the correct order" do
+ it "displays badges in the expected order" do
expect(user.featured_user_badges.map(&:badge_id)).to eq(
[Badge::Member, Badge::FirstLike, Badge::BasicUser],
)
@@ -2752,7 +2752,7 @@ RSpec.describe User do
end
describe ".human_users" do
- it "should only return users with a positive primary key" do
+ it "returns only users with a positive primary key" do
Fabricate(:bot)
user = Fabricate(:user)
@@ -2771,7 +2771,7 @@ RSpec.describe User do
end
describe "#publish_notifications_state" do
- it "should publish the right message sorted by ID desc" do
+ it "publishes the message sorted by descending ID" do
notification = Fabricate(:notification, user: user)
notification2 = Fabricate(:notification, user: user, read: true)
@@ -3072,13 +3072,13 @@ RSpec.describe User do
end
describe "#filter_by_username" do
- it "should be able to filter by username" do
+ it "filters by username" do
filter_by(:filter_by_username)
end
end
describe "#filter_by_username_or_email" do
- it "should be able to filter by email" do
+ it "filters by email" do
user.update!(email: email)
@@ -3087,7 +3087,7 @@ RSpec.describe User do
expect(User.filter_by_username_or_email("veryspeCiaLtest")).to eq([user])
end
- it "should be able to filter by username" do
+ it "filters by username" do
filter_by(:filter_by_username_or_email)
end
end
@@ -3120,7 +3120,7 @@ RSpec.describe User do
expect(User.find(user.id).email).to eq(new_email)
end
- it "will automatically remove matching secondary emails" do
+ it "automatically removes matching secondary emails" do
secondary_email_record = Fabricate(:secondary_email, user: user)
user.reload
expect(user.secondary_emails.count).to eq(1)
@@ -3162,7 +3162,7 @@ RSpec.describe User do
end
describe "ensure_consistency!" do
- it "will clean up dangling avatars" do
+ it "cleans up dangling avatars" do
upload = Fabricate(:upload)
user = Fabricate(:user, uploaded_avatar_id: upload.id)
@@ -3195,7 +3195,7 @@ RSpec.describe User do
expect { user.update(primary_group: group_a) }.to_not change { user.reload.title }
end
- it "updates user's title only when it is blank or matches the previous primary group" do
+ it "updates the flair group to match primary group changes" do
expect { user.update(primary_group: group_a) }.to change { user.reload.flair_group }.from(
nil,
).to(group_a)
@@ -3938,7 +3938,7 @@ RSpec.describe User do
Fabricate(:category_sidebar_section_link, user: user, linkable: secured_category)
end
- it "should only return the category ids of category sidebar section link records that the user is allowed to see" do
+ it "returns sidebar category IDs visible to the user" do
expect(user.secured_sidebar_category_ids).to contain_exactly(category.id)
user.update!(admin: true)
@@ -3965,7 +3965,7 @@ RSpec.describe User do
Fabricate(:tag_sidebar_section_link, user: user, linkable: synonym)
end
- it "should only return tag sidebar section link records of tags that the user is allowed to browse" do
+ it "returns sidebar tag links the user is allowed to browse" do
expect(user.visible_sidebar_tags).to contain_exactly(tag)
user.update!(admin: true)
diff --git a/spec/models/user_stat_spec.rb b/spec/models/user_stat_spec.rb
index 649958337c4..cf017da5aa4 100644
--- a/spec/models/user_stat_spec.rb
+++ b/spec/models/user_stat_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe UserStat do
expect { UserStat.update_view_counts }.to change { stat.reload.topics_entered }.to 1
end
- it "won't record a second view as a different topic" do
+ it "does not count a repeat view as another topic" do
TopicViewItem.add(topic.id, "127.0.0.1", user.id)
expect { UserStat.update_view_counts }.to change { stat.reload.topics_entered }.to 1
end
diff --git a/spec/models/web_hook_event_spec.rb b/spec/models/web_hook_event_spec.rb
index 6cfb6e0b88a..3e51714a4ff 100644
--- a/spec/models/web_hook_event_spec.rb
+++ b/spec/models/web_hook_event_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe WebHookEvent do
describe ".purge_old" do
before { SiteSetting.retain_web_hook_events_period_days = 1 }
- it "should be able to purge old web hook events" do
+ it "purges old webhook events" do
web_hook = Fabricate(:web_hook)
web_hook_event = WebHookEvent.create!(status: 200, web_hook: web_hook)
WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 2.days.ago)
diff --git a/spec/models/web_hook_events_daily_aggregate_spec.rb b/spec/models/web_hook_events_daily_aggregate_spec.rb
index d9913882c37..d1bd4ef33e1 100644
--- a/spec/models/web_hook_events_daily_aggregate_spec.rb
+++ b/spec/models/web_hook_events_daily_aggregate_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe WebHookEventsDailyAggregate do
describe ".purge_old" do
before { SiteSetting.retain_web_hook_events_aggregate_days = 1 }
- it "should be able to purge old web hook event aggregates" do
+ it "purges old webhook event aggregates" do
web_hook = Fabricate(:web_hook)
WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 1.day.ago, duration: 180)
WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 2.days.ago, duration: 180)
@@ -59,7 +59,7 @@ RSpec.describe WebHookEventsDailyAggregate do
end
describe "aggregation works" do
- it "should be able to aggregate web hook events" do
+ it "aggregates webhook events" do
yesterday_aggregate =
WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.day.ago)
yesterday_events = [event, failed_event, failed_event2]
@@ -75,7 +75,7 @@ RSpec.describe WebHookEventsDailyAggregate do
expect(yesterday_aggregate.failed_event_count).to eq(2)
end
- it "should be able to filter by day" do
+ it "filters by day" do
WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.day.ago)
WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 0.days.ago)
yesterday_events = [event, failed_event, failed_event2]
@@ -101,7 +101,7 @@ RSpec.describe WebHookEventsDailyAggregate do
)
end
- it "should not create a new WebHookEventsDailyAggregate row if AggregateWebHooksEvents runs twice" do
+ it "does not duplicate daily aggregates when the job runs twice" do
expect { Jobs::AggregateWebHooksEvents.new.execute(date: 1.day.ago) }.to change {
WebHookEventsDailyAggregate.count
}.by(1)
@@ -111,7 +111,7 @@ RSpec.describe WebHookEventsDailyAggregate do
}
end
- it "should not fail if there are no events" do
+ it "handles an empty event list without error" do
expect { Jobs::AggregateWebHooksEvents.new.execute(date: 99.days.ago) }.not_to raise_error
expect(WebHookEventsDailyAggregate.count).to eq(1)
diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb
index 25b9fbe82b1..9fa11196775 100644
--- a/spec/models/web_hook_spec.rb
+++ b/spec/models/web_hook_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe WebHook do
describe "wildcard web hooks" do
fab!(:wildcard_hook, :wildcard_web_hook)
- it "should include wildcard hooks" do
+ it "includes wildcard hooks" do
expect(WebHook.active_web_hooks(:wildcard)).to eq([wildcard_hook])
expect(WebHook.active_web_hooks(:post_created)).to contain_exactly(
@@ -156,7 +156,7 @@ RSpec.describe WebHook do
before { topic_web_hook }
describe "when there are no active hooks" do
- it "should not generate payload and enqueue anything for topic events" do
+ it "does not generate payloads or enqueue topic events" do
topic_web_hook.destroy!
post = PostCreator.create(user, raw: "post", title: "topic", skip_validations: true)
expect(Jobs::EmitWebHookEvent.jobs.length).to eq(0)
@@ -166,14 +166,14 @@ RSpec.describe WebHook do
expect(Jobs::EmitWebHookEvent.jobs.length).to eq(0)
end
- it "should not enqueue anything for tag events" do
+ it "does not enqueue tag events" do
tag = Fabricate(:tag)
tag.destroy!
expect(Jobs::EmitWebHookEvent.jobs.length).to eq(0)
end
end
- it "should enqueue the right hooks for topic events" do
+ it "enqueues matching hooks for topic events" do
post = PostCreator.create(user, raw: "post", title: "topic", skip_validations: true)
topic_id = post.topic.id
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
@@ -241,7 +241,7 @@ RSpec.describe WebHook do
)
end
- it "should enqueue granular hooks for topic" do
+ it "enqueues granular hooks for the topic" do
topic_web_hook.web_hook_event_types.delete(
WebHookEventType.where(name: "topic_destroyed").last,
)
@@ -259,7 +259,7 @@ RSpec.describe WebHook do
}
end
- it "should not log a personal message view when processing new topic" do
+ it "does not log a personal message view when processing a new topic" do
SiteSetting.log_personal_messages_views = true
Fabricate(:topic_web_hook)
@@ -283,7 +283,7 @@ RSpec.describe WebHook do
end
describe "when topic has been deleted" do
- it "should not enqueue a post/topic edited hooks" do
+ it "does not enqueue post or topic edited hooks" do
topic.trash!
post.reload
@@ -297,7 +297,7 @@ RSpec.describe WebHook do
end
end
- it "should enqueue the right hooks for post events" do
+ it "enqueues matching hooks for post events" do
Fabricate(:web_hook)
post =
@@ -365,7 +365,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(post.topic.id)
end
- it "should not enqueue post hooks when the topic is permanently destroyed" do
+ it "does not enqueue post hooks when the topic is permanently destroyed" do
Fabricate(:web_hook)
Jobs::EmitWebHookEvent.jobs.clear
@@ -380,7 +380,7 @@ RSpec.describe WebHook do
).to eq(0)
end
- it "should serialize the right topic posts counts when a post is deleted" do
+ it "serializes updated topic post counts after a post is deleted" do
Fabricate(:web_hook)
Jobs::EmitWebHookEvent.jobs.clear
@@ -401,7 +401,7 @@ RSpec.describe WebHook do
expect(payload["topic_filtered_posts_count"]).to eq(1)
end
- it "should enqueue the destroyed hooks with tag filter for post events" do
+ it "enqueues destroyed hooks with the tag filter for post events" do
tag = Fabricate(:tag)
Fabricate(:web_hook, tags: [tag])
@@ -430,7 +430,7 @@ RSpec.describe WebHook do
job.execute(args.with_indifferent_access)
end
- it "should enqueue the right hooks for user events" do
+ it "enqueues matching hooks for user events" do
SiteSetting.must_approve_users = true
Fabricate(:user_web_hook, active: true)
@@ -506,7 +506,7 @@ RSpec.describe WebHook do
expect(payload["user_fields"].size).to eq(1)
end
- it "should enqueue the right hooks for category events" do
+ it "enqueues matching hooks for category events" do
Fabricate(:category_web_hook)
category = Fabricate(:category)
@@ -534,7 +534,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(category.id)
end
- it "should enqueue the right hooks for group events" do
+ it "enqueues matching hooks for group events" do
Fabricate(:group_web_hook)
group = Fabricate(:group)
@@ -560,7 +560,7 @@ RSpec.describe WebHook do
expect(payload["full_name"]).to eq("testing")
end
- it "should enqueue the right hooks for tag events" do
+ it "enqueues matching hooks for tag events" do
Fabricate(:tag_web_hook)
tag = Fabricate(:tag)
@@ -587,7 +587,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(tag.id)
end
- it "should enqueue the right hooks for notifications" do
+ it "enqueues matching hooks for notifications" do
Fabricate(:notification_web_hook)
notification = Fabricate(:notification)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
@@ -597,7 +597,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(notification.id)
end
- it "should enqueue the right hooks for reviewables" do
+ it "enqueues matching hooks for reviewables" do
Fabricate(:reviewable_web_hook)
reviewable = Fabricate(:reviewable)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
@@ -621,7 +621,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(reviewable.id)
end
- it "should enqueue the right hooks for badge grants" do
+ it "enqueues matching hooks for badge grants" do
Fabricate(:user_badge_web_hook)
badge = Fabricate(:badge)
badge.multiple_grant = true
@@ -646,7 +646,7 @@ RSpec.describe WebHook do
# Future work: revoke badge hook
end
- it "should enqueue the right hooks for group user addition" do
+ it "enqueues matching hooks when a user joins a group" do
Fabricate(:group_user_web_hook)
group = Fabricate(:group)
@@ -667,7 +667,7 @@ RSpec.describe WebHook do
expect(Time.zone.parse(payload["created_at"])).to be_within_one_second_of(now)
end
- it "should enqueue the right hooks for group user deletion" do
+ it "enqueues matching hooks when a user leaves a group" do
Fabricate(:group_user_web_hook)
group = Fabricate(:group)
group_user = Fabricate(:group_user, group: group, user: user)
@@ -691,7 +691,7 @@ RSpec.describe WebHook do
fab!(:user_promoted_web_hook)
fab!(:another_user) { Fabricate(:user, trust_level: 2) }
- it "should pass the user to the webhook job when a user is promoted" do
+ it "passes the promoted user to the webhook job" do
another_user.change_trust_level!(another_user.trust_level + 1)
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
@@ -700,7 +700,7 @@ RSpec.describe WebHook do
expect(payload["id"]).to eq(another_user.id)
end
- it "shouldn’t trigger when the user is demoted" do
+ it "does not trigger when the user is demoted" do
expect { another_user.change_trust_level!(another_user.trust_level - 1) }.not_to change {
Jobs::EmitWebHookEvent.jobs.length
}
@@ -711,7 +711,7 @@ RSpec.describe WebHook do
fab!(:like_web_hook)
fab!(:another_user, :user)
- it "should pass the group id to the emit webhook job" do
+ it "passes the group ID to the emit webhook job" do
group = Fabricate(:group)
group_user = Fabricate(:group_user, group: group, user: user)
post = Fabricate(:post, user: another_user)
@@ -738,7 +738,7 @@ RSpec.describe WebHook do
)
end
- it "should pass the category id to the emit webhook job" do
+ it "passes the category ID to the emit webhook job" do
category = Fabricate(:category)
topic.update!(category: category)
like =
@@ -754,7 +754,7 @@ RSpec.describe WebHook do
assert_hook_was_queued_with(post, another_user, category_id: category.id)
end
- it "should pass the tag id to the emit webhook job" do
+ it "passes the tag ID to the emit webhook job" do
tag = Fabricate(:tag)
topic.update!(tags: [tag])
like =
diff --git a/spec/multisite/jobs_spec.rb b/spec/multisite/jobs_spec.rb
index c02e5a66aa1..8175eb77be5 100644
--- a/spec/multisite/jobs_spec.rb
+++ b/spec/multisite/jobs_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "Running Sidekiq Jobs in Multisite", type: :multisite do
- it "should revert back to the default connection" do
+ it "reverts to the default connection" do
expect do Jobs::DestroyOldDeletionStubs.new.perform({}) end.to_not change {
RailsMultisite::ConnectionManagement.current_db
}
diff --git a/spec/multisite/pausable_multisite_spec.rb b/spec/multisite/pausable_multisite_spec.rb
index 11dd4ff311f..0742da52c9b 100644
--- a/spec/multisite/pausable_multisite_spec.rb
+++ b/spec/multisite/pausable_multisite_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Sidekiq::Pausable, type: :multisite do
) { yield }
end
- it "should delay the job" do
+ it "delays the job" do
Sidekiq.pause!
called = false
diff --git a/spec/multisite/site_settings_spec.rb b/spec/multisite/site_settings_spec.rb
index bf1fe826e85..8f88693f27e 100644
--- a/spec/multisite/site_settings_spec.rb
+++ b/spec/multisite/site_settings_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "Multisite SiteSettings", type: :multisite do
after { SiteSetting.provider = @original_provider }
describe "#default_locale" do
- it "should return the right locale" do
+ it "returns the site's locale" do
test_multisite_connection("default") { expect(SiteSetting.default_locale).to eq("en") }
test_multisite_connection("second") do
@@ -65,7 +65,7 @@ RSpec.describe "Multisite SiteSettings", type: :multisite do
describe "themeable site settings" do
describe "#enable_welcome_banner" do
- it "should return the right value" do
+ it "returns the site's setting value" do
test_multisite_connection("default") do
expect(SiteSetting.enable_welcome_banner(theme_id: Theme.find_default.id)).to eq(true)
end
diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb
index 54e75da0365..b17b525bbf3 100644
--- a/spec/requests/about_controller_spec.rb
+++ b/spec/requests/about_controller_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe AboutController do
describe "#index" do
- it "should display the about page for anonymous user when login_required is false" do
+ it "displays the about page anonymously when login is optional" do
SiteSetting.login_required = false
get "/about"
@@ -10,14 +10,14 @@ RSpec.describe AboutController do
expect(response.body).to include("<title>About - Discourse</title>")
end
- it "should redirect to login page for anonymous user when login_required is true" do
+ it "redirects anonymous users to login when login is required" do
SiteSetting.login_required = true
get "/about"
expect(response).to redirect_to "/login"
end
- it "should display the about page for logged in user when login_required is true" do
+ it "displays the about page to logged-in users when login is required" do
SiteSetting.login_required = true
sign_in(Fabricate(:user))
get "/about"
@@ -26,13 +26,13 @@ RSpec.describe AboutController do
end
context "with crawler view" do
- it "should include correct title" do
+ it "includes the page title" do
get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
expect(response.body).to include("<title>About - Discourse</title>")
end
- it "should include correct user URLs" do
+ it "includes the user URLs" do
Fabricate(:admin, username: "anAdminUser")
get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rb
index 22fa4dde570..7f73832924a 100644
--- a/spec/requests/admin/api_controller_spec.rb
+++ b/spec/requests/admin/api_controller_spec.rb
@@ -184,7 +184,7 @@ RSpec.describe Admin::ApiController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "works" do
+ it "deletes the API key and logs the action" do
expect(ApiKey.exists?(key1.id)).to eq(true)
delete "/admin/api/keys/#{key1.id}.json"
diff --git a/spec/requests/admin/backups_controller_spec.rb b/spec/requests/admin/backups_controller_spec.rb
index 57b7376fe9b..9172391468c 100644
--- a/spec/requests/admin/backups_controller_spec.rb
+++ b/spec/requests/admin/backups_controller_spec.rb
@@ -499,7 +499,7 @@ RSpec.describe Admin::BackupsController do
before { sign_in(admin) }
describe "when filename contains invalid characters" do
- it "should raise an error" do
+ it "returns 415 for invalid filename characters" do
["灰色.tar.gz", '; echo \'haha\'.tar.gz'].each do |invalid_filename|
described_class.any_instance.expects(:has_enough_space_on_disk?).returns(true)
@@ -517,7 +517,7 @@ RSpec.describe Admin::BackupsController do
end
describe "when resumableIdentifier is invalid" do
- it "should raise an error" do
+ it "returns 400 for an invalid upload identifier" do
filename = "test_site-0123456789.tar.gz"
@paths = [backup_path(File.join("tmp", "test", "#{filename}.part1"))]
@@ -537,7 +537,7 @@ RSpec.describe Admin::BackupsController do
end
describe "when filename is valid" do
- it "should upload the file successfully" do
+ it "uploads the file" do
freeze_time
described_class.any_instance.expects(:has_enough_space_on_disk?).returns(true)
@@ -753,7 +753,7 @@ RSpec.describe Admin::BackupsController do
before { sign_in(admin) }
describe "when resumableIdentifier is invalid" do
- it "should raise an error" do
+ it "returns 400 for an invalid chunk identifier" do
get "/admin/backups/upload",
params: {
resumableidentifier: "../some_file",
@@ -836,7 +836,7 @@ RSpec.describe Admin::BackupsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should rollback the restore" do
+ it "rolls back the restore" do
BackupRestore.expects(:rollback!)
post "/admin/backups/rollback.json"
@@ -844,7 +844,7 @@ RSpec.describe Admin::BackupsController do
expect(response.status).to eq(200)
end
- it "should not allow rollback via a GET request" do
+ it "rejects rollback through a GET request" do
get "/admin/backups/rollback.json"
expect(response.status).to eq(404)
end
@@ -852,7 +852,7 @@ RSpec.describe Admin::BackupsController do
context "when readonly mode is enabled" do
before { Discourse.enable_readonly_mode }
- it "should rollback the restore" do
+ it "rolls back the restore" do
BackupRestore.expects(:rollback!)
post "/admin/backups/rollback.json"
expect(response.status).to eq(200)
@@ -886,7 +886,7 @@ RSpec.describe Admin::BackupsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should cancel an backup" do
+ it "cancels the backup" do
BackupRestore.expects(:cancel!)
delete "/admin/backups/cancel.json"
@@ -894,7 +894,7 @@ RSpec.describe Admin::BackupsController do
expect(response.status).to eq(200)
end
- it "should not allow cancel via a GET request" do
+ it "rejects cancellation through a GET request" do
get "/admin/backups/cancel.json"
expect(response.status).to eq(404)
end
@@ -902,7 +902,7 @@ RSpec.describe Admin::BackupsController do
context "when readonly mode is enabled" do
before { Discourse.enable_readonly_mode }
- it "should cancel an backup" do
+ it "cancels the backup" do
BackupRestore.expects(:cancel!)
delete "/admin/backups/cancel.json"
diff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rb
index 3f962c4c7b9..4b07f36769c 100644
--- a/spec/requests/admin/email_controller_spec.rb
+++ b/spec/requests/admin/email_controller_spec.rb
@@ -302,7 +302,7 @@ RSpec.describe Admin::EmailController do
expect(response.body).to include("param is missing")
end
- it "should enqueue the right job, and show a deprecation warning (email_encoded param should be used)" do
+ it "enqueues the email job and warns that email_encoded is preferred" do
expect_enqueued_with(
job: :process_email,
args: {
@@ -317,7 +317,7 @@ RSpec.describe Admin::EmailController do
)
end
- it "should enqueue the right job, decoding the raw email param" do
+ it "decodes the raw email and enqueues the email job" do
expect_enqueued_with(
job: :process_email,
args: {
@@ -388,7 +388,7 @@ RSpec.describe Admin::EmailController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should ..." do
+ it "returns parsed email text and elided content" do
post "/admin/email/advanced-test.json", params: { email: email }
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/email_logs_controller_spec.rb b/spec/requests/admin/email_logs_controller_spec.rb
index 5ad2de79def..fce9f93e173 100644
--- a/spec/requests/admin/email_logs_controller_spec.rb
+++ b/spec/requests/admin/email_logs_controller_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Admin::EmailLogsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/admin/email-logs/sent.json"
expect(response.status).to eq(200)
@@ -35,7 +35,7 @@ RSpec.describe Admin::EmailLogsController do
expect(log["post_url"]).to eq(post.url)
end
- it "should be able to filter by reply key" do
+ it "filters by reply key" do
email_log_2 = Fabricate(:email_log, post: post)
post_reply_key_2 =
@@ -58,7 +58,7 @@ RSpec.describe Admin::EmailLogsController do
end
end
- it "should be able to filter by smtp_transaction_response" do
+ it "filters by smtp_transaction_response" do
email_log_2 = Fabricate(:email_log, smtp_transaction_response: <<~RESPONSE)
250 Ok: queued as [email protected]
RESPONSE
@@ -77,7 +77,7 @@ RSpec.describe Admin::EmailLogsController do
let(:email_type) { "group_smtp" }
let(:target_email) { user.email }
- it "should be able to filter across both to address and cc addresses" do
+ it "filters across recipient and CC addresses" do
other_email = "[email protected]"
another_email = "[email protected]"
email_log_matching_to_address =
@@ -150,7 +150,7 @@ RSpec.describe Admin::EmailLogsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "succeeds" do
+ it "returns skipped email logs" do
get "/admin/email-logs/skipped.json"
expect(response.status).to eq(200)
@@ -162,7 +162,7 @@ RSpec.describe Admin::EmailLogsController do
end
context "when filtered by username" do
- it "should return the right response" do
+ it "returns the matching username response" do
get "/admin/email-logs/skipped.json", params: { user: user.username }
expect(response.status).to eq(200)
@@ -175,7 +175,7 @@ RSpec.describe Admin::EmailLogsController do
end
context "when filtered by address" do
- it "should return the right response" do
+ it "returns the matching address response" do
get "/admin/email-logs/skipped.json", params: { address: "test@example" }
expect(response.status).to eq(200)
logs = response.parsed_body
@@ -212,7 +212,7 @@ RSpec.describe Admin::EmailLogsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should provide a string for a blank error" do
+ it "provides a string for a blank error" do
Fabricate(:incoming_email, error: "")
get "/admin/email-logs/rejected.json"
expect(response.status).to eq(200)
@@ -247,7 +247,7 @@ RSpec.describe Admin::EmailLogsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should provide a string for a blank error" do
+ it "provides a string for a blank error" do
incoming_email = Fabricate(:incoming_email, error: "")
get "/admin/email-logs/incoming/#{incoming_email.id}.json"
expect(response.status).to eq(200)
@@ -321,7 +321,7 @@ RSpec.describe Admin::EmailLogsController do
expect(json["error"]).to eq(error_message)
end
- it "returns an incoming email sent to the notification_email address" do
+ it "returns an incoming email sent to a VERP notification address" do
Fabricate(
:incoming_email,
is_bounce: true,
@@ -336,7 +336,7 @@ RSpec.describe Admin::EmailLogsController do
expect(json["error"]).to eq(error_message)
end
- it "returns an incoming email sent to the notification_email address" do
+ it "returns an incoming email sent to a reply-by-email subdomain" do
SiteSetting.reply_by_email_address = "replies+%{reply_key}@subdomain.example.com"
Fabricate(
:incoming_email,
diff --git a/spec/requests/admin/email_templates_controller_spec.rb b/spec/requests/admin/email_templates_controller_spec.rb
index b5f390ec6d3..85617699cf4 100644
--- a/spec/requests/admin/email_templates_controller_spec.rb
+++ b/spec/requests/admin/email_templates_controller_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Admin::EmailTemplatesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should work if you are an admin" do
+ it "allows an administrator to update the template" do
get "/admin/email/templates.json"
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/embedding_controller_spec.rb b/spec/requests/admin/embedding_controller_spec.rb
index 0f092f93a63..66f6884681f 100644
--- a/spec/requests/admin/embedding_controller_spec.rb
+++ b/spec/requests/admin/embedding_controller_spec.rb
@@ -91,7 +91,7 @@ RSpec.describe Admin::EmbeddingController do
end
end
- context "when logged in as a moderator" do
+ context "when logged in as a regular user" do
before { sign_in(moderator) }
include_examples "embedding updates not allowed"
diff --git a/spec/requests/admin/emojis_controller_spec.rb b/spec/requests/admin/emojis_controller_spec.rb
index c45f145576e..8398352ff22 100644
--- a/spec/requests/admin/emojis_controller_spec.rb
+++ b/spec/requests/admin/emojis_controller_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe Admin::EmojiController do
before { sign_in(admin) }
context "when upload is invalid" do
- it "should publish the right error" do
+ it "publishes the expected error" do
post "/admin/config/emoji.json",
params: {
name: "test",
@@ -75,7 +75,7 @@ RSpec.describe Admin::EmojiController do
end
context "when emoji name already exists" do
- it "should publish the right error" do
+ it "publishes the expected error" do
CustomEmoji.create!(name: "test", upload: upload)
post "/admin/config/emoji.json",
@@ -92,7 +92,7 @@ RSpec.describe Admin::EmojiController do
end
end
- it "should allow an admin to add a custom emoji" do
+ it "allows an admin to add a custom emoji" do
Emoji.expects(:clear_cache)
post "/admin/config/emoji.json",
@@ -115,7 +115,7 @@ RSpec.describe Admin::EmojiController do
expect(custom_emoji.user_id).to eq(admin.id)
end
- it "should log the action" do
+ it "logs the action" do
Emoji.expects(:clear_cache)
post "/admin/config/emoji.json",
@@ -131,7 +131,7 @@ RSpec.describe Admin::EmojiController do
expect(last_log.new_value).to eq("test")
end
- it "should allow an admin to add a custom emoji with a custom group" do
+ it "allows an admin to add a custom emoji with a custom group" do
Emoji.expects(:clear_cache)
post "/admin/config/emoji.json",
@@ -147,7 +147,7 @@ RSpec.describe Admin::EmojiController do
expect(custom_emoji.group).to eq("foo")
end
- it "should allow an admin to add a custom SVG emoji" do
+ it "allows an admin to add a custom SVG emoji" do
Emoji.expects(:clear_cache)
post "/admin/config/emoji.json",
@@ -165,7 +165,7 @@ RSpec.describe Admin::EmojiController do
expect(upload.extension).to eq("svg")
end
- it "should allow an admin to add a custom animated GIF emoji" do
+ it "allows an admin to add a custom animated GIF emoji" do
Emoji.expects(:clear_cache)
post "/admin/config/emoji.json",
@@ -183,7 +183,7 @@ RSpec.describe Admin::EmojiController do
expect(upload.extension).to eq("gif")
end
- it "should fix up the emoji name" do
+ it "normalizes the emoji name" do
Emoji.expects(:clear_cache).times(3)
post "/admin/config/emoji.json",
@@ -621,7 +621,7 @@ RSpec.describe Admin::EmojiController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should allow an admin to delete a custom emoji" do
+ it "allows an admin to delete a custom emoji" do
custom_emoji = CustomEmoji.create!(name: "test", upload: upload)
Emoji.clear_cache
@@ -633,7 +633,7 @@ RSpec.describe Admin::EmojiController do
expect(response.parsed_body["success"]).to eq("OK")
end
- it "should log the action" do
+ it "logs the action" do
custom_emoji = CustomEmoji.create!(name: "test", upload: upload)
Emoji.clear_cache
diff --git a/spec/requests/admin/form_templates_controller_spec.rb b/spec/requests/admin/form_templates_controller_spec.rb
index c19fcd06771..c10e8c171f3 100644
--- a/spec/requests/admin/form_templates_controller_spec.rb
+++ b/spec/requests/admin/form_templates_controller_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Admin::FormTemplatesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should work if you are an admin" do
+ it "allows an administrator to create a form template" do
get "/admin/customize/form-templates.json"
expect(response.status).to eq(200)
@@ -21,7 +21,7 @@ RSpec.describe Admin::FormTemplatesController do
context "when logged in as a non-admin user" do
before { sign_in(user) }
- it "should not work if you are not an admin" do
+ it "forbids a non-administrator from creating a form template" do
get "/admin/customize/form-templates.json"
expect(response.status).to eq(404)
@@ -34,7 +34,7 @@ RSpec.describe Admin::FormTemplatesController do
SiteSetting.enable_form_templates = false
end
- it "should not work if you are an admin" do
+ it "rejects an invalid form template" do
get "/admin/customize/form-templates.json"
expect(response.status).to eq(403)
@@ -46,7 +46,7 @@ RSpec.describe Admin::FormTemplatesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should work if you are an admin" do
+ it "allows an administrator to update a form template" do
get "/admin/customize/form-templates/#{form_template.id}.json"
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/groups_controller_spec.rb b/spec/requests/admin/groups_controller_spec.rb
index 46cee9cb8ce..0c4a5dac482 100644
--- a/spec/requests/admin/groups_controller_spec.rb
+++ b/spec/requests/admin/groups_controller_spec.rb
@@ -234,7 +234,7 @@ RSpec.describe Admin::GroupsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should work" do
+ it "adds the user to the group" do
group.add_owner(user)
delete "/admin/groups/#{group.id}/owners.json", params: { user_id: user.id }
@@ -243,7 +243,7 @@ RSpec.describe Admin::GroupsController do
expect(group.group_users.where(owner: true)).to eq([])
end
- it "should work with multiple users" do
+ it "adds multiple users to the group" do
group.add_owner(user)
group.add_owner(user3)
@@ -429,7 +429,7 @@ RSpec.describe Admin::GroupsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should return the right response for an invalid group_id" do
+ it "returns an error for an invalid group ID" do
max_id = Group.maximum(:id).to_i
delete "/admin/groups/#{max_id + 1}.json"
expect(response.status).to eq(404)
diff --git a/spec/requests/admin/reports_controller_spec.rb b/spec/requests/admin/reports_controller_spec.rb
index 053219fc9d1..3a19cfefe6f 100644
--- a/spec/requests/admin/reports_controller_spec.rb
+++ b/spec/requests/admin/reports_controller_spec.rb
@@ -442,7 +442,7 @@ RSpec.describe Admin::ReportsController do
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:other_topic, :topic)
- it "should render the report as JSON" do
+ it "renders the report as JSON" do
get "/admin/reports/topics.json", params: { category_id: category.id }
expect(response.status).to eq(200)
@@ -459,7 +459,7 @@ RSpec.describe Admin::ReportsController do
fab!(:other_user, :user)
fab!(:group)
- it "should render the report as JSON" do
+ it "renders the report as JSON" do
group.add(user)
get "/admin/reports/signups.json", params: { group_id: group.id }
diff --git a/spec/requests/admin/site_settings_controller_spec.rb b/spec/requests/admin/site_settings_controller_spec.rb
index bd9922f3fc2..bd9370b20fb 100644
--- a/spec/requests/admin/site_settings_controller_spec.rb
+++ b/spec/requests/admin/site_settings_controller_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.status).to eq(404)
end
- it "should return correct user count for default categories change" do
+ it "returns the affected user count for a default-category change" do
category_id = Fabricate(:category).id
put "/admin/site_settings/default_categories_watching/user_count.json",
@@ -95,7 +95,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.parsed_body["user_count"]).to eq(User.real.where(staged: false).count - 1)
end
- it "should return correct user count for default tags change" do
+ it "returns the affected user count for a default-tag change" do
tag = Fabricate(:tag)
put "/admin/site_settings/default_tags_watching/user_count.json",
@@ -181,7 +181,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.parsed_body["user_count"]).to eq(1)
end
- it "should return correct user count for boolean setting" do
+ it "returns the affected user count for a boolean setting" do
expect_user_count(
site_setting_name: "default_other_external_links_in_new_tab",
user_setting_name: "external_links_in_new_tab",
@@ -190,7 +190,7 @@ RSpec.describe Admin::SiteSettingsController do
)
end
- it "should return correct user count for 'text_size_key'" do
+ it "returns the affected user count for text_size_key" do
expect_user_count(
site_setting_name: "default_text_size",
user_setting_name: "text_size_key",
@@ -201,7 +201,7 @@ RSpec.describe Admin::SiteSettingsController do
)
end
- it "should return correct user count for 'title_count_mode_key'" do
+ it "returns the affected user count for title_count_mode_key" do
expect_user_count(
site_setting_name: "default_title_count_mode",
user_setting_name: "title_count_mode_key",
@@ -355,7 +355,7 @@ RSpec.describe Admin::SiteSettingsController do
let!(:user1) { Fabricate(:user) }
let!(:user2) { Fabricate(:user) }
- it "should update all existing user options" do
+ it "updates every existing user option" do
SiteSetting.default_email_in_reply_to = true
user2.user_option.email_in_reply_to = true
@@ -371,7 +371,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(user2.user_option.email_in_reply_to).to eq(false)
end
- it "should not update existing user options" do
+ it "does not update existing user options" do
expect {
put "/admin/site_settings/default_email_in_reply_to.json",
params: {
@@ -380,7 +380,7 @@ RSpec.describe Admin::SiteSettingsController do
}.not_to change { UserOption.where(email_in_reply_to: false).count }
end
- it "should update `email_digests` column in existing user options" do
+ it "updates email_digests in existing user options" do
UserOption.last.update(email_digests: false)
expect {
@@ -475,7 +475,7 @@ RSpec.describe Admin::SiteSettingsController do
)
end
- it "should update existing users user preference" do
+ it "updates existing users' category preferences" do
put "/admin/site_settings/default_categories_watching.json",
params: {
default_categories_watching: category_ids.last(2).join("|"),
@@ -510,7 +510,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.status).to eq(204)
end
- it "should not update existing users user preference" do
+ it "does not update existing users' category preferences" do
expect {
put "/admin/site_settings/default_categories_watching.json",
params: {
@@ -548,7 +548,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.status).to eq(204)
end
- it "should publish a MessageBus informing the correct groups" do
+ it "publishes the affected groups through MessageBus" do
messages =
MessageBus.track_publish("/site_setting/default_categories_watching/process") do
put "/admin/site_settings/default_categories_watching.json",
@@ -577,7 +577,7 @@ RSpec.describe Admin::SiteSettingsController do
TagUser.create!(tag_id: tags.last.id, notification_level: tracking, user: user2)
end
- it "should update existing users user preference" do
+ it "updates existing users' tag preferences" do
put "/admin/site_settings/default_tags_watching.json",
params: {
default_tags_watching: tags.last(2).pluck(:name).join("|"),
@@ -596,7 +596,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.status).to eq(204)
end
- it "should not update existing users user preference" do
+ it "does not update existing users' tag preferences" do
expect {
put "/admin/site_settings/default_tags_watching.json",
params: {
@@ -618,7 +618,7 @@ RSpec.describe Admin::SiteSettingsController do
expect(response.status).to eq(204)
end
- it "should publish a MessageBus informing the correct groups" do
+ it "publishes the affected groups through MessageBus" do
messages =
MessageBus.track_publish("/site_setting/default_tags_watching/process") do
put "/admin/site_settings/default_tags_watching.json",
diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rb
index e543743cbaf..0350a828a01 100644
--- a/spec/requests/admin/themes_controller_spec.rb
+++ b/spec/requests/admin/themes_controller_spec.rb
@@ -246,13 +246,13 @@ RSpec.describe Admin::ThemesController do
)
end
- it "fails to import with a failing status" do
+ it "returns 422 for a nonexistent remote theme" do
post "/admin/themes/import.json", params: { remote: "non-existent" }
expect(response.status).to eq(422)
end
- it "fails to import with a failing status" do
+ it "returns 422 for an excessively long remote URL" do
post "/admin/themes/import.json", params: { remote: "https://#{"a" * 10_000}.com" }
expect(response.status).to eq(422)
@@ -1261,7 +1261,7 @@ RSpec.describe Admin::ThemesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should return the right response when an invalid id is given" do
+ it "rejects an invalid theme ID" do
get "/admin/themes/9999/preview.json"
expect(response.status).to eq(400)
@@ -1303,7 +1303,7 @@ RSpec.describe Admin::ThemesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should update a theme setting" do
+ it "updates a theme setting" do
put "/admin/themes/#{theme.id}/setting.json", params: { name: "bg", value: "green" }
expect(response.status).to eq(200)
@@ -1316,7 +1316,7 @@ RSpec.describe Admin::ThemesController do
expect(user_history.action).to eq(UserHistory.actions[:change_theme_setting])
end
- it "should return the right error when value used to update a theme setting of `objects` typed is invalid" do
+ it "returns an error for an invalid objects setting value" do
theme.set_field(
target: :settings,
name: "yaml",
@@ -1341,7 +1341,7 @@ RSpec.describe Admin::ThemesController do
)
end
- it "should be able to update a theme setting of `objects` typed" do
+ it "updates an objects theme setting" do
theme.set_field(
target: :settings,
name: "yaml",
@@ -1371,7 +1371,7 @@ RSpec.describe Admin::ThemesController do
)
end
- it "should clear a theme setting" do
+ it "clears a theme setting" do
put "/admin/themes/#{theme.id}/setting.json", params: { name: "bg" }
theme.reload
@@ -1425,7 +1425,7 @@ RSpec.describe Admin::ThemesController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should update a theme translation" do
+ it "updates a theme translation" do
put "/admin/themes/#{theme.id}.json",
params: {
theme: {
@@ -1439,7 +1439,7 @@ RSpec.describe Admin::ThemesController do
theme.reload.translations.map { |t| expect(t.value).to eq("Hello there! updated") }
end
- it "should update a theme translation with locale" do
+ it "updates a theme translation for the requested locale" do
put "/admin/themes/#{theme.id}.json",
params: {
theme: {
@@ -1454,7 +1454,7 @@ RSpec.describe Admin::ThemesController do
theme.reload.translations.map { |t| expect(t.value).to eq("Hello there! updated") }
end
- it "should fail update a theme translation when locale is wrong" do
+ it "rejects a theme translation with an invalid locale" do
put "/admin/themes/#{theme.id}.json",
params: {
theme: {
@@ -1471,7 +1471,7 @@ RSpec.describe Admin::ThemesController do
)
end
- it "should update other locale and do not change current one" do
+ it "updates another locale without changing the current locale" do
put "/admin/themes/#{theme.id}.json",
params: {
theme: {
diff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rb
index 95dc14dbef3..7e3149e93da 100644
--- a/spec/requests/admin/users_controller_spec.rb
+++ b/spec/requests/admin/users_controller_spec.rb
@@ -679,7 +679,7 @@ RSpec.describe Admin::UsersController do
expect(response.status).to eq(200)
end
- it "won't delete a category topic" do
+ it "preserves category topics" do
c = Fabricate(:category_with_definition)
cat_post = c.topic.posts.first
put(
@@ -691,7 +691,7 @@ RSpec.describe Admin::UsersController do
expect(response.status).to eq(200)
end
- it "won't delete a category topic by replies" do
+ it "preserves category topics when deleting replies" do
c = Fabricate(:category_with_definition)
cat_post = c.topic.posts.first
put(
@@ -2038,7 +2038,7 @@ RSpec.describe Admin::UsersController do
expect(reg_user.active).to eq(true)
end
- it "should confirm email even when the tokens are expired" do
+ it "confirms email even when the tokens are expired" do
reg_user.email_tokens.update_all(confirmed: false, expired: true)
reg_user.reload
@@ -2233,7 +2233,7 @@ RSpec.describe Admin::UsersController do
expect(reg_user).to be_silenced
end
- it "will set a length of time if provided" do
+ it "sets the provided duration" do
future_date = 1.month.from_now.to_date
put "/admin/users/#{reg_user.id}/silence.json",
params: {
@@ -2247,7 +2247,7 @@ RSpec.describe Admin::UsersController do
expect(reg_user.silenced_till).to eq(future_date)
end
- it "will send a message if provided" do
+ it "sends the provided message" do
expect do
put "/admin/users/#{reg_user.id}/silence.json",
params: {
@@ -2575,7 +2575,7 @@ RSpec.describe Admin::UsersController do
describe "#delete_other_accounts_with_same_ip" do
shared_examples "deleting other accounts with same ip possible" do
- it "works" do
+ it "deletes other accounts with the same IP while preserving the target user" do
target_user = Fabricate(:user, ip_address: "42.42.42.42")
user_a = Fabricate(:user, ip_address: "42.42.42.42")
user_b = Fabricate(:user, ip_address: "42.42.42.42")
@@ -2734,7 +2734,7 @@ RSpec.describe Admin::UsersController do
expect(User.find_by(username: "bob").name).to eq("Bob~~~")
end
- it "should create new users" do
+ it "creates new users" do
sso.name = "Dr. Claw"
sso.username = "dr_claw"
sso.email = "[email protected]"
@@ -2766,7 +2766,7 @@ RSpec.describe Admin::UsersController do
expect(events).to include(event_name: :sync_sso, params: [user])
end
- it "should return the right message if the record is invalid" do
+ it "returns an error for an invalid record" do
sso.email = ""
sso.name = ""
sso.external_id = "1"
@@ -2776,7 +2776,7 @@ RSpec.describe Admin::UsersController do
expect(response.parsed_body["message"]).to include("Primary email can't be blank")
end
- it "should return the right message if the signature is invalid" do
+ it "returns an error for an invalid signature" do
sso.name = "Dr. Claw"
sso.username = "dr_claw"
sso.email = "[email protected]"
@@ -2870,7 +2870,7 @@ RSpec.describe Admin::UsersController do
expect(user.reload.user_second_factors.totps.first).to eq(second_factor)
end
- it "should able to disable the second factor for another user" do
+ it "disables second factor for another user" do
expect do put "/admin/users/#{user.id}/disable_second_factor.json" end.to change {
Jobs::CriticalUserEmail.jobs.length
}.by(1)
@@ -2885,14 +2885,14 @@ RSpec.describe Admin::UsersController do
expect(job_args["type"]).to eq("account_second_factor_disabled")
end
- it "should not be able to disable the second factor for the current user" do
+ it "rejects disabling second factor for the current user" do
put "/admin/users/#{admin.id}/disable_second_factor.json"
expect(response.status).to eq(403)
end
describe "when user has only one second factor type enabled" do
- it "should succeed with security keys" do
+ it "disables security key authentication" do
user.user_second_factors.destroy_all
put "/admin/users/#{user.id}/disable_second_factor.json"
@@ -2900,7 +2900,7 @@ RSpec.describe Admin::UsersController do
expect(response.status).to eq(200)
end
- it "should succeed with totp" do
+ it "disables TOTP authentication" do
user.security_keys.destroy_all
put "/admin/users/#{user.id}/disable_second_factor.json"
@@ -2910,7 +2910,7 @@ RSpec.describe Admin::UsersController do
end
describe "when user does not have second factor enabled" do
- it "should raise the right error" do
+ it "returns 400 when second factor is not enabled" do
user.user_second_factors.destroy_all
user.security_keys.destroy_all
@@ -3010,7 +3010,7 @@ RSpec.describe Admin::UsersController do
describe "#delete_posts_batch" do
shared_examples "post batch deletion possible" do
context "when user is is invalid" do
- it "should return the right response" do
+ it "returns 404 for an invalid user" do
put "/admin/users/nothing/delete_posts_batch.json"
expect(response.status).to eq(404)
@@ -3192,7 +3192,7 @@ RSpec.describe Admin::UsersController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should merge source user to target user" do
+ it "merges the source user into the target user" do
Jobs.run_immediately!
post "/admin/users/#{user.id}/merge.json", params: { target_username: target_user.username }
@@ -3342,7 +3342,7 @@ RSpec.describe Admin::UsersController do
describe "#anonymize" do
shared_examples "user anonymization possible" do
- it "will make the user anonymous" do
+ it "anonymizes the user" do
put "/admin/users/#{user.id}/anonymize.json"
expect(response.status).to eq(200)
expect(response.parsed_body["username"]).to be_present
@@ -3389,7 +3389,7 @@ RSpec.describe Admin::UsersController do
context "when logged in as a moderator" do
before { sign_in(moderator) }
- it "will reset the bounce score" do
+ it "resets the bounce score" do
post "/admin/users/#{user.id}/reset-bounce-score.json"
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/versions_controller_spec.rb b/spec/requests/admin/versions_controller_spec.rb
index 2396c350d74..ca974010947 100644
--- a/spec/requests/admin/versions_controller_spec.rb
+++ b/spec/requests/admin/versions_controller_spec.rb
@@ -13,14 +13,14 @@ RSpec.describe Admin::VersionsController do
describe "#show" do
shared_examples "version info accessible" do
- it "should return the currently available version" do
+ it "returns the currently available version" do
get "/admin/version_check.json"
expect(response.status).to eq(200)
json = response.parsed_body
expect(json["latest_version"]).to eq("1.2.33")
end
- it "should return the installed version" do
+ it "returns the installed version" do
get "/admin/version_check.json"
json = response.parsed_body
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/watched_words_controller_spec.rb b/spec/requests/admin/watched_words_controller_spec.rb
index 7ff15d6d6b2..1ffd29c5dd2 100644
--- a/spec/requests/admin/watched_words_controller_spec.rb
+++ b/spec/requests/admin/watched_words_controller_spec.rb
@@ -73,13 +73,13 @@ RSpec.describe Admin::WatchedWordsController do
context "when logged in as staff user" do
before { sign_in(admin) }
- it "should return the right response when given an invalid id param" do
+ it "rejects an invalid watched word ID" do
delete "/admin/customize/watched_words/9999.json"
expect(response.status).to eq(400)
end
- it "should be able to delete a watched word" do
+ it "deletes the watched word" do
delete "/admin/customize/watched_words/#{watched_word.id}.json"
expect(response.status).to eq(200)
@@ -87,7 +87,7 @@ RSpec.describe Admin::WatchedWordsController do
expect(UserHistory.where(action: UserHistory.actions[:watched_word_destroy]).count).to eq(1)
end
- it "should delete watched word group if it's the last word" do
+ it "deletes the watched word group after its last word is removed" do
watched_word_group = Fabricate(:watched_word_group)
watched_word = watched_word_group.watched_words.first
@@ -228,7 +228,7 @@ RSpec.describe Admin::WatchedWordsController do
Fabricate(:tag, name: "tag3")
end
- it "creates the words from the file" do
+ it "imports flagged words from the CSV file" do
post "/admin/customize/watched_words/upload.json",
params: {
action_key: "flag",
@@ -251,7 +251,7 @@ RSpec.describe Admin::WatchedWordsController do
expect(UserHistory.where(action: UserHistory.actions[:watched_word_create]).count).to eq(6)
end
- it "creates the words from the file" do
+ it "imports tagged words and replacements from the CSV file" do
post "/admin/customize/watched_words/upload.json",
params: {
action_key: "tag",
diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index 9d701f06a06..95fda889483 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -134,18 +134,18 @@ RSpec.describe ApplicationController do
SiteSetting.login_required = true
end
- it "should never cache a login redirect" do
+ it "does not cache login redirects" do
get "/"
expect(response.headers["Cache-Control"]).to eq("no-cache, no-store")
end
- it "should not redirect to login" do
+ it "does not redirect to login" do
get "/"
expect(response).not_to redirect_to("/login")
expect(response.status).to eq(200)
end
- it "should redirect to SSO if enabled" do
+ it "redirects to SSO when enabled" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -153,7 +153,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/session/sso")
end
- it "should redirect to authenticator if only one, and local logins disabled" do
+ it "redirects to the sole authenticator when local logins are disabled" do
# Local logins and google enabled, show login UI
SiteSetting.enable_google_oauth2_logins = true
get "/"
@@ -172,7 +172,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should not redirect to SSO when auth_immediately is disabled" do
+ it "does not redirect to SSO when auth_immediately is disabled" do
SiteSetting.auth_immediately = false
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
@@ -183,7 +183,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should not redirect to authenticator when auth_immediately is disabled" do
+ it "does not redirect to the authenticator when auth_immediately is disabled" do
SiteSetting.auth_immediately = false
SiteSetting.enable_google_oauth2_logins = true
SiteSetting.enable_local_logins = false
@@ -213,7 +213,7 @@ RSpec.describe ApplicationController do
OmniAuth.config.test_mode = false
end
- it "should not redirect to authenticator if registration in progress" do
+ it "does not redirect to the authenticator during registration" do
SiteSetting.enable_local_logins = false
SiteSetting.enable_google_oauth2_logins = true
@@ -267,7 +267,7 @@ RSpec.describe ApplicationController do
admin # to skip welcome wizard at home page `/`
end
- it "should redirect admins when enforce_second_factor is 'all'" do
+ it "redirects admins when second factor is enforced for everyone" do
SiteSetting.enforce_second_factor = "all"
sign_in(admin)
@@ -275,7 +275,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/u/#{admin.username}/preferences/second-factor")
end
- it "should properly redirect admins when enforce_second_factor is 'all' in subfolder" do
+ it "includes the subfolder when redirecting admins for enforced second factor" do
set_subfolder "/forum"
SiteSetting.enforce_second_factor = "all"
sign_in(admin)
@@ -284,7 +284,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/forum/u/#{admin.username}/preferences/second-factor")
end
- it "should redirect users when enforce_second_factor is 'all'" do
+ it "redirects users when second factor is enforced for everyone" do
SiteSetting.enforce_second_factor = "all"
sign_in(user)
@@ -292,7 +292,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/u/#{user.username}/preferences/second-factor")
end
- it "should redirect users when enforce_second_factor is 'all' and authenticated via oauth" do
+ it "redirects OAuth users when second factor is enforced for everyone" do
SiteSetting.enforce_second_factor = "all"
sign_in(user)
user.user_auth_tokens.last.update(authenticated_with_oauth: true)
@@ -301,7 +301,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/u/#{user.username}/preferences/second-factor")
end
- it "should not redirect users when enforce_second_factor is 'all', authenticated via oauth but enforce_second_factor_on_external_auth is false" do
+ it "exempts OAuth users when second factor enforcement excludes external authentication" do
SiteSetting.enforce_second_factor = "all"
SiteSetting.enforce_second_factor_on_external_auth = false
sign_in(user)
@@ -311,7 +311,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should not redirect anonymous users when enforce_second_factor is 'all'" do
+ it "does not redirect anonymous users for enforced second factor" do
SiteSetting.enforce_second_factor = "all"
SiteSetting.allow_anonymous_mode = true
@@ -324,7 +324,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should redirect admins when enforce_second_factor is 'staff'" do
+ it "redirects admins when second factor is enforced for staff" do
SiteSetting.enforce_second_factor = "staff"
sign_in(admin)
@@ -332,7 +332,7 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/u/#{admin.username}/preferences/second-factor")
end
- it "should not redirect users when enforce_second_factor is 'staff'" do
+ it "does not redirect regular users when second factor is enforced for staff" do
SiteSetting.enforce_second_factor = "staff"
sign_in(user)
@@ -340,7 +340,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should not redirect admins when turned off" do
+ it "does not redirect admins when enforcement is disabled" do
SiteSetting.enforce_second_factor = "no"
sign_in(admin)
@@ -348,7 +348,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(200)
end
- it "should not redirect users when turned off" do
+ it "does not redirect users when enforcement is disabled" do
SiteSetting.enforce_second_factor = "no"
sign_in(user)
@@ -444,7 +444,7 @@ RSpec.describe ApplicationController do
after { Rails.logger.stop_broadcasting_to(fake_logger) }
- it "should not raise a 500 (nor should it log a warning) for bad params" do
+ it "handles invalid parameters without a 500 response or warning" do
bad_str = (+"d\xDE").force_encoding("utf-8")
expect(bad_str.valid_encoding?).to eq(false)
@@ -458,7 +458,7 @@ RSpec.describe ApplicationController do
end
describe "missing required param" do
- it "should return a 400" do
+ it "returns 400" do
get "/search/query.json", params: { trem: "misspelled term" }
expect(response.status).to eq(400)
@@ -470,7 +470,7 @@ RSpec.describe ApplicationController do
describe "build_not_found_page" do
describe "topic not found" do
- it "should not redirect to permalink if topic/category does not exist" do
+ it "does not redirect to a permalink for a missing topic or category" do
topic = create_post.topic
Permalink.create!(url: topic.relative_url, topic_id: topic.id + 1)
topic.trash!
@@ -484,7 +484,7 @@ RSpec.describe ApplicationController do
expect(response.status).to eq(410)
end
- it "should return permalink for deleted topics" do
+ it "returns the permalink for deleted topics" do
topic = create_post.topic
external_url = "https://somewhere.over.rainbow"
Permalink.create!(url: topic.relative_url, external_url: external_url)
@@ -533,7 +533,7 @@ RSpec.describe ApplicationController do
)
end
- it "should return 404 and show Google search for an invalid topic route" do
+ it "returns 404 with Google search for an invalid topic route" do
get "/t/nope-nope/99999999"
expect(response.status).to eq(404)
@@ -544,7 +544,7 @@ RSpec.describe ApplicationController do
expect(response_body).to have_tag("input", with: { value: "nope nope" })
end
- it "should not include Google search if login_required is enabled" do
+ it "omits Google search when login is required" do
SiteSetting.login_required = true
sign_in(Fabricate(:user))
get "/t/nope-nope/99999999"
@@ -561,7 +561,7 @@ RSpec.describe ApplicationController do
expect(response.body).not_to include(I18n.t("page_not_found.search_title"))
end
- it "should allow anchor tags in title" do
+ it "allows anchor tags in the title" do
TranslationOverride.upsert!(
I18n.locale,
"page_not_found.title",
@@ -573,7 +573,7 @@ RSpec.describe ApplicationController do
expect(response.body).to include('<a href="/search">search</a>')
end
- it "should sanitize unsafe HTML in title" do
+ it "sanitizes unsafe HTML in the title" do
TranslationOverride.upsert!(
I18n.locale,
"page_not_found.title",
@@ -593,7 +593,7 @@ RSpec.describe ApplicationController do
after { Rails.logger.stop_broadcasting_to(fake_logger) }
- it "should handle 404 to a css file" do
+ it "handles a missing CSS file" do
Discourse.cache.delete("page_not_found_topics:#{I18n.locale}")
topic1 = Fabricate(:topic)
@@ -618,7 +618,7 @@ RSpec.describe ApplicationController do
expect(fake_logger.warnings.length).to eq(0)
end
- it "should render category badges with correct style classes on 404 page" do
+ it "renders category badge style classes on the 404 page" do
Discourse.cache.delete("page_not_found_topics:#{I18n.locale}")
square_cat = Fabricate(:category, style_type: :square)
@@ -694,7 +694,7 @@ RSpec.describe ApplicationController do
end
end
- it "should cache results" do
+ it "caches results" do
Discourse.cache.delete("page_not_found_topics:#{I18n.locale}")
Discourse.cache.delete("page_not_found_topics:fr")
@@ -800,12 +800,12 @@ RSpec.describe ApplicationController do
end
describe "allow_embedding_site_in_an_iframe" do
- it "should have the 'X-Frame-Options' header with value 'sameorigin'" do
+ it "sets X-Frame-Options to sameorigin" do
get("/latest")
expect(response.headers["X-Frame-Options"]).to eq("SAMEORIGIN")
end
- it "should not include the 'X-Frame-Options' header" do
+ it "omits the X-Frame-Options header" do
SiteSetting.allow_embedding_site_in_an_iframe = true
get("/latest")
expect(response.headers).not_to include("X-Frame-Options")
@@ -1436,7 +1436,7 @@ RSpec.describe ApplicationController do
end
context "with a logged in user" do
- it "it uses the default locale" do
+ it "uses the default locale" do
user = Fabricate(:user, locale: :fr)
sign_in(user)
diff --git a/spec/requests/associate_accounts_controller_spec.rb b/spec/requests/associate_accounts_controller_spec.rb
index 3b92af9f434..cf8854d36f2 100644
--- a/spec/requests/associate_accounts_controller_spec.rb
+++ b/spec/requests/associate_accounts_controller_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe Users::AssociateAccountsController do
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
end
- it "should work correctly" do
+ it "associates the external account" do
sign_in(user)
# Reconnect flow:
@@ -70,7 +70,7 @@ RSpec.describe Users::AssociateAccountsController do
expect(response.status).to eq(404)
end
- it "should only work within the current session" do
+ it "restricts association to the current session" do
sign_in(user)
post "/auth/google_oauth2?reconnect=true"
diff --git a/spec/requests/badges_controller_spec.rb b/spec/requests/badges_controller_spec.rb
index 5611d35d7c7..4642119b345 100644
--- a/spec/requests/badges_controller_spec.rb
+++ b/spec/requests/badges_controller_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe BadgesController do
before { SiteSetting.enable_badges = true }
describe "#index" do
- it "should return a list of all badges" do
+ it "returns all badges" do
get "/badges.json"
expect(response.status).to eq(200)
@@ -125,14 +125,14 @@ RSpec.describe BadgesController do
end
describe "#show" do
- it "should return a badge" do
+ it "returns the badge" do
get "/badges/#{badge.id}.json"
expect(response.status).to eq(200)
parsed = response.parsed_body
expect(parsed["badge"]).to be_present
end
- it "should mark the notification as viewed" do
+ it "marks the notification as viewed" do
sign_in(user)
user_badge = BadgeGranter.grant(badge, user)
expect(user_badge.notification.read).to eq(false)
diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb
index 6b96b2b30e5..bddd4a16190 100644
--- a/spec/requests/categories_controller_spec.rb
+++ b/spec/requests/categories_controller_spec.rb
@@ -620,7 +620,7 @@ RSpec.describe CategoriesController do
end
describe "success" do
- it "works" do
+ it "creates the category with group permissions" do
SiteSetting.enable_category_group_moderation = true
readonly = CategoryGroup.permission_types[:readonly]
@@ -741,7 +741,7 @@ RSpec.describe CategoriesController do
expect(SiteSetting.max_category_nesting).to eq(3)
end
- it "will set the schema value for site settings when overrides are not provided" do
+ it "uses the schema value when no site-setting override is provided" do
SiteSetting.max_category_nesting = 3
Categories::Types::Discussion.stubs(:configuration_schema).returns(
{ site_settings: { max_category_nesting: 2 } },
@@ -2391,7 +2391,7 @@ RSpec.describe CategoriesController do
context "when in readonly mode" do
before { Discourse.enable_readonly_mode }
- it "works" do
+ it "returns category search results in read-only mode" do
post "/categories/search.json", params: { term: "" }
expect(response.status).to eq(200)
diff --git a/spec/requests/directory_items_controller_spec.rb b/spec/requests/directory_items_controller_spec.rb
index 936a7f69a43..f372d7e8f71 100644
--- a/spec/requests/directory_items_controller_spec.rb
+++ b/spec/requests/directory_items_controller_spec.rb
@@ -142,7 +142,7 @@ RSpec.describe DirectoryItemsController do
context "with a logged in user" do
before { sign_in(user) }
- it "succeeds" do
+ it "returns 200 when the directory has no data" do
get "/directory_items.json", params: { period: "all" }
expect(response.status).to eq(200)
end
diff --git a/spec/requests/do_not_disturb_controller_spec.rb b/spec/requests/do_not_disturb_controller_spec.rb
index 9a52b14047f..ea448b6f37c 100644
--- a/spec/requests/do_not_disturb_controller_spec.rb
+++ b/spec/requests/do_not_disturb_controller_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe DoNotDisturbController do
expect(response.status).to eq(400)
end
- it "works properly with integer minute durations" do
+ it "accepts a positive integer minute duration" do
freeze_time
post "/do-not-disturb.json", params: { duration: 30 }
@@ -24,7 +24,7 @@ RSpec.describe DoNotDisturbController do
expect(user.do_not_disturb_timings.last.ends_at).to eq_time(30.minutes.from_now)
end
- it "works properly with integer minute durations" do
+ it "rejects a negative integer minute duration" do
post "/do-not-disturb.json", params: { duration: -30 }
expect(response.status).to eq(422)
expect(response.parsed_body).to eq({ "errors" => ["Ends at is invalid"] })
diff --git a/spec/requests/email_controller_spec.rb b/spec/requests/email_controller_spec.rb
index 380c88beaf4..c64412f4f51 100644
--- a/spec/requests/email_controller_spec.rb
+++ b/spec/requests/email_controller_spec.rb
@@ -202,7 +202,7 @@ RSpec.describe EmailController do
describe "#unsubscribed" do
describe "when email is invalid" do
- it "should return the right response" do
+ it "returns an invalid-email response" do
get "/email/unsubscribed", params: { email: "somerandomstring" }
expect(response.status).to eq(404)
end
@@ -211,7 +211,7 @@ RSpec.describe EmailController do
describe "when topic is public" do
fab!(:topic)
- it "should return the right response" do
+ it "returns the public topic details" do
key = SecureRandom.hex
Discourse.cache.write(key, user.email)
get "/email/unsubscribed", params: { key: key, topic_id: topic.id }
@@ -223,7 +223,7 @@ RSpec.describe EmailController do
describe "when topic is private" do
fab!(:private_topic, :private_message_topic)
- it "should return the right response" do
+ it "does not expose the private topic" do
key = SecureRandom.hex
Discourse.cache.write(key, user.email)
get "/email/unsubscribed", params: { key: key, topic_id: private_topic.id }
diff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rb
index c0e98396dc3..b51e1aed7b9 100644
--- a/spec/requests/embed_controller_spec.rb
+++ b/spec/requests/embed_controller_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe EmbedController do
describe "#info" do
context "without api key" do
- it "fails" do
+ it "returns an embed error without an API key" do
get "/embed/info.json"
expect(response.body).to match(I18n.t("embed.error"))
diff --git a/spec/requests/exceptions_controller_spec.rb b/spec/requests/exceptions_controller_spec.rb
index 45efffe151f..e5307576aa1 100644
--- a/spec/requests/exceptions_controller_spec.rb
+++ b/spec/requests/exceptions_controller_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe ExceptionsController do
describe "#not_found" do
- it "should return the right response" do
+ it "renders the not-found page" do
get "/404"
expect(response.status).to eq(404)
@@ -18,7 +18,7 @@ RSpec.describe ExceptionsController do
describe "text site logo" do
before { SiteSetting.logo = "" }
- it "should return the right response" do
+ it "renders the not-found page with the text logo" do
get "/404"
expect(response.status).to eq(404)
diff --git a/spec/requests/export_csv_controller_spec.rb b/spec/requests/export_csv_controller_spec.rb
index 22cf1a186aa..b50c9d44e40 100644
--- a/spec/requests/export_csv_controller_spec.rb
+++ b/spec/requests/export_csv_controller_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe ExportCsvController do
expect(job_data["user_id"]).to eq(user.id)
end
- it "should not enqueue export job if rate limit is reached" do
+ it "does not enqueue an export job after reaching the rate limit" do
UserExport.create(file_name: "user-archive-codinghorror-150116-003249", user_id: user.id)
post "/export_csv/export_entity.json", params: { entity: "user_archive" }
expect(response.status).to eq(422)
@@ -127,7 +127,7 @@ RSpec.describe ExportCsvController do
expect(job_data["user_id"]).to eq(admin.id)
end
- it "should not rate limit export for staff" do
+ it "does not rate-limit exports for staff" do
UserExport.create(file_name: "screened-email-150116-010145", user_id: admin.id)
post "/export_csv/export_entity.json", params: { entity: "staff_action" }
expect(response.status).to eq(200)
diff --git a/spec/requests/extra_locales_controller_spec.rb b/spec/requests/extra_locales_controller_spec.rb
index 44d04b6cb50..448ae4054de 100644
--- a/spec/requests/extra_locales_controller_spec.rb
+++ b/spec/requests/extra_locales_controller_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe ExtraLocalesController do
let(:fake_digest) { "a" * 40 }
describe "#show" do
- it "won't work with a weird parameter" do
+ it "rejects an invalid parameter" do
get "/extra-locales/#{fake_digest}/en/-invalid..character!!.js"
expect(response.status).to eq(404)
end
@@ -238,7 +238,7 @@ RSpec.describe ExtraLocalesController do
end
describe ".url" do
- it "works" do
+ it "builds the locale bundle URL with a version digest" do
expect(ExtraLocalesController.url("admin")).to match(
%r{\A/extra-locales/\h{40}/en/admin\.js\z},
)
diff --git a/spec/requests/form_templates_controller_spec.rb b/spec/requests/form_templates_controller_spec.rb
index 6ae86134bc4..6b57f69ea3c 100644
--- a/spec/requests/form_templates_controller_spec.rb
+++ b/spec/requests/form_templates_controller_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe FormTemplatesController do
context "when logged in as a user" do
before { sign_in(user) }
- it "should return all form templates ordered by its ids" do
+ it "returns all form templates ordered by ID" do
get "/form-templates.json"
expect(response.status).to eq(200)
json = response.parsed_body
@@ -57,7 +57,7 @@ RSpec.describe FormTemplatesController do
end
context "when you are not logged in" do
- it "should deny access" do
+ it "denies access" do
get "/form-templates.json"
expect(response.status).to eq(403)
end
@@ -69,7 +69,7 @@ RSpec.describe FormTemplatesController do
SiteSetting.enable_form_templates = false
end
- it "should not work if you are a logged in user" do
+ it "rejects a logged-in user" do
get "/form-templates.json"
expect(response.status).to eq(403)
end
@@ -82,7 +82,7 @@ RSpec.describe FormTemplatesController do
context "when logged in as a user" do
before { sign_in(user) }
- it "should return a single template" do
+ it "returns one template" do
get "/form-templates/#{form_template.id}.json"
expect(response.status).to eq(200)
json = response.parsed_body
@@ -151,7 +151,7 @@ RSpec.describe FormTemplatesController do
sign_in(user)
end
- it "should return a single template with the correct data" do
+ it "returns one template with the expected data" do
get "/form-templates/#{tag_groups_form_template.id}.json"
expect(response.status).to eq(200)
json = response.parsed_body
@@ -186,7 +186,7 @@ RSpec.describe FormTemplatesController do
)
end
- it "should return a single template with the correct data in order" do
+ it "returns one template with ordered data" do
new_tag = Fabricate(:tag, description: "Custom Tag")
tag_group1.tags = [tag3, tag1, new_tag]
tag_group1.save
@@ -209,7 +209,7 @@ RSpec.describe FormTemplatesController do
end
context "when you are not logged in" do
- it "should deny access" do
+ it "denies access" do
get "/form-templates/#{form_template.id}.json"
expect(response.status).to eq(403)
end
@@ -221,7 +221,7 @@ RSpec.describe FormTemplatesController do
SiteSetting.enable_form_templates = false
end
- it "should not work if you are a logged in user" do
+ it "rejects a logged-in user" do
get "/form-templates/#{form_template.id}.json"
expect(response.status).to eq(403)
end
diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb
index cc5bf6367b5..cbc7944a928 100644
--- a/spec/requests/groups_controller_spec.rb
+++ b/spec/requests/groups_controller_spec.rb
@@ -53,26 +53,26 @@ RSpec.describe GroupsController do
context "when group directory is disabled" do
before { SiteSetting.enable_group_directory = false }
- it "should deny access for an anon" do
+ it "denies access to an anonymous user" do
get "/groups.json"
expect(response.status).to eq(403)
end
- it "should deny access for a normal user" do
+ it "denies access to a regular user" do
sign_in(user)
get "/groups.json"
expect(response.status).to eq(403)
end
- it "should allow access for an admin" do
+ it "allows access for an admin" do
sign_in(admin)
get "/groups.json"
expect(response.status).to eq(200)
end
- it "should allow access for a moderator" do
+ it "allows access for a moderator" do
sign_in(moderator)
get "/groups.json"
@@ -81,7 +81,7 @@ RSpec.describe GroupsController do
end
context "with searchable" do
- it "should return the searched groups" do
+ it "returns the matching groups" do
testing_group = Fabricate(:group, name: "testing")
get "/groups.json", params: { filter: "test" }
@@ -187,7 +187,7 @@ RSpec.describe GroupsController do
end
end
- it "should return the right response" do
+ it "returns the expected response" do
group
staff_group
@@ -230,7 +230,7 @@ RSpec.describe GroupsController do
context "when viewing groups of another user" do
describe "when an invalid username is given" do
- it "should return the right response" do
+ it "returns the expected response" do
group
get "/groups.json", params: { username: "asdasd" }
@@ -238,7 +238,7 @@ RSpec.describe GroupsController do
end
end
- it "should return the right response" do
+ it "returns the expected response" do
u = Fabricate(:user)
m = Fabricate(:user)
o = Fabricate(:user)
@@ -365,7 +365,7 @@ RSpec.describe GroupsController do
group.add_owner(admin)
end
- it "should return the right response" do
+ it "returns the expected response" do
staff_group
get "/groups.json"
@@ -401,13 +401,13 @@ RSpec.describe GroupsController do
end
describe "my groups" do
- it "should return the groups admin is a member of" do
+ it "returns groups the admin belongs to" do
expect_type_to_return_right_groups("my", admin.group_users.map(&:group_id))
end
end
describe "owner groups" do
- it "should return the groups admin is a owner of" do
+ it "returns groups the admin owns" do
group2 = Fabricate(:group)
_group3 = Fabricate(:group)
group2.add_owner(admin)
@@ -420,7 +420,7 @@ RSpec.describe GroupsController do
end
describe "automatic groups" do
- it "should return the right response" do
+ it "returns the expected response" do
expect_type_to_return_right_groups(
"automatic",
Group::AUTO_GROUP_IDS.keys -
@@ -434,14 +434,14 @@ RSpec.describe GroupsController do
end
describe "non automatic groups" do
- it "should return the right response" do
+ it "returns the expected response" do
group2 = Fabricate(:group)
expect_type_to_return_right_groups("non_automatic", [group.id, group2.id])
end
end
describe "public groups" do
- it "should return the right response" do
+ it "returns the expected response" do
group2 = Fabricate(:group, public_admission: true)
expect_type_to_return_right_groups("public", [group2.id])
@@ -449,7 +449,7 @@ RSpec.describe GroupsController do
end
describe "close groups" do
- it "should return the right response" do
+ it "returns the expected response" do
group2 = Fabricate(:group, public_admission: false)
_group3 = Fabricate(:group, public_admission: true)
@@ -549,7 +549,7 @@ RSpec.describe GroupsController do
end
end
- it "should respond to HTML" do
+ it "responds to HTML" do
group.update!(bio_raw: "testing **group** bio")
get "/groups/#{group.name}.html"
@@ -593,7 +593,7 @@ RSpec.describe GroupsController do
include_examples "group show behavior", "/groups", :name
describe "when viewing activity filters" do
- it "should return the right response" do
+ it "returns the expected response" do
get "/groups/#{group.name}/activity/posts.json"
expect(response.status).to eq(200)
@@ -929,7 +929,7 @@ RSpec.describe GroupsController do
end
end
- describe "#members" do
+ describe "#members membership changes" do
it "returns correct error code with invalid params" do
sign_in(user)
@@ -1156,7 +1156,7 @@ RSpec.describe GroupsController do
end
describe "#mentionable" do
- it "should return the right response" do
+ it "returns the expected response" do
sign_in(user)
group.update!(
@@ -1195,7 +1195,7 @@ RSpec.describe GroupsController do
end
describe "#messageable" do
- it "should return the right response" do
+ it "returns the expected response" do
user.change_trust_level!(1)
sign_in(user)
@@ -1296,7 +1296,7 @@ RSpec.describe GroupsController do
sign_in(user)
end
- it "should be able update the group" do
+ it "updates the group" do
group.update!(
allow_membership_requests: false,
visibility_level: 2,
@@ -1363,7 +1363,7 @@ RSpec.describe GroupsController do
expect(group.group_tag_notification_defaults.first&.tag).to eq(tag)
end
- it "should not clear group title when owner updates other settings" do
+ it "preserves the group title when an owner updates other settings" do
group.update!(title: "Original Title")
put "/groups/#{group.id}.json",
@@ -1382,7 +1382,7 @@ RSpec.describe GroupsController do
expect(group.flair_bg_color).to eq("FFF")
end
- it "should not allow group owner to modify the group title" do
+ it "does not allow a group owner to modify the title" do
group.update!(title: "Original Title")
put "/groups/#{group.id}.json",
@@ -1400,7 +1400,7 @@ RSpec.describe GroupsController do
expect(group.flair_bg_color).to eq("FFF")
end
- it "should not clear automatic_membership_email_domains when moderator owner updates group" do
+ it "preserves automatic membership domains when a moderator owner updates the group" do
SiteSetting.moderators_manage_groups = false
user.update!(moderator: true)
group.update!(automatic_membership_email_domains: "test.org")
@@ -1420,7 +1420,7 @@ RSpec.describe GroupsController do
expect(group.bio_raw).to eq("updated bio")
end
- it "should not be allowed to update automatic groups" do
+ it "does not allow automatic groups to be updated" do
group = Group.find(Group::AUTO_GROUPS[:admins])
put "/groups/#{group.id}.json", params: { group: { messageable_level: 1 } }
@@ -1432,7 +1432,7 @@ RSpec.describe GroupsController do
context "when user is group admin" do
before { sign_in(admin) }
- it "should be able to update the group" do
+ it "updates the group" do
group.update!(visibility_level: 2, members_visibility_level: 2, grant_trust_level: 0)
put "/groups/#{group.id}.json",
@@ -1530,7 +1530,7 @@ RSpec.describe GroupsController do
end
context "with user default notifications" do
- it "should update default notification preference for existing users" do
+ it "updates the default notification preference for existing users" do
group.update!(default_notification_level: NotificationLevels.all[:watching])
user1 = Fabricate(:user)
group.add(user1)
@@ -1594,7 +1594,7 @@ RSpec.describe GroupsController do
expect(group_user2.reload.notification_level).to eq(NotificationLevels.all[:tracking])
end
- it "should update category & tag notification preferences for existing users" do
+ it "updates category and tag notification preferences for existing users" do
user1 = Fabricate(:user)
CategoryUser.create!(user: user1, category: category, notification_level: 4)
TagUser.create!(user: user1, tag: tag, notification_level: 4)
@@ -1673,7 +1673,7 @@ RSpec.describe GroupsController do
sign_in(moderator)
end
- it "should not be able to update the group if the SiteSetting is false" do
+ it "does not update the group when the site setting is disabled" do
SiteSetting.moderators_manage_groups = false
put "/groups/#{group.id}.json", params: { group: { name: "testing" } }
@@ -1681,7 +1681,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(403)
end
- it "should not be able to update a group it cannot see" do
+ it "does not update a group the user cannot see" do
group.update!(visibility_level: Group.visibility_levels[:owners])
put "/groups/#{group.id}.json", params: { group: { name: "testing" } }
@@ -1689,7 +1689,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(403)
end
- it "should be able to update the group" do
+ it "updates the group" do
put "/groups/#{group.id}.json",
params: {
group: {
@@ -1768,7 +1768,7 @@ RSpec.describe GroupsController do
expect(group.allow_unknown_sender_topic_replies).to eq(false)
end
- it "should be able to update an automatic group" do
+ it "updates an automatic group" do
group = Group.find(Group::AUTO_GROUPS[:trust_level_4])
group.update!(mentionable_level: 2, messageable_level: 2, default_notification_level: 2)
@@ -1812,7 +1812,7 @@ RSpec.describe GroupsController do
end
context "when user is not a group owner or admin" do
- it "should not be able to update the group" do
+ it "does not update the group" do
sign_in(user)
put "/groups/#{group.id}.json", params: { group: { name: "testing" } }
@@ -1822,7 +1822,7 @@ RSpec.describe GroupsController do
end
end
- describe "#members" do
+ describe "#members listing" do
let(:user1) do
Fabricate(:user, last_seen_at: Time.zone.now, last_posted_at: 1.day.ago, email: "[email protected]")
end
@@ -1836,7 +1836,7 @@ RSpec.describe GroupsController do
fab!(:bot)
let(:group) { Fabricate(:group, users: [user1, user2, user3, bot]) }
- it "should allow members to be sorted by" do
+ it "allows members to be sorted by supported columns" do
get "/groups/#{group.name}/members.json", params: { order: "last_seen_at" }
expect(response.status).to eq(200)
@@ -1862,7 +1862,7 @@ RSpec.describe GroupsController do
expect(members.map { |m| m["id"] }).to eq([user2.id, user1.id, user3.id])
end
- it "should not allow members to be sorted by columns that are not allowed" do
+ it "rejects unsupported sort columns" do
get "/groups/#{group.name}/members.json", params: { order: "email" }
expect(response.status).to eq(200)
@@ -1888,7 +1888,7 @@ RSpec.describe GroupsController do
describe "filterable" do
describe "as a normal user" do
- it "should not allow members to be filterable by email" do
+ it "does not allow filtering members by email" do
user1.update!(email: email)
@@ -1903,7 +1903,7 @@ RSpec.describe GroupsController do
describe "as an admin" do
before { sign_in(admin) }
- it "should allow members to be filterable by username" do
+ it "allows filtering members by username" do
user1.update!(email: email)
@@ -1920,7 +1920,7 @@ RSpec.describe GroupsController do
end
end
- it "should allow members to be filterable by email" do
+ it "allows filtering members by email" do
username = "uniquetest"
user1.update!(username: username)
@@ -1940,7 +1940,7 @@ RSpec.describe GroupsController do
fab!(:group)
context "when user is not signed in" do
- it "should be forbidden" do
+ it "returns a forbidden response" do
put "/groups/#{group.id}/members.json", params: { usernames: "bob" }
expect(response).to be_forbidden
@@ -1949,7 +1949,7 @@ RSpec.describe GroupsController do
end
context "with public group" do
- it "should be forbidden" do
+ it "returns a forbidden response" do
group.update!(public_admission: true, public_exit: true)
put "/groups/#{group.id}/members.json", params: { usernames: "bob" }
@@ -2262,7 +2262,7 @@ RSpec.describe GroupsController do
end
end
- it "will send invites to each email with group_id set" do
+ it "sends invitations to each email with group_id set" do
put "/groups/#{group.id}/members.json", params: { emails: emails.join(",") }
@@ -2289,7 +2289,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(200)
end
- it "will find users by email, and invite the correct user" do
+ it "finds users by email and invites the matching user" do
new_user = Fabricate(:user)
expect(new_user.group_ids.include?(group.id)).to eq(false)
@@ -2298,7 +2298,7 @@ RSpec.describe GroupsController do
expect(new_user.reload.group_ids.include?(group.id)).to eq(true)
end
- it "will invite the user if their username and email are both invited" do
+ it "invites the user once when both username and email are supplied" do
new_user = Fabricate(:user)
put "/groups/#{group.id}/members.json",
params: {
@@ -2334,7 +2334,7 @@ RSpec.describe GroupsController do
context "when logged in as an admin" do
before { sign_in(admin) }
- it "should work" do
+ it "invites the user to the group" do
put "/groups/#{group.id}/owners.json",
params: {
usernames: [user.username, admin.username].join(","),
@@ -2492,7 +2492,7 @@ RSpec.describe GroupsController do
describe "#join" do
let(:public_group) { Fabricate(:public_group) }
- it "should allow a user to join a public group" do
+ it "allows a user to join a public group" do
sign_in(user)
expect do put "/groups/#{public_group.id}/join.json" end.to change {
@@ -2502,7 +2502,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(204)
end
- it "should not allow a user to join a public group they cannot see" do
+ it "does not allow joining a hidden public group" do
hidden_group =
Fabricate(
:public_group,
@@ -2523,7 +2523,7 @@ RSpec.describe GroupsController do
expect(user.reload.trust_level).to eq(TrustLevel[0])
end
- it "should not allow a user to join a nonpublic group" do
+ it "does not allow joining a nonpublic group" do
sign_in(user)
expect do put "/groups/#{group.id}/join.json" end.not_to change { group.users.count }
@@ -2531,7 +2531,7 @@ RSpec.describe GroupsController do
expect(response).to be_forbidden
end
- it "should not allow an anonymous user to call the join method" do
+ it "does not allow an anonymous user to join" do
expect do put "/groups/#{group.id}/join.json" end.not_to change { group.users.count }
expect(response).to be_forbidden
@@ -2638,7 +2638,7 @@ RSpec.describe GroupsController do
end
end
- it "should not allow a underprivileged user to leave a group for another user" do
+ it "does not allow an underprivileged user to remove another member" do
sign_in(user)
delete "/groups/#{group.id}/members.json", params: { username: other_user.username }
@@ -2715,7 +2715,7 @@ RSpec.describe GroupsController 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
+ it "allows a user to leave a group with public exit" do
sign_in(user)
expect do delete "/groups/#{group_with_public_exit.id}/leave.json" end.to change {
@@ -2725,7 +2725,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(204)
end
- it "should not allow a user to leave a group without public exit" do
+ it "does not allow leaving a group without public exit" do
sign_in(user)
expect do delete "/groups/#{group.id}/leave.json" end.not_to change { group.users.count }
@@ -2733,7 +2733,7 @@ RSpec.describe GroupsController do
expect(response).to be_forbidden
end
- it "should not allow an anonymous user to call the leave method" do
+ it "does not allow an anonymous user to leave" do
expect do delete "/groups/#{group_with_public_exit.id}/leave.json" end.not_to change {
group_with_public_exit.users.count
}
@@ -2874,7 +2874,7 @@ RSpec.describe GroupsController do
describe "#histories" do
context "when user is not signed in" do
- it "should raise the right error" do
+ it "raises the expected error" do
get "/groups/#{group.name}/logs.json"
expect(response.status).to eq(403)
end
@@ -2883,7 +2883,7 @@ RSpec.describe GroupsController do
context "when user is not a group owner" do
before { sign_in(user) }
- it "should be forbidden" do
+ it "returns a forbidden response" do
get "/groups/#{group.name}/logs.json"
expect(response).to be_forbidden
@@ -2903,7 +2903,7 @@ RSpec.describe GroupsController do
GroupActionLogger.new(user, group).log_change_group_settings
end
- it "should allow group owner to view history" do
+ it "allows a group owner to view history" do
get "/groups/#{group.name}/logs.json"
expect(response.status).to eq(200)
@@ -2940,7 +2940,7 @@ RSpec.describe GroupsController do
end
end
- it "should not be allowed to view history of an automatic group" do
+ it "does not allow viewing an automatic group's history" do
group = Group.find_by(id: Group::AUTO_GROUPS[:admins])
get "/groups/#{group.name}/logs.json"
@@ -2952,7 +2952,7 @@ RSpec.describe GroupsController do
context "when user is an admin" do
before { sign_in(admin) }
- it "should be able to view history" do
+ it "returns the group history" do
GroupActionLogger.new(admin, group).log_remove_user_from_group(user)
get "/groups/#{group.name}/logs.json"
@@ -2964,7 +2964,7 @@ RSpec.describe GroupsController do
expect(result["action"]).to eq(GroupHistory.actions[3].to_s)
end
- it "should be able to view history of automatic groups" do
+ it "returns history for automatic groups" do
group = Group.find_by(id: Group::AUTO_GROUPS[:admins])
get "/groups/#{group.name}/logs.json"
@@ -2972,7 +2972,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(200)
end
- it "should be able to filter through the history" do
+ it "filters the group history" do
GroupActionLogger.new(admin, group).log_add_user_to_group(user)
GroupActionLogger.new(admin, group).log_remove_user_from_group(user)
@@ -3055,7 +3055,7 @@ RSpec.describe GroupsController do
)
end
- it "should create the right PM" do
+ it "creates the expected private message" do
owner1 = Fabricate(:user, last_seen_at: Time.zone.now)
owner2 = Fabricate(:user, last_seen_at: 1.day.ago)
[owner1, owner2].each { |owner| group.add_owner(owner) }
@@ -3255,7 +3255,7 @@ RSpec.describe GroupsController do
describe "#new" do
describe "for an anon user" do
- it "should return 404" do
+ it "returns 404" do
get "/groups/custom/new"
expect(response.status).to eq(404)
@@ -3265,7 +3265,7 @@ RSpec.describe GroupsController do
describe "for a normal user" do
before { sign_in(user) }
- it "should return 404" do
+ it "returns 404" do
get "/groups/custom/new"
expect(response.status).to eq(404)
@@ -3275,7 +3275,7 @@ RSpec.describe GroupsController do
describe "for an admin user" do
before { sign_in(admin) }
- it "should return 200" do
+ it "returns 200" do
get "/groups/custom/new"
expect(response.status).to eq(200)
@@ -3285,13 +3285,13 @@ RSpec.describe GroupsController do
describe "#check_name" do
describe "for an anon user" do
- it "should return the right response" do
+ it "returns the expected response" do
get "/groups/check-name.json", params: { group_name: "test" }
expect(response.status).to eq(403)
end
end
- it "should return the right response" do
+ it "returns the expected response" do
sign_in(Fabricate(:user))
SiteSetting.reserved_usernames = "test|donkey"
get "/groups/check-name.json", params: { group_name: "test" }
diff --git a/spec/requests/hashtags_controller_spec.rb b/spec/requests/hashtags_controller_spec.rb
index e342c0b9a28..b81a5b29cb1 100644
--- a/spec/requests/hashtags_controller_spec.rb
+++ b/spec/requests/hashtags_controller_spec.rb
@@ -300,7 +300,7 @@ RSpec.describe HashtagsController do
sign_in(Fabricate(:user))
end
- it "works" do
+ it "resolves hashtags for deeply nested categories" do
foo = Fabricate(:category_with_definition, slug: "foo")
foobar = Fabricate(:category_with_definition, slug: "bar", parent_category_id: foo.id)
foobarbaz =
diff --git a/spec/requests/home_page_controller_spec.rb b/spec/requests/home_page_controller_spec.rb
index 148bf2a41d1..bbde504f039 100644
--- a/spec/requests/home_page_controller_spec.rb
+++ b/spec/requests/home_page_controller_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe HomePageController do
SiteSetting.has_login_hint = false
end
- it "should display the menu by default" do
+ it "displays the menu by default" do
get "/custom", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
@@ -26,7 +26,7 @@ RSpec.describe HomePageController do
end
end
- it "should allow plugin to override output" do
+ it "allows a plugin to override the output" do
plugin =
plugin_class.new(
nil,
@@ -52,7 +52,7 @@ RSpec.describe HomePageController do
end
end
- it "should display the site description on the homepage" do
+ it "displays the site description on the homepage" do
get "/", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
@@ -74,7 +74,7 @@ RSpec.describe HomePageController do
expect(response.body).not_to include("crawler-view-anon-menu")
end
- it "should not display the site description on another route" do
+ it "does not display the site description on another route" do
get "/top", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb
index c8833e4688b..cac75f4071a 100644
--- a/spec/requests/invites_controller_spec.rb
+++ b/spec/requests/invites_controller_spec.rb
@@ -412,7 +412,7 @@ RSpec.describe InvitesController do
context "with invite to topic" do
fab!(:topic)
- it "works" do
+ it "enqueues an email invitation to the topic" do
sign_in(user)
post "/invites.json",
@@ -571,7 +571,7 @@ RSpec.describe InvitesController do
context "when validations fail" do
let(:email) { "[email protected]" }
- it "fails" do
+ it "returns validation errors for a blocked email domain" do
create_invite
expect(response).to have_http_status :unprocessable_entity
expect(response.parsed_body["errors"]).to be_present
@@ -581,7 +581,7 @@ RSpec.describe InvitesController do
context "when email address is too long" do
let(:email) { "a" * 495 + "@example.com" }
- it "fails" do
+ it "returns a validation error for an excessively long email address" do
create_invite
expect(response).to have_http_status :unprocessable_entity
expect(response.parsed_body["errors"]).to be_present
@@ -618,7 +618,7 @@ RSpec.describe InvitesController do
end
context "with domain invite" do
- it "works" do
+ it "creates a domain invitation" do
sign_in(admin)
post "/invites.json", params: { domain: "example.com" }
@@ -912,7 +912,7 @@ RSpec.describe InvitesController do
end
context "with link invite" do
- it "works" do
+ it "creates a single-use link invitation without an email" do
sign_in(admin)
post "/invites.json"
@@ -1006,7 +1006,7 @@ RSpec.describe InvitesController do
context "with invite to topic" do
fab!(:topic)
- it "works" do
+ it "enqueues topic invitation emails through the multiple-invite endpoint" do
sign_in(admin)
post "/invites/create-multiple.json",
@@ -1477,7 +1477,7 @@ RSpec.describe InvitesController do
OmniAuth.config.test_mode = false
end
- it "should associate the invited user with authenticator records" do
+ it "associates the invited user with authenticator records" do
SiteSetting.auth_overrides_name = true
invite.update!(email: authenticated_email)
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index 81b2f942a41..257d1d8e046 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -28,12 +28,12 @@ RSpec.describe ListController do
end
context "when params are invalid" do
- it "should return a 400 response when `page` param is a string that represent a negative integer" do
+ it "returns 400 when page is a negative integer string" do
get "/latest?page=-1"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `page` param is a string larger than maximum integer value" do
+ it "returns 400 when page exceeds the maximum integer" do
get "/latest?page=2147483648"
expect(response.status).to eq(400)
@@ -41,117 +41,117 @@ RSpec.describe ListController do
expect(response.status).to eq(400)
end
- it "should return a 400 response when `before` param is not a string represetning an integer" do
+ it "returns 400 when before is not an integer string" do
get "/latest?before[1]=haxx"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `bumped_before` param is not a string representing an integer" do
+ it "returns 400 when bumped_before is not an integer string" do
get "/latest?bumped_before[1]=haxx"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `topic_ids` param is not a string representing an integer" do
+ it "returns 400 when topic_ids is not an integer string" do
get "/latest?topic_ids[1]=haxx"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `category` param is not a string representing an integer" do
+ it "returns 400 when category is not an integer string" do
get "/latest?category[1]=haxx"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `order` param is not a string" do
+ it "returns 400 when order is not a string" do
get "/latest?order[1]=haxx"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `ascending` param is not a string that is either `true` or `false`" do
+ it "returns 400 when ascending is not a boolean string" do
get "/latest?ascending=maybe"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `min_posts` param is a string that does not represent an integer" do
+ it "returns 400 when min_posts is not an integer string" do
get "/latest?min_posts=bob"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `max_posts` param is a string that does not represent an integer" do
+ it "returns 400 when max_posts is not an integer string" do
get "/latest?max_posts=bob"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `max_posts` param is a string larger than maximum integer value" do
+ it "returns 400 when max_posts exceeds the maximum integer" do
get "/latest?max_posts=1111111111111111111111111111111111111111"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `status` param is not a string" do
+ it "returns 400 when status is not a string" do
get "/latest?status%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `filter` param is not a string" do
+ it "returns 400 when the list filter is not a string" do
get "/latest?filter%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `state` param is not a string" do
+ it "returns 400 when state is not a string" do
get "/latest?state%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `search` param is not a string" do
+ it "returns 400 when search is not a string" do
get "/latest?search%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `q` param is not a string" do
+ it "returns 400 when q is not a string" do
get "/latest?q%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `f` param is not a string" do
+ it "returns 400 when f is not a string" do
get "/latest?f%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `subset` param is not a string" do
+ it "returns 400 when subset is not a string" do
get "/latest?subset%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `group_name` param is not a string" do
+ it "returns 400 when group_name is not a string" do
get "/latest?group_name%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `tags` param is not an array or string" do
+ it "returns 400 when tags is neither an array nor a string" do
get "/latest?tags[1]=hello"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `filter` param is not a string" do
+ it "returns 400 when the user filter is not a string" do
get "/latest?filter%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `match_all_tags` param is not a string that is either `true` or `false`" do
+ it "returns 400 when match_all_tags is not a boolean string" do
get "/latest?match_all_tags=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `no_subcategories` param is not a string that is either `true` or `false`" do
+ it "returns 400 when no_subcategories is not a boolean string" do
get "/latest?no_subcategories=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `no_tags` param is not a string that is either `true` or `false`" do
+ it "returns 400 when no_tags is not a boolean string" do
get "/latest?no_tags=something"
expect(response.status).to eq(400)
end
- it "should return a 400 response when `exclude_tag` param is not a string" do
+ it "returns 400 when exclude_tag is not a string" do
get "/latest?exclude_tag%5Bsomehash%5D=something"
expect(response.status).to eq(400)
end
@@ -191,7 +191,7 @@ RSpec.describe ListController do
(Discourse.anonymous_filters - [:categories]).each do |filter|
context "with #{filter}" do
- it "succeeds" do
+ it "returns the requested list" do
get "/#{filter}"
expect(response.status).to eq(200)
end
@@ -500,13 +500,13 @@ RSpec.describe ListController do
Fabricate(:topic_tag, tag: tag, topic: private_message)
end
- it "should fail for non-staff users" do
+ it "fails for non-staff users" do
sign_in(user)
get "/topics/private-messages-tags/#{user.username}/#{tag.name}.json"
expect(response.status).to eq(404)
end
- it "should fail for staff users if empty" do
+ it "fails for staff users when empty" do
SiteSetting.pm_tags_allowed_for_groups = ""
[moderator, admin].each do |user|
@@ -516,7 +516,7 @@ RSpec.describe ListController do
end
end
- it "should be success for staff users" do
+ it "succeeds for staff users" do
[moderator, admin].each do |user|
sign_in(user)
get "/topics/private-messages-tags/#{user.username}/#{tag.name}.json"
@@ -524,7 +524,7 @@ RSpec.describe ListController do
end
end
- it "should work for tag with unicode name" do
+ it "supports a tag with a Unicode name" do
unicode_tag = Fabricate(:tag, name: "hello-🇺🇸")
Fabricate(:topic_tag, tag: unicode_tag, topic: private_message)
@@ -534,7 +534,7 @@ RSpec.describe ListController do
expect(response.parsed_body["topic_list"]["topics"].first["id"]).to eq(private_message.id)
end
- it "should work for users who are allowed and direct links" do
+ it "supports direct links for authorized users" do
SiteSetting.pm_tags_allowed_for_groups = group.name
group.add(user)
sign_in(user)
@@ -593,7 +593,7 @@ RSpec.describe ListController do
SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:staff]
end
- it "should display group private messages for an admin" do
+ it "displays group private messages for an admin" do
sign_in(Fabricate(:admin))
get "/topics/private-messages-group/#{user.username}/#{group.name}.json"
@@ -603,7 +603,7 @@ RSpec.describe ListController do
expect(response.parsed_body["topic_list"]["topics"].first["id"]).to eq(topic.id)
end
- it "should display moderator group private messages for a moderator" do
+ it "displays moderator-group private messages for a moderator" do
moderator = Fabricate(:moderator)
group = Group.find(Group::AUTO_GROUPS[:moderators])
Fabricate(:private_message_topic, allowed_groups: [group])
@@ -614,7 +614,7 @@ RSpec.describe ListController do
expect(response.status).to eq(200)
end
- it "should not display group private messages for a moderator's group" do
+ it "does not display private messages for a moderator's group" do
moderator = Fabricate(:moderator)
sign_in(moderator)
@@ -623,7 +623,7 @@ RSpec.describe ListController do
expect(response.status).to eq(404)
end
- it "should sort group private messages by posts_count" do
+ it "sorts group private messages by posts_count" do
topic2 = Fabricate(:private_message_topic, allowed_groups: [group])
topic3 = Fabricate(:private_message_topic, allowed_groups: [group])
2.times { Fabricate(:post, topic: topic2) }
@@ -643,14 +643,14 @@ RSpec.describe ListController do
end
end
- describe "with unicode_usernames" do
+ describe "with unicode_usernames disabled" do
before do
group.add(user)
sign_in(user)
SiteSetting.unicode_usernames = false
end
- it "should return the right response when user does not belong to group" do
+ it "returns not found when the user does not belong to the group" do
Fabricate(:private_message_topic, allowed_groups: [group])
group.remove(user)
@@ -660,7 +660,7 @@ RSpec.describe ListController do
expect(response.status).to eq(404)
end
- it "should return the right response" do
+ it "returns the group's private messages" do
topic = Fabricate(:private_message_topic, allowed_groups: [group])
get "/topics/private-messages-group/#{user.username}/awesomegroup.json"
@@ -670,7 +670,7 @@ RSpec.describe ListController do
end
end
- describe "with unicode_usernames" do
+ describe "with unicode_usernames enabled" do
before do
sign_in(user)
SiteSetting.unicode_usernames = true
@@ -702,7 +702,7 @@ RSpec.describe ListController do
let!(:another_topic) { Fabricate(:topic) }
describe "when an invalid group name is given" do
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/something.json"
expect(response.status).to eq(404)
@@ -711,7 +711,7 @@ RSpec.describe ListController do
describe "for an anon user" do
describe "public visible group" do
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(200)
@@ -722,7 +722,7 @@ RSpec.describe ListController do
describe "group restricted to logged-on-users" do
before { group.update!(visibility_level: Group.visibility_levels[:logged_on_users]) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(403)
@@ -732,7 +732,7 @@ RSpec.describe ListController do
describe "restricted group" do
before { group.update!(visibility_level: Group.visibility_levels[:staff]) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(403)
@@ -744,7 +744,7 @@ RSpec.describe ListController do
group.update!(members_visibility_level: Group.visibility_levels[:logged_on_users])
end
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(403)
@@ -758,7 +758,7 @@ RSpec.describe ListController do
describe "restricted group" do
before { group.update!(visibility_level: Group.visibility_levels[:staff]) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(403)
@@ -768,7 +768,7 @@ RSpec.describe ListController do
describe "group restricted to logged-on-users" do
before { group.update!(visibility_level: Group.visibility_levels[:logged_on_users]) }
- it "should return the right response" do
+ it "returns the expected response" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(200)
@@ -779,7 +779,7 @@ RSpec.describe ListController do
describe "for a group user" do
before { sign_in(user) }
- it "should be able to view the topics started by group users" do
+ it "allows viewing topics started by group members" do
get "/topics/groups/#{group.name}.json"
expect(response.status).to eq(200)
@@ -1025,7 +1025,7 @@ RSpec.describe ListController do
end
context "with access to see the category" do
- it "succeeds" do
+ it "returns the category list" do
get "/c/#{category.slug}/#{category.id}/l/latest"
expect(response.status).to eq(200)
end
@@ -1036,7 +1036,7 @@ RSpec.describe ListController do
before { SiteSetting.slug_generation_method = "encoded" }
- it "succeeds" do
+ it "returns the encoded-slug category list" do
get "/c/#{category.slug}/#{category.id}/l/latest"
expect(response.status).to eq(200)
end
@@ -1046,7 +1046,7 @@ RSpec.describe ListController do
let(:child_category) { Fabricate(:category_with_definition, parent_category: category) }
context "with valid slug" do
- it "succeeds" do
+ it "returns the child-category list" do
get "/c/#{category.slug}/#{child_category.slug}/#{child_category.id}/l/latest"
expect(response.status).to eq(200)
end
@@ -1083,7 +1083,7 @@ RSpec.describe ListController do
let(:sub_category) { Fabricate(:category_with_definition, parent_category_id: category.id) }
context "when parent and child are requested" do
- it "succeeds" do
+ it "returns the nested child-category list" do
get "/c/#{category.slug}/#{sub_category.slug}/#{sub_category.id}/l/latest"
expect(response.status).to eq(200)
end
@@ -1307,14 +1307,14 @@ RSpec.describe ListController do
sign_in(user2)
end
- it "should respond with a list" do
+ it "responds with a list" do
get "/topics/created-by/#{user.username}.json"
expect(response.status).to eq(200)
json = response.parsed_body
expect(json["topic_list"]["topics"].size).to eq(2)
end
- it "should work with period in username" do
+ it "supports a period in the username" do
user.update!(username: "myname.test")
get "/topics/created-by/#{user.username}", xhr: true
expect(response.status).to eq(200)
@@ -1325,7 +1325,7 @@ RSpec.describe ListController do
context "with unicode usernames" do
before { SiteSetting.unicode_usernames = true }
- it "should return the more_topics_url in the encoded form" do
+ it "returns more_topics_url in encoded form" do
stub_const(TopicQuery, "DEFAULT_PER_PAGE_COUNT", 1) do
user.update!(username: "快快快")
@@ -1350,7 +1350,7 @@ RSpec.describe ListController do
expect(response.status).to eq(404)
end
- it "should respond with a list when `allow_users_to_hide_profile` is false" do
+ it "responds with a list when profile hiding is disabled" do
SiteSetting.allow_users_to_hide_profile = false
get "/topics/created-by/#{user.username}.json"
expect(response.status).to eq(200)
@@ -1533,7 +1533,7 @@ RSpec.describe ListController do
end
context "when logged in" do
- it "succeeds" do
+ it "returns the read-topic list" do
sign_in(user)
get "/read"
expect(response.status).to eq(200)
@@ -1542,7 +1542,7 @@ RSpec.describe ListController do
end
describe "best_periods_for" do
- it "works" do
+ it "returns the applicable best periods" do
expect(ListController.best_periods_for(nil)).to eq([:all])
expect(ListController.best_periods_for(5.years.ago)).to eq([:all])
expect(ListController.best_periods_for(2.years.ago)).to eq(%i[yearly all])
@@ -1759,7 +1759,7 @@ RSpec.describe ListController do
fab!(:topic_in_private_category) { Fabricate(:topic, category: private_category) }
fab!(:user2, :user)
- it "should not return topics that the user is not allowed to view" do
+ it "does not return topics the user cannot view" do
sign_in(user)
get "/filter.json"
@@ -1771,7 +1771,7 @@ RSpec.describe ListController do
).to contain_exactly(topic.id)
end
- it "should not return topics that an anon user is not allowed to view" do
+ it "does not return topics an anonymous user cannot view" do
get "/filter.json"
expect(response.status).to eq(200)
@@ -1815,7 +1815,7 @@ RSpec.describe ListController do
).to contain_exactly(topic.id)
end
- it "should accept the `page` query parameter" do
+ it "accepts the page query parameter" do
topic_with_tag = Fabricate(:topic, tags: [tag])
topic2_with_tag = Fabricate(:topic, tags: [tag])
@@ -1880,7 +1880,7 @@ RSpec.describe ListController do
end
end
- it "should include filter_option_info in the response" do
+ it "includes filter_option_info in the response" do
get "/filter.json"
parsed = response.parsed_body
expect(response.status).to eq(200)
@@ -1889,7 +1889,7 @@ RSpec.describe ListController do
)
end
- it "should filter with tag_group option" do
+ it "filters with the tag_group option" do
topic_with_tag = Fabricate(:topic, tags: [tag])
topic2_with_tag = Fabricate(:topic, tags: [tag])
tag_group = Fabricate(:tag_group, tags: [tag])
@@ -2308,7 +2308,7 @@ RSpec.describe ListController do
end
end
- it "should not have N+1s when loading localizations" do
+ it "does not issue N+1 queries while loading localizations" do
Fabricate.times(5, :topic, category:, locale: "en")
Topic.all.each { |t| Fabricate(:topic_localization, topic: t, locale: "ja") }
diff --git a/spec/requests/net_http_header_spec.rb b/spec/requests/net_http_header_spec.rb
index ce96a88cdaf..7b8de2ca660 100644
--- a/spec/requests/net_http_header_spec.rb
+++ b/spec/requests/net_http_header_spec.rb
@@ -2,7 +2,7 @@
# We can use the redeliver event to test the user-agent header
RSpec.describe "Net::HTTPHeader sets a default user-agent" do
- it "should set a user-agent when none has been set" do
+ it "sets a User-Agent when none is present" do
get "/test_net_http_headers.json"
expect(response).to have_http_status(:success)
diff --git a/spec/requests/net_http_timeout_spec.rb b/spec/requests/net_http_timeout_spec.rb
index 350d489af81..d56e6f59473 100644
--- a/spec/requests/net_http_timeout_spec.rb
+++ b/spec/requests/net_http_timeout_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "Net::HTTP timeouts when processing a request" do
- it "should set the right timeouts for any `Net::HTTP` instances initialized while processing a request" do
+ it "sets timeouts on Net::HTTP instances initialized during a request" do
stub_const(NetHTTPPatch, :OPEN_TIMEOUT, 0.001) do
stub_const(NetHTTPPatch, :READ_TIMEOUT, 0.002) do
stub_const(NetHTTPPatch, :WRITE_TIMEOUT, 0.003) do
diff --git a/spec/requests/notifications_controller_spec.rb b/spec/requests/notifications_controller_spec.rb
index 8613ab53f34..dd999bfefa7 100644
--- a/spec/requests/notifications_controller_spec.rb
+++ b/spec/requests/notifications_controller_spec.rb
@@ -38,12 +38,12 @@ RSpec.describe NotificationsController do
end
describe "#index" do
- it "should succeed for recent" do
+ it "returns recent notifications" do
get "/notifications", params: { recent: true }
expect(response.status).to eq(200)
end
- it "should succeed for history" do
+ it "returns notification history" do
get "/notifications.json"
expect(response.status).to eq(200)
@@ -54,7 +54,7 @@ RSpec.describe NotificationsController do
expect(notifications.first["id"]).to eq(notification.id)
end
- it "should mark notifications as viewed" do
+ it "marks notifications as viewed" do
expect(user.reload.unread_notifications).to eq(1)
expect(user.reload.total_unread_notifications).to eq(1)
@@ -65,7 +65,7 @@ RSpec.describe NotificationsController do
expect(user.reload.total_unread_notifications).to eq(1)
end
- it "should not mark notifications as viewed if silent param is present" do
+ it "does not mark notifications viewed with the silent parameter" do
expect(user.reload.unread_notifications).to eq(1)
expect(user.reload.total_unread_notifications).to eq(1)
@@ -76,7 +76,7 @@ RSpec.describe NotificationsController do
expect(user.reload.total_unread_notifications).to eq(1)
end
- it "should not mark notifications as viewed in readonly mode" do
+ it "does not mark notifications viewed in read-only mode" do
Discourse.received_redis_readonly!
expect(user.reload.unread_notifications).to eq(1)
expect(user.reload.total_unread_notifications).to eq(1)
@@ -206,7 +206,7 @@ RSpec.describe NotificationsController do
)
end
- it "should not bump last seen reviewable in readonly mode" do
+ it "does not update the last-seen reviewable in read-only mode" do
user.update!(admin: true)
Discourse.received_redis_readonly!
@@ -219,14 +219,14 @@ RSpec.describe NotificationsController do
Discourse.clear_redis_readonly!
end
- it "should not bump last seen reviewable if the user can't see reviewables" do
+ it "does not update the last-seen reviewable without review access" do
expect {
get "/notifications.json", params: { recent: true, bump_last_seen_reviewable: true }
expect(response.status).to eq(200)
}.not_to change { user.reload.last_seen_reviewable_id }
end
- it "should not bump last seen reviewable if the silent param is present" do
+ it "does not update the last-seen reviewable with the silent parameter" do
user.update!(admin: true)
expect {
@@ -240,7 +240,7 @@ RSpec.describe NotificationsController do
}.not_to change { user.reload.last_seen_reviewable_id }
end
- it "should not bump last seen reviewable if the bump_last_seen_reviewable param is not present" do
+ it "does not update the last-seen reviewable without the bump parameter" do
user.update!(admin: true)
expect {
@@ -373,7 +373,7 @@ RSpec.describe NotificationsController do
end
context "when username params is not valid" do
- it "should raise the right error" do
+ it "returns the permission error" do
get "/notifications.json", params: { username: "somedude" }
expect(response.status).to eq(404)
end
@@ -586,7 +586,7 @@ RSpec.describe NotificationsController do
end
end
- it "should succeed" do
+ it "marks every notification as read" do
put "/notifications/mark-read.json"
expect(response.status).to eq(200)
end
@@ -737,7 +737,7 @@ RSpec.describe NotificationsController do
context "when not logged in" do
describe "#index" do
- it "should raise an error" do
+ it "requires authentication" do
get "/notifications.json", params: { recent: true }
expect(response.status).to eq(403)
end
diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb
index e70e0854438..5b5f9cca755 100644
--- a/spec/requests/omniauth_callbacks_controller_spec.rb
+++ b/spec/requests/omniauth_callbacks_controller_spec.rb
@@ -154,14 +154,14 @@ RSpec.describe Users::OmniauthCallbacksController do
end
describe "request" do
- it "should error for non existant authenticators" do
+ it "returns an error for nonexistent authenticators" do
post "/auth/fake_auth"
expect(response.status).to eq(404)
get "/auth/fake_auth"
expect(response.status).to eq(403)
end
- it "should error for disabled authenticators" do
+ it "returns an error for disabled authenticators" do
SiteSetting.enable_google_oauth2_logins = false
post "/auth/google_oauth2"
expect(response.status).to eq(404)
@@ -169,7 +169,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(response.status).to eq(403)
end
- it "should handle common errors" do
+ it "handles common authentication errors" do
OmniAuth::Strategies::GoogleOauth2
.any_instance
.stubs(:mock_request_call)
@@ -194,7 +194,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(response.location).to include("/auth/failure?message=invalid_iat")
end
- it "should only start auth with a POST request" do
+ it "starts authentication only through a POST request" do
post "/auth/google_oauth2"
expect(response.status).to eq(302)
get "/auth/google_oauth2"
@@ -205,7 +205,7 @@ RSpec.describe Users::OmniauthCallbacksController do
before { ActionController::Base.allow_forgery_protection = true }
after { ActionController::Base.allow_forgery_protection = false }
- it "should be CSRF protected" do
+ it "requires CSRF protection" do
post "/auth/google_oauth2"
expect(response.status).to eq(302)
expect(response.location).to include("/auth/failure?message=csrf_detected")
@@ -221,7 +221,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(response.status).to eq(302)
end
- it "should not be CSRF protected if it is the only auth method" do
+ it "allows authentication without CSRF protection when it is the only method" do
get "/auth/google_oauth2"
expect(response.status).to eq(200)
SiteSetting.enable_local_logins = false
@@ -229,7 +229,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(response.status).to eq(302)
end
- it "should not be CSRF protected if the setting has been disabled" do
+ it "allows authentication without CSRF protection when disabled in settings" do
SiteSetting.auth_require_interaction = false
SiteSetting.enable_local_logins = true
get "/auth/google_oauth2"
@@ -287,7 +287,7 @@ RSpec.describe Users::OmniauthCallbacksController do
end
context "without an `omniauth.auth` env" do
- it "should return a 404" do
+ it "returns 404" do
get "/auth/eviltrout/callback"
expect(response.code).to eq("404")
end
@@ -300,7 +300,7 @@ RSpec.describe Users::OmniauthCallbacksController do
before { mock_auth(email, username, name) }
- it "should return the right response" do
+ it "redirects with authentication details for the new user" do
destination_url = "/somepath"
Rails.application.env_config["omniauth.origin"] = destination_url
@@ -326,7 +326,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["destination_url"]).to eq(destination_url)
end
- it "should return the right response for staged users" do
+ it "redirects with authentication details for staged users" do
Fabricate(:user, username: username, email: email, staged: true)
destination_url = "/somepath"
@@ -354,7 +354,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["destination_url"]).to eq(destination_url)
end
- it "should include destination url in response" do
+ it "includes the destination URL in the response" do
destination_url = "/cookiepath"
cookies[:destination_url] = destination_url
@@ -364,7 +364,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["destination_url"]).to eq(destination_url)
end
- it "should return an associate url when multiple login methods are enabled" do
+ it "returns an association URL when multiple login methods are enabled" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -421,7 +421,7 @@ RSpec.describe Users::OmniauthCallbacksController do
describe "when site is invite_only" do
before { SiteSetting.invite_only = true }
- it "should return the right response without any origin" do
+ it "requires an invitation when no origin is supplied" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -439,7 +439,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(response.status).to eq(302)
end
- it "should return the right response when origin is invites page" do
+ it "redirects to the invitation page without requiring another invite" do
origin =
Rails.application.routes.url_helpers.invite_url(
Fabricate(:invite).invite_key,
@@ -492,7 +492,7 @@ RSpec.describe Users::OmniauthCallbacksController do
before { mock_auth(user.email, "Somenickname", "Some name", uid) }
- it "should return the right response" do
+ it "authenticates the user and confirms their email" do
expect(user.email_confirmed?).to eq(false)
events = DiscourseEvent.track_events { get "/auth/google_oauth2/callback.json" }
@@ -517,7 +517,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.user_auth_tokens.last.authenticated_with_oauth).to be true
end
- it "should return the authenticated response with the correct path for subfolders" do
+ it "includes the subfolder in the authenticated response path" do
set_subfolder "/forum"
events = DiscourseEvent.track_events { get "/auth/google_oauth2/callback.json" }
@@ -544,7 +544,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.email_confirmed?).to eq(true)
end
- it "should confirm email even when the tokens are expired" do
+ it "confirms email even when the tokens are expired" do
user.email_tokens.update_all(confirmed: false, expired: true)
user.reload
@@ -563,7 +563,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.email_confirmed?).to eq(true)
end
- it "should treat a staged user the same as an unregistered user" do
+ it "treats a staged user as an unregistered user" do
user.update!(staged: true, registration_ip_address: nil)
user.reload
@@ -601,7 +601,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.name).to eq("My new name")
end
- it "should activate user with matching email" do
+ it "activates the user with a matching email" do
user.update!(password: "securepassword", active: false, registration_ip_address: "1.1.1.1")
user.reload
@@ -617,7 +617,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.confirm_password?("securepassword")).to eq(false)
end
- it "should work if the user has no email_tokens, and an invite" do
+ it "authenticates an invited user without email tokens" do
# Confirming existing email_tokens has a side effect of redeeming invites.
# Pretend we don't have any email_tokens
user.email_tokens.destroy_all
@@ -631,7 +631,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(invite.reload.invalidated_at).not_to eq(nil)
end
- it "should update name/username/email when SiteSetting.auth_overrides_* are enabled" do
+ it "updates name, username, and email when authentication overrides are enabled" do
SiteSetting.email_editable = false
SiteSetting.auth_overrides_email = true
SiteSetting.auth_overrides_name = true
@@ -655,7 +655,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.name).to eq("Some name")
end
- it "should preserve username when several users login with the same username" do
+ it "preserves usernames when several users log in with the same username" do
SiteSetting.auth_overrides_username = true
# if several users have username "bill" on the external site,
@@ -683,7 +683,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(user.username).to eq("bill3")
end
- it "will not update email if not verified" do
+ it "does not update an unverified email" do
SiteSetting.email_editable = false
SiteSetting.auth_overrides_email = true
@@ -762,7 +762,7 @@ RSpec.describe Users::OmniauthCallbacksController do
context "when user has TOTP enabled" do
before { user.create_totp(enabled: true) }
- it "should return the right response" do
+ it "requires second factor for a user with TOTP enabled" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -783,7 +783,7 @@ RSpec.describe Users::OmniauthCallbacksController do
context "when user has TOTP enabled but enforce_second_factor_on_external_auth is false" do
before { user.create_totp(enabled: true) }
- it "should return the right response" do
+ it "authenticates without TOTP when external authentication is exempt" do
SiteSetting.enforce_second_factor_on_external_auth = false
get "/auth/google_oauth2/callback.json"
@@ -798,7 +798,7 @@ RSpec.describe Users::OmniauthCallbacksController do
context "when user has security key enabled" do
before { Fabricate(:user_security_key_with_random_credential, user: user) }
- it "should return the right response" do
+ it "requires second factor for a user with a security key" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -837,7 +837,7 @@ RSpec.describe Users::OmniauthCallbacksController do
mock_auth(user.email, nil, nil, provider_uid)
end
- it "should return the right response" do
+ it "sets the SSO provider destination from the payload cookie" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -862,7 +862,7 @@ RSpec.describe Users::OmniauthCallbacksController do
mock_auth(another_email, nil, nil, provider_uid)
end
- it "should return the right response" do
+ it "keeps the user awaiting activation when their email is unverified" do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
@@ -1113,7 +1113,7 @@ RSpec.describe Users::OmniauthCallbacksController do
mock_auth("[email protected]", nil, nil, user1_provider_id)
end
- it "should not reconnect normally" do
+ it "does not reconnect through the normal callback" do
# Log in normally
post "/auth/google_oauth2"
expect(response.status).to eq(302)
@@ -1135,7 +1135,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(UserAssociatedAccount.count).to eq(2)
end
- it "should redirect to associate URL if parameter supplied" do
+ it "redirects to the association URL when supplied" do
# Log in normally
post "/auth/google_oauth2?reconnect=true"
expect(response.status).to eq(302)
@@ -1218,7 +1218,7 @@ RSpec.describe Users::OmniauthCallbacksController do
Fabricate(:user, username: "staged_user", email: "[email protected]", staged: true)
end
- it "should use username of the staged user if username is not present in payload" do
+ it "keeps the staged user's username when the payload omits it" do
mock_auth(staged_user.email, nil)
get "/auth/google_oauth2/callback.json"
@@ -1227,7 +1227,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["username"]).to eq(staged_user.username)
end
- it "should use username of the staged user if username in payload is the same" do
+ it "keeps the staged user's username when the payload matches it" do
# it's important to check this, because we had regressions
# when usernames were changed to the same username with "1" added at the end
@@ -1239,7 +1239,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["username"]).to eq(staged_user.username)
end
- it "should override username of the staged user if payload contains a new username" do
+ it "updates the staged user's username when the payload supplies a new one" do
new_username = "new_username"
mock_auth(staged_user.email, new_username)
diff --git a/spec/requests/permalinks_controller_spec.rb b/spec/requests/permalinks_controller_spec.rb
index de3d9b1b5fb..c1906117e7a 100644
--- a/spec/requests/permalinks_controller_spec.rb
+++ b/spec/requests/permalinks_controller_spec.rb
@@ -15,14 +15,14 @@ RSpec.describe PermalinksController do
fab!(:admin)
describe "show" do
- it "should redirect to a permalink's target_url with status 301" do
+ it "redirects permanently to the permalink target URL" do
get "/#{permalink.url}"
expect(response).to redirect_to(topic.relative_url)
expect(response.status).to eq(301)
end
- it "should work for subfolder installs too" do
+ it "redirects correctly for subfolder installations" do
set_subfolder "/forum"
get "/#{permalink.url}"
@@ -31,7 +31,7 @@ RSpec.describe PermalinksController do
expect(response.status).to eq(301)
end
- it "should apply normalizations" do
+ it "normalizes the permalink URL" do
permalink.update!(external_url: "/topic/100", topic_id: nil)
SiteSetting.permalink_normalizations = "/(.*)\\?.*/\\1"
diff --git a/spec/requests/post_action_users_controller_spec.rb b/spec/requests/post_action_users_controller_spec.rb
index 3a298e4a500..5a1ea1db008 100644
--- a/spec/requests/post_action_users_controller_spec.rb
+++ b/spec/requests/post_action_users_controller_spec.rb
@@ -116,7 +116,7 @@ RSpec.describe PostActionUsersController do
expect(response).to be_forbidden
end
- it "succeeds" do
+ it "returns 200 when listing users who liked the post" do
get "/post_action_users.json",
params: {
id: post.id,
@@ -126,7 +126,7 @@ RSpec.describe PostActionUsersController do
expect(response.status).to eq(200)
end
- it "will return an unknown attribute for muted users" do
+ it "returns an unknown attribute for muted users" do
muted_user = Fabricate(:user)
PostActionCreator.like(muted_user, post)
regular_user = Fabricate(:user)
diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb
index f4ab97e0f1d..8f525219736 100644
--- a/spec/requests/posts_controller_spec.rb
+++ b/spec/requests/posts_controller_spec.rb
@@ -11,7 +11,7 @@ RSpec.shared_examples "finding and showing post" do
expect(response).to be_forbidden
end
- it "succeeds" do
+ it "returns 200 for an accessible post" do
get url
expect(response.status).to eq(200)
end
@@ -965,7 +965,7 @@ RSpec.describe PostsController do
expect(response.parsed_body["current_revision"]).to eq(2)
end
- it "won't update bump date if post is a whisper" do
+ it "does not update the bump date for whispers" do
created_at = freeze_time 1.day.ago
post = Fabricate(:post, post_type: Post.types[:whisper], user: user)
@@ -1475,7 +1475,7 @@ RSpec.describe PostsController do
expect(response.status).to eq(200)
end
- it "will invalidate broken images cache" do
+ it "invalidates the broken images cache" do
sign_in(moderator)
PostHotlinkedMedia.create!(
url: "https://example.com/image.jpg",
@@ -1761,7 +1761,7 @@ RSpec.describe PostsController do
expect(Draft.get(user, Draft::NEW_TOPIC, 0)).to eq("test")
end
- it "will raise an error if specified category cannot be found" do
+ it "returns an error when the specified category does not exist" do
user = Fabricate(:admin)
master_key = Fabricate(:api_key).key
@@ -1783,7 +1783,7 @@ RSpec.describe PostsController do
)
end
- it "will raise an error if specified embed_url is invalid" do
+ it "returns an error when embed_url is invalid" do
user = Fabricate(:admin)
master_key = Fabricate(:api_key).key
@@ -2428,7 +2428,7 @@ RSpec.describe PostsController do
end
context "when adding custom fields to topic via the `topic_custom_fields` param" do
- it "should return a 400 response code when no custom fields has been permitted" do
+ it "returns 400 when no custom fields are permitted" do
sign_in(user)
post "/posts.json",
@@ -2454,7 +2454,7 @@ RSpec.describe PostsController do
plugin
end
- it "should return a 400 response when trying to add a staff ony custom field for a non-staff user" do
+ it "returns 400 when a non-staff user adds a staff-only custom field" do
sign_in(user)
post "/posts.json",
@@ -2471,7 +2471,7 @@ RSpec.describe PostsController do
expect(Topic.last.custom_fields).to eq({})
end
- it "should add custom fields to topic that is permitted for a non-staff user" do
+ it "adds topic custom fields permitted for non-staff users" do
sign_in(user)
post "/posts.json",
@@ -2488,7 +2488,7 @@ RSpec.describe PostsController do
expect(Topic.last.custom_fields).to eq({ "xyz" => "abc" })
end
- it "should add custom fields to topic that is permitted for a non-staff user via the deprecated `meta_data` param" do
+ it "adds permitted topic custom fields through the deprecated meta_data parameter" do
sign_in(user)
post "/posts.json",
@@ -2505,7 +2505,7 @@ RSpec.describe PostsController do
expect(Topic.last.custom_fields).to eq({ "xyz" => "abc" })
end
- it "should add custom fields to topic that is permitted for a staff user and public user" do
+ it "adds topic custom fields permitted for staff and public users" do
sign_in(Fabricate(:admin))
post "/posts.json",
@@ -2646,7 +2646,7 @@ RSpec.describe PostsController do
expect(response.status).to eq(422)
end
- it "it triggers flag_linked_posts_as_spam when the post creator returns spam" do
+ it "triggers flag_linked_posts_as_spam when the post creator returns spam" do
SiteSetting.newuser_spam_host_threshold = 1
sign_in(Fabricate(:user, trust_level: TrustLevel[0]))
@@ -2841,7 +2841,7 @@ RSpec.describe PostsController do
describe "shared draft" do
fab!(:destination_category, :category)
- it "will raise an error for regular users" do
+ it "returns an error for regular users" do
post "/posts.json",
params: {
raw: "this is the shared draft content",
@@ -2855,7 +2855,7 @@ RSpec.describe PostsController do
describe "as a staff user" do
before { sign_in(moderator) }
- it "will raise an error if there is no shared draft category" do
+ it "returns an error when no shared draft category exists" do
post "/posts.json",
params: {
raw: "this is the shared draft content",
@@ -2870,7 +2870,7 @@ RSpec.describe PostsController do
fab!(:shared_category, :category)
before { SiteSetting.shared_drafts_category = shared_category.id }
- it "will work if the shared draft category is present" do
+ it "creates a shared draft when the shared draft category exists" do
post "/posts.json",
params: {
raw: "this is the shared draft content",
@@ -2912,7 +2912,7 @@ RSpec.describe PostsController do
context "as a staff user" do
before { sign_in(admin) }
- it "should be able to mark a topic as warning" do
+ it "marks the topic as a warning" do
post "/posts.json",
params: {
raw: "this is the test content",
@@ -2944,7 +2944,7 @@ RSpec.describe PostsController do
expect(Topic.last.is_official_warning?).to eq(true)
end
- it "should be able to mark a topic as not a warning" do
+ it "removes the topic's warning status" do
post "/posts.json",
params: {
raw: "this is the test content",
@@ -2964,7 +2964,7 @@ RSpec.describe PostsController do
end
context "as a normal user" do
- it "should not be able to mark a topic as warning" do
+ it "rejects marking the topic as a warning" do
sign_in(user)
post "/posts.json",
params: {
@@ -2987,7 +2987,7 @@ RSpec.describe PostsController do
context "with topic bump" do
shared_examples "it works" do
- it "should be able to skip topic bumping" do
+ it "skips topic bumping when requested" do
original_bumped_at = 1.day.ago
topic = Fabricate(:topic, bumped_at: original_bumped_at)
@@ -3017,7 +3017,7 @@ RSpec.describe PostsController do
expect(topic.reload.bumped_at).to eq_time(original_bumped_at)
end
- it "should be able to post with topic bumping" do
+ it "creates the post and bumps the topic" do
post "/posts.json", params: { raw: "this is the test content", topic_id: topic.id }
expect(response.status).to eq(200)
@@ -3049,7 +3049,7 @@ RSpec.describe PostsController do
fab!(:topic)
[:user].each do |user|
- it "will raise an error for #{user}" do
+ it "returns an error for #{user}" do
sign_in(Fabricate(user))
post "/posts.json",
params: {
@@ -3550,7 +3550,7 @@ RSpec.describe PostsController do
context "with a tagged topic" do
let(:tag) { Fabricate(:tag) }
- it "works" do
+ it "returns tagged topic revisions with tagging enabled or disabled" do
SiteSetting.tagging_enabled = true
post_revision.post.topic.update(tags: [tag])
@@ -4312,7 +4312,7 @@ RSpec.describe PostsController do
context "with private posts" do
describe "when not logged in" do
- it "should return the right response" do
+ it "returns 404 and the private posts login form" do
Fabricate(:post)
get "/private-posts.rss"
@@ -4826,7 +4826,7 @@ RSpec.describe PostsController do
expect(@controller.send(:create_params)).to include(hash_arg: { key1: "val" })
end
- it "allows strings to be added" do
+ it "allows arrays to be added" do
instance.add_permitted_post_create_param(:array_arg)
request.call
expect(@controller.send(:create_params)).not_to include(array_arg: %w[1 2 3])
diff --git a/spec/requests/presence_controller_spec.rb b/spec/requests/presence_controller_spec.rb
index 886671738fa..7ea6724508b 100644
--- a/spec/requests/presence_controller_spec.rb
+++ b/spec/requests/presence_controller_spec.rb
@@ -61,7 +61,7 @@ RSpec.describe PresenceController do
end
end
- it "works" do
+ it "updates presence for the requested channels" do
sign_in(user)
client_id = SecureRandom.hex
@@ -156,7 +156,7 @@ RSpec.describe PresenceController do
let(:user2) { Fabricate(:user) }
let(:user3) { Fabricate(:user) }
- it "works" do
+ it "returns presence for the requested channels" do
get "/presence/get", params: { channels: [ch1.name] }
expect(response.status).to eq(200)
expect(response.parsed_body).to eq(
diff --git a/spec/requests/push_notification_controller_spec.rb b/spec/requests/push_notification_controller_spec.rb
index b0ac96662d7..403cf737d84 100644
--- a/spec/requests/push_notification_controller_spec.rb
+++ b/spec/requests/push_notification_controller_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe PushNotificationController do
fab!(:user)
context "when logged out" do
- it "should not allow subscribe" do
+ it "does not allow subscribing" do
post "/push_notifications/subscribe.json",
params: {
username: "test",
@@ -25,7 +25,7 @@ RSpec.describe PushNotificationController do
context "when logged in" do
before { sign_in(user) }
- it "should subscribe" do
+ it "subscribes the user" do
post "/push_notifications/subscribe.json",
params: {
username: user.username,
@@ -43,7 +43,7 @@ RSpec.describe PushNotificationController do
expect(user.push_subscriptions.count).to eq(1)
end
- it "should fix duplicate subscriptions" do
+ it "repairs duplicate subscriptions" do
subscription = { endpoint: "endpoint", keys: { p256dh: "256dh", auth: "auth" } }
PushSubscription.create user: user, data: subscription.to_json
post "/push_notifications/subscribe.json",
@@ -57,7 +57,7 @@ RSpec.describe PushNotificationController do
expect(user.push_subscriptions.count).to eq(1)
end
- it "should not create duplicate subscriptions" do
+ it "does not create duplicate subscriptions" do
2.times do
post "/push_notifications/subscribe.json",
params: {
@@ -77,7 +77,7 @@ RSpec.describe PushNotificationController do
expect(user.push_subscriptions.count).to eq(1)
end
- it "should unsubscribe with existing subscription" do
+ it "unsubscribes an existing subscription" do
sub = { endpoint: "endpoint", keys: { p256dh: "256dh", auth: "auth" } }
PushSubscription.create!(user: user, data: sub.to_json)
@@ -91,7 +91,7 @@ RSpec.describe PushNotificationController do
expect(user.push_subscriptions).to eq([])
end
- it "should unsubscribe without subscription" do
+ it "handles unsubscribing without a subscription" do
post "/push_notifications/unsubscribe.json",
params: {
username: user.username,
diff --git a/spec/requests/reviewables_controller_spec.rb b/spec/requests/reviewables_controller_spec.rb
index 7ed56d1d28f..91dd5fc108c 100644
--- a/spec/requests/reviewables_controller_spec.rb
+++ b/spec/requests/reviewables_controller_spec.rb
@@ -306,7 +306,7 @@ RSpec.describe ReviewablesController do
expect(json["reviewables"]).to be_present
end
- it "will use the ReviewableUser serializer for its fields" do
+ it "uses the ReviewableUser serializer for its fields" do
Jobs.run_immediately!
SiteSetting.must_approve_users = true
user = Fabricate(:user)
diff --git a/spec/requests/safe_mode_controller_spec.rb b/spec/requests/safe_mode_controller_spec.rb
index 5165885ac30..d7ad7f05350 100644
--- a/spec/requests/safe_mode_controller_spec.rb
+++ b/spec/requests/safe_mode_controller_spec.rb
@@ -31,14 +31,14 @@ RSpec.describe SafeModeController do
describe "enter" do
context "when no params are given" do
- it "should redirect back to safe mode page" do
+ it "redirects back to the safe-mode page" do
post "/safe-mode"
expect(response.status).to redirect_to(safe_mode_path)
end
end
context "when safe mode is not enabled" do
- it "should raise an error" do
+ it "returns an error" do
SiteSetting.enable_safe_mode = false
post "/safe-mode"
expect(response.status).to eq(404)
diff --git a/spec/requests/search_controller_spec.rb b/spec/requests/search_controller_spec.rb
index 04ec01f4fbf..601f4aaf1b2 100644
--- a/spec/requests/search_controller_spec.rb
+++ b/spec/requests/search_controller_spec.rb
@@ -226,7 +226,7 @@ RSpec.describe SearchController do
end
context "when searching by topic id" do
- it "should not be restricted by minimum search term length" do
+ it "is not restricted by the minimum search-term length" do
SiteSetting.min_search_term_length = 20_000
get "/search/query.json",
@@ -242,7 +242,7 @@ RSpec.describe SearchController do
expect(data["topics"][0]["id"]).to eq(awesome_post.topic_id)
end
- it "should return the right result" do
+ it "returns the topic matching the requested ID" do
get "/search/query.json",
params: {
term: user_post.topic_id,
diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb
index a5c21bb87f7..5c117d8e692 100644
--- a/spec/requests/session_controller_spec.rb
+++ b/spec/requests/session_controller_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe SessionController do
let(:admin_email_token) { Fabricate(:email_token, user: admin) }
shared_examples "failed to continue local login" do
- it "should return the right response" do
+ it "returns a forbidden response" do
expect(response).not_to be_successful
expect(response.status).to eq(403)
end
@@ -215,7 +215,7 @@ RSpec.describe SessionController do
end
context "when token has expired" do
- it "should return the right response" do
+ it "returns the expired-token error" do
email_token.update!(created_at: 999.years.ago)
post "/session/email-login/#{email_token.token}.json"
@@ -1207,7 +1207,7 @@ RSpec.describe SessionController do
describe "when in development mode" do
before { Rails.env.stubs(:development?).returns(true) }
- it "works" do
+ it "signs in as the requested user" do
get "/session/#{user.username}/become"
expect(response).to be_redirect
@@ -1352,7 +1352,7 @@ RSpec.describe SessionController do
end.not_to change { UserAuthToken.count }
end
- it "will never redirect back to /session/sso path" do
+ it "never redirects back to the SSO path" do
sso = get_sso("/session/sso?bla=1")
sso.email = user.email
sso.external_id = "abc"
@@ -1592,7 +1592,7 @@ RSpec.describe SessionController do
expect(response).to redirect_to("/")
end
- it "redirects to root if the host of the return_path is different" do
+ it "redirects protocol-relative external return paths to root" do
sso = get_sso("//eviltrout.com")
sso.external_id = "666"
sso.email = "[email protected]"
@@ -1603,7 +1603,7 @@ RSpec.describe SessionController do
expect(response).to redirect_to("/")
end
- it "redirects to root if the host of the return_path is different" do
+ it "redirects absolute external return paths to root" do
sso = get_sso("http://eviltrout.com")
sso.external_id = "666"
sso.email = "[email protected]"
@@ -2608,7 +2608,7 @@ RSpec.describe SessionController do
end
describe "invalid password" do
- it "should return an error with an invalid password" do
+ it "returns an error for an invalid password" do
post "/session.json", params: { login: user.username, password: "sssss" }
expect(response.status).to eq(200)
@@ -2617,7 +2617,7 @@ RSpec.describe SessionController do
)
end
- it "should return an error with an invalid password if too long" do
+ it "returns an error for an overlong password" do
User.any_instance.expects(:confirm_password?).never
post "/session.json",
params: {
@@ -2633,7 +2633,7 @@ RSpec.describe SessionController do
end
describe "suspended user" do
- it "should return an error" do
+ it "returns the suspension error" do
user.suspended_till = 2.days.from_now
user.suspended_at = Time.now
user.save!
@@ -2669,7 +2669,7 @@ RSpec.describe SessionController do
end
describe "deactivated user" do
- it "should return an error" do
+ it "returns the activation error" do
user.active = false
user.save!
@@ -2723,7 +2723,7 @@ RSpec.describe SessionController do
describe "when user's password has been marked as expired" do
before { RateLimiter.enable }
- it "should return an error response code with the right error message" do
+ it "returns the expired-password error" do
UserPasswordExpirer.expire_user_password(user)
post "/session.json", params: { login: user.username, password: "myawesomepassword" }
@@ -2861,7 +2861,7 @@ RSpec.describe SessionController do
let!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user: user) }
describe "when second factor token is missing" do
- it "should return the right response" do
+ it "returns the missing-second-factor error" do
post "/session.json", params: { login: user.username, password: "myawesomepassword" }
expect(response.status).to eq(200)
@@ -2873,7 +2873,7 @@ RSpec.describe SessionController do
describe "when second factor token is invalid" do
context "when using totp method" do
- it "should return the right response" do
+ it "returns the invalid-TOTP error" do
post "/session.json",
params: {
login: user.username,
@@ -2890,7 +2890,7 @@ RSpec.describe SessionController do
end
context "when using backup code method" do
- it "should return the right response" do
+ it "returns the invalid-backup-code error" do
post "/session.json",
params: {
login: user.username,
@@ -2909,7 +2909,7 @@ RSpec.describe SessionController do
describe "when second factor token is valid" do
context "when using totp method" do
- it "should log the user in" do
+ it "logs the user in with TOTP" do
post "/session.json",
params: {
login: user.username,
@@ -2932,7 +2932,7 @@ RSpec.describe SessionController do
end
context "when using backup code method" do
- it "should log the user in" do
+ it "logs the user in with a backup code" do
post "/session.json",
params: {
login: user.username,
@@ -3397,7 +3397,7 @@ RSpec.describe SessionController do
end
context "when token is valid" do
- it "should display the form for GET" do
+ it "displays the one-time-password form" do
token = SecureRandom.hex
Discourse.redis.setex "otp_#{token}", 10.minutes, user.username
@@ -3413,7 +3413,7 @@ RSpec.describe SessionController do
expect(session[:current_user_id]).to eq(nil)
end
- it "should redirect on GET if already logged in" do
+ it "redirects an already logged-in user" do
sign_in(user)
token = SecureRandom.hex
Discourse.redis.setex "otp_#{token}", 10.minutes, user.username
@@ -3425,7 +3425,7 @@ RSpec.describe SessionController do
expect(session[:current_user_id]).to eq(user.id)
end
- it "should authenticate user and delete token" do
+ it "authenticates the user and deletes the token" do
user = Fabricate(:user)
get "/session/current.json"
@@ -3483,7 +3483,7 @@ RSpec.describe SessionController do
expect(response.status).to eq(400)
end
- it "should correctly screen ips" do
+ it "screens blocked IP addresses" do
ScreenedIpAddress.create!(
ip_address: "100.0.0.1",
action_type: ScreenedIpAddress.actions[:block],
@@ -3505,7 +3505,7 @@ RSpec.describe SessionController do
describe "rate limiting" do
before { RateLimiter.enable }
- it "should correctly rate limits" do
+ it "rate-limits repeated password-reset requests" do
user = Fabricate(:user)
3.times do
diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb
index f4279c1b817..d88e1d8a872 100644
--- a/spec/requests/static_controller_spec.rb
+++ b/spec/requests/static_controller_spec.rb
@@ -156,7 +156,7 @@ RSpec.describe StaticController do
end
context "with a static file that's present" do
- it "should return the right response for /faq" do
+ it "returns the expected response for /faq" do
get "/faq"
expect(response).to redirect_to("/guidelines")
@@ -244,31 +244,31 @@ RSpec.describe StaticController do
end
context "with a missing file" do
- it "should respond 404" do
+ it "responds with 404" do
get "/static/does-not-exist"
expect(response.status).to eq(404)
end
context "with modal pages" do
- it "should return the right response for /signup" do
+ it "returns the expected response for /signup" do
get "/signup"
expect(response.status).to eq(200)
end
- it "should return the right response for /password-reset" do
+ it "returns the expected response for /password-reset" do
get "/password-reset"
expect(response.status).to eq(200)
end
end
end
- it "should redirect to / when logged in and path is /login without redirect" do
+ it "redirects a logged-in user from /login to /" do
sign_in(Fabricate(:user))
get "/login"
expect(response).to redirect_to("/")
end
- it "should display the login template when login is required" do
+ it "displays the login template when login is required" do
SiteSetting.login_required = true
get "/login"
@@ -311,7 +311,7 @@ RSpec.describe StaticController do
end
context "with crawler view" do
- it "should include correct title" do
+ it "includes the correct title" do
get "/guidelines", headers: { "HTTP_USER_AGENT" => "Googlebot" }
expect(response.status).to eq(200)
expect(response.body).to include("<title>Guidelines - Discourse</title>")
@@ -617,7 +617,7 @@ RSpec.describe StaticController do
end
describe "#service_worker_asset" do
- it "works" do
+ it "renders the requested static page" do
get "/service-worker.js"
expect(response.status).to eq(200)
expect(response.content_type).to start_with("text/javascript")
diff --git a/spec/requests/svg_sprite_controller_spec.rb b/spec/requests/svg_sprite_controller_spec.rb
index e3e0b7e0b3a..3af3668a8a2 100644
--- a/spec/requests/svg_sprite_controller_spec.rb
+++ b/spec/requests/svg_sprite_controller_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe SvgSpriteController do
describe "#show" do
before { SvgSprite.expire_cache }
- it "should return bundle when version is current" do
+ it "returns the bundle when its version is current" do
get "/svg-sprite/#{Discourse.current_hostname}/svg--#{SvgSprite.version}.js"
expect(response.status).to eq(200)
@@ -17,7 +17,7 @@ RSpec.describe SvgSpriteController do
expect(response.status).to eq(200)
end
- it "should redirect to current version" do
+ it "redirects to the current version" do
random_hash = Digest::SHA1.hexdigest("somerandomstring")
get "/svg-sprite/#{Discourse.current_hostname}/svg--#{random_hash}.js"
@@ -34,12 +34,12 @@ RSpec.describe SvgSpriteController do
end
describe "#search" do
- it "should not work for anons" do
+ it "rejects anonymous requests" do
get "/svg-sprite/search/bolt"
expect(response.status).to eq(404)
end
- it "should return symbol for FA icon search" do
+ it "returns the symbol for a Font Awesome icon search" do
sign_in(user)
get "/svg-sprite/search/bolt"
@@ -47,14 +47,14 @@ RSpec.describe SvgSpriteController do
expect(response.body).to include("bolt")
end
- it "should return 404 when looking for non-existent FA icon" do
+ it "returns 404 for a nonexistent Font Awesome icon" do
sign_in(user)
get "/svg-sprite/search/not-a-valid-icon"
expect(response.status).to eq(404)
end
- it "should find a custom icon in default theme" do
+ it "finds a custom icon in the default theme" do
theme = Fabricate(:theme)
fname = "custom-theme-icon-sprite.svg"
@@ -79,13 +79,13 @@ RSpec.describe SvgSpriteController do
end
describe "#icon_picker_search" do
- it "should return 403 for anonymous users" do
+ it "returns 403 for anonymous users" do
get "/svg-sprite/picker-search"
expect(response.status).to eq(403)
end
- it "should work with no filter and return one page of results" do
+ it "returns one page of results without a filter" do
sign_in(user)
get "/svg-sprite/picker-search"
@@ -96,7 +96,7 @@ RSpec.describe SvgSpriteController do
expect(data[0]["id"]).to be_in(SvgSprite.all_icons)
end
- it "should filter" do
+ it "filters the icon results" do
sign_in(user)
get "/svg-sprite/picker-search", params: { filter: "500px", only_available: "false" }
@@ -191,7 +191,7 @@ RSpec.describe SvgSpriteController do
expect(response.status).to eq(200)
end
- it "should display only available" do
+ it "displays only available icons" do
sign_in(user)
get "/svg-sprite/picker-search", params: { only_available: "true", filter: "beer" }
diff --git a/spec/requests/tag_groups_controller_spec.rb b/spec/requests/tag_groups_controller_spec.rb
index cb8895c894d..2c6eb9e7d3b 100644
--- a/spec/requests/tag_groups_controller_spec.rb
+++ b/spec/requests/tag_groups_controller_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe TagGroupsController do
fab!(:tag_group)
describe "for a non staff user" do
- it "should not be accessible" do
+ it "is not accessible" do
get "/tag_groups.json"
expect(response.status).to eq(404)
@@ -24,7 +24,7 @@ RSpec.describe TagGroupsController do
before { sign_in(admin) }
- it "should return the right response" do
+ it "returns the expected response" do
tag_group
get "/tag_groups.json"
@@ -186,7 +186,7 @@ RSpec.describe TagGroupsController do
before { sign_in(admin) }
- it "should create a tag group and log the creation" do
+ it "creates a tag group and logs the creation" do
post "/tag_groups.json",
params: {
tag_group: {
@@ -210,7 +210,7 @@ RSpec.describe TagGroupsController do
)
end
- it "should create a tag group with a parent tag" do
+ it "creates a tag group with a parent tag" do
post "/tag_groups.json",
params: {
tag_group: {
@@ -274,7 +274,7 @@ RSpec.describe TagGroupsController do
before { sign_in(admin) }
- it "should delete the tag group and log the deletion" do
+ it "deletes the tag group and logs the deletion" do
previous_value = TagGroupSerializer.new(tag_group).to_json(root: false)
delete "/tag_groups/#{tag_group.id}.json"
@@ -303,7 +303,7 @@ RSpec.describe TagGroupsController do
before { sign_in(admin) }
- it "should update the tag group and log the modification" do
+ it "updates the tag group and logs the change" do
previous_value = TagGroupSerializer.new(tag_group).to_json(root: false)
put "/tag_groups/#{tag_group.id}.json",
@@ -329,7 +329,7 @@ RSpec.describe TagGroupsController do
)
end
- it "should update the tag group's parent tag" do
+ it "updates the tag group's parent tag" do
put "/tag_groups/#{tag_group.id}.json",
params: {
tag_group: {
diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb
index 27d5e92d633..cd410881b4e 100644
--- a/spec/requests/tags_controller_spec.rb
+++ b/spec/requests/tags_controller_spec.rb
@@ -529,7 +529,7 @@ RSpec.describe TagsController do
fab!(:topic_without_tags, :topic)
fab!(:topic_with_tags) { Fabricate(:topic, tags: [tag]) }
- it "should return the right response" do
+ it "returns the requested tag in the topic list" do
get "/tag/test.json"
expect(response.status).to eq(200)
@@ -580,12 +580,12 @@ RSpec.describe TagsController do
expect(response.parsed_body["tag_info"]["name"]).to eq("node.js")
end
- it "should handle invalid tags" do
+ it "handles invalid tags" do
get "/tag/%2ftest%2f"
expect(response.status).to eq(404)
end
- it "should handle synonyms" do
+ it "handles tag synonyms" do
synonym = Fabricate(:tag, target_tag: tag)
get "/tag/#{synonym.name}/l/top.json?period=daily"
expect(response.status).to eq(301)
@@ -748,7 +748,7 @@ RSpec.describe TagsController do
expect(response.body).not_to include(private_category.name)
end
- it "should produce the topic inside the category and not the topic outside of it" do
+ it "returns the topic inside the requested category" do
get "/tags/c/#{category.slug}/#{tag.name}.json"
topic_ids = response.parsed_body["topic_list"]["topics"].map { |x| x["id"] }
@@ -757,7 +757,7 @@ RSpec.describe TagsController do
expect(topic_ids).to_not include(topic_in_category_without_tag.id)
end
- it "should produce the right next topic URL" do
+ it "returns the next topic URL" do
get "/tags/c/#{category.slug_path.join("/")}/#{category.id}/#{tag.name}.json?per_page=1"
expect(response.parsed_body["topic_list"]["more_topics_url"]).to start_with(
@@ -765,13 +765,13 @@ RSpec.describe TagsController do
)
end
- it "should 404 for invalid category path" do
+ it "returns 404 for an invalid category path" do
get "/tags/c/#{category.slug_path.join("/")}/#{category.id}/somerandomstring/#{tag.name}.json?per_page=1"
expect(response.status).to eq(404)
end
- it "should 404 for secure categories" do
+ it "returns 404 for restricted categories" do
c = Fabricate(:private_category, group: Fabricate(:group))
get "/tags/c/#{c.slug_path.join("/")}/#{c.id}/#{tag.name}.json"
@@ -786,7 +786,7 @@ RSpec.describe TagsController do
fab!(:topic_out_of_subcategory) { Fabricate(:topic, tags: [tag]) }
- it "should produce the topic inside the subcategory and not the topic outside of it" do
+ it "returns the topic inside the requested subcategory" do
get "/tags/c/#{category.slug}/#{subcategory.slug}/#{tag.name}.json"
topic_ids = response.parsed_body["topic_list"]["topics"].map { |x| x["id"] }
@@ -796,7 +796,7 @@ RSpec.describe TagsController do
end
end
- it "should ignore invalid tag parameter" do
+ it "ignores an invalid tag parameter" do
get "/tag/test.json?tags[0]=nada"
expect(response.status).to eq(200)
end
@@ -2621,13 +2621,13 @@ RSpec.describe TagsController do
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [staff_only_tag.name])
end
- it "should return 403 for an anonymous user" do
+ it "returns 403 for an anonymous user" do
get "/tags/list.json"
expect(response.status).to eq(403)
end
- it "should return 404 when tagging is disabled" do
+ it "returns 404 when tagging is disabled" do
SiteSetting.tagging_enabled = false
sign_in(user)
@@ -2637,7 +2637,7 @@ RSpec.describe TagsController do
expect(response.status).to eq(404)
end
- it "should only return tags that are visible to the user for non admin users" do
+ it "returns only visible tags for non-admin users" do
stub_const(TagsController, "LIST_LIMIT", 2) do
sign_in(user)
@@ -2666,7 +2666,7 @@ RSpec.describe TagsController do
end
end
- it "should return all tags for admin users" do
+ it "returns all tags for admins" do
stub_const(TagsController, "LIST_LIMIT", 2) do
sign_in(admin)
diff --git a/spec/requests/topic_view_stats_controller_spec.rb b/spec/requests/topic_view_stats_controller_spec.rb
index a517ce588de..8ece25d6e43 100644
--- a/spec/requests/topic_view_stats_controller_spec.rb
+++ b/spec/requests/topic_view_stats_controller_spec.rb
@@ -3,31 +3,31 @@
describe TopicViewStatsController do
fab!(:topic)
- it "will error if accessed on require login sites" do
+ it "returns an error on login-required sites" do
SiteSetting.login_required = true
get "/t/#{topic.id}/view-stats.json"
expect(response.status).to eq(403)
end
- it "will not allow access to private topics" do
+ it "does not allow access to private topics" do
topic.category.update!(read_restricted: true)
get "/t/#{topic.id}/view-stats.json"
expect(response.status).to eq(403)
end
- it "will raise correct errors if any param is invalid" do
+ it "returns errors for invalid parameters" do
get "/t/999999999999999999999999999999990000009/view-stats.json"
expect(response.status).to eq(404)
end
- it "will return an error if from and to are not valid dates" do
+ it "returns an error for invalid date parameters" do
get "/t/#{topic.id}/view-stats.json?from=abc&to=xxx"
expect(response.status).to eq(422)
end
- it "will return view stats for public topics" do
+ it "returns view statistics for public topics" do
freeze_time "2021-01-01 12:00"
TopicViewStat.create!(
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index f3abd87c736..69ad3eb20b2 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -236,7 +236,7 @@ RSpec.describe TopicsController do
end
describe "when topic has been deleted" do
- it "should still be able to move posts" do
+ it "still allows posts to be moved" do
PostDestroyer.new(admin, topic.first_post, context: "Automated testing").destroy
expect(topic.reload.deleted_at).to_not be_nil
@@ -730,7 +730,7 @@ RSpec.describe TopicsController do
end
describe "when message has been deleted" do
- it "should still be able to move posts" do
+ it "still allows posts to be moved" do
PostDestroyer.new(admin, message.first_post).destroy
expect(message.reload.deleted_at).to_not be_nil
@@ -1464,7 +1464,7 @@ RSpec.describe TopicsController do
Fabricate(:post, user: post_author2, topic: topic, created_at: old_timestamp + 1.day)
end
- it "should update the timestamps of selected posts" do
+ it "updates timestamps for the selected posts" do
# try to see if we fail with invalid first
put "/t/1/change-timestamp.json"
expect(response.status).to eq(400)
@@ -1477,7 +1477,7 @@ RSpec.describe TopicsController do
expect(p2.reload.created_at).to eq_time(old_timestamp)
end
- it "should create a staff log entry" do
+ it "creates a staff log entry" do
put "/t/#{topic.id}/change-timestamp.json", params: { timestamp: new_timestamp.to_f }
log = UserHistory.last
@@ -1504,7 +1504,7 @@ RSpec.describe TopicsController do
end
describe "when the user can see the topic" do
- it "succeeds" do
+ it "clears the topic pin" do
expect do put "/t/#{topic.id}/clear-pin.json" end.to change {
TopicUser.where(topic_id: topic.id, user_id: user.id).count
}.by(1)
@@ -1544,7 +1544,7 @@ RSpec.describe TopicsController do
expect(response.status).to eq(400)
end
- it "should update the status of the topic correctly" do
+ it "updates the topic status" do
closed_user_topic = Fabricate(:topic, user: user, closed: true)
Fabricate(:topic_timer, topic: closed_user_topic, status_type: TopicTimer.types[:open])
@@ -1559,7 +1559,7 @@ RSpec.describe TopicsController do
expect(body["topic_status_update"]).to eq(nil)
end
- it "should update the status when `enabled` is a truthy value" do
+ it "updates the status when enabled is truthy" do
closed_user_topic = Fabricate(:topic, user: user, closed: false)
put "/t/#{closed_user_topic.id}/status.json", params: { status: "closed", enabled: "t" }
@@ -1591,7 +1591,7 @@ RSpec.describe TopicsController do
SiteSetting.enable_category_group_moderation = true
end
- it "should allow a group moderator to close a topic" do
+ it "allows a group moderator to close a topic" do
put "/t/#{topic.id}/status.json", params: { status: "closed", enabled: "true" }
expect(response.status).to eq(200)
@@ -1599,7 +1599,7 @@ RSpec.describe TopicsController do
expect(topic.posts.last.action_code).to eq("closed.enabled")
end
- it "should allow a group moderator to open a closed topic" do
+ it "allows a group moderator to reopen a topic" do
topic.update!(closed: true)
expect do
@@ -1611,7 +1611,7 @@ RSpec.describe TopicsController do
expect(topic.posts.last.action_code).to eq("closed.disabled")
end
- it "should allow a group moderator to archive a topic" do
+ it "allows a group moderator to archive a topic" do
expect do
put "/t/#{topic.id}/status.json", params: { status: "archived", enabled: "true" }
end.to change { topic.reload.posts.count }.by(1)
@@ -1621,7 +1621,7 @@ RSpec.describe TopicsController do
expect(topic.posts.last.action_code).to eq("archived.enabled")
end
- it "should allow a group moderator to unarchive an archived topic" do
+ it "allows a group moderator to unarchive a topic" do
topic.update!(archived: true)
put "/t/#{topic.id}/status.json", params: { status: "archived", enabled: "false" }
@@ -1631,7 +1631,7 @@ RSpec.describe TopicsController do
expect(topic.posts.last.action_code).to eq("archived.disabled")
end
- it "should allow a group moderator to pin a topic" do
+ it "allows a group moderator to pin a topic" do
put "/t/#{topic.id}/status.json",
params: {
status: "pinned",
@@ -1643,14 +1643,14 @@ RSpec.describe TopicsController do
expect(topic.reload.pinned_at).to_not eq(nil)
end
- it "should allow a group moderator to unpin a topic" do
+ it "allows a group moderator to unpin a topic" do
put "/t/#{topic.id}/status.json", params: { status: "pinned", enabled: "false" }
expect(response.status).to eq(200)
expect(topic.reload.pinned_at).to eq(nil)
end
- it "should allow a group moderator to unlist a topic" do
+ it "allows a group moderator to unlist a topic" do
put "/t/#{topic.id}/status.json", params: { status: "visible", enabled: "false" }
expect(response.status).to eq(200)
@@ -1661,7 +1661,7 @@ RSpec.describe TopicsController do
expect(topic.posts.last.action_code).to eq("visible.disabled")
end
- it "should allow a group moderator to list an unlisted topic" do
+ it "allows a group moderator to relist a topic" do
topic.update!(visible: false)
put "/t/#{topic.id}/status.json", params: { status: "visible", enabled: "true" }
@@ -1848,7 +1848,7 @@ RSpec.describe TopicsController do
end
context "for last post only" do
- it "should allow you to retain topic timing but remove last post only" do
+ it "retains topic timing while removing only the last post" do
freeze_time
post1 = create_post
@@ -1968,7 +1968,7 @@ RSpec.describe TopicsController do
end
describe "#recover" do
- it "won't allow us to recover a topic when we're not logged in" do
+ it "does not recover a topic for an anonymous user" do
put "/t/1/recover.json"
expect(response.status).to eq(403)
end
@@ -2007,7 +2007,7 @@ RSpec.describe TopicsController do
context "with permission" do
before { sign_in(moderator) }
- it "succeeds" do
+ it "recovers the topic" do
put "/t/#{topic.id}/recover.json"
topic.reload
post.reload
@@ -2086,7 +2086,7 @@ RSpec.describe TopicsController do
end
describe "#delete" do
- it "won't allow us to delete a topic when we're not logged in" do
+ it "does not delete a topic for an anonymous user" do
delete "/t/1.json"
expect(response.status).to eq(403)
end
@@ -2106,7 +2106,7 @@ RSpec.describe TopicsController do
describe "with permission" do
before { sign_in(moderator) }
- it "succeeds" do
+ it "deletes the topic" do
delete "/t/#{topic.id}.json"
expect(response.status).to eq(200)
topic.reload
@@ -2272,7 +2272,7 @@ RSpec.describe TopicsController do
end
describe "#update" do
- it "won't allow us to update a topic when we're not logged in" do
+ it "does not update a topic for an anonymous user" do
put "/t/1.json", params: { slug: "xyz" }
expect(response.status).to eq(403)
end
@@ -2379,7 +2379,7 @@ RSpec.describe TopicsController do
fab!(:post_hook, :post_web_hook)
fab!(:topic_hook, :topic_web_hook)
- it "succeeds" do
+ it "updates the topic" do
put "/t/#{topic.slug}/#{topic.id}.json"
expect(response.status).to eq(200)
@@ -2987,7 +2987,7 @@ RSpec.describe TopicsController do
expect(topic.reload.tags.map(&:name)).not_to include(tag3.name)
end
- it "will clean tag params" do
+ it "cleans tag parameters" do
restricted_category.allowed_tags = [tag2.name]
put "/t/#{topic.slug}/#{topic.id}.json",
@@ -3214,7 +3214,7 @@ RSpec.describe TopicsController do
end
describe "when user does not have access to the topic" do
- it "should return the right response" do
+ it "returns a not-found response" do
sign_in(user)
get "/t/external_id/private.json"
@@ -3230,7 +3230,7 @@ RSpec.describe TopicsController do
fab!(:topic) { Fabricate(:post, user: post_author1).topic }
describe "when topic is not allowed" do
- it "should return the right response" do
+ it "returns a not-found response" do
SiteSetting.detailed_404 = true
sign_in(user)
@@ -3917,7 +3917,7 @@ RSpec.describe TopicsController do
end
expected_slug_response = expected[:secure_topic] == 200 ? 301 : expected[:secure_topic]
- it "will return a #{expected_slug_response} when requesting a secure topic by slug" do
+ it "returns a #{expected_slug_response} for a secure topic requested by slug" do
format = request_json ? ".json" : ""
get "/t/#{secure_topic.slug}#{format}"
expect(response.status).to eq(expected_slug_response)
@@ -4392,7 +4392,7 @@ RSpec.describe TopicsController do
fab!(:quote_reply) { Fabricate(:basic_reply, user: user, topic: topic) }
fab!(:post_reply) { PostReply.create(post_id: post2.id, reply_post_id: quote_reply.id) }
- it "should return the right posts" do
+ it "returns replies to the selected post" do
get "/t/#{topic.id}.json", params: { replies_to_post_number: post2.post_number }
expect(response.status).to eq(200)
@@ -4434,7 +4434,7 @@ RSpec.describe TopicsController do
)
end
- it "should return the right posts" do
+ it "returns top-level replies" do
get "/t/#{topic.id}.json", params: { filter_top_level_replies: true }
expect(response.status).to eq(200)
@@ -4469,7 +4469,7 @@ RSpec.describe TopicsController do
end
fab!(:post6) { Fabricate(:post, user: post_author6, topic: topic) }
- it "should return the right posts" do
+ it "returns posts preceding the selected post" do
get "/t/#{topic.id}.json", params: { filter_upwards_post_id: post5.id }
expect(response.status).to eq(200)
@@ -4485,7 +4485,7 @@ RSpec.describe TopicsController do
expect(ids).to eq([post.id, post4.id, post5.id, post6.id])
end
- it "should respect max_reply_history site setting" do
+ it "respects the max_reply_history site setting" do
SiteSetting.max_reply_history = 2
get "/t/#{topic.id}.json", params: { filter_upwards_post_id: post5.id }
@@ -4891,7 +4891,7 @@ RSpec.describe TopicsController do
fab!(:post2) { Fabricate(:post, topic: topic, user: user) }
fab!(:post3) { Fabricate(:post, user: post_author3, topic: topic) }
- it "should return the right posts" do
+ it "returns post IDs matching the username filter" do
get "/t/#{topic.id}/post_ids.json",
params: {
post_number: post.post_number,
@@ -4910,7 +4910,7 @@ RSpec.describe TopicsController do
fab!(:post2) { Fabricate(:post, user: post_author2, topic: topic, percent_rank: 0.2) }
fab!(:post3) { Fabricate(:post, user: post_author3, topic: topic) }
- it "should return the right posts" do
+ it "returns summarized post IDs" do
get "/t/#{topic.id}/post_ids.json",
params: {
post_number: post.post_number,
@@ -4931,7 +4931,7 @@ RSpec.describe TopicsController do
after { TopicView.custom_filters.clear }
- it "should return the right posts" do
+ it "returns post IDs matching custom filters" do
TopicView.add_custom_filter("percent") do |posts, topic_view|
posts.where(percent_rank: 0.5)
end
@@ -5013,7 +5013,7 @@ RSpec.describe TopicsController do
fab!(:post2) { Fabricate(:post, user: post_author2, topic: topic) }
fab!(:post3) { Fabricate(:post, user: post_author3, topic: topic) }
- it "should return the right posts" do
+ it "returns posts matching the username filter" do
TopicView.stubs(:chunk_size).returns(2)
get "/t/#{topic.id}/posts.json",
@@ -5035,7 +5035,7 @@ RSpec.describe TopicsController do
fab!(:post2) { Fabricate(:post, user: post_author2, topic: topic, percent_rank: 0.2) }
fab!(:post3) { Fabricate(:post, user: post_author3, topic: topic) }
- it "should return the right posts" do
+ it "returns summarized posts" do
TopicView.stubs(:chunk_size).returns(2)
get "/t/#{topic.id}/posts.json",
@@ -5788,7 +5788,7 @@ RSpec.describe TopicsController do
expect(response.parsed_body["error_type"]).to eq("not_found")
end
- it "should remove bookmarks properly from non first post" do
+ it "removes bookmarks from a non-first post" do
sign_in(user)
post = create_post
@@ -5833,7 +5833,7 @@ RSpec.describe TopicsController do
expect(response.parsed_body["error_type"]).to eq("not_found")
end
- it "should create a new bookmark for the topic" do
+ it "creates a topic bookmark" do
post = create_post
_post2 = create_post(topic_id: post.topic_id)
put "/t/#{post.topic_id}/bookmark.json"
@@ -5852,7 +5852,7 @@ RSpec.describe TopicsController do
describe "#reset_new" do
context "when a user is not signed in" do
- it "fails" do
+ it "requires authentication" do
put "/topics/reset-new.json"
expect(response.status).to eq(403)
end
@@ -6707,7 +6707,7 @@ RSpec.describe TopicsController do
Fabricate(:post, user: post_author1, topic: topic, post_type: Post.types[:whisper])
end
- it "should gracefully handle invalid timings sent in" do
+ it "ignores invalid timing values" do
sign_in(user)
params = {
topic_id: topic.id,
@@ -6734,7 +6734,7 @@ RSpec.describe TopicsController do
expect(tu.last_read_post_number).to eq(post_1.post_number)
end
- it "should gracefully handle invalid timings sent in from staff" do
+ it "ignores invalid timing values from staff" do
sign_in(admin)
post "/topics/timings.json",
@@ -6776,7 +6776,7 @@ RSpec.describe TopicsController do
end
end
- it "should record the timing" do
+ it "records the topic timing" do
sign_in(user)
post "/topics/timings.json",
@@ -6826,14 +6826,14 @@ RSpec.describe TopicsController do
describe "#timer" do
context "when a user is not logged in" do
- it "should return the right response" do
+ it "requires authentication" do
post "/t/#{topic.id}/timer.json", params: { time: "24", status_type: TopicTimer.types[1] }
expect(response.status).to eq(403)
end
end
context "when does not have permission" do
- it "should return the right response" do
+ it "forbids a user without permission" do
sign_in(user)
post "/t/#{topic.id}/timer.json", params: { time: "24", status_type: TopicTimer.types[1] }
@@ -6889,7 +6889,7 @@ RSpec.describe TopicsController do
sign_in(admin)
end
- it "should be able to create a topic status update" do
+ it "creates a topic status update" do
post "/t/#{topic.id}/timer.json", params: { time: 24, status_type: TopicTimer.types[1] }
expect(response.status).to eq(200)
@@ -6909,7 +6909,7 @@ RSpec.describe TopicsController do
expect(json["closed"]).to eq(topic.reload.closed)
end
- it "should be able to delete a topic status update" do
+ it "deletes a topic status update" do
Fabricate(:topic_timer, topic: topic)
post "/t/#{topic.id}/timer.json", params: { time: nil, status_type: TopicTimer.types[1] }
@@ -6924,7 +6924,7 @@ RSpec.describe TopicsController do
expect(json["closed"]).to eq(topic.closed)
end
- it "should be able to create a topic status update with duration" do
+ it "creates a topic status update with a duration" do
post "/t/#{topic.id}/timer.json",
params: {
duration_minutes: 7200,
@@ -6948,7 +6948,7 @@ RSpec.describe TopicsController do
expect(json["duration_minutes"]).to eq(topic_status_update.duration_minutes)
end
- it "should be able to delete a topic status update for delete_replies type" do
+ it "deletes a delete_replies topic status update" do
Fabricate(:topic_timer, topic: topic, status_type: TopicTimer.types[:delete_replies])
post "/t/#{topic.id}/timer.json", params: { time: nil, status_type: TopicTimer.types[7] }
@@ -6964,7 +6964,7 @@ RSpec.describe TopicsController do
end
describe "publishing topic to category in the future" do
- it "should be able to create the topic status update" do
+ it "creates the topic status update" do
post "/t/#{topic.id}/timer.json",
params: {
time: 24,
@@ -6987,13 +6987,13 @@ RSpec.describe TopicsController do
end
describe "publishing topic to category without category_id" do
- it "should return an error when setting a timer" do
+ it "returns an error when setting a timer" do
post "/t/#{topic.id}/timer.json", params: { time: 24, status_type: "publish_to_category" }
expect(response.status).to eq(404)
end
- it "should allow removing a timer" do
+ it "allows removing a timer" do
topic.set_or_create_timer(
TopicTimer.types[:publish_to_category],
24,
@@ -7013,7 +7013,7 @@ RSpec.describe TopicsController do
end
describe "invalid status type" do
- it "should raise the right error" do
+ it "returns the invalid-status error" do
post "/t/#{topic.id}/timer.json", params: { time: 10, status_type: "something" }
expect(response.status).to eq(400)
expect(response.body).to include("status_type")
@@ -7243,7 +7243,7 @@ RSpec.describe TopicsController do
describe "changes slow mode" do
before { sign_in(admin) }
- it "should create a staff log entry" do
+ it "creates a staff log entry" do
put "/t/#{topic.id}/slow_mode.json", params: { seconds: "3600" }
log = UserHistory.last
@@ -7263,7 +7263,7 @@ RSpec.describe TopicsController do
describe "#invite" do
context "when not logged in" do
- it "should return the right response" do
+ it "requires authentication" do
post "/t/#{topic.id}/invite.json", params: { email: "[email protected]" }
expect(response.status).to eq(403)
@@ -7276,7 +7276,7 @@ RSpec.describe TopicsController do
context "when topic id is not PM" do
fab!(:user_topic) { Fabricate(:topic, user: user) }
- it "should return the right response" do
+ it "rejects a non-private-message topic" do
user.update!(trust_level: TrustLevel[2])
post "/t/#{user_topic.id}/invite.json", params: { email: "[email protected]" }
@@ -7286,7 +7286,7 @@ RSpec.describe TopicsController do
end
context "when topic id is invalid" do
- it "should return the right response" do
+ it "returns a not-found response" do
id = topic.id
topic.destroy!
post "/t/#{id}/invite.json", params: { email: user.email }
@@ -7367,7 +7367,7 @@ RSpec.describe TopicsController do
context "when user does not have permission to invite to the topic" do
fab!(:topic) { pm }
- it "should return the right response" do
+ it "forbids a user without invitation permission" do
post "/t/#{topic.id}/invite.json", params: { user: user.username }
expect(response.status).to eq(403)
@@ -7387,7 +7387,7 @@ RSpec.describe TopicsController do
before { admins.update!(messageable_level: Group::ALIAS_LEVELS[:everyone]) }
context "as an anon user" do
- it "should be forbidden" do
+ it "forbids the invitation" do
invite_group(pm, 403)
end
end
@@ -7396,7 +7396,7 @@ RSpec.describe TopicsController do
before { sign_in(user) }
context "when user does not have permission to view the topic" do
- it "should be forbidden" do
+ it "forbids the invitation" do
invite_group(pm, 403)
end
end
@@ -7404,7 +7404,7 @@ RSpec.describe TopicsController do
context "when user has permission to view the topic" do
before { pm.allowed_users << user }
- it "should allow user to invite group to topic" do
+ it "allows the user to invite a group to the topic" do
invite_group(pm, 200)
expect(pm.allowed_groups.first.id).to eq(admins.id)
end
@@ -7544,7 +7544,7 @@ RSpec.describe TopicsController do
context "as staff" do
before { sign_in(moderator) }
- it "will publish the topic" do
+ it "publishes the topic" do
put "/t/#{topic.id}/publish.json", params: { destination_category_id: category.id }
expect(response.status).to eq(200)
json = response.parsed_body["basic_topic"]
@@ -7947,7 +7947,7 @@ RSpec.describe TopicsController do
end
end
- it "should fail for non-existent topic" do
+ it "returns an error for a missing topic" do
max_id = Topic.maximum(:id)
sign_in(admin)
put "/t/#{max_id + 1}/reset-bump-date.json"
@@ -7963,7 +7963,7 @@ RSpec.describe TopicsController do
end
%i[admin moderator trust_level_4].each do |user|
- it "should reset bumped_at as #{user}" do
+ it "resets bumped_at as #{user}" do
sign_in(public_send(user))
topic.update!(bumped_at: 1.hour.ago)
timestamp = 1.day.ago
@@ -8129,7 +8129,7 @@ RSpec.describe TopicsController do
).topic
end
- it "should be able to archive a private message" do
+ it "archives a private message" do
sign_in(user)
message =
diff --git a/spec/requests/uploads_controller_spec.rb b/spec/requests/uploads_controller_spec.rb
index 362884bce08..ead49eba54f 100644
--- a/spec/requests/uploads_controller_spec.rb
+++ b/spec/requests/uploads_controller_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe UploadsController do
context "when rate limited" do
before { RateLimiter.enable }
- it "should return 429 response code when maximum number of uploads per minute has been exceeded for a user" do
+ it "returns 429 after the user exceeds the upload rate limit" do
SiteSetting.max_uploads_per_minute = 1
post "/uploads.json",
@@ -296,7 +296,7 @@ RSpec.describe UploadsController do
)
end
- it "should accept large files if system user" do
+ it "accepts large files from the system user" do
SiteSetting.authorized_extensions = "*"
SiteSetting.system_user_max_attachment_size_kb = 421_730
@@ -304,7 +304,7 @@ RSpec.describe UploadsController do
expect(response.status).to eq(200)
end
- it "should fail to accept large files if system user system_user_max_attachment_size_kb setting is low" do
+ it "rejects large system-user files above the system limit" do
SiteSetting.authorized_extensions = "*"
SiteSetting.max_attachment_size_kb = 1
SiteSetting.system_user_max_attachment_size_kb = 1
@@ -318,7 +318,7 @@ RSpec.describe UploadsController do
)
end
- it "should fail to accept large files if system user system_user_max_attachment_size_kb setting is low and general setting is low" do
+ it "rejects large system-user files when both limits are low" do
SiteSetting.authorized_extensions = "*"
SiteSetting.max_attachment_size_kb = 10
SiteSetting.system_user_max_attachment_size_kb = 5
@@ -332,7 +332,7 @@ RSpec.describe UploadsController do
)
end
- it "should fail to accept large files if attachment_size settings are low" do
+ it "rejects large files above the attachment limit" do
SiteSetting.authorized_extensions = "*"
SiteSetting.max_attachment_size_kb = 1
SiteSetting.system_user_max_attachment_size_kb = 10
@@ -567,7 +567,7 @@ RSpec.describe UploadsController do
before { setup_s3 }
- it "should redirect to the s3 URL" do
+ it "redirects to the S3 URL" do
get upload.short_path
expect(response).to redirect_to(upload.url)
@@ -652,12 +652,12 @@ RSpec.describe UploadsController do
SiteSetting.secure_uploads = true
end
- it "should return 404 for anonymous requests requests" do
+ it "returns 404 for anonymous requests" do
get secure_url
expect(response.status).to eq(404)
end
- it "should return signed url for legitimate request" do
+ it "returns a signed URL for an authorized request" do
sign_in(user)
get secure_url
@@ -677,7 +677,7 @@ RSpec.describe UploadsController do
expect(response.redirect_url).to include("response-content-disposition=inline")
end
- it "should return secure uploads URL when looking up urls" do
+ it "returns the secure-upload URL during lookup" do
upload.update_column(:secure, true)
sign_in(user)
@@ -705,13 +705,13 @@ RSpec.describe UploadsController do
before { upload.update(access_control_post_id: post.id) }
context "when the user is anon" do
- it "should return signed url for public posts" do
+ it "returns a signed URL for public posts" do
get secure_url
expect(response.status).to eq(302)
expect(response.redirect_url).to match("Amz-Expires")
end
- it "should return 403 for deleted posts" do
+ it "returns 403 for deleted posts" do
post.trash!
get secure_url
expect(response.status).to eq(403)
@@ -731,7 +731,7 @@ RSpec.describe UploadsController do
before { sign_in(user) }
context "when the user has access to the post via guardian" do
- it "should return signed url for legitimate request" do
+ it "returns a signed URL for an authorized request" do
get secure_url
expect(response.status).to eq(302)
expect(response.redirect_url).to match("Amz-Expires")
@@ -806,7 +806,7 @@ RSpec.describe UploadsController do
context "if the upload is secure false, meaning the ACL is probably public" do
before { upload.update(secure: false) }
- it "should redirect to the regular show route" do
+ it "redirects to the regular show route" do
secure_url = upload.url.sub(SiteSetting.Upload.absolute_base_url, "/secure-uploads")
sign_in(user)
get secure_url
@@ -819,7 +819,7 @@ RSpec.describe UploadsController do
context "if the upload is secure true, meaning the ACL is probably private" do
before { upload.update(secure: true) }
- it "should redirect to the presigned URL still otherwise we will get a 403" do
+ it "redirects to the presigned URL" do
secure_url = upload.url.sub(SiteSetting.Upload.absolute_base_url, "/secure-uploads")
sign_in(user)
get secure_url
@@ -960,7 +960,7 @@ RSpec.describe UploadsController do
fab!(:upload)
describe "when url is missing" do
- it "should return the right response" do
+ it "requires a URL" do
post "/uploads/lookup-metadata.json"
expect(response.status).to eq(403)
@@ -968,7 +968,7 @@ RSpec.describe UploadsController do
end
describe "when not signed in" do
- it "should return the right response" do
+ it "requires authentication" do
post "/uploads/lookup-metadata.json", params: { url: upload.url }
expect(response.status).to eq(403)
@@ -1003,14 +1003,14 @@ RSpec.describe UploadsController do
end
describe "when url is invalid" do
- it "should return the right response" do
+ it "rejects an invalid URL" do
post "/uploads/lookup-metadata.json", params: { url: "abc" }
expect(response.status).to eq(404)
end
end
- it "should return the right response" do
+ it "returns the upload metadata" do
post "/uploads/lookup-metadata.json", params: { url: upload.url }
expect(response.status).to eq(200)
diff --git a/spec/requests/user_actions_controller_spec.rb b/spec/requests/user_actions_controller_spec.rb
index 08339c7cf00..90b9128703d 100644
--- a/spec/requests/user_actions_controller_spec.rb
+++ b/spec/requests/user_actions_controller_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe UserActionsController do
context "when 'username' is not specified" do
let(:params) { {} }
- it "fails" do
+ it "returns 400 when username is missing" do
user_actions
expect(response).to have_http_status :bad_request
end
@@ -103,7 +103,7 @@ RSpec.describe UserActionsController do
context "when `allow_users_to_hide_profile` is disabled" do
before { SiteSetting.allow_users_to_hide_profile = false }
- it "succeeds" do
+ it "returns user actions when profile hiding is disabled" do
user_actions
expect(response).to have_http_status :ok
end
diff --git a/spec/requests/user_api_key_clients_controller_spec.rb b/spec/requests/user_api_key_clients_controller_spec.rb
index 2941e7ee506..ddc08f765a6 100644
--- a/spec/requests/user_api_key_clients_controller_spec.rb
+++ b/spec/requests/user_api_key_clients_controller_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe UserApiKeyClientsController do
context "with a registered client" do
before { Fabricate(:user_api_key_client, **args) }
- it "succeeds" do
+ it "returns 200 for a registered client" do
head "/user-api-key-client.json", params: { client_id: args[:client_id] }
expect(response.status).to eq(200)
end
@@ -102,7 +102,7 @@ RSpec.describe UserApiKeyClientsController do
context "with rate limiting" do
before { RateLimiter.enable }
- it "works" do
+ it "rejects client creation after the daily limit is reached" do
SiteSetting.user_api_key_clients_create_per_day = 1
post "/user-api-key-client.json", params: args_with_scopes
expect(response.status).to eq(200)
diff --git a/spec/requests/user_badges_controller_spec.rb b/spec/requests/user_badges_controller_spec.rb
index b1c771d1c95..31c17a8e31c 100644
--- a/spec/requests/user_badges_controller_spec.rb
+++ b/spec/requests/user_badges_controller_spec.rb
@@ -305,7 +305,7 @@ RSpec.describe UserBadgesController do
)
end
- it "will trigger :user_badge_granted" do
+ it "triggers user_badge_granted" do
sign_in(Fabricate(:admin))
events =
@@ -431,7 +431,7 @@ RSpec.describe UserBadgesController do
expect(UserHistory.where(acting_user: admin, target_user: user).count).to eq(1)
end
- it "will trigger :user_badge_removed" do
+ it "triggers user_badge_removed" do
sign_in(Fabricate(:admin))
events =
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 26fc3cb8fd9..28c2bf8455a 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe UsersController do
describe "#full account registration flow" do
let(:server_session) { request.server_session }
- it "will correctly handle honeypot and challenge" do
+ it "handles the honeypot and challenge fields" do
get "/session/hp.json"
expect(response.status).to eq(200)
@@ -128,7 +128,7 @@ RSpec.describe UsersController do
context "when user is not approved" do
before { SiteSetting.must_approve_users = true }
- it "should return the right response" do
+ it "returns the pending-approval response" do
put "/u/activate-account/#{email_token.token}"
expect(response.status).to eq(200)
@@ -152,7 +152,7 @@ RSpec.describe UsersController do
context "when cookies contains a destination URL" do
context "when the destination URL has a query" do
- it "should redirect to the URL and preserve the query" do
+ it "redirects to the URL and preserves its query" do
destination_url = "http://thisisasite.com/somepath?latest=1"
cookies[:destination_url] = destination_url
@@ -164,7 +164,7 @@ RSpec.describe UsersController do
end
context "when destination URL doesn't have a query" do
- it "should redirect to the URL" do
+ it "redirects to the URL" do
destination_url = "http://thisisasite.com/somepath"
cookies[:destination_url] = destination_url
@@ -186,7 +186,7 @@ RSpec.describe UsersController do
invite.reload
end
- it "should redirect to the topic" do
+ it "redirects to the topic" do
put "/u/activate-account/#{email_token.token}"
expect(response.status).to eq(200)
@@ -862,7 +862,7 @@ RSpec.describe UsersController do
end
context "when email params is missing" do
- it "should raise the right error" do
+ it "returns the missing-email error" do
post "/u.json",
params: {
name: @user.name,
@@ -1213,7 +1213,7 @@ RSpec.describe UsersController do
end
context "when creating as active" do
- it "won't create the user as active" do
+ it "does not create the user as active" do
post "/u.json", params: post_user_params.merge(active: true)
expect(response.status).to eq(200)
expect(response.parsed_body["active"]).to be_falsey
@@ -1222,7 +1222,7 @@ RSpec.describe UsersController do
context "with a regular api key" do
fab!(:api_key, refind: false) { Fabricate(:api_key, user: user1) }
- it "won't create the user as active with a regular key" do
+ it "does not activate the user with a regular API key" do
post "/u.json",
params: post_user_params.merge(active: true),
headers: {
@@ -1261,7 +1261,7 @@ RSpec.describe UsersController do
expect(new_user.email_tokens.where(confirmed: true, email: new_user.email)).to exist
end
- it "will create a reviewable when a user is created as active but not approved" do
+ it "creates a reviewable for an active unapproved user" do
Jobs.run_immediately!
SiteSetting.must_approve_users = true
@@ -1280,7 +1280,7 @@ RSpec.describe UsersController do
expect(ReviewableUser.pending.find_by(target: new_user)).to be_present
end
- it "won't create a reviewable when a user is not active" do
+ it "does not create a reviewable for an inactive user" do
Jobs.run_immediately!
SiteSetting.must_approve_users = true
@@ -1295,7 +1295,7 @@ RSpec.describe UsersController do
expect(ReviewableUser.pending.find_by(target: new_user)).to be_blank
end
- it "won't create the developer as active" do
+ it "does not create the developer as active" do
UsernameCheckerService.expects(:is_developer?).returns(true)
post "/u.json",
@@ -1307,7 +1307,7 @@ RSpec.describe UsersController do
expect(response.parsed_body["active"]).to be_falsy
end
- it "won't set the new user's locale to the admin's locale" do
+ it "does not copy the administrator's locale to the new user" do
SiteSetting.allow_user_locale = true
admin.update!(locale: :fr)
@@ -1323,7 +1323,7 @@ RSpec.describe UsersController do
expect(new_user.locale).not_to eq("fr")
end
- it "will auto approve user if the user email domain matches auto_approve_email_domains setting" do
+ it "automatically approves a user from a configured email domain" do
Jobs.run_immediately!
SiteSetting.must_approve_users = true
SiteSetting.auto_approve_email_domains = "example.com"
@@ -1346,7 +1346,7 @@ RSpec.describe UsersController do
end
context "when creating as staged" do
- it "won't create the user as staged" do
+ it "does not create the user as staged" do
post "/u.json", params: post_user_params.merge(staged: true)
expect(response.status).to eq(200)
new_user = User.where(username: post_user_params[:username]).first
@@ -1356,7 +1356,7 @@ RSpec.describe UsersController do
context "with a regular api key" do
fab!(:api_key, refind: false) { Fabricate(:api_key, user: user1) }
- it "won't create the user as staged with a regular key" do
+ it "does not stage the user with a regular API key" do
post "/u.json",
params: post_user_params.merge(staged: true),
headers: {
@@ -1385,7 +1385,7 @@ RSpec.describe UsersController do
expect(new_user.staged?).to eq(true)
end
- it "won't create the developer as staged" do
+ it "does not create the developer as staged" do
UsernameCheckerService.expects(:is_developer?).returns(true)
post "/u.json",
params: post_user_params.merge(staged: true),
@@ -1421,7 +1421,7 @@ RSpec.describe UsersController do
expect(response.parsed_body["message"]).to eq(I18n.t "login.active")
end
- it "should be logged in" do
+ it "logs in the new user" do
User.any_instance.expects(:enqueue_welcome_message)
post_user
expect(response.status).to eq(200)
@@ -1471,7 +1471,7 @@ RSpec.describe UsersController do
OmniAuth.config.test_mode = false
end
- it "should create twitter user info if required" do
+ it "creates Twitter user information when required" do
post "/u.json",
params: {
name: "Test Osama",
@@ -1499,7 +1499,7 @@ RSpec.describe UsersController do
expect(json["message"]).to be_present
end
- it "will create the user successfully if email validation is required" do
+ it "creates the user when email validation is required" do
post "/u.json",
params: {
name: "Test Osama",
@@ -1553,7 +1553,7 @@ RSpec.describe UsersController do
OmniAuth.config.test_mode = false
end
- it "will create the user successfully" do
+ it "creates the user" do
Rails.application.env_config["omniauth.auth"].info.email = nil
post "/u.json",
@@ -1580,7 +1580,7 @@ RSpec.describe UsersController do
end
shared_examples "honeypot fails" do
- it "should not create a new user" do
+ it "does not create a new user" do
User.any_instance.expects(:enqueue_welcome_message).never
expect { post "/u.json", params: create_params }.to_not change { User.count }
@@ -1644,12 +1644,12 @@ RSpec.describe UsersController do
end
shared_examples "failed signup" do
- it "should not create a new User" do
+ it "does not create a new user" do
expect { post "/u.json", params: create_params }.to_not change { User.count }
expect(response.status).to eq(200)
end
- it "should report failed" do
+ it "reports the failed signup" do
post "/u.json", params: create_params
json = response.parsed_body
expect(json["success"]).not_to eq(true)
@@ -1726,7 +1726,7 @@ RSpec.describe UsersController do
context "with a missing username" do
let(:create_params) { { name: @user.name, email: @user.email, password: "x" * 20 } }
- it "should not create a new User" do
+ it "does not create a new user" do
expect { post "/u.json", params: create_params }.to_not change { User.count }
expect(response.status).to eq(400)
end
@@ -1798,7 +1798,7 @@ RSpec.describe UsersController do
end
end
- it "should allow single values and not just arrays" do
+ it "accepts a single value as well as an array" do
expect do
put update_user_url, params: { user_fields: { field_id => "Axe" } }
end.to change { user1.reload.user_fields[field_id] }.from(nil).to("Axe")
@@ -1808,13 +1808,13 @@ RSpec.describe UsersController do
end.to change { user1.reload.user_fields[field_id] }.from("Axe").to(%w[Axe Sword])
end
- it "shouldn't allow unregistered field values" do
+ it "rejects unregistered field values" do
expect do
put update_user_url, params: { user_fields: { field_id => %w[Juice] } }
end.not_to change { user1.reload.user_fields[field_id] }
end
- it "should filter valid values" do
+ it "filters valid field values" do
expect do
put update_user_url, params: { user_fields: { field_id => %w[Axe Juice Sword] } }
end.to change { user1.reload.user_fields[field_id] }.from(nil).to(valid_options)
@@ -1885,7 +1885,7 @@ RSpec.describe UsersController do
end
end
- it "shouldn't allow unregistered field values" do
+ it "rejects unregistered field values" do
expect do
put update_user_url, params: { user_fields: { field_id => "Umbrella Corporation" } }
end.not_to change { user1.reload.user_fields[field_id] }
@@ -1931,7 +1931,7 @@ RSpec.describe UsersController do
}
end
- it "should succeed without the optional field" do
+ it "creates the user without the optional field" do
post "/u.json", params: create_params
expect(response.status).to eq(200)
inserted = User.find_by_email(@user.email)
@@ -1942,7 +1942,7 @@ RSpec.describe UsersController do
expect(inserted.custom_fields["user_field_#{optional_field.id}"]).to be_blank
end
- it "should succeed with the optional field" do
+ it "creates the user with the optional field" do
create_params[:user_fields][optional_field.id.to_s] = "value3"
post "/u.json", params: create_params.merge(create_params)
expect(response.status).to eq(200)
@@ -1979,7 +1979,7 @@ RSpec.describe UsersController do
}
end
- it "should succeed" do
+ it "creates the user without optional field values" do
post "/u.json", params: create_params
expect(response.status).to eq(200)
inserted = User.find_by_email(@user.email)
@@ -2000,7 +2000,7 @@ RSpec.describe UsersController do
fab!(:staged) { Fabricate(:staged, email: "[email protected]", active: true) }
- it "succeeds" do
+ it "claims the staged account" do
post "/u.json",
params:
honeypot_magic(email: staged.email, username: "zogstrip", password: "P4ssw0rd$$")
@@ -2112,7 +2112,7 @@ RSpec.describe UsersController do
expect(user.reload.username).to eq(old_username)
end
- it "should succeed in normal circumstances" do
+ it "returns the username availability" do
put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username }
expect(response).to be_successful
@@ -2160,7 +2160,7 @@ RSpec.describe UsersController do
expect(response.parsed_body["errors"].first).to include("Username must be unique")
end
- it "should fail if the user is old" do
+ it "rejects the change for an old account" do
# Older than the change period and >1 post
user.created_at = Time.now - (SiteSetting.username_change_period + 1).days
PostCreator.new(
@@ -2175,7 +2175,7 @@ RSpec.describe UsersController do
expect(user.reload.username).to eq(old_username)
end
- it "should create a staff action log when a staff member changes the username" do
+ it "logs a staff member's username change" do
acting_user = admin
sign_in(acting_user)
@@ -2192,13 +2192,13 @@ RSpec.describe UsersController do
expect(user.reload.username).to eq(new_username)
end
- it "should return a JSON response with the updated username" do
+ it "returns the updated username as JSON" do
put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username }
expect(response.parsed_body["username"]).to eq(new_username)
end
- it "should respond with proper error message if auth_overrides_username is enabled" do
+ it "returns an error when authentication overrides usernames" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -2244,7 +2244,7 @@ RSpec.describe UsersController do
end
shared_examples "when username is unavailable" do
- it "should return available as false in the JSON and return a suggested username" do
+ it "returns unavailable with a suggested username" do
expect(response.status).to eq(200)
expect(response.parsed_body["available"]).to eq(false)
expect(response.parsed_body["suggestion"]).to be_present
@@ -2252,7 +2252,7 @@ RSpec.describe UsersController do
end
shared_examples "when username is available" do
- it "should return available in the JSON" do
+ it "returns the username's availability" do
expect(response.status).to eq(200)
expect(response.parsed_body["available"]).to eq(true)
end
@@ -2303,7 +2303,7 @@ RSpec.describe UsersController do
end
shared_examples "checking an invalid username" do
- it "should not return an available key but should return an error message" do
+ it "returns an error without an availability key" do
expect(response.status).to eq(200)
expect(response.parsed_body["available"]).to eq(nil)
expect(response.parsed_body["errors"]).to be_present
@@ -2315,7 +2315,7 @@ RSpec.describe UsersController do
include_examples "checking an invalid username"
- it "should return the invalid characters message" do
+ it "returns the invalid-characters message" do
expect(response.status).to eq(200)
expect(response.parsed_body["errors"]).to include(I18n.t(:"user.username.characters"))
end
@@ -2331,7 +2331,7 @@ RSpec.describe UsersController do
include_examples "checking an invalid username"
- it 'should return the "too long" message' do
+ it 'returns the "too long" message' do
expect(response.status).to eq(200)
expect(response.parsed_body["errors"]).to include(
I18n.t(:"user.username.long", count: SiteSetting.max_username_length),
@@ -2758,7 +2758,7 @@ RSpec.describe UsersController do
fab!(:user) { Fabricate(:user, username: "test.test", name: "Test User") }
- it "should be able to update a user" do
+ it "updates the user" do
put "/u/#{user.username}", params: { name: "test.test" }
expect(response.status).to eq(200)
@@ -2922,7 +2922,7 @@ RSpec.describe UsersController do
fab!(:user_field) { Fabricate(:user_field, requirement: "for_all_users") }
fab!(:optional_field) { Fabricate(:user_field, requirement: "optional") }
- it "should update the user field" do
+ it "updates the user field" do
put "/u/#{user.username}.json",
params: {
name: "Jim Tom",
@@ -2960,7 +2960,7 @@ RSpec.describe UsersController do
expect(user.user_fields[user_field.id.to_s].size).to eq(UserField.max_length)
end
- it "should retain existing user fields" do
+ it "retains existing user fields" do
put "/u/#{user.username}.json",
params: {
name: "Jim Tom",
@@ -3174,7 +3174,7 @@ RSpec.describe UsersController do
end.to_not change { user.sidebar_section_links.count }
end
- it "should allow user to remove all category sidebar section links" do
+ it "allows removal of all category sidebar links" do
Fabricate(:category_sidebar_section_link, user: user)
expect do
@@ -3184,7 +3184,7 @@ RSpec.describe UsersController do
end.to change { user.sidebar_section_links.count }.from(1).to(0)
end
- it "should allow user to only modify category sidebar section links for categories they have access to" do
+ it "allows category sidebar links only for accessible categories" do
category = Fabricate(:category)
group = Fabricate(:group)
restricted_category = Fabricate(:private_category, group: group)
@@ -3219,7 +3219,7 @@ RSpec.describe UsersController do
)
end
- it "should allow user to remove all tag sidebar section links" do
+ it "allows removal of all tag sidebar links" do
SiteSetting.tagging_enabled = true
Fabricate(:tag_sidebar_section_link, user: user)
@@ -3231,7 +3231,7 @@ RSpec.describe UsersController do
end.to change { user.sidebar_section_links.count }.from(1).to(0)
end
- it "should not allow user to add tag sidebar section links when tagging is disabled" do
+ it "rejects tag sidebar links when tagging is disabled" do
SiteSetting.tagging_enabled = false
tag = Fabricate(:tag)
@@ -3242,7 +3242,7 @@ RSpec.describe UsersController do
expect(user.reload.sidebar_section_links.count).to eq(0)
end
- it "should allow user to add tag sidebar section links only for tags that the user can browse" do
+ it "allows tag sidebar links only for browsable tags" do
SiteSetting.tagging_enabled = true
tag = Fabricate(:tag)
@@ -3754,7 +3754,7 @@ RSpec.describe UsersController do
context "for an existing user" do
context "for an activated account with email confirmed" do
- it "fails" do
+ it "rejects an already activated account" do
user = post_user
email_token = Fabricate(:email_token, user: user).token
EmailToken.confirm(email_token)
@@ -3768,7 +3768,7 @@ RSpec.describe UsersController do
end
context "for an activated account with unconfirmed email" do
- it "should send an email" do
+ it "sends an activation email" do
user = post_user
user.update!(active: true)
Fabricate(:email_token, user: user)
@@ -3790,7 +3790,7 @@ RSpec.describe UsersController do
context "when approval is enabled" do
before { SiteSetting.must_approve_users = true }
- it "should raise an error" do
+ it "returns the approval error" do
user = post_user
user.update(active: true)
user.save!
@@ -3802,12 +3802,12 @@ RSpec.describe UsersController do
end
describe "when user does not have a valid session" do
- it "should not be valid" do
+ it "rejects a non-staff request" do
post "/u/action/send_activation_email.json", params: { username: user.username }
expect(response.status).to eq(403)
end
- it "should allow staff regardless" do
+ it "allows staff to send the activation email" do
sign_in(admin)
user = Fabricate(:user, active: false)
post "/u/action/send_activation_email.json", params: { username: user.username }
@@ -3816,7 +3816,7 @@ RSpec.describe UsersController do
end
context "with a valid email_token" do
- it "should send the activation email" do
+ it "sends the activation email" do
user = post_user
expect_enqueued_with(job: :critical_user_email, args: { type: :signup }) do
@@ -3836,13 +3836,13 @@ RSpec.describe UsersController do
user.reload
end
- it "should generate a new token" do
+ it "generates a new activation token" do
expect {
post "/u/action/send_activation_email.json", params: { username: user.username }
}.to change { user.reload.email_tokens.count }.by(1)
end
- it "should send an email" do
+ it "sends the new activation email" do
expect do
post "/u/action/send_activation_email.json", params: { username: user.username }
end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)
@@ -3853,7 +3853,7 @@ RSpec.describe UsersController do
end
context "when username does not exist" do
- it "should not send an email" do
+ it "does not send an activation email" do
post "/u/action/send_activation_email.json", params: { username: "nopenopenopenope" }
expect(response.status).to eq(404)
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
@@ -4408,12 +4408,12 @@ RSpec.describe UsersController do
context "when the user is logged in" do
before { sign_in(user1) }
- it "will not redirect to an invalid path" do
+ it "does not redirect to an invalid path" do
get "/my/wat/..password.txt"
expect(response).not_to be_redirect
end
- it "will redirect to an valid path" do
+ it "redirects to a valid path" do
get "/my/preferences"
expect(response).to redirect_to("/u/#{user1.username}/preferences")
end
@@ -5266,7 +5266,7 @@ RSpec.describe UsersController do
expect(response.headers["X-Robots-Tag"]).to eq("noindex")
end
- it "should 403 for anonymous user when profiles are hidden" do
+ it "returns 403 to anonymous users when profiles are hidden" do
SiteSetting.hide_user_profiles_from_public = true
get "/u/#{user.username}.json"
expect(response.headers["X-Robots-Tag"]).to eq("noindex")
@@ -5275,7 +5275,7 @@ RSpec.describe UsersController do
expect(response).to have_http_status(:forbidden)
end
- it "should 403 correctly for crawlers when profiles are hidden" do
+ it "returns 403 to crawlers when profiles are hidden" do
SiteSetting.hide_user_profiles_from_public = true
get "/u/#{user.username}", headers: { "User-Agent" => "Googlebot" }
expect(response).to have_http_status(:forbidden)
@@ -5284,7 +5284,7 @@ RSpec.describe UsersController do
end
describe "user profile views" do
- it "should track a user profile view for an anon user" do
+ it "tracks an anonymous profile view" do
get "/"
UserProfileView.expects(:add).with(another_user.user_profile.id, request.remote_ip, nil)
get "/u/#{another_user.username}.json"
@@ -5338,7 +5338,7 @@ RSpec.describe UsersController do
end
describe "user profile views" do
- it "should track a user profile view for a signed in user" do
+ it "tracks a signed-in user's profile view" do
UserProfileView.expects(:add).with(
another_user.user_profile.id,
request.remote_ip,
@@ -5347,7 +5347,7 @@ RSpec.describe UsersController do
get "/u/#{another_user.username}.json"
end
- it "should not track a user profile view for a user viewing his own profile" do
+ it "does not track a user viewing their own profile" do
UserProfileView.expects(:add).never
get "/u/#{user1.username}.json"
end
@@ -5443,14 +5443,14 @@ RSpec.describe UsersController do
end
end
- it "should be able to view a user" do
+ it "returns the user" do
get "/u/#{user1.username}"
expect(response.status).to eq(200)
expect(response.body).to include(user1.username)
end
- it "should not be able to view a private user profile" do
+ it "does not return a private user profile" do
user1.user_profile.update!(bio_raw: "Hello world!")
user1.user_option.update!(hide_profile: true)
@@ -5463,7 +5463,7 @@ RSpec.describe UsersController do
describe "when username contains a period" do
before_all { user1.update!(username: "test.test") }
- it "should be able to view a user" do
+ it "returns the user" do
get "/u/#{user1.username}"
expect(response.status).to eq(200)
@@ -5559,7 +5559,7 @@ RSpec.describe UsersController do
expect(user_json["silence_reason"]).to eq("public reason")
end
- it "should have http status 403 for anonymous user when profiles are hidden" do
+ it "returns 403 to anonymous users when profiles are hidden" do
SiteSetting.hide_user_profiles_from_public = true
get "/u/#{user.username}/card.json"
expect(response).to have_http_status(:forbidden)
@@ -5681,7 +5681,7 @@ RSpec.describe UsersController do
expect(parsed.map { |u| u["username"] }).to contain_exactly(user.username, user2.username)
end
- it "should have http status 403 for anonymous user when profiles are hidden" do
+ it "returns 403 to anonymous users when profiles are hidden" do
SiteSetting.hide_user_profiles_from_public = true
get "/user-cards.json?user_ids=#{user.id},#{user2.id}"
expect(response).to have_http_status(:forbidden)
@@ -5743,7 +5743,7 @@ RSpec.describe UsersController do
end
context "when cookies contains a destination URL" do
- it "should redirect to the URL" do
+ it "redirects to the URL" do
sign_in(user1)
destination_url = "http://thisisasite.com/somepath"
@@ -6146,7 +6146,7 @@ RSpec.describe UsersController do
end
describe "when not signed in" do
- it "should not include mentionable/messageable groups" do
+ it "omits mentionable and messageable groups" do
get "/u/search/users.json",
params: {
include_mentionable_groups: "false",
@@ -6418,14 +6418,14 @@ RSpec.describe UsersController do
describe "when enable_local_logins_via_email is disabled" do
before { SiteSetting.enable_local_logins_via_email = false }
- it "should return the right response" do
+ it "returns the disabled-login error" do
post "/u/email-login.json", params: { login: user1.email }
expect(response.status).to eq(404)
end
end
describe "when username or email is not valid" do
- it "should not enqueue the email to login" do
+ it "does not enqueue the login email" do
post "/u/email-login.json", params: { login: "@random" }
expect(response.status).to eq(200)
@@ -6437,7 +6437,7 @@ RSpec.describe UsersController do
end
describe "when hide_email_address_taken is true" do
- it "should return the right response" do
+ it "returns a generic response" do
SiteSetting.hide_email_address_taken = true
post "/u/email-login.json", params: { login: user1.email }
@@ -6449,7 +6449,7 @@ RSpec.describe UsersController do
end
describe "when user is already logged in" do
- it "should redirect to the root path" do
+ it "redirects to the root path" do
sign_in(user1)
post "/u/email-login.json", params: { login: user1.email }
@@ -6460,7 +6460,7 @@ RSpec.describe UsersController do
describe "#create_second_factor_totp" do
context "when not logged in" do
- it "should return the right response" do
+ it "requires authentication" do
post "/users/second_factors.json", params: { password: "wrongpassword" }
expect(response.status).to eq(403)
@@ -6482,7 +6482,7 @@ RSpec.describe UsersController do
end
describe "when local logins are disabled" do
- it "should return the right response" do
+ it "rejects TOTP creation when local logins are disabled" do
SiteSetting.enable_local_logins = false
post "/users/create_second_factor_totp.json"
@@ -6492,7 +6492,7 @@ RSpec.describe UsersController do
end
describe "when SSO is enabled" do
- it "should return the right response" do
+ it "rejects TOTP creation when SSO is enabled" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -6673,7 +6673,7 @@ RSpec.describe UsersController do
fab!(:user_second_factor) { Fabricate(:user_second_factor_totp, user: user1) }
context "when not logged in" do
- it "should return the right response" do
+ it "requires authentication" do
put "/users/second_factor.json"
expect(response.status).to eq(403)
@@ -6700,7 +6700,7 @@ RSpec.describe UsersController do
context "when token is valid" do
before { stub_server_session_confirmed }
- it "should allow second factor for the user to be renamed" do
+ it "renames the user's second factor" do
put "/users/second_factor.json",
params: {
name: "renamed",
@@ -6712,7 +6712,7 @@ RSpec.describe UsersController do
expect(user1.reload.user_second_factors.totps.first.name).to eq("renamed")
end
- it "should allow second factor for the user to be disabled" do
+ it "disables the user's second factor" do
put "/users/second_factor.json",
params: {
disable: "true",
@@ -6746,7 +6746,7 @@ RSpec.describe UsersController do
.returns("confirmed-session-#{user1.id}" => "true")
end
- it "should allow second factor backup for the user to be disabled" do
+ it "disables the user's backup codes" do
put "/users/second_factor.json",
params: {
second_factor_target: UserSecondFactor.methods[:backup_codes],
@@ -6765,7 +6765,7 @@ RSpec.describe UsersController do
fab!(:user_second_factor) { Fabricate(:user_second_factor_totp, user: user1) }
context "when not logged in" do
- it "should return the right response" do
+ it "requires authentication" do
put "/users/second_factors_backup.json",
params: {
second_factor_token: "wrongtoken",
@@ -6791,7 +6791,7 @@ RSpec.describe UsersController do
end
describe "when local logins are disabled" do
- it "should return the right response" do
+ it "rejects backup-code creation when local logins are disabled" do
SiteSetting.enable_local_logins = false
put "/users/second_factors_backup.json"
@@ -6801,7 +6801,7 @@ RSpec.describe UsersController do
end
describe "when SSO is enabled" do
- it "should return the right response" do
+ it "rejects backup-code creation when SSO is enabled" do
SiteSetting.discourse_connect_url = "http://someurl.com"
SiteSetting.discourse_connect_secret = "x" * 10
SiteSetting.enable_discourse_connect = true
@@ -6965,7 +6965,7 @@ RSpec.describe UsersController do
Fabricate(:passkey_with_random_credential, user: user1)
end
- it "should disable all totp and security keys (but not passkeys)" do
+ it "disables all TOTP factors and security keys but preserves passkeys" do
expect_enqueued_with(
job: :critical_user_email,
args: {
@@ -7329,7 +7329,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(200)
end
- it "works" do
+ it "revokes the account through the external provider" do
authenticator.can_revoke = true
post "/u/#{user1.username}/preferences/revoke-account.json",
diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rb
index eb7f5b440f1..56527a5f3bd 100644
--- a/spec/requests/webhooks_controller_spec.rb
+++ b/spec/requests/webhooks_controller_spec.rb
@@ -539,7 +539,7 @@ RSpec.describe WebhooksController do
end
describe "#mandrill_head" do
- it "works" do
+ it "returns 200 for a Mandrill HEAD request" do
head "/webhooks/mandrill.json"
expect(response.status).to eq(200)
diff --git a/spec/serializers/admin_plugin_serializer_spec.rb b/spec/serializers/admin_plugin_serializer_spec.rb
index b6f0691d7c6..a1c913710aa 100644
--- a/spec/serializers/admin_plugin_serializer_spec.rb
+++ b/spec/serializers/admin_plugin_serializer_spec.rb
@@ -76,14 +76,14 @@ RSpec.describe AdminPluginSerializer do
end
describe "enabled_setting" do
- it "should return the right value" do
+ it "returns the expected value" do
instance.enabled_site_setting("test")
expect(serializer.enabled_setting).to eq("test")
end
end
describe "commit_hash" do
- it "should return commit_hash and commit_url" do
+ it "returns commit_hash and commit_url" do
git_repo = instance.git_repo
git_repo.stubs(:latest_local_commit).returns("123456")
git_repo.stubs(:url).returns("http://github.com/discourse/discourse-plugin")
diff --git a/spec/serializers/basic_group_serializer_spec.rb b/spec/serializers/basic_group_serializer_spec.rb
index c4d6e23d29a..112bae1a386 100644
--- a/spec/serializers/basic_group_serializer_spec.rb
+++ b/spec/serializers/basic_group_serializer_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe BasicGroupSerializer do
describe "automatic group" do
let(:group) { Group.find(1) }
- it "should include the display name" do
+ it "includes the display name" do
expect(serializer.display_name).to eq(I18n.t("groups.default_names.admins"))
end
end
@@ -19,7 +19,7 @@ RSpec.describe BasicGroupSerializer do
describe "normal group" do
fab!(:group)
- it "should not include the display name" do
+ it "does not include the display name" do
expect(serializer.display_name).to eq(nil)
end
end
@@ -33,7 +33,7 @@ RSpec.describe BasicGroupSerializer do
fab!(:group) { Fabricate(:group, bio_raw: "testing :slightly_smiling_face:") }
describe "group owner" do
- it "should include bio_raw" do
+ it "includes bio_raw" do
expect(serializer.as_json[:bio_raw]).to eq("testing :slightly_smiling_face:")
expect(serializer.as_json[:bio_excerpt]).to start_with("testing <img")
end
@@ -46,7 +46,7 @@ RSpec.describe BasicGroupSerializer do
describe "for a staff user" do
let!(:guardian) { Guardian.new(Fabricate(:moderator)) }
- it "should be present" do
+ it "includes has_messages" do
expect(serializer.as_json[:has_messages]).to eq(true)
end
end
@@ -57,7 +57,7 @@ RSpec.describe BasicGroupSerializer do
before { group.add(user) }
- it "should be present" do
+ it "includes has_messages" do
expect(serializer.as_json[:has_messages]).to eq(true)
end
end
@@ -65,7 +65,7 @@ RSpec.describe BasicGroupSerializer do
describe "for a normal user" do
let(:guardian) { Guardian.new(Fabricate(:user)) }
- it "should not be present" do
+ it "omits has_messages" do
expect(serializer.as_json[:has_messages]).to eq(nil)
end
end
@@ -80,7 +80,7 @@ RSpec.describe BasicGroupSerializer do
before { group.add(user) }
- it "should be true" do
+ it "allows the member to see members" do
expect(serializer.as_json[:can_see_members]).to eq(true)
end
end
@@ -88,7 +88,7 @@ RSpec.describe BasicGroupSerializer do
describe "for a normal user" do
let(:guardian) { Guardian.new(Fabricate(:user)) }
- it "should be false" do
+ it "does not allow the user to see members" do
expect(serializer.as_json[:can_see_members]).to eq(false)
end
end
diff --git a/spec/serializers/basic_group_user_serializer_spec.rb b/spec/serializers/basic_group_user_serializer_spec.rb
index 2bca31763f6..ca307c74875 100644
--- a/spec/serializers/basic_group_user_serializer_spec.rb
+++ b/spec/serializers/basic_group_user_serializer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe BasicGroupUserSerializer do
describe "#owner" do
describe "when scoped to the user" do
- it "should be false" do
+ it "returns false for a member who is not an owner" do
json = described_class.new(GroupUser.last, scope: Guardian.new(user), root: false).as_json
expect(json[:owner]).to eq(false)
@@ -16,7 +16,7 @@ RSpec.describe BasicGroupUserSerializer do
end
describe "when not scoped to the user" do
- it "should be nil" do
+ it "omits owner information without a user scope" do
json = described_class.new(GroupUser.last, scope: Guardian.new, root: false).as_json
expect(json[:owner]).to eq(nil)
diff --git a/spec/serializers/category_upload_serializer_spec.rb b/spec/serializers/category_upload_serializer_spec.rb
index 34545547b43..0679a18dc09 100644
--- a/spec/serializers/category_upload_serializer_spec.rb
+++ b/spec/serializers/category_upload_serializer_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe CategoryUploadSerializer do
fab!(:upload)
- it "should include width and height" do
+ it "includes the upload dimensions" do
expect(serializer.width).to eq(upload.width)
expect(serializer.height).to eq(upload.height)
end
diff --git a/spec/serializers/current_user_serializer_spec.rb b/spec/serializers/current_user_serializer_spec.rb
index a046ff9818d..1bc1337136a 100644
--- a/spec/serializers/current_user_serializer_spec.rb
+++ b/spec/serializers/current_user_serializer_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe CurrentUserSerializer do
let(:guardian) { user.guardian }
context "when SSO is not enabled" do
- it "should not include the external_id field" do
+ it "does not include external_id" do
payload = serializer.as_json
expect(payload).not_to have_key(:external_id)
end
@@ -20,7 +20,7 @@ RSpec.describe CurrentUserSerializer do
user
end
- it "should include the external_id" do
+ it "includes external_id" do
SiteSetting.discourse_connect_url = "http://example.com/discourse_sso"
SiteSetting.discourse_connect_secret = "12345678910"
SiteSetting.enable_discourse_connect = true
@@ -34,12 +34,12 @@ RSpec.describe CurrentUserSerializer do
fab!(:category2, :category)
fab!(:category3, :category)
- it "should include empty top_category_ids array" do
+ it "includes an empty top_category_ids array" do
payload = serializer.as_json
expect(payload[:top_category_ids]).to eq([])
end
- it "should include correct id in top_category_ids array" do
+ it "includes the correct ID in top_category_ids" do
_category = Category.first
CategoryUser.create!(
user_id: user.id,
@@ -107,7 +107,7 @@ RSpec.describe CurrentUserSerializer do
end
describe "#groups" do
- it "should only show visible groups" do
+ it "shows only visible groups" do
Fabricate(:group, visibility_level: Group.visibility_levels[:public])
hidden_group = Fabricate(:group, visibility_level: Group.visibility_levels[:owners])
public_group =
@@ -309,11 +309,11 @@ RSpec.describe CurrentUserSerializer do
)
end
- it "should not include associated account ids by default" do
+ it "does not include associated account IDs by default" do
expect(serializer.as_json[:associated_account_ids]).to be_nil
end
- it "should include associated account ids when site setting enabled" do
+ it "includes associated account IDs when enabled" do
SiteSetting.include_associated_account_ids = true
expect(serializer.as_json[:associated_account_ids]).to eq({ "twitter" => "1" })
end
diff --git a/spec/serializers/group_show_serializer_spec.rb b/spec/serializers/group_show_serializer_spec.rb
index 8646fce580d..8dd390d85eb 100644
--- a/spec/serializers/group_show_serializer_spec.rb
+++ b/spec/serializers/group_show_serializer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe GroupShowSerializer do
fab!(:user, :admin)
fab!(:group) { Fabricate(:group, users: [user]) }
- it "should return the right attributes" do
+ it "returns the public group attributes" do
json = GroupShowSerializer.new(group, scope: Guardian.new(user)).as_json
expect(json[:group_show][:is_group_owner]).to eq(nil)
@@ -19,7 +19,7 @@ RSpec.describe GroupShowSerializer do
context "with a group owner" do
before { group.add_owner(user) }
- it "should return the right attributes" do
+ it "returns the private group attributes" do
json = GroupShowSerializer.new(group, scope: Guardian.new(user)).as_json
expect(json[:group_show][:is_group_owner]).to eq(true)
@@ -30,7 +30,7 @@ RSpec.describe GroupShowSerializer do
describe "#mentionable" do
fab!(:group) { Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone]) }
- it "should return the right value" do
+ it "returns the group flair URL" do
json = GroupShowSerializer.new(group, scope: Guardian.new).as_json
expect(json[:group_show][:mentionable]).to eq(nil)
@@ -45,19 +45,19 @@ RSpec.describe GroupShowSerializer do
fab!(:group) { Fabricate(:group, automatic_membership_email_domains: "ilovediscourse.com") }
let(:admin_guardian) { Guardian.new(Fabricate(:admin)) }
- it "should include email domains for admin" do
+ it "includes email domains for an administrator" do
subject =
described_class.new(group, scope: admin_guardian, root: false, owner_group_ids: [group.id])
expect(subject.as_json[:automatic_membership_email_domains]).to eq("ilovediscourse.com")
end
- it "should not include email domains for other users" do
+ it "omits email domains for other users" do
subject =
described_class.new(group, scope: Guardian.new, root: false, owner_group_ids: [group.id])
expect(subject.as_json[:automatic_membership_email_domains]).to eq(nil)
end
- it "should include email domains for moderator when moderators_manage_groups is enabled" do
+ it "includes email domains for a moderator who can manage groups" do
SiteSetting.moderators_manage_groups = true
moderator_guardian = Fabricate(:moderator).guardian
subject =
diff --git a/spec/serializers/notification_serializer_spec.rb b/spec/serializers/notification_serializer_spec.rb
index 4abf94572d4..3543bddd6f7 100644
--- a/spec/serializers/notification_serializer_spec.rb
+++ b/spec/serializers/notification_serializer_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe NotificationSerializer do
let(:serializer) { NotificationSerializer.new(notification) }
let(:json) { serializer.as_json }
- it "should include the external_id" do
+ it "includes the external ID" do
SiteSetting.discourse_connect_url = "http://example.com/discourse_sso"
SiteSetting.discourse_connect_secret = "12345678910"
SiteSetting.enable_discourse_connect = true
diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb
index 6e1a23f6b0d..0cedca83cca 100644
--- a/spec/serializers/post_serializer_spec.rb
+++ b/spec/serializers/post_serializer_spec.rb
@@ -117,7 +117,7 @@ RSpec.describe PostSerializer do
expect(notify_user_action).to be_blank
end
- it "should not allow user to flag post and notify non human user" do
+ it "prevents flagging a post to notify a non-human user" do
post.update!(user: Discourse.system_user)
serializer = PostSerializer.new(post, scope: Guardian.new(actor), root: false)
@@ -304,12 +304,12 @@ RSpec.describe PostSerializer do
revisor.revise!(post.user, raw: "Hello, everyone!")
end
- it "will not leak version to users" do
+ it "hides the real version from regular users" do
json = PostSerializer.new(post, scope: Guardian.new(user), root: false).as_json
expect(json[:version]).to eq(1)
end
- it "will show real version to staff" do
+ it "shows the real version to staff" do
json = PostSerializer.new(post, scope: Guardian.new(Fabricate(:admin)), root: false).as_json
expect(json[:version]).to eq(2)
end
diff --git a/spec/serializers/reviewable_serializer_spec.rb b/spec/serializers/reviewable_serializer_spec.rb
index bc24b68619f..02e98201b3d 100644
--- a/spec/serializers/reviewable_serializer_spec.rb
+++ b/spec/serializers/reviewable_serializer_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe ReviewableSerializer do
expect(json[:removed_topic_id]).to eq reviewable.topic_id
end
- it "will not throw an error when the payload is `nil`" do
+ it "does not raise an error when the payload is nil" do
reviewable.payload = nil
json =
ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
diff --git a/spec/serializers/single_sign_on_record_serializer_spec.rb b/spec/serializers/single_sign_on_record_serializer_spec.rb
index d7e182f4096..698b53313bb 100644
--- a/spec/serializers/single_sign_on_record_serializer_spec.rb
+++ b/spec/serializers/single_sign_on_record_serializer_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe SingleSignOnRecordSerializer do
SingleSignOnRecordSerializer.new(sso, scope: Guardian.new(admin), root: false)
end
- it "should include user sso info" do
+ it "includes user SSO information" do
payload = serializer.as_json
expect(payload[:user_id]).to eq(user.id)
expect(payload[:external_id]).to eq("12345")
@@ -31,7 +31,7 @@ RSpec.describe SingleSignOnRecordSerializer do
SingleSignOnRecordSerializer.new(sso, scope: Guardian.new(moderator), root: false)
end
- it "should not include user sso payload" do
+ it "omits the user SSO payload" do
payload = serializer.as_json
expect(payload[:user_id]).to eq(user.id)
expect(payload[:external_id]).to eq("12345")
diff --git a/spec/serializers/site_serializer_spec.rb b/spec/serializers/site_serializer_spec.rb
index 9dda140a87f..3a014769752 100644
--- a/spec/serializers/site_serializer_spec.rb
+++ b/spec/serializers/site_serializer_spec.rb
@@ -489,7 +489,7 @@ RSpec.describe SiteSerializer do
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name])
end
- it "should return the site's top tags as the default tags for sidebar" do
+ it "returns the site's top tags as default sidebar tags" do
serialized = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json
expect(serialized[:navigation_menu_site_top_tags]).to eq(
@@ -519,7 +519,7 @@ RSpec.describe SiteSerializer do
)
end
- it "should not be serialized if `tagging_enabled` site setting is set to false" do
+ it "is not serialized when tagging is disabled" do
SiteSetting.set(:tagging_enabled, false)
serialized = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json
@@ -527,7 +527,7 @@ RSpec.describe SiteSerializer do
expect(serialized[:navigation_menu_site_top_tags]).to eq(nil)
end
- it "should use slug_for_url for tags with empty slugs" do
+ it "uses slug_for_url for tags with empty slugs" do
numeric_tag =
Fabricate(:tag, name: "1").tap { |tag| Fabricate.times(10, :topic, tags: [tag]) }
@@ -540,7 +540,7 @@ RSpec.describe SiteSerializer do
expect(numeric_entry[:slug]).to eq("#{numeric_tag.id}-tag")
end
- it "should return an empty array if site has no top tags" do
+ it "returns an empty array when the site has no top tags" do
Tag.delete_all
serialized = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json
diff --git a/spec/serializers/suggested_topic_serializer_spec.rb b/spec/serializers/suggested_topic_serializer_spec.rb
index dc07ce0b5a9..c8f70adccf1 100644
--- a/spec/serializers/suggested_topic_serializer_spec.rb
+++ b/spec/serializers/suggested_topic_serializer_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe SuggestedTopicSerializer do
SiteSetting.topic_featured_link_enabled = false
end
- it "should not return featured link attrs" do
+ it "omits featured link attributes" do
expect(json[:featured_link]).to eq(nil)
expect(json[:featured_link_root_domain]).to eq(nil)
end
@@ -34,7 +34,7 @@ RSpec.describe SuggestedTopicSerializer do
context "when topic featured link is enabled" do
before { SiteSetting.topic_featured_link_enabled = true }
- it "should return featured link attrs" do
+ it "returns featured link attributes" do
expect(json[:featured_link]).to eq(featured_link)
expect(json[:featured_link_root_domain]).to eq("discourse.org")
end
diff --git a/spec/serializers/tag_serializer_spec.rb b/spec/serializers/tag_serializer_spec.rb
index 853e59360e9..7f11c5ca005 100644
--- a/spec/serializers/tag_serializer_spec.rb
+++ b/spec/serializers/tag_serializer_spec.rb
@@ -25,13 +25,13 @@ RSpec.describe TagSerializer do
end
describe "#topic_count" do
- it "should return the value of `Tag#public_topic_count` for a non-staff user" do
+ it "returns the public topic count for non-staff users" do
serialized = described_class.new(tag, scope: Guardian.new(user), root: false).as_json
expect(serialized[:topic_count]).to eq(1)
end
- it "should return the value of `Tag#topic_count` for a staff user" do
+ it "returns the total topic count for staff" do
serialized = described_class.new(tag, scope: Guardian.new(admin), root: false).as_json
expect(serialized[:topic_count]).to eq(2)
diff --git a/spec/serializers/theme_objects_setting_metadata_serializer_spec.rb b/spec/serializers/theme_objects_setting_metadata_serializer_spec.rb
index fa8e8b6655b..1070a2bfad1 100644
--- a/spec/serializers/theme_objects_setting_metadata_serializer_spec.rb
+++ b/spec/serializers/theme_objects_setting_metadata_serializer_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe ThemeObjectsSettingMetadataSerializer do
theme.save!
end
- it "should return a hash of the settings property descriptions with schema.properties segments stripped" do
+ it "returns property descriptions without schema.properties segments" do
objects_setting_locale
payload = described_class.new(theme_setting[:objects_setting], root: false).as_json
@@ -50,7 +50,7 @@ RSpec.describe ThemeObjectsSettingMetadataSerializer do
fab!(:category_3) { Fabricate(:private_category, group: Fabricate(:group)) }
fab!(:admin)
- it "should return a hash of serialized categories" do
+ it "returns serialized categories" do
theme_setting[:objects_with_categories].value = [
{
"category_ids" => [category_1.id, category_2.id],
diff --git a/spec/serializers/theme_serializer_spec.rb b/spec/serializers/theme_serializer_spec.rb
index 6f77f322fc9..23baf5eefae 100644
--- a/spec/serializers/theme_serializer_spec.rb
+++ b/spec/serializers/theme_serializer_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe ThemeSerializer do
describe ".settings" do
fab!(:theme)
- it "should add error message when settings format is invalid" do
+ it "adds an error for an invalid settings format" do
Theme
.any_instance
.stubs(:settings)
@@ -15,7 +15,7 @@ RSpec.describe ThemeSerializer do
expect(serialized[:errors][0]).to eq(I18n.t("themes.settings_errors.invalid_yaml"))
end
- it "should add errors messages from theme fields" do
+ it "adds error messages from theme fields" do
error = "error when compiling theme field"
theme_field = Fabricate(:theme_field, error: error, theme: theme)
serialized = ThemeSerializer.new(theme.reload).as_json[:theme]
@@ -28,11 +28,11 @@ RSpec.describe ThemeSerializer do
fab!(:theme) { Fabricate(:theme, color_scheme_id: 1, dark_color_scheme_id: 2) }
let(:serialized) { ThemeSerializer.new(theme.reload).as_json[:theme] }
- it "should include color scheme id" do
+ it "includes the color scheme ID" do
expect(serialized[:color_scheme_id]).to eq(1)
end
- it "should include dark color scheme id" do
+ it "includes the dark color scheme ID" do
expect(serialized[:dark_color_scheme_id]).to eq(2)
end
end
@@ -41,7 +41,7 @@ RSpec.describe ThemeSerializer do
fab!(:theme)
let(:serialized) { ThemeSerializer.new(theme.reload).as_json[:theme] }
- it "should include screenshot_light_url when there is a theme field with screenshot upload type and name 'screenshot_light'" do
+ it "includes screenshot_light_url for the light screenshot field" do
Fabricate(
:theme_field,
theme: theme,
@@ -52,12 +52,12 @@ RSpec.describe ThemeSerializer do
expect(serialized[:screenshot_light_url]).to be_present
end
- it "should not include screenshot_light_url/screenshot_dark_url when there is no theme fields of screenshot upload type with names 'screenshot_light' or 'screenshot_dark'" do
+ it "omits screenshot URLs when no screenshot fields exist" do
expect(serialized[:screenshot_light_url]).to be_nil
expect(serialized[:screenshot_dark_url]).to be_nil
end
- it "should handle dark/light screenshot fields and use both" do
+ it "includes both dark and light screenshot URLs" do
first_upload = Fabricate(:upload)
second_upload = Fabricate(:upload)
Fabricate(
diff --git a/spec/serializers/theme_settings_serializer_spec.rb b/spec/serializers/theme_settings_serializer_spec.rb
index f8475ad77c9..fa38c7b1315 100644
--- a/spec/serializers/theme_settings_serializer_spec.rb
+++ b/spec/serializers/theme_settings_serializer_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe ThemeSettingsSerializer do
end
describe "#objects_schema" do
- it "should include the attribute when theme setting is typed objects" do
+ it "includes the attribute for an objects theme setting" do
payload = ThemeSettingsSerializer.new(theme_setting[:objects_setting]).as_json
expect(payload[:theme_settings][:objects_schema][:name]).to eq("section")
diff --git a/spec/serializers/topic_list_item_serializer_spec.rb b/spec/serializers/topic_list_item_serializer_spec.rb
index 8ab9dffd023..66898fb573a 100644
--- a/spec/serializers/topic_list_item_serializer_spec.rb
+++ b/spec/serializers/topic_list_item_serializer_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe TopicListItemSerializer do
describe "when topic featured link is disable" do
before { SiteSetting.topic_featured_link_enabled = false }
- it "should not include the topic's featured link" do
+ it "omits the topic's featured link" do
topic.featured_link = "http://meta.discourse.org"
serialized = TopicListItemSerializer.new(topic, scope: Guardian.new, root: false).as_json
diff --git a/spec/serializers/topic_list_serializer_spec.rb b/spec/serializers/topic_list_serializer_spec.rb
index 5b382839eb4..17d20707ebd 100644
--- a/spec/serializers/topic_list_serializer_spec.rb
+++ b/spec/serializers/topic_list_serializer_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe TopicListSerializer do
before { topic.allowed_user_ids = [topic.user_id] }
- it "should return the right payload" do
+ it "returns the expected payload" do
topic_list = TopicList.new(nil, user, [topic])
serialized = described_class.new(topic_list, scope: Guardian.new(user)).as_json
diff --git a/spec/serializers/topic_view_posts_serializer_spec.rb b/spec/serializers/topic_view_posts_serializer_spec.rb
index e0aa849c017..6b06f6b9f6f 100644
--- a/spec/serializers/topic_view_posts_serializer_spec.rb
+++ b/spec/serializers/topic_view_posts_serializer_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe TopicViewPostsSerializer do
)
end
- it "should return the right attributes" do
+ it "returns the expected attributes" do
topic_view = TopicView.new(topic, user, post_ids: [post.id])
serializer =
diff --git a/spec/serializers/topic_view_serializer_spec.rb b/spec/serializers/topic_view_serializer_spec.rb
index 5e136df3db9..2ccd19128b1 100644
--- a/spec/serializers/topic_view_serializer_spec.rb
+++ b/spec/serializers/topic_view_serializer_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe TopicViewSerializer do
fab!(:featured_link) { "http://meta.discourse.org" }
describe "when topic featured link is disable" do
- it "should return the right attributes" do
+ it "omits featured link attributes" do
topic.update!(featured_link: featured_link)
SiteSetting.topic_featured_link_enabled = false
@@ -31,7 +31,7 @@ RSpec.describe TopicViewSerializer do
end
describe "when topic featured link is enabled" do
- it "should return the right attributes" do
+ it "returns the featured link and root domain" do
topic.update!(featured_link: featured_link)
json = serialize_topic(topic, user)
@@ -46,7 +46,7 @@ RSpec.describe TopicViewSerializer do
describe "when a topic has an external_id" do
before { topic.update!(external_id: "42-asdf") }
- it "should return the external_id" do
+ it "returns the external_id" do
json = serialize_topic(topic, user)
expect(json[:external_id]).to eq("42-asdf")
end
@@ -59,13 +59,13 @@ RSpec.describe TopicViewSerializer do
describe "when a topic has an image" do
before { topic.update!(image_upload_id: image_upload.id) }
- it "should return the image url" do
+ it "returns the image URL" do
json = serialize_topic(topic, user)
expect(json[:image_url]).to end_with(image_upload.url)
end
- it "should have thumbnail jobs enqueued" do
+ it "enqueues thumbnail jobs" do
SiteSetting.create_thumbnails = true
Discourse.redis.del(topic.thumbnail_job_redis_key([]))
@@ -84,7 +84,7 @@ RSpec.describe TopicViewSerializer do
end
describe "when a topic does not contain an image" do
- it "should return a nil image url" do
+ it "returns a nil image URL" do
json = serialize_topic(topic, user)
expect(json.has_key? :image_url).to eq(true)
@@ -98,13 +98,13 @@ RSpec.describe TopicViewSerializer do
before { TopicUser.update_last_read(user, topic2.id, 0, 0, 0) }
- it "should include suggested topics if `TopicView#include_suggested` is set to `true`" do
+ it "includes suggested topics when include_suggested is true" do
json = serialize_topic(topic, user, include_suggested: true)
expect(json[:suggested_topics].first[:id]).to eq(topic2.id)
end
- it "should not include suggested topics if `TopicView#include_suggested` is set to `false`" do
+ it "omits suggested topics when include_suggested is false" do
post = Fabricate(:post, topic:)
post2 = Fabricate(:post, topic:)
@@ -209,19 +209,19 @@ RSpec.describe TopicViewSerializer do
SiteSetting.pm_tags_allowed_for_groups = "1|2|3|4"
end
- it "should not include the tag for normal users" do
+ it "omits the tag for regular users" do
json = serialize_topic(pm, user)
expect(json[:tags]).to eq(nil)
end
- it "should include the tag for staff users" do
+ it "includes the tag for staff" do
[moderator, admin].each do |user|
json = serialize_topic(pm, user)
expect(json[:tags]).to eq([{ id: tag.id, name: tag.name, slug: tag.slug }])
end
end
- it "should include the tag for users in allowed groups" do
+ it "includes the tag for users in allowed groups" do
SiteSetting.pm_tags_allowed_for_groups = "1|2|3|#{group.id}"
user.group_users << Fabricate(:group_user, group: group, user: user)
@@ -232,7 +232,7 @@ RSpec.describe TopicViewSerializer do
expect(json[:tags]).to eq(nil)
end
- it "should not include the tag if pm tags disabled" do
+ it "omits the tag when PM tags are disabled" do
SiteSetting.pm_tags_allowed_for_groups = ""
[moderator, admin].each do |user|
@@ -331,7 +331,7 @@ RSpec.describe TopicViewSerializer do
fab!(:flagger_1) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:flagger_2) { Fabricate(:user, refresh_auto_groups: true) }
- it "will return reviewable counts on posts" do
+ it "returns reviewable counts on posts" do
r = PostActionCreator.inappropriate(flagger_1, post).reviewable
r.perform(admin, :agree_and_keep)
PostActionCreator.spam(flagger_2, post)
@@ -546,7 +546,7 @@ RSpec.describe TopicViewSerializer do
before { SiteSetting.enable_category_group_moderation = true }
# Ensure having enable_category_group_moderation turned on doesn't break private messages
- it "should return posts" do
+ it "returns posts" do
json = serialize_topic(pm_topic, user)
expect(json[:post_stream][:posts]).to be_present
end
@@ -591,7 +591,7 @@ RSpec.describe TopicViewSerializer do
fab!(:pm) { Fabricate(:private_message_post).topic }
fab!(:group)
- it "should return the right group name when PM is a group membership request" do
+ it "returns the requested group's name for a membership request PM" do
pm.custom_fields[:requested_group_id] = group.id
pm.save!
@@ -602,7 +602,7 @@ RSpec.describe TopicViewSerializer do
expect(json[:requested_group_name]).to eq(group.name)
end
- it "should not include the attribute for a non group membership request PM" do
+ it "omits membership request attributes for other PMs" do
json = serialize_topic(pm, pm.first_post.user)
expect(json[:requested_group_name]).to eq(nil)
diff --git a/spec/serializers/upload_serializer_spec.rb b/spec/serializers/upload_serializer_spec.rb
index 145f2484535..4852060f597 100644
--- a/spec/serializers/upload_serializer_spec.rb
+++ b/spec/serializers/upload_serializer_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe UploadSerializer do
fab!(:upload)
- it "should render without errors" do
+ it "renders the upload" do
json_data = JSON.parse(serializer.to_json)
expect(json_data["id"]).to eql upload.id
diff --git a/spec/serializers/user_export_serializer_spec.rb b/spec/serializers/user_export_serializer_spec.rb
index 67baf737862..c2476fa0d1c 100644
--- a/spec/serializers/user_export_serializer_spec.rb
+++ b/spec/serializers/user_export_serializer_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe UserExportSerializer do
)
end
- it "should render without errors" do
+ it "renders the export without errors" do
json_data = JSON.parse(serializer.to_json)
expect(json_data["id"]).to eql user_export.id
diff --git a/spec/serializers/web_hook_post_serializer_spec.rb b/spec/serializers/web_hook_post_serializer_spec.rb
index 618722dd0b7..c2547c95618 100644
--- a/spec/serializers/web_hook_post_serializer_spec.rb
+++ b/spec/serializers/web_hook_post_serializer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe WebHookPostSerializer do
WebHookPostSerializer.new(post, scope: Guardian.new(u), root: false).as_json
end
- it "should only include the required keys" do
+ it "includes only the required keys" do
expect(serialized_for_user(admin).keys).to contain_exactly(
:id,
:name,
@@ -63,7 +63,7 @@ RSpec.describe WebHookPostSerializer do
expect(serialized_for_user(admin)[:category_id]).to eq(post.topic.category_id)
end
- it "should only include deleted topic title for staffs" do
+ it "includes a deleted topic title only for staff" do
topic = post.topic
PostDestroyer.new(Discourse.system_user, post, context: "Automated testing").destroy
post.reload
diff --git a/spec/serializers/web_hook_topic_view_serializer_spec.rb b/spec/serializers/web_hook_topic_view_serializer_spec.rb
index b728087772f..55f1c4b54e2 100644
--- a/spec/serializers/web_hook_topic_view_serializer_spec.rb
+++ b/spec/serializers/web_hook_topic_view_serializer_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe WebHookTopicViewSerializer do
before { SiteSetting.tagging_enabled = true }
- it "should only include the keys that are sent out in the webhook" do
+ it "includes only the webhook keys" do
expected_keys = %i[
id
title
diff --git a/spec/serializers/web_hook_user_serializer_spec.rb b/spec/serializers/web_hook_user_serializer_spec.rb
index 4824af8b6de..d6aaa8efa0f 100644
--- a/spec/serializers/web_hook_user_serializer_spec.rb
+++ b/spec/serializers/web_hook_user_serializer_spec.rb
@@ -14,13 +14,13 @@ RSpec.describe WebHookUserSerializer do
WebHookUserSerializer.new(user, scope: Guardian.new(admin), root: false)
end
- it "should include relevant user info" do
+ it "includes relevant user information" do
payload = serializer.as_json
expect(payload[:email]).to eq(user.email)
expect(payload[:external_id]).to eq("12345")
end
- it "should only include the required keys" do
+ it "includes only the required keys" do
expect(serializer.as_json.keys).to contain_exactly(
:admin,
:allowed_pm_usernames,
diff --git a/spec/serializers/wizard_serializer_spec.rb b/spec/serializers/wizard_serializer_spec.rb
index b77c6dc2846..9e4f66c6c02 100644
--- a/spec/serializers/wizard_serializer_spec.rb
+++ b/spec/serializers/wizard_serializer_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe WizardSerializer do
expect(json["wizard"]["current_color_scheme"][0]["hex"]).to eq("222")
end
- it "should provide custom colors correctly" do
+ it "returns the custom colors" do
colors =
ColorScheme.create_from_base(
name: "Customized",
diff --git a/spec/services/admin_dashboard_section_loader_spec.rb b/spec/services/admin_dashboard_section_loader_spec.rb
index ca5012d868e..44c2cb41716 100644
--- a/spec/services/admin_dashboard_section_loader_spec.rb
+++ b/spec/services/admin_dashboard_section_loader_spec.rb
@@ -1,161 +1,163 @@
# frozen_string_literal: true
describe AdminDashboardSectionLoader do
- fab!(:admin)
-
- after do
- if thread_pool = described_class.instance_variable_get(:@thread_pool)
- thread_pool.shutdown
- thread_pool.wait_for_termination(timeout: 1)
- described_class.remove_instance_variable(:@thread_pool)
+ context "with transactional tests" do
+ fab!(:admin)
+
+ after do
+ if thread_pool = described_class.instance_variable_get(:@thread_pool)
+ thread_pool.shutdown
+ thread_pool.wait_for_termination(timeout: 1)
+ described_class.remove_instance_variable(:@thread_pool)
+ end
end
- end
- describe ".build" do
- it "ensures the sections are built in order with current user and dates" do
- AdminDashboardSiteTraffic
- .expects(:build)
- .with do |kwargs|
- kwargs[:start_date] == "2026-05-01" && kwargs[:end_date] == "2026-05-07" &&
- kwargs[:guardian].is_a?(Guardian) && kwargs[:guardian].user.id == admin.id
- end
- .returns({ value: "traffic" })
- AdminDashboardEngagement
- .expects(:build)
- .with(start_date: "2026-05-01", end_date: "2026-05-07", current_user: admin)
- .returns({ value: "engagement" })
- AdminDashboardSearch
- .expects(:build)
- .with(start_date: "2026-05-01", end_date: "2026-05-07")
- .returns({ value: "search" })
-
- expect(
- described_class.build(
- section_ids: %w[traffic engagement search],
- current_user: admin,
- start_date: "2026-05-01",
- end_date: "2026-05-07",
- ),
- ).to eq(
- [
- { id: "traffic", data: { value: "traffic" } },
- { id: "engagement", data: { value: "engagement" } },
- { id: "search", data: { value: "search" } },
- ],
- )
+ describe ".build" do
+ it "ensures the sections are built in order with current user and dates" do
+ AdminDashboardSiteTraffic
+ .expects(:build)
+ .with do |kwargs|
+ kwargs[:start_date] == "2026-05-01" && kwargs[:end_date] == "2026-05-07" &&
+ kwargs[:guardian].is_a?(Guardian) && kwargs[:guardian].user.id == admin.id
+ end
+ .returns({ value: "traffic" })
+ AdminDashboardEngagement
+ .expects(:build)
+ .with(start_date: "2026-05-01", end_date: "2026-05-07", current_user: admin)
+ .returns({ value: "engagement" })
+ AdminDashboardSearch
+ .expects(:build)
+ .with(start_date: "2026-05-01", end_date: "2026-05-07")
+ .returns({ value: "search" })
+
+ expect(
+ described_class.build(
+ section_ids: %w[traffic engagement search],
+ current_user: admin,
+ start_date: "2026-05-01",
+ end_date: "2026-05-07",
+ ),
+ ).to eq(
+ [
+ { id: "traffic", data: { value: "traffic" } },
+ { id: "engagement", data: { value: "engagement" } },
+ { id: "search", data: { value: "search" } },
+ ],
+ )
+ end
+
+ it "returns partial section data when a section fails to build" do
+ error = StandardError.new("boom")
+ AdminDashboardSiteTraffic.stubs(:build).returns({ value: "traffic" })
+ AdminDashboardSearch.stubs(:build).raises(error)
+ Discourse.expects(:warn_exception).with(
+ error,
+ message: "Failed to build admin dashboard section",
+ env: {
+ section_id: "search",
+ },
+ )
+
+ expect(
+ described_class.build(
+ section_ids: %w[traffic search],
+ current_user: admin,
+ start_date: "2026-05-01",
+ end_date: "2026-05-07",
+ ),
+ ).to eq(
+ [{ id: "traffic", data: { value: "traffic" } }, { id: "search", data: nil, error: true }],
+ )
+ end
end
- it "returns partial section data when a section fails to build" do
- error = StandardError.new("boom")
- AdminDashboardSiteTraffic.stubs(:build).returns({ value: "traffic" })
- AdminDashboardSearch.stubs(:build).raises(error)
- Discourse.expects(:warn_exception).with(
- error,
- message: "Failed to build admin dashboard section",
- env: {
- section_id: "search",
- },
- )
+ describe "plugin sections" do
+ it "routes a registered plugin section id to its loader block" do
+ loader = ->(start_date:, end_date:, current_user:) do
+ { value: "support", user: current_user.id }
+ end
+ DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns(
+ [{ id: "support", enabled: -> { true }, loader: loader }],
+ )
+
+ expect(
+ described_class.build(
+ section_ids: ["support"],
+ current_user: admin,
+ start_date: "2026-05-01",
+ end_date: "2026-05-07",
+ ),
+ ).to eq([{ id: "support", data: { value: "support", user: admin.id } }])
+ end
- expect(
- described_class.build(
- section_ids: %w[traffic search],
- current_user: admin,
- start_date: "2026-05-01",
- end_date: "2026-05-07",
- ),
- ).to eq(
- [{ id: "traffic", data: { value: "traffic" } }, { id: "search", data: nil, error: true }],
- )
+ it "returns nil data for an unknown section id" do
+ DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns([])
+
+ expect(
+ described_class.build(
+ section_ids: ["frobnitz"],
+ current_user: admin,
+ start_date: "2026-05-01",
+ end_date: "2026-05-07",
+ ),
+ ).to eq([{ id: "frobnitz", data: nil }])
+ end
end
- end
- describe "plugin sections" do
- it "routes a registered plugin section id to its loader block" do
- loader = ->(start_date:, end_date:, current_user:) do
- { value: "support", user: current_user.id }
+ describe ".pool_size" do
+ it "caps at the DB connection pool, reserving one for the request thread" do
+ ActiveRecord::Base.connection_pool.stubs(:size).returns(3)
+ expect(described_class.pool_size).to eq(2)
end
- DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns(
- [{ id: "support", enabled: -> { true }, loader: loader }],
- )
- expect(
- described_class.build(
- section_ids: ["support"],
- current_user: admin,
- start_date: "2026-05-01",
- end_date: "2026-05-07",
- ),
- ).to eq([{ id: "support", data: { value: "support", user: admin.id } }])
- end
+ it "uses the desired count when the pool has room to spare" do
+ ActiveRecord::Base.connection_pool.stubs(:size).returns(100)
+ desired =
+ AdminDashboardSectionConfiguration::KNOWN_SECTIONS.size +
+ DiscoursePluginRegistry.admin_dashboard_sections.size
+ expect(described_class.pool_size).to eq(desired)
+ end
- it "returns nil data for an unknown section id" do
- DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns([])
-
- expect(
- described_class.build(
- section_ids: ["frobnitz"],
- current_user: admin,
- start_date: "2026-05-01",
- end_date: "2026-05-07",
- ),
- ).to eq([{ id: "frobnitz", data: nil }])
+ it "never drops below one" do
+ ActiveRecord::Base.connection_pool.stubs(:size).returns(1)
+ expect(described_class.pool_size).to eq(1)
+ end
end
end
- describe ".pool_size" do
- it "caps at the DB connection pool, reserving one for the request thread" do
- ActiveRecord::Base.connection_pool.stubs(:size).returns(3)
- expect(described_class.pool_size).to eq(2)
- end
-
- it "uses the desired count when the pool has room to spare" do
- ActiveRecord::Base.connection_pool.stubs(:size).returns(100)
- desired =
- AdminDashboardSectionConfiguration::KNOWN_SECTIONS.size +
- DiscoursePluginRegistry.admin_dashboard_sections.size
- expect(described_class.pool_size).to eq(desired)
- end
+ context "without transactional tests" do
+ self.use_transactional_tests = false
- it "never drops below one" do
- ActiveRecord::Base.connection_pool.stubs(:size).returns(1)
- expect(described_class.pool_size).to eq(1)
+ after do
+ if thread_pool = described_class.instance_variable_get(:@thread_pool)
+ thread_pool.shutdown
+ thread_pool.wait_for_termination(timeout: 1)
+ described_class.remove_instance_variable(:@thread_pool)
+ end
end
- end
-end
-describe AdminDashboardSectionLoader do
- self.use_transactional_tests = false
+ it "returns database connections to the pool once a section finishes building" do
+ worker_thread = nil
+ loader = ->(start_date:, end_date:, current_user:) do
+ worker_thread = Thread.current
+ ActiveRecord::Base.connection.execute("SELECT 1")
+ { value: "leaky" }
+ end
+ DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns(
+ [{ id: "leaky", enabled: -> { true }, loader: loader }],
+ )
- after do
- if thread_pool = described_class.instance_variable_get(:@thread_pool)
- thread_pool.shutdown
- thread_pool.wait_for_termination(timeout: 1)
- described_class.remove_instance_variable(:@thread_pool)
- end
- end
+ described_class.build(
+ section_ids: ["leaky"],
+ current_user: Discourse.system_user,
+ start_date: "2026-05-01",
+ end_date: "2026-05-07",
+ )
- it "returns database connections to the pool once a section finishes building" do
- worker_thread = nil
- loader = ->(start_date:, end_date:, current_user:) do
- worker_thread = Thread.current
- ActiveRecord::Base.connection.execute("SELECT 1")
- { value: "leaky" }
- end
- DiscoursePluginRegistry.stubs(:admin_dashboard_sections).returns(
- [{ id: "leaky", enabled: -> { true }, loader: loader }],
- )
-
- described_class.build(
- section_ids: ["leaky"],
- current_user: Discourse.system_user,
- start_date: "2026-05-01",
- end_date: "2026-05-07",
- )
-
- expect(worker_thread).not_to eq(Thread.current)
- wait_for do
- ActiveRecord::Base.connection_pool.connections.none? { |c| c.owner == worker_thread }
+ expect(worker_thread).not_to eq(Thread.current)
+ wait_for do
+ ActiveRecord::Base.connection_pool.connections.none? { |c| c.owner == worker_thread }
+ end
end
end
end
diff --git a/spec/services/auto_silence_spec.rb b/spec/services/auto_silence_spec.rb
index 55e4246e583..517694669ca 100644
--- a/spec/services/auto_silence_spec.rb
+++ b/spec/services/auto_silence_spec.rb
@@ -150,7 +150,7 @@ RSpec.describe SpamRule::AutoSilence do
let(:post2) { Fabricate(:post, user: user) }
context "with higher trust levels or staff" do
- it "should not autosilence any of them" do
+ it "does not automatically silence any users" do
PostActionCreator.spam(flagger, post)
PostActionCreator.spam(flagger2, post)
diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rb
index e274818a70e..6e18bc0329a 100644
--- a/spec/services/badge_granter_spec.rb
+++ b/spec/services/badge_granter_spec.rb
@@ -154,7 +154,7 @@ RSpec.describe BadgeGranter do
b.badge_id = Badge::FirstLike
end
- it "should grant missing badges" do
+ it "grants missing badges" do
nice_topic = Badge.find(Badge::NiceTopic)
good_topic = Badge.find(Badge::GoodTopic)
@@ -181,7 +181,7 @@ RSpec.describe BadgeGranter do
expect(good_topic.grant_count).to eq(1)
end
- it "should grant badges in the user locale" do
+ it "grants badges in the user's locale" do
SiteSetting.allow_user_locale = true
nice_topic = Badge.find(Badge::NiceTopic)
diff --git a/spec/services/categories/types/base_spec.rb b/spec/services/categories/types/base_spec.rb
index 0299f188d06..a21a915a23d 100644
--- a/spec/services/categories/types/base_spec.rb
+++ b/spec/services/categories/types/base_spec.rb
@@ -130,7 +130,7 @@ RSpec.describe Categories::Types::Base do
end
end
- describe ".configure_site_settings" do
+ describe ".configure_site_settings with scalar defaults" do
it "applies site settings from configuration_schema defaults" do
test_type =
build_test_type(
@@ -544,7 +544,7 @@ RSpec.describe Categories::Types::Base do
end
end
- describe ".configure_site_settings" do
+ describe ".configure_site_settings with hash defaults" do
it "extracts default from hash config values" do
test_type =
build_test_type(
diff --git a/spec/services/email_style_updater_spec.rb b/spec/services/email_style_updater_spec.rb
index 674f7a2680f..49f62d707c4 100644
--- a/spec/services/email_style_updater_spec.rb
+++ b/spec/services/email_style_updater_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe EmailStyleUpdater do
expect(SiteSetting.email_custom_css_compiled.strip).to eq("h1{color:blue}")
end
- it "will not store defaults" do
+ it "does not store default styles" do
updater.update(html: default_html, css: "")
expect_settings_to_be_unset
end
diff --git a/spec/services/group_action_logger_spec.rb b/spec/services/group_action_logger_spec.rb
index 4a33533c250..b110bd6c53a 100644
--- a/spec/services/group_action_logger_spec.rb
+++ b/spec/services/group_action_logger_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe GroupActionLogger do
before { group.add_owner(group_owner) }
describe "#log_make_user_group_owner" do
- it "should create the right record" do
+ it "records making the user a group owner" do
logger.log_make_user_group_owner(user)
group_history = GroupHistory.last
@@ -22,7 +22,7 @@ RSpec.describe GroupActionLogger do
end
describe "#log_remove_user_as_group_owner" do
- it "should create the right record" do
+ it "records removing the user as a group owner" do
logger.log_remove_user_as_group_owner(user)
group_history = GroupHistory.last
@@ -35,7 +35,7 @@ RSpec.describe GroupActionLogger do
describe "#log_add_user_to_group" do
context "as a group owner" do
- it "should create the right record" do
+ it "records the group owner's action" do
logger.log_add_user_to_group(user)
group_history = GroupHistory.last
@@ -51,7 +51,7 @@ RSpec.describe GroupActionLogger do
before { group.update!(public_admission: true) }
- it "should create the right record" do
+ it "records the regular user's action" do
logger.log_add_user_to_group(user)
group_history = GroupHistory.last
@@ -65,7 +65,7 @@ RSpec.describe GroupActionLogger do
describe "#log_remove_user_from_group" do
context "as group owner" do
- it "should create the right record" do
+ it "records the group owner's action" do
logger.log_remove_user_from_group(user)
group_history = GroupHistory.last
@@ -81,7 +81,7 @@ RSpec.describe GroupActionLogger do
before { group.update!(public_exit: true) }
- it "should create the right record" do
+ it "records the regular user's action" do
logger.log_remove_user_from_group(user)
group_history = GroupHistory.last
@@ -195,7 +195,7 @@ RSpec.describe GroupActionLogger do
end
describe "#log_change_group_settings" do
- it "should create the right record" do
+ it "records the group settings change" do
group.update!(public_admission: true, created_at: Time.zone.now)
expect { logger.log_change_group_settings }.to change { GroupHistory.count }.by(1)
diff --git a/spec/services/group_mentions_updater_spec.rb b/spec/services/group_mentions_updater_spec.rb
index deafebdac06..3ad3c578f7d 100644
--- a/spec/services/group_mentions_updater_spec.rb
+++ b/spec/services/group_mentions_updater_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe GroupMentionsUpdater do
before { Jobs.run_immediately! }
describe ".update" do
- it "should update valid group mentions" do
+ it "updates valid group mentions" do
new_group_name = "awesome_team"
old_group_name = "team"
@@ -29,7 +29,7 @@ RSpec.describe GroupMentionsUpdater do
end
end
- it "should not update invalid group mentions" do
+ it "does not update invalid group mentions" do
group = Fabricate(:group, name: "team", mentionable_level: Group::ALIAS_LEVELS[:everyone])
post.update!(raw: "This is not [email protected]")
@@ -41,7 +41,7 @@ RSpec.describe GroupMentionsUpdater do
expect(post.reload.raw_mentions).to eq([])
end
- it "should update the category description when a category description topic mentions the group" do
+ it "updates a category description that mentions the group" do
group = Fabricate(:group, name: "old_team", mentionable_level: Group::ALIAS_LEVELS[:everyone])
category = Fabricate(:category_with_definition)
@@ -58,7 +58,7 @@ RSpec.describe GroupMentionsUpdater do
expect(category.description).not_to include("old_team")
end
- it "should ignore validations" do
+ it "ignores validations" do
everyone_mention_level = Group::ALIAS_LEVELS[:everyone]
%w[awesome_team pro_team].each do |name|
diff --git a/spec/services/group_message_spec.rb b/spec/services/group_message_spec.rb
index 37dbf27f14b..c2246ef8a5f 100644
--- a/spec/services/group_message_spec.rb
+++ b/spec/services/group_message_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe GroupMessage do
describe "not sent recently" do
before { GroupMessage.any_instance.stubs(:sent_recently?).returns(false) }
- it "should send a private message to the given group" do
+ it "sends a private message to the given group" do
PostCreator
.expects(:create)
.with do |from_user, opts|
@@ -50,7 +50,7 @@ RSpec.describe GroupMessage do
it { is_expected.to eq(false) }
- it "should not send the same notification again" do
+ it "does not send the same notification again" do
PostCreator.expects(:create).never
group_message
end
diff --git a/spec/services/inline_uploads_multisite_spec.rb b/spec/services/inline_uploads_multisite_spec.rb
index f616cf70042..50c263d1566 100644
--- a/spec/services/inline_uploads_multisite_spec.rb
+++ b/spec/services/inline_uploads_multisite_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe InlineUploads, type: :multisite do
SiteSetting.s3_cdn_url = "https://s3.cdn.com"
end
- it "should correct image URLs in multisite" do
+ it "corrects image URLs in multisite" do
md = <<~MD
https:#{upload2.url} https:#{upload2.url}
#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path)}
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index 9d1ee64361a..6fdf2ef828b 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe InlineUploads do
fab!(:upload2, :upload)
fab!(:upload3, :upload)
- it "should not correct existing inline uploads" do
+ it "does not change existing inline uploads" do
md = <<~MD
![test](#{upload.short_url})haha
[test]#{upload.short_url}
@@ -24,19 +24,19 @@ RSpec.describe InlineUploads do
expect(InlineUploads.process(md)).to eq(md)
end
- it "should not escape existing content" do
+ it "does not escape existing content" do
md = "1 > 2"
expect(InlineUploads.process(md)).to eq(md)
end
- it "should not escape invalid HTML tags" do
+ it "does not escape invalid HTML tags" do
md = "<x>.<y>"
expect(InlineUploads.process(md)).to eq(md)
end
- it "should work with invalid img tags" do
+ it "handles invalid image tags" do
md = <<~MD
<img src="#{upload.url}">
@@ -53,7 +53,7 @@ RSpec.describe InlineUploads do
expect(InlineUploads.process(md)).to eq(md)
end
- it "should not correct code blocks" do
+ it "does not change code blocks" do
md = "`<a class=\"attachment\" href=\"#{upload2.url}\">In Code Block</a>`"
expect(InlineUploads.process(md)).to eq(md)
@@ -63,7 +63,7 @@ RSpec.describe InlineUploads do
expect(InlineUploads.process(md)).to eq(md)
end
- it "should not correct invalid links in quotes" do
+ it "does not change invalid links in quotes" do
post = Fabricate(:post)
user = Fabricate(:user)
@@ -102,7 +102,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct links in quotes" do
+ it "shortens upload links in quotes" do
post = Fabricate(:post)
user = Fabricate(:user)
@@ -127,7 +127,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct markdown linked images" do
+ it "shortens Markdown-linked images" do
md = <<~MD
[![](#{upload.url})](https://somelink.com)
@@ -141,7 +141,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct markdown images with title" do
+ it "shortens Markdown images with titles" do
md = <<~MD
![](#{upload.url} "some alt")
![testing](#{upload2.url} 'some alt' )
@@ -153,7 +153,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct bbcode img URLs to the short version" do
+ it "shortens BBCode image URLs" do
md = <<~MD
[img]http://some.external.img[/img]
[img]#{upload.url}[/img]
@@ -177,7 +177,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct bbcode img URLs with non-standard dimension syntax" do
+ it "shortens BBCode image URLs with nonstandard dimensions" do
md = <<~MD
[img=100x200]#{upload.url}[/img]
[IMG=640x480]#{upload2.url}[/IMG]
@@ -193,7 +193,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct markdown references" do
+ it "shortens Markdown references" do
md = <<~MD
[link3][3]
@@ -221,7 +221,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct html and markdown uppercase references" do
+ it "shortens uppercase HTML and Markdown references" do
md = <<~MD
[IMG]#{upload.url}[/IMG]
<IMG src="#{upload2.url}" />
@@ -235,7 +235,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct image URLs with v parameters" do
+ it "shortens image URLs with version parameters" do
md = <<~MD
<img src="#{upload.url}?v=1">
@@ -264,7 +264,7 @@ RSpec.describe InlineUploads do
context "with subfolder" do
before { set_subfolder "/community" }
- it "should correct subfolder images" do
+ it "shortens image URLs in subfolder installations" do
md = <<~MD
<img src="/community#{upload.url}">
@@ -279,7 +279,7 @@ RSpec.describe InlineUploads do
end
end
- it "should correct raw image URLs to the short url and paths" do
+ it "shortens raw image URLs and paths" do
md = <<~MD
#{Discourse.base_url}#{upload.url}
@@ -301,7 +301,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct non image URLs to the short url" do
+ it "shortens non-image upload URLs" do
SiteSetting.authorized_extensions = "mp4"
upload = Fabricate(:video_upload)
upload2 = Fabricate(:video_upload)
@@ -323,7 +323,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct img tags with uppercase upload extension" do
+ it "shortens image tags with uppercase upload extensions" do
md = <<~MD
test<img src="#{upload.url.sub(".png", ".PNG")}">
MD
@@ -333,7 +333,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct image URLs that follows an image md" do
+ it "shortens image URLs following Markdown images" do
md = <<~MD
![image|690x290](#{upload.short_url})#{Discourse.base_url}#{upload2.url}
@@ -347,7 +347,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct image URLs to the short version" do
+ it "shortens image URLs" do
md = <<~MD
![image|690x290](#{upload.short_url})
@@ -399,7 +399,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should not replace identical markdown in code blocks", skip: "Known issue" do
+ it "does not replace identical Markdown in code blocks", skip: "Known issue" do
md = <<~MD
`![image|690x290](#{upload.url})`
![image|690x290](#{upload.url})
@@ -411,7 +411,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should not be affected by an emoji" do
+ it "preserves adjacent emoji" do
CustomEmoji.create!(name: "test", upload: upload3)
Emoji.clear_cache
@@ -428,7 +428,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correctly update images sources within anchor tags with indentation" do
+ it "updates indented image sources inside anchor tags" do
md = <<~MD
<h1></h1>
<a href="http://somelink.com">
@@ -459,7 +459,7 @@ RSpec.describe InlineUploads do
)
end
- it "should correctly update image sources within anchor or paragraph tags" do
+ it "updates image sources inside anchor and paragraph tags" do
md = <<~MD
<a href="http://somelink.com">
<img src="#{upload.url}" alt="test" width="500" height="500">
@@ -513,7 +513,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should not be affected by fake HTML tags" do
+ it "ignores fake HTML tags" do
md = <<~MD
```
This is some <img src=" and <a href="
@@ -543,7 +543,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should not be affected by an external or invalid links" do
+ it "ignores external and invalid links" do
md = <<~MD
<a id="test">invalid</a>
@@ -565,7 +565,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct attachment URLS to the short version when raw contains inline image" do
+ it "shortens attachment URLs alongside inline images" do
md = <<~MD
![image](#{upload.short_url}) ![image](#{upload.short_url})
@@ -583,7 +583,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct attachment URLs to the short version" do
+ it "shortens attachment URLs" do
md = <<~MD
<a class="attachment" href="#{upload.url}">
this
@@ -627,7 +627,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct full upload url to the shorter version" do
+ it "shortens full upload URLs" do
md = <<~MD
Some random text
@@ -694,7 +694,7 @@ RSpec.describe InlineUploads do
SiteSetting.s3_cdn_url = "https://s3.cdn.com"
end
- it "should correct image URLs to the short version" do
+ it "shortens image URLs" do
md = <<~MD
#{upload.url}
<img src="#{upload.url}" alt="some image">
@@ -710,7 +710,7 @@ RSpec.describe InlineUploads do
MD
end
- it "should correct markdown references" do
+ it "shortens Markdown references" do
md = <<~MD
This is a [some reference] something
diff --git a/spec/services/post_action_notifier_spec.rb b/spec/services/post_action_notifier_spec.rb
index d0ea7ad99a4..c9c5859ddf0 100644
--- a/spec/services/post_action_notifier_spec.rb
+++ b/spec/services/post_action_notifier_spec.rb
@@ -210,7 +210,7 @@ RSpec.describe PostActionNotifier do
Fabricate(:post, topic: private_message, user: user, raw: "Hello @eviltrout")
end
- it "won't notify someone who can't see the post" do
+ it "does not notify users who cannot see the post" do
expect { PostAlerter.post_created(mention_post) }.not_to change(
evil_trout.notifications,
:count,
@@ -232,7 +232,7 @@ RSpec.describe PostActionNotifier do
fab!(:first_post) { Fabricate(:post, user: user, raw: "A useless post for you.") }
let(:topic) { first_post.topic }
- it "should not notify anyone" do
+ it "does not notify anyone" do
expect {
Fabricate(
:post,
diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb
index 3ddbd0b94af..fe8712e3ef7 100644
--- a/spec/services/post_alerter_spec.rb
+++ b/spec/services/post_alerter_spec.rb
@@ -585,7 +585,7 @@ RSpec.describe PostAlerter do
}.to change(evil_trout.notifications, :count).by(2)
end
- it "won't notify the user a second time on revision" do
+ it "does not notify the user again on revision" do
p1 = create_post_with_alerts(raw: '[quote="Evil Trout, post:1"]whatup[/quote]')
expect {
p1.revise(p1.user, raw: '[quote="Evil Trout, post:1"]whatup now?[/quote]')
@@ -677,7 +677,7 @@ RSpec.describe PostAlerter do
before { Jobs.run_immediately! }
- it "will notify correctly on linking" do
+ it "notifies the linked user" do
linking_post
expect(user.notifications.count).to eq(1)
@@ -873,7 +873,7 @@ RSpec.describe PostAlerter do
expect { mention_post }.to change(evil_trout.notifications, :count).by(1)
end
- it "won't notify the user a second time on revision" do
+ it "does not notify the user again on revision" do
mention_post
expect {
mention_post.revise(
@@ -1876,7 +1876,7 @@ RSpec.describe PostAlerter do
).to eq(true)
end
- it "it doesn't notify about small action posts when the topic author is watching the topic " do
+ it "does not notify the watching topic author about small action posts" do
Jobs.run_immediately!
u1 = Fabricate(:admin)
@@ -2743,7 +2743,7 @@ RSpec.describe PostAlerter do
)
end
- it "should use the first post of the topic" do
+ it "uses the first post of the topic" do
topic_link
expect(PostAlerter.new.extract_linked_users(post.reload)).to eq([post2.user])
end
diff --git a/spec/services/post_owner_changer_spec.rb b/spec/services/post_owner_changer_spec.rb
index 95f26251100..3b4d014ae24 100644
--- a/spec/services/post_owner_changer_spec.rb
+++ b/spec/services/post_owner_changer_spec.rb
@@ -308,7 +308,7 @@ RSpec.describe PostOwnerChanger do
let(:pm) { create_post(archetype: "private_message", target_usernames: [p2user.username]) }
let(:pm_poster) { pm.user }
- it "should update users' counts" do
+ it "updates the users' counts" do
PostActionCreator.like(p2user, pm)
expect {
diff --git a/spec/services/problem_check/maxmind_db_configuration_spec.rb b/spec/services/problem_check/maxmind_db_configuration_spec.rb
index f5981993139..c103b032d3f 100644
--- a/spec/services/problem_check/maxmind_db_configuration_spec.rb
+++ b/spec/services/problem_check/maxmind_db_configuration_spec.rb
@@ -4,19 +4,19 @@ RSpec.describe ProblemCheck::MaxmindDbConfiguration do
subject(:check) { described_class.new }
context "when `maxmind_license_key` and `maxmind_account_id` global settings are not set" do
- it "should not raise any warning message" do
+ it "reports no problem" do
expect(check).to be_chill_about_it
end
end
context "when `maxmind_license_key` and `maxmind_account_id` global settings are set" do
- it "should not raise any warning message" do
+ it "reports no problem" do
expect(check).to be_chill_about_it
end
end
context "when `maxmind_license_key` global setting is set but not `maxmind_account_id`" do
- it "should raise the right warning" do
+ it "reports a low-priority MaxMind configuration warning" do
global_setting :maxmind_license_key, "license_key"
expect(check).to have_a_problem.with_priority("low").with_message(
diff --git a/spec/services/search_indexer_spec.rb b/spec/services/search_indexer_spec.rb
index 2fc31d5ce4d..4bd65ce77f5 100644
--- a/spec/services/search_indexer_spec.rb
+++ b/spec/services/search_indexer_spec.rb
@@ -162,7 +162,7 @@ RSpec.describe SearchIndexer do
let(:topic) { Fabricate(:topic, title: "this is a title that I am testing") }
let(:post) { Fabricate(:post, topic: topic) }
- it "should index posts correctly" do
+ it "indexes post content" do
expect { post }.to change { PostSearchData.count }.by(1)
expect { post.update!(raw: "this is new content") }.to change {
@@ -174,7 +174,7 @@ RSpec.describe SearchIndexer do
}
end
- it "should work with edge case domain names" do
+ it "indexes edge-case domain names" do
# 00E5A4 stems to 00e5 and a4, which is odd, but by-design
# this may cause internal indexing to fail due to indexes not aligning
# when stuffing terms for domains
@@ -192,7 +192,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should work with invalid HTML" do
+ it "handles invalid HTML" do
post.update!(cooked: "<FD>" * Nokogiri::Gumbo::DEFAULT_MAX_TREE_DEPTH)
SearchIndexer.update_posts_index(
@@ -205,14 +205,14 @@ RSpec.describe SearchIndexer do
)
end
- it "should not index posts with empty raw" do
+ it "does not index posts with empty raw content" do
expect do
post = Fabricate.build(:post, raw: "", post_type: Post.types[:small_action])
post.save!(validate: false)
end.to_not change { PostSearchData.count }
end
- it "should not tokenize urls and duplicate title and href in <a>" do
+ it "does not duplicate anchor titles and URLs as tokens" do
post.update!(raw: <<~RAW)
https://meta.discourse.org/some.png
RAW
@@ -227,7 +227,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should not tokenize versions" do
+ it "does not tokenize version numbers" do
post.update!(raw: "123.223")
expect(post.post_search_data.search_data).to eq(
@@ -242,7 +242,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should tokenize host of a URL and removes query string" do
+ it "tokenizes URL hosts without query strings" do
category = Fabricate(:category, name: "awesome category")
topic = Fabricate(:topic, category: category, title: "this is a test topic")
@@ -269,7 +269,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should not include lightbox in search" do
+ it "excludes lightbox markup from search" do
Jobs.run_immediately!
SiteSetting.max_image_width = 1
@@ -292,7 +292,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should strips audio and videos URLs from raw data" do
+ it "strips audio and video URLs from raw content" do
SiteSetting.authorized_extensions = "mp4"
Fabricate(:video_upload)
@@ -315,7 +315,7 @@ RSpec.describe SearchIndexer do
)
end
- it "should unaccent indexed content" do
+ it "removes accents from indexed content" do
SiteSetting.search_ignore_accents = true
post.update!(raw: "Cette oeuvre d'art n'est pas une œuvre")
post.post_search_data.reload
@@ -379,7 +379,7 @@ RSpec.describe SearchIndexer do
let(:post) { Fabricate(:post) }
let(:topic) { post.topic }
- it "should reset the version of search data for all posts in the topic" do
+ it "resets search-data versions for every post in the topic" do
post2 = Fabricate(:post)
SearchIndexer.queue_post_reindex(topic.id)
@@ -394,7 +394,7 @@ RSpec.describe SearchIndexer do
let!(:user) { Fabricate(:user) }
let!(:user2) { Fabricate(:user) }
- it "should reset the version of search data for all users" do
+ it "resets search-data versions for every user" do
SearchIndexer.index(user, force: true)
SearchIndexer.index(user2, force: true)
SearchIndexer.queue_users_reindex([user.id])
diff --git a/spec/services/site_settings_spec.rb b/spec/services/site_settings_spec.rb
index 2e24061f6cc..86fcd356061 100644
--- a/spec/services/site_settings_spec.rb
+++ b/spec/services/site_settings_spec.rb
@@ -41,14 +41,14 @@ RSpec.describe SiteSettingsTask do
expect(SiteSetting.default_theme_id).to eq(999_999_999)
end
- it "won't update a setting that doesn't exist" do
+ it "does not update a missing setting" do
yml = "fake_setting: foo"
log, counts = SiteSettingsTask.import(yml)
expect(log[0]).to eq "NOT FOUND: existing site setting not found for fake_setting"
expect(counts[:not_found]).to eq 1
end
- it "will log that an error has occurred" do
+ it "logs the missing-setting error" do
yml = "min_password_length: 0"
log, counts = SiteSettingsTask.import(yml)
expect(log[0]).to eq "ERROR: min_password_length: Value must be between 8 and 500."
diff --git a/spec/services/themes/theme_site_setting_manager_spec.rb b/spec/services/themes/theme_site_setting_manager_spec.rb
index adbaa53d86e..f2ab21da9fd 100644
--- a/spec/services/themes/theme_site_setting_manager_spec.rb
+++ b/spec/services/themes/theme_site_setting_manager_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe Themes::ThemeSiteSettingManager do
).to(false)
end
- it "should publish changes to clients for client site settings" do
+ it "publishes client site-setting changes" do
message = MessageBus.track_publish("/client_settings") { result }.first
expect(message.data).to eq(
{ name: :enable_welcome_banner, scoped_to: { theme_id: theme.id }, value: false },
@@ -121,7 +121,7 @@ RSpec.describe Themes::ThemeSiteSettingManager do
).to(false)
end
- it "should publish changes to clients for client site settings" do
+ it "publishes client site-setting changes" do
message = MessageBus.track_publish("/client_settings") { result }.first
expect(message.data).to eq(
{ name: :enable_welcome_banner, scoped_to: { theme_id: theme.id }, value: false },
@@ -173,7 +173,7 @@ RSpec.describe Themes::ThemeSiteSettingManager do
).to(true)
end
- it "should publish changes to clients for client site settings" do
+ it "publishes client site-setting changes" do
message = MessageBus.track_publish("/client_settings") { result }.first
expect(message.data).to eq(
{ name: :enable_welcome_banner, scoped_to: { theme_id: theme.id }, value: true },
diff --git a/spec/services/topic_timestamp_changer_spec.rb b/spec/services/topic_timestamp_changer_spec.rb
index dbde22d5ff8..1fce728244a 100644
--- a/spec/services/topic_timestamp_changer_spec.rb
+++ b/spec/services/topic_timestamp_changer_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe TopicTimestampChanger do
context "when new timestamp is in the future" do
let(:new_timestamp) { old_timestamp + 2.days }
- it "should raise the right error" do
+ it "raises the expected error" do
expect {
TopicTimestampChanger.new(topic: topic, timestamp: new_timestamp.to_f).change!
}.to raise_error(TopicTimestampChanger::InvalidTimestampError)
@@ -42,7 +42,7 @@ RSpec.describe TopicTimestampChanger do
end
context "when posts have timestamps in the future" do
- it "should set the new timestamp as the default timestamp" do
+ it "sets the new timestamp as the default" do
new_timestamp = freeze_time
p3 = Fabricate(:post, topic: topic, created_at: new_timestamp + 3.days)
diff --git a/spec/services/user_authenticator_spec.rb b/spec/services/user_authenticator_spec.rb
index c96db48880f..604f1a67c9d 100644
--- a/spec/services/user_authenticator_spec.rb
+++ b/spec/services/user_authenticator_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe UserAuthenticator do
describe "#start" do
describe "without authentication session" do
- it "should apply the right user attributes" do
+ it "requires a password without an authentication session" do
user = User.new
UserAuthenticator.new(user, {}).start
diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb
index b0e23620040..027def05f30 100644
--- a/spec/services/user_destroyer_spec.rb
+++ b/spec/services/user_destroyer_spec.rb
@@ -32,22 +32,22 @@ RSpec.describe UserDestroyer do
end
shared_examples "successfully destroy a user" do
- it "should delete the user" do
+ it "deletes the user" do
expect { destroy }.to change { User.count }.by(-1)
end
- it "should return the deleted user record" do
+ it "returns the deleted user record" do
return_value = destroy
expect(return_value).to eq(user)
expect(return_value).to be_destroyed
end
- it "should log the action" do
+ it "logs the action" do
StaffActionLogger.any_instance.expects(:log_user_deletion).with(user, anything).once
destroy
end
- it "should not log the action if quiet is true" do
+ it "does not log the action when quiet is true" do
expect {
UserDestroyer.new(admin).destroy(user, destroy_opts.merge(quiet: true))
}.to_not change { UserHistory.where(action: UserHistory.actions[:delete_user]).count }
@@ -239,7 +239,7 @@ RSpec.describe UserDestroyer do
user.stubs(:first_post_created_at).returns(Time.zone.now)
end
- it "should raise the right error" do
+ it "raises the expected error" do
StaffActionLogger.any_instance.expects(:log_user_deletion).never
expect { destroy }.to raise_error(UserDestroyer::PostsExistError)
expect(user.reload.id).to be_present
@@ -376,7 +376,7 @@ RSpec.describe UserDestroyer do
end
context "when user was invited" do
- it "should delete the invite of user" do
+ it "deletes the user's invite" do
invite = Fabricate(:invite)
topic_invite = invite.topic_invites.create!(topic: Fabricate(:topic))
invited_group = invite.invited_groups.create!(group: Fabricate(:group))
@@ -390,7 +390,7 @@ RSpec.describe UserDestroyer do
expect(TopicInvite.exists?(topic_invite.id)).to eq(false)
end
- it "should delete invites matching associated account emails" do
+ it "deletes invites matching associated-account emails" do
user = Fabricate(:user)
invite = Fabricate(:invite, email: "[email protected]")
UserAssociatedAccount.create!(
@@ -441,7 +441,7 @@ RSpec.describe UserDestroyer do
context "when user has deleted posts" do
let!(:deleted_post) { Fabricate(:post, user: user, deleted_at: 1.hour.ago) }
- it "should mark the user's deleted posts as belonging to a nuked user" do
+ it "marks deleted posts as belonging to a nuked user" do
expect { UserDestroyer.new(admin).destroy(user) }.to change { User.count }.by(-1)
expect(deleted_post.reload.user_id).to eq(nil)
end
@@ -460,7 +460,7 @@ RSpec.describe UserDestroyer do
context "when destroy fails" do
subject(:destroy) { UserDestroyer.new(admin).destroy(user) }
- it "should not log the action" do
+ it "does not log the action" do
user.stubs(:destroy).returns(false)
StaffActionLogger.any_instance.expects(:log_user_deletion).never
destroy
@@ -582,7 +582,7 @@ RSpec.describe UserDestroyer do
PostActionCreator.like(user, @post)
end
- it "should destroy the like" do
+ it "destroys the like" do
expect { UserDestroyer.new(admin).destroy(user, delete_posts: true) }.to change {
PostAction.count
}.by(-1)
@@ -634,7 +634,7 @@ RSpec.describe UserDestroyer do
)
end
- it "should keep the staff action log and add the username" do
+ it "keeps the staff action log and adds the username" do
username = user.username
ids =
UserHistory.staff_action_records(Discourse.system_user, acting_user: username).map(&:id)
diff --git a/spec/services/user_password_expirer_spec.rb b/spec/services/user_password_expirer_spec.rb
index f5c7d7695b7..479d0c77be1 100644
--- a/spec/services/user_password_expirer_spec.rb
+++ b/spec/services/user_password_expirer_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe UserPasswordExpirer do
fab!(:user) { Fabricate(:user, password:) }
describe ".expire_user_password" do
- it "should update `UserPassword#password_expired_at` if the user already has an existing UserPassword record with the same password hash, salt and algorithm" do
+ it "updates password_expired_at on an existing matching password record" do
freeze_time(1.hour.ago) do
described_class.expire_user_password(user)
diff --git a/spec/services/user_stat_count_updater_spec.rb b/spec/services/user_stat_count_updater_spec.rb
index ce8f4d68160..6c0ef1e1506 100644
--- a/spec/services/user_stat_count_updater_spec.rb
+++ b/spec/services/user_stat_count_updater_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe UserStatCountUpdater do
after { Rails.logger.stop_broadcasting_to(fake_logger) }
- it "should log the exception when a negative count is inserted" do
+ it "logs the exception when a negative count is inserted" do
UserStatCountUpdater.decrement!(post, user_stat: user_stat)
expect(fake_logger.warnings.last).to match("topic_count")
@@ -27,7 +27,7 @@ RSpec.describe UserStatCountUpdater do
expect(fake_logger.warnings.last).to match(post_2.id.to_s)
end
- it "should log the exception when a negative count will be inserted but 0 is used instead" do
+ it "logs the exception when zero replaces a negative count" do
UserStatCountUpdater.set!(user_stat: user_stat, count: -10, count_column: :post_count)
expect(fake_logger.warnings.last).to match("post_count")
diff --git a/spec/services/username_changer_spec.rb b/spec/services/username_changer_spec.rb
index 9c9f3dfa20b..0062a212be2 100644
--- a/spec/services/username_changer_spec.rb
+++ b/spec/services/username_changer_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe UsernameChanger do
context "when everything goes well" do
let!(:old_username) { user.username }
- it "should change the username" do
+ it "changes the username" do
new_username = "#{user.username}1234"
events =
@@ -49,7 +49,7 @@ RSpec.describe UsernameChanger do
let(:username_before_change) { user.username }
let(:username_lower_before_change) { user.username_lower }
- it "should not change the username" do
+ it "does not change the username" do
@result = UsernameChanger.change(user, wrong_username)
expect(@result).to eq(false)
@@ -62,7 +62,7 @@ RSpec.describe UsernameChanger do
context "when changing the case of my username" do
let!(:myself) { Fabricate(:user, username: "hansolo") }
- it "should change the username" do
+ it "changes the username" do
expect do
expect(UsernameChanger.change(myself, "HanSolo", myself)).to eq(true)
end.to change { UserHistory.count }.by(1)
@@ -87,17 +87,17 @@ RSpec.describe UsernameChanger do
SiteSetting.min_username_length = @custom_min
end
- it "should allow a shorter username than default" do
+ it "allows a username shorter than the default minimum" do
result = UsernameChanger.change(user, "a" * @custom_min)
expect(result).not_to eq(false)
end
- it "should not allow a shorter username than limit" do
+ it "rejects a username shorter than the configured minimum" do
result = UsernameChanger.change(user, "a" * (@custom_min - 1))
expect(result).to eq(false)
end
- it "should not allow a longer username than limit" do
+ it "rejects a username longer than the maximum" do
result = UsernameChanger.change(user, "a" * (User.username_length.end + 1))
expect(result).to eq(false)
end
@@ -380,7 +380,7 @@ RSpec.describe UsernameChanger do
let(:user) { Fabricate(:user, username: "թռչուն") }
- it "it correctly updates mentions" do
+ it "updates mentions" do
post = create_post_and_change_username(raw: "Hello @թռչուն", target_username: "птица")
expect(post.raw).to eq("Hello @птица")
diff --git a/spec/system/admin_customize_form_templates_spec.rb b/spec/system/admin_customize_form_templates_spec.rb
index 5fb30abdd52..5b38e8d028a 100644
--- a/spec/system/admin_customize_form_templates_spec.rb
+++ b/spec/system/admin_customize_form_templates_spec.rb
@@ -16,28 +16,28 @@ describe "Admin Customize Form Templates" do
describe "when visiting the page to customize form templates" do
before { category.update!(form_template_ids: [form_template.id]) }
- it "should show the existing form templates in a table" do
+ it "shows existing form templates in a table" do
form_template_page.visit
expect(form_template_page).to have_form_template_table
expect(form_template_page).to have_form_template(form_template.name)
end
- it "should show the categories the form template is used in" do
+ it "shows the categories using each form template" do
form_template_page.visit
expect(form_template_page).to have_form_template_table
expect(form_template_page).to have_category_in_template_row(category.name)
end
- it "should show the form template structure in a modal" do
+ it "shows the form-template structure in a modal" do
form_template_page.visit
form_template_page.click_view_form_template
expect(form_template_page).to have_template_structure("- type: input")
end
- it "should show a preview of the template in a modal when toggling the preview" do
+ it "shows a template preview when the preview is toggled" do
form_template_page.visit
form_template_page.click_view_form_template
@@ -46,14 +46,14 @@ describe "Admin Customize Form Templates" do
end
context "when using the view template modal" do
- it "should navigate to the edit page when clicking the edit button" do
+ it "opens the edit page from the edit button" do
form_template_page.visit
form_template_page.click_view_form_template
form_template_page.find(".d-modal__footer .btn-primary").click
expect(page).to have_current_path("/admin/customize/form-templates/#{form_template.id}")
end
- it "should delete the form template when clicking the delete button" do
+ it "deletes the form template from the delete button" do
form_template_page.visit
original_template_name = form_template.name
form_template_page.click_view_form_template
@@ -66,7 +66,7 @@ describe "Admin Customize Form Templates" do
end
describe "when visiting the page to edit a form template" do
- it "should prefill form data" do
+ it "prefills the form data" do
visit("/admin/customize/form-templates/#{form_template.id}")
expect(form_template_page).to have_name_value(form_template.name)
expect(ace_editor).to have_content(form_template.template)
@@ -81,7 +81,7 @@ describe "Admin Customize Form Templates" do
end
describe "when visiting the page to create a new form template" do
- it "should allow admin to create a new form template" do
+ it "allows an administrator to create a form template" do
form_template_page.visit_new
sample_name = "My First Template"
@@ -93,7 +93,7 @@ describe "Admin Customize Form Templates" do
expect(form_template_page).to have_form_template(sample_name)
end
- it "should disable the save button until form is filled out" do
+ it "disables saving until the form is complete" do
form_template_page.visit_new
expect(form_template_page).to have_save_button_with_state(disabled: true)
form_template_page.type_in_template_name("New Template")
@@ -102,7 +102,7 @@ describe "Admin Customize Form Templates" do
expect(form_template_page).to have_save_button_with_state(disabled: false)
end
- it "should disable the preview button until form is filled out" do
+ it "disables previewing until the form is complete" do
form_template_page.visit_new
expect(form_template_page).to have_preview_button_with_state(disabled: true)
form_template_page.type_in_template_name("New Template")
@@ -111,7 +111,7 @@ describe "Admin Customize Form Templates" do
expect(form_template_page).to have_preview_button_with_state(disabled: false)
end
- it "should show validation options in a modal when clicking the validations button" do
+ it "shows validation options from the validations button" do
form_template_page.visit_new
form_template_page.click_validations_button
expect(form_template_page).to have_validations_modal
@@ -136,7 +136,7 @@ describe "Admin Customize Form Templates" do
expect(form_template_page).to have_form_template(sample_name)
end
- it "should show a preview of the template in a modal when clicking the preview button" do
+ it "shows the template preview from the preview button" do
form_template_page.visit_new
form_template_page.type_in_template_name("New Template")
ace_editor.type_input("- type: input\n id: name")
@@ -146,7 +146,7 @@ describe "Admin Customize Form Templates" do
expect(form_template_page).to have_input_field("input")
end
- it "should render all the input field types in the preview" do
+ it "renders every input type in the preview" do
tag1 = Fabricate(:tag)
tag2 = Fabricate(:tag)
tag3 = Fabricate(:tag)
@@ -183,7 +183,7 @@ describe "Admin Customize Form Templates" do
tag_group.tags.each { |tag| expect(form_template_page).to have_tag_chooser_tag(tag) }
end
- it "should allow quick insertion of checkbox field" do
+ it "quickly inserts a checkbox field" do
quick_insertion_test(
"checkbox",
'- type: checkbox
@@ -195,7 +195,7 @@ describe "Admin Customize Form Templates" do
)
end
- it "should allow quick insertion of short answer field" do
+ it "quickly inserts a short-answer field" do
quick_insertion_test(
"input",
'- type: input
@@ -208,7 +208,7 @@ describe "Admin Customize Form Templates" do
)
end
- it "should allow quick insertion of long answer field" do
+ it "quickly inserts a long-answer field" do
quick_insertion_test(
"textarea",
'- type: textarea
@@ -221,7 +221,7 @@ describe "Admin Customize Form Templates" do
)
end
- it "should allow quick insertion of dropdown field" do
+ it "quickly inserts a dropdown field" do
quick_insertion_test(
"dropdown",
'- type: dropdown
@@ -238,7 +238,7 @@ describe "Admin Customize Form Templates" do
)
end
- it "should allow quick insertion of upload field" do
+ it "quickly inserts an upload field" do
quick_insertion_test(
"upload",
'- type: upload
@@ -252,7 +252,7 @@ describe "Admin Customize Form Templates" do
)
end
- it "should allow quick insertion of multiple choice field" do
+ it "quickly inserts a multiple-choice field" do
quick_insertion_test(
"multiselect",
'- type: multi-select
diff --git a/spec/system/admin_customize_themes_spec.rb b/spec/system/admin_customize_themes_spec.rb
index 0bfe8f1a534..0ab5e5161dd 100644
--- a/spec/system/admin_customize_themes_spec.rb
+++ b/spec/system/admin_customize_themes_spec.rb
@@ -15,12 +15,12 @@ describe "Admin Customize Themes" do
before { sign_in(admin) }
describe "when visiting the page to customize a single theme" do
- it "should keep sidebar navigation link active" do
+ it "keeps the sidebar navigation link active" do
theme_page.visit(theme)
expect(sidebar).to have_active_link("admin_themes_and_components")
end
- it "should allow admin to update the light color scheme of the theme" do
+ it "allows admins to update the theme's light color scheme" do
theme_page.visit(theme)
color_scheme_settings = find(".theme-settings__light-color-scheme")
@@ -42,7 +42,7 @@ describe "Admin Customize Themes" do
)
end
- it "should allow admin to update the dark color scheme of the theme" do
+ it "allows admins to update the theme's dark color scheme" do
theme_page.visit(theme)
color_scheme_settings = find(".theme-settings__dark-color-scheme")
@@ -182,7 +182,7 @@ describe "Admin Customize Themes" do
end
describe "when editing theme translations" do
- it "should allow admin to edit and save the theme translations" do
+ it "allows admins to edit and save theme translations" do
theme.set_field(
target: :translations,
name: "en",
@@ -204,7 +204,7 @@ describe "Admin Customize Themes" do
expect(theme_translations_settings_editor.get_input_value).to have_content("Hello World")
end
- it "should allow admin to edit and save the theme translations from other languages" do
+ it "allows admins to edit and save theme translations in other languages" do
theme.set_field(
target: :translations,
name: "en",
@@ -234,7 +234,7 @@ describe "Admin Customize Themes" do
theme_translations_settings_editor.save
end
- it "should match the current user locale translation" do
+ it "uses translations matching the current user's locale" do
SiteSetting.allow_user_locale = true
SiteSetting.set_locale_from_accept_language_header = true
SiteSetting.default_locale = "fr"
diff --git a/spec/system/admin_editing_objects_typed_theme_setting_spec.rb b/spec/system/admin_editing_objects_typed_theme_setting_spec.rb
index f53faa71178..03c5b362d45 100644
--- a/spec/system/admin_editing_objects_typed_theme_setting_spec.rb
+++ b/spec/system/admin_editing_objects_typed_theme_setting_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe "Admin editing objects type" do
before { objects_setting }
- it "should display the right label and description for each property if the label and description has been configured in a locale file" do
+ it "displays property labels and descriptions from the locale file" do
theme.set_field(
target: :translations,
name: "en",
@@ -61,7 +61,7 @@ RSpec.describe "Admin editing objects type" do
expect(admin_objects_setting_editor_page).to have_setting_field_label("url", "URL")
end
- it "should allow admin to edit the theme setting of objects type" do
+ it "allows admins to edit an objects theme setting" do
visit("/admin/customize/themes/#{theme.id}")
expect(admin_customize_themes_page).to have_no_overriden_setting("objects_setting")
diff --git a/spec/system/admin_reports_spec.rb b/spec/system/admin_reports_spec.rb
index a46beae049b..bf52f5facd6 100644
--- a/spec/system/admin_reports_spec.rb
+++ b/spec/system/admin_reports_spec.rb
@@ -19,7 +19,7 @@ describe "Admin Reports" do
context "when use_legacy_pageviews is false" do
before { SiteSetting.use_legacy_pageviews = false }
- it "won't redirects from site_traffic to consolidated_page_views" do
+ it "does not redirect site_traffic to consolidated_page_views" do
visit "/admin/reports/site_traffic"
expect(page).to have_current_path("/admin/reports/site_traffic")
end
diff --git a/spec/system/capabilities_service_spec.rb b/spec/system/capabilities_service_spec.rb
index 4f65ff54184..6c2c8aeaf4a 100644
--- a/spec/system/capabilities_service_spec.rb
+++ b/spec/system/capabilities_service_spec.rb
@@ -2,7 +2,7 @@
describe "capabilities service" do
describe "viewport helpers" do
- it "works" do
+ it "updates viewport matches when the window is resized" do
def matches(name)
page.evaluate_script("Discourse.lookup('service:capabilities').viewport[#{name.to_json}]")
end
diff --git a/spec/system/category_localizations_spec.rb b/spec/system/category_localizations_spec.rb
index 0191f2a98cd..d204a505626 100644
--- a/spec/system/category_localizations_spec.rb
+++ b/spec/system/category_localizations_spec.rb
@@ -36,7 +36,7 @@ describe "Category Localizations" do
context "when content localization setting is disabled" do
before { SiteSetting.content_localization_enabled = false }
- it "should not show the localization tab" do
+ it "hides the localization tab" do
sign_in(admin)
category_page.visit_settings(category)
@@ -68,7 +68,7 @@ describe "Category Localizations" do
describe "Category Settings" do
before { sign_in(admin) }
- it "should show the localization tab" do
+ it "shows the localization tab" do
category_page.visit_settings(category)
expect(category_page).to have_setting_tab("localizations")
end
@@ -99,12 +99,12 @@ describe "Category Localizations" do
describe "when editing a category with no category localizations" do
fab!(:mono_category, :category)
- it "should show info hint to add new localizations" do
+ it "shows a hint to add new localizations" do
category_page.visit_edit_localizations(mono_category)
expect(form).to have_an_alert(I18n.t("js.category.localization.hint"))
end
- it "should allow you to add new localizations" do
+ it "allows adding new localizations" do
category_page.visit_edit_localizations(mono_category)
category_page.find(".edit-category-tab-localizations .add-localization").click
form.field("localizations.0.locale").select("es")
diff --git a/spec/system/composer/default_to_subcategory_spec.rb b/spec/system/composer/default_to_subcategory_spec.rb
index 12f4365d946..10dd1a09935 100644
--- a/spec/system/composer/default_to_subcategory_spec.rb
+++ b/spec/system/composer/default_to_subcategory_spec.rb
@@ -33,7 +33,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" do
describe "Can't post on parent category" do
describe "Category has subcategory" do
- it "should have 'New Topic' button enabled and default Subcategory set in the composer" do
+ it "enables New Topic and selects the default subcategory" do
category_page.visit(category)
expect(category_page).to have_button("New Topic", disabled: false)
category_page.new_topic_button.click
@@ -44,7 +44,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" do
end
describe "Category does not have subcategory" do
- it "should have the 'New Topic' button enabled and no category set in the composer" do
+ it "enables New Topic without selecting a category" do
category_page.visit(category_with_no_subcategory)
expect(category_page).to have_button("New Topic", disabled: false)
@@ -58,7 +58,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" do
end
describe "Can post on home page" do
- it "should have the default category set in the composer" do
+ it "selects the default category in the composer" do
page.visit("latest")
expect(page).to have_button("New Topic", disabled: false)
page.find("#create-topic").click
diff --git a/spec/system/discovery_list_spec.rb b/spec/system/discovery_list_spec.rb
index 33574dd290a..4b066c04897 100644
--- a/spec/system/discovery_list_spec.rb
+++ b/spec/system/discovery_list_spec.rb
@@ -45,7 +45,7 @@ describe "Discovery list" do
fab!(:post1) { create_post(user: user, topic: topic) }
fab!(:post2) { create_post(topic: topic) }
- it "should correctly show/hide the bulk select toggle for regular users" do
+ it "shows and hides the bulk-select toggle for regular users" do
sign_in(user)
visit("/unread")
diff --git a/spec/system/edit_category_form_templates_spec.rb b/spec/system/edit_category_form_templates_spec.rb
index 1a928c7a6a6..4a94b5153a7 100644
--- a/spec/system/edit_category_form_templates_spec.rb
+++ b/spec/system/edit_category_form_templates_spec.rb
@@ -19,13 +19,13 @@ describe "Edit Category Form Templates" do
describe "when editing a category with no form templates set" do
before { category.update(form_template_ids: []) }
- it "should have form templates disabled and topic template enabled" do
+ it "disables form templates and enables the topic template" do
category_page.visit_edit_template(category)
expect(category_page).not_to have_form_template_enabled
expect(category_page).to have_d_editor
end
- it "should allow you to select and save a form template" do
+ it "allows selecting and saving one form template" do
category_page.visit_edit_template(category)
category_page.toggle_form_templates
expect(category_page).to have_no_d_editor
@@ -36,7 +36,7 @@ describe "Edit Category Form Templates" do
expect(Category.find_by_id(category.id).form_template_ids).to eq([form_template.id])
end
- it "should allow you to select and save multiple form templates" do
+ it "allows selecting and saving multiple form templates" do
category_page.visit_edit_template(category)
category_page.toggle_form_templates
category_page.select_form_template(form_template.name)
@@ -52,7 +52,7 @@ describe "Edit Category Form Templates" do
describe "when editing a category with form templates set" do
before { category.update(form_template_ids: [form_template.id, form_template_2.id]) }
- it "should have form templates enabled and showing the selected templates" do
+ it "enables form templates and shows the selected templates" do
category_page.visit_edit_template(category)
expect(category_page).to have_form_template_enabled
expect(category_page).to have_no_d_editor
diff --git a/spec/system/editing_sidebar_community_section_spec.rb b/spec/system/editing_sidebar_community_section_spec.rb
index d7fac8366d8..27f4735017f 100644
--- a/spec/system/editing_sidebar_community_section_spec.rb
+++ b/spec/system/editing_sidebar_community_section_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe "Editing Sidebar Community Section" do
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:sidebar_header_dropdown) { PageObjects::Components::NavigationMenu::HeaderDropdown.new }
- it "should not display the edit section button to non admins" do
+ it "hides the edit-section button from non-administrators" do
sign_in(user)
visit("/latest")
@@ -102,7 +102,7 @@ RSpec.describe "Editing Sidebar Community Section" do
expect(modal).to be_visible
end
- it "should allow admins to open modal to edit the section when `navigation_menu` site setting is `header dropdown`" do
+ it "lets administrators edit the section from the header dropdown" do
SiteSetting.navigation_menu = "header dropdown"
sign_in(admin)
diff --git a/spec/system/emojis/emoji_deny_list_spec.rb b/spec/system/emojis/emoji_deny_list_spec.rb
index e001652dce4..9e5ac4c5683 100644
--- a/spec/system/emojis/emoji_deny_list_spec.rb
+++ b/spec/system/emojis/emoji_deny_list_spec.rb
@@ -31,7 +31,7 @@ describe "Emoji deny list" do
fab!(:topic) { Fabricate(:topic, title: "Time for :monkey: business") }
fab!(:post) { Fabricate(:post, topic: topic, raw: "We have no time to :monkey: around!") }
- it "should remove denied emojis from page title, heading and body" do
+ it "removes denied emojis from the page title, heading, and body" do
topic_page.visit_topic(topic)
expect(page.title).to eq("Time for business - Discourse")
expect(topic_page).to have_topic_title("Time for business")
@@ -59,7 +59,7 @@ describe "Emoji deny list" do
expect(emoji_picker).to have_no_emoji(":poop:")
end
- it "should not show denied emojis and aliases in emoji autocomplete" do
+ it "hides denied emojis and aliases from emoji autocomplete" do
topic_page.visit_topic_and_open_composer(topic)
composer.type_content(":poop") # shows no results
@@ -72,7 +72,7 @@ describe "Emoji deny list" do
expect(composer).to have_no_emoji_suggestion("fu")
end
- it "should not show denied emoji in preview" do
+ it "hides denied emojis from the preview" do
topic_page.visit_topic_and_open_composer(topic)
composer.fill_content(":wave:")
@@ -96,7 +96,7 @@ describe "Emoji deny list" do
end
fab!(:post) { Fabricate(:post, topic: topic, raw: "Can we use the :monkey: emoji here?") }
- it "should remove denied emojis from message title and body" do
+ it "removes denied emojis from the message title and body" do
topic_page.visit_topic(topic)
expect(topic_page).to have_topic_title("Want to catch up for today?")
expect(post).not_to have_css(".emoji[title=':monkey:']")
diff --git a/spec/system/filtering_topics_spec.rb b/spec/system/filtering_topics_spec.rb
index a0c479cce5b..1427a31eb8f 100644
--- a/spec/system/filtering_topics_spec.rb
+++ b/spec/system/filtering_topics_spec.rb
@@ -47,7 +47,7 @@ describe "Filtering topics" do
topic
end
- it "should display the right topics when the status filter is used in the query string" do
+ it "displays matching topics for a status query-string filter" do
sign_in(user)
visit("/filter")
@@ -82,7 +82,7 @@ describe "Filtering topics" do
fab!(:topic_with_tag2) { Fabricate(:topic, tags: [tag2]) }
fab!(:topic_with_tag_and_tag2) { Fabricate(:topic, tags: [tag, tag2]) }
- it "should display the right topics when tags filter is used in the query string" do
+ it "displays matching topics for a tag query-string filter" do
sign_in(user)
visit("/filter")
diff --git a/spec/system/forgot_password_spec.rb b/spec/system/forgot_password_spec.rb
index b252d28eaa7..6a8d58273f2 100644
--- a/spec/system/forgot_password_spec.rb
+++ b/spec/system/forgot_password_spec.rb
@@ -21,7 +21,7 @@ shared_examples "forgot password scenarios" do
end
context "when user does not have any multi-factor authentication configured" do
- it "should allow a user to reset their password" do
+ it "allows the user to reset their password" do
visit_reset_password_link
user_reset_password_page.fill_in_new_password("newsuperpassword").submit_new_password
@@ -34,7 +34,7 @@ shared_examples "forgot password scenarios" do
context "when user only has TOTP configured" do
fab!(:user_second_factor_totp) { Fabricate(:user_second_factor_totp, user:) }
- it "should allow a user to reset password with TOTP" do
+ it "allows resetting the password with TOTP" do
visit_reset_password_link
expect(user_reset_password_page).to have_no_toggle_button_to_second_factor_form
@@ -50,7 +50,7 @@ shared_examples "forgot password scenarios" do
end
context "when user only has security key configured" do
- it "should allow a user to reset password with a security key" do
+ it "allows resetting the password with a security key" do
with_security_key(user) do
visit_reset_password_link
@@ -69,7 +69,7 @@ shared_examples "forgot password scenarios" do
fab!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user:) }
fab!(:user_second_factor_totp) { Fabricate(:user_second_factor_totp, user:) }
- it "should allow a user to reset password with backup code" do
+ it "allows resetting the password with a backup code" do
visit_reset_password_link
user_reset_password_page
@@ -86,7 +86,7 @@ shared_examples "forgot password scenarios" do
context "when user has security key and backup codes configured" do
fab!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user:) }
- it "should allow a user to reset password with backup code instead of security key" do
+ it "allows using a backup code instead of a security key to reset the password" do
with_security_key(user) do
visit_reset_password_link
@@ -109,7 +109,7 @@ shared_examples "forgot password scenarios" do
fab!(:user_second_factor_totp) { Fabricate(:user_second_factor_totp, user:) }
fab!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user:) }
- it "should allow a user to toggle from security key to TOTP and between TOTP and backup codes" do
+ it "allows switching between security keys, TOTP, and backup codes" do
with_security_key(user) do
visit_reset_password_link
@@ -131,7 +131,7 @@ shared_examples "forgot password scenarios" do
context "when user has TOTP and security key configured but no backup codes" do
fab!(:user_second_factor_totp) { Fabricate(:user_second_factor_totp, user:) }
- it "should allow a user to reset password with TOTP instead of security key" do
+ it "allows using TOTP instead of a security key to reset the password" do
with_security_key(user) do
visit_reset_password_link
diff --git a/spec/system/groups/group_members_spec.rb b/spec/system/groups/group_members_spec.rb
index 0235afdfb2a..5e877703073 100644
--- a/spec/system/groups/group_members_spec.rb
+++ b/spec/system/groups/group_members_spec.rb
@@ -9,7 +9,7 @@ describe "Group members" do
before { sign_in(admin) }
describe "adds a user to the group" do
- it "should show that the user is already in the group" do
+ it "shows that the user is already in the group" do
group_page.visit(group).add_users.select_user_and_add(admin)
expect(
diff --git a/spec/system/new_category_spec.rb b/spec/system/new_category_spec.rb
index 73b3324cd50..b06fc717987 100644
--- a/spec/system/new_category_spec.rb
+++ b/spec/system/new_category_spec.rb
@@ -6,7 +6,7 @@ describe "New Category" do
before { sign_in(admin) }
- it "should create category with 0 in minimum_required_tags column when not defined" do
+ it "defaults minimum_required_tags to zero when creating a category" do
category_page.visit_new_category
category_page.find(".edit-category-tab-general input.category-name").fill_in(
diff --git a/spec/system/post_translation_spec.rb b/spec/system/post_translation_spec.rb
index c903477acab..16eae014a42 100644
--- a/spec/system/post_translation_spec.rb
+++ b/spec/system/post_translation_spec.rb
@@ -30,7 +30,7 @@ describe "Post translations" do
end
context "when a post does not have translations" do
- it "should only show the languages listed in the site setting" do
+ it "shows only languages configured in the site setting" do
post.update!(locale: "en")
topic_page.visit_topic(topic)
@@ -218,7 +218,7 @@ describe "Post translations" do
end
context "when creating a new post in a different locale" do
- it "should only show the languages listed in the site setting and default locale and a none value" do
+ it "shows configured languages, the default locale, and no locale" do
visit("/latest")
page.find("#create-topic").click
post_language_selector.expand
@@ -231,7 +231,7 @@ describe "Post translations" do
)
end
- it "should allow a user to create a post in a different locale" do
+ it "allows a user to create a post in another locale" do
visit("/latest")
page.find("#create-topic").click
post_language_selector.expand
@@ -244,7 +244,7 @@ describe "Post translations" do
expect(updated_post.locale).to eq("fr")
end
- it "should not have a locale set by default" do
+ it "does not select a locale by default" do
visit("/latest")
page.find("#create-topic").click
expect(
diff --git a/spec/system/private_message_spec.rb b/spec/system/private_message_spec.rb
index 73604c42a78..e4dfce848ec 100644
--- a/spec/system/private_message_spec.rb
+++ b/spec/system/private_message_spec.rb
@@ -25,7 +25,7 @@ describe "Private Message" do
context "for 'new personal message' action option in composer" do
before { sign_in(sender) }
- it "should be available in new topic" do
+ it "offers the personal message action in a new topic" do
visit "/new-topic"
expect(composer).to be_opened
@@ -35,7 +35,7 @@ describe "Private Message" do
expect(composer.button_label).to have_text(I18n.t("js.composer.create_pm"))
end
- it "should not be available in private conversation reply" do
+ it "omits the personal message action when replying to a private conversation" do
visit(pm_post.full_url)
pm_post_obj.reply
diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb
index facf54107b5..739f5d15bfa 100644
--- a/spec/system/reviewables_spec.rb
+++ b/spec/system/reviewables_spec.rb
@@ -61,7 +61,7 @@ describe "Reviewables" do
expect(post.reload.raw).to eq("This post has been edited by a moderator.")
end
- it "should open a modal when suspending a user" do
+ it "opens a modal when suspending a user" do
visit("/review")
select_kit =
@@ -76,7 +76,7 @@ describe "Reviewables" do
)
end
- it "should show a toast when disagreeing with a flag flag" do
+ it "shows a toast when disagreeing with a flag" do
visit("/review")
select_kit = PageObjects::Components::SelectKit.new(".dropdown-select-box.post-disagree")
diff --git a/spec/system/table_builder_spec.rb b/spec/system/table_builder_spec.rb
index 9a8bb10774e..47c7ef2458e 100644
--- a/spec/system/table_builder_spec.rb
+++ b/spec/system/table_builder_spec.rb
@@ -29,7 +29,7 @@ describe "Table Builder" do
end
context "when creating a new table" do
- it "should add table items created in spreadsheet to composer input" do
+ it "adds spreadsheet table items to the composer" do
visit("/latest")
page.find("#create-topic").click
find(".toolbar-menu__options-trigger").click
@@ -55,7 +55,7 @@ describe "Table Builder" do
end
context "when cancelling table creation" do
- it "should close the modal if there are no changes made" do
+ it "closes the modal when nothing changed" do
visit("/latest")
page.find("#create-topic").click
find(".toolbar-menu__options-trigger").click
@@ -64,7 +64,7 @@ describe "Table Builder" do
expect(page).to have_no_css(".insert-table-modal")
end
- it "should show a warning popup if there are unsaved changes" do
+ it "warns about unsaved changes" do
visit("/latest")
page.find("#create-topic").click
find(".toolbar-menu__options-trigger").click
@@ -77,7 +77,7 @@ describe "Table Builder" do
end
context "when editing a table" do
- it "should prefill the spreadsheet with the markdown table items from the post" do
+ it "prefills the spreadsheet from the post's Markdown table" do
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
@@ -95,7 +95,7 @@ describe "Table Builder" do
end
end
- it "should update the post with the new table content" do
+ it "updates the post with the new table content" do
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
@@ -113,7 +113,7 @@ describe "Table Builder" do
expect(normalize_value(post1.reload.raw)).to eq(normalize_value(updated_post))
end
- it "should respect the original empty header" do
+ it "preserves an empty table header" do
topic_page.visit_topic(topic2)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
@@ -131,7 +131,7 @@ describe "Table Builder" do
end
context "when adding an edit reason" do
- it "should add the edit reason to the edit history" do
+ it "adds the edit reason to the revision history" do
edit_reason = "Updated Nissan model"
topic_page.visit_topic(topic)
@@ -147,7 +147,7 @@ describe "Table Builder" do
end
context "when cancelling table creation" do
- it "should close the modal if there are no changes made" do
+ it "closes the modal when nothing changed" do
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
@@ -163,7 +163,7 @@ describe "Table Builder" do
expect(page).to have_no_css(".insert-table-modal")
end
- it "should show a warning popup if there are unsaved changes" do
+ it "warns about unsaved changes" do
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
expect(page).to have_selector(".insert-table-modal")
@@ -173,7 +173,7 @@ describe "Table Builder" do
end
end
- it "should not accept default Discourse keyboard shortcuts" do
+ it "ignores default Discourse keyboard shortcuts" do
topic_page.visit_topic(topic)
topic_page.find(".btn-edit-table", visible: :all).click
insert_table_modal.find_cell(0, 0)
diff --git a/spec/system/tag_notification_level_spec.rb b/spec/system/tag_notification_level_spec.rb
index f734253b165..2a91181675b 100644
--- a/spec/system/tag_notification_level_spec.rb
+++ b/spec/system/tag_notification_level_spec.rb
@@ -12,7 +12,7 @@ describe "Tag notification level" do
before { sign_in(current_user) }
describe "when changing a tag's notification level" do
- it "should change instantly" do
+ it "changes the notification level immediately" do
tags_page.visit_tag(tag_1)
expect(notifications_tracking).to have_selected_level_name("regular")
diff --git a/spec/system/user_page/staff_info_spec.rb b/spec/system/user_page/staff_info_spec.rb
index ec3db2812cb..eea1dccf7e9 100644
--- a/spec/system/user_page/staff_info_spec.rb
+++ b/spec/system/user_page/staff_info_spec.rb
@@ -11,7 +11,7 @@ describe "Viewing user staff info as an admin" do
fab!(:topic) { Fabricate(:private_message_topic, user: admin, recipient: user) }
fab!(:user_warning) { UserWarning.create!(user: user, created_by: admin, topic: topic) }
- it "should display the right link to user's warnings with the right count in text" do
+ it "shows the user's warning link and count" do
user_page.visit(user).click_staff_info_warnings_link(user, warnings_count: 1)
expect(user_page).to have_warning_messages_path(user)
@@ -22,7 +22,7 @@ describe "Viewing user staff info as an admin" do
fab!(:silencing) do
Fabricate(:user_history, action: UserHistory.actions[:silence_user], target_user: user)
end
- it "should display the right link to user's silencings with the right count in text" do
+ it "shows the user's silencing link and count" do
user_page.visit(user)
silencings_counters = page.find(".staff-counters .silencings")
expect(silencings_counters).to have_text("1")
diff --git a/spec/system/user_page/user_preferences_navigation_spec.rb b/spec/system/user_page/user_preferences_navigation_spec.rb
index e7888d694d7..c9a77e21602 100644
--- a/spec/system/user_page/user_preferences_navigation_spec.rb
+++ b/spec/system/user_page/user_preferences_navigation_spec.rb
@@ -6,7 +6,7 @@ describe "User preferences | Navigation menu" do
let(:user_preferences_page) { PageObjects::Pages::UserPreferences.new }
describe "when visiting the user's preferences page" do
- it "should allow the user to scroll the horizontal navigation menu when window width is narrow" do
+ it "allows horizontal navigation scrolling in a narrow window" do
resize_window(width: 650) do # narrow enough to hide some links, but higher than 640px so we don't trigger mobile styling
sign_in(user)
diff --git a/spec/system/viewing_navigation_menu_preferences_spec.rb b/spec/system/viewing_navigation_menu_preferences_spec.rb
index 5355b0c2deb..65fcd420e9e 100644
--- a/spec/system/viewing_navigation_menu_preferences_spec.rb
+++ b/spec/system/viewing_navigation_menu_preferences_spec.rb
@@ -13,7 +13,7 @@ describe "Viewing sidebar preferences" do
before { sign_in(admin) }
- it "should be able to view navigation menu preferences of another user" do
+ it "shows another user's navigation-menu preferences" do
user.user_option.update!(
sidebar_link_to_filtered_list: true,
sidebar_show_count_of_new_items: true,
diff --git a/spec/system/viewing_sidebar_as_anonymous_user_spec.rb b/spec/system/viewing_sidebar_as_anonymous_user_spec.rb
index 7b3c744625d..df008a39e27 100644
--- a/spec/system/viewing_sidebar_as_anonymous_user_spec.rb
+++ b/spec/system/viewing_sidebar_as_anonymous_user_spec.rb
@@ -32,7 +32,7 @@ describe "Viewing sidebar as anonymous user" do
Fabricate(:tag, name: "tag 6").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
end
- it "should not display the tags section when tagging has been disabled" do
+ it "hides the tags section when tagging is disabled" do
SiteSetting.tagging_enabled = false
visit("/latest")
@@ -40,7 +40,7 @@ describe "Viewing sidebar as anonymous user" do
expect(sidebar).to have_no_tags_section
end
- it "should not display the tags section when site has no top tags and `default_navigation_menu_tags` site setting has not been set" do
+ it "hides the tags section when there are no top or configured tags" do
Tag.delete_all
visit("/latest")
@@ -48,7 +48,7 @@ describe "Viewing sidebar as anonymous user" do
expect(sidebar).to have_no_tags_section
end
- it "should display the site's top tags when `default_navigation_menu_tags` site setting has not been set" do
+ it "shows the site's top tags when no navigation tags are configured" do
visit("/latest")
expect(sidebar).to have_tags_section
@@ -56,7 +56,7 @@ describe "Viewing sidebar as anonymous user" do
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag5, tag1])
end
- it "should display the site's top tags when `default_navigation_menu_tags` site setting has been set but the tags configured are hidden to the user" do
+ it "shows the site's top tags when configured navigation tags are hidden" do
SiteSetting.default_navigation_menu_tags = "#{tag5.name}"
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [tag5.name])
@@ -67,7 +67,7 @@ describe "Viewing sidebar as anonymous user" do
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag1, tag6])
end
- it "should display the tags configured in `default_navigation_menu_tags` site setting when it has been set" do
+ it "shows the configured navigation tags" do
SiteSetting.default_navigation_menu_tags = "#{tag3.name}|#{tag4.name}"
visit("/latest")
diff --git a/spec/system/viewing_sidebar_spec.rb b/spec/system/viewing_sidebar_spec.rb
index ae291788f7f..faefd81b9eb 100644
--- a/spec/system/viewing_sidebar_spec.rb
+++ b/spec/system/viewing_sidebar_spec.rb
@@ -13,7 +13,7 @@ describe "Viewing sidebar" do
describe "when using the header dropdown navigation menu" do
before { SiteSetting.navigation_menu = "header dropdown" }
- it "should display the sidebar when `navigation_menu` query param is 'sidebar' and maintain header dropdown" do
+ it "shows the sidebar while preserving the header dropdown" do
visit("/latest?navigation_menu=sidebar")
expect(sidebar).to be_visible
@@ -24,7 +24,7 @@ describe "Viewing sidebar" do
describe "when using the sidebar navigation menu" do
before { SiteSetting.navigation_menu = "sidebar" }
- it "should display the sidebar dropdown menu when `navigation_menu` query param is 'header_dropdown'" do
+ it "shows the header dropdown selected by the query parameter" do
visit("/latest?navigation_menu=header_dropdown")
expect(sidebar).to be_not_visible
@@ -122,7 +122,7 @@ describe "Viewing sidebar" do
Fabricate(:tag, name: "tag 6").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
end
- it "should not display the tags section when tagging is disabled" do
+ it "hides the tags section when tagging is disabled" do
SiteSetting.tagging_enabled = false
visit("/latest")
@@ -131,7 +131,7 @@ describe "Viewing sidebar" do
expect(sidebar).to have_no_tags_section
end
- it "should not display the tags section when there are no tags that a user can see" do
+ it "hides the tags section when no tags are visible" do
Tag.delete_all
visit("/latest")
@@ -140,7 +140,7 @@ describe "Viewing sidebar" do
expect(sidebar).to have_no_tags_section
end
- it "should display the site's top tags in the tags section when user has not configured any tags" do
+ it "shows top tags when the user has not configured tags" do
visit("/latest")
expect(sidebar).to be_visible
@@ -149,7 +149,7 @@ describe "Viewing sidebar" do
expect(sidebar).to have_all_tags_section_link
end
- it "should display the tags configured by the user in alphabetical order" do
+ it "shows the user's tags in alphabetical order" do
Fabricate(:sidebar_section_link, linkable: tag3, user: user)
Fabricate(:sidebar_section_link, linkable: tag1, user: user)
Fabricate(:sidebar_section_link, linkable: tag2, user: user)
@@ -164,13 +164,13 @@ describe "Viewing sidebar" do
end
describe "when My messages sidebar link" do
- it "should show for user with `can_send_private_messages` permission" do
+ it "shows for a user who can send private messages" do
sign_in(admin)
visit("/")
expect(sidebar).to have_my_messages_link
end
- it "shouldn't show for user without `can_send_private_messages` permission" do
+ it "hides from a user who cannot send private messages" do
SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:admins]
sign_in(user)
visit("/")
@@ -199,20 +199,20 @@ describe "Viewing sidebar" do
end
let(:user_private_messages_page) { PageObjects::Pages::UserPrivateMessages.new }
- it "should show new messages indicator" do
+ it "shows the new-messages indicator" do
sign_in(admin)
visit("/")
expect(sidebar).to have_my_messages_link_with_unread_icon
end
- it "should show a count of the new items" do
+ it "shows the new-item count" do
admin.user_option.update!(sidebar_show_count_of_new_items: true)
sign_in(admin)
visit("/")
expect(sidebar).to have_my_messages_link_with_unread_count
end
- it "should remove unread icon after all messages are read" do
+ it "removes the unread icon after every message is read" do
sign_in(admin)
user_private_messages_page.visit(admin)
user_private_messages_page.click_unseen_private_message(private_message.id)
@@ -225,7 +225,7 @@ describe "Viewing sidebar" do
end
end
- it "shouldn't display the panel header for the main sidebar" do
+ it "hides the panel header in the main sidebar" do
visit("/latest")
expect(sidebar).to be_visible
expect(sidebar).to have_no_panel_header
@@ -234,7 +234,7 @@ describe "Viewing sidebar" do
context "as anonymous user" do
describe "My messages sidebar link" do
- it "shouldn't show for anonymous user" do
+ it "hides from anonymous users" do
visit("/")
expect(sidebar).to have_no_my_messages_link
end
diff --git a/spec/system/viewing_user_menu_spec.rb b/spec/system/viewing_user_menu_spec.rb
index b8d2e517cd3..96611817a2c 100644
--- a/spec/system/viewing_user_menu_spec.rb
+++ b/spec/system/viewing_user_menu_spec.rb
@@ -65,7 +65,7 @@ RSpec.describe "Viewing User Menu" do
describe "when viewing replies notifications tab" do
fab!(:topic)
- it "should display group mentioned notifications in the tab" do
+ it "shows group-mention notifications in the tab" do
Jobs.run_immediately!
mentionable_group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone])
@@ -90,7 +90,7 @@ RSpec.describe "Viewing User Menu" do
context "with SiteSetting.prioritize_full_name_in_ux=true" do
before { SiteSetting.prioritize_full_name_in_ux = true }
- it "should display user full name in mention notifications" do
+ it "shows the user's full name in mention notifications" do
Jobs.run_immediately!
user = Fabricate(:user)
@@ -110,7 +110,7 @@ RSpec.describe "Viewing User Menu" do
expect(user_menu).to have_user_full_name_mentioned_notification(topic, user)
end
- it "should display user full name in message notification" do
+ it "shows the user's full name in message notifications" do
Jobs.run_immediately!
user = Fabricate(:moderator)
@@ -132,7 +132,7 @@ RSpec.describe "Viewing User Menu" do
expect(user_menu).to have_user_full_name_messaged_notification(post, user)
end
- it "should display user full name in bookmark notification" do
+ it "shows the user's full name in bookmark notifications" do
Jobs.run_immediately!
user = Fabricate(:moderator)
@@ -158,7 +158,7 @@ RSpec.describe "Viewing User Menu" do
context "with SiteSetting.prioritize_full_name_in_ux=false" do
before { SiteSetting.prioritize_full_name_in_ux = false }
- it "should display only username in mention notifications" do
+ it "shows only the username in mention notifications" do
Jobs.run_immediately!
SiteSetting.prioritize_username_in_ux = true
diff --git a/spec/system/welcome_banner_spec.rb b/spec/system/welcome_banner_spec.rb
index bd67fae4fd4..b0cc0f15f1e 100644
--- a/spec/system/welcome_banner_spec.rb
+++ b/spec/system/welcome_banner_spec.rb
@@ -221,7 +221,7 @@ describe "Welcome banner" do
before { SiteSetting.welcome_banner_page_visibility = "all_pages" }
- it "should show on" do
+ it "shows on the homepage, preferences, and messages pages" do
sign_in(current_user)
visit "/"
@@ -234,7 +234,7 @@ describe "Welcome banner" do
expect(banner).to be_visible
end
- it "should NOT show on" do
+ it "hides on authentication and admin pages" do
visit "/login"
expect(banner).to be_hidden
@@ -262,7 +262,7 @@ describe "Welcome banner" do
end
end
- it "should show on discovery routes only" do
+ it "shows only on discovery routes" do
sign_in(current_user)
SiteSetting.welcome_banner_page_visibility = "discovery"
@@ -273,7 +273,7 @@ describe "Welcome banner" do
expect(banner).to be_hidden
end
- it "should show on top menu pages only" do
+ it "shows only on top menu pages" do
sign_in(current_user)
SiteSetting.welcome_banner_page_visibility = "top_menu_pages"
SiteSetting
@@ -288,7 +288,7 @@ describe "Welcome banner" do
expect(banner).to be_hidden
end
- it "should show on homepage only" do
+ it "shows only on the homepage" do
SiteSetting.welcome_banner_page_visibility = "homepage"
visit "/"
diff --git a/spec/tasks/posts_spec.rb b/spec/tasks/posts_spec.rb
index d5bd2745a1a..eb643416aab 100644
--- a/spec/tasks/posts_spec.rb
+++ b/spec/tasks/posts_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe "Post rake tasks" do
before { STDOUT.stubs(:write) }
describe "remap" do
- it "should remap posts" do
+ it "remaps posts" do
HighLine::Simulate.with("y") { invoke_rake_task("posts:remap", "brown", "red") }
post.reload
@@ -54,7 +54,7 @@ RSpec.describe "Post rake tasks" do
end
let(:upload) { Fabricate(:upload, url: url) }
- it "should create post custom field for missing upload" do
+ it "creates a post custom field for a missing upload" do
post = Fabricate(:post, raw: "A sample post <img src='#{url}'>")
upload.destroy!
@@ -64,7 +64,7 @@ RSpec.describe "Post rake tasks" do
expect(post.custom_fields[Post::MISSING_UPLOADS]).to eq([url])
end
- it 'should skip all the posts with "ignored" custom field' do
+ it 'skips posts with the "ignored" custom field' do
post = Fabricate(:post, raw: "A sample post <img src='#{url}'>")
post.custom_fields[Post::MISSING_UPLOADS_IGNORED] = true
post.save_custom_fields
diff --git a/spec/tasks/redis_spec.rb b/spec/tasks/redis_spec.rb
index 6db66509ecc..d9332a32a94 100644
--- a/spec/tasks/redis_spec.rb
+++ b/spec/tasks/redis_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "Redis rake tasks", type: :multisite do
let(:redis) { Discourse.redis.without_namespace }
describe "clean up" do
- it "should clean up orphan Redis keys" do
+ it "cleans up orphan Redis keys" do
active_keys = %w[
__mb_backlog_id_n_/users/someusername$|$default
default:user-last-seen:607
diff --git a/spec/tasks/themes_spec.rb b/spec/tasks/themes_spec.rb
index 281f6205e9e..3fe94de04f9 100644
--- a/spec/tasks/themes_spec.rb
+++ b/spec/tasks/themes_spec.rb
@@ -229,7 +229,7 @@ RSpec.describe "tasks/themes" do
after { `rm -fr #{initial_repo}` }
- it "should retain a theme's settings and not update the theme when a theme's setting fails to save" do
+ it "preserves the theme and its settings when a setting fails to save" do
theme.update_setting(:some_setting, "some setting value")
migration_content = <<~JS
@@ -280,7 +280,7 @@ RSpec.describe "tasks/themes" do
expect(theme.settings[:string_setting].value).to eq("default value")
end
- it "should not update the theme if a theme setting migration fails during the update" do
+ it "preserves the theme when a setting migration fails during the update" do
migration_content = <<~JS
export default function migrate(settings) {
throw "error";
diff --git a/spec/tasks/topics_spec.rb b/spec/tasks/topics_spec.rb
index a2273a231b9..4d570234fb6 100644
--- a/spec/tasks/topics_spec.rb
+++ b/spec/tasks/topics_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe "Post rake tasks" do
before { STDOUT.stubs(:write) }
describe "topics:apply_autoclose" do
- it "should close topics silently" do
+ it "closes topics silently" do
category.auto_close_hours = 1
category.save!
diff --git a/spec/tasks/users_spec.rb b/spec/tasks/users_spec.rb
index 7beec249323..868a8ffe24a 100644
--- a/spec/tasks/users_spec.rb
+++ b/spec/tasks/users_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "tasks/users" do
describe "users:disable_2fa" do
let(:user) { Fabricate(:user) }
- it "should remove all 2fa methods for user with given username" do
+ it "removes all second factor methods for the given username" do
Fabricate(:user_second_factor_totp, user: user, name: "TOTP", enabled: true)
Fabricate(:user_second_factor_totp, user: user, name: "TOTP2", enabled: true)
Fabricate(
diff --git a/themes/horizon/spec/system/horizon_high_level_spec.rb b/themes/horizon/spec/system/horizon_high_level_spec.rb
index a1cd9200d3d..f6f7eeb8339 100644
--- a/themes/horizon/spec/system/horizon_high_level_spec.rb
+++ b/themes/horizon/spec/system/horizon_high_level_spec.rb
@@ -79,7 +79,7 @@ describe "Horizon theme | High level" do
context "for signed in users" do
before { sign_in(current_user) }
- it "works" do
+ it "passes the high-level checks for a signed-in user" do
visit "/"
run_all_high_level_tests
end