Skip to content

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

DEV: Use proper wording for contexts in specs

Loïc Guitaut3eaac5679780
diff --git a/Gemfile.lock b/Gemfile.lock
index a6881fc67b2..4d73ec747fb 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/discourse/rubocop-discourse.git
- revision: 5afeae107d3c003bf5bcf75457501ee7c1248fd2
+ revision: 9642e65f3767e5fd1d4e1aec4b617179f4128909
specs:
rubocop-discourse (2.5.0)
rubocop (>= 1.1.0)
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 651a12ea89d..6d4425660e1 100644
--- a/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb
+++ b/plugins/discourse-local-dates/spec/integration/local_dates_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe "Local Dates" do
expect(cooked).to include("data-countdown=")
end
- context 'ranges' do
+ describe 'ranges' do
it 'generates ranges without time' do
raw = "[date-range from=2022-01-06 to=2022-01-08]"
cooked = Fabricate(:post, raw: raw).cooked
diff --git a/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb b/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
index 326c9dabb3e..0f4af09ae6c 100644
--- a/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
+++ b/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe PrettyText do
freeze_time
end
- context 'emails simplified rendering' do
+ describe 'emails simplified rendering' do
it 'works with default markup' do
cooked = PrettyText.cook("[date=2018-05-08]")
cooked_mail = generate_html("2018-05-08T00:00:00Z UTC",
@@ -70,7 +70,7 @@ RSpec.describe PrettyText do
end
end
- context 'excerpt simplified rendering' do
+ describe 'excerpt simplified rendering' do
let(:post) { Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone="America/New_York"]') }
it 'adds UTC' do
@@ -79,7 +79,7 @@ RSpec.describe PrettyText do
end
end
- context 'special quotes' do
+ describe 'special quotes' do
it 'converts special quotes to regular quotes' do
# german
post = Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone=„America/New_York“]')
@@ -97,7 +97,7 @@ RSpec.describe PrettyText do
end
end
- context 'french quotes' do
+ describe 'french quotes' do
let(:post) { Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone=«America/New_York»]') }
it 'converts french quotes to regular quotes' do
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 c04ef0008cf..cd89d1b5a94 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
@@ -133,12 +133,11 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(Topic.last.title).to eq(I18n.t('discourse_narrative_bot.advanced_user_narrative.title'))
end
-
end
end
describe "#input" do
- context 'edit tutorial' do
+ context 'when editing tutorial' do
before do
narrative.set_data(user,
state: :tutorial_edit,
@@ -150,7 +149,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when post is not in the right topic' do
+ context 'when post is not in the right topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -160,7 +159,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the post' do
+ context 'when user replies to the post' do
it 'should create the right reply' do
post
narrative.expects(:enqueue_timeout_job).with(user).once
@@ -174,7 +173,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
))
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: "@#{discobot_username} #{skip_trigger.upcase}")
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -192,7 +191,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user edits the right post' 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
@@ -214,7 +213,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context 'delete tutorial' do
+ context 'when deleting tutorial' do
before do
narrative.set_data(user,
state: :tutorial_delete,
@@ -223,7 +222,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.expects(:enqueue_timeout_job).with(user).once
@@ -237,7 +236,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_delete)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: skip_trigger.upcase)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -255,7 +254,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user destroys a post in a different topic' do
+ context 'when user destroys a post in a different topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -266,7 +265,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user deletes a post in the right topic' do
+ context 'when user deletes a post in the right topic' do
it 'should create the right reply' do
post
@@ -304,7 +303,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context 'undelete post tutorial' do
+ context 'when undeleting post tutorial' do
before do
narrative.set_data(user,
state: :tutorial_recover,
@@ -313,7 +312,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when posts are configured to be deleted immediately' do
+ context 'when posts are configured to be deleted immediately' do
before do
SiteSetting.delete_removed_posts_after = 0
end
@@ -337,7 +336,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.set_data(user, narrative.get_data(user).merge(
tutorial_recover: { post_id: '1' }
@@ -355,7 +354,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_recover)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
parent_category = Fabricate(:category, name: 'a')
_category = Fabricate(:category, parent_category: parent_category, name: 'b')
@@ -377,7 +376,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user recovers a post in a different topic' do
+ context 'when user recovers a post in a different topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -389,7 +388,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user recovers a post in the right topic' do
+ context 'when user recovers a post in the right topic' do
it 'should create the right reply' do
parent_category = Fabricate(:category, name: 'a')
_category = Fabricate(:category, parent_category: parent_category, name: 'b')
@@ -412,7 +411,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context 'category hashtag tutorial' do
+ context 'with category hashtag tutorial' do
before do
narrative.set_data(user,
state: :tutorial_category_hashtag,
@@ -421,7 +420,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when post is not in the right topic' do
+ context 'when post is not in the right topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -434,7 +433,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -446,7 +445,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_category_hashtag)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -481,7 +480,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context 'topic notification level tutorial' do
+ context 'with topic notification level tutorial' do
before do
narrative.set_data(user,
state: :tutorial_change_topic_notification_level,
@@ -490,7 +489,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when notification level is changed for another topic' do
+ context 'when notification level is changed for another topic' do
it 'should not do anything' do
other_topic
user
@@ -508,7 +507,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -520,7 +519,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_change_topic_notification_level)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -538,7 +537,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user changed the topic notification level' do
+ context 'when user changed the topic notification level' do
it 'should create the right reply' do
TopicUser.change(
user.id,
@@ -557,7 +556,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user cannot create polls' do
+ context 'when user cannot create polls' do
it 'should create the right reply (polls disabled)' do
SiteSetting.poll_enabled = false
@@ -598,7 +597,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context 'poll tutorial' do
+ context 'with poll tutorial' do
before do
narrative.set_data(user,
state: :tutorial_poll,
@@ -620,7 +619,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(post.errors[:base].size).to eq(0)
end
- describe 'when post is not in the right topic' do
+ context 'when post is not in the right topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -630,7 +629,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.input(:reply, user, post: post)
new_post = Post.last
@@ -639,7 +638,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_poll)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: skip_trigger)
described_class.any_instance.expects(:enqueue_timeout_job).with(user)
@@ -672,7 +671,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- context "details tutorial" do
+ context "with details tutorial" do
before do
narrative.set_data(user,
state: :tutorial_details,
@@ -681,7 +680,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
)
end
- describe 'when post is not in the right topic' do
+ context 'when post is not in the right topic' do
it 'should not do anything' do
other_post
narrative.expects(:enqueue_timeout_job).with(user).never
@@ -691,7 +690,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
end
end
- describe 'when user replies to the topic' do
+ context 'when user replies to the topic' do
it 'should create the right reply' do
narrative.input(:reply, user, post: post)
@@ -699,7 +698,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_details)
end
- describe 'when reply contains the skip trigger' do
+ context 'when reply contains the skip trigger' do
it 'should create the right reply' do
post.update!(raw: skip_trigger)
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 f1b68d154d0..543192f6cfc 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
@@ -49,7 +49,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
describe '#select' do
- context 'in a PM with discobot' do
+ context 'when in a PM with discobot' do
let(:first_post) { Fabricate(:post, user: discobot_user) }
let(:topic) do
@@ -63,7 +63,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:post) { Fabricate(:post, topic: topic, user: user) }
- context 'during a tutorial track' do
+ context 'while in a tutorial track' do
before do
narrative.set_data(user,
state: :tutorial_formatting,
@@ -146,7 +146,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when user thank the bot' do
+ context 'when user thank the bot' do
it 'should like the post' do
post.update!(raw: 'thanks!')
@@ -176,7 +176,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
.to eq("tutorial_bookmark")
end
- describe 'reset trigger in surrounded by quotes' do
+ context 'when reset trigger in surrounded by quotes' do
it 'should reset the track' do
post.update!(
raw: "'#{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger}'"
@@ -189,8 +189,8 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'reset trigger in a middle of a sentence' do
- describe 'when post is less than reset trigger exact match limit' 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
post.update!(
raw: "I would like to #{described_class.reset_trigger} #{DiscourseNarrativeBot::NewUserNarrative.reset_trigger} now"
@@ -203,7 +203,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when post exceeds reset trigger exact match limit' do
+ context 'when post exceeds reset trigger exact match limit' do
it 'should 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}"
@@ -233,7 +233,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- context 'at the end of a tutorial track' do
+ context 'when at the end of a tutorial track' do
before do
narrative.set_data(user,
state: :end,
@@ -242,7 +242,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
)
end
- context 'generic replies' do
+ context 'with generic replies' do
after do
Discourse.redis.del("#{described_class::GENERIC_REPLIES_COUNT_PREFIX}#{user.id}")
end
@@ -290,7 +290,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
expect(new_post.raw).to eq(random_mention_reply)
end
- describe 'when asking discobot for help' do
+ context 'when asking discobot for help' do
it 'should create the right reply' do
post.update!(raw: 'show me what you can do @discobot display help')
described_class.new(:reply, user, post_id: post.id).select
@@ -298,7 +298,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
expect(Post.last.raw).to include(help_message)
end
- describe 'as an admin or moderator' do
+ context 'as an admin or moderator' do
it 'should include the commands to start the advanced user track' do
user.update!(moderator: true)
post.update!(raw: 'Show me what you can do @discobot display help')
@@ -311,7 +311,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'as a user that has completed the new user track' do
+ context 'as a user that has completed the new user track' do
it 'should include the commands to start the advanced user track' do
narrative.set_data(user,
state: :end,
@@ -335,7 +335,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when discobot is asked to roll dice' do
+ context 'when discobot is asked to roll dice' do
before do
narrative.set_data(user,
state: :end,
@@ -353,7 +353,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
))
end
- describe 'when range of dice request is too high' do
+ context 'when range of dice request is too high' do
before do
srand(1)
end
@@ -376,7 +376,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when number of dice to roll is too high' do
+ context 'when number of dice to roll is too high' do
it 'should create the right reply' do
post.update!(raw: "roll #{DiscourseNarrativeBot::Dice::MAXIMUM_NUM_OF_DICE + 1}d1")
described_class.new(:reply, user, post_id: post.id).select
@@ -392,7 +392,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when dice combination is invalid' do
+ context 'when dice combination is invalid' do
it 'should create the right reply' do
post.update!(raw: "roll 0d1")
described_class.new(:reply, user, post_id: post.id).select
@@ -407,7 +407,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
context 'when in a normal PM with discobot' do
- describe 'when discobot is replied to' do
+ context 'when discobot is replied to' do
it 'should create the right reply' do
SiteSetting.discourse_narrative_bot_disable_public_replies = true
post.update!(raw: 'Show me what you can do @discobot')
@@ -439,16 +439,16 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- context 'random discobot mentions' do
+ context 'with random discobot mentions' do
let(:topic) { Fabricate(:topic) }
let(:post) { Fabricate(:post, topic: topic, user: user) }
- describe 'when discobot public replies are disabled' do
+ context 'when discobot public replies are disabled' do
before do
SiteSetting.discourse_narrative_bot_disable_public_replies = true
end
- describe 'when discobot is mentioned' do
+ context 'when discobot is mentioned' do
it 'should not reply' do
post.update!(raw: 'Show me what you can do @discobot')
@@ -459,7 +459,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when discobot is mentioned' do
+ context 'when discobot is mentioned' do
it 'should create the right reply' do
post.update!(raw: 'Show me what you can do @discobot')
described_class.new(:reply, user, post_id: post.id).select
@@ -496,7 +496,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
expect(new_post.raw).to eq(random_mention_reply)
end
- describe 'rate limiting random reply message in public topic' do
+ context 'with rate limiting random reply message in public topic' do
let(:topic) { Fabricate(:topic) }
let(:other_post) { Fabricate(:post, raw: '@discobot show me something', topic: topic) }
let(:post) { Fabricate(:post, topic: topic) }
@@ -505,7 +505,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
Discourse.redis.flushdb
end
- describe 'when random reply massage has been displayed in the last 6 hours' do
+ context 'when random reply massage has been displayed in the last 6 hours' do
it 'should not do anything' do
Discourse.redis.set(
"#{described_class::PUBLIC_DISPLAY_BOT_HELP_KEY}:#{other_post.topic_id}",
@@ -522,7 +522,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when random reply message has not been displayed in the last 6 hours' do
+ context 'when random reply message has not been displayed in the last 6 hours' do
it 'should create the right reply' do
Discourse.redis.set(
"#{described_class::PUBLIC_DISPLAY_BOT_HELP_KEY}:#{other_post.topic_id}",
@@ -540,7 +540,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when random reply message has been displayed in the last 10 replies' do
+ context 'when random reply message has been displayed in the last 10 replies' do
it 'should not do anything' do
described_class.new(:reply, user, post_id: other_post.id).select
expect(Post.last.raw).to eq(random_mention_reply)
@@ -559,7 +559,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when asking discobot for help' do
+ context 'when asking discobot for help' do
it 'should create the right reply' do
post.update!(raw: '@discobot display help')
described_class.new(:reply, user, post_id: post.id).select
@@ -568,8 +568,8 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when asking discobot to start new user track' do
- describe 'invalid text' do
+ context 'when asking discobot to start new user track' do
+ context 'with invalid text' do
it 'should not trigger the bot' do
post.update!(raw: "`@discobot #{I18n.t('discourse_narrative_bot.track_selector.reset_trigger')} #{I18n.t(DiscourseNarrativeBot::NewUserNarrative.reset_trigger)}`")
@@ -579,7 +579,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when discobot is asked to roll dice' do
+ context 'when discobot is asked to roll dice' do
it 'should create the right reply' do
post.update!(raw: '@discobot roll 2d1')
described_class.new(:reply, user, post_id: post.id).select
@@ -591,7 +591,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
))
end
- describe 'when dice roll is requested incorrectly' do
+ context 'when dice roll is requested incorrectly' do
it 'should create the right reply' do
post.update!(raw: 'roll 2d1 @discobot')
described_class.new(:reply, user, post_id: post.id).select
@@ -600,7 +600,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when roll dice command is present inside a quote' do
+ context 'when roll dice command is present inside a quote' do
it 'should ignore the command' do
user
post.update!(raw: "[quote=\"Donkey, post:6, topic:1\"]\n@discobot roll 2d1\n[/quote]")
@@ -611,7 +611,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when a quote is requested' do
+ context 'when a quote is requested' do
it 'should create the right reply' do
post.update!(raw: "@discobot quote")
@@ -624,7 +624,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
))
end
- describe 'when quote is requested incorrectly' do
+ context 'when quote is requested incorrectly' do
it 'should create the right reply' do
post.update!(raw: 'quote @discobot')
described_class.new(:reply, user, post_id: post.id).select
@@ -633,7 +633,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when quote command is present inside a onebox or quote' do
+ context 'when quote command is present inside a onebox or quote' do
it 'should ignore the command' do
user
post.update!(raw: "[quote=\"Donkey, post:6, topic:1\"]\n@discobot quote\n[/quote]")
@@ -643,7 +643,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when user requesting quote has a preferred locale' do
+ context 'when user requesting quote has a preferred locale' do
before do
SiteSetting.allow_user_locale = true
user.update!(locale: 'it')
@@ -662,7 +662,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when magic 8 ball is requested' do
+ context 'when magic 8 ball is requested' do
before do
srand(1)
end
@@ -677,8 +677,8 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when bot is asked to reset/start a track' do
- describe 'when user likes a post containing a reset trigger' 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
another_post = Fabricate(:post,
user: Fabricate(:user),
@@ -694,7 +694,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe "when new and advanced user triggers overlap" do
+ context "when new and advanced user triggers overlap" do
before do
@overrides = []
@@ -723,7 +723,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- context 'pm to self' do
+ context 'when sending pm to self' do
let(:other_topic) do
topic_allowed_user = Fabricate.build(:topic_allowed_user, user: user)
Fabricate(:private_message_topic, topic_allowed_users: [topic_allowed_user])
@@ -731,7 +731,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:other_post) { Fabricate(:post, topic: other_topic) }
- describe 'when a new message is made' do
+ context 'when a new message is made' do
it 'should not do anything' do
other_post
@@ -741,7 +741,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- context 'pms to bot' do
+ context 'when sending pms to bot' do
let(:other_topic) do
topic_allowed_user = Fabricate.build(:topic_allowed_user, user: user)
bot = Fabricate.build(:topic_allowed_user, user: discobot_user)
@@ -750,7 +750,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
let(:other_post) { Fabricate(:post, topic: other_topic) }
- describe 'when a new like is made' do
+ context 'when a new like is made' do
it 'should not do anything' do
other_post
expect { described_class.new(:like, user, post_id: other_post.id).select }
@@ -758,7 +758,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when a new message is made' do
+ context 'when a new message is made' do
it 'should create the right reply' do
described_class.new(:reply, user, post_id: other_post.id).select
@@ -766,7 +766,7 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
end
end
- describe 'when user thanks the bot' do
+ context 'when user thanks the bot' do
it 'should like the post' do
other_post.update!(raw: 'thanks!')
diff --git a/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb b/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb
index 6b0326b7f59..61d9455b0b0 100644
--- a/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
end
end
- context 'subfolder' do
+ context 'with subfolder' do
let!(:post) do
Fabricate(:post,
user: ::DiscourseNarrativeBot::Base.new.discobot_user,
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 6fa4be2b9d4..e57c9ed4574 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
@@ -14,7 +14,7 @@ RSpec.describe "Discobot welcome post" do
end
end
- context 'When discourse_narrative_bot_welcome_post_delay is greater than 0' do
+ context 'when discourse_narrative_bot_welcome_post_delay is greater than 0' do
before do
SiteSetting.discourse_narrative_bot_welcome_post_delay = 5
end
diff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rb
index 7b3d51b6f05..d7036373f6b 100644
--- a/plugins/discourse-narrative-bot/spec/user_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/user_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe User do
end
describe 'welcome post' do
- context 'disabled' do
+ context 'when disabled' do
before do
SiteSetting.disable_discourse_narrative_bot_welcome_post = true
end
@@ -57,7 +57,7 @@ RSpec.describe User do
end
end
- context 'enabled' do
+ context 'when enabled' do
before do
SiteSetting.disable_discourse_narrative_bot_welcome_post = false
end
diff --git a/plugins/poll/spec/integration/poll_endpoints_spec.rb b/plugins/poll/spec/integration/poll_endpoints_spec.rb
index 0fd37236466..9fff1972a88 100644
--- a/plugins/poll/spec/integration/poll_endpoints_spec.rb
+++ b/plugins/poll/spec/integration/poll_endpoints_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe "DiscoursePoll endpoints" do
end
end
- context "number poll" do
+ context "with number poll" do
let(:post) { Fabricate(:post, raw: "[poll type=number min=1 max=20 step=1 public=true]\n[/poll]") }
it 'should return the right response' do
diff --git a/plugins/poll/spec/requests/users_controller_spec.rb b/plugins/poll/spec/requests/users_controller_spec.rb
index 87b354ea488..78e387de6eb 100644
--- a/plugins/poll/spec/requests/users_controller_spec.rb
+++ b/plugins/poll/spec/requests/users_controller_spec.rb
@@ -3,7 +3,6 @@
require "rails_helper"
RSpec.describe Admin::UsersController do
-
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
@@ -11,7 +10,7 @@ RSpec.describe Admin::UsersController do
describe '#destroy' do
let(:delete_me) { Fabricate(:user) }
- context "user has voted" do
+ context "when user has voted" do
let!(:topic) { Fabricate(:topic, user: admin) }
let!(:post) { Fabricate(:post, topic: topic, user: admin, raw: "[poll]\n- a\n- b\n[/poll]") }
@@ -26,5 +25,4 @@ RSpec.describe Admin::UsersController do
end
end
end
-
end
diff --git a/plugins/poll/spec/serializers/poll_option_serializer_spec.rb b/plugins/poll/spec/serializers/poll_option_serializer_spec.rb
index 1a31df98381..ad46e779619 100644
--- a/plugins/poll/spec/serializers/poll_option_serializer_spec.rb
+++ b/plugins/poll/spec/serializers/poll_option_serializer_spec.rb
@@ -16,10 +16,10 @@ RSpec.describe PollOptionSerializer do
poll.poll_votes.create!(poll_option_id: poll.poll_options.first.id, user_id: voter.id)
end
- context 'poll results are public' do
+ context 'when poll results are public' do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }
- context 'user is not staff' do
+ context 'when user is not staff' do
let(:user) { Fabricate(:user) }
it 'include votes' do
@@ -30,10 +30,10 @@ RSpec.describe PollOptionSerializer do
end
end
- context 'poll results are staff only' do
+ context 'when poll results are staff only' do
let(:post) { Fabricate(:post, raw: "[poll results=staff_only]\n- A\n- B\n[/poll]") }
- context 'user is not staff' do
+ context 'when user is not staff' do
let(:user) { Fabricate(:user) }
it 'doesn’t include votes' do
@@ -43,7 +43,7 @@ RSpec.describe PollOptionSerializer do
end
end
- context 'user staff' do
+ context 'when user is staff' do
let(:admin) { Fabricate(:admin) }
it 'includes votes' do
diff --git a/plugins/styleguide/spec/integration/access_spec.rb b/plugins/styleguide/spec/integration/access_spec.rb
index cf5081f299d..568d35eafa3 100644
--- a/plugins/styleguide/spec/integration/access_spec.rb
+++ b/plugins/styleguide/spec/integration/access_spec.rb
@@ -5,12 +5,12 @@ RSpec.describe 'SiteSetting.styleguide_admin_only' do
SiteSetting.styleguide_enabled = true
end
- context 'styleguide is admin only' do
+ context 'when styleguide is admin only' do
before do
SiteSetting.styleguide_admin_only = true
end
- context 'user is admin' do
+ context 'when user is admin' do
before do
sign_in(Fabricate(:admin))
end
@@ -21,7 +21,7 @@ RSpec.describe 'SiteSetting.styleguide_admin_only' do
end
end
- context 'user is not admin' do
+ context 'when user is not admin' do
before do
sign_in(Fabricate(:user))
end
@@ -39,7 +39,7 @@ RSpec.describe 'SiteSetting.styleguide_enabled' do
sign_in(Fabricate(:admin))
end
- context 'style is enabled' do
+ context 'when style is enabled' do
before do
SiteSetting.styleguide_enabled = true
end
@@ -50,7 +50,7 @@ RSpec.describe 'SiteSetting.styleguide_enabled' do
end
end
- context 'styleguide is disabled' do
+ context 'when styleguide is disabled' do
before do
SiteSetting.styleguide_enabled = false
end
diff --git a/plugins/styleguide/spec/integration/assets_spec.rb b/plugins/styleguide/spec/integration/assets_spec.rb
index ad555711a60..e4d6f2cfa0f 100644
--- a/plugins/styleguide/spec/integration/assets_spec.rb
+++ b/plugins/styleguide/spec/integration/assets_spec.rb
@@ -6,14 +6,14 @@ RSpec.describe 'Styleguide assets' do
sign_in(Fabricate(:admin))
end
- context 'visits homepage' do
+ context 'when visiting homepage' do
it 'doesn’t load styleguide assets' do
get '/'
expect(response.body).to_not include('styleguide')
end
end
- context 'visits styleguide' do
+ context 'when visiting styleguide' do
it 'loads styleguide assets' do
get '/styleguide'
expect(response.body).to include('styleguide')
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 1dac777d6ec..f4c25c979a2 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -2,7 +2,6 @@
# frozen_string_literal: true
RSpec.describe ApplicationHelper do
-
describe "preload_script" do
def preload_link(url)
<<~HTML
@@ -111,37 +110,45 @@ RSpec.describe ApplicationHelper do
)
helper.request.env[:resolved_theme_id] = dark_theme.id
end
- context "on desktop" do
+
+ context "when on desktop" do
before do
session[:mobile_view] = '0'
end
+
context "when logo_dark is not set" do
it "will return site_logo_url instead" do
expect(helper.application_logo_url).to eq(SiteSetting.site_logo_url)
end
end
+
context "when logo_dark is set" do
before do
SiteSetting.logo_dark = Fabricate(:upload, url: '/images/logo-dark.png')
end
+
it "will return site_logo_dark_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_logo_dark_url)
end
end
end
- context "on mobile" do
+
+ context "when on mobile" do
before do
session[:mobile_view] = '1'
end
+
context "when mobile_logo_dark is not set" do
it "will return site_mobile_logo_url instead" do
expect(helper.application_logo_url).to eq(SiteSetting.site_mobile_logo_url)
end
end
+
context "when mobile_logo_dark is set" do
before do
SiteSetting.mobile_logo_dark = Fabricate(:upload, url: '/images/mobile-logo-dark.png')
end
+
it "will return site_mobile_logo_dark_url" do
expect(helper.application_logo_url).to eq(SiteSetting.site_mobile_logo_dark_url)
end
@@ -203,8 +210,8 @@ RSpec.describe ApplicationHelper do
end
end
- describe "mobile_view?" do
- context "enable_mobile_theme is true" do
+ describe "#mobile_view?" do
+ context "when enable_mobile_theme is true" do
before do
SiteSetting.enable_mobile_theme = true
end
@@ -219,7 +226,7 @@ RSpec.describe ApplicationHelper do
expect(helper.mobile_view?).to eq(false)
end
- context "mobile_view session is cleared" do
+ context "when mobile_view session is cleared" do
before do
params[:mobile_view] = 'auto'
end
@@ -237,7 +244,7 @@ RSpec.describe ApplicationHelper do
end
end
- context "mobile_view is not set" do
+ context "when mobile_view is not set" do
it "is false if user agent is not mobile" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36')
expect(helper.mobile_view?).to be_falsey
@@ -275,7 +282,7 @@ RSpec.describe ApplicationHelper do
end
end
- context "enable_mobile_theme is false" do
+ context "when enable_mobile_theme is false" do
before do
SiteSetting.enable_mobile_theme = false
end
@@ -290,7 +297,7 @@ RSpec.describe ApplicationHelper do
expect(helper.mobile_view?).to eq(false)
end
- context "mobile_view is not set" do
+ context "when mobile_view is not set" do
it "is false if user agent is not mobile" do
controller.request.stubs(:user_agent).returns('Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36')
expect(helper.mobile_view?).to eq(false)
@@ -418,7 +425,6 @@ RSpec.describe ApplicationHelper do
end
describe 'crawlable_meta_data' do
-
it 'Supports ASCII URLs with odd chars' do
result = helper.crawlable_meta_data(
url: (+"http://localhost/ión").force_encoding("ASCII-8BIT").freeze
@@ -427,7 +433,7 @@ RSpec.describe ApplicationHelper do
expect(result).to include("ión")
end
- context "opengraph image" do
+ context "with opengraph image" do
it 'returns the correct image' do
SiteSetting.opengraph_image = Fabricate(:upload,
url: '/images/og-image.png'
@@ -544,7 +550,7 @@ RSpec.describe ApplicationHelper do
expect(cs_stylesheets).not_to include("(prefers-color-scheme: dark)")
end
- context "custom light scheme" do
+ context "with custom light scheme" do
before do
@new_cs = Fabricate(:color_scheme, name: 'Flamboyant')
user.user_option.color_scheme_id = @new_cs.id
@@ -576,7 +582,7 @@ RSpec.describe ApplicationHelper do
end
end
- context "dark scheme with user option and/or cookies" do
+ context "with dark scheme with user option and/or cookies" do
before do
user.user_option.dark_scheme_id = -1
user.user_option.save!
@@ -615,7 +621,6 @@ RSpec.describe ApplicationHelper do
color_stylesheets = helper.discourse_color_scheme_stylesheets
expect(color_stylesheets).not_to include("(prefers-color-scheme: dark)")
end
-
end
end
diff --git a/spec/import_export/importer_spec.rb b/spec/import_export/importer_spec.rb
index ad75f2ade70..b9f6581aadc 100644
--- a/spec/import_export/importer_spec.rb
+++ b/spec/import_export/importer_spec.rb
@@ -3,7 +3,6 @@
require "import_export"
RSpec.describe ImportExport::Importer do
-
before do
STDOUT.stubs(:write)
end
@@ -18,7 +17,6 @@ RSpec.describe ImportExport::Importer do
end
describe '.perform' do
-
it 'topics and users' do
data = import_data.dup
data[:categories] = nil
@@ -32,7 +30,7 @@ RSpec.describe ImportExport::Importer do
.and change { User.count }.by(2)
end
- context 'categories and groups' do
+ context 'with categories and groups' do
it 'works' do
data = import_data.dup
data[:topics] = nil
@@ -105,7 +103,5 @@ RSpec.describe ImportExport::Importer do
.and change { Topic.count }.by(8)
.and change { User.count }.by(2)
end
-
end
-
end
diff --git a/spec/integration/auto_reject_reviewable_users_spec.rb b/spec/integration/auto_reject_reviewable_users_spec.rb
index f51d41705c7..f993f097c21 100644
--- a/spec/integration/auto_reject_reviewable_users_spec.rb
+++ b/spec/integration/auto_reject_reviewable_users_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "auto reject reviewable users" do
- context "reviewable users" do
+ describe "reviewable users" do
fab!(:old_user) { Fabricate(:reviewable, created_at: 80.days.ago) }
it "does not send email to rejected user" do
diff --git a/spec/integration/category_tag_spec.rb b/spec/integration/category_tag_spec.rb
index 4650f02cd3a..59bee8e8975 100644
--- a/spec/integration/category_tag_spec.rb
+++ b/spec/integration/category_tag_spec.rb
@@ -2,7 +2,6 @@
# frozen_string_literal: true
RSpec.describe "category tag restrictions" do
-
def filter_allowed_tags(opts = {})
DiscourseTagging.filter_allowed_tags(Guardian.new(user), opts)
end
@@ -22,7 +21,7 @@ RSpec.describe "category tag restrictions" do
SiteSetting.min_trust_level_to_tag_topics = 0
end
- context "tags restricted to one category" do
+ context "with tags restricted to one category" do
fab!(:category_with_tags) { Fabricate(:category) }
fab!(:other_category) { Fabricate(:category) }
@@ -94,7 +93,7 @@ RSpec.describe "category tag restrictions" do
expect { other_category.update(allowed_tags: [tag1.name, 'tag-stuff', tag2.name, 'another-tag']) }.to change { Tag.count }.by(2)
end
- context 'required tags from tag group' do
+ context 'with required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag3]) }
before { category_with_tags.update!(category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -105,7 +104,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context 'category allows other tags to be used' do
+ context 'when category allows other tags to be used' do
before do
category_with_tags.update!(allow_global_tags: true)
end
@@ -128,7 +127,7 @@ RSpec.describe "category tag restrictions" do
expect_same_tag_names(filter_allowed_tags(for_input: true, category: other_category, selected_tags: [tag3.name], term: 'tag'), [tag4])
end
- context 'required tags from tag group' do
+ context 'with required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag3]) }
before { category_with_tags.update!(category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -141,7 +140,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context "tag groups restricted to a category" do
+ context "with tag groups restricted to a category" do
fab!(:tag_group1) { Fabricate(:tag_group) }
fab!(:category) { Fabricate(:category) }
fab!(:other_category) { Fabricate(:category) }
@@ -188,7 +187,7 @@ RSpec.describe "category tag restrictions" do
expect_same_tag_names(filter_allowed_tags(for_input: true, term: 'with:c'), [tag_with_colon])
end
- context 'required tags from tag group' do
+ context 'with required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag3]) }
before { category.update!(category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -199,7 +198,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context 'category allows other tags to be used' do
+ context 'when category allows other tags to be used' do
before do
category.update!(allow_global_tags: true)
end
@@ -222,7 +221,7 @@ RSpec.describe "category tag restrictions" do
expect_same_tag_names(filter_allowed_tags(for_input: true, category: other_category), [tag1])
end
- context 'required tags from tag group' do
+ context 'with required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag3]) }
before { category.update!(category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -233,7 +232,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context 'another category has restricted tags using groups' do
+ context 'when another category has restricted tags using groups' do
fab!(:category2) { Fabricate(:category) }
fab!(:tag_group2) { Fabricate(:tag_group) }
@@ -260,7 +259,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context 'another category has restricted tags' do
+ context 'when another category has restricted tags' do
fab!(:category2) { Fabricate(:category) }
it "doesn't filter tags that are also restricted in another category" do
@@ -274,7 +273,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context "tag groups with parent tag" do
+ context "with tag groups with parent tag" do
it "for input field, filter_allowed_tags returns results based on whether parent tag is present or not" do
tag_group = Fabricate(:tag_group, parent_tag_id: tag1.id)
tag_group.tags = [tag3, tag4]
@@ -318,7 +317,7 @@ RSpec.describe "category tag restrictions" do
expect_same_tag_names(filter_allowed_tags(for_input: true, selected_tags: [tag3.name]), [tag4, common])
end
- context 'required tags from tag group' do
+ context 'with required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag2]) }
fab!(:category) { Fabricate(:category, category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -331,7 +330,7 @@ RSpec.describe "category tag restrictions" do
end
end
- context "and category restrictions" do
+ context "with category restrictions" do
fab!(:car_category) { Fabricate(:category) }
fab!(:other_category) { Fabricate(:category) }
fab!(:makes) { Fabricate(:tag_group, name: "Makes") }
@@ -395,7 +394,7 @@ RSpec.describe "category tag restrictions" do
expect(post.topic.tags.map(&:name).sort).to eq(['ford', 'mustang'])
end
- context "limit one tag from each group" do
+ context "with limit one tag from each group" do
before do
makes.update(one_per_topic: true)
honda_group.update(one_per_topic: true)
@@ -460,7 +459,7 @@ RSpec.describe "tag topic counts per category" do
expect(CategoryTagStat.where(category: category, tag: tag2).sum(:topic_count)).to eq(1)
end
- context "topic with 2 tags" do
+ context "with topic with 2 tags" do
fab!(:topic) { Fabricate(:topic, category: category, tags: [tag1, tag2]) }
fab!(:post) { Fabricate(:post, user: topic.user, topic: topic) }
@@ -492,7 +491,7 @@ RSpec.describe "tag topic counts per category" do
end
end
- context "topic with one tag" do
+ context "with topic with one tag" do
fab!(:topic) { Fabricate(:topic, tags: [tag1], category: category) }
fab!(:post) { Fabricate(:post, user: topic.user, topic: topic) }
diff --git a/spec/integration/email_outbound_spec.rb b/spec/integration/email_outbound_spec.rb
index eaeebbe3ea9..fea69ea7c41 100644
--- a/spec/integration/email_outbound_spec.rb
+++ b/spec/integration/email_outbound_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe "Outbound Email" do
[message, result]
end
- context "email custom headers" do
+ describe "email custom headers" do
it "discards the custom header if it is one that has already been set based on arguments" do
SiteSetting.email_custom_headers = "Precedence: bulk"
post = Fabricate(:post)
diff --git a/spec/integration/email_style_spec.rb b/spec/integration/email_style_spec.rb
index b23cbe35e56..a53cff48e22 100644
--- a/spec/integration/email_style_spec.rb
+++ b/spec/integration/email_style_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe EmailStyle do
-
- context "ERB evaluation" do
+ describe "ERB evaluation" do
it "does not evaluate ERB outside of the email itself" do
SiteSetting.email_custom_template = "<hello>%{email_content}</hello><%= (111 * 333) %>"
html = Email::Renderer.new(UserNotifications.signup(Fabricate(:user))).html
@@ -23,7 +22,7 @@ RSpec.describe EmailStyle do
SiteSetting.remove_override!(:email_custom_css)
end
- context 'invite' do
+ context 'with invite' do
fab!(:invite) { Fabricate(:invite) }
let(:invite_mail) { InviteMailer.send_invite(invite) }
@@ -48,7 +47,7 @@ RSpec.describe EmailStyle do
end
end
- context 'user_replied' do
+ context 'when user_replied' do
let(:response_by_user) { Fabricate(:user, name: "John Doe") }
let(:category) { Fabricate(:category, name: 'India') }
let(:topic) { Fabricate(:topic, category: category, title: "Super cool topic") }
@@ -80,7 +79,7 @@ RSpec.describe EmailStyle do
# TODO: translation override
end
- context 'signup' do
+ context 'with signup' do
let(:signup_mail) { UserNotifications.signup(Fabricate(:user)) }
subject(:mail_html) { Email::Renderer.new(signup_mail).html }
@@ -89,7 +88,7 @@ RSpec.describe EmailStyle do
expect(mail_html).to include('activate-account')
end
- context 'translation override' do
+ context 'with translation override' do
before do
TranslationOverride.upsert!(
SiteSetting.default_locale,
@@ -121,7 +120,7 @@ RSpec.describe EmailStyle do
end
end
- context 'digest' do
+ context 'with digest' do
fab!(:popular_topic) { Fabricate(:topic, user: Fabricate(:coding_horror), created_at: 1.hour.ago) }
let(:summary_email) { UserNotifications.digest(Fabricate(:user)) }
subject(:mail_html) { Email::Renderer.new(summary_email).html }
diff --git a/spec/integration/same_ip_spammers_spec.rb b/spec/integration/same_ip_spammers_spec.rb
index b7cde6e3f63..a586891cf44 100644
--- a/spec/integration/same_ip_spammers_spec.rb
+++ b/spec/integration/same_ip_spammers_spec.rb
@@ -2,13 +2,12 @@
# frozen_string_literal: true
RSpec.describe "spammers on same IP" do
-
let(:ip_address) { '182.189.119.174' }
let!(:spammer1) { Fabricate(:user, ip_address: ip_address) }
let!(:spammer2) { Fabricate(:user, ip_address: ip_address) }
let(:spammer3) { Fabricate(:user, ip_address: ip_address) }
- context 'flag_sockpuppets is disabled' do
+ context 'when flag_sockpuppets is disabled' do
let!(:first_post) { create_post(user: spammer1) }
let!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
@@ -18,7 +17,7 @@ RSpec.describe "spammers on same IP" do
end
end
- context 'flag_sockpuppets is enabled' do
+ context 'when flag_sockpuppets is enabled' do
before do
SiteSetting.flag_sockpuppets = true
end
@@ -27,10 +26,10 @@ RSpec.describe "spammers on same IP" do
SiteSetting.flag_sockpuppets = false
end
- context 'first spammer starts a topic' do
+ context 'when first spammer starts a topic' do
let!(:first_post) { create_post(user: spammer1) }
- context 'second spammer replies' do
+ context 'when second spammer replies' do
let!(:second_post) { create_post(user: spammer2, topic: first_post.topic) }
it 'should increase spam count' do
@@ -38,7 +37,7 @@ RSpec.describe "spammers on same IP" do
expect(second_post.reload.spam_count).to eq(1)
end
- context 'third spam post' do
+ context 'with third spam post' do
let!(:third_post) { create_post(user: spammer3, topic: first_post.topic) }
it 'should increase spam count' do
@@ -50,13 +49,13 @@ RSpec.describe "spammers on same IP" do
end
end
- context 'first user is not new' do
+ context 'when first user is not new' do
let!(:old_user) { Fabricate(:user, ip_address: ip_address, created_at: 2.days.ago, trust_level: TrustLevel[1]) }
- context 'first user starts a topic' do
+ context 'when first user starts a topic' do
let!(:first_post) { create_post(user: old_user) }
- context 'a reply by a new user at the same IP address' 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
@@ -67,5 +66,4 @@ RSpec.describe "spammers on same IP" do
end
end
end
-
end
diff --git a/spec/integration/spam_rules_spec.rb b/spec/integration/spam_rules_spec.rb
index cfc22442d8e..bf89f478680 100644
--- a/spec/integration/spam_rules_spec.rb
+++ b/spec/integration/spam_rules_spec.rb
@@ -2,7 +2,6 @@
# frozen_string_literal: true
RSpec.describe "spam rules for users" do
-
describe 'auto-silence users based on flagging' do
fab!(:admin) { Fabricate(:admin) } # needed to send a system message
fab!(:moderator) { Fabricate(:moderator) }
@@ -16,10 +15,10 @@ RSpec.describe "spam rules for users" do
SiteSetting.num_users_to_silence_new_user = 2
end
- context 'spammer is a new user' do
+ context 'when spammer is a new user' do
fab!(:spammer) { Fabricate(:user, trust_level: TrustLevel[0]) }
- context 'spammer post is not flagged enough times' do
+ context 'when spammer post is not flagged enough times' do
let!(:spam_post) { create_post(user: spammer) }
let!(:spam_post2) { create_post(user: spammer) }
@@ -31,7 +30,7 @@ RSpec.describe "spam rules for users" do
expect(spam_post.reload).to_not be_hidden
end
- context 'spam posts are flagged enough times, but not by enough users' do
+ context 'when spam posts are flagged enough times, but not by enough users' do
it 'should not hide the post' do
PostActionCreator.create(user1, spam_post2, :spam)
@@ -41,7 +40,7 @@ RSpec.describe "spam rules for users" do
end
end
- context 'one spam post is flagged enough times by enough users' do
+ context 'when one spam post is flagged enough times by enough users' do
fab!(:another_topic) { Fabricate(:topic) }
let!(:private_messages_count) { spammer.private_topics_count }
let!(:mod_pm_count) { moderator.private_topics_count }
@@ -57,14 +56,14 @@ RSpec.describe "spam rules for users" do
expect(spammer.reload.private_topics_count).to eq(private_messages_count + 1)
end
- context "a post is deleted" do
+ context "when a post is deleted" do
it 'should silence the spammer' do
spam_post.trash!(moderator); spammer.reload
expect(spammer.reload).to be_silenced
end
end
- context "spammer becomes trust level 1" do
+ context "when spammer becomes trust level 1" do
it 'should silence the spammer' do
spammer.change_trust_level!(TrustLevel[1]); spammer.reload
expect(spammer.reload).to be_silenced
@@ -72,7 +71,7 @@ RSpec.describe "spam rules for users" do
end
end
- context 'hide_post_sensitivity' do
+ context 'with hide_post_sensitivity' do
it 'should silence the spammer' do
Reviewable.set_priorities(high: 2.0)
SiteSetting.hide_post_sensitivity = Reviewable.sensitivity[:low]
@@ -84,10 +83,10 @@ RSpec.describe "spam rules for users" do
end
end
- context "spammer has trust level basic" do
+ context "when spammer has trust level basic" do
let(:spammer) { Fabricate(:user, trust_level: TrustLevel[1]) }
- context 'one spam post is flagged enough times by enough users' do
+ context 'when one spam post is flagged enough times by enough users' do
let!(:spam_post) { Fabricate(:post, user: spammer) }
let!(:private_messages_count) { spammer.private_topics_count }
diff --git a/spec/integration/topic_auto_close_spec.rb b/spec/integration/topic_auto_close_spec.rb
index 11d851678ec..95821bc30ed 100644
--- a/spec/integration/topic_auto_close_spec.rb
+++ b/spec/integration/topic_auto_close_spec.rb
@@ -4,10 +4,10 @@
RSpec.describe Topic do
let(:job_klass) { Jobs::CloseTopic }
- context 'creating a topic without auto-close' do
+ context 'when creating a topic without auto-close' do
let(:topic) { Fabricate(:topic, category: category) }
- context 'uncategorized' do
+ context 'when uncategorized' do
let(:category) { nil }
it 'should not schedule the topic to auto-close' do
@@ -16,7 +16,7 @@ RSpec.describe Topic do
end
end
- context 'category without default auto-close' 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
@@ -25,12 +25,12 @@ RSpec.describe Topic do
end
end
- context 'jobs may be queued' do
+ context 'when jobs may be queued' do
before do
freeze_time
end
- context 'category has a default auto-close' 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
@@ -42,7 +42,7 @@ RSpec.describe Topic do
expect(topic.public_topic_timer.execute_at).to be_within_one_second_of(2.hours.from_now)
end
- context 'topic was created by staff user' do
+ context 'when topic was created by staff user' do
let(:admin) { Fabricate(:admin) }
let(:staff_topic) { Fabricate(:topic, user: admin, category: category) }
@@ -56,7 +56,7 @@ RSpec.describe Topic do
expect(topic_status_update.user).to eq(Discourse.system_user)
end
- context 'topic is closed manually' do
+ context 'when topic is closed manually' do
it 'should remove the schedule to auto-close the topic' do
topic_timer_id = staff_topic.public_topic_timer.id
@@ -68,7 +68,7 @@ RSpec.describe Topic do
end
end
- context 'topic was created by a non-staff user' do
+ context 'when topic was created by a non-staff user' do
let(:regular_user) { Fabricate(:user) }
let(:regular_user_topic) { Fabricate(:topic, user: regular_user, category: category) }
diff --git a/spec/integration/topic_thumbnail_spec.rb b/spec/integration/topic_thumbnail_spec.rb
index 9245716b149..9a51836c5a6 100644
--- a/spec/integration/topic_thumbnail_spec.rb
+++ b/spec/integration/topic_thumbnail_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "Topic Thumbnails" do
fab!(:topic) { Fabricate(:topic, image_upload_id: image.id) }
fab!(:user) { Fabricate(:user) }
- context 'latest' do
+ describe 'latest' do
def get_topic
Discourse.redis.del(topic.thumbnail_job_redis_key(Topic.thumbnail_sizes))
Discourse.redis.del(topic.thumbnail_job_redis_key([]))
diff --git a/spec/integration/watched_words_spec.rb b/spec/integration/watched_words_spec.rb
index 0aec8298d18..f776bafe996 100644
--- a/spec/integration/watched_words_spec.rb
+++ b/spec/integration/watched_words_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe WatchedWord do
WordWatcher.clear_cache!
end
- context "block" do
+ context "with block" do
def should_block_post(manager)
expect {
result = manager.perform
@@ -88,7 +88,7 @@ RSpec.describe WatchedWord do
end
end
- context "require_approval" do
+ context "with require_approval" do
it "should queue the post for approval" do
manager = NewPostManager.new(tl2_user, raw: "My dog's name is #{require_approval_word.word}.", topic_id: topic.id)
result = manager.perform
@@ -130,7 +130,7 @@ RSpec.describe WatchedWord do
end
end
- context "flag" do
+ context "with flag" do
def should_flag_post(author, raw, topic)
post = Fabricate(:post, raw: raw, topic: topic, user: author)
expect {
diff --git a/spec/integrity/i18n_spec.rb b/spec/integrity/i18n_spec.rb
index 0205584c24d..b175e8a459f 100644
--- a/spec/integrity/i18n_spec.rb
+++ b/spec/integrity/i18n_spec.rb
@@ -113,7 +113,7 @@ RSpec.describe "fallbacks" do
end
end
- context "in a multi-threaded environment" do
+ context "when in a multi-threaded environment" do
it "finds the fallback translation" do
I18n.backend.store_translations(:en, test: "en test")
diff --git a/spec/jobs/auto_queue_handler_spec.rb b/spec/jobs/auto_queue_handler_spec.rb
index ece2af84735..6fb6c2a9003 100644
--- a/spec/jobs/auto_queue_handler_spec.rb
+++ b/spec/jobs/auto_queue_handler_spec.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
RSpec.describe Jobs::AutoQueueHandler do
-
subject { Jobs::AutoQueueHandler.new.execute({}) }
- context "old flagged post" do
+ describe "old flagged post" do
fab!(:spam_result) do
PostActionCreator.new(
Fabricate(:user),
@@ -38,7 +37,7 @@ RSpec.describe Jobs::AutoQueueHandler do
end
end
- context "reviewables" do
+ describe "reviewables" do
fab!(:new_post) { Fabricate(:reviewable_queued_post, created_at: 59.days.ago) }
fab!(:old_post) { Fabricate(:reviewable_queued_post, created_at: 61.days.ago) }
fab!(:new_user) { Fabricate(:reviewable, created_at: 10.days.ago) }
@@ -62,5 +61,4 @@ RSpec.describe Jobs::AutoQueueHandler do
expect(old_user.reload.pending?).to eq(true)
end
end
-
end
diff --git a/spec/jobs/bulk_invite_spec.rb b/spec/jobs/bulk_invite_spec.rb
index 0bbddc17b48..9d0984551d9 100644
--- a/spec/jobs/bulk_invite_spec.rb
+++ b/spec/jobs/bulk_invite_spec.rb
@@ -106,7 +106,7 @@ RSpec.describe Jobs::BulkInvite do
expect(new_staged_user.user_fields[user_field.id.to_s]).to eq('value 3')
end
- context 'invites are more than 200' do
+ context 'when there are more than 200 invites' do
let(:bulk_invites) { [] }
before do
diff --git a/spec/jobs/clean_up_unused_staged_users_spec.rb b/spec/jobs/clean_up_unused_staged_users_spec.rb
index c0838871159..daaad64912f 100644
--- a/spec/jobs/clean_up_unused_staged_users_spec.rb
+++ b/spec/jobs/clean_up_unused_staged_users_spec.rb
@@ -14,19 +14,19 @@ RSpec.describe Jobs::CleanUpUnusedStagedUsers do
context "when staged user is old enough" do
before { staged_user.update!(created_at: 2.years.ago) }
- context "regular staged user" do
+ context "with regular staged user" do
it "deletes the staged user" do
expect { described_class.new.execute({}) }.to change { User.count }.by(-1)
expect(User.exists?(staged_user.id)).to eq(false)
end
end
- context "staged admin" do
+ context "with staged admin" do
before { staged_user.update!(admin: true) }
include_examples "does not delete"
end
- context "staged moderator" do
+ context "with staged moderator" do
before { staged_user.update!(moderator: true) }
include_examples "does not delete"
end
diff --git a/spec/jobs/enqueue_digest_emails_spec.rb b/spec/jobs/enqueue_digest_emails_spec.rb
index 958c7a5064a..82b18c8c646 100644
--- a/spec/jobs/enqueue_digest_emails_spec.rb
+++ b/spec/jobs/enqueue_digest_emails_spec.rb
@@ -3,8 +3,7 @@
RSpec.describe Jobs::EnqueueDigestEmails do
describe '#target_users' do
-
- context 'disabled digests' do
+ context 'with disabled digests' do
before { SiteSetting.default_email_digest_frequency = 0 }
let!(:user_no_digests) { Fabricate(:active_user, last_emailed_at: 8.days.ago, last_seen_at: 10.days.ago) }
@@ -13,8 +12,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'unapproved users' do
-
+ context 'with unapproved users' do
before do
SiteSetting.must_approve_users = true
end
@@ -38,7 +36,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'staged users' do
+ context 'with staged users' do
let!(:staged_user) { Fabricate(:active_user, staged: true, last_emailed_at: 1.year.ago, last_seen_at: 1.year.ago) }
it "doesn't return staged users" do
@@ -46,16 +44,15 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'recently emailed' do
+ context 'when recently emailed' do
let!(:user_emailed_recently) { Fabricate(:active_user, last_emailed_at: 6.days.ago) }
it "doesn't return users who have been emailed recently" do
expect(Jobs::EnqueueDigestEmails.new.target_user_ids.include?(user_emailed_recently.id)).to eq(false)
end
-
end
- context "inactive user" do
+ context "with inactive user" do
let!(:inactive_user) { Fabricate(:user, active: false) }
it "doesn't return users who have been emailed recently" do
@@ -63,7 +60,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context "suspended user" do
+ context "with suspended user" do
let!(:suspended_user) { Fabricate(:user, suspended_till: 1.week.from_now, suspended_at: 1.day.ago) }
it "doesn't return users who are suspended" do
@@ -71,7 +68,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'visited the site this week' do
+ context 'when visited the site this week' do
let(:user_visited_this_week) { Fabricate(:active_user, last_seen_at: 6.days.ago) }
it "doesn't return users who have been emailed recently" do
@@ -80,7 +77,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'visited the site a year ago' do
+ context 'when visited the site a year ago' do
let!(:user_visited_a_year_ago) { Fabricate(:active_user, last_seen_at: 370.days.ago) }
it "doesn't return the user who have not visited the site for more than 365 days" do
@@ -88,7 +85,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'regular users' do
+ context 'with regular users' do
let!(:user) { Fabricate(:active_user, last_seen_at: (SiteSetting.suppress_digest_email_after_days - 1).days.ago) }
it "returns the user" do
@@ -96,7 +93,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context 'too many bounces' do
+ context 'with too many bounces' do
let!(:bounce_user) { Fabricate(:active_user, last_seen_at: 6.month.ago) }
it "doesn't return users with too many bounces" do
@@ -105,7 +102,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context "no primary email" do
+ context "with no primary email" do
let!(:user) { Fabricate(:active_user, last_seen_at: 2.months.ago) }
it "doesn't return users with no primary emails" do
@@ -116,7 +113,6 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
describe '#execute' do
-
let(:user) { Fabricate(:user) }
it "limits jobs enqueued per max_digests_enqueued_per_30_mins_per_site" do
@@ -146,7 +142,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context "digest emails are enabled" do
+ context "when digest emails are enabled" do
before do
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).returns([user.id])
end
@@ -160,7 +156,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context "private email" do
+ context "with private email" do
before do
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).never
SiteSetting.private_email = true
@@ -173,7 +169,7 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
- context "digest emails are disabled" do
+ context "when digest emails are disabled" do
before do
Jobs::EnqueueDigestEmails.any_instance.expects(:target_user_ids).never
SiteSetting.disable_digest_emails = true
@@ -185,7 +181,5 @@ RSpec.describe Jobs::EnqueueDigestEmails do
end
end
end
-
end
-
end
diff --git a/spec/jobs/ensure_s3_uploads_existence_spec.rb b/spec/jobs/ensure_s3_uploads_existence_spec.rb
index aef97c2258c..84d6e6c812a 100644
--- a/spec/jobs/ensure_s3_uploads_existence_spec.rb
+++ b/spec/jobs/ensure_s3_uploads_existence_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::EnsureS3UploadsExistence do
- context "S3 inventory enabled" do
+ context "with S3 inventory enabled" do
before do
setup_s3
SiteSetting.enable_s3_inventory = true
@@ -27,7 +27,7 @@ RSpec.describe Jobs::EnsureS3UploadsExistence do
end
end
- context "S3 inventory disabled" do
+ context "with S3 inventory disabled" do
before { SiteSetting.enable_s3_inventory = false }
it "doesn't execute" do
diff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rb
index 15eb36313ac..09f86a331fe 100644
--- a/spec/jobs/export_user_archive_spec.rb
+++ b/spec/jobs/export_user_archive_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'user_archive posts' do
+ describe 'user_archive posts' do
let(:component) { 'user_archive' }
let(:subsubcategory) { Fabricate(:category_with_definition, parent_category_id: subcategory.id) }
let(:subsubtopic) { Fabricate(:topic, category: subsubcategory) }
@@ -181,7 +181,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'preferences' do
+ describe 'preferences' do
let(:component) { 'preferences' }
before do
@@ -206,7 +206,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'auth tokens' do
+ describe 'auth tokens' do
let(:component) { 'auth_tokens' }
before do
@@ -225,7 +225,7 @@ RSpec.describe Jobs::ExportUserArchive do
expect(data[0]['user_agent']).to eq('MyWebBrowser')
end
- context 'auth token logs' do
+ context 'with auth token logs' do
let(:component) { 'auth_token_logs' }
it 'includes details such as the path' do
data, _csv_out = make_component_csv
@@ -237,7 +237,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'badges' do
+ describe 'badges' do
let(:component) { 'badges' }
let(:badge1) { Fabricate(:badge) }
@@ -264,10 +264,9 @@ RSpec.describe Jobs::ExportUserArchive do
expect(data[2]['granted_manually']).to eq('true')
expect(Post.find(data[3]['post_id'])).to_not be_nil
end
-
end
- context 'bookmarks' do
+ describe 'bookmarks' do
let(:component) { 'bookmarks' }
let(:name) { 'Collect my thoughts on this' }
@@ -321,7 +320,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'category_preferences' do
+ describe 'category_preferences' do
let(:component) { 'category_preferences' }
let(:subsubcategory) { Fabricate(:category_with_definition, parent_category_id: subcategory.id, name: "User Archive Subcategory") }
@@ -394,7 +393,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'flags' do
+ describe 'flags' do
let(:component) { 'flags' }
let(:other_post) { Fabricate(:post, user: admin) }
let(:post3) { Fabricate(:post) }
@@ -429,7 +428,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'likes' do
+ describe 'likes' do
let(:component) { 'likes' }
let(:other_post) { Fabricate(:post, user: admin) }
let(:post3) { Fabricate(:post) }
@@ -452,7 +451,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'queued posts' do
+ describe 'queued posts' do
let(:component) { 'queued_posts' }
let(:reviewable_post) { Fabricate(:reviewable_queued_post, topic: topic, created_by: user) }
let(:reviewable_topic) { Fabricate(:reviewable_queued_post_topic, category: category, created_by: user) }
@@ -478,7 +477,7 @@ RSpec.describe Jobs::ExportUserArchive do
end
end
- context 'visits' do
+ describe 'visits' do
let(:component) { 'visits' }
it 'correctly exports the UserVisit table' do
diff --git a/spec/jobs/feature_topic_users_spec.rb b/spec/jobs/feature_topic_users_spec.rb
index bae3f19a6d3..3fa7eba0928 100644
--- a/spec/jobs/feature_topic_users_spec.rb
+++ b/spec/jobs/feature_topic_users_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe Jobs::FeatureTopicUsers do
end
end
- context "participant count" do
+ context "with participant count" do
let!(:post) { create_post }
let(:topic) { post.topic }
diff --git a/spec/jobs/grant_anniversary_badges_spec.rb b/spec/jobs/grant_anniversary_badges_spec.rb
index e2e2b70c849..ae5cad056c2 100644
--- a/spec/jobs/grant_anniversary_badges_spec.rb
+++ b/spec/jobs/grant_anniversary_badges_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Jobs::GrantAnniversaryBadges do
-
let(:granter) { described_class.new }
it "doesn't award to a user who is less than a year old" do
@@ -86,7 +85,7 @@ RSpec.describe Jobs::GrantAnniversaryBadges do
expect(badge.count).to eq(1)
end
- context "repeated grants" do
+ context "with repeated grants" do
it "won't 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,5 +131,4 @@ RSpec.describe Jobs::GrantAnniversaryBadges do
expect(badge.count).to eq(2)
end
end
-
end
diff --git a/spec/jobs/invalidate_inactive_admins_spec.rb b/spec/jobs/invalidate_inactive_admins_spec.rb
index ca84c2e8577..8994e9f7304 100644
--- a/spec/jobs/invalidate_inactive_admins_spec.rb
+++ b/spec/jobs/invalidate_inactive_admins_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Jobs::InvalidateInactiveAdmins do
fab!(:not_seen_admin) { Fabricate(:admin, last_seen_at: 370.days.ago) }
before { not_seen_admin.email_tokens.update_all(confirmed: true) }
- context 'invalidate_inactive_admin_email_after_days = 365' do
+ context 'when invalidate_inactive_admin_email_after_days = 365' do
before do
SiteSetting.invalidate_inactive_admin_email_after_days = 365
end
@@ -65,7 +65,7 @@ RSpec.describe Jobs::InvalidateInactiveAdmins do
end
end
- context 'invalidate_inactive_admin_email_after_days = 0 to disable this feature' do
+ context 'when invalidate_inactive_admin_email_after_days = 0 to disable this feature' do
before do
SiteSetting.invalidate_inactive_admin_email_after_days = 0
end
diff --git a/spec/jobs/jobs_spec.rb b/spec/jobs/jobs_spec.rb
index f5ce9e2ccdb..09c4252decd 100644
--- a/spec/jobs/jobs_spec.rb
+++ b/spec/jobs/jobs_spec.rb
@@ -110,7 +110,7 @@ RSpec.describe Jobs do
Jobs.enqueue(:process_post, post_id: 1)
end
- context 'and current_site_id option is given and does not match the current connection' do
+ context 'when current_site_id option is given and does not match the current connection' do
before do
Sidekiq::Client.stubs(:enqueue)
Jobs::ProcessPost.any_instance.stubs(:execute).returns(true)
diff --git a/spec/jobs/notify_mailing_list_subscribers_spec.rb b/spec/jobs/notify_mailing_list_subscribers_spec.rb
index ceed63d598a..ace5161f91d 100644
--- a/spec/jobs/notify_mailing_list_subscribers_spec.rb
+++ b/spec/jobs/notify_mailing_list_subscribers_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Jobs::NotifyMailingListSubscribers do
-
fab!(:mailing_list_user) { Fabricate(:user) }
before { mailing_list_user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1) }
@@ -88,68 +87,67 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
end
context "with a valid post from another user" do
-
- context "to an inactive user" do
+ context "when to an inactive user" do
before { mailing_list_user.update(active: false) }
include_examples "no emails"
end
- context "to a silenced user" do
+ context "when to a silenced user" do
before { mailing_list_user.update(silenced_till: 1.year.from_now) }
include_examples "no emails"
end
- context "to a suspended user" do
+ context "when to a suspended user" do
before { mailing_list_user.update(suspended_till: 1.day.from_now) }
include_examples "no emails"
end
- context "to an anonymous user" do
+ context "when to an anonymous user" do
fab!(:mailing_list_user) { Fabricate(:anonymous) }
include_examples "no emails"
end
- context "to an user who has disabled mailing list mode" do
+ context "when to an user who has disabled mailing list mode" do
before { mailing_list_user.user_option.update(mailing_list_mode: false) }
include_examples "no emails"
end
- context "to an user who has frequency set to 'always'" do
+ context "when to an user who has frequency set to 'always'" do
before { mailing_list_user.user_option.update(mailing_list_mode_frequency: 1) }
include_examples "one email"
end
- context "to an user who has frequency set to 'no echo'" do
+ context "when to an user who has frequency set to 'no echo'" do
before { mailing_list_user.user_option.update(mailing_list_mode_frequency: 2) }
include_examples "one email"
end
- context "from a muted user" do
+ context "when from a muted user" do
before { MutedUser.create(user: mailing_list_user, muted_user: user) }
include_examples "no emails"
end
- context "from an ignored user" do
+ context "when from an ignored user" do
before { Fabricate(:ignored_user, user: mailing_list_user, ignored_user: user) }
include_examples "no emails"
end
- context "from a muted topic" do
+ context "when from a muted topic" do
before { TopicUser.create(user: mailing_list_user, topic: post.topic, notification_level: TopicUser.notification_levels[:muted]) }
include_examples "no emails"
end
- context "from a muted category" do
+ context "when from a muted category" do
before { CategoryUser.create(user: mailing_list_user, category: post.topic.category, notification_level: CategoryUser.notification_levels[:muted]) }
include_examples "no emails"
end
- context "mute all categories by default setting" do
+ context "with mute all categories by default setting" do
before { SiteSetting.mute_all_categories_by_default = true }
include_examples "no emails"
end
- context "mute all categories by default setting but user is watching category" do
+ context "with mute all categories by default setting but user is watching category" do
before do
SiteSetting.mute_all_categories_by_default = true
CategoryUser.create(user: mailing_list_user, category: post.topic.category, notification_level: CategoryUser.notification_levels[:watching])
@@ -157,7 +155,7 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
include_examples "one email"
end
- context "mute all categories by default setting but user is watching tag" do
+ context "with mute all categories by default setting but user is watching tag" do
before do
SiteSetting.mute_all_categories_by_default = true
TagUser.create(user: mailing_list_user, tag: tag, notification_level: TagUser.notification_levels[:watching])
@@ -165,7 +163,7 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
include_examples "one email"
end
- context "mute all categories by default setting but user is watching topic" do
+ context "with mute all categories by default setting but user is watching topic" do
before do
SiteSetting.mute_all_categories_by_default = true
TopicUser.create(user: mailing_list_user, topic: post.topic, notification_level: TopicUser.notification_levels[:watching])
@@ -173,12 +171,12 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
include_examples "one email"
end
- context "from a muted tag" do
+ context "when from a muted tag" do
before { TagUser.create(user: mailing_list_user, tag: tag, notification_level: TagUser.notification_levels[:muted]) }
include_examples "no emails"
end
- context "max emails per day was reached" do
+ context "when max emails per day was reached" do
before { SiteSetting.max_emails_per_day_per_user = 2 }
it "doesn't send any emails" do
@@ -224,8 +222,7 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
end
end
- context "bounce score was reached" do
-
+ context "when bounce score was reached" do
it "doesn't send any emails" do
mailing_list_user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold + 1)
@@ -240,30 +237,26 @@ RSpec.describe Jobs::NotifyMailingListSubscribers do
reason_type: SkippedEmailLog.reason_types[:exceeded_bounces_limit]
)).to eq(true)
end
-
end
-
end
context "with a valid post from same user" do
fab!(:post) { Fabricate(:post, user: mailing_list_user) }
- context "to an user who has frequency set to 'daily'" do
+ context "when to an user who has frequency set to 'daily'" do
before { mailing_list_user.user_option.update(mailing_list_mode_frequency: 0) }
include_examples "no emails"
end
- context "to an user who has frequency set to 'always'" do
+ context "when to an user who has frequency set to 'always'" do
before { mailing_list_user.user_option.update(mailing_list_mode_frequency: 1) }
include_examples "one email"
end
- context "to an user who has frequency set to 'no echo'" do
+ context "when to an user who has frequency set to 'no echo'" do
before { mailing_list_user.user_option.update(mailing_list_mode_frequency: 2) }
include_examples "no emails"
end
end
-
end
-
end
diff --git a/spec/jobs/notify_tag_change_spec.rb b/spec/jobs/notify_tag_change_spec.rb
index efe15c959fe..f0fab3d5190 100644
--- a/spec/jobs/notify_tag_change_spec.rb
+++ b/spec/jobs/notify_tag_change_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe ::Jobs::NotifyTagChange do
-
fab!(:user) { Fabricate(:user) }
fab!(:regular_user) { Fabricate(:trust_level_4) }
fab!(:post) { Fabricate(:post, user: regular_user) }
@@ -50,7 +49,7 @@ RSpec.describe ::Jobs::NotifyTagChange do
expect { described_class.new.execute(post_id: post.id, notified_user_ids: [regular_user.id]) }.not_to change { Notification.count }
end
- context 'hidden tag' do
+ describe 'hidden tag' do
let!(:hidden_group) { Fabricate(:group, name: 'hidden_group') }
let!(:hidden_tag_group) { Fabricate(:tag_group, name: 'hidden', permissions: [[hidden_group.id, :full]]) }
let!(:topic_user) { Fabricate(:topic_user, user: user, topic: post.topic, notification_level: TopicUser.notification_levels[:watching]) }
diff --git a/spec/jobs/pending_queued_posts_reminder_spec.rb b/spec/jobs/pending_queued_posts_reminder_spec.rb
index fde2b66e0be..7611556dd5f 100644
--- a/spec/jobs/pending_queued_posts_reminder_spec.rb
+++ b/spec/jobs/pending_queued_posts_reminder_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Jobs::PendingQueuedPostsReminder do
let(:job) { described_class.new }
- context "notify_about_queued_posts_after is 0" do
+ context "when notify_about_queued_posts_after is 0" do
before { SiteSetting.notify_about_queued_posts_after = 0 }
it "never emails" do
@@ -14,7 +14,7 @@ RSpec.describe Jobs::PendingQueuedPostsReminder do
end
end
- context "notify_about_queued_posts_after accepts a float" do
+ context "when notify_about_queued_posts_after accepts a float" do
before do
SiteSetting.notify_about_queued_posts_after = 0.25
job.last_notified_id = nil
@@ -32,13 +32,12 @@ RSpec.describe Jobs::PendingQueuedPostsReminder do
end
end
- context "notify_about_queued_posts_after is 24" do
+ context "when notify_about_queued_posts_after is 24" do
before do
SiteSetting.notify_about_queued_posts_after = 24
end
context "when we haven't been notified in a while" do
-
before do
job.last_notified_id = nil
end
diff --git a/spec/jobs/pending_reviewables_reminder_spec.rb b/spec/jobs/pending_reviewables_reminder_spec.rb
index c93928c35dd..2b6d4deafd7 100644
--- a/spec/jobs/pending_reviewables_reminder_spec.rb
+++ b/spec/jobs/pending_reviewables_reminder_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Jobs::PendingReviewablesReminder do
expect(execute.sent_reminder).to eq(false)
end
- context "notify_about_flags_after is 0" do
+ context "when notify_about_flags_after is 0" do
before { SiteSetting.notify_about_flags_after = 0 }
it "never notifies" do
@@ -24,7 +24,7 @@ RSpec.describe Jobs::PendingReviewablesReminder do
end
end
- context "notify_about_flags_after accepts a float" do
+ context "when notify_about_flags_after accepts a float" do
before { SiteSetting.notify_about_flags_after = 0.25 }
it "doesn't send message when flags are less than 15 minutes old" do
@@ -38,7 +38,7 @@ RSpec.describe Jobs::PendingReviewablesReminder do
end
end
- context "notify_about_flags_after is 48" do
+ context "when notify_about_flags_after is 48" do
before do
SiteSetting.notify_about_flags_after = 48
described_class.clear_key
@@ -68,7 +68,7 @@ RSpec.describe Jobs::PendingReviewablesReminder do
expect(execute.sent_reminder).to eq(true)
end
- context "reviewable_default_visibility" do
+ context "with reviewable_default_visibility" do
before do
create_flag(49.hours.ago)
create_flag(51.hours.ago)
diff --git a/spec/jobs/pending_users_reminder_spec.rb b/spec/jobs/pending_users_reminder_spec.rb
index d3a9c4d011c..c482231d6e7 100644
--- a/spec/jobs/pending_users_reminder_spec.rb
+++ b/spec/jobs/pending_users_reminder_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe Jobs::PendingUsersReminder do
-
- context 'must_approve_users is true' do
+ context 'when must_approve_users is true' do
before do
SiteSetting.must_approve_users = true
Jobs::PendingUsersReminder.any_instance.stubs(:previous_newest_username).returns(nil)
@@ -13,7 +12,7 @@ RSpec.describe Jobs::PendingUsersReminder do
Jobs::PendingUsersReminder.new.execute({})
end
- context "there are pending users" do
+ context "when there are pending users" do
before do
Fabricate(:moderator, approved: true, approved_by_id: -1, approved_at: 1.week.ago)
Group.refresh_automatic_group!(:moderators)
@@ -49,7 +48,7 @@ RSpec.describe Jobs::PendingUsersReminder do
end
end
- context 'must_approve_users is false' do
+ context 'when must_approve_users is false' do
before do
SiteSetting.must_approve_users = false
end
diff --git a/spec/jobs/poll_mailbox_spec.rb b/spec/jobs/poll_mailbox_spec.rb
index 1f5e59e7641..3ba8fe72fec 100644
--- a/spec/jobs/poll_mailbox_spec.rb
+++ b/spec/jobs/poll_mailbox_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
RSpec.describe Jobs::PollMailbox do
-
let(:poller) { Jobs::PollMailbox.new }
describe ".execute" do
-
it "does no polling if pop3_polling_enabled is false" do
SiteSetting.expects(:pop3_polling_enabled).returns(false)
poller.expects(:poll_pop3).never
@@ -17,7 +15,6 @@ RSpec.describe Jobs::PollMailbox do
poller.expects(:poll_pop3).once
poller.execute({})
end
-
end
describe ".poll_pop3" do
@@ -39,7 +36,7 @@ RSpec.describe Jobs::PollMailbox do
EMAIL
end
- context "pop errors" do
+ context "with pop errors" do
before do
Discourse.expects(:handle_job_exception).at_least_once
end
@@ -114,7 +111,7 @@ RSpec.describe Jobs::PollMailbox do
poller.poll_pop3
end
- context "has emails" do
+ context "when has emails" do
let(:oldmail) { file_from_fixtures("old_destination.eml", "emails").read }
before do
@@ -173,7 +170,5 @@ RSpec.describe Jobs::PollMailbox do
I18n.t("emails.incoming.errors.bounced_email_error")
)
end
-
end
-
end
diff --git a/spec/jobs/regular/group_smtp_email_spec.rb b/spec/jobs/regular/group_smtp_email_spec.rb
index b85ef6d3caa..01bc1ec1de8 100644
--- a/spec/jobs/regular/group_smtp_email_spec.rb
+++ b/spec/jobs/regular/group_smtp_email_spec.rb
@@ -253,7 +253,7 @@ RSpec.describe Jobs::GroupSmtpEmail do
end
end
- context "group is deleted" do
+ context "when group is deleted" do
it "returns without sending email" do
group.destroy
subject.execute(args)
diff --git a/spec/jobs/remove_banner_spec.rb b/spec/jobs/remove_banner_spec.rb
index f218d801fc7..6456568eb1a 100644
--- a/spec/jobs/remove_banner_spec.rb
+++ b/spec/jobs/remove_banner_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Jobs::RemoveBanner do
fab!(:topic) { Fabricate(:topic) }
fab!(:user) { topic.user }
- context 'topic is not bannered until' do
+ context 'when topic is not bannered until' do
it 'doesn’t enqueue a future job to remove it' do
expect do
topic.make_banner!(user)
@@ -12,8 +12,8 @@ RSpec.describe Jobs::RemoveBanner do
end
end
- context 'topic is bannered until' do
- context 'bannered_until is a valid date' do
+ context 'when topic is bannered until' do
+ context 'when bannered_until is a valid date' do
it 'enqueues a future job to remove it' do
bannered_until = 5.days.from_now
@@ -36,7 +36,7 @@ RSpec.describe Jobs::RemoveBanner do
end
end
- context 'bannered_until is an invalid date' do
+ context 'when bannered_until is an invalid date' do
it 'doesn’t enqueue a future job to remove it' do
expect do
expect do
diff --git a/spec/jobs/sync_acls_for_uploads_spec.rb b/spec/jobs/sync_acls_for_uploads_spec.rb
index 87d5e42d262..a7b43162cad 100644
--- a/spec/jobs/sync_acls_for_uploads_spec.rb
+++ b/spec/jobs/sync_acls_for_uploads_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Jobs::SyncAclsForUploads do
run_job
end
- context "external storage enabled" do
+ context "with external storage enabled" do
before do
setup_s3
stub_s3_store
diff --git a/spec/jobs/tl3_promotions_spec.rb b/spec/jobs/tl3_promotions_spec.rb
index 5c43b378e9c..770bb39c166 100644
--- a/spec/jobs/tl3_promotions_spec.rb
+++ b/spec/jobs/tl3_promotions_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Jobs::Tl3Promotions do
-
def create_qualifying_stats(user)
user.create_user_stat if user.user_stat.nil?
user.user_stat.update!(
@@ -44,7 +43,7 @@ RSpec.describe Jobs::Tl3Promotions do
run_job
end
- context "tl3 user who doesn't qualify for tl3 anymore" do
+ context "with tl3 user who doesn't qualify for tl3 anymore" do
def create_leader_user
user = Fabricate(:user, trust_level: TrustLevel[2])
TrustLevel3Requirements.any_instance.stubs(:requirements_met?).returns(true)
diff --git a/spec/jobs/user_email_spec.rb b/spec/jobs/user_email_spec.rb
index 3025fbe4742..efda1132b6f 100644
--- a/spec/jobs/user_email_spec.rb
+++ b/spec/jobs/user_email_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Jobs::UserEmail do
-
before do
SiteSetting.email_time_window_mins = 10
end
@@ -23,7 +22,7 @@ RSpec.describe Jobs::UserEmail do
expect { Jobs::UserEmail.new.execute(type: :no_method, user_id: user.id) }.to raise_error(Discourse::InvalidParameters)
end
- context 'digest can be generated' do
+ context 'when digest can be generated' do
fab!(:user) { Fabricate(:user, last_seen_at: 8.days.ago, last_emailed_at: 8.days.ago) }
fab!(:popular_topic) { Fabricate(:topic, user: Fabricate(:admin), created_at: 1.hour.ago) }
@@ -38,7 +37,7 @@ RSpec.describe Jobs::UserEmail do
expect(ActionMailer::Base.deliveries).to eq([])
end
- context 'not emailed recently' do
+ context 'when not emailed recently' do
before do
freeze_time
user.update!(last_emailed_at: 8.days.ago)
@@ -51,7 +50,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'recently emailed' do
+ context 'when recently emailed' do
before do
freeze_time
user.update!(last_emailed_at: 2.hours.ago)
@@ -66,8 +65,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context "bounce score" do
-
+ context "with bounce score" do
it "always sends critical emails when bounce score threshold has been reached" do
email_token = Fabricate(:email_token)
user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold + 1)
@@ -81,10 +79,9 @@ RSpec.describe Jobs::UserEmail do
user.email
)
end
-
end
- context 'to_address' do
+ context 'with to_address' do
it 'overwrites a to_address when present' do
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, to_address: '[email protected]')
@@ -94,7 +91,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context "disable_emails setting" do
+ context "with disable_emails setting" do
it "sends when no" do
SiteSetting.disable_emails = 'no'
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id)
@@ -112,7 +109,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context "recently seen" do
+ context "when recently seen" do
fab!(:post) { Fabricate(:post, user: user) }
fab!(:notification) { Fabricate(
:notification,
@@ -246,7 +243,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context "email_log" do
+ context "with email_log" do
fab!(:post) { Fabricate(:post, created_at: 30.seconds.ago) }
before do
@@ -317,8 +314,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'args' do
-
+ context 'with args' do
it 'passes a token as an argument when a token is present' do
Jobs::UserEmail.new.execute(type: :forgot_password, user_id: user.id, email_token: 'asdfasdf')
@@ -328,7 +324,7 @@ RSpec.describe Jobs::UserEmail do
expect(mail.body).to include("asdfasdf")
end
- context "confirm_new_email" do
+ context "with confirm_new_email" do
let(:email_token) { Fabricate(:email_token, user: user) }
before do
EmailChangeRequest.create!(
@@ -368,7 +364,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context "post" do
+ context "with post" do
fab!(:post) { Fabricate(:post, user: user) }
it "doesn't send the email if you've seen the post" do
@@ -392,7 +388,7 @@ RSpec.describe Jobs::UserEmail do
expect(ActionMailer::Base.deliveries).to eq([])
end
- context 'user is suspended' do
+ context 'when user is suspended' do
it "doesn't send email for a pm from a regular user" do
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: suspended.id, post_id: post.id)
@@ -443,7 +439,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'user is anonymous' do
+ context 'when user is anonymous' do
before { SiteSetting.allow_anonymous_posting = true }
it "doesn't send email for a pm from a regular user" do
@@ -462,7 +458,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'notification' do
+ context 'with notification' do
fab!(:post) { Fabricate(:post, user: user) }
fab!(:notification) {
Fabricate(:notification,
@@ -541,7 +537,7 @@ RSpec.describe Jobs::UserEmail do
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(user.email)
end
- context "recently seen" do
+ context "when recently seen" do
it "doesn't send an email to a user that's been recently seen" do
user.update!(last_seen_at: 9.minutes.ago)
@@ -572,7 +568,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'max_emails_per_day_per_user limit is reached' do
+ context 'when max_emails_per_day_per_user limit is reached' do
before do
SiteSetting.max_emails_per_day_per_user = 2
2.times { Fabricate(:email_log, user: user, email_type: 'blah', to_address: user.email) }
@@ -718,7 +714,7 @@ RSpec.describe Jobs::UserEmail do
expect(ActionMailer::Base.deliveries).to eq([])
end
- context 'user is suspended' do
+ context 'when user is suspended' do
it "doesn't send email for a pm from a regular user" do
msg, err = Jobs::UserEmail.new.message_for_email(
suspended,
@@ -731,7 +727,7 @@ RSpec.describe Jobs::UserEmail do
expect(err).not_to eq(nil)
end
- context 'pm from staff' do
+ context 'with pm from staff' do
before do
@pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
@pm_from_staff.topic.topic_allowed_users.create!(user_id: suspended.id)
@@ -768,7 +764,7 @@ RSpec.describe Jobs::UserEmail do
end
end
- context 'user is anonymous' do
+ context 'when user is anonymous' do
before { SiteSetting.allow_anonymous_posting = true }
it "doesn't send email for a pm from a regular user" do
@@ -802,6 +798,5 @@ RSpec.describe Jobs::UserEmail do
end
end
end
-
end
end
diff --git a/spec/lib/admin_user_index_query_spec.rb b/spec/lib/admin_user_index_query_spec.rb
index d9519d33eaa..4bce40f83e4 100644
--- a/spec/lib/admin_user_index_query_spec.rb
+++ b/spec/lib/admin_user_index_query_spec.rb
@@ -100,7 +100,7 @@ RSpec.describe AdminUserIndexQuery do
expect(query.find_users).not_to include(inactive_user)
end
- context 'and a suspended pending user' do
+ context 'with a suspended pending user' do
fab!(:suspended_user) { Fabricate(:user, approved: false, suspended_at: 1.hour.ago, suspended_till: 20.years.from_now) }
it "doesn't return the suspended user" do
query = ::AdminUserIndexQuery.new(query: 'pending')
@@ -182,7 +182,7 @@ RSpec.describe AdminUserIndexQuery do
describe "filtering" do
- context "exact email bypass" do
+ context "with exact email bypass" do
it "can correctly bypass expensive ilike query" do
user = Fabricate(:user, email: '[email protected]')
@@ -208,7 +208,7 @@ RSpec.describe AdminUserIndexQuery do
end
end
- context "by email fragment" do
+ context "with email fragment" do
before(:each) { Fabricate(:user, email: "[email protected]") }
@@ -224,7 +224,7 @@ RSpec.describe AdminUserIndexQuery do
end
- context "by username fragment" do
+ context "with username fragment" do
before(:each) { Fabricate(:user, username: "test_user_1") }
@@ -239,7 +239,7 @@ RSpec.describe AdminUserIndexQuery do
end
end
- context "by ip address fragment" do
+ context "with ip address fragment" do
fab!(:user) { Fabricate(:user, ip_address: "117.207.94.9") }
diff --git a/spec/lib/archetype_spec.rb b/spec/lib/archetype_spec.rb
index 1f662c7b891..9b5a6b6945b 100644
--- a/spec/lib/archetype_spec.rb
+++ b/spec/lib/archetype_spec.rb
@@ -4,9 +4,7 @@
require 'archetype'
RSpec.describe Archetype do
-
- context 'default archetype' do
-
+ describe 'default archetype' do
it 'has an Archetype by default' do
expect(Archetype.list).to be_present
end
@@ -15,8 +13,7 @@ RSpec.describe Archetype do
expect(Archetype.list.first.id).to eq(Archetype.default)
end
- context 'duplicate' do
-
+ context 'with duplicate' do
before do
@old_size = Archetype.list.size
Archetype.register(Archetype.default)
@@ -25,20 +22,15 @@ RSpec.describe Archetype do
it 'does not add the same archetype twice' do
expect(Archetype.list.size).to eq(@old_size)
end
-
end
-
end
- context 'register an archetype' do
-
+ describe 'register an archetype' do
it 'has one more element' do
@list = Archetype.list.dup
Archetype.register('glados')
expect(Archetype.list.size).to eq(@list.size + 1)
expect(Archetype.list.find { |a| a.id == 'glados' }).to be_present
end
-
end
-
end
diff --git a/spec/lib/auth/default_current_user_provider_spec.rb b/spec/lib/auth/default_current_user_provider_spec.rb
index b26d91afa97..bd470e547e7 100644
--- a/spec/lib/auth/default_current_user_provider_spec.rb
+++ b/spec/lib/auth/default_current_user_provider_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
expect(provider.current_user).to eq(nil)
end
- context "server header api" do
+ describe "server header api" do
it "raises for a revoked key" do
api_key = ApiKey.create!
params = { "HTTP_API_USERNAME" => user.username.downcase, "HTTP_API_KEY" => api_key.key }
@@ -214,7 +214,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
end
- context "rate limiting" do
+ context "with rate limiting" do
before do
RateLimiter.enable
end
@@ -435,7 +435,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
- context "events" do
+ describe "events" do
before do
@refreshes = 0
@@ -472,8 +472,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
end
- context "rate limiting" do
-
+ describe "rate limiting" do
before do
RateLimiter.enable
end
@@ -622,7 +621,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
expect(user.staged).to eq(false)
end
- context "user api" do
+ describe "user api" do
fab! :user do
Fabricate(:user)
end
@@ -705,8 +704,7 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
end
end
- context "rate limiting" do
-
+ context "with rate limiting" do
before do
RateLimiter.enable
end
diff --git a/spec/lib/auth/discord_authenticator_spec.rb b/spec/lib/auth/discord_authenticator_spec.rb
index ab925bedc76..cff7c662f49 100644
--- a/spec/lib/auth/discord_authenticator_spec.rb
+++ b/spec/lib/auth/discord_authenticator_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Auth::DiscordAuthenticator do
let(:authenticator) { described_class.new }
- context 'after_authenticate' do
+ describe 'after_authenticate' do
it 'works normally' do
result = authenticator.after_authenticate(hash)
expect(result.user).to eq(nil)
diff --git a/spec/lib/auth/facebook_authenticator_spec.rb b/spec/lib/auth/facebook_authenticator_spec.rb
index 8237d3a67d0..4a39fe5c469 100644
--- a/spec/lib/auth/facebook_authenticator_spec.rb
+++ b/spec/lib/auth/facebook_authenticator_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Auth::FacebookAuthenticator do
let(:authenticator) { Auth::FacebookAuthenticator.new }
- context 'after_authenticate' do
+ describe 'after_authenticate' do
it 'can authenticate and create a user record for already existing users' do
user = Fabricate(:user)
result = authenticator.after_authenticate(hash.deep_merge(info: { email: user.email }))
@@ -46,7 +46,7 @@ RSpec.describe Auth::FacebookAuthenticator do
end
end
- context 'description_for_user' do
+ describe 'description_for_user' do
fab!(:user) { Fabricate(:user) }
it 'returns empty string if no entry for user' do
@@ -59,7 +59,7 @@ RSpec.describe Auth::FacebookAuthenticator do
end
end
- context 'revoke' do
+ describe 'revoke' do
fab!(:user) { Fabricate(:user) }
let(:authenticator) { Auth::FacebookAuthenticator.new }
@@ -82,5 +82,4 @@ RSpec.describe Auth::FacebookAuthenticator do
end
end
end
-
end
diff --git a/spec/lib/auth/github_authenticator_spec.rb b/spec/lib/auth/github_authenticator_spec.rb
index ce2dc264921..15020a96367 100644
--- a/spec/lib/auth/github_authenticator_spec.rb
+++ b/spec/lib/auth/github_authenticator_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Auth::GithubAuthenticator do
let(:authenticator) { described_class.new }
fab!(:user) { Fabricate(:user) }
- context 'after_authenticate' do
+ describe 'after_authenticate' do
let(:data) { auth_token_for(user) }
it 'can authenticate and create a user record for already existing users' do
@@ -247,10 +247,9 @@ RSpec.describe Auth::GithubAuthenticator do
expect(UserAssociatedAccount.exists?(user_id: user1.id)).to eq(false)
expect(UserAssociatedAccount.exists?(user_id: user2.id)).to eq(true)
end
-
end
- context 'revoke' do
+ describe 'revoke' do
fab!(:user) { Fabricate(:user) }
let(:authenticator) { Auth::GithubAuthenticator.new }
@@ -258,13 +257,12 @@ RSpec.describe Auth::GithubAuthenticator do
expect { authenticator.revoke(user) }.to raise_error(Discourse::NotFound)
end
- it 'revokes correctly' do
- UserAssociatedAccount.create!(provider_name: "github", user_id: user.id, provider_uid: 100, info: { nickname: "boris" })
- expect(authenticator.can_revoke?).to eq(true)
- expect(authenticator.revoke(user)).to eq(true)
- expect(authenticator.description_for_user(user)).to eq("")
- end
-
+ it 'revokes correctly' do
+ UserAssociatedAccount.create!(provider_name: "github", user_id: user.id, provider_uid: 100, info: { nickname: "boris" })
+ expect(authenticator.can_revoke?).to eq(true)
+ expect(authenticator.revoke(user)).to eq(true)
+ expect(authenticator.description_for_user(user)).to eq("")
+ end
end
describe 'avatar retrieval' do
diff --git a/spec/lib/auth/google_oauth2_authenticator_spec.rb b/spec/lib/auth/google_oauth2_authenticator_spec.rb
index e00b51d40c0..661ef1f25c5 100644
--- a/spec/lib/auth/google_oauth2_authenticator_spec.rb
+++ b/spec/lib/auth/google_oauth2_authenticator_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
expect(result.user).to eq(nil)
end
- context 'after_authenticate' do
+ describe 'after_authenticate' do
it 'can authenticate and create a user record for already existing users' do
authenticator = Auth::GoogleOAuth2Authenticator.new
user = Fabricate(:user)
@@ -111,7 +111,7 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
expect(result.name).to eq("Jane Doe")
end
- context "provides groups" do
+ describe "provides groups" do
before do
SiteSetting.google_oauth2_hd = "domain.com"
group1 = OmniAuth::AuthHash.new(id: "12345", name: "group1")
@@ -137,7 +137,7 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
)
end
- context "enabled" do
+ context "when enabled" do
before do
SiteSetting.google_oauth2_hd_groups = true
end
@@ -154,7 +154,7 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
end
end
- context "disabled" do
+ context "when disabled" do
before do
SiteSetting.google_oauth2_hd_groups = false
end
@@ -167,7 +167,7 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
end
end
- context 'revoke' do
+ describe 'revoke' do
fab!(:user) { Fabricate(:user) }
let(:authenticator) { Auth::GoogleOAuth2Authenticator.new }
@@ -175,12 +175,11 @@ RSpec.describe Auth::GoogleOAuth2Authenticator do
expect { authenticator.revoke(user) }.to raise_error(Discourse::NotFound)
end
- it 'revokes correctly' do
- UserAssociatedAccount.create!(provider_name: "google_oauth2", user_id: user.id, provider_uid: 12345)
- expect(authenticator.can_revoke?).to eq(true)
- expect(authenticator.revoke(user)).to eq(true)
- expect(authenticator.description_for_user(user)).to eq("")
- end
-
+ it 'revokes correctly' do
+ UserAssociatedAccount.create!(provider_name: "google_oauth2", user_id: user.id, provider_uid: 12345)
+ expect(authenticator.can_revoke?).to eq(true)
+ expect(authenticator.revoke(user)).to eq(true)
+ expect(authenticator.description_for_user(user)).to eq("")
+ end
end
end
diff --git a/spec/lib/auth/omniauth_strategies/discourse_google_oauth2_spec.rb b/spec/lib/auth/omniauth_strategies/discourse_google_oauth2_spec.rb
index db4adc1c26b..37229ecae44 100644
--- a/spec/lib/auth/omniauth_strategies/discourse_google_oauth2_spec.rb
+++ b/spec/lib/auth/omniauth_strategies/discourse_google_oauth2_spec.rb
@@ -85,12 +85,12 @@ RSpec.describe Auth::OmniAuthStrategies::DiscourseGoogleOauth2 do
OmniAuth.config.test_mode = false
end
- context 'request_groups is true' do
+ context 'when request_groups is true' do
before do
@options[:request_groups] = true
end
- context 'groups request successful' do
+ context 'when groups request successful' do
before do
@strategy = build_strategy(successful_groups_token)
end
@@ -100,7 +100,7 @@ RSpec.describe Auth::OmniAuthStrategies::DiscourseGoogleOauth2 do
end
end
- context 'groups request unsuccessful' do
+ context 'when groups request unsuccessful' do
before do
@strategy = build_strategy(unsuccessful_groups_token)
end
@@ -111,7 +111,7 @@ RSpec.describe Auth::OmniAuthStrategies::DiscourseGoogleOauth2 do
end
end
- context 'request_groups is not true' do
+ context 'when request_groups is not true' do
before do
@options[:request_groups] = false
@strategy = build_strategy(successful_groups_token)
diff --git a/spec/lib/auth/twitter_authenticator_spec.rb b/spec/lib/auth/twitter_authenticator_spec.rb
index 0e2863c3f43..14f5c834a6a 100644
--- a/spec/lib/auth/twitter_authenticator_spec.rb
+++ b/spec/lib/auth/twitter_authenticator_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Auth::TwitterAuthenticator do
-
it "takes over account if email is supplied" do
auth = Auth::TwitterAuthenticator.new
@@ -51,7 +50,7 @@ RSpec.describe Auth::TwitterAuthenticator do
expect(UserAssociatedAccount.exists?(provider_name: "twitter", user_id: user2.id)).to eq(true)
end
- context 'revoke' do
+ describe 'revoke' do
fab!(:user) { Fabricate(:user) }
let(:authenticator) { Auth::TwitterAuthenticator.new }
@@ -65,7 +64,5 @@ RSpec.describe Auth::TwitterAuthenticator do
expect(authenticator.revoke(user)).to eq(true)
expect(authenticator.description_for_user(user)).to eq("")
end
-
end
-
end
diff --git a/spec/lib/backup_restore/backup_file_handler_multisite_spec.rb b/spec/lib/backup_restore/backup_file_handler_multisite_spec.rb
index c7d44170936..5a0b1f6de1c 100644
--- a/spec/lib/backup_restore/backup_file_handler_multisite_spec.rb
+++ b/spec/lib/backup_restore/backup_file_handler_multisite_spec.rb
@@ -3,7 +3,7 @@
require_relative "shared_context_for_backup_restore"
RSpec.describe BackupRestore::BackupFileHandler, type: :multisite do
- include_context "shared stuff"
+ include_context "with shared stuff"
it "works with old backup file format" do
test_multisite_connection("second") do
diff --git a/spec/lib/backup_restore/backup_file_handler_spec.rb b/spec/lib/backup_restore/backup_file_handler_spec.rb
index 5b35a6c4ffe..8803de78908 100644
--- a/spec/lib/backup_restore/backup_file_handler_spec.rb
+++ b/spec/lib/backup_restore/backup_file_handler_spec.rb
@@ -3,7 +3,7 @@
require_relative 'shared_context_for_backup_restore'
RSpec.describe BackupRestore::BackupFileHandler do
- include_context "shared stuff"
+ include_context "with shared stuff"
it "works with current backup file format" do
expect_decompress_and_clean_up_to_work(
diff --git a/spec/lib/backup_restore/database_restorer_multisite_spec.rb b/spec/lib/backup_restore/database_restorer_multisite_spec.rb
index ec3fc81954c..19044c1f726 100644
--- a/spec/lib/backup_restore/database_restorer_multisite_spec.rb
+++ b/spec/lib/backup_restore/database_restorer_multisite_spec.rb
@@ -3,14 +3,14 @@
require_relative "shared_context_for_backup_restore"
RSpec.describe BackupRestore::DatabaseRestorer, type: :multisite do
- include_context "shared stuff"
+ include_context "with shared stuff"
let(:current_db) { RailsMultisite::ConnectionManagement.current_db }
subject { BackupRestore::DatabaseRestorer.new(logger, current_db) }
describe "#restore" do
- context "database connection" do
+ context "with database connection" do
it "reconnects to the correct database" do
RailsMultisite::ConnectionManagement.establish_connection(db: "second")
execute_stubbed_restore
diff --git a/spec/lib/backup_restore/database_restorer_spec.rb b/spec/lib/backup_restore/database_restorer_spec.rb
index 1f2de1a8efd..e8d69c0723c 100644
--- a/spec/lib/backup_restore/database_restorer_spec.rb
+++ b/spec/lib/backup_restore/database_restorer_spec.rb
@@ -3,7 +3,7 @@
require_relative 'shared_context_for_backup_restore'
RSpec.describe BackupRestore::DatabaseRestorer do
- include_context "shared stuff"
+ include_context "with shared stuff"
let(:current_db) { RailsMultisite::ConnectionManagement.current_db }
@@ -79,7 +79,7 @@ RSpec.describe BackupRestore::DatabaseRestorer do
end
end
- context "rewrites database dump" do
+ describe "rewrites database dump" do
let(:logger) do
Class.new do
attr_reader :log_messages
@@ -124,7 +124,7 @@ RSpec.describe BackupRestore::DatabaseRestorer do
end
end
- context "database connection" do
+ describe "database connection" do
it 'it is not erroring for non-multisite' do
expect { execute_stubbed_restore }.not_to raise_error
end
@@ -144,7 +144,7 @@ RSpec.describe BackupRestore::DatabaseRestorer do
end
end
- context "readonly functions" do
+ describe "readonly functions" do
before do
BackupRestore::DatabaseRestorer.stubs(:core_migration_files).returns(
Dir[Rails.root.join("spec/fixtures/db/post_migrate/drop_column/**/*.rb")]
diff --git a/spec/lib/backup_restore/meta_data_handler_spec.rb b/spec/lib/backup_restore/meta_data_handler_spec.rb
index 6ea18c48373..9dd08f0e822 100644
--- a/spec/lib/backup_restore/meta_data_handler_spec.rb
+++ b/spec/lib/backup_restore/meta_data_handler_spec.rb
@@ -3,7 +3,7 @@
require_relative 'shared_context_for_backup_restore'
RSpec.describe BackupRestore::MetaDataHandler do
- include_context "shared stuff"
+ include_context "with shared stuff"
let!(:backup_filename) { 'discourse-2019-11-18-143242-v20191108000414.tar.gz' }
@@ -22,7 +22,7 @@ RSpec.describe BackupRestore::MetaDataHandler do
BackupRestore::MetaDataHandler.new(logger, filename, tmp_directory).validate
end
- context "metadata file" do
+ describe "metadata file" do
it "extracts metadata from file when metadata file exists" do
metadata = '{"source":"discourse","version":20160329101122}'
@@ -67,7 +67,7 @@ RSpec.describe BackupRestore::MetaDataHandler do
end
end
- context "filename" do
+ describe "filename" do
it "extracts metadata from filename when metadata file does not exist" do
with_metadata_file(nil) do |dir|
expect(validate_metadata(backup_filename, dir))
diff --git a/spec/lib/backup_restore/s3_backup_store_spec.rb b/spec/lib/backup_restore/s3_backup_store_spec.rb
index dbe62f6c460..4aad803cfd4 100644
--- a/spec/lib/backup_restore/s3_backup_store_spec.rb
+++ b/spec/lib/backup_restore/s3_backup_store_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe BackupRestore::S3BackupStore do
it_behaves_like "backup store"
it_behaves_like "remote backup store"
- context "S3 specific behavior" do
+ describe "S3 specific behavior" do
before { create_backups }
after { remove_backups }
diff --git a/spec/lib/backup_restore/shared_context_for_backup_restore.rb b/spec/lib/backup_restore/shared_context_for_backup_restore.rb
index 66047d1bc38..5ad59e604f1 100644
--- a/spec/lib/backup_restore/shared_context_for_backup_restore.rb
+++ b/spec/lib/backup_restore/shared_context_for_backup_restore.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.shared_context "shared stuff" do
+RSpec.shared_context "with shared stuff" do
let!(:logger) do
Class.new do
def log(message, ex = nil); end
diff --git a/spec/lib/backup_restore/shared_examples_for_backup_store.rb b/spec/lib/backup_restore/shared_examples_for_backup_store.rb
index b65dadd9d88..eeb8ee2e053 100644
--- a/spec/lib/backup_restore/shared_examples_for_backup_store.rb
+++ b/spec/lib/backup_restore/shared_examples_for_backup_store.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# rubocop:disable Discourse/OnlyTopLevelMultisiteSpecs
-RSpec.shared_context "backups" do
+RSpec.shared_context "with backups" do
before { create_backups }
after { remove_backups }
@@ -46,7 +46,7 @@ RSpec.shared_examples "backup store" do
end
context "with backup files" do
- include_context "backups"
+ include_context "with backups"
describe "#files" do
it "sorts files by last modified date in descending order" do
@@ -214,7 +214,7 @@ RSpec.shared_examples "remote backup store" do
end
context "with backups" do
- include_context "backups"
+ include_context "with backups"
describe "#upload_file" do
def upload_file
diff --git a/spec/lib/backup_restore/system_interface_multisite_spec.rb b/spec/lib/backup_restore/system_interface_multisite_spec.rb
index 6587a716697..e9d93e6e3f1 100644
--- a/spec/lib/backup_restore/system_interface_multisite_spec.rb
+++ b/spec/lib/backup_restore/system_interface_multisite_spec.rb
@@ -3,7 +3,7 @@
require_relative "shared_context_for_backup_restore"
RSpec.describe BackupRestore::SystemInterface, type: :multisite do
- include_context "shared stuff"
+ include_context "with shared stuff"
subject { BackupRestore::SystemInterface.new(logger) }
diff --git a/spec/lib/backup_restore/system_interface_spec.rb b/spec/lib/backup_restore/system_interface_spec.rb
index 8c5c295c2f8..20a701d8d32 100644
--- a/spec/lib/backup_restore/system_interface_spec.rb
+++ b/spec/lib/backup_restore/system_interface_spec.rb
@@ -3,11 +3,11 @@
require_relative 'shared_context_for_backup_restore'
RSpec.describe BackupRestore::SystemInterface do
- include_context "shared stuff"
+ include_context "with shared stuff"
subject { BackupRestore::SystemInterface.new(logger) }
- context "readonly mode" do
+ describe "readonly mode" do
after do
Discourse::READONLY_KEYS.each { |key| Discourse.redis.del(key) }
end
@@ -171,7 +171,7 @@ RSpec.describe BackupRestore::SystemInterface do
end
describe "#flush_redis" do
- context "Sidekiq" do
+ context "with Sidekiq" do
after { Sidekiq.unpause! }
it "doesn't unpause Sidekiq" do
diff --git a/spec/lib/backup_restore/uploads_restorer_spec.rb b/spec/lib/backup_restore/uploads_restorer_spec.rb
index 0b55fbeeba5..3314358e9e4 100644
--- a/spec/lib/backup_restore/uploads_restorer_spec.rb
+++ b/spec/lib/backup_restore/uploads_restorer_spec.rb
@@ -4,7 +4,7 @@
require_relative 'shared_context_for_backup_restore'
RSpec.describe BackupRestore::UploadsRestorer do
- include_context "shared stuff"
+ include_context "with shared stuff"
subject { BackupRestore::UploadsRestorer.new(logger) }
@@ -94,7 +94,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
Regexp.escape("//#{bucket}") + %q*\.s3(?:\.dualstack\.[a-z0-9\-]+?|[.\-][a-z0-9\-]+?)?\.amazonaws\.com* + Regexp.escape(path)
end
- context "uploads" do
+ describe "uploads" do
let!(:multisite) { { name: "multisite", value: true } }
let!(:no_multisite) { { name: "multisite", value: false } }
let!(:source_db_name) { { name: "db_name", value: "foo" } }
@@ -104,7 +104,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
let(:target_site_name) { target_site_type == multisite ? "second" : "default" }
let(:target_hostname) { target_site_type == multisite ? "test2.localhost" : "test.localhost" }
- shared_context "no uploads" do
+ shared_context "with no uploads" do
it "does nothing when temporary uploads directory is missing or empty" do
store_class.any_instance.expects(:copy_from).never
@@ -132,7 +132,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- shared_context "restores uploads" do
+ shared_context "when restoring uploads" do
before do
Upload.where("id > 0").destroy_all
Fabricate(:optimized_image)
@@ -242,34 +242,34 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "currently stored locally" do
+ context "when currently stored locally" do
before do
SiteSetting.enable_s3_uploads = false
end
let!(:store_class) { FileStore::LocalStore }
- include_context "no uploads"
- include_context "restores uploads"
+ include_context "with no uploads"
+ include_context "when restoring uploads"
- context "remaps" do
+ context "with remaps" do
include_examples "without metadata"
- context "uploads previously stored locally" do
+ context "when uploads previously stored locally" do
let!(:s3_base_url) { { name: "s3_base_url", value: nil } }
let!(:s3_cdn_url) { { name: "s3_cdn_url", value: nil } }
- context "from regular site" do
+ context "with regular site as source" do
let!(:source_site_type) { no_multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "remaps from local storage"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { multisite }
include_examples "common remaps"
@@ -277,17 +277,17 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from multisite" do
+ context "with multisite as source" do
let!(:source_site_type) { multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "remaps from local storage"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { multisite }
include_examples "common remaps"
@@ -296,7 +296,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "uploads previously stored on S3" do
+ context "with uploads previously stored on S3" do
let!(:s3_base_url) { { name: "s3_base_url", value: "//old-bucket.s3-us-east-1.amazonaws.com" } }
let!(:s3_cdn_url) { { name: "s3_cdn_url", value: "https://s3-cdn.example.com" } }
@@ -346,17 +346,17 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from regular site" do
+ context "with regular site as source" do
let!(:source_site_type) { no_multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "regular site remaps from S3"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { multisite }
include_examples "common remaps"
@@ -364,17 +364,17 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from multisite" do
+ context "with multisite as source" do
let!(:source_site_type) { multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "multisite remaps from S3"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
@@ -385,34 +385,34 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "currently stored on S3" do
+ context "when currently stored on S3" do
before do
setup_s3
end
let!(:store_class) { FileStore::S3Store }
- include_context "no uploads"
- include_context "restores uploads"
+ include_context "with no uploads"
+ include_context "when restoring uploads"
- context "remaps" do
+ context "with remaps" do
include_examples "without metadata"
- context "uploads previously stored locally" do
+ context "with uploads previously stored locally" do
let!(:s3_base_url) { { name: "s3_base_url", value: nil } }
let!(:s3_cdn_url) { { name: "s3_cdn_url", value: nil } }
- context "from regular site" do
+ context "with regular site as source" do
let!(:source_site_type) { no_multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "remaps from local storage"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
@@ -420,17 +420,17 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from multisite" do
+ context "with multisite as source" do
let!(:source_site_type) { multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "remaps from local storage"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { multisite }
include_examples "common remaps"
@@ -439,7 +439,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "uploads previously stored on S3" do
+ context "with uploads previously stored on S3" do
let!(:s3_base_url) { { name: "s3_base_url", value: "//old-bucket.s3-us-east-1.amazonaws.com" } }
let!(:s3_cdn_url) { { name: "s3_cdn_url", value: "https://s3-cdn.example.com" } }
@@ -510,10 +510,10 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from regular site" do
+ context "with regular site as source" do
let!(:source_site_type) { no_multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_name) { "default" }
let!(:target_hostname) { "test.localhost" }
@@ -521,7 +521,7 @@ RSpec.describe BackupRestore::UploadsRestorer do
include_examples "regular site remaps from S3"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_name) { "second" }
let!(:target_hostname) { "test2.localhost" }
@@ -530,17 +530,17 @@ RSpec.describe BackupRestore::UploadsRestorer do
end
end
- context "from multisite" do
+ context "with multisite as source" do
let!(:source_site_type) { multisite }
- context "to regular site" do
+ context "with regular site as target" do
let!(:target_site_type) { no_multisite }
include_examples "common remaps"
include_examples "multisite remaps from S3"
end
- context "to multisite", type: :multisite do
+ context "with multisite as target", type: :multisite do
let!(:target_site_type) { multisite }
include_examples "common remaps"
diff --git a/spec/lib/common_passwords/common_passwords_spec.rb b/spec/lib/common_passwords/common_passwords_spec.rb
index 8d3ebf2499d..fba5e6804f8 100644
--- a/spec/lib/common_passwords/common_passwords_spec.rb
+++ b/spec/lib/common_passwords/common_passwords_spec.rb
@@ -61,7 +61,7 @@ RSpec.describe CommonPasswords do
end
end
- context "missing password file" do
+ describe "missing password file" do
it "tolerates it" do
File.stubs(:readlines).with(described_class::PASSWORD_FILE).raises(Errno::ENOENT)
expect(described_class.common_password?("password")).to eq(false)
diff --git a/spec/lib/composer_messages_finder_spec.rb b/spec/lib/composer_messages_finder_spec.rb
index e52ff3e73f3..e6bbac2144c 100644
--- a/spec/lib/composer_messages_finder_spec.rb
+++ b/spec/lib/composer_messages_finder_spec.rb
@@ -4,8 +4,7 @@
require 'composer_messages_finder'
RSpec.describe ComposerMessagesFinder do
-
- context "delegates work" do
+ describe "delegates work" do
let(:user) { Fabricate.build(:user) }
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') }
@@ -19,13 +18,12 @@ RSpec.describe ComposerMessagesFinder do
finder.expects(:check_get_a_room).once
finder.find
end
-
end
describe '.check_education_message' do
let(:user) { Fabricate.build(:user) }
- context 'creating topic' do
+ context 'when creating topic' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') }
before do
@@ -43,10 +41,10 @@ RSpec.describe ComposerMessagesFinder do
end
end
- context 'private message' do
+ context 'with private message' do
fab!(:topic) { Fabricate(:private_message_topic) }
- context 'starting a new private message' do
+ context 'when starting a new private message' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic', topic_id: topic.id) }
it 'should return an empty string' do
@@ -54,7 +52,7 @@ RSpec.describe ComposerMessagesFinder do
end
end
- context 'replying to a private message' do
+ context 'when replying to a private message' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id) }
it 'should return an empty string' do
@@ -63,7 +61,7 @@ RSpec.describe ComposerMessagesFinder do
end
end
- context 'creating reply' do
+ context 'when creating reply' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply') }
before do
@@ -85,7 +83,7 @@ RSpec.describe ComposerMessagesFinder do
describe '.check_new_user_many_replies' do
let(:user) { Fabricate.build(:user) }
- context 'replying' do
+ context 'when replying' do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply') }
it "has no message when `posted_too_much_in_topic?` is false" do
@@ -105,7 +103,7 @@ RSpec.describe ComposerMessagesFinder do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') }
fab!(:user) { Fabricate(:user) }
- context "success" do
+ context "with success" do
let!(:message) { finder.check_avatar_notification }
it "returns an avatar upgrade message" do
@@ -174,7 +172,7 @@ RSpec.describe ComposerMessagesFinder do
expect(ComposerMessagesFinder.new(user, composer_action: 'reply').check_sequential_replies).to be_blank
end
- context "reply" do
+ context "with reply" do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id) }
it "does not give a message to users who are still in the 'education' phase" do
@@ -207,7 +205,7 @@ RSpec.describe ComposerMessagesFinder do
expect(finder.check_sequential_replies).to be_blank
end
- context "success" do
+ context "with success" do
let!(:message) { finder.check_sequential_replies }
it "returns a message" do
@@ -249,7 +247,7 @@ RSpec.describe ComposerMessagesFinder do
expect(ComposerMessagesFinder.new(user, composer_action: 'reply').check_dominating_topic).to be_blank
end
- context "reply" do
+ context "with reply" do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id) }
it "does not give a message to users who are still in the 'education' phase" do
@@ -292,7 +290,7 @@ RSpec.describe ComposerMessagesFinder do
expect(finder.check_dominating_topic).to be_blank
end
- context "success" do
+ context "with success" do
let!(:message) { finder.check_dominating_topic }
it "returns a message" do
@@ -349,7 +347,7 @@ RSpec.describe ComposerMessagesFinder do
expect(UserHistory.exists_for_user?(user, :notified_about_get_a_room)).to eq(false)
end
- context "reply" do
+ context "with reply" do
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply', topic_id: topic.id, post_id: op.id) }
it "does not give a message to users who are still in the 'education' phase" do
@@ -415,7 +413,7 @@ RSpec.describe ComposerMessagesFinder do
end
end
- context "success" do
+ context "with success" do
let!(:message) { finder.check_get_a_room(min_users_posted: 2) }
it "works as expected" do
@@ -440,8 +438,8 @@ RSpec.describe ComposerMessagesFinder do
expect(described_class.new(user, composer_action: 'reply').check_reviving_old_topic).to be_blank
end
- context "a reply" do
- context "warn_reviving_old_topic_age is 180 days" do
+ context "with a reply" do
+ context "when warn_reviving_old_topic_age is 180 days" do
before do
SiteSetting.warn_reviving_old_topic_age = 180
end
@@ -459,7 +457,7 @@ RSpec.describe ComposerMessagesFinder do
end
end
- context "warn_reviving_old_topic_age is 0" do
+ context "when warn_reviving_old_topic_age is 0" do
before do
SiteSetting.warn_reviving_old_topic_age = 0
end
@@ -503,5 +501,4 @@ RSpec.describe ComposerMessagesFinder do
expect(edit_post_finder.find).to eq(nil)
end
end
-
end
diff --git a/spec/lib/compression/engine_spec.rb b/spec/lib/compression/engine_spec.rb
index 913c5da0728..6e96e5a226f 100644
--- a/spec/lib/compression/engine_spec.rb
+++ b/spec/lib/compression/engine_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe Compression::Engine do
end
end
- context 'working with zip files' do
+ context 'when working with zip files' do
let(:extension) { '.zip' }
it 'decompress the folder and inspect files correctly' do
@@ -43,7 +43,7 @@ RSpec.describe Compression::Engine do
end
end
- context 'working with .tar.gz files' do
+ context 'when working with .tar.gz files' do
let(:extension) { '.tar.gz' }
it 'decompress the folder and inspect files correctly' do
@@ -56,7 +56,7 @@ RSpec.describe Compression::Engine do
end
end
- context 'working with .tar files' do
+ context 'when working with .tar files' do
let(:extension) { '.tar' }
it 'decompress the folder and inspect files correctly' do
diff --git a/spec/lib/concern/cached_counting_spec.rb b/spec/lib/concern/cached_counting_spec.rb
index 44976a37374..260744902d5 100644
--- a/spec/lib/concern/cached_counting_spec.rb
+++ b/spec/lib/concern/cached_counting_spec.rb
@@ -15,13 +15,11 @@ class TestCachedCounting
end
RSpec.describe CachedCounting do
-
it "should be default disabled in test" do
expect(CachedCounting.enabled?).to eq(false)
end
- context "backing implementation" do
-
+ describe "backing implementation" do
it "can correctly check for flush to db lock" do
CachedCounting.clear_flush_to_db_lock!
@@ -55,7 +53,7 @@ RSpec.describe CachedCounting do
end
end
- context "active record" do
+ describe "active record" do
class RailsCacheCounter < ActiveRecord::Base
include CachedCounting
self.table_name = "posts"
diff --git a/spec/lib/concern/category_hashtag_spec.rb b/spec/lib/concern/category_hashtag_spec.rb
index 94bcb3f7d08..57d687beb20 100644
--- a/spec/lib/concern/category_hashtag_spec.rb
+++ b/spec/lib/concern/category_hashtag_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe CategoryHashtag do
expect(Category.query_from_hashtag_slug("non-existent#{CategoryHashtag::SEPARATOR}#{parent_category.slug}")).to eq(nil)
end
- context "multi-level categories" do
+ context "with multi-level categories" do
before do
SiteSetting.max_category_nesting = 3
end
diff --git a/spec/lib/concern/has_custom_fields_spec.rb b/spec/lib/concern/has_custom_fields_spec.rb
index 698d82604cd..af0bbaebd81 100644
--- a/spec/lib/concern/has_custom_fields_spec.rb
+++ b/spec/lib/concern/has_custom_fields_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe HasCustomFields do
- context "custom_fields" do
+ describe "custom_fields" do
before do
DB.exec("create temporary table custom_fields_test_items(id SERIAL primary key)")
DB.exec("create temporary table custom_fields_test_item_custom_fields(id SERIAL primary key, custom_fields_test_item_id int, name varchar(256) not null, value text, created_at TIMESTAMP, updated_at TIMESTAMP)")
diff --git a/spec/lib/concern/has_search_data_spec.rb b/spec/lib/concern/has_search_data_spec.rb
index e0a0583af1c..74f4fbb66d3 100644
--- a/spec/lib/concern/has_search_data_spec.rb
+++ b/spec/lib/concern/has_search_data_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe HasSearchData do
- context "belongs to its model" do
+ describe "belongs to its model" do
before do
DB.exec("create temporary table model_items(id SERIAL primary key)")
DB.exec("create temporary table model_item_search_data(model_item_id int primary key, search_data tsvector, raw_data text, locale text)")
diff --git a/spec/lib/concern/positionable_spec.rb b/spec/lib/concern/positionable_spec.rb
index b491ab10902..f4a57463867 100644
--- a/spec/lib/concern/positionable_spec.rb
+++ b/spec/lib/concern/positionable_spec.rb
@@ -1,12 +1,11 @@
# frozen_string_literal: true
RSpec.describe Positionable do
-
def positions
TestItem.order('position asc, id asc').pluck(:id)
end
- context "move_to" do
+ describe "move_to" do
before do
class TestItem < ActiveRecord::Base
include Positionable
diff --git a/spec/lib/concern/searchable_spec.rb b/spec/lib/concern/searchable_spec.rb
index 75e3cafa08d..b92b0eb4af8 100644
--- a/spec/lib/concern/searchable_spec.rb
+++ b/spec/lib/concern/searchable_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Searchable do
- context "has search data" do
+ describe "has search data" do
before do
DB.exec("create temporary table searchable_records(id SERIAL primary key)")
DB.exec("create temporary table searchable_record_search_data(searchable_record_id int primary key, search_data tsvector, raw_data text, locale text)")
diff --git a/spec/lib/concern/second_factor_manager_spec.rb b/spec/lib/concern/second_factor_manager_spec.rb
index 1f0dd30cd8b..a30b726e731 100644
--- a/spec/lib/concern/second_factor_manager_spec.rb
+++ b/spec/lib/concern/second_factor_manager_spec.rb
@@ -409,7 +409,7 @@ RSpec.describe SecondFactorManager do
end
end
- context 'backup codes' do
+ describe 'backup codes' do
describe '#generate_backup_codes' do
it 'should generate and store 10 backup codes' do
backup_codes = user.generate_backup_codes
diff --git a/spec/lib/cooked_post_processor_spec.rb b/spec/lib/cooked_post_processor_spec.rb
index 2dc678159c1..4c633b5a547 100644
--- a/spec/lib/cooked_post_processor_spec.rb
+++ b/spec/lib/cooked_post_processor_spec.rb
@@ -249,12 +249,12 @@ RSpec.describe CookedPostProcessor do
end
end
- context "processing images" do
+ context "when processing images" do
before do
SiteSetting.responsive_post_image_sizes = ""
end
- context "responsive images" do
+ context "with responsive images" do
before { SiteSetting.responsive_post_image_sizes = "1|1.5|3" }
it "includes responsive images on demand" do
@@ -361,7 +361,7 @@ RSpec.describe CookedPostProcessor do
cpp.post_process
end
- context "valid" do
+ context "when valid" do
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 111, "height" => 222 } } }
it "uses them" do
@@ -371,17 +371,17 @@ RSpec.describe CookedPostProcessor do
end
end
- context "invalid width" do
+ context "with invalid width" do
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 0, "height" => 222 } } }
include_examples "leave dimensions alone"
end
- context "invalid height" do
+ context "with invalid height" do
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 111, "height" => 0 } } }
include_examples "leave dimensions alone"
end
- context "invalid width & height" do
+ context "with invalid width & height" do
let(:image_sizes) { { "http://foo.bar/image.png" => { "width" => 0, "height" => 0 } } }
include_examples "leave dimensions alone"
end
@@ -433,7 +433,7 @@ RSpec.describe CookedPostProcessor do
expect(cpp).to be_dirty
end
- describe 'when image is inside onebox' do
+ context 'when image is inside onebox' do
let(:url) { 'https://image.com/my-avatar' }
let(:post) { Fabricate(:post, raw: url) }
@@ -452,7 +452,7 @@ RSpec.describe CookedPostProcessor do
end
end
- describe 'when image is an svg' do
+ context 'when image is an svg' do
fab!(:post) do
Fabricate(:post, raw: "<img src=\"/#{Discourse.store.upload_path}/original/1X/1234567890123456.svg\">")
end
@@ -467,7 +467,7 @@ RSpec.describe CookedPostProcessor do
HTML
end
- describe 'when image src is an URL' do
+ context 'when image src is an URL' do
let(:post) do
Fabricate(:post, raw: "<img src=\"http://test.discourse/#{upload_path}/original/1X/1234567890123456.svg?somepamas\">")
end
@@ -482,7 +482,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "s3_uploads" do
+ context "with s3_uploads" do
let(:upload) { Fabricate(:secure_upload_s3) }
before do
@@ -746,7 +746,7 @@ RSpec.describe CookedPostProcessor do
end
- context "topic image" do
+ context "with topic image" do
fab!(:post) { Fabricate(:post_with_uploaded_image) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -822,7 +822,7 @@ RSpec.describe CookedPostProcessor do
expect(post.reload.image_upload_id).to eq(upload2.id)
end
- context "post image" do
+ context "with post image" do
let(:reply) { Fabricate(:post_with_uploaded_image, post_number: 2) }
let(:cpp) { CookedPostProcessor.new(reply) }
@@ -838,18 +838,15 @@ RSpec.describe CookedPostProcessor do
end
describe "#extract_images" do
-
let(:post) { build(:post_with_plenty_of_images) }
let(:cpp) { CookedPostProcessor.new(post) }
it "does not extract emojis or images inside oneboxes or quotes" do
expect(cpp.extract_images.length).to eq(0)
end
-
end
describe "#get_size_from_attributes" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -879,11 +876,9 @@ RSpec.describe CookedPostProcessor do
img = { 'src' => nil, 'height' => 100 }
expect(cpp.get_size_from_attributes(img)).to be_nil
end
-
end
describe "#get_size_from_image_sizes" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -891,11 +886,9 @@ RSpec.describe CookedPostProcessor do
image_sizes = { "http://my.discourse.org/image.png" => { "width" => 111, "height" => 222 } }
expect(cpp.get_size_from_image_sizes("/image.png", image_sizes)).to eq([111, 222])
end
-
end
describe "#get_size" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -917,7 +910,6 @@ RSpec.describe CookedPostProcessor do
end
describe "#is_valid_image_url?" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -936,11 +928,9 @@ RSpec.describe CookedPostProcessor do
it "doesn't throw an exception with a bad URI" do
expect(cpp.is_valid_image_url?("http://do<main.com")).to eq(nil)
end
-
end
describe "#get_filename" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -957,7 +947,6 @@ RSpec.describe CookedPostProcessor do
upload = build(:upload, original_filename: "blob.png")
expect(cpp.get_filename(upload, "http://domain.com/image.png")).to eq(I18n.t('upload.pasted_image_filename'))
end
-
end
describe "#convert_to_link" do
@@ -995,7 +984,7 @@ RSpec.describe CookedPostProcessor do
expect(doc.css('img.animated').size).to eq(1)
end
- context "giphy/tenor images" do
+ context "with giphy/tenor images" do
before do
CookedPostProcessor.any_instance.stubs(:get_size).with("https://media2.giphy.com/media/7Oifk90VrCdNe/giphy.webp").returns([311, 280])
CookedPostProcessor.any_instance.stubs(:get_size).with("https://media1.tenor.com/images/20c7ddd5e84c7427954f430439c5209d/tenor.gif").returns([833, 104])
@@ -1226,7 +1215,6 @@ RSpec.describe CookedPostProcessor do
end
describe "#post_process_oneboxes with square image" do
-
it "generates a onebox-avatar class" do
url = 'https://square-image.com/onebox'
@@ -1256,11 +1244,9 @@ RSpec.describe CookedPostProcessor do
expect(cpp.doc.to_s).not_to include('aspect-image')
expect(cpp.doc.to_s).to include('onebox-avatar')
end
-
end
describe "#optimize_urls" do
-
let(:post) { build(:post_with_uploads_and_links) }
let(:cpp) { CookedPostProcessor.new(post) }
@@ -1277,7 +1263,6 @@ RSpec.describe CookedPostProcessor do
end
context "when CDN is enabled" do
-
it "uses schemaless CDN url for http uploads" do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
cpp.optimize_urls
@@ -1332,7 +1317,7 @@ RSpec.describe CookedPostProcessor do
HTML
end
- context "s3_uploads" do
+ context "with s3_uploads" do
before do
Rails.configuration.action_controller.stubs(:asset_host).returns("https://local.cdn.com")
@@ -1405,7 +1390,7 @@ RSpec.describe CookedPostProcessor do
HTML
end
- context "media uploads" do
+ context "with media uploads" do
fab!(:image_upload) { Fabricate(:upload) }
fab!(:audio_upload) { Fabricate(:upload, extension: "ogg") }
fab!(:video_upload) { Fabricate(:upload, extension: "mov") }
@@ -1543,7 +1528,6 @@ RSpec.describe CookedPostProcessor do
end
describe "#is_a_hyperlink?" do
-
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
let(:doc) { Nokogiri::HTML5::fragment('<body><div><a><img id="linked_image"></a><p><img id="standard_image"></p></div></body>') }
@@ -1557,13 +1541,12 @@ RSpec.describe CookedPostProcessor do
img = doc.css("img#standard_image").first
expect(cpp.is_a_hyperlink?(img)).to eq(false)
end
-
end
- context "grant badges" do
+ describe "grant badges" do
let(:cpp) { CookedPostProcessor.new(post) }
- context "emoji inside a quote" do
+ context "with emoji inside a quote" do
let(:post) { Fabricate(:post, raw: "time to eat some sweet \n[quote]\n:candy:\n[/quote]\n mmmm") }
it "doesn't award a badge when the emoji is in a quote" do
@@ -1572,7 +1555,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "emoji in the text" do
+ context "with emoji in the text" do
let(:post) { Fabricate(:post, raw: "time to eat some sweet :candy: mmmm") }
it "awards a badge for using an emoji" do
@@ -1581,7 +1564,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "onebox" do
+ context "with onebox" do
before do
Oneboxer.stubs(:onebox).with(anything, anything).returns(nil)
Oneboxer.stubs(:onebox).with('https://discourse.org', anything).returns("<aside class=\"onebox allowlistedgeneric\">the rest of the onebox</aside>")
@@ -1613,7 +1596,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "reply_by_email" do
+ context "with reply_by_email" do
let(:post) { Fabricate(:post, raw: "This is a **reply** via email ;)", via_email: true, post_number: 2) }
it "awards a badge for replying via email" do
@@ -1624,7 +1607,7 @@ RSpec.describe CookedPostProcessor do
end
- context "quote processing" do
+ describe "quote processing" do
let(:cpp) { CookedPostProcessor.new(cp) }
let(:pp) { Fabricate(:post, raw: "This post is ripe for quoting!") }
@@ -1656,7 +1639,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "external discourse instance quote" do
+ context "with external discourse instance quote" do
let(:external_raw) do
<<~RAW.strip
[quote="random_guy_not_from_our_discourse, post:2004, topic:401"]
@@ -1674,7 +1657,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "full quote on direct reply" do
+ describe "full quote on direct reply" do
fab!(:topic) { Fabricate(:topic) }
let!(:post) { Fabricate(:post, topic: topic, raw: 'this is the "first" post') }
@@ -1803,7 +1786,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "full quote on direct reply with full name prioritization" do
+ describe "full quote on direct reply with full name prioritization" do
fab!(:user) { Fabricate(:user, name: "james, john, the third") }
fab!(:topic) { Fabricate(:topic) }
let!(:post) { Fabricate(:post, user: user, topic: topic, raw: 'this is the "first" post') }
@@ -1935,7 +1918,7 @@ RSpec.describe CookedPostProcessor do
end
end
- context "prioritizes full name in quotes" do
+ describe "prioritizes full name in quotes" do
fab!(:user) { Fabricate(:user, name: "james, john, the third") }
fab!(:topic) { Fabricate(:topic) }
let!(:post) { Fabricate(:post, user: user, topic: topic, raw: 'this is the "first" post') }
diff --git a/spec/lib/crawler_detection_spec.rb b/spec/lib/crawler_detection_spec.rb
index 905950a1e69..91c8ff32556 100644
--- a/spec/lib/crawler_detection_spec.rb
+++ b/spec/lib/crawler_detection_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe CrawlerDetection do
-
def crawler!(user_agent, via = nil)
if (!CrawlerDetection.crawler?(user_agent, via))
raise "#{user_agent} should be a crawler!"
@@ -14,8 +13,7 @@ RSpec.describe CrawlerDetection do
end
end
- describe "crawler?" do
-
+ describe ".crawler?" do
it "can be amended via site settings" do
SiteSetting.crawler_user_agents = 'Mooble|Kaboodle+*'
@@ -67,7 +65,7 @@ RSpec.describe CrawlerDetection do
end
- describe 'show_browser_update?' do
+ describe '.show_browser_update?' do
it 'always returns false if setting is empty' do
SiteSetting.browser_update_user_agents = ""
@@ -83,12 +81,12 @@ RSpec.describe CrawlerDetection do
end
end
- describe 'allow_crawler?' do
+ describe '.allow_crawler?' do
it 'returns true if allowlist and blocklist are blank' do
expect(CrawlerDetection.allow_crawler?('Googlebot/2.1 (+http://www.google.com/bot.html)')).to eq(true)
end
- context 'allowlist is set' do
+ context 'when allowlist is set' do
before do
SiteSetting.allowed_crawler_user_agents = 'Googlebot|Twitterbot'
end
@@ -105,7 +103,7 @@ RSpec.describe CrawlerDetection do
expect(CrawlerDetection.allow_crawler?('')).to eq(false)
end
- context 'and blocklist is set' do
+ context 'when blocklist is set' do
before do
SiteSetting.blocked_crawler_user_agents = 'Googlebot-Image'
end
@@ -116,7 +114,7 @@ RSpec.describe CrawlerDetection do
end
end
- context 'blocklist is set' do
+ context 'when blocklist is set' do
before do
SiteSetting.blocked_crawler_user_agents = 'Googlebot|Twitterbot'
end
@@ -135,7 +133,7 @@ RSpec.describe CrawlerDetection do
end
end
- describe 'is_blocked_crawler?' do
+ describe '.is_blocked_crawler?' do
it 'is false if user agent is a crawler and no allowlist or blocklist is defined' do
expect(CrawlerDetection.is_blocked_crawler?('Twitterbot')).to eq(false)
end
diff --git a/spec/lib/discourse_plugin_registry_spec.rb b/spec/lib/discourse_plugin_registry_spec.rb
index 78c8852670c..162a2f051ee 100644
--- a/spec/lib/discourse_plugin_registry_spec.rb
+++ b/spec/lib/discourse_plugin_registry_spec.rb
@@ -3,13 +3,12 @@
require 'discourse_plugin_registry'
RSpec.describe DiscoursePluginRegistry do
-
class TestRegistry < DiscoursePluginRegistry; end
let(:registry) { TestRegistry }
let(:registry_instance) { registry.new }
- context '::define_register' do
+ describe '.define_register' do
let(:fresh_registry) { Class.new(TestRegistry) }
let(:plugin_class) do
@@ -39,7 +38,7 @@ RSpec.describe DiscoursePluginRegistry do
expect(fresh_registry.test_things[:test]).to eq(nil)
end
- context '::define_filtered_register' do
+ describe '.define_filtered_register' do
it 'works' do
fresh_registry.define_filtered_register(:test_things)
expect(fresh_registry.test_things.length).to eq(0)
@@ -262,5 +261,4 @@ RSpec.describe DiscoursePluginRegistry do
expect(registry.seed_data["admin_quick_start_filename"]).to eq(File.expand_path("../docs/BANANA-QUICK-START.md", __FILE__))
end
end
-
end
diff --git a/spec/lib/discourse_spec.rb b/spec/lib/discourse_spec.rb
index 653d6268349..a26a54bfb26 100644
--- a/spec/lib/discourse_spec.rb
+++ b/spec/lib/discourse_spec.rb
@@ -3,24 +3,23 @@
require 'discourse'
RSpec.describe Discourse do
-
before do
RailsMultisite::ConnectionManagement.stubs(:current_hostname).returns('foo.com')
end
- context 'current_hostname' do
+ describe 'current_hostname' do
it 'returns the hostname from the current db connection' do
expect(Discourse.current_hostname).to eq('foo.com')
end
end
- context 'avatar_sizes' do
+ describe 'avatar_sizes' do
it 'returns a list of integers' do
expect(Discourse.avatar_sizes).to contain_exactly(20, 25, 30, 32, 37, 40, 45, 48, 50, 60, 64, 67, 75, 90, 96, 120, 135, 180, 240, 360)
end
end
- context 'running_in_rack' do
+ describe 'running_in_rack' do
after do
ENV.delete("DISCOURSE_RUNNING_IN_RACK")
end
@@ -32,7 +31,7 @@ RSpec.describe Discourse do
end
end
- context 'base_url' do
+ describe 'base_url' do
context 'when https is off' do
before do
SiteSetting.force_https = false
@@ -64,7 +63,7 @@ RSpec.describe Discourse do
end
end
- context "asset_filter_options" do
+ describe "asset_filter_options" do
it "obmits path if request is missing" do
opts = Discourse.asset_filter_options(:js, nil)
expect(opts[:path]).to be_blank
@@ -77,7 +76,7 @@ RSpec.describe Discourse do
end
end
- context 'plugins' do
+ describe 'plugins' do
let(:plugin_class) do
Class.new(Plugin::Instance) do
attr_accessor :enabled
@@ -129,7 +128,7 @@ RSpec.describe Discourse do
end
- context 'authenticators' do
+ describe 'authenticators' do
it 'returns inbuilt authenticators' do
expect(Discourse.authenticators).to match_array(Discourse::BUILTIN_AUTH.map(&:authenticator))
end
@@ -167,7 +166,7 @@ RSpec.describe Discourse do
end
end
- context 'enabled_authenticators' do
+ describe 'enabled_authenticators' do
it 'only returns enabled authenticators' do
expect(Discourse.enabled_authenticators.length).to be(0)
expect { SiteSetting.enable_twitter_logins = true }
@@ -178,7 +177,6 @@ RSpec.describe Discourse do
end
describe '#site_contact_user' do
-
fab!(:admin) { Fabricate(:admin) }
fab!(:another_admin) { Fabricate(:admin) }
@@ -201,7 +199,6 @@ RSpec.describe Discourse do
end
describe "#store" do
-
it "returns LocalStore by default" do
expect(Discourse.store).to be_a(FileStore::LocalStore)
end
@@ -213,10 +210,9 @@ RSpec.describe Discourse do
SiteSetting.s3_secret_access_key = "s3_secret_access_key"
expect(Discourse.store).to be_a(FileStore::S3Store)
end
-
end
- context 'readonly mode' do
+ describe 'readonly mode' do
let(:readonly_mode_key) { Discourse::READONLY_MODE_KEY }
let(:readonly_mode_ttl) { Discourse::READONLY_MODE_KEY_TTL }
let(:user_readonly_mode_key) { Discourse::USER_READONLY_MODE_KEY }
@@ -244,7 +240,7 @@ RSpec.describe Discourse do
expect(Discourse.redis.get(readonly_mode_key)).to eq(nil)
end
- context 'user enabled readonly mode' do
+ context 'when user enabled readonly mode' do
it "adds a key in redis and publish a message through the message bus" do
expect(Discourse.redis.get(user_readonly_mode_key)).to eq(nil)
end
@@ -252,7 +248,7 @@ RSpec.describe Discourse do
end
describe ".disable_readonly_mode" do
- context 'user disabled readonly mode' do
+ context 'when user disabled readonly mode' do
it "removes readonly key in redis and publish a message through the message bus" do
message = MessageBus.track_publish { Discourse.disable_readonly_mode(user_readonly_mode_key) }.first
assert_readonly_mode_disabled(message, user_readonly_mode_key)
@@ -320,7 +316,6 @@ RSpec.describe Discourse do
end
describe "#handle_exception" do
-
class TempSidekiqLogger
attr_accessor :exception, :context
@@ -341,7 +336,6 @@ RSpec.describe Discourse do
end
describe "#job_exception_stats" do
-
class FakeTestError < StandardError
end
diff --git a/spec/lib/discourse_tagging_spec.rb b/spec/lib/discourse_tagging_spec.rb
index acf7f821fda..ddcd88916d7 100644
--- a/spec/lib/discourse_tagging_spec.rb
+++ b/spec/lib/discourse_tagging_spec.rb
@@ -6,7 +6,6 @@ require 'discourse_tagging'
# More tests are found in the category_tag_spec integration specs
RSpec.describe DiscourseTagging do
-
fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }
let(:guardian) { Guardian.new(user) }
@@ -40,7 +39,7 @@ RSpec.describe DiscourseTagging do
expect(tags).to contain_exactly(tag1.name, tag3.name)
end
- context 'tag with colon' do
+ context 'with tag with colon' do
fab!(:tag_with_colon) { Fabricate(:tag, name: 'with:colon') }
it "can use it as selected tag" do
@@ -240,7 +239,7 @@ RSpec.describe DiscourseTagging do
end
- context 'empty term' do
+ context 'with empty term' do
it "works with an empty term" do
tags = DiscourseTagging.filter_allowed_tags(Guardian.new(user),
term: '',
@@ -250,7 +249,7 @@ RSpec.describe DiscourseTagging do
end
end
- context 'tag synonyms' do
+ context 'with tag synonyms' do
fab!(:base_tag) { Fabricate(:tag, name: 'discourse') }
fab!(:synonym) { Fabricate(:tag, name: 'discource', target_tag: base_tag) }
@@ -320,7 +319,7 @@ RSpec.describe DiscourseTagging do
end
describe 'tag_topic_by_names' do
- context 'visible but restricted tags' do
+ context 'with visible but restricted tags' do
fab!(:topic) { Fabricate(:topic) }
before do
@@ -357,7 +356,7 @@ RSpec.describe DiscourseTagging do
expect(tag_changed_event[:params].second[:new_tag_names]).to eq(['alpha'])
end
- context 'non-staff users in tag group groups' do
+ context 'with non-staff users in tag group groups' do
fab!(:non_staff_group) { Fabricate(:group, name: 'non_staff_group') }
before do
@@ -424,7 +423,7 @@ RSpec.describe DiscourseTagging do
expect(topic.reload.tags.pluck(:name)).to eq([tag1.name])
end
- context 'respects category minimum_required_tags setting' do
+ context 'when respecting category minimum_required_tags setting' do
fab!(:category) { Fabricate(:category, minimum_required_tags: 2) }
fab!(:topic) { Fabricate(:topic, category: category) }
@@ -453,7 +452,7 @@ RSpec.describe DiscourseTagging do
end
end
- context 'hidden tags' do
+ context 'with hidden tags' do
fab!(:hidden_tag) { Fabricate(:tag) }
let!(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name]) }
fab!(:topic) { Fabricate(:topic, user: user) }
@@ -476,7 +475,7 @@ RSpec.describe DiscourseTagging do
end
end
- context 'tag group with parent tag' do
+ context 'with tag group with parent tag' do
let(:topic) { Fabricate(:topic, user: user) }
let(:post) { Fabricate(:post, user: user, topic: topic, post_number: 1) }
let(:tag_group) { Fabricate(:tag_group, parent_tag_id: tag1.id) }
@@ -522,7 +521,7 @@ RSpec.describe DiscourseTagging do
end
end
- context "enforces required tags from a tag group" do
+ context "when enforcing required tags from a tag group" do
fab!(:category) { Fabricate(:category) }
fab!(:tag_group) { Fabricate(:tag_group) }
fab!(:topic) { Fabricate(:topic, category: category) }
@@ -567,7 +566,7 @@ RSpec.describe DiscourseTagging do
end
end
- context 'tag synonyms' do
+ context 'with tag synonyms' do
fab!(:topic) { Fabricate(:topic) }
fab!(:syn1) { Fabricate(:tag, name: 'synonym1', target_tag: tag1) }
@@ -603,7 +602,7 @@ RSpec.describe DiscourseTagging do
expect(described_class.tags_for_saving(['newtag'], guardian)).to eq([])
end
- context "can tag topics but not create tags" do
+ describe "can tag topics but not create tags" do
before do
guardian.stubs(:can_create_tag?).returns(false)
guardian.stubs(:can_tag_topics?).returns(true)
@@ -620,7 +619,7 @@ RSpec.describe DiscourseTagging do
end
end
- context "can tag topics and create tags" do
+ describe "can tag topics and create tags" do
before do
guardian.stubs(:can_create_tag?).returns(true)
guardian.stubs(:can_tag_topics?).returns(true)
diff --git a/spec/lib/discourse_updates_spec.rb b/spec/lib/discourse_updates_spec.rb
index 140d7e33ca3..e3ad55311e0 100644
--- a/spec/lib/discourse_updates_spec.rb
+++ b/spec/lib/discourse_updates_spec.rb
@@ -10,13 +10,13 @@ RSpec.describe DiscourseUpdates do
subject { DiscourseUpdates.check_version }
- context 'version check was done at the current installed version' do
+ context 'when version check was done at the current installed version' do
before do
DiscourseUpdates.last_installed_version = Discourse::VERSION::STRING
end
- context 'a good version check request happened recently' do
- context 'and server is up-to-date' do
+ context 'when a good version check request happened recently' do
+ context 'when server is up-to-date' do
let(:time) { 12.hours.ago }
before { stub_data(Discourse::VERSION::STRING, 0, false, time) }
@@ -33,7 +33,7 @@ RSpec.describe DiscourseUpdates do
end
end
- context 'and server is not up-to-date' do
+ context 'when server is not up-to-date' do
let(:time) { 12.hours.ago }
before { stub_data('0.9.0', 2, false, time) }
@@ -50,7 +50,7 @@ RSpec.describe DiscourseUpdates do
end
end
- context 'a version check has never been performed' do
+ context 'when a version check has never been performed' do
before { stub_data(nil, nil, false, nil) }
it 'returns the installed version' do
@@ -77,7 +77,7 @@ RSpec.describe DiscourseUpdates do
# These cases should never happen anymore, but keep the specs to be sure
# they're handled in a sane way.
- context 'old version check data' do
+ context 'with old version check data' do
shared_examples "queue version check and report that version is ok" do
it 'queues a version check' do
expect_enqueued_with(job: :version_check) do
@@ -94,19 +94,19 @@ RSpec.describe DiscourseUpdates do
end
end
- context 'installed is latest' do
+ context 'when installed is latest' do
before { stub_data(Discourse::VERSION::STRING, 1, false, 8.hours.ago) }
include_examples "queue version check and report that version is ok"
end
- context 'installed does not match latest version, but missing_versions_count is 0' do
+ context 'when installed does not match latest version, but missing_versions_count is 0' do
before { stub_data('0.10.10.123', 0, false, 8.hours.ago) }
include_examples "queue version check and report that version is ok"
end
end
end
- context 'version check was done at a different installed version' do
+ context 'when version check was done at a different installed version' do
before do
DiscourseUpdates.last_installed_version = '0.9.1'
end
@@ -127,18 +127,18 @@ RSpec.describe DiscourseUpdates do
end
end
- context 'missing_versions_count is 0' do
+ context 'when missing_versions_count is 0' do
before { stub_data('0.9.7', 0, false, 8.hours.ago) }
include_examples "when last_installed_version is old"
end
- context 'missing_versions_count is not 0' do
+ context 'when missing_versions_count is not 0' do
before { stub_data('0.9.7', 1, false, 8.hours.ago) }
include_examples "when last_installed_version is old"
end
end
- context 'new features' do
+ describe 'new features' do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin2) { Fabricate(:admin) }
let!(:last_item_date) { 5.minutes.ago }
diff --git a/spec/lib/distributed_mutex_spec.rb b/spec/lib/distributed_mutex_spec.rb
index aaa25161c73..accd753a62a 100644
--- a/spec/lib/distributed_mutex_spec.rb
+++ b/spec/lib/distributed_mutex_spec.rb
@@ -66,7 +66,7 @@ RSpec.describe DistributedMutex do
}.to raise_error(ThreadError)
end
- context "readonly redis" do
+ describe "readonly redis" do
before do
Discourse.redis.slaveof "127.0.0.1", "65534"
end
@@ -91,7 +91,7 @@ RSpec.describe DistributedMutex do
end
end
- context "executions" do
+ describe "executions" do
it "should not allow critical sections to overlap" do
connections = 3.times.map { DiscourseRedis.new }
diff --git a/spec/lib/email/message_builder_spec.rb b/spec/lib/email/message_builder_spec.rb
index 0f0c795a196..00487992c04 100644
--- a/spec/lib/email/message_builder_spec.rb
+++ b/spec/lib/email/message_builder_spec.rb
@@ -3,7 +3,6 @@
require 'email/message_builder'
RSpec.describe Email::MessageBuilder do
-
let(:to_address) { "[email protected]" }
let(:subject) { "Tree Trunks has made some apple pie!" }
let(:body) { "oh my glob Jake, Tree Trunks just made the tastiest apple pie ever!" }
@@ -32,8 +31,7 @@ RSpec.describe Email::MessageBuilder do
expect(header_args['X-Auto-Response-Suppress']).to eq("All")
end
- context "reply by email" do
-
+ describe "reply by email" do
context "without allow_reply_by_email" do
it "does not have a X-Discourse-Reply-Key" do
expect(header_args['X-Discourse-Reply-Key']).to be_blank
@@ -47,7 +45,7 @@ RSpec.describe Email::MessageBuilder do
context "with allow_reply_by_email" do
let(:reply_by_email_builder) { Email::MessageBuilder.new(to_address, allow_reply_by_email: true) }
- context "With the SiteSetting enabled" do
+ context "with the SiteSetting enabled" do
before do
SiteSetting.stubs(:reply_by_email_enabled?).returns(true)
SiteSetting.stubs(:reply_by_email_address).returns("r+%{reply_key}@reply.myforum.com")
@@ -72,7 +70,7 @@ RSpec.describe Email::MessageBuilder do
end
end
- context "With the SiteSetting disabled" do
+ context "with the SiteSetting disabled" do
before do
SiteSetting.stubs(:reply_by_email_enabled?).returns(false)
end
@@ -96,7 +94,7 @@ RSpec.describe Email::MessageBuilder do
)
end
- context "With the SiteSetting enabled" do
+ context "with the SiteSetting enabled" do
before do
SiteSetting.stubs(:reply_by_email_enabled?).returns(true)
@@ -113,7 +111,7 @@ RSpec.describe Email::MessageBuilder do
end
end
- context "With the SiteSetting disabled" do
+ context "with the SiteSetting disabled" do
before do
SiteSetting.stubs(:reply_by_email_enabled?).returns(false)
end
@@ -130,8 +128,7 @@ RSpec.describe Email::MessageBuilder do
end
- context "custom headers" do
-
+ describe "custom headers" do
let(:custom_headers_string) { " Precedence : bulk | :: | No-colon | No-Value: | Multi-colon : : value : : | Auto-Submitted : auto-generated " }
let(:custom_headers_result) { { "Precedence" => "bulk", "Multi-colon" => ": value : :", "Auto-Submitted" => "auto-generated" } }
@@ -149,8 +146,7 @@ RSpec.describe Email::MessageBuilder do
end
- context "header args" do
-
+ describe "header args" do
let(:additional_opts) { {} }
let(:message_with_header_args) do
Email::MessageBuilder.new(
@@ -209,8 +205,7 @@ RSpec.describe Email::MessageBuilder do
end
end
- context "unsubscribe link" do
-
+ describe "unsubscribe link" do
context "with add_unsubscribe_link false" do
it "has no unsubscribe header by default" do
expect(builder.header_args['List-Unsubscribe']).to be_blank
@@ -246,7 +241,7 @@ RSpec.describe Email::MessageBuilder do
end
- context "template_args" do
+ describe "template_args" do
let(:template_args) { builder.template_args }
it "has site title as email_prefix when `SiteSetting.email_prefix` is not present" do
@@ -267,7 +262,7 @@ RSpec.describe Email::MessageBuilder do
end
end
- context "email prefix in subject" do
+ describe "email prefix in subject" do
context "when use_site_subject is true" do
let(:message_with_email_prefix) { Email::MessageBuilder.new(to_address,
body: 'hello world',
@@ -280,8 +275,7 @@ RSpec.describe Email::MessageBuilder do
end
end
- context "subject_template" do
-
+ describe "subject_template" do
let(:templated_builder) { Email::MessageBuilder.new(to_address, template: 'mystery') }
let(:rendered_template) { "rendered template" }
@@ -319,11 +313,9 @@ RSpec.describe Email::MessageBuilder do
expect(templated_builder.subject).to match("customized subject")
end
end
-
end
- context "from field" do
-
+ describe "from field" do
it "has the default from" do
SiteSetting.title = ""
expect(build_args[:from]).to eq(SiteSetting.notification_email)
diff --git a/spec/lib/email/processor_spec.rb b/spec/lib/email/processor_spec.rb
index c0a52ffd1bd..4fd1c0c1121 100644
--- a/spec/lib/email/processor_spec.rb
+++ b/spec/lib/email/processor_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe Email::Processor do
end
end
- context "known error" do
+ describe "known error" do
let(:mail) { "From: #{from}\nTo: [email protected]" }
let(:mail2) { "From: #{from}\nTo: [email protected]" }
let(:mail3) { "From: #{from}\nTo: [email protected]" }
@@ -97,7 +97,7 @@ RSpec.describe Email::Processor do
end
end
- context "unrecognized error" do
+ describe "unrecognized error" do
let(:mail) { "Date: Fri, 15 Jan 2016 00:12:43 +0100\nFrom: #{from}\nTo: [email protected]\nSubject: FOO BAR\n\nFoo foo bar bar?" }
let(:mail2) { "Date: Fri, 15 Jan 2016 00:12:43 +0100\nFrom: #{from}\nTo: [email protected]\nSubject: BAR BAR\n\nBar bar bar bar?" }
@@ -140,7 +140,7 @@ RSpec.describe Email::Processor do
end
end
- context "from reply to email address" do
+ describe "from reply to email address" do
let(:mail) { "Date: Fri, 15 Jan 2016 00:12:43 +0100\nFrom: [email protected]\nTo: [email protected]\nSubject: FOO BAR\n\nFoo foo bar bar?" }
it "ignores the email" do
@@ -152,7 +152,7 @@ RSpec.describe Email::Processor do
end
end
- context "mailinglist mirror" do
+ describe "mailinglist mirror" do
before do
SiteSetting.email_in = true
Fabricate(:mailinglist_mirror_category)
diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rb
index de77d2acd1f..306afa83e4e 100644
--- a/spec/lib/email/receiver_spec.rb
+++ b/spec/lib/email/receiver_spec.rb
@@ -3,7 +3,6 @@
require "email/receiver"
RSpec.describe Email::Receiver do
-
before do
SiteSetting.email_in = true
SiteSetting.reply_by_email_address = "reply+%{reply_key}@bar.com"
@@ -108,7 +107,7 @@ RSpec.describe Email::Receiver do
)
end
- context "bounces" do
+ describe "bounces" do
it "raises a BouncerEmailError" do
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
expect(IncomingEmail.last.is_bounce).to eq(true)
@@ -194,8 +193,7 @@ RSpec.describe Email::Receiver do
end.to raise_error(Email::Receiver::BadDestinationAddress)
end
- context "bounces to VERP" do
-
+ describe "bounces to VERP" do
let(:bounce_key) { "14b08c855160d67f2e0c2f8ef36e251e" }
let(:bounce_key_2) { "b542fb5a9bacda6d28cc061d18e4eb83" }
fab!(:user) { Fabricate(:user, email: "[email protected]") }
@@ -244,8 +242,7 @@ RSpec.describe Email::Receiver do
end
end
- context "reply" do
-
+ describe "reply" do
let(:reply_key) { "4f97315cc828096c9cb34c6f1a0d6fe8" }
fab!(:category) { Fabricate(:category) }
fab!(:user) { Fabricate(:user, email: "[email protected]") }
@@ -306,8 +303,7 @@ RSpec.describe Email::Receiver do
expect { process(:reply_user_matching) }.to raise_error(Email::Receiver::TopicNotFoundError)
end
- context "a closed topic" do
-
+ context "with a closed topic" do
before do
topic.update_columns(closed: true)
end
@@ -827,8 +823,7 @@ RSpec.describe Email::Receiver do
end
end
- context "new message to a group" do
-
+ describe "new message to a group" do
fab!(:group) { Fabricate(:group, incoming_email: "[email protected]|[email protected]") }
it "handles encoded display names" do
@@ -1203,7 +1198,7 @@ RSpec.describe Email::Receiver do
end
end
- context "emailing a group by email_username and following reply flow" do
+ context "when emailing a group by email_username and following reply flow" do
let!(:original_inbound_email_topic) do
group.update!(
email_username: "[email protected]",
@@ -1368,8 +1363,7 @@ RSpec.describe Email::Receiver do
end
end
- context "new topic in a category" do
-
+ describe "new topic in a category" do
fab!(:category) { Fabricate(:category, email_in: "[email protected]|[email protected]", email_in_allow_strangers: false) }
it "raises a StrangersNotAllowedError when 'email_in_allow_strangers' is disabled" do
@@ -1508,8 +1502,7 @@ RSpec.describe Email::Receiver do
end
end
- context "new topic in a category that allows strangers" do
-
+ describe "new topic in a category that allows strangers" do
fab!(:category) { Fabricate(:category, email_in: "[email protected]|[email protected]", email_in_allow_strangers: true) }
it "lets an email in from a stranger" do
@@ -1530,7 +1523,6 @@ RSpec.describe Email::Receiver do
end
describe "#reply_by_email_address_regex" do
-
before do
SiteSetting.reply_by_email_address = nil
SiteSetting.alternative_reply_by_email_addresses = nil
@@ -1558,7 +1550,7 @@ RSpec.describe Email::Receiver do
end
- context "check_address" do
+ describe "check_address" do
before do
SiteSetting.reply_by_email_address = "foo+%{reply_key}@bar.com"
end
@@ -1581,7 +1573,7 @@ RSpec.describe Email::Receiver do
end
end
- context "staged users" do
+ describe "staged users" do
before do
SiteSetting.enable_staged_users = true
end
@@ -1652,7 +1644,7 @@ RSpec.describe Email::Receiver do
include_examples "does not create staged users", :blocklist_allowlist_email, Email::Receiver::EmailNotAllowed
end
- context "blocklist and allowlist for To and Cc" do
+ context "with blocklist and allowlist for To and Cc" do
before do
Fabricate(:group, incoming_email: "[email protected]")
end
@@ -1714,7 +1706,7 @@ RSpec.describe Email::Receiver do
end
end
- context "email is a reply" do
+ context "when email is a reply" do
let(:reply_key) { "4f97315cc828096c9cb34c6f1a0d6fe8" }
fab!(:category) { Fabricate(:category) }
fab!(:user) { Fabricate(:user, email: "[email protected]") }
@@ -1739,7 +1731,7 @@ RSpec.describe Email::Receiver do
include_examples "does not create staged users", :reply_and_forwarded
end
- context "forwarded email to category that doesn't allow strangers" do
+ context "with forwarded email to category that doesn't allow strangers" do
before do
category.update!(email_in: "[email protected]", email_in_allow_strangers: false)
end
@@ -1749,7 +1741,7 @@ RSpec.describe Email::Receiver do
end
end
- context "replying without key is allowed" do
+ context "when replying without key is allowed" do
fab!(:group) { Fabricate(:group, incoming_email: "[email protected]") }
let!(:topic) do
SiteSetting.find_related_post_with_key = false
@@ -1789,7 +1781,7 @@ RSpec.describe Email::Receiver do
end
end
- context "mailing list mirror" do
+ describe "mailing list mirror" do
fab!(:category) { Fabricate(:mailinglist_mirror_category) }
before do
@@ -1818,7 +1810,7 @@ RSpec.describe Email::Receiver do
expect { process(:mailinglist_short_message) }.to change { Topic.count }
end
- context "read-only category" do
+ context "with read-only category" do
before do
category.set_permissions(everyone: :readonly)
category.save!
@@ -1864,7 +1856,6 @@ RSpec.describe Email::Receiver do
end
describe "#select_body" do
-
let(:email) {
<<~EMAIL
MIME-Version: 1.0
@@ -2028,8 +2019,7 @@ RSpec.describe Email::Receiver do
end
end
- context "find_related_post" do
-
+ describe "find_related_post" do
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group, users: [user]) }
diff --git a/spec/lib/email/sender_spec.rb b/spec/lib/email/sender_spec.rb
index 92c29a9423d..f448a93b61b 100644
--- a/spec/lib/email/sender_spec.rb
+++ b/spec/lib/email/sender_spec.rb
@@ -15,11 +15,11 @@ RSpec.describe Email::Sender do
)
end
- context "disable_emails is enabled" do
+ context "when disable_emails is enabled" do
fab!(:user) { Fabricate(:user) }
fab!(:moderator) { Fabricate(:moderator) }
- context "disable_emails is enabled for everyone" do
+ context "when disable_emails is enabled for everyone" do
before { SiteSetting.disable_emails = "yes" }
it "doesn't deliver mail when mails are disabled" do
@@ -44,7 +44,7 @@ RSpec.describe Email::Sender do
end
end
- context "disable_emails is enabled for non-staff users" do
+ context "when disable_emails is enabled for non-staff users" do
before { SiteSetting.disable_emails = "non-staff" }
it "doesn't deliver mail to normal user" do
@@ -106,7 +106,7 @@ RSpec.describe Email::Sender do
Email::Sender.new(message, :hello).send
end
- context "host_for" do
+ describe ".host_for" do
it "defaults to localhost" do
expect(Email::Sender.host_for(nil)).to eq("localhost")
end
@@ -126,7 +126,6 @@ RSpec.describe Email::Sender do
end
context 'with a valid message' do
-
let(:reply_key) { "abcd" * 8 }
let(:message) do
@@ -145,7 +144,7 @@ RSpec.describe Email::Sender do
email_sender.send
end
- context "doesn't add return_path when no plus addressing" 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
@@ -154,7 +153,7 @@ RSpec.describe Email::Sender do
end
end
- context "adds return_path with plus addressing" do
+ context "with plus addressing" do
before { SiteSetting.reply_by_email_address = 'replies+%{reply_key}@test.com' }
it 'should set the return_path' do
@@ -163,7 +162,7 @@ RSpec.describe Email::Sender do
end
end
- context "adds a List-ID header to identify the forum" do
+ context "when topic id is present" do
fab!(:category) { Fabricate(:category, name: 'Name With Space') }
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:post) { Fabricate(:post, topic: topic) }
@@ -181,8 +180,7 @@ RSpec.describe Email::Sender do
end
end
- context "adds a Message-ID header even when topic id is not present" do
-
+ context "when topic id is not present" do
it 'should add the right header' do
email_sender.send
@@ -190,7 +188,7 @@ RSpec.describe Email::Sender do
end
end
- context "replaces reply_key in custom headers" do
+ context "when reply_key is present" do
fab!(:user) { Fabricate(:user) }
let(:email_sender) { Email::Sender.new(message, :valid_type, user) }
let(:reply_key) { PostReplyKey.find_by!(post_id: post.id, user_id: user.id).reply_key }
@@ -227,7 +225,7 @@ RSpec.describe Email::Sender do
end
end
- context "adds Precedence header" do
+ describe "adds Precedence header" do
fab!(:topic) { Fabricate(:topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
@@ -242,7 +240,7 @@ RSpec.describe Email::Sender do
end
end
- context "removes custom Discourse headers from topic notification mails" do
+ describe "removes custom Discourse headers from topic notification mails" do
fab!(:topic) { Fabricate(:topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
@@ -259,7 +257,7 @@ RSpec.describe Email::Sender do
end
end
- context "removes custom Discourse headers from digest/registration/other mails" do
+ describe "removes custom Discourse headers from digest/registration/other mails" do
it 'should remove the right headers' do
email_sender.send
expect(message.header['X-Discourse-Topic-Id']).not_to be_present
@@ -268,7 +266,7 @@ RSpec.describe Email::Sender do
end
end
- context "email threading" do
+ context "with email threading" do
let(:random_message_id_suffix) { "5f1330cfd941f323d7f99b9e" }
fab!(:topic) { Fabricate(:topic) }
@@ -369,7 +367,7 @@ RSpec.describe Email::Sender do
end
- context "merges custom mandrill header" do
+ describe "merges custom mandrill header" do
before do
ActionMailer::Base.smtp_settings[:address] = "smtp.mandrillapp.com"
message.header['X-MC-Metadata'] = { foo: "bar" }.to_json
@@ -381,7 +379,7 @@ RSpec.describe Email::Sender do
end
end
- context "merges custom sparkpost header" do
+ describe "merges custom sparkpost header" do
before do
ActionMailer::Base.smtp_settings[:address] = "smtp.sparkpostmail.com"
message.header['X-MSYS-API'] = { foo: "bar" }.to_json
@@ -393,7 +391,7 @@ RSpec.describe Email::Sender do
end
end
- context 'email logs' do
+ context 'with email logs' do
let(:email_log) { EmailLog.last }
it 'should create the right log' do
@@ -457,7 +455,7 @@ RSpec.describe Email::Sender do
end
end
- context "email log with a post id and topic id" do
+ context "with email log with a post id and topic id" do
let(:topic) { post.topic }
before do
@@ -475,7 +473,7 @@ RSpec.describe Email::Sender do
end
end
- context 'email parts' do
+ context 'with email parts' do
it 'should contain the right message' do
email_sender.send
@@ -686,7 +684,6 @@ RSpec.describe Email::Sender do
end
context 'with a deleted post' do
-
it 'should skip sending the email' do
post = Fabricate(:post, deleted_at: 1.day.ago)
@@ -705,7 +702,6 @@ RSpec.describe Email::Sender do
end
context 'with a deleted topic' do
-
it 'should skip sending the email' do
post = Fabricate(:post, topic: Fabricate(:topic, deleted_at: 1.day.ago))
diff --git a/spec/lib/email/styles_spec.rb b/spec/lib/email/styles_spec.rb
index a150ea81765..f7372a810c5 100644
--- a/spec/lib/email/styles_spec.rb
+++ b/spec/lib/email/styles_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Email::Styles do
Nokogiri::HTML5.fragment(styler.to_html)
end
- context "basic formatter" do
+ describe "basic formatter" do
it "adds a max-width to large images" do
frag = basic_fragment("<img height='auto' width='auto' src='gigantic.jpg'>")
expect(frag.at("img")["style"]).to match("max-width")
@@ -48,7 +48,7 @@ RSpec.describe Email::Styles do
end
- context "html template formatter" do
+ describe "html template formatter" do
it "attaches a style to h3 tags" do
frag = html_fragment("<h3>hello</h3>")
expect(frag.at('h3')['style']).to be_present
@@ -106,7 +106,7 @@ RSpec.describe Email::Styles do
end
end
- context "rewriting protocol relative URLs to the forum" do
+ describe "rewriting protocol relative URLs to the forum" do
it "doesn't rewrite a url to another site" do
frag = html_fragment('<a href="//youtube.com/discourse">hello</a>')
expect(frag.at('a')['href']).to eq("//youtube.com/discourse")
@@ -156,7 +156,7 @@ RSpec.describe Email::Styles do
end
- context "dark mode emails" do
+ describe "dark mode emails" do
it "adds dark_mode_styles when site setting active" do
frag = html_fragment('<div class="body">test</div>')
styler = Email::Styles.new(frag)
@@ -169,7 +169,7 @@ RSpec.describe Email::Styles do
end
end
- context "strip_avatars_and_emojis" do
+ describe "strip_avatars_and_emojis" do
it "works for lonesome emoji with no title" do
emoji = "<img src='/images/emoji/twitter/crying_cat_face.png'>"
style = Email::Styles.new(emoji)
@@ -192,7 +192,7 @@ RSpec.describe Email::Styles do
end
end
- context "onebox_styles" do
+ describe "onebox_styles" do
it "renders quote as <blockquote>" do
fragment = html_fragment('<aside class="quote"> <div class="title"> <div class="quote-controls"> <i class="fa fa-chevron-down" title="expand/collapse"></i><a href="/t/xyz/123" title="go to the quoted post" class="back"></a> </div> <img alt="" width="20" height="20" src="https://cdn-enterprise.discourse.org/boingboing/user_avatar/bbs.boingboing.net/techapj/40/54379_1.png" class="avatar">techAPJ: </div> <blockquote> <p>lorem ipsum</p> </blockquote> </aside>')
expect(fragment.to_s.squish).to match(/^<blockquote.+<\/blockquote>$/)
@@ -208,7 +208,7 @@ RSpec.describe Email::Styles do
end
end
- context "replace_secure_media_urls" do
+ describe "replace_secure_media_urls" do
before do
setup_s3
SiteSetting.secure_media = true
@@ -258,7 +258,7 @@ RSpec.describe Email::Styles do
end
- context "inline_secure_images" do
+ describe "inline_secure_images" do
before do
setup_s3
SiteSetting.secure_media = true
diff --git a/spec/lib/email_updater_spec.rb b/spec/lib/email_updater_spec.rb
index 7416fd9127f..0c8b4c65319 100644
--- a/spec/lib/email_updater_spec.rb
+++ b/spec/lib/email_updater_spec.rb
@@ -126,7 +126,7 @@ RSpec.describe EmailUpdater do
let(:user) { Fabricate(:user, email: old_email) }
let(:updater) { EmailUpdater.new(guardian: user.guardian, user: user) }
- context "changing primary email" do
+ context "when changing primary email" do
before do
expect_enqueued_with(job: :critical_user_email, args: { type: :confirm_new_email, to_address: new_email }) do
updater.change_to(new_email)
@@ -145,7 +145,7 @@ RSpec.describe EmailUpdater do
expect(updater.change_req.new_email_token.email).to eq(new_email)
end
- context 'confirming an invalid token' do
+ context 'when confirming an invalid token' do
it "produces an error" do
updater.confirm('random')
expect(updater.errors).to be_present
@@ -153,7 +153,7 @@ RSpec.describe EmailUpdater do
end
end
- context 'confirming a valid token' do
+ context 'when confirming a valid token' do
it "updates the user's email" do
event = DiscourseEvent.track_events {
expect_enqueued_with(job: :critical_user_email, args: { type: :notify_old_email, to_address: old_email }) do
@@ -173,14 +173,14 @@ RSpec.describe EmailUpdater do
end
end
- context "adding an email" do
+ context "when adding an email" do
before do
expect_enqueued_with(job: :critical_user_email, args: { type: :confirm_new_email, to_address: new_email }) do
updater.change_to(new_email, add: true)
end
end
- context 'confirming a valid token' do
+ context 'when confirming a valid token' do
it "adds a user email" do
expect(UserHistory.where(action: UserHistory.actions[:add_email], acting_user_id: user.id).last).to be_present
@@ -201,7 +201,7 @@ RSpec.describe EmailUpdater do
end
end
- context 'that was deleted before' do
+ context 'when it was deleted before' do
it 'works' do
expect_enqueued_with(job: :critical_user_email, args: { type: :notify_old_email_add, to_address: old_email }) do
updater.confirm(updater.change_req.new_email_token.token)
@@ -225,7 +225,7 @@ RSpec.describe EmailUpdater do
end
end
- context "max_allowed_secondary_emails" do
+ context "with max_allowed_secondary_emails" do
let(:secondary_email_1) { "[email protected]" }
let(:secondary_email_2) { "[email protected]" }
@@ -265,7 +265,7 @@ RSpec.describe EmailUpdater do
expect(updater.change_req.new_email_token).to be_blank
end
- context 'confirming an invalid token' do
+ context 'when confirming an invalid token' do
it "produces an error" do
updater.confirm('random')
expect(updater.errors).to be_present
@@ -273,7 +273,7 @@ RSpec.describe EmailUpdater do
end
end
- context 'confirming a valid token' do
+ context 'when confirming a valid token' do
before do
expect_enqueued_with(job: :critical_user_email, args: { type: :confirm_new_email, to_address: new_email }) do
@old_token = updater.change_req.old_email_token.token
@@ -299,7 +299,7 @@ RSpec.describe EmailUpdater do
expect(updater.change_req.new_email_token.email).to eq(new_email)
end
- context "completing the new update process" do
+ context "when completing the new update process" do
before do
expect_not_enqueued_with(job: :critical_user_email, args: { type: :notify_old_email, to_address: old_email }) do
updater.confirm(updater.change_req.new_email_token.token)
@@ -317,7 +317,7 @@ RSpec.describe EmailUpdater do
end
end
- context 'hide_email_address_taken is enabled' do
+ context 'when hide_email_address_taken is enabled' do
before do
SiteSetting.hide_email_address_taken = true
end
diff --git a/spec/lib/encodings_spec.rb b/spec/lib/encodings_spec.rb
index be94d5a8e12..bf3a5e0f025 100644
--- a/spec/lib/encodings_spec.rb
+++ b/spec/lib/encodings_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Encodings do
Encodings.to_utf8(string)
end
- context "unicode" do
+ describe "unicode" do
let(:expected) { 'Το σύστημα γραφής είναι ένα συμβολικό, οπτικό σύστημα καταγραφής της γλώσσας.' }
it "correctly encodes UTF-8 as UTF-8" do
diff --git a/spec/lib/enum_spec.rb b/spec/lib/enum_spec.rb
index 99db4f17034..e0c1f51b35c 100644
--- a/spec/lib/enum_spec.rb
+++ b/spec/lib/enum_spec.rb
@@ -44,7 +44,7 @@ RSpec.describe Enum do
end
end
- context "allows to specify number of first enum member" do
+ describe "allows to specify number of first enum member" do
it "number of first enum member should be 0 " do
start_enum = Enum.new(:jake, :finn, :princess_bubblegum, :peppermint_butler, start: 0)
expect(start_enum[:princess_bubblegum]).to eq(2)
diff --git a/spec/lib/file_store/base_store_spec.rb b/spec/lib/file_store/base_store_spec.rb
index 0a8cba20a83..6ea506fadd4 100644
--- a/spec/lib/file_store/base_store_spec.rb
+++ b/spec/lib/file_store/base_store_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe FileStore::BaseStore do
expect(described_class.new.get_path_for_upload(upload)).to eq(expected_path)
end
- context "empty URL" do
+ context "with empty URL" do
before do
upload.update!(url: "")
end
@@ -32,8 +32,8 @@ RSpec.describe FileStore::BaseStore do
end
end
- context "existing URL" do
- context "regular site" do
+ context "with existing URL" do
+ context "with regular site" do
it "returns the correct path for files stored on local storage" do
upload.update!(url: "/uploads/default/original/1X/63b76551662ccea1a594e161c37dd35188d77657.jpeg")
expect_correct_path("original/1X/63b76551662ccea1a594e161c37dd35188d77657.jpeg")
@@ -51,7 +51,7 @@ RSpec.describe FileStore::BaseStore do
end
end
- context "multisite" do
+ context "with multisite" do
it "returns the correct path for files stored on local storage" do
upload.update!(url: "/uploads/foo/original/1X/63b76551662ccea1a594e161c37dd35188d77657.jpeg")
expect_correct_path("original/1X/63b76551662ccea1a594e161c37dd35188d77657.jpeg")
@@ -83,7 +83,7 @@ RSpec.describe FileStore::BaseStore do
let!(:upload) { Fabricate.build(:upload, id: 100) }
let!(:optimized_path) { "optimized/1X/#{upload.sha1}_1_100x200.png" }
- context "empty URL" do
+ context "with empty URL" do
it 'should return the right 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)
@@ -95,7 +95,7 @@ RSpec.describe FileStore::BaseStore do
end
end
- context "existing URL" do
+ context "with existing URL" do
let!(:optimized) { Fabricate.build(:optimized_image, upload: upload, version: 1) }
let!(:optimized_path) { "optimized/1X/#{upload.sha1}_1_100x200.jpg" }
@@ -103,7 +103,7 @@ RSpec.describe FileStore::BaseStore do
expect(described_class.new.get_path_for_optimized_image(optimized)).to eq(optimized_path)
end
- context "regular site" do
+ context "with regular site" do
it "returns the correct path for files stored on local storage" do
optimized.update!(url: "/uploads/default/optimized/1X/#{upload.sha1}_1_100x200.jpg")
expect_correct_optimized_path
@@ -115,7 +115,7 @@ RSpec.describe FileStore::BaseStore do
end
end
- context "multisite" do
+ context "with multisite" do
it "returns the correct path for files stored on local storage" do
optimized.update!(url: "/uploads/foo/optimized/1X/#{upload.sha1}_1_100x200.jpg")
expect_correct_optimized_path
diff --git a/spec/lib/file_store/s3_store_spec.rb b/spec/lib/file_store/s3_store_spec.rb
index bfebbe75316..bff47c3ce8b 100644
--- a/spec/lib/file_store/s3_store_spec.rb
+++ b/spec/lib/file_store/s3_store_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe FileStore::S3Store do
SiteSetting.s3_region = 'us-west-1'
end
- context 'uploading to s3' do
+ describe 'uploading to s3' do
let(:etag) { "etag" }
describe "#store_upload" do
@@ -189,7 +189,7 @@ RSpec.describe FileStore::S3Store do
end
end
- context 'copying files in S3' do
+ describe 'copying files in S3' do
describe '#copy_file' do
it "copies the from in S3 with the right paths" do
upload.update!(
@@ -211,7 +211,7 @@ RSpec.describe FileStore::S3Store do
end
end
- context 'removal from s3' do
+ describe 'removal from s3' do
describe "#remove_upload" do
it "removes the file from s3 with the right paths" do
upload_key = Discourse.store.get_path_for_upload(upload)
@@ -380,7 +380,7 @@ RSpec.describe FileStore::S3Store do
end
end
- context 'update ACL' do
+ describe 'update ACL' do
before do
SiteSetting.authorized_extensions = "pdf|png"
end
diff --git a/spec/lib/final_destination_spec.rb b/spec/lib/final_destination_spec.rb
index 2782f7b894e..0e00d508d8c 100644
--- a/spec/lib/final_destination_spec.rb
+++ b/spec/lib/final_destination_spec.rb
@@ -3,7 +3,6 @@
require 'final_destination'
RSpec.describe FinalDestination do
-
let(:opts) do
{
ignore_redirects: ['https://ignore-me.com'],
@@ -82,7 +81,6 @@ RSpec.describe FinalDestination do
end
describe '.resolve' do
-
it "has a ready status code before anything happens" do
expect(fd('https://eviltrout.com').status).to eq(:ready)
end
@@ -118,7 +116,7 @@ RSpec.describe FinalDestination do
expect(final.status).to eq(:resolved)
end
- context "underscores in URLs" do
+ context "with underscores in URLs" do
before do
stub_request(:head, 'https://some_thing.example.com').to_return(doc_response)
end
@@ -202,7 +200,7 @@ RSpec.describe FinalDestination do
expect { final.resolve }.to raise_error(Excon::Errors::ExpectationFailed, "connect timeout reached: https://codinghorror.com/blog")
end
- context 'follows canonical links' do
+ context 'when following canonical links' do
it 'resolves the canonical link as the final destination' do
canonical_follow("https://eviltrout.com", "https://codinghorror.com/blog")
stub_request(:head, "https://codinghorror.com/blog").to_return(doc_response)
@@ -260,7 +258,7 @@ RSpec.describe FinalDestination do
end
end
- context "GET can be forced" do
+ context "when forcing GET" do
before do
stub_request(:head, 'https://force.get.com/posts?page=4')
stub_request(:get, 'https://force.get.com/posts?page=4')
@@ -305,7 +303,7 @@ RSpec.describe FinalDestination do
end
- context "HEAD not supported" do
+ context "when HEAD not supported" do
before do
stub_request(:get, 'https://eviltrout.com').to_return(
status: 301,
@@ -410,7 +408,7 @@ RSpec.describe FinalDestination do
expect(final.status).to eq(:resolved)
end
- context "content_type" do
+ context "with content_type" do
before do
stub_request(:head, "https://eviltrout.com/this/is/an/image").to_return(image_response)
end
@@ -475,7 +473,7 @@ RSpec.describe FinalDestination do
end
describe '.validate_uri' do
- context "host lookups" do
+ context "with host lookups" do
it "works for various hosts" do
expect(fd('https://private-host.com').validate_uri).to eq(false)
expect(fd('https://eviltrout.com:443').validate_uri).to eq(true)
@@ -626,5 +624,4 @@ RSpec.describe FinalDestination do
.to eq('https://ru.wikipedia.org/wiki/%D0%A1%D0%B2%D0%BE%D0%B1%D0%BE')
end
end
-
end
diff --git a/spec/lib/freedom_patches/translate_accelerator_spec.rb b/spec/lib/freedom_patches/translate_accelerator_spec.rb
index 4903b066af4..c3a65925778 100644
--- a/spec/lib/freedom_patches/translate_accelerator_spec.rb
+++ b/spec/lib/freedom_patches/translate_accelerator_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe "translate accelerator" do
end
end
- context "plugins" do
+ describe "plugins" do
before do
DiscoursePluginRegistry.register_locale(
'foo',
@@ -236,7 +236,7 @@ RSpec.describe "translate accelerator" do
end
end
- context "translation precedence" do
+ describe "translation precedence" do
def translation_should_equal(key, expected_value)
I18n.locale = :en
expect(I18n.t(key, locale: :de)).to eq(expected_value)
diff --git a/spec/lib/gaps_spec.rb b/spec/lib/gaps_spec.rb
index 9cd2cbfb7fe..aeab2f87e5e 100644
--- a/spec/lib/gaps_spec.rb
+++ b/spec/lib/gaps_spec.rb
@@ -3,7 +3,6 @@
require 'cache'
RSpec.describe Gaps do
-
it 'returns no gaps for empty data' do
expect(Gaps.new(nil, nil)).to be_blank
end
@@ -16,7 +15,7 @@ RSpec.describe Gaps do
expect(Gaps.new([1, 2, 3], [1, 2, 3])).to be_blank
end
- context "single element gap" do
+ describe "single element gap" do
let(:gap) { Gaps.new([1, 3], [1, 2, 3]) }
it 'has a gap for post 3' do
@@ -26,7 +25,7 @@ RSpec.describe Gaps do
end
end
- context "larger gap" do
+ describe "larger gap" do
let(:gap) { Gaps.new([1, 2, 3, 6, 7], [1, 2, 3, 4, 5, 6, 7]) }
it 'has a gap for post 6' do
@@ -36,7 +35,7 @@ RSpec.describe Gaps do
end
end
- context "multiple gaps" do
+ describe "multiple gaps" do
let(:gap) { Gaps.new([1, 5, 6, 7, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) }
it 'has both gaps' do
@@ -47,7 +46,7 @@ RSpec.describe Gaps do
end
end
- context "a gap in the beginning" do
+ describe "a gap in the beginning" do
let(:gap) { Gaps.new([2, 3, 4], [1, 2, 3, 4]) }
it 'has the gap' do
@@ -57,7 +56,7 @@ RSpec.describe Gaps do
end
end
- context "a gap in the ending" do
+ describe "a gap in the ending" do
let(:gap) { Gaps.new([1, 2, 3], [1, 2, 3, 4]) }
it 'has the gap' do
@@ -67,7 +66,7 @@ RSpec.describe Gaps do
end
end
- context "a large gap in the ending" do
+ describe "a large gap in the ending" do
let(:gap) { Gaps.new([1, 2, 3], [1, 2, 3, 4, 5, 6]) }
it 'has the gap' do
@@ -76,5 +75,4 @@ RSpec.describe Gaps do
expect(gap.after[3]).to eq([4, 5, 6])
end
end
-
end
diff --git a/spec/lib/global_path_spec.rb b/spec/lib/global_path_spec.rb
index 40c063817e7..9846dca06fa 100644
--- a/spec/lib/global_path_spec.rb
+++ b/spec/lib/global_path_spec.rb
@@ -7,8 +7,7 @@ class GlobalPathInstance
end
RSpec.describe GlobalPath do
-
- context 'cdn_relative_path' do
+ describe '.cdn_relative_path' do
def cdn_relative_path(p)
GlobalPathInstance.cdn_relative_path(p)
end
@@ -28,7 +27,7 @@ RSpec.describe GlobalPath do
end
end
- describe '#upload_cdn_path' do
+ describe '.upload_cdn_path' do
it 'generates correctly when S3 bucket has a folder' do
global_setting :s3_access_key_id, 's3_access_key_id'
global_setting :s3_secret_access_key, 's3_secret_access_key'
diff --git a/spec/lib/guardian/user_guardian_spec.rb b/spec/lib/guardian/user_guardian_spec.rb
index 9015e8d554a..3b10a6fbe11 100644
--- a/spec/lib/guardian/user_guardian_spec.rb
+++ b/spec/lib/guardian/user_guardian_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe UserGuardian do
Guardian.new(user)
end
- context 'anon user' do
+ context 'with anon user' do
let(:guardian) { Guardian.new }
it "should return the right value" do
@@ -53,7 +53,7 @@ RSpec.describe UserGuardian do
end
end
- context 'current user' do
+ context 'with current user' do
it "can not set uploads not owned by current user" do
expect(guardian.can_pick_avatar?(user_avatar, users_upload)).to eq(true)
expect(guardian.can_pick_avatar?(user_avatar, already_uploaded)).to eq(true)
@@ -78,8 +78,7 @@ RSpec.describe UserGuardian do
end
end
- context 'moderator' do
-
+ context 'with moderator' do
let :guardian do
Guardian.new(moderator)
end
@@ -93,7 +92,7 @@ RSpec.describe UserGuardian do
end
end
- context 'admin' do
+ context 'with admin' do
let :guardian do
Guardian.new(admin)
end
@@ -106,7 +105,6 @@ RSpec.describe UserGuardian do
end
describe "#can_see_profile?" do
-
it "is false for no user" do
expect(Guardian.new.can_see_profile?(nil)).to eq(false)
end
@@ -115,7 +113,7 @@ RSpec.describe UserGuardian do
expect(Guardian.new.can_see_profile?(user)).to eq(true)
end
- context "hidden profile" do
+ context "with hidden profile" do
# Mixing Fabricate.build() and Fabricate() could cause ID clashes, so override :user
fab!(:user) { Fabricate(:user) }
@@ -229,7 +227,7 @@ RSpec.describe UserGuardian do
end
end
- context "delete myself" do
+ context "when deleting myself" do
let(:guardian) { Guardian.new(user) }
include_examples "can_delete_user examples"
@@ -469,7 +467,7 @@ RSpec.describe UserGuardian do
expect(Guardian.new(admin_user).can_change_tracking_preferences?(admin_user)).to eq(true)
end
- context "allow_changing_staged_user_tracking is false" do
+ context "when allow_changing_staged_user_tracking is false" do
before { SiteSetting.allow_changing_staged_user_tracking = false }
it "is false to staged user" do
@@ -481,7 +479,7 @@ RSpec.describe UserGuardian do
end
end
- context "allow_changing_staged_user_tracking is true" do
+ context "when allow_changing_staged_user_tracking is true" do
before { SiteSetting.allow_changing_staged_user_tracking = true }
it "is true to staged user" do
diff --git a/spec/lib/guardian_spec.rb b/spec/lib/guardian_spec.rb
index f773cf23e38..b8b0780176e 100644
--- a/spec/lib/guardian_spec.rb
+++ b/spec/lib/guardian_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Guardian do
-
fab!(:user) { Fabricate(:user) }
fab!(:another_user) { Fabricate(:user) }
fab!(:member) { Fabricate(:user) }
@@ -283,7 +282,7 @@ RSpec.describe Guardian do
expect(Guardian.new(user).can_send_private_message?(another_user)).to be_falsey
end
- context "enable_personal_messages is false" do
+ context "when enable_personal_messages is false" do
before { SiteSetting.enable_personal_messages = false }
it "returns false if user is not staff member" do
@@ -296,7 +295,7 @@ RSpec.describe Guardian do
end
end
- context "target user is suspended" do
+ context "when target user is suspended" do
it "returns true for staff" do
expect(Guardian.new(admin).can_send_private_message?(suspended_user)).to be_truthy
expect(Guardian.new(moderator).can_send_private_message?(suspended_user)).to be_truthy
@@ -307,7 +306,7 @@ RSpec.describe Guardian do
end
end
- context "author is silenced" do
+ context "when author is silenced" do
before do
user.silenced_till = 1.year.from_now
user.save
@@ -375,7 +374,7 @@ RSpec.describe Guardian do
expect(Guardian.new(user).can_send_private_message?(group)).to eq(true)
end
- context 'target user has private message disabled' do
+ context 'when target user has private message disabled' do
before do
another_user.user_option.update!(allow_private_messages: false)
end
@@ -928,7 +927,7 @@ RSpec.describe Guardian do
describe 'a PostRevision' do
fab!(:post_revision) { Fabricate(:post_revision) }
- context 'edit_history_visible_to_public is true' do
+ context 'when edit_history_visible_to_public is true' do
before { SiteSetting.edit_history_visible_to_public = true }
it 'is false for nil' do
@@ -944,7 +943,7 @@ RSpec.describe Guardian do
end
end
- context 'edit_history_visible_to_public is false' do
+ context 'when edit_history_visible_to_public is false' do
before { SiteSetting.edit_history_visible_to_public = false }
it 'is true for staff' do
@@ -1040,7 +1039,7 @@ RSpec.describe Guardian do
expect(Guardian.new(topic.user).can_create?(Post, topic)).to be_falsey
end
- context 'closed topic' do
+ context 'with closed topic' do
before do
topic.closed = true
end
@@ -1066,12 +1065,12 @@ RSpec.describe Guardian do
end
end
- context 'archived topic' do
+ context 'with archived topic' do
before do
topic.archived = true
end
- context 'regular users' do
+ context 'with regular users' do
it "doesn't allow new posts from regular users" do
expect(Guardian.new(coding_horror).can_create?(Post, topic)).to be_falsey
end
@@ -1090,7 +1089,7 @@ RSpec.describe Guardian do
end
end
- context "trashed topic" do
+ context "with trashed topic" do
before do
topic.deleted_at = Time.now
end
@@ -1108,7 +1107,7 @@ RSpec.describe Guardian do
end
end
- context "system message" do
+ context "with system message" do
fab!(:private_message) {
Fabricate(
:topic,
@@ -1127,7 +1126,7 @@ RSpec.describe Guardian do
end
- context "private message" do
+ context "with private message" do
fab!(:private_message) { Fabricate(:topic, archetype: Archetype.private_message, category_id: nil) }
before { user.save! }
@@ -1220,7 +1219,7 @@ RSpec.describe Guardian do
end
end
- context 'category group moderation is enabled' do
+ context 'when category group moderation is enabled' do
fab!(:group_user) { Fabricate(:group_user) }
before do
@@ -1281,7 +1280,7 @@ RSpec.describe Guardian do
end
- context 'can_convert_topic?' do
+ describe '#can_convert_topic?' do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_convert_topic?(nil)).to be_falsey
end
@@ -1480,7 +1479,7 @@ RSpec.describe Guardian do
expect(Guardian.new(post.user).can_edit?(post)).to be_truthy
end
- context "shared drafts" do
+ context "with shared drafts" do
fab!(:category) { Fabricate(:category) }
let(:topic) { Fabricate(:topic, category: category) }
@@ -1507,7 +1506,7 @@ RSpec.describe Guardian do
end
end
- context 'category group moderation is enabled' do
+ context 'when category group moderation is enabled' do
fab!(:cat_mod_user) { Fabricate(:user) }
before do
@@ -1527,7 +1526,7 @@ RSpec.describe Guardian do
describe 'post edit time limits' do
- context 'post is older than post_edit_time_limit' do
+ context 'when post is older than post_edit_time_limit' do
let(:topic) { Fabricate(:topic) }
let(:old_post) { Fabricate(:post, topic: topic, user: topic.user, created_at: 6.minutes.ago) }
@@ -1557,7 +1556,7 @@ RSpec.describe Guardian do
expect(Guardian.new(coding_horror).can_edit?(old_post)).to be_truthy
end
- context "unlimited owner edits on first post" do
+ context "when unlimited owner edits on first post" do
let(:owner) { old_post.user }
it "returns true when the post topic's category allow_unlimited_owner_edits_on_first_post" do
@@ -1583,7 +1582,7 @@ RSpec.describe Guardian do
end
end
- context 'post is older than tl2_post_edit_time_limit' do
+ context 'when post is older than tl2_post_edit_time_limit' do
let(:old_post) { build(:post, topic: topic, user: topic.user, created_at: 12.minutes.ago) }
before do
@@ -1614,7 +1613,7 @@ RSpec.describe Guardian do
end
end
- context "first post of a static page doc" do
+ context "with first post of a static page doc" do
let!(:tos_topic) { Fabricate(:topic, user: Discourse.system_user) }
let!(:tos_first_post) { build(:post, topic: tos_topic, user: tos_topic.user) }
before { SiteSetting.tos_topic_id = tos_topic.id }
@@ -1641,7 +1640,7 @@ RSpec.describe Guardian do
expect(Guardian.new(coding_horror).can_edit?(topic)).to be_falsey
end
- context 'first post is hidden' do
+ context 'when first post is hidden' do
let!(:topic) { Fabricate(:topic, user: user) }
let!(:post) { Fabricate(:post, topic: topic, user: topic.user, hidden: true, hidden_at: Time.zone.now) }
@@ -1652,7 +1651,7 @@ RSpec.describe Guardian do
end
end
- context "locked" do
+ context "when locked" do
let(:post) { Fabricate(:post, locked_by_id: admin.id) }
let(:topic) { post.topic }
@@ -1662,7 +1661,7 @@ RSpec.describe Guardian do
end
end
- context 'not archived' do
+ context 'when not archived' do
it 'returns true as a moderator' do
expect(Guardian.new(moderator).can_edit?(topic)).to eq(true)
end
@@ -1702,7 +1701,7 @@ RSpec.describe Guardian do
end
end
- context 'private message' do
+ context 'with private message' do
it 'returns false at trust level 3' do
topic.archetype = 'private_message'
expect(Guardian.new(trust_level_3).can_edit?(topic)).to eq(false)
@@ -1714,7 +1713,7 @@ RSpec.describe Guardian do
end
end
- context 'archived' do
+ context 'when archived' do
let(:archived_topic) { build(:topic, user: user, archived: true) }
it 'returns true as a moderator' do
@@ -1743,7 +1742,7 @@ RSpec.describe Guardian do
end
end
- context 'very old' do
+ context 'when very old' do
let(:old_topic) { build(:topic, user: user, created_at: 6.minutes.ago) }
before { SiteSetting.post_edit_time_limit = 5 }
@@ -1809,8 +1808,7 @@ RSpec.describe Guardian do
end
- context 'can_moderate?' do
-
+ describe '#can_moderate?' do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_moderate?(nil)).to be_falsey
end
@@ -1823,8 +1821,7 @@ RSpec.describe Guardian do
end
end
- context 'a Topic' do
-
+ context 'with a Topic' do
it 'returns false when not logged in' do
expect(Guardian.new.can_moderate?(topic)).to be_falsey
end
@@ -1844,13 +1841,10 @@ RSpec.describe Guardian do
it 'returns true when trust level 4' do
expect(Guardian.new(trust_level_4).can_moderate?(topic)).to be_truthy
end
-
end
-
end
- context 'can_see_flags?' do
-
+ describe '#can_see_flags?' do
it "returns false when there is no post" do
expect(Guardian.new(moderator).can_see_flags?(nil)).to be_falsey
end
@@ -1872,7 +1866,7 @@ RSpec.describe Guardian do
end
end
- context "can_review_topic?" do
+ describe "#can_review_topic?" do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_review_topic?(nil)).to eq(false)
end
@@ -1893,7 +1887,7 @@ RSpec.describe Guardian do
end
end
- context "can_close_topic?" do
+ describe "#can_close_topic?" do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_close_topic?(nil)).to eq(false)
end
@@ -1914,7 +1908,7 @@ RSpec.describe Guardian do
end
end
- context "can_archive_topic?" do
+ describe "#can_archive_topic?" do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_archive_topic?(nil)).to eq(false)
end
@@ -1935,7 +1929,7 @@ RSpec.describe Guardian do
end
end
- context "can_edit_staff_notes?" do
+ describe "#can_edit_staff_notes?" do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_edit_staff_notes?(nil)).to eq(false)
end
@@ -1956,7 +1950,7 @@ RSpec.describe Guardian do
end
end
- context "can_create_topic?" do
+ describe "#can_create_topic?" do
it 'returns true for staff user' do
expect(Guardian.new(moderator).can_create_topic?(topic)).to eq(true)
end
@@ -1990,14 +1984,12 @@ RSpec.describe Guardian do
end
end
- context 'can_move_posts?' do
-
+ describe '#can_move_posts?' do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_move_posts?(nil)).to be_falsey
end
- context 'a Topic' do
-
+ context 'with a Topic' do
it 'returns false when not logged in' do
expect(Guardian.new.can_move_posts?(topic)).to be_falsey
end
@@ -2013,18 +2005,15 @@ RSpec.describe Guardian do
it 'returns true when an admin' do
expect(Guardian.new(admin).can_move_posts?(topic)).to be_truthy
end
-
end
-
end
- context 'can_delete?' do
-
+ describe '#can_delete?' do
it 'returns false with a nil object' do
expect(Guardian.new(user).can_delete?(nil)).to be_falsey
end
- context 'a Topic' do
+ context 'with a Topic' do
before do
# pretend we have a real topic
topic.id = 9999999
@@ -2068,7 +2057,7 @@ RSpec.describe Guardian do
expect(Guardian.new(topic.user).can_delete?(topic)).to be_falsey
end
- context 'category group moderation is enabled' do
+ context 'when category group moderation is enabled' do
fab!(:group_user) { Fabricate(:group_user) }
before do
@@ -2085,11 +2074,9 @@ RSpec.describe Guardian do
expect(Guardian.new(group_user.user).can_delete?(topic)).to be_truthy
end
end
-
end
- context 'a Post' do
-
+ context 'with a Post' do
before do
post.post_number = 2
end
@@ -2155,7 +2142,7 @@ RSpec.describe Guardian do
expect(Guardian.new(admin).can_delete?(post)).to be_falsey
end
- context 'the topic is archived' do
+ context 'when the topic is archived' do
before do
post.topic.archived = true
end
@@ -2168,11 +2155,9 @@ RSpec.describe Guardian do
expect(Guardian.new(post.user).can_delete?(post)).to be_falsey
end
end
-
end
- context 'a Category' do
-
+ context 'with a Category' do
let(:category) { build(:category, user: moderator) }
it 'returns false when not logged in' do
@@ -2206,10 +2191,9 @@ RSpec.describe Guardian do
category.expects(:has_children?).returns(true)
expect(Guardian.new(admin).can_delete?(category)).to be_falsey
end
-
end
- context 'can_suspend?' do
+ describe '#can_suspend?' do
it 'returns false when a user tries to suspend another user' do
expect(Guardian.new(user).can_suspend?(coding_horror)).to be_falsey
end
@@ -2227,7 +2211,7 @@ RSpec.describe Guardian do
end
end
- context 'a PostAction' do
+ context 'with a PostAction' do
let(:post_action) {
user.id = 1
post.id = 1
@@ -2254,13 +2238,10 @@ RSpec.describe Guardian do
it "returns true if it's yours" do
expect(Guardian.new(user).can_delete?(post_action)).to be_truthy
end
-
end
-
end
- context 'can_approve?' do
-
+ describe '#can_approve?' do
it "wont allow a non-logged in user to approve" do
expect(Guardian.new.can_approve?(user)).to be_falsey
end
@@ -2286,10 +2267,9 @@ RSpec.describe Guardian do
it "allows a moderator to approve a user" do
expect(Guardian.new(moderator).can_approve?(user)).to be_truthy
end
-
end
- context 'can_grant_admin?' do
+ describe '#can_grant_admin?' do
it "wont allow a non logged in user to grant an admin's access" do
expect(Guardian.new.can_grant_admin?(another_admin)).to be_falsey
end
@@ -2318,7 +2298,7 @@ RSpec.describe Guardian do
end
end
- context 'can_revoke_admin?' do
+ describe '#can_revoke_admin?' do
it "wont allow a non logged in user to revoke an admin's access" do
expect(Guardian.new.can_revoke_admin?(another_admin)).to be_falsey
end
@@ -2343,8 +2323,7 @@ RSpec.describe Guardian do
end
end
- context 'can_grant_moderation?' do
-
+ describe '#can_grant_moderation?' do
it "wont allow a non logged in user to grant an moderator's access" do
expect(Guardian.new.can_grant_moderation?(user)).to be_falsey
end
@@ -2375,7 +2354,7 @@ RSpec.describe Guardian do
end
end
- context 'can_revoke_moderation?' do
+ describe '#can_revoke_moderation?' do
it "wont allow a non logged in user to revoke an moderator's access" do
expect(Guardian.new.can_revoke_moderation?(moderator)).to be_falsey
end
@@ -2406,8 +2385,7 @@ RSpec.describe Guardian do
end
end
- context "can_see_invite_details?" do
-
+ describe "#can_see_invite_details?" do
it 'is false without a logged in user' do
expect(Guardian.new(nil).can_see_invite_details?(user)).to be_falsey
end
@@ -2421,8 +2399,7 @@ RSpec.describe Guardian do
end
end
- context "can_access_forum?" do
-
+ describe "#can_access_forum?" do
let(:unapproved_user) { Fabricate.build(:user) }
context "when must_approve_users is false" do
@@ -2461,12 +2438,10 @@ RSpec.describe Guardian do
unapproved_user.approved = true
expect(Guardian.new(unapproved_user).can_access_forum?).to be_truthy
end
-
end
-
end
- describe "can_delete_all_posts?" do
+ describe "#can_delete_all_posts?" do
it "is false without a logged in user" do
expect(Guardian.new(nil).can_delete_all_posts?(user)).to be_falsey
end
@@ -3176,7 +3151,7 @@ RSpec.describe Guardian do
let!(:theme) { Fabricate(:theme) }
let!(:theme2) { Fabricate(:theme) }
- context "allowlist mode" do
+ context "when in allowlist mode" do
before do
global_setting :allowed_theme_repos, " https://magic.com/repo.git, https://x.com/git"
end
@@ -3267,7 +3242,7 @@ RSpec.describe Guardian do
expect(Guardian.new(trust_level_4).can_wiki?(post)).to be_truthy
end
- context 'post is older than post_edit_time_limit' do
+ context 'when post is older than post_edit_time_limit' do
let(:old_post) { build(:post, user: trust_level_2, created_at: 6.minutes.ago) }
before do
SiteSetting.min_trust_to_allow_self_wiki = 2
@@ -3289,7 +3264,7 @@ RSpec.describe Guardian do
end
describe "Tags" do
- context "tagging disabled" do
+ context "with tagging disabled" do
before do
SiteSetting.tagging_enabled = false
end
@@ -3307,13 +3282,13 @@ RSpec.describe Guardian do
end
end
- context "tagging is enabled" do
+ context "when tagging is enabled" do
before do
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_level_to_tag_topics = 1
end
- context 'min_trust_to_create_tag is 3' do
+ context 'when min_trust_to_create_tag is 3' do
before do
SiteSetting.min_trust_to_create_tag = 3
end
@@ -3349,7 +3324,7 @@ RSpec.describe Guardian do
end
end
- context 'min_trust_to_create_tag is "staff"' do
+ context 'when min_trust_to_create_tag is "staff"' do
before do
SiteSetting.min_trust_to_create_tag = 'staff'
end
@@ -3364,7 +3339,7 @@ RSpec.describe Guardian do
end
end
- context 'min_trust_to_create_tag is "admin"' do
+ context 'when min_trust_to_create_tag is "admin"' do
before do
SiteSetting.min_trust_to_create_tag = 'admin'
end
@@ -3380,7 +3355,7 @@ RSpec.describe Guardian do
end
end
- context "tagging PMs" do
+ context "when tagging PMs" do
it "pm_tags_allowed_for_groups contains everyone" do
SiteSetting.pm_tags_allowed_for_groups = "#{Group::AUTO_GROUPS[:everyone]}"
@@ -3397,7 +3372,7 @@ RSpec.describe Guardian do
end
end
- describe(:can_see_group) do
+ describe "#can_see_group?" do
it 'Correctly handles owner visible groups' do
group = Group.new(name: 'group', visibility_level: Group.visibility_levels[:owners])
@@ -3470,10 +3445,9 @@ RSpec.describe Guardian do
expect(Guardian.new.can_see_group?(group)).to eq(true)
end
-
end
- describe(:can_see_group_members) do
+ describe "#can_see_group_members?" do
it 'Correctly handles group members visibility for owner' do
group = Group.new(name: 'group', members_visibility_level: Group.visibility_levels[:owners])
@@ -3669,12 +3643,12 @@ RSpec.describe Guardian do
end
end
- context 'topic featured link category restriction' do
+ describe 'topic featured link category restriction' do
before { SiteSetting.topic_featured_link_enabled = true }
let(:guardian) { Guardian.new(user) }
let(:uncategorized) { Category.find(SiteSetting.uncategorized_category_id) }
- context "uncategorized" do
+ context "when uncategorized" do
fab!(:link_category) { Fabricate(:link_category) }
it "allows featured links if uncategorized allows it" do
@@ -3704,7 +3678,7 @@ RSpec.describe Guardian do
end
end
- context "suspension reasons" do
+ describe "suspension reasons" do
it "will be shown by default" do
expect(Guardian.new.can_see_suspension_reason?(user)).to eq(true)
end
@@ -3729,14 +3703,14 @@ RSpec.describe Guardian do
end
describe '#can_remove_allowed_users?' do
- context 'staff users' do
+ context 'with staff users' do
it 'should be true' do
expect(Guardian.new(moderator).can_remove_allowed_users?(topic))
.to eq(true)
end
end
- context 'trust_level >= 2 user' do
+ context 'with trust_level >= 2 user' do
fab!(:topic_creator) { build(:user, trust_level: 2) }
fab!(:topic) { Fabricate(:topic, user: topic_creator) }
@@ -3751,7 +3725,7 @@ RSpec.describe Guardian do
end
end
- context 'normal user' do
+ context 'with normal user' do
fab!(:topic) { Fabricate(:topic, user: Fabricate(:user, trust_level: 1)) }
before do
@@ -3797,7 +3771,7 @@ RSpec.describe Guardian do
end
end
- context "anonymous users" do
+ context "with anonymous users" do
fab!(:topic) { Fabricate(:topic) }
it 'should be false' do
@@ -3884,8 +3858,8 @@ RSpec.describe Guardian do
end
end
- describe "can_see_site_contact_details" do
- context "login_required is enabled" do
+ describe "#can_see_site_contact_details?" do
+ context "when login_required is enabled" do
before do
SiteSetting.login_required = true
end
@@ -3899,7 +3873,7 @@ RSpec.describe Guardian do
end
end
- context "login_required is disabled" do
+ context "when login_required is disabled" do
before do
SiteSetting.login_required = false
end
diff --git a/spec/lib/has_errors_spec.rb b/spec/lib/has_errors_spec.rb
index 436039706cb..a63b31ef88c 100644
--- a/spec/lib/has_errors_spec.rb
+++ b/spec/lib/has_errors_spec.rb
@@ -3,7 +3,6 @@
require 'has_errors'
RSpec.describe HasErrors do
-
class ErrorTestClass
include HasErrors
end
@@ -18,7 +17,7 @@ RSpec.describe HasErrors do
expect(error_test.errors).to be_blank
end
- context "validate_child" do
+ describe "validate_child" do
it "adds the errors from invalid AR objects" do
expect(error_test.validate_child(invalid_topic)).to eq(false)
expect(error_test.errors).to be_present
@@ -32,7 +31,7 @@ RSpec.describe HasErrors do
end
end
- context "rollback_from_errors!" do
+ describe "rollback_from_errors!" do
it "triggers a rollback" do
invalid_topic.valid?
@@ -42,7 +41,7 @@ RSpec.describe HasErrors do
end
end
- context "rollback_with_error!" do
+ describe "rollback_with_error!" do
it "triggers a rollback" do
expect do
@@ -52,5 +51,4 @@ RSpec.describe HasErrors do
expect(error_test.errors[:base]).to include("You can only send warnings to one user at a time.")
end
end
-
end
diff --git a/spec/lib/hijack_spec.rb b/spec/lib/hijack_spec.rb
index c05985f1052..0e806fd7ab7 100644
--- a/spec/lib/hijack_spec.rb
+++ b/spec/lib/hijack_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe Hijack do
Hijack::Tester.new
end
- context "Request Tracker integration" do
+ describe "Request Tracker integration" do
let :logger do
lambda do |env, data|
@calls += 1
diff --git a/spec/lib/imap/sync_spec.rb b/spec/lib/imap/sync_spec.rb
index d7f66fd0522..e68ba4a6818 100644
--- a/spec/lib/imap/sync_spec.rb
+++ b/spec/lib/imap/sync_spec.rb
@@ -3,7 +3,6 @@
require 'imap/sync'
RSpec.describe Imap::Sync do
-
before do
SiteSetting.tagging_enabled = true
SiteSetting.pm_tags_allowed_for_groups = "1|2|3"
@@ -39,7 +38,7 @@ RSpec.describe Imap::Sync do
)
end
- context 'no previous sync' do
+ describe 'no previous sync' do
let(:from) { '[email protected]' }
let(:subject) { 'Testing email post' }
let(:message_id) { "#{SecureRandom.hex}@example.com" }
@@ -169,7 +168,7 @@ RSpec.describe Imap::Sync do
end
end
- context 'previous sync' do
+ describe 'previous sync' do
let(:subject) { 'Testing email post' }
let(:first_from) { '[email protected]' }
@@ -527,7 +526,7 @@ RSpec.describe Imap::Sync do
end
- context 'invalidated previous sync' do
+ describe 'invalidated previous sync' do
let(:subject) { 'Testing email post' }
let(:first_from) { '[email protected]' }
diff --git a/spec/lib/inline_oneboxer_spec.rb b/spec/lib/inline_oneboxer_spec.rb
index 52321f84e23..18acb78f5e3 100644
--- a/spec/lib/inline_oneboxer_spec.rb
+++ b/spec/lib/inline_oneboxer_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe InlineOneboxer do
expect(results).to be_blank
end
- context "caching" do
+ describe "caching" do
fab!(:topic) { Fabricate(:topic) }
before do
@@ -351,7 +351,7 @@ RSpec.describe InlineOneboxer do
end
end
- context "register_local_handler" do
+ describe ".register_local_handler" do
it "calls registered local handler" do
InlineOneboxer.register_local_handler('wizard') do |url, route|
{ url: url, title: 'Custom Onebox for Wizard' }
diff --git a/spec/lib/js_locale_helper_spec.rb b/spec/lib/js_locale_helper_spec.rb
index 5a28c82454f..775db523eb0 100644
--- a/spec/lib/js_locale_helper_spec.rb
+++ b/spec/lib/js_locale_helper_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe JsLocaleHelper do
end
- context "message format" do
+ describe "message format" do
def message_format_filename(locale)
Rails.root + "lib/javascripts/locale/#{locale}.js"
end
diff --git a/spec/lib/middleware/anonymous_cache_spec.rb b/spec/lib/middleware/anonymous_cache_spec.rb
index 3dfa03b918b..71f0428435d 100644
--- a/spec/lib/middleware/anonymous_cache_spec.rb
+++ b/spec/lib/middleware/anonymous_cache_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Middleware::AnonymousCache do
Middleware::AnonymousCache::Helper.new(env(opts))
end
- context "cacheable?" do
+ describe "#cacheable?" do
it "true by default" do
expect(new_helper.cacheable?).to eq(true)
end
@@ -38,7 +38,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
- context "per theme cache" do
+ describe "per theme cache" do
it "handles theme keys" do
theme = Fabricate(:theme, user_selectable: true)
@@ -93,7 +93,7 @@ RSpec.describe Middleware::AnonymousCache do
expect(key1).not_to eq(key2)
end
- context "cached" do
+ context "when cached" do
let!(:helper) do
new_helper("ANON_CACHE_DURATION" => 10)
end
@@ -151,7 +151,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
- context 'background request rate limit' do
+ describe 'background request rate limit' do
it 'will rate limit background requests' do
app = Middleware::AnonymousCache.new(
@@ -194,7 +194,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
- context 'force_anonymous!' do
+ describe '#force_anonymous!' do
before do
RateLimiter.enable
end
@@ -260,7 +260,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
- context 'invalid request payload' do
+ describe 'invalid request payload' do
it 'returns 413 for GET request with payload' do
status, headers, _ = middleware.call(env.tap do |environment|
environment[Rack::RACK_INPUT].write("test")
@@ -271,7 +271,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
- context "crawler blocking" do
+ describe "crawler blocking" do
let :non_crawler do
{
"HTTP_USER_AGENT" =>
diff --git a/spec/lib/middleware/request_tracker_spec.rb b/spec/lib/middleware/request_tracker_spec.rb
index 00edd39b87c..721c836ce40 100644
--- a/spec/lib/middleware/request_tracker_spec.rb
+++ b/spec/lib/middleware/request_tracker_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Middleware::RequestTracker do
CachedCounting.disable
end
- context "full request" do
+ describe "full request" do
it "can handle rogue user agents" do
agent = (+"Evil Googlebot String \xc3\x28").force_encoding("Windows-1252")
@@ -36,7 +36,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
- context "log_request" do
+ describe "log_request" do
before do
freeze_time
ApplicationRequest.clear_cache!
@@ -126,7 +126,7 @@ RSpec.describe Middleware::RequestTracker do
expect(ApplicationRequest.page_view_anon.first.count).to eq(1)
end
- context "ignore anonymous page views" do
+ context "when ignoring anonymous page views" do
let(:anon_data) do
Middleware::RequestTracker.get_data(env(
"HTTP_USER_AGENT" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
@@ -180,7 +180,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
- context "rate limiting" do
+ describe "rate limiting" do
before do
RateLimiter.enable
RateLimiter.clear_all_global!
@@ -549,7 +549,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
- context "callbacks" do
+ describe "callbacks" do
def app(result, sql_calls: 0, redis_calls: 0)
lambda do |env|
sql_calls.times do
diff --git a/spec/lib/new_post_manager_spec.rb b/spec/lib/new_post_manager_spec.rb
index 4241ab72b5f..f904074b99d 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) }
fab!(:topic) { Fabricate(:topic) }
- context "default action" do
+ describe "default action" 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
- context "default action" do
+ describe "default action" do
fab!(:other_user) { Fabricate(:user) }
it "doesn't enqueue private messages" do
@@ -101,7 +101,7 @@ RSpec.describe NewPostManager do
end
end
- context "default handler" do
+ describe "default handler" do
let(:manager) { NewPostManager.new(user, raw: 'this is new post content', topic_id: topic.id) }
context 'with the settings zeroed out' do
@@ -117,7 +117,7 @@ RSpec.describe NewPostManager do
end
end
- context 'basic post/topic count restrictions' do
+ context 'with basic post/topic count restrictions' do
before do
SiteSetting.approve_post_count = 1
end
@@ -324,7 +324,7 @@ RSpec.describe NewPostManager do
end
end
- context "new topic handler" do
+ describe "new topic handler" do
let(:manager) { NewPostManager.new(user, raw: 'this is new topic content', title: 'new topic title') }
context 'with a high trust level setting for new topics' do
before do
@@ -337,11 +337,9 @@ RSpec.describe NewPostManager do
expect(result.reason).to eq(:new_topics_unless_trust_level)
end
end
-
end
- context "extensibility priority" do
-
+ describe "extensibility priority" do
after do
NewPostManager.clear_handlers!
end
@@ -365,11 +363,9 @@ RSpec.describe NewPostManager do
NewPostManager.add_handler(101, &c)
expect(NewPostManager.handlers).to eq([c, a, b])
end
-
end
- context "extensibility" do
-
+ describe "extensibility" do
before do
@counter = 0
@@ -465,11 +461,9 @@ RSpec.describe NewPostManager do
expect(result.post).to be_present
expect(@counter).to be(0)
end
-
end
- context "user needs approval?" do
-
+ describe "user needs approval?" do
let :user do
user = Fabricate.build(:user, trust_level: 0)
user_stat = UserStat.new(post_count: 0)
@@ -661,7 +655,7 @@ RSpec.describe NewPostManager do
end
end
- context "via email" do
+ describe "via email" do
let(:manager) do
NewPostManager.new(
topic.user,
@@ -690,7 +684,7 @@ RSpec.describe NewPostManager do
end
end
- context "via email with a spam failure" do
+ describe "via email with a spam failure" do
let(:user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) }
@@ -725,7 +719,7 @@ RSpec.describe NewPostManager do
end
end
- context "via email with an authentication results failure" do
+ describe "via email with an authentication results failure" do
let(:user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) }
@@ -759,7 +753,7 @@ RSpec.describe NewPostManager do
end
end
- context "private message via email" do
+ describe "private message via email" do
it "doesn't enqueue authentication results failure" do
manager = NewPostManager.new(
topic.user,
@@ -788,5 +782,4 @@ RSpec.describe NewPostManager do
expect(result.action).to eq(:create_post)
end
end
-
end
diff --git a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
index 23c17334913..4064fde840a 100644
--- a/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
+++ b/spec/lib/onebox/engine/allowlisted_generic_onebox_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'canonical link' do
- context 'uses canonical link if available' do
+ context 'when using canonical link if available' do
let(:mobile_url) { "https://m.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
let(:canonical_url) { "https://www.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
before do
@@ -111,7 +111,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
end
- context 'does not use canonical link for Discourse topics' do
+ context 'when not using canonical link for Discourse topics' do
let(:discourse_topic_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483" }
let(:discourse_topic_reply_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483/2" }
before do
@@ -164,7 +164,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'missing description' do
- context 'works without description if image is present' do
+ context 'when working without description if image is present' do
before do
stub_request(:get, "https://edition.cnn.com/2020/05/15/health/gallery/coronavirus-people-adopting-pets-photos/index.html")
.to_return(status: 200, body: onebox_response('cnn'))
@@ -183,7 +183,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
end
- context 'uses basic meta description when necessary' do
+ context 'when using basic meta description when necessary' do
before do
stub_request(:get, "https://www.reddit.com/r/colors/comments/b4d5xm/literally_nothing_black_edition/")
.to_return(status: 200, body: onebox_response('reddit_image'))
@@ -204,7 +204,7 @@ RSpec.describe Onebox::Engine::AllowlistedGenericOnebox do
end
describe 'article html hosts' do
- context 'returns article_html for hosts in article_html_hosts' do
+ context 'when returning article_html for hosts in article_html_hosts' do
before do
stub_request(:get, "https://www.imdb.com/title/tt0108002/")
.to_return(status: 200, body: onebox_response('imdb'))
diff --git a/spec/lib/onebox/engine/amazon_onebox_spec.rb b/spec/lib/onebox/engine/amazon_onebox_spec.rb
index f9be9bc6965..ad624b6c9cd 100644
--- a/spec/lib/onebox/engine/amazon_onebox_spec.rb
+++ b/spec/lib/onebox/engine/amazon_onebox_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::AmazonOnebox do
- context "regular amazon page" do
+ describe "regular amazon page" do
before do
@link = "https://www.amazon.com/Knit-Noro-Accessories-Colorful-Little/dp/193609620X"
@uri = "https://www.amazon.com/dp/193609620X"
@@ -10,7 +10,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
.to_return(status: 200, body: onebox_response("amazon"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "works with international domains" do
@@ -101,7 +101,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
- context "amazon with opengraph" do
+ describe "amazon with opengraph" do
let(:link) { "https://www.amazon.com/dp/B01MFXN4Y2" }
let(:html) { described_class.new(link).to_html }
@@ -128,7 +128,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
- context "amazon book page" do
+ describe "amazon book page" do
let(:link) { "https://www.amazon.com/dp/B00AYQNR46" }
let(:html) { described_class.new(link).to_html }
@@ -156,7 +156,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
- context "amazon ebook page" do
+ describe "amazon ebook page" do
let(:link) { "https://www.amazon.com/dp/193435659X" }
let(:html) { described_class.new(link).to_html }
@@ -192,7 +192,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
- context "non-standard response from Amazon" do
+ describe "non-standard response from Amazon" do
let(:link) { "https://www.amazon.com/dp/B0123ABCD3210" }
let(:onebox) { described_class.new(link) }
@@ -215,7 +215,7 @@ RSpec.describe Onebox::Engine::AmazonOnebox do
end
end
- context "alternate page layout response from Amazon" do
+ describe "alternate page layout response from Amazon" do
let(:link) { "https://www.amazon.com/dp/B07FQ7M16H" }
let(:html) { described_class.new(link).to_html }
diff --git a/spec/lib/onebox/engine/github_actions_onebox_spec.rb b/spec/lib/onebox/engine/github_actions_onebox_spec.rb
index 8a24337c845..fb5b80b91d4 100644
--- a/spec/lib/onebox/engine/github_actions_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_actions_onebox_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
.to_return(status: 200, body: onebox_response("githubactions_pr_run"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@@ -34,7 +34,7 @@ RSpec.describe Onebox::Engine::GithubActionsOnebox do
.to_return(status: 200, body: onebox_response("githubactions_actions_run"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/github_blob_onebox_spec.rb b/spec/lib/onebox/engine/github_blob_onebox_spec.rb
index 6a25d8cfac7..6f926990e15 100644
--- a/spec/lib/onebox/engine/github_blob_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_blob_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubBlobOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/github_commit_onebox_spec.rb b/spec/lib/onebox/engine/github_commit_onebox_spec.rb
index a0a26b2be37..ec1d8a1e19e 100644
--- a/spec/lib/onebox/engine/github_commit_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_commit_onebox_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Onebox::Engine::GithubCommitOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response("githubcommit"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@@ -64,7 +64,7 @@ RSpec.describe Onebox::Engine::GithubCommitOnebox do
.to_return(status: 200, body: onebox_response("githubcommit"))
end
- include_context "engines"
+ include_context "with engines"
# TODO: fix test to make sure it's not failing when matching object
# it_behaves_like "an engine"
diff --git a/spec/lib/onebox/engine/github_folder_onebox_spec.rb b/spec/lib/onebox/engine/github_folder_onebox_spec.rb
index 849821ac885..86505c59313 100644
--- a/spec/lib/onebox/engine/github_folder_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_folder_onebox_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Onebox::Engine::GithubFolderOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/github_gist_onebox_spec.rb b/spec/lib/onebox/engine/github_gist_onebox_spec.rb
index 167c3a23f5a..6cbb285e005 100644
--- a/spec/lib/onebox/engine/github_gist_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_gist_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubGistOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#data" do
diff --git a/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb b/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
index af11fbfc660..546ff00438c 100644
--- a/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GithubPullRequestOnebox do
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/gitlab_blob_onebox_spec.rb b/spec/lib/onebox/engine/gitlab_blob_onebox_spec.rb
index 9cbf0769ccd..ec812b66bc5 100644
--- a/spec/lib/onebox/engine/gitlab_blob_onebox_spec.rb
+++ b/spec/lib/onebox/engine/gitlab_blob_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GitlabBlobOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/google_docs_onebox_spec.rb b/spec/lib/onebox/engine/google_docs_onebox_spec.rb
index 4326930e004..214fe05dab1 100644
--- a/spec/lib/onebox/engine/google_docs_onebox_spec.rb
+++ b/spec/lib/onebox/engine/google_docs_onebox_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Onebox::Engine::GoogleDocsOnebox do
stub_request(:get, @link).to_return(status: 200, body: onebox_response("googledocs"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/google_play_app_onebox_spec.rb b/spec/lib/onebox/engine/google_play_app_onebox_spec.rb
index 8df0dcea5f4..43bf0437e18 100644
--- a/spec/lib/onebox/engine/google_play_app_onebox_spec.rb
+++ b/spec/lib/onebox/engine/google_play_app_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::GooglePlayAppOnebox do
.to_return(status: 200, body: onebox_response("googleplayapp"))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
diff --git a/spec/lib/onebox/engine/hackernews_spec.rb b/spec/lib/onebox/engine/hackernews_spec.rb
index c1e448aad71..152ec7adc4d 100644
--- a/spec/lib/onebox/engine/hackernews_spec.rb
+++ b/spec/lib/onebox/engine/hackernews_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::HackernewsOnebox do
- context "When oneboxing a comment" do
+ context "when oneboxing a comment" do
let(:link) { "https://news.ycombinator.com/item?id=30181167" }
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/30181167.json" }
let(:html) { described_class.new(link).to_html }
@@ -27,7 +27,7 @@ RSpec.describe Onebox::Engine::HackernewsOnebox do
end
end
- context "When oneboxing a story" do
+ context "when oneboxing a story" do
let(:link) { "https://news.ycombinator.com/item?id=5172905" }
let(:api_link) { "https://hacker-news.firebaseio.com/v0/item/5172905.json" }
let(:html) { described_class.new(link).to_html }
diff --git a/spec/lib/onebox/engine/pubmed_onebox_spec.rb b/spec/lib/onebox/engine/pubmed_onebox_spec.rb
index 58450b84d84..135a6b8ae58 100644
--- a/spec/lib/onebox/engine/pubmed_onebox_spec.rb
+++ b/spec/lib/onebox/engine/pubmed_onebox_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Onebox::Engine::PubmedOnebox do
expect(html).to include(link)
end
- context "Pubmed electronic print" do
+ describe "Pubmed electronic print" do
let(:link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116" }
let(:xml_link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116?report=xml&format=text" }
let(:html) { described_class.new(link).to_html }
@@ -56,7 +56,7 @@ RSpec.describe Onebox::Engine::PubmedOnebox do
end
end
- context "regex URI match" do
+ describe "regex URI match" do
it "matches on specific articles" do
expect(match("http://www.ncbi.nlm.nih.gov/pubmed/7288891")).to eq true
end
diff --git a/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb b/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
index 03f5824e6f4..cd7ac3d9ed3 100644
--- a/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
+++ b/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Onebox::Engine::StackExchangeOnebox do
.to_return(status: 200, body: onebox_response('stackexchange-question'))
end
- include_context 'engines'
+ include_context 'with engines'
it_behaves_like 'an engine'
describe '#to_html' do
@@ -80,7 +80,7 @@ RSpec.describe Onebox::Engine::StackExchangeOnebox do
.to_return(status: 200, body: onebox_response('stackexchange-answer'))
end
- include_context 'engines'
+ include_context 'with engines'
it_behaves_like 'an engine'
describe '#to_html' do
diff --git a/spec/lib/onebox/engine/trello_onebox_spec.rb b/spec/lib/onebox/engine/trello_onebox_spec.rb
index 136f4ff7c5c..0d795afa231 100644
--- a/spec/lib/onebox/engine/trello_onebox_spec.rb
+++ b/spec/lib/onebox/engine/trello_onebox_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Onebox::Engine::TrelloOnebox do
- context "Boards" do
+ describe "Boards" do
it "should onebox with SEF url corrrectly" 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
@@ -14,7 +14,7 @@ RSpec.describe Onebox::Engine::TrelloOnebox do
end
end
- context "Cards" do
+ describe "Cards" do
it "should onebox with SEF url corrrectly" do
expect(Onebox.preview('https://trello.com/c/NIRpzVDM/1211-what-can-you-expect-from-this-board').to_s).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
end
diff --git a/spec/lib/onebox/engine/twitter_status_onebox_spec.rb b/spec/lib/onebox/engine/twitter_status_onebox_spec.rb
index d60c2f99a65..6edf74928cc 100644
--- a/spec/lib/onebox/engine/twitter_status_onebox_spec.rb
+++ b/spec/lib/onebox/engine/twitter_status_onebox_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
end
end
- shared_context "standard tweet info" do
+ shared_context "with standard tweet info" do
before do
@link = "https://twitter.com/vyki_e/status/363116819147538433"
@onebox_fixture = "twitterstatus"
@@ -55,7 +55,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
let(:retweets_count) { "0" }
end
- shared_context "quoted tweet info" do
+ shared_context "with quoted tweet info" do
before do
@link = "https://twitter.com/metallica/status/1128068672289890305"
@onebox_fixture = "twitterstatus_quoted"
@@ -72,7 +72,7 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
let(:retweets_count) { "201" }
end
- shared_context "featured image info" do
+ shared_context "with featured image info" do
before do
@link = "https://twitter.com/codinghorror/status/1409351083177046020"
@onebox_fixture = "twitterstatus_featured_image"
@@ -111,8 +111,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
context "with a standard tweet" do
let(:tweet_content) { "I'm a sucker for pledges." }
- include_context "standard tweet info"
- include_context "engines"
+ include_context "with standard tweet info"
+ include_context "with engines"
it_behaves_like "an engine"
it_behaves_like "#to_html"
@@ -123,8 +123,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
"Thank you to everyone who came out for #MetInParis last night for helping us support @EMMAUSolidarite &amp;"
end
- include_context "quoted tweet info"
- include_context "engines"
+ include_context "with quoted tweet info"
+ include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'
@@ -136,8 +136,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
"My first text message from my child! A moment that shall live on in infamy!"
end
- include_context "featured image info"
- include_context "engines"
+ include_context "with featured image info"
+ include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'
@@ -289,8 +289,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
}
end
- include_context "standard tweet info"
- include_context "engines"
+ include_context "with standard tweet info"
+ include_context "with engines"
it_behaves_like "an engine"
it_behaves_like "#to_html"
@@ -674,8 +674,8 @@ RSpec.describe Onebox::Engine::TwitterStatusOnebox do
}
end
- include_context "quoted tweet info"
- include_context "engines"
+ include_context "with quoted tweet info"
+ include_context "with engines"
it_behaves_like "an engine"
it_behaves_like '#to_html'
diff --git a/spec/lib/onebox/engine/wikipedia_onebox_spec.rb b/spec/lib/onebox/engine/wikipedia_onebox_spec.rb
index 4ad63992494..c55305c3dcf 100644
--- a/spec/lib/onebox/engine/wikipedia_onebox_spec.rb
+++ b/spec/lib/onebox/engine/wikipedia_onebox_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
end
- include_context "engines"
+ include_context "with engines"
it_behaves_like "an engine"
describe "#to_html" do
@@ -21,7 +21,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
end
end
- context "url with section hash" do
+ describe "url with section hash" do
before do
@link = "http://en.wikipedia.org/wiki/Billy_Jack#Soundtrack"
end
@@ -31,7 +31,7 @@ RSpec.describe Onebox::Engine::WikipediaOnebox do
end
end
- context "url with url-encoded section hash" do
+ describe "url with url-encoded section hash" do
before do
@link = "https://fr.wikipedia.org/wiki/Th%C3%A9ologie#La_th%C3%A9ologie_selon_Aristote"
diff --git a/spec/lib/onebox/helpers_spec.rb b/spec/lib/onebox/helpers_spec.rb
index c8f8c1547dd..22f97cebde3 100644
--- a/spec/lib/onebox/helpers_spec.rb
+++ b/spec/lib/onebox/helpers_spec.rb
@@ -51,7 +51,7 @@ RSpec.describe Onebox::Helpers do
expect(described_class.fetch_html_doc(uri).to_s).to match("success")
end
- context "canonical link" do
+ context "with canonical link" do
it "follows canonical link" do
uri = 'https://www.example.com'
stub_request(:get, uri).to_return(status: 200, body: "<!DOCTYPE html><link rel='canonical' href='http://foobar.com/'/><p>invalid</p>")
@@ -133,7 +133,7 @@ RSpec.describe Onebox::Helpers do
end
describe "user_agent" do
- context "default" do
+ context "with default" do
it "has the default Discourse user agent" do
stub_request(:get, "http://example.com/some-resource")
.with(headers: { "user-agent" => /Discourse Forum Onebox/ })
@@ -143,7 +143,7 @@ RSpec.describe Onebox::Helpers do
end
end
- context "Custom option" do
+ context "with custom option" do
around do |example|
previous_options = Onebox.options.to_h
Onebox.options = { user_agent: "EvilTroutBot v0.1" }
diff --git a/spec/lib/oneboxer_spec.rb b/spec/lib/oneboxer_spec.rb
index 2ae8c97de21..b011f6fbbf1 100644
--- a/spec/lib/oneboxer_spec.rb
+++ b/spec/lib/oneboxer_spec.rb
@@ -25,8 +25,7 @@ RSpec.describe Oneboxer do
end
end
- context "local oneboxes" do
-
+ describe "local oneboxes" do
def link(url)
url = "#{Discourse.base_url}#{url}"
%{<a href="#{url}">#{url}</a>}
@@ -171,8 +170,7 @@ RSpec.describe Oneboxer do
<html>
HTML
- context "blacklisted domains" do
-
+ context "with blacklisted domains" do
it "does not return a onebox if redirect uri final destination is in blacklist" do
SiteSetting.blocked_onebox_domains = "kitten.com"
@@ -451,7 +449,7 @@ RSpec.describe Oneboxer do
expect(Oneboxer.onebox("https://allowlist.ed/iframes", invalidate_oneboxes: true)).to match("iframe src")
end
- context 'missing attributes' do
+ describe 'missing attributes' do
before do
stub_request(:head, url)
end
@@ -480,7 +478,7 @@ RSpec.describe Oneboxer do
end
end
- context 'instagram' do
+ describe 'instagram' do
it 'providing a token should attempt to use new endpoint' do
url = "https://www.instagram.com/p/CHLkBERAiLa"
access_token = 'abc123'
@@ -558,7 +556,7 @@ RSpec.describe Oneboxer do
end
end
- context 'strategies' do
+ describe 'strategies' do
it "has a 'default' strategy" do
expect(Oneboxer.strategies.keys.first).to eq(:default)
end
@@ -568,7 +566,7 @@ RSpec.describe Oneboxer do
expect(Oneboxer.strategies[strategy].keys).not_to eq([])
end
- context "using a non-default strategy" do
+ context "when using a non-default strategy" do
let(:hostname) { "my.interesting.site" }
let(:url) { "https://#{hostname}/cool/content" }
let(:html) do
@@ -646,7 +644,7 @@ RSpec.describe Oneboxer do
end
end
- context "register_local_handler" do
+ describe "register_local_handler" do
it "calls registered local handler" do
Oneboxer.register_local_handler('wizard') do |url, route|
'Custom Onebox for Wizard'
diff --git a/spec/lib/plain_text_to_markdown_spec.rb b/spec/lib/plain_text_to_markdown_spec.rb
index e358cf67b2a..c6f9af3b70c 100644
--- a/spec/lib/plain_text_to_markdown_spec.rb
+++ b/spec/lib/plain_text_to_markdown_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe PlainTextToMarkdown do
let(:nbsp) { "&nbsp;" }
- context "quotes" do
+ describe "quotes" do
it "uses the correct quote level" do
expect(to_markdown("> foo")).to eq("> foo")
expect(to_markdown(">>> foo")).to eq(">>> foo")
@@ -47,7 +47,7 @@ RSpec.describe PlainTextToMarkdown do
end
end
- context "special characters" do
+ describe "special characters" do
it "escapes special Markdown characters" do
expect(to_markdown('\ backslash')).to eq('\\\\ backslash')
expect(to_markdown('` backtick')).to eq('\` backtick')
@@ -77,7 +77,7 @@ RSpec.describe PlainTextToMarkdown do
end
end
- context "indentation" do
+ describe "indentation" do
it "does not replace one leading whitespace" do
expect(to_markdown(" foo")).to eq(" foo")
end
@@ -106,7 +106,7 @@ RSpec.describe PlainTextToMarkdown do
end
end
- context "format=flowed" do
+ describe "format=flowed" do
it "concats lines ending with a space" do
text = "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Quasi vero, inquit, \nperpetua oratio rhetorum solum, non \netiam philosophorum sit."
markdown = "Lorem ipsum dolor sit amet, consectetur adipiscing elit\\. Quasi vero, inquit, perpetua oratio rhetorum solum, non etiam philosophorum sit\\."
@@ -157,7 +157,7 @@ RSpec.describe PlainTextToMarkdown do
end
end
- context "links" do
+ describe "links" do
it "removes duplicate links" do
expect(to_markdown("foo https://www.example.com/foo.html?a=1 <https://www.example.com/foo.html?a=1> bar"))
.to eq("foo https://www.example.com/foo.html?a=1 bar")
@@ -186,7 +186,7 @@ RSpec.describe PlainTextToMarkdown do
end
end
- context "code" do
+ describe "code" do
it "detects matching Markdown code block within backticks" do
expect(to_markdown("foo\n```\n<this is code>\n```")).to eq("foo\n```\n<this is code>\n```")
end
diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb
index 0556a985948..b22f10c8fd3 100644
--- a/spec/lib/plugin/instance_spec.rb
+++ b/spec/lib/plugin/instance_spec.rb
@@ -1,12 +1,11 @@
# frozen_string_literal: true
RSpec.describe Plugin::Instance do
-
after do
DiscoursePluginRegistry.reset!
end
- context "find_all" do
+ describe "find_all" do
it "can find plugins correctly" do
plugins = Plugin::Instance.find_all("#{Rails.root}/spec/fixtures/plugins")
expect(plugins.count).to eq(5)
@@ -22,14 +21,12 @@ RSpec.describe Plugin::Instance do
end
end
- context "enabling/disabling" do
-
+ describe "enabling/disabling" do
it "is enabled by default" do
expect(Plugin::Instance.new.enabled?).to eq(true)
end
context "with a plugin that extends things" do
-
class Trout
attr_accessor :data
end
@@ -128,7 +125,7 @@ RSpec.describe Plugin::Instance do
end
end
- context "register asset" do
+ describe "register asset" do
it "populates the DiscoursePluginRegistry" do
plugin = Plugin::Instance.new nil, "/tmp/test.rb"
plugin.register_asset("test.css")
@@ -150,7 +147,7 @@ RSpec.describe Plugin::Instance do
end
end
- context "register service worker" do
+ describe "register service worker" do
it "populates the DiscoursePluginRegistry" do
plugin = Plugin::Instance.new nil, "/tmp/test.rb"
plugin.register_service_worker("test.js")
@@ -210,7 +207,7 @@ RSpec.describe Plugin::Instance do
expect(authenticator.enabled?).to eq(false)
end
- context "activate!" do
+ describe "#activate!" do
before do
# lets piggy back on another boolean setting, so we don't dirty our SiteSetting object
SiteSetting.enable_badges = false
@@ -271,7 +268,7 @@ RSpec.describe Plugin::Instance do
end
end
- context "serialized_current_user_fields" do
+ describe "serialized_current_user_fields" do
before do
DiscoursePluginRegistry.serialized_current_user_fields << "has_car"
end
@@ -303,7 +300,7 @@ RSpec.describe Plugin::Instance do
end
end
- context "register_color_scheme" do
+ describe "#register_color_scheme" do
it "can add a color scheme for the first time" do
plugin = Plugin::Instance.new nil, "/tmp/test.rb"
expect {
@@ -380,7 +377,7 @@ RSpec.describe Plugin::Instance do
end
end
- context "locales" do
+ describe "locales" do
let(:plugin_path) { "#{Rails.root}/spec/fixtures/plugins/custom_locales" }
let!(:plugin) { Plugin::Instance.new(nil, "#{plugin_path}/plugin.rb") }
let(:plural) do
diff --git a/spec/lib/plugin/metadata_spec.rb b/spec/lib/plugin/metadata_spec.rb
index f7d4d492317..922e6b92c54 100644
--- a/spec/lib/plugin/metadata_spec.rb
+++ b/spec/lib/plugin/metadata_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Plugin::Metadata do
- context "parse" do
+ describe "parse" do
it "correctly parses plugin info" do
metadata = Plugin::Metadata.parse <<TEXT
# name: plugin-name
@@ -49,5 +49,4 @@ TEXT
official("discourse-data-explorer")
unofficial("babble")
end
-
end
diff --git a/spec/lib/post_action_creator_spec.rb b/spec/lib/post_action_creator_spec.rb
index 6a10739deb2..8343f730964 100644
--- a/spec/lib/post_action_creator_spec.rb
+++ b/spec/lib/post_action_creator_spec.rb
@@ -25,7 +25,6 @@ RSpec.describe PostActionCreator do
end
describe "messaging" do
-
it "doesn't generate title longer than 255 characters" do
topic = Fabricate(:topic, title: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet rutrum neque. Pellentesque suscipit vehicula facilisis. Phasellus lacus sapien, aliquam nec convallis sit amet, vestibulum laoreet ante. Curabitur et pellentesque tortor. Donec non.")
post = Fabricate(:post, topic: topic)
@@ -119,7 +118,7 @@ RSpec.describe PostActionCreator do
end
end
- context "flags" do
+ describe "flags" do
it "will create a reviewable if one does not exist" do
result = PostActionCreator.create(user, post, :inappropriate)
expect(result.success?).to eq(true)
@@ -167,7 +166,7 @@ RSpec.describe PostActionCreator do
end
end
- context "existing reviewable" do
+ context "with existing reviewable" do
let!(:reviewable) {
PostActionCreator.create(Fabricate(:user), post, :inappropriate).reviewable
}
@@ -237,7 +236,7 @@ RSpec.describe PostActionCreator do
end
end
- context "take_action" do
+ describe "take_action" do
before do
PostActionCreator.create(Fabricate(:user), post, :inappropriate)
end
@@ -256,8 +255,7 @@ RSpec.describe PostActionCreator do
end
end
- context "queue_for_review" do
-
+ describe "queue_for_review" do
it 'fails if the user is not a staff member' do
creator = PostActionCreator.new(
user, post,
diff --git a/spec/lib/post_action_destroyer_spec.rb b/spec/lib/post_action_destroyer_spec.rb
index d38e4b994b5..f381897b81d 100644
--- a/spec/lib/post_action_destroyer_spec.rb
+++ b/spec/lib/post_action_destroyer_spec.rb
@@ -6,8 +6,8 @@ RSpec.describe PostActionDestroyer do
fab!(:post) { Fabricate(:post) }
describe '#perform' do
- context 'like' do
- context 'post action exists' do
+ context 'with like' do
+ context 'when post action exists' do
before do
PostActionCreator.new(user, post, PostActionType.types[:like]).perform
end
@@ -49,18 +49,16 @@ RSpec.describe PostActionDestroyer do
end
end
- context 'post action doesn’t exist' do
- describe 'perform' do
- it 'fails' do
- result = PostActionDestroyer.destroy(user, post, :like)
- expect(result.success).to eq(false)
- expect(result.not_found).to eq(true)
- end
+ context 'when post action doesn’t exist' do
+ it 'fails' do
+ result = PostActionDestroyer.destroy(user, post, :like)
+ expect(result.success).to eq(false)
+ expect(result.not_found).to eq(true)
end
end
end
- context 'any other notifiable type' do
+ context 'with any other notifiable type' do
before do
PostActionCreator.new(user, post, PostActionType.types[:spam]).perform
end
diff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rb
index b3156a22ce0..d32e14cb5f9 100644
--- a/spec/lib/post_creator_spec.rb
+++ b/spec/lib/post_creator_spec.rb
@@ -4,14 +4,13 @@ require 'post_creator'
require 'topic_subtype'
RSpec.describe PostCreator do
-
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:coding_horror) { Fabricate(:coding_horror) }
fab!(:evil_trout) { Fabricate(:evil_trout) }
let(:topic) { Fabricate(:topic, user: user) }
- context "new topic" do
+ describe "new topic" do
fab!(:category) { Fabricate(:category, user: user) }
let(:basic_topic_params) { { title: "hello world topic", raw: "my name is fred", archetype_id: 1, advance_draft: true } }
let(:image_sizes) { { 'http://an.image.host/image.jpg' => { "width" => 111, "height" => 222 } } }
@@ -63,14 +62,14 @@ RSpec.describe PostCreator do
expect(post.topic.custom_fields).to eq("hello" => "world")
end
- context "reply to post number" do
+ context "with reply to post number" do
it "omits reply to post number if received on a new topic" do
p = PostCreator.new(user, basic_topic_params.merge(reply_to_post_number: 3)).create
expect(p.reply_to_post_number).to be_nil
end
end
- context "invalid title" do
+ context "with invalid title" do
let(:creator_invalid_title) { PostCreator.new(user, basic_topic_params.merge(title: 'a')) }
it "has errors" do
@@ -79,7 +78,7 @@ RSpec.describe PostCreator do
end
end
- context "invalid raw" do
+ context "with invalid raw" do
let(:creator_invalid_raw) { PostCreator.new(user, basic_topic_params.merge(raw: '')) }
it "has errors" do
@@ -88,7 +87,7 @@ RSpec.describe PostCreator do
end
end
- context "success" do
+ context "with success" do
before { creator }
it "is not hidden" do
@@ -477,11 +476,11 @@ RSpec.describe PostCreator do
end
end
- context "tags" do
+ context "with tags" do
let(:tag_names) { ['art', 'science', 'dance'] }
let(:creator_with_tags) { PostCreator.new(user, basic_topic_params.merge(tags: tag_names)) }
- context "tagging disabled" do
+ context "with tagging disabled" do
before do
SiteSetting.tagging_enabled = false
end
@@ -492,12 +491,12 @@ RSpec.describe PostCreator do
end
end
- context "tagging enabled" do
+ context "with tagging enabled" do
before do
SiteSetting.tagging_enabled = true
end
- context "can create tags" do
+ context "when can create tags" do
before do
SiteSetting.min_trust_to_create_tag = 0
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -516,7 +515,7 @@ RSpec.describe PostCreator do
end
end
- context "cannot create tags" do
+ context "when cannot create tags" do
before do
SiteSetting.min_trust_to_create_tag = 4
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -529,7 +528,7 @@ RSpec.describe PostCreator do
end
end
- context "automatically tags first posts" do
+ context "when automatically tagging first posts" do
before do
SiteSetting.min_trust_to_create_tag = 0
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -587,7 +586,7 @@ RSpec.describe PostCreator do
end
end
- context 'whisper' do
+ describe 'whisper' do
fab!(:topic) { Fabricate(:topic, user: user) }
it 'whispers do not mess up the public view' do
@@ -665,7 +664,7 @@ RSpec.describe PostCreator do
end
end
- context 'silent' do
+ describe 'silent' do
fab!(:topic) { Fabricate(:topic, user: user) }
it 'silent do not mess up the public view' do
@@ -695,13 +694,12 @@ RSpec.describe PostCreator do
end
end
- context 'uniqueness' do
-
+ describe 'uniqueness' do
fab!(:topic) { Fabricate(:topic, user: user) }
let(:basic_topic_params) { { raw: 'test reply', topic_id: topic.id, reply_to_post_number: 4 } }
let(:creator) { PostCreator.new(user, basic_topic_params) }
- context "disabled" do
+ context "when disabled" do
before do
SiteSetting.unique_posts_mins = 0
creator.create
@@ -713,7 +711,7 @@ RSpec.describe PostCreator do
end
end
- context 'enabled' do
+ context 'when enabled' do
let(:new_post_creator) { PostCreator.new(user, basic_topic_params) }
before do
@@ -757,8 +755,7 @@ RSpec.describe PostCreator do
end
- context "host spam" do
-
+ describe "host spam" do
fab!(:topic) { Fabricate(:topic, user: user) }
let(:basic_topic_params) { { raw: 'test reply', topic_id: topic.id, reply_to_post_number: 4 } }
let(:creator) { PostCreator.new(user, basic_topic_params) }
@@ -792,7 +789,7 @@ RSpec.describe PostCreator do
end
# more integration testing ... maximise our testing
- context 'existing topic' do
+ describe 'existing topic' do
fab!(:topic) { Fabricate(:topic, user: user, title: 'topic title with 25 chars') }
let(:creator) { PostCreator.new(user, raw: 'test reply', topic_id: topic.id, reply_to_post_number: 4) }
@@ -804,7 +801,7 @@ RSpec.describe PostCreator do
expect(creator.errors.messages[:base][0]).to match I18n.t(:topic_not_found)
end
- context 'success' do
+ context 'with success' do
it 'create correctly' do
post = creator.create
expect(Post.count).to eq(1)
@@ -836,7 +833,7 @@ RSpec.describe PostCreator do
end
end
- context "topic stats" do
+ context "with topic stats" do
before do
PostCreator.new(
coding_horror,
@@ -924,7 +921,7 @@ RSpec.describe PostCreator do
end
end
- context 'closed topic' do
+ describe 'closed topic' do
fab!(:topic) { Fabricate(:topic, user: user, closed: true) }
let(:creator) { PostCreator.new(user, raw: 'test reply', topic_id: topic.id, reply_to_post_number: 4) }
@@ -936,7 +933,7 @@ RSpec.describe PostCreator do
end
end
- context 'missing topic' do
+ describe 'missing topic' do
let(:topic) { Fabricate(:topic, user: user, deleted_at: 5.minutes.ago) }
let(:creator) { PostCreator.new(user, raw: 'test reply', topic_id: topic.id, reply_to_post_number: 4) }
@@ -948,7 +945,7 @@ RSpec.describe PostCreator do
end
end
- context "cooking options" do
+ describe "cooking options" do
let(:raw) { "this is my awesome message body hello world" }
it "passes the cooking options through correctly" do
@@ -963,7 +960,7 @@ RSpec.describe PostCreator do
end
# integration test ... minimise db work
- context 'private message' do
+ describe 'private message' do
let(:target_user1) { coding_horror }
fab!(:target_user2) { Fabricate(:moderator) }
fab!(:unrelated_user) { Fabricate(:user) }
@@ -1067,7 +1064,7 @@ RSpec.describe PostCreator do
end
end
- context "warnings" do
+ describe "warnings" do
let(:target_user1) { coding_horror }
fab!(:target_user2) { Fabricate(:moderator) }
let(:base_args) do
@@ -1105,7 +1102,7 @@ RSpec.describe PostCreator do
end
end
- context 'auto closing' do
+ describe 'auto closing' do
it 'closes private messages that have more than N posts' do
SiteSetting.auto_close_messages_post_count = 2
@@ -1146,7 +1143,7 @@ RSpec.describe PostCreator do
end
end
- context 'private message to group' do
+ describe 'private message to group' do
let(:target_user1) { coding_horror }
fab!(:target_user2) { Fabricate(:moderator) }
let(:group) do
@@ -1202,7 +1199,7 @@ RSpec.describe PostCreator do
end
end
- context 'setting created_at' do
+ describe 'setting created_at' do
it 'supports Time instances' do
freeze_time
@@ -1248,7 +1245,7 @@ RSpec.describe PostCreator do
end
end
- context 'disable validations' do
+ describe 'disable validations' do
it 'can save a post' do
creator = PostCreator.new(user, raw: 'q', title: 'q', skip_validations: true)
creator.create
@@ -1268,7 +1265,6 @@ RSpec.describe PostCreator do
end
describe "embed_url" do
-
let(:embed_url) { "http://eviltrout.com/stupid-url" }
it "creates the topic_embed record" do
@@ -1319,7 +1315,7 @@ RSpec.describe PostCreator do
expect(post.raw).to eq(" <-- whitespaces -->")
end
- context "events" do
+ describe "events" do
before do
@posts_created = 0
@topics_created = 0
@@ -1350,7 +1346,7 @@ RSpec.describe PostCreator do
end
end
- context "staged users" do
+ describe "staged users" do
fab!(:staged) { Fabricate(:staged) }
it "automatically watches all messages it participates in" do
@@ -1364,7 +1360,7 @@ RSpec.describe PostCreator do
end
end
- context "topic tracking" do
+ describe "topic tracking" do
it "automatically watches topic based on preference" do
user.user_option.notification_level_when_replying = 3
@@ -1486,7 +1482,7 @@ RSpec.describe PostCreator do
end
end
- context 'private message to a user that has disabled private messages' do
+ describe 'private message to a user that has disabled private messages' do
fab!(:another_user) { Fabricate(:user, username: 'HelloWorld') }
before do
@@ -1522,7 +1518,7 @@ RSpec.describe PostCreator do
end
end
- context "private message to a muted user" do
+ describe "private message to a muted user" do
fab!(:muted_me) { evil_trout }
fab!(:another_user) { Fabricate(:user) }
@@ -1563,7 +1559,7 @@ RSpec.describe PostCreator do
end
end
- context "private message to an ignored user" do
+ describe "private message to an ignored user" do
fab!(:ignorer) { evil_trout }
fab!(:another_user) { Fabricate(:user) }
@@ -1605,7 +1601,7 @@ RSpec.describe PostCreator do
end
- context "private message to user in allow list" do
+ describe "private message to user in allow list" do
fab!(:sender) { evil_trout }
fab!(:allowed_user) { Fabricate(:user) }
@@ -1651,7 +1647,7 @@ RSpec.describe PostCreator do
end
end
- context "private message to user not in allow list" do
+ describe "private message to user not in allow list" do
fab!(:sender) { evil_trout }
fab!(:allowed_user) { Fabricate(:user) }
fab!(:not_allowed_user) { Fabricate(:user) }
@@ -1693,7 +1689,7 @@ RSpec.describe PostCreator do
end
end
- context "private message when post author is admin who is not in allow list" do
+ describe "private message when post author is admin who is not in allow list" do
fab!(:staff_user) { Fabricate(:admin) }
fab!(:allowed_user) { Fabricate(:user) }
fab!(:not_allowed_user) { Fabricate(:user) }
@@ -1712,7 +1708,7 @@ RSpec.describe PostCreator do
end
end
- context "private message to multiple users and one is not allowed" do
+ describe "private message to multiple users and one is not allowed" do
fab!(:sender) { evil_trout }
fab!(:allowed_user) { Fabricate(:user) }
fab!(:not_allowed_user) { Fabricate(:user) }
@@ -1740,7 +1736,7 @@ RSpec.describe PostCreator do
end
end
- context "private message recipients limit (max_allowed_message_recipients) reached" do
+ describe "private message recipients limit (max_allowed_message_recipients) reached" do
fab!(:target_user1) { coding_horror }
fab!(:target_user2) { evil_trout }
fab!(:target_user3) { Fabricate(:walter_white) }
@@ -1776,10 +1772,10 @@ RSpec.describe PostCreator do
end
end
- context "always succeeds if the user is staff" do
+ context "if the user is staff" do
fab!(:staff_user) { Fabricate(:admin) }
- it 'when sending message to multiple recipients' do
+ it 'succeeds when sending message to multiple recipients' do
pc = PostCreator.new(
staff_user,
title: 'this message is for multiple recipients!',
@@ -1828,7 +1824,7 @@ RSpec.describe PostCreator do
end
end
- context "secure media uploads" do
+ describe "secure media uploads" do
fab!(:image_upload) { Fabricate(:upload, secure: true) }
fab!(:user2) { Fabricate(:user) }
fab!(:public_topic) { Fabricate(:topic) }
@@ -1849,7 +1845,7 @@ RSpec.describe PostCreator do
end
end
- context 'queue for review' do
+ describe 'queue for review' do
before { SiteSetting.review_every_post = true }
it 'created a reviewable post after creating the post' do
diff --git a/spec/lib/post_destroyer_spec.rb b/spec/lib/post_destroyer_spec.rb
index 56f120a1877..019db8de92b 100644
--- a/spec/lib/post_destroyer_spec.rb
+++ b/spec/lib/post_destroyer_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe PostDestroyer do
-
before do
UserActionManager.enable
end
@@ -12,7 +11,6 @@ RSpec.describe PostDestroyer do
let(:post) { create_post }
describe "destroy_old_hidden_posts" do
-
it "destroys posts that have been hidden for 30 days" do
now = Time.now
@@ -44,7 +42,6 @@ RSpec.describe PostDestroyer do
expect(reply3.deleted_at).to eq(nil)
expect(reply4.deleted_at).to eq(nil)
end
-
end
describe 'destroy_old_stubs' do
@@ -214,8 +211,7 @@ RSpec.describe PostDestroyer do
expect(recovered_topic.deleted_by_id).to be_nil
end
- context "recover" do
-
+ context "with recover" do
it "doesn't raise an error when the raw doesn't change" do
PostRevisor.new(@reply).revise!(
@user,
@@ -256,7 +252,7 @@ RSpec.describe PostDestroyer do
end
end
- context "recovered by admin" do
+ context "when recovered by admin" do
it "should set user_deleted to false" do
PostDestroyer.new(@user, @reply).destroy
expect(@reply.reload.user_deleted).to eq(true)
@@ -286,7 +282,7 @@ RSpec.describe PostDestroyer do
expect(UserAction.where(target_topic_id: post.topic_id, action_type: UserAction::REPLY).count).to eq(1)
end
- context "recovered by user with access to moderate topic category" do
+ context "when recovered by user with access to moderate topic category" do
fab!(:review_user) { Fabricate(:user) }
before do
@@ -530,7 +526,7 @@ RSpec.describe PostDestroyer do
end
end
- context "deleted by user with access to moderate topic category" do
+ context "when deleted by user with access to moderate topic category" do
fab!(:review_user) { Fabricate(:user) }
before do
@@ -606,7 +602,7 @@ RSpec.describe PostDestroyer do
end
- context 'private message' do
+ describe 'private message' do
fab!(:author) { Fabricate(:user) }
fab!(:private_message) { Fabricate(:private_message_topic, user: author) }
fab!(:first_post) { Fabricate(:post, topic: private_message, user: author) }
@@ -665,8 +661,7 @@ RSpec.describe PostDestroyer do
end
end
- context 'deleting the second post in a topic' do
-
+ describe 'deleting the second post in a topic' do
fab!(:user) { Fabricate(:user) }
let!(:post) { create_post(user: user) }
let(:topic) { post.topic }
@@ -690,8 +685,7 @@ RSpec.describe PostDestroyer do
expect(topic.highest_post_number).to eq(post.post_number)
end
- context 'topic_user' do
-
+ context 'with topic_user' do
let(:topic_user) { second_user.topic_users.find_by(topic_id: topic.id) }
it 'clears the posted flag for the second user' do
@@ -704,7 +698,7 @@ RSpec.describe PostDestroyer do
end
end
- context "deleting a post belonging to a deleted topic" do
+ describe "deleting a post belonging to a deleted topic" do
let!(:topic) { post.topic }
let(:author) { post.user }
@@ -747,7 +741,7 @@ RSpec.describe PostDestroyer do
end
end
- context "deleting a reply belonging to a deleted topic" do
+ describe "deleting a reply belonging to a deleted topic" do
let!(:topic) { post.topic }
let!(:reply) { create_post(topic_id: topic.id, user: post.user) }
let(:author) { reply.user }
@@ -802,7 +796,6 @@ RSpec.describe PostDestroyer do
end
describe 'after delete' do
-
fab!(:coding_horror) { coding_horror }
fab!(:post) { Fabricate(:post, raw: "Hello @CodingHorror") }
@@ -834,8 +827,7 @@ RSpec.describe PostDestroyer do
end
end
- describe 'with a reply' do
-
+ context 'with a reply' do
fab!(:reply) { Fabricate(:basic_reply, user: coding_horror, topic: post.topic) }
let!(:post_reply) { PostReply.create(post_id: post.id, reply_post_id: reply.id) }
@@ -858,12 +850,10 @@ RSpec.describe PostDestroyer do
p = Fabricate(:post, user: post.user, topic: post.topic)
expect(p.post_number).to eq(3)
end
-
end
-
end
- context '@mentions' do
+ describe '@mentions' do
it 'removes notifications when deleted' do
Jobs.run_immediately!
user = Fabricate(:evil_trout)
diff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rb
index e6e64806bcb..f1d0918398c 100644
--- a/spec/lib/post_revisor_spec.rb
+++ b/spec/lib/post_revisor_spec.rb
@@ -3,7 +3,6 @@
require 'post_revisor'
RSpec.describe PostRevisor do
-
fab!(:topic) { Fabricate(:topic) }
fab!(:newuser) { Fabricate(:newuser, last_seen_at: Date.today) }
fab!(:user) { Fabricate(:user) }
@@ -12,7 +11,7 @@ RSpec.describe PostRevisor do
fab!(:moderator) { Fabricate(:moderator) }
let(:post_args) { { user: newuser, topic: topic } }
- context 'TopicChanges' do
+ describe 'TopicChanges' do
let(:tc) {
topic.reload
PostRevisor::TopicChanges.new(topic, topic.user)
@@ -43,7 +42,7 @@ RSpec.describe PostRevisor do
end
end
- context 'editing category' do
+ describe 'editing category' do
it "triggers the :post_edited event with topic_changed?" do
category = Fabricate(:category)
category.set_permissions(everyone: :full)
@@ -124,7 +123,7 @@ RSpec.describe PostRevisor do
end
end
- context 'editing tags' do
+ describe 'editing tags' do
fab!(:post) { Fabricate(:post) }
subject { PostRevisor.new(post) }
@@ -152,8 +151,7 @@ RSpec.describe PostRevisor do
end
end
- context 'revise wiki' do
-
+ describe 'revise wiki' do
before do
# There used to be a bug where wiki changes were considered posting "too similar"
# so this is enabled and checked
@@ -170,7 +168,7 @@ RSpec.describe PostRevisor do
end
end
- context 'revise' do
+ describe 'revise' do
let(:post) { Fabricate(:post, post_args) }
let(:first_version_at) { post.last_version_at }
@@ -473,7 +471,6 @@ RSpec.describe PostRevisor do
end
describe 'category topic' do
-
let!(:category) do
category = Fabricate(:category)
category.update_column(:topic_id, topic.id)
@@ -486,7 +483,7 @@ RSpec.describe PostRevisor do
expect(category.description).to be_blank
end
- context "one paragraph description" do
+ context "with one paragraph description" do
before do
subject.revise!(post.user, raw: new_description)
category.reload
@@ -501,7 +498,7 @@ RSpec.describe PostRevisor do
end
end
- context "multiple paragraph description" do
+ context "with multiple paragraph description" do
before do
subject.revise!(post.user, raw: "#{new_description}\n\nOther content goes here.")
category.reload
@@ -516,7 +513,7 @@ RSpec.describe PostRevisor do
end
end
- context "invalid description without paragraphs" do
+ context "with invalid description without paragraphs" do
before do
subject.revise!(post.user, raw: "# This is a title")
category.reload
@@ -670,8 +667,7 @@ RSpec.describe PostRevisor do
end.to change { post.user.user_stat.post_edits_count.to_i }.by(1)
end
- context 'second poster posts again quickly' do
-
+ context 'when second poster posts again quickly' do
it 'is a grace period edit, because the second poster posted again quickly' do
SiteSetting.editing_grace_period = 1.minute
subject.revise!(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.seconds)
@@ -682,7 +678,7 @@ RSpec.describe PostRevisor do
end
end
- context 'passing skip_revision as true' do
+ context 'when passing skip_revision as true' do
before do
SiteSetting.editing_grace_period = 1.minute
subject.revise!(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.hours, skip_revision: true)
@@ -773,7 +769,7 @@ RSpec.describe PostRevisor do
end
end
- context "logging staff edits" do
+ context "when logging staff edits" do
it "doesn't log when a regular user revises a post" do
subject.revise!(
post.user,
@@ -829,7 +825,7 @@ RSpec.describe PostRevisor do
end
end
- context "logging group moderator edits" do
+ context "when logging group moderator edits" do
fab!(:group_user) { Fabricate(:group_user) }
fab!(:category) { Fabricate(:category, reviewable_by_group_id: group_user.group.id, topic: topic) }
@@ -851,9 +847,8 @@ RSpec.describe PostRevisor do
end
end
- context "staff_edit_locks_post" do
-
- context "disabled" do
+ context "with staff_edit_locks_post" do
+ context "when disabled" do
before do
SiteSetting.staff_edit_locks_post = false
end
@@ -870,8 +865,7 @@ RSpec.describe PostRevisor do
end
end
- context "enabled" do
-
+ context "when enabled" do
before do
SiteSetting.staff_edit_locks_post = true
end
@@ -943,8 +937,7 @@ RSpec.describe PostRevisor do
end
end
- context "alerts" do
-
+ context "with alerts" do
fab!(:mentioned_user) { Fabricate(:user) }
before do
@@ -965,8 +958,8 @@ RSpec.describe PostRevisor do
end
- context "tagging" do
- context "tagging disabled" do
+ context "with tagging" do
+ context "with tagging disabled" do
before do
SiteSetting.tagging_enabled = false
end
@@ -979,12 +972,12 @@ RSpec.describe PostRevisor do
end
end
- context "tagging enabled" do
+ context "with tagging enabled" do
before do
SiteSetting.tagging_enabled = true
end
- context "can create tags" do
+ context "when can create tags" do
before do
SiteSetting.min_trust_to_create_tag = 0
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -1085,7 +1078,7 @@ RSpec.describe PostRevisor do
end
end
- context "hidden tags" do
+ context "with hidden tags" do
let(:bumped_at) { 1.day.ago }
before do
@@ -1146,7 +1139,7 @@ RSpec.describe PostRevisor do
end
end
- context "required tag group" do
+ context "with required tag group" do
fab!(:tag1) { Fabricate(:tag) }
fab!(:tag2) { Fabricate(:tag) }
fab!(:tag3) { Fabricate(:tag) }
@@ -1179,7 +1172,7 @@ RSpec.describe PostRevisor do
end
end
- context "cannot create tags" do
+ context "when cannot create tags" do
before do
SiteSetting.min_trust_to_create_tag = 4
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -1198,7 +1191,7 @@ RSpec.describe PostRevisor do
end
end
- context "uploads" do
+ context "with uploads" do
let(:image1) { Fabricate(:upload) }
let(:image2) { Fabricate(:upload) }
let(:image3) { Fabricate(:upload) }
@@ -1229,7 +1222,7 @@ RSpec.describe PostRevisor do
expect(post.reload.upload_references.pluck(:upload_id)).to contain_exactly(image2.id, image3.id, image4.id)
end
- context "secure media uploads" do
+ context "with secure media uploads" do
let!(:image5) { Fabricate(:secure_upload) }
before do
Jobs.run_immediately!
diff --git a/spec/lib/pretty_text/helpers_spec.rb b/spec/lib/pretty_text/helpers_spec.rb
index f39680ee3ce..d1c72183f65 100644
--- a/spec/lib/pretty_text/helpers_spec.rb
+++ b/spec/lib/pretty_text/helpers_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe PrettyText::Helpers do
-
- context "lookup_upload_urls" do
+ describe ".lookup_upload_urls" do
let(:upload) { Fabricate(:upload) }
it "should return cdn url if available" do
@@ -16,5 +15,4 @@ RSpec.describe PrettyText::Helpers do
expect(result[short_url][:url]).to eq("https://awesome.com#{upload.url}")
end
end
-
end
diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rb
index 02580f65eac..4974ead3271 100644
--- a/spec/lib/pretty_text_spec.rb
+++ b/spec/lib/pretty_text_spec.rb
@@ -21,8 +21,7 @@ RSpec.describe PrettyText do
let(:wrapped_image) { "<div class=\"lightbox-wrapper\"><a href=\"//localhost:3000/uploads/default/4399/33691397e78b4d75.png\" class=\"lightbox\" title=\"Screen Shot 2014-04-14 at 9.47.10 PM.png\"><img src=\"//localhost:3000/uploads/default/_optimized/bd9/b20/bbbcd6a0c0_655x500.png\" width=\"655\" height=\"500\"><div class=\"meta\">\n<span class=\"filename\">Screen Shot 2014-04-14 at 9.47.10 PM.png</span><span class=\"informations\">966x737 1.47 MB</span><span class=\"expand\"></span>\n</div></a></div>" }
describe "Quoting" do
-
- describe "with avatar" do
+ context "with avatar" do
let(:default_avatar) { "//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/{size}.png" }
before do
@@ -47,7 +46,7 @@ RSpec.describe PrettyText do
expect(cook("[quote=\"EvilTrout, post:2, topic:#{topic.id}\"]\nddd\n[/quote]", topic_id: 1)).to eq(n(expected))
end
- context "emojis" do
+ context "with emojis" do
let(:md) do
<<~MD
> This is a quote with a regular emoji :upside_down_face:
@@ -298,7 +297,7 @@ RSpec.describe PrettyText do
end
end
- describe "with primary user group" do
+ context "with primary user group" do
let(:default_avatar) { "//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/{size}.png" }
fab!(:group) { Fabricate(:group) }
fab!(:user) { Fabricate(:user, primary_group: group) }
@@ -367,8 +366,8 @@ RSpec.describe PrettyText do
expect(cooked.scan('quote]').length).to eq(0)
end
- describe "with letter avatar" do
- context "subfolder" do
+ context "with letter avatar" do
+ context "with subfolder" do
it "should have correct avatar url" do
set_subfolder "/forum"
md = <<~MD
@@ -383,7 +382,6 @@ RSpec.describe PrettyText do
end
describe "Mentions" do
-
it "can handle mentions after abbr" do
expect(PrettyText.cook("test <abbr>test</abbr>\n\n@bob")).to eq("<p>test <abbr>test</abbr></p>\n<p><span class=\"mention\">@bob</span></p>")
end
@@ -422,7 +420,7 @@ RSpec.describe PrettyText do
end
end
- context 'subfolder' do
+ context 'with subfolder' do
it "handles user and group mentions correctly" do
set_subfolder "/forum"
@@ -466,7 +464,7 @@ RSpec.describe PrettyText do
)
end
- describe 'when mentions are disabled' do
+ context 'when mentions are disabled' do
before do
SiteSetting.enable_mentions = false
end
@@ -727,7 +725,6 @@ RSpec.describe PrettyText do
end
describe "Excerpt" do
-
it "sanitizes attempts to inject invalid attributes" do
spinner = "<a href=\"http://thedailywtf.com/\" data-bbcode=\"' class='fa fa-spin\">WTF</a>"
expect(PrettyText.excerpt(spinner, 20)).to match_html spinner
@@ -736,13 +733,12 @@ RSpec.describe PrettyText do
expect(PrettyText.excerpt(spinner, 20)).to match_html spinner
end
- context "images" do
-
+ context "with images" do
it "should dump images" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif'>", 100)).to eq("[image]")
end
- context 'alt tags' do
+ context 'with alt tags' do
it "should keep alt tags" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' alt='car' title='my big car'>", 100)).to eq("[car]")
end
@@ -754,7 +750,7 @@ RSpec.describe PrettyText do
end
end
- context 'title tags' do
+ context 'with title tags' do
it "should keep title tags" do
expect(PrettyText.excerpt("<img src='http://cnn.com/a.gif' title='car'>", 100)).to eq("[car]")
end
@@ -796,7 +792,7 @@ RSpec.describe PrettyText do
end
end
- context "emojis" do
+ context "with emojis" do
it "should remove 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\">
@@ -987,7 +983,7 @@ RSpec.describe PrettyText do
expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:")
end
- context 'option to preserve onebox source' do
+ context 'with option to preserve onebox source' do
it "should return the right 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 = "<a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>"
@@ -2166,7 +2162,7 @@ HTML
expect(cooked).to match_html(html)
end
- context "customizing markdown-it rules" do
+ describe "customizing markdown-it rules" do
it 'customizes the markdown-it rules correctly' do
cooked = PrettyText.cook('This is some text **bold**', markdown_it_rules: [])
@@ -2178,7 +2174,7 @@ HTML
end
end
- context "enabling/disabling features" do
+ describe "enabling/disabling features" do
it "allows features to be overridden" do
cooked = PrettyText.cook(':grin: @mention', features_override: [])
diff --git a/spec/lib/promotion_spec.rb b/spec/lib/promotion_spec.rb
index 2312a4bca5b..3f5e6be0f98 100644
--- a/spec/lib/promotion_spec.rb
+++ b/spec/lib/promotion_spec.rb
@@ -3,7 +3,6 @@
require 'promotion'
RSpec.describe Promotion do
-
describe "review" do
it "skips regular users" do
# Reviewing users at higher trust levels is expensive, so trigger those reviews in a background job.
@@ -14,8 +13,7 @@ RSpec.describe Promotion do
end
end
- context "newuser" do
-
+ describe "newuser" do
fab!(:user) { Fabricate(:user, trust_level: TrustLevel[0], created_at: 2.days.ago) }
let(:promotion) { Promotion.new(user) }
@@ -23,7 +21,7 @@ RSpec.describe Promotion do
expect { Promotion.new(nil).review }.not_to raise_error
end
- context 'that has done nothing' do
+ context 'when user has done nothing' do
let!(:result) { promotion.review }
it "returns false" do
@@ -35,8 +33,7 @@ RSpec.describe Promotion do
end
end
- context "that has done the requisite things" do
-
+ context "when user has done the requisite things" do
before do
stat = user.user_stat
stat.topics_entered = SiteSetting.tl1_requires_topics_entered
@@ -54,7 +51,7 @@ RSpec.describe Promotion do
end
end
- context "that has not done the requisite things" do
+ context "when user has not done the requisite things" do
it "does not promote the user" do
user.created_at = 1.minute.ago
stat = user.user_stat
@@ -67,7 +64,7 @@ RSpec.describe Promotion do
end
end
- context "may send tl1 promotion messages" do
+ context "when may send tl1 promotion messages" do
before do
stat = user.user_stat
stat.topics_entered = SiteSetting.tl1_requires_topics_entered
@@ -112,7 +109,7 @@ RSpec.describe Promotion do
end
end
- context "may send tl2 promotion messages" do
+ context "when may send tl2 promotion messages" do
fab!(:user) { Fabricate(:user, trust_level: TrustLevel[1], created_at: (SiteSetting.tl2_requires_time_spent_mins * 60).minutes.ago) }
before do
@@ -142,12 +139,11 @@ RSpec.describe Promotion do
end
end
- context "basic" do
-
+ describe "basic" do
fab!(:user) { Fabricate(:user, trust_level: TrustLevel[1], created_at: 2.days.ago) }
let(:promotion) { Promotion.new(user) }
- context 'that has done nothing' do
+ context 'when has done nothing' do
let!(:result) { promotion.review }
it "returns false" do
@@ -159,8 +155,7 @@ RSpec.describe Promotion do
end
end
- context "that has done the requisite things" do
-
+ context "when has done the requisite things" do
before do
SiteSetting.tl2_requires_topic_reply_count = 3
@@ -213,11 +208,11 @@ RSpec.describe Promotion do
end
- context "regular" do
+ describe "regular" do
fab!(:user) { Fabricate(:user, trust_level: TrustLevel[2]) }
let(:promotion) { Promotion.new(user) }
- context "doesn't qualify for promotion" do
+ context "when doesn't qualify for promotion" do
before do
TrustLevel3Requirements.any_instance.expects(:requirements_met?).at_least_once.returns(false)
end
@@ -241,7 +236,7 @@ RSpec.describe Promotion do
end
end
- context "qualifies for promotion" do
+ context "when qualifies for promotion" do
before do
TrustLevel3Requirements.any_instance.expects(:requirements_met?).at_least_once.returns(true)
end
@@ -262,5 +257,4 @@ RSpec.describe Promotion do
end
end
end
-
end
diff --git a/spec/lib/rate_limiter_spec.rb b/spec/lib/rate_limiter_spec.rb
index 4d9774d07cb..83af13f8f63 100644
--- a/spec/lib/rate_limiter_spec.rb
+++ b/spec/lib/rate_limiter_spec.rb
@@ -3,7 +3,6 @@
require 'rate_limiter'
RSpec.describe RateLimiter do
-
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
let(:rate_limiter) { RateLimiter.new(user, "peppermint-butler", 2, 60) }
@@ -11,7 +10,7 @@ RSpec.describe RateLimiter do
let(:staff_rate_limiter) { RateLimiter.new(user, "peppermind-servant", 5, 40, staff_limit: { max: 10, secs: 80 }) }
let(:admin_staff_rate_limiter) { RateLimiter.new(admin, "peppermind-servant", 5, 40, staff_limit: { max: 10, secs: 80 }) }
- context 'disabled' do
+ describe 'disabled' do
before do
rate_limiter.performed!
rate_limiter.performed!
@@ -28,10 +27,9 @@ RSpec.describe RateLimiter do
it "doesn't raise an error on performed!" do
expect { rate_limiter.performed! }.not_to raise_error
end
-
end
- context 'enabled' do
+ describe 'enabled' do
before do
RateLimiter.enable
rate_limiter.clear!
@@ -39,10 +37,8 @@ RSpec.describe RateLimiter do
admin_staff_rate_limiter.clear!
end
- context 'aggressive rate limiter' do
-
+ context 'with aggressive rate limiter' do
it 'can operate correctly and totally stop limiting' do
-
freeze_time
# 2 requests every 30 seconds
@@ -76,12 +72,10 @@ RSpec.describe RateLimiter do
expect { limiter.performed! }.not_to raise_error
expect { limiter.performed! }.not_to raise_error
-
end
end
- context 'global rate limiter' do
-
+ context 'with global rate limiter' do
it 'can operate in global mode' do
limiter = RateLimiter.new(nil, "test", 2, 30, global: true)
limiter.clear!
@@ -100,10 +94,9 @@ RSpec.describe RateLimiter do
end
expect(thrown).to be(true)
end
-
end
- context 'handles readonly' do
+ context 'when handling readonly' do
before do
# random IP address in the ULA range that does not exist
Discourse.redis.without_namespace.slaveof 'fdec:3f5d:d0b7:4c4b:472b:636a:4370:7ac5', '49999'
@@ -118,7 +111,7 @@ RSpec.describe RateLimiter do
end
end
- context 'never done' do
+ context 'when never done' do
it "should perform right away" do
expect(rate_limiter.can_perform?).to eq(true)
end
@@ -128,7 +121,7 @@ RSpec.describe RateLimiter do
end
end
- context "remaining" do
+ context "when remaining" do
it "updates correctly" do
expect(rate_limiter.remaining).to eq(2)
rate_limiter.performed!
@@ -138,8 +131,7 @@ RSpec.describe RateLimiter do
end
end
- context 'max is less than or equal to zero' do
-
+ context 'when max is less than or equal to zero' do
it 'should raise the right error' do
[-1, 0, nil].each do |max|
expect do
@@ -149,7 +141,7 @@ RSpec.describe RateLimiter do
end
end
- context "multiple calls" do
+ context "with multiple calls" do
before do
freeze_time
rate_limiter.performed!
@@ -224,7 +216,7 @@ RSpec.describe RateLimiter do
end
end
- context "rollback!" do
+ describe "#rollback!" do
before do
rate_limiter.rollback!
end
@@ -237,8 +229,6 @@ RSpec.describe RateLimiter do
expect { rate_limiter.performed! }.not_to raise_error
end
end
-
end
end
-
end
diff --git a/spec/lib/retrieve_title_spec.rb b/spec/lib/retrieve_title_spec.rb
index 13c39ae8626..7edd62ff08a 100644
--- a/spec/lib/retrieve_title_spec.rb
+++ b/spec/lib/retrieve_title_spec.rb
@@ -1,9 +1,7 @@
# frozen_string_literal: true
RSpec.describe RetrieveTitle do
-
- context "extract_title" do
-
+ describe ".extract_title" do
it "will extract the value from the title tag" do
title = RetrieveTitle.extract_title(
"<html><title>My Cool Title</title></html>"
@@ -55,7 +53,7 @@ RSpec.describe RetrieveTitle do
end
end
- context "crawl" do
+ describe ".crawl" do
it "can properly extract a title from a url" do
stub_request(:get, "https://brelksdjflaskfj.com/amazing")
.to_return(status: 200, body: "<html><title>very amazing</title>")
@@ -156,7 +154,7 @@ RSpec.describe RetrieveTitle do
end
end
- context 'fetch_title' do
+ describe '.fetch_title' do
it "does not parse broken title tag" do
# webmock does not do chunks
stub_request(:get, "https://en.wikipedia.org/wiki/Internet").
diff --git a/spec/lib/rtl_spec.rb b/spec/lib/rtl_spec.rb
index 9f051b83e8a..f67aa0a5f97 100644
--- a/spec/lib/rtl_spec.rb
+++ b/spec/lib/rtl_spec.rb
@@ -1,17 +1,15 @@
# frozen_string_literal: true
RSpec.describe Rtl do
-
let(:user) { Fabricate.build(:user) }
describe '.css_class' do
-
- context 'user locale is allowed' do
+ context 'when user locale is allowed' do
before {
SiteSetting.allow_user_locale = true
}
- context 'user locale is RTL' do
+ context 'when user locale is RTL' do
before { user.locale = 'he' }
it 'returns rtl class' do
@@ -19,18 +17,17 @@ RSpec.describe Rtl do
end
end
- context 'user locale is not RTL' do
+ context 'when user locale is not RTL' do
it 'returns empty class' do
expect(Rtl.new(user).css_class).to eq('')
end
end
-
end
- context 'user locale is not allowed' do
+ context 'when user locale is not allowed' do
before { SiteSetting.allow_user_locale = false }
- context 'site default locale is RTL' do
+ context 'when site default locale is RTL' do
before { SiteSetting.default_locale = 'he' }
it 'returns rtl class' do
@@ -38,10 +35,10 @@ RSpec.describe Rtl do
end
end
- context 'site default locale is LTR' do
+ context 'when site default locale is LTR' do
before { SiteSetting.default_locale = 'en' }
- context 'user locale is RTL' do
+ context 'when user locale is RTL' do
before { user.stubs(:locale).returns('he') }
it 'returns empty class' do
@@ -50,6 +47,5 @@ RSpec.describe Rtl do
end
end
end
-
end
end
diff --git a/spec/lib/s3_inventory_spec.rb b/spec/lib/s3_inventory_spec.rb
index 6eee5355f10..ab215820d98 100644
--- a/spec/lib/s3_inventory_spec.rb
+++ b/spec/lib/s3_inventory_spec.rb
@@ -174,7 +174,7 @@ RSpec.describe "S3Inventory" do
expect(Discourse.stats.get("missing_s3_uploads")).to eq(2)
end
- context "s3 inventory configuration" do
+ describe "s3 inventory configuration" do
let(:bucket_name) { "s3-upload-bucket" }
let(:subfolder_path) { "subfolder" }
before do
diff --git a/spec/lib/score_calculator_spec.rb b/spec/lib/score_calculator_spec.rb
index 352630eed31..9506ec4a1ac 100644
--- a/spec/lib/score_calculator_spec.rb
+++ b/spec/lib/score_calculator_spec.rb
@@ -3,7 +3,6 @@
require 'score_calculator'
RSpec.describe ScoreCalculator do
-
fab!(:post) { Fabricate(:post, reads: 111) }
fab!(:another_post) { Fabricate(:post, topic: post.topic, reads: 222) }
let(:topic) { post.topic }
@@ -28,11 +27,9 @@ RSpec.describe ScoreCalculator do
it "gives the topic a score" do
expect(topic.score).to be_present
end
-
end
- context 'summary' do
-
+ describe 'summary' do
it "won't update the site settings when the site settings don't match" do
ScoreCalculator.new(reads: 3).calculate
topic.reload
@@ -68,7 +65,5 @@ RSpec.describe ScoreCalculator do
topic.reload
expect(topic.has_summary).to eq(true)
end
-
end
-
end
diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb
index f62e1f41e9e..2be1c5dc536 100644
--- a/spec/lib/search_spec.rb
+++ b/spec/lib/search_spec.rb
@@ -60,7 +60,7 @@ RSpec.describe Search do
SiteSetting.tagging_enabled = true
end
- context "staff tags" do
+ context "with staff tags" do
fab!(:hidden_tag) { Fabricate(:tag) }
let!(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [hidden_tag.name]) }
fab!(:topic) { Fabricate(:topic, tags: [hidden_tag]) }
@@ -85,7 +85,7 @@ RSpec.describe Search do
end
end
- context "accents" do
+ context "with accents" do
fab!(:post_1) { Fabricate(:post, raw: "Cette ****** d'art n'est pas une œuvre") }
fab!(:post_2) { Fabricate(:post, raw: "Cette oeuvre d'art n'est pas une *****") }
@@ -115,7 +115,7 @@ RSpec.describe Search do
end
end
- context "custom_eager_load" do
+ describe "custom_eager_load" do
fab!(:topic) { Fabricate(:topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
@@ -146,7 +146,7 @@ RSpec.describe Search do
end
end
- context "users" do
+ describe "users" do
fab!(:user) { Fabricate(:user, username: "DonaldDuck") }
fab!(:user2) { Fabricate(:user) }
@@ -214,7 +214,7 @@ RSpec.describe Search do
end
end
- context "categories" do
+ describe "categories" do
it "finds topics in sub-sub-categories" do
SiteSetting.max_category_nesting = 3
@@ -242,7 +242,7 @@ RSpec.describe Search do
end
end
- context 'post indexing' do
+ describe 'post indexing' do
fab!(:category) { Fabricate(:category_with_definition, name: 'america') }
fab!(:topic) { Fabricate(:topic, title: 'sam saffron test topic', category: category) }
let!(:post) { Fabricate(:post, topic: topic, raw: 'this <b>fun test</b> <img src="bla" title="my image">') }
@@ -283,7 +283,7 @@ RSpec.describe Search do
end
end
- context 'user indexing' do
+ describe 'user indexing' do
before do
@user = Fabricate(:user, username: 'fred', name: 'bob jones')
@indexed = @user.user_search_data.search_data
@@ -295,7 +295,7 @@ RSpec.describe Search do
end
end
- context 'category indexing' do
+ describe 'category indexing' do
let!(:category) { Fabricate(:category_with_definition, name: 'america') }
let!(:topic) { Fabricate(:topic, category: category) }
let!(:post) { Fabricate(:post, topic: topic) }
@@ -366,7 +366,7 @@ RSpec.describe Search do
expect(search.term).to eq('a b c okaylength')
end
- context 'query sanitization' do
+ describe 'query sanitization' do
let!(:post) { Fabricate(:post, raw: 'hello world') }
it 'escapes backslash' do
@@ -386,7 +386,7 @@ RSpec.describe Search do
expect { Search.execute('evil trout') }.not_to raise_error
end
- context 'users' do
+ describe 'users' do
let!(:user) { Fabricate(:user) }
let(:result) { Search.execute('bruce', type_filter: 'user') }
@@ -395,7 +395,7 @@ RSpec.describe Search do
expect(result.users[0].id).to eq(user.id)
end
- context 'hiding user profiles' do
+ context 'when hiding user profiles' do
before { SiteSetting.hide_user_profiles_from_public = true }
it 'returns no result for anon' do
@@ -409,7 +409,7 @@ RSpec.describe Search do
end
end
- context 'inactive users' do
+ describe 'inactive users' do
let!(:inactive_user) { Fabricate(:inactive_user, active: false) }
let(:result) { Search.execute('bruce') }
@@ -418,7 +418,7 @@ RSpec.describe Search do
end
end
- context 'staged users' do
+ describe 'staged users' do
let(:staged) { Fabricate(:staged) }
let(:result) { Search.execute(staged.username) }
@@ -427,7 +427,7 @@ RSpec.describe Search do
end
end
- context 'private messages' do
+ describe 'private messages' do
let!(:post) { Fabricate(:private_message_post) }
let(:topic) { post.topic }
@@ -533,7 +533,7 @@ RSpec.describe Search do
end
end
- context 'personal_messages filter' do
+ context 'with personal_messages filter' do
it 'does not allow a normal user to search for personal messages of another user' do
expect do
Search.execute(
@@ -562,7 +562,7 @@ RSpec.describe Search do
end
end
- context 'all-pms flag' do
+ context 'with all-pms flag' do
it 'returns matching PMs if the user is an admin' do
results = Search.execute('mars in:all-pms', guardian: Guardian.new(admin))
@@ -582,7 +582,7 @@ RSpec.describe Search do
end
end
- context 'personal-direct and group_messages flags' do
+ context 'with personal-direct and group_messages flags' do
let(:current) { Fabricate(:user, admin: true, username: "current_user") }
let(:participant) { Fabricate(:user, username: "participant_1") }
let(:participant_2) { Fabricate(:user, username: "participant_2") }
@@ -610,7 +610,7 @@ RSpec.describe Search do
pm.reload
end
- context "personal-direct flag" do
+ context "with personal-direct flag" do
it 'can find all direct PMs of the current user' do
pm = create_pm(users: [current, participant])
_pm_2 = create_pm(users: [participant_2, participant])
@@ -657,7 +657,7 @@ RSpec.describe Search do
end
end
- context "group_messages flag" do
+ context "with group_messages flag" do
it 'returns results correctly for a PM in a given group' do
pm = create_pm(users: [participant, participant_2], group: group)
@@ -700,7 +700,7 @@ RSpec.describe Search do
end
end
- context 'all topics' do
+ context 'with all topics' do
let!(:u1) { Fabricate(:user, username: 'fred', name: 'bob jones', email: '[email protected]') }
let!(:u2) { Fabricate(:user, username: 'bob', name: 'fred jones', email: '[email protected]') }
let!(:u3) { Fabricate(:user, username: 'jones', name: 'bob fred', email: '[email protected]') }
@@ -765,7 +765,7 @@ RSpec.describe Search do
end
end
- context 'posts' do
+ context 'with posts' do
fab!(:post) do
SearchIndexer.enable
Fabricate(:post)
@@ -935,11 +935,11 @@ RSpec.describe Search do
end
end
- context 'topics' do
+ describe 'topics' do
let(:post) { Fabricate(:post) }
let(:topic) { post.topic }
- context 'search within topic' do
+ context 'with search within topic' do
def new_post(raw, topic = nil, created_at: nil)
topic ||= Fabricate(:topic)
Fabricate(:post, topic: topic, topic_id: topic.id, user: topic.user, raw: raw, created_at: created_at)
@@ -990,7 +990,7 @@ RSpec.describe Search do
end
end
- context 'searching the OP' do
+ context 'when searching the OP' do
let!(:post) { Fabricate(:post_with_long_raw_content) }
let(:result) { Search.execute('hundred', type_filter: 'topic') }
@@ -1000,7 +1000,7 @@ RSpec.describe Search do
end
end
- context 'searching for quoted title' do
+ context 'when searching for quoted title' do
it "can find quoted title" do
create_post(raw: "this is the raw body", title: "I am a title yeah")
result = Search.execute('"a title yeah"')
@@ -1009,7 +1009,7 @@ RSpec.describe Search do
end
end
- context "search for a topic by id" do
+ context "when searching for a topic by id" do
let(:result) { Search.execute(topic.id, type_filter: 'topic', search_for_id: true, min_search_term_length: 1) }
it 'returns the topic' do
@@ -1018,14 +1018,14 @@ RSpec.describe Search do
end
end
- context "search for a topic by url" do
+ context "when searching for a topic by url" do
it 'returns the topic' do
result = Search.execute(topic.relative_url, search_for_id: true, type_filter: 'topic')
expect(result.posts.length).to eq(1)
expect(result.posts.first.id).to eq(post.id)
end
- context 'restrict_to_archetype' do
+ context 'with restrict_to_archetype' do
let(:personal_message) { Fabricate(:private_message_topic) }
let!(:p1) { Fabricate(:post, topic: personal_message, post_number: 1) }
@@ -1047,7 +1047,7 @@ RSpec.describe Search do
end
end
- context 'security' do
+ context 'with security' do
def result(current_user)
Search.execute('hello', guardian: Guardian.new(current_user))
end
@@ -1068,7 +1068,7 @@ RSpec.describe Search do
end
end
- context 'cyrillic topic' do
+ describe 'cyrillic topic' do
let!(:cyrillic_topic) do
Fabricate(:topic) do
user
@@ -1089,7 +1089,7 @@ RSpec.describe Search do
expect(Search.execute('canned').posts).to be_present
end
- context 'categories' do
+ describe 'categories' do
let(:category) { Fabricate(:category_with_definition, name: "monkey Category 2") }
let(:topic) { Fabricate(:topic, category: category) }
let!(:post) { Fabricate(:post, topic: topic, raw: "snow monkey") }
@@ -1185,7 +1185,7 @@ RSpec.describe Search do
end
end
- context 'groups' do
+ describe 'groups' do
def search(user = Fabricate(:user))
Search.execute(group.name, guardian: Guardian.new(user))
end
@@ -1196,20 +1196,20 @@ RSpec.describe Search do
expect(search.groups.map(&:name)).to eq([group.name])
end
- context 'group visibility' do
+ context 'with group visibility' do
let!(:group) { Fabricate(:group) }
before do
group.update!(visibility_level: 3)
end
- context 'staff logged in' do
+ context 'with staff logged in' do
it 'shows group' do
expect(search(admin).groups.map(&:name)).to eq([group.name])
end
end
- context 'non staff logged in' do
+ context 'with non staff logged in' do
it 'shows doesn’t show group' do
expect(search.groups.map(&:name)).to be_empty
end
@@ -1217,7 +1217,7 @@ RSpec.describe Search do
end
end
- context 'tags' do
+ describe 'tags' do
def search
Search.execute(tag.name)
end
@@ -1227,7 +1227,7 @@ RSpec.describe Search do
let(:tag_group) { Fabricate(:tag_group) }
let(:category) { Fabricate(:category_with_definition) }
- context 'post searching' do
+ context 'with post searching' do
before do
SiteSetting.tagging_enabled = true
DiscourseTagging.tag_topic_by_names(post.topic, Guardian.new(Fabricate.build(:admin)), [tag.name, uppercase_tag.name])
@@ -1260,7 +1260,7 @@ RSpec.describe Search do
end
end
- context 'tagging is disabled' do
+ context 'when tagging is disabled' do
before { SiteSetting.tagging_enabled = false }
it 'does not include tags' do
@@ -1268,7 +1268,7 @@ RSpec.describe Search do
end
end
- context 'tagging is enabled' do
+ context 'when tagging is enabled' do
before { SiteSetting.tagging_enabled = true }
it 'returns the tag in the result' do
@@ -1295,11 +1295,11 @@ RSpec.describe Search do
end
end
- context 'type_filter' do
+ describe 'type_filter' do
let!(:user) { Fabricate(:user, username: 'amazing', email: '[email protected]') }
let!(:category) { Fabricate(:category_with_definition, name: 'amazing category', user: user) }
- context 'user filter' do
+ context 'with user filter' do
let(:results) { Search.execute('amazing', type_filter: 'user') }
it "returns a user result" do
@@ -1309,7 +1309,7 @@ RSpec.describe Search do
end
end
- context 'category filter' do
+ context 'with category filter' do
let(:results) { Search.execute('amazing', type_filter: 'category') }
it "returns a category result" do
@@ -1320,7 +1320,7 @@ RSpec.describe Search do
end
end
- context 'search_context' do
+ describe 'search_context' do
it 'can find a user when using search context' do
coding_horror = Fabricate(:coding_horror)
post = Fabricate(:post)
@@ -1369,7 +1369,7 @@ RSpec.describe Search do
end
end
- context 'Japanese search' do
+ describe 'Japanese search' do
let!(:topic) { Fabricate(:topic) }
let!(:post) { Fabricate(:post, topic: topic, raw: 'This is some japanese text 日本が大好きです。') }
let!(:topic_2) { Fabricate(:topic, title: '日本の話題、 more japanese text') }
@@ -1598,7 +1598,7 @@ RSpec.describe Search do
expect(Search.execute("@#{post_1.user.username}").posts).to contain_exactly(post_1)
end
- context "searching for posts made by users of a group" do
+ context "when searching for posts made by users of a group" do
fab!(:topic) { Fabricate(:topic, created_at: 3.months.ago) }
fab!(:user) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }
@@ -1910,7 +1910,7 @@ RSpec.describe Search do
expect(results.posts.length).to eq(0)
end
- context 'tags' do
+ context 'with tags' do
fab!(:tag1) { Fabricate(:tag, name: 'lunch') }
fab!(:tag2) { Fabricate(:tag, name: 'eggs') }
fab!(:tag3) { Fabricate(:tag, name: 'sandwiches') }
@@ -2097,7 +2097,7 @@ RSpec.describe Search do
end
end
- context "search_log_id" do
+ describe "search_log_id" do
it "returns an id when the search succeeds" do
s = Search.new(
'indiana jones',
@@ -2115,7 +2115,7 @@ RSpec.describe Search do
end
end
- context 'in:title' do
+ describe 'in:title' do
it 'allows for search in title' do
topic = Fabricate(:topic, title: 'I am testing a title search')
_post2 = Fabricate(:post, topic: topic, raw: 'this is the second post', post_number: 2)
@@ -2145,7 +2145,7 @@ RSpec.describe Search do
end
end
- context 'ignore_diacritics' do
+ describe 'ignore_diacritics' do
before { SiteSetting.search_ignore_accents = true }
let!(:post1) { Fabricate(:post, raw: 'สวัสดี Rágis hello') }
@@ -2167,7 +2167,7 @@ RSpec.describe Search do
end
end
- context 'include_diacritics' do
+ describe 'include_diacritics' do
before { SiteSetting.search_ignore_accents = false }
let!(:post1) { Fabricate(:post, raw: 'สวัสดี Régis hello') }
@@ -2188,7 +2188,7 @@ RSpec.describe Search do
end
end
- context 'pagination' do
+ describe 'pagination' do
let(:number_of_results) { 2 }
let!(:post1) { Fabricate(:post, raw: 'hello hello hello hello hello') }
let!(:post2) { Fabricate(:post, raw: 'hello hello hello hello') }
@@ -2236,7 +2236,7 @@ RSpec.describe Search do
end
end
- context 'header in-topic search' do
+ describe 'header in-topic search' do
let!(:topic) { Fabricate(:topic, title: 'This is a topic with a bunch of posts') }
let!(:post1) { Fabricate(:post, topic: topic, raw: 'hola amiga') }
let!(:post2) { Fabricate(:post, topic: topic, raw: 'hola amigo') }
@@ -2255,7 +2255,7 @@ RSpec.describe Search do
end
end
- context 'in:tagged' do
+ describe 'in:tagged' do
it 'allows for searching by presence of any tags' do
topic = Fabricate(:topic, title: 'I am testing a tagged search')
_post = Fabricate(:post, topic: topic, raw: 'this is the first post')
@@ -2273,7 +2273,7 @@ RSpec.describe Search do
end
end
- context 'in:untagged' do
+ describe 'in:untagged' do
it 'allows for searching by presence of no tags' do
topic = Fabricate(:topic, title: 'I am testing a untagged search')
_post = Fabricate(:post, topic: topic, raw: 'this is the first post')
@@ -2286,7 +2286,7 @@ RSpec.describe Search do
end
end
- context 'plugin extensions' do
+ describe 'plugin extensions' do
let!(:post0) { Fabricate(:post, raw: 'this is the first post about advanced filter with length more than 50 chars') }
let!(:post1) { Fabricate(:post, raw: 'this is the second post about advanced filter') }
@@ -2309,7 +2309,7 @@ RSpec.describe Search do
end
end
- context 'exclude_topics filter' do
+ describe 'exclude_topics filter' do
before { SiteSetting.tagging_enabled = true }
let!(:user) { Fabricate(:user) }
fab!(:group) { Fabricate(:group, name: 'bruce-world-fans') }
diff --git a/spec/lib/second_factor/auth_manager_spec.rb b/spec/lib/second_factor/auth_manager_spec.rb
index 4e08ea1ae0e..bd39b823995 100644
--- a/spec/lib/second_factor/auth_manager_spec.rb
+++ b/spec/lib/second_factor/auth_manager_spec.rb
@@ -227,7 +227,7 @@ RSpec.describe SecondFactor::AuthManager do
end
end
- context "returned results object" do
+ context "with returned results object" do
it "has the correct status and contains the return value of the action hook that's called" do
action = create_action
action.expects(:skip_second_factor_auth?).with({}).returns(true).once
diff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rb
index c51cbad66d0..c26024b6728 100644
--- a/spec/lib/site_setting_extension_spec.rb
+++ b/spec/lib/site_setting_extension_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe SiteSettingExtension do
-
# We disable message bus here to avoid a large amount
# of unneeded messaging, tests are careful to call refresh
# when they need to.
@@ -21,7 +20,7 @@ RSpec.describe SiteSettingExtension do
end
describe '#types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@types = SiteSetting.types
end
@@ -73,7 +72,6 @@ RSpec.describe SiteSettingExtension do
end
describe "refresh!" do
-
it "will reset to default if provider vanishes" do
settings.setting(:hello, 1)
settings.hello = 100
@@ -585,8 +583,7 @@ RSpec.describe SiteSettingExtension do
end
describe "global override" do
-
- context "default_locale" do
+ context "with default_locale" do
it "supports adding a default locale via a global" do
global_setting :default_locale, 'zh_CN'
settings.default_locale = 'en'
@@ -835,5 +832,4 @@ RSpec.describe SiteSettingExtension do
end
end
end
-
end
diff --git a/spec/lib/site_settings/type_supervisor_spec.rb b/spec/lib/site_settings/type_supervisor_spec.rb
index b1865c24b6a..5e4a0801747 100644
--- a/spec/lib/site_settings/type_supervisor_spec.rb
+++ b/spec/lib/site_settings/type_supervisor_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe SiteSettings::TypeSupervisor do
end
describe '#types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
it "'string' should be at 1st position" do
expect(SiteSettings::TypeSupervisor.types[:string]).to eq(1)
end
diff --git a/spec/lib/site_settings/validations_spec.rb b/spec/lib/site_settings/validations_spec.rb
index 15c00d6efeb..671730f8aac 100644
--- a/spec/lib/site_settings/validations_spec.rb
+++ b/spec/lib/site_settings/validations_spec.rb
@@ -5,7 +5,7 @@ require 'site_settings/validations'
RSpec.describe SiteSettings::Validations do
subject { Class.new.include(described_class).new }
- context "default_categories" do
+ describe "default_categories" do
fab!(:category) { Fabricate(:category) }
it "supports valid categories" do
@@ -31,7 +31,7 @@ RSpec.describe SiteSettings::Validations do
end
end
- context "s3 buckets reusage" do
+ describe "s3 buckets reusage" do
let(:error_message) { I18n.t("errors.site_settings.s3_bucket_reused") }
shared_examples "s3 bucket validation" do
@@ -308,7 +308,7 @@ RSpec.describe SiteSettings::Validations do
end
end
- context "slow_down_crawler_user_agents" do
+ describe "slow_down_crawler_user_agents" do
let(:too_short_message) do
I18n.t(
"errors.site_settings.slow_down_crawler_user_agent_must_be_at_least_3_characters"
diff --git a/spec/lib/slug_spec.rb b/spec/lib/slug_spec.rb
index 8e2c239c983..43615d4f3f4 100644
--- a/spec/lib/slug_spec.rb
+++ b/spec/lib/slug_spec.rb
@@ -4,7 +4,6 @@
require 'slug'
RSpec.describe Slug do
-
describe '#for' do
let(:default_slug) { 'topic' }
@@ -32,7 +31,7 @@ RSpec.describe Slug do
expect(Slug.for(":smile: To Infinity and beyond! 🚀 :woman:t5:")).to eq("to-infinity-and-beyond")
end
- context 'ascii generator' do
+ context 'with ascii generator' do
before { SiteSetting.slug_generation_method = 'ascii' }
it 'generates the slug' do
@@ -58,7 +57,7 @@ RSpec.describe Slug do
end
end
- context 'encoded generator' do
+ context 'with encoded generator' do
before { SiteSetting.slug_generation_method = 'encoded' }
after { SiteSetting.slug_generation_method = 'ascii' }
@@ -91,7 +90,7 @@ RSpec.describe Slug do
end
end
- context 'none generator' do
+ context 'with none generator' do
before { SiteSetting.slug_generation_method = 'none' }
after { SiteSetting.slug_generation_method = 'ascii' }
diff --git a/spec/lib/stylesheet/manager_spec.rb b/spec/lib/stylesheet/manager_spec.rb
index 35c3402f087..9a24f9cb333 100644
--- a/spec/lib/stylesheet/manager_spec.rb
+++ b/spec/lib/stylesheet/manager_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Stylesheet::Manager do
expect(link).not_to eq("")
end
- context "themes with components" do
+ describe "themes with components" do
let(:child_theme) { Fabricate(:theme, component: true, name: "a component").tap { |c|
c.set_field(target: :common, name: "scss", value: ".child_common{.scss{color: red;}}")
c.set_field(target: :desktop, name: "scss", value: ".child_desktop{.scss{color: red;}}")
@@ -148,7 +148,7 @@ RSpec.describe Stylesheet::Manager do
})
end
- context "stylesheet order" do
+ context "with stylesheet order" do
let(:z_child_theme) do
Fabricate(:theme, component: true, name: "ze component").tap do |z|
z.set_field(target: :desktop, name: "scss", value: ".child_desktop{.scss{color: red;}}")
@@ -607,7 +607,7 @@ RSpec.describe Stylesheet::Manager do
expect(details1[:new_href]).not_to eq(details2[:new_href])
end
- context "theme colors" do
+ context "with theme colors" do
let(:theme) { Fabricate(:theme).tap { |t|
t.set_field(target: :common, name: "color_definitions", value: ':root {--special: rebeccapurple;}')
t.save!
@@ -696,7 +696,7 @@ RSpec.describe Stylesheet::Manager do
end
end
- context 'encoded slugs' do
+ context 'with encoded slugs' do
before { SiteSetting.slug_generation_method = 'encoded' }
after { SiteSetting.slug_generation_method = 'ascii' }
diff --git a/spec/lib/suggested_topics_builder_spec.rb b/spec/lib/suggested_topics_builder_spec.rb
index 42cd0ad1261..ba24627f817 100644
--- a/spec/lib/suggested_topics_builder_spec.rb
+++ b/spec/lib/suggested_topics_builder_spec.rb
@@ -3,7 +3,6 @@
require 'suggested_topics_builder'
RSpec.describe SuggestedTopicsBuilder do
-
fab!(:topic) { Fabricate(:topic) }
let(:builder) { SuggestedTopicsBuilder.new(topic) }
@@ -11,8 +10,7 @@ RSpec.describe SuggestedTopicsBuilder do
SiteSetting.suggested_topics = 5
end
- context "splicing category results" do
-
+ describe "splicing category results" do
def fake_topic(topic_id, category_id)
build(:topic, id: topic_id, category_id: category_id)
end
@@ -57,8 +55,7 @@ RSpec.describe SuggestedTopicsBuilder do
expect(builder).to be_full
end
- context "adding results" do
-
+ describe "adding results" do
it "adds nothing with nil results" do
builder.add_results(nil)
expect(builder.results_left).to eq(5)
@@ -66,7 +63,7 @@ RSpec.describe SuggestedTopicsBuilder do
expect(builder).not_to be_full
end
- context "adding topics" do
+ context "when adding topics" do
fab!(:other_topic) { Fabricate(:topic) }
before do
@@ -81,10 +78,9 @@ RSpec.describe SuggestedTopicsBuilder do
expect(builder.excluded_topic_ids.include?(topic.id)).to eq(true)
expect(builder.excluded_topic_ids.include?(other_topic.id)).to eq(true)
end
-
end
- context "adding topics that are not open" do
+ context "when adding topics that are not open" do
fab!(:archived_topic) { Fabricate(:topic, archived: true) }
fab!(:closed_topic) { Fabricate(:topic, closed: true) }
fab!(:invisible_topic) { Fabricate(:topic, visible: false) }
@@ -96,7 +92,7 @@ RSpec.describe SuggestedTopicsBuilder do
end
end
- context "category definition topics" do
+ context "when category definition topics" do
fab!(:category) { Fabricate(:category_with_definition) }
it "doesn't add a category definition topic" do
@@ -106,7 +102,5 @@ RSpec.describe SuggestedTopicsBuilder do
expect(builder).not_to be_full
end
end
-
end
-
end
diff --git a/spec/lib/svg_sprite/svg_sprite_spec.rb b/spec/lib/svg_sprite/svg_sprite_spec.rb
index cdaac927fbb..40a027e0878 100644
--- a/spec/lib/svg_sprite/svg_sprite_spec.rb
+++ b/spec/lib/svg_sprite/svg_sprite_spec.rb
@@ -151,7 +151,7 @@ RSpec.describe SvgSprite do
expect(icons).to include("fly")
end
- context "s3" do
+ describe "s3" do
let(:upload_s3) { Fabricate(:upload_s3) }
before do
@@ -283,6 +283,5 @@ RSpec.describe SvgSprite do
expect(Upload.exists?(id: upload.id)).to eq(true)
expect(SvgSprite.bundle(theme.id)).to match(/my-custom-theme-icon/)
end
-
end
end
diff --git a/spec/lib/text_cleaner_spec.rb b/spec/lib/text_cleaner_spec.rb
index ea1f60c207a..42ad5d135b6 100644
--- a/spec/lib/text_cleaner_spec.rb
+++ b/spec/lib/text_cleaner_spec.rb
@@ -3,9 +3,7 @@
require 'text_cleaner'
RSpec.describe TextCleaner do
-
- context "exclamation marks" do
-
+ describe "exclamation marks" do
let(:duplicated_string) { "my precious!!!!" }
let(:deduplicated_string) { "my precious!" }
@@ -16,11 +14,9 @@ RSpec.describe TextCleaner do
it "deduplicates ! when enabled" do
expect(TextCleaner.clean(duplicated_string, deduplicate_exclamation_marks: true)).to eq(deduplicated_string)
end
-
end
- context "question marks" do
-
+ describe "question marks" do
let(:duplicated_string) { "please help me????" }
let(:deduplicated_string) { "please help me?" }
@@ -31,11 +27,9 @@ RSpec.describe TextCleaner do
it "deduplicates ? when enabled" do
expect(TextCleaner.clean(duplicated_string, deduplicate_question_marks: true)).to eq(deduplicated_string)
end
-
end
- context "all upper case text" do
-
+ describe "all upper case text" do
let(:all_caps) { "ENTIRE TEXT IS ALL CAPS" }
let(:almost_all_caps) { "ENTIRE TEXT iS ALL CAPS" }
let(:regular_case) { "entire text is all caps" }
@@ -51,11 +45,9 @@ RSpec.describe TextCleaner do
it "ignores almost all upper case text when enabled" do
expect(TextCleaner.clean(almost_all_caps, replace_all_upper_case: true)).to eq(almost_all_caps)
end
-
end
- context "first letter" do
-
+ describe "first letter" do
let(:lowercased) { "this is awesome" }
let(:capitalized) { "This is awesome" }
let(:iletter) { "iLetter" }
@@ -71,11 +63,9 @@ RSpec.describe TextCleaner do
expect(TextCleaner.clean(capitalized, capitalize_first_letter: true)).to eq(capitalized)
expect(TextCleaner.clean(iletter, capitalize_first_letter: true)).to eq(iletter)
end
-
end
- context "periods at the end" do
-
+ describe "periods at the end" do
let(:with_one_period) { "oops." }
let(:with_several_periods) { "oops..." }
let(:without_period) { "oops" }
@@ -93,11 +83,9 @@ RSpec.describe TextCleaner do
it "keeps trailing whitespaces when enabled" do
expect(TextCleaner.clean(with_several_periods + " ", remove_all_periods_from_the_end: true)).to eq(without_period + " ")
end
-
end
- context "extraneous space" do
-
+ describe "extraneous space" do
let(:with_space_exclamation) { "oops !" }
let(:without_space_exclamation) { "oops!" }
let(:with_space_question) { "oops ?" }
@@ -117,11 +105,9 @@ RSpec.describe TextCleaner do
expect(TextCleaner.clean(with_space_exclamation + " ", remove_extraneous_space: true)).to eq(without_space_exclamation + " ")
expect(TextCleaner.clean(with_space_question + " ", remove_extraneous_space: true)).to eq(without_space_question + " ")
end
-
end
- context "interior spaces" do
-
+ describe "interior spaces" do
let(:spacey_string) { "hello there's weird spaces here." }
let(:unspacey_string) { "hello there's weird spaces here." }
@@ -132,11 +118,9 @@ RSpec.describe TextCleaner do
it "fixes interior spaces when enabled" do
expect(TextCleaner.clean(spacey_string, fixes_interior_spaces: true)).to eq(unspacey_string)
end
-
end
- context "leading and trailing whitespaces" do
-
+ describe "leading and trailing whitespaces" do
let(:spacey_string) { " \t test \n " }
let(:unspacey_string) { "test" }
@@ -147,11 +131,9 @@ RSpec.describe TextCleaner do
it "strips leading and trailing whitespaces when enabled" do
expect(TextCleaner.clean(spacey_string, strip_whitespaces: true)).to eq(unspacey_string)
end
-
end
- context "title" do
-
+ describe "title" do
it "fixes interior spaces" do
expect(TextCleaner.clean_title("Hello there")).to eq("Hello there")
end
@@ -165,8 +147,7 @@ RSpec.describe TextCleaner do
expect(TextCleaner.clean_title("Hello​ ​there").length).to eq(11)
end
- context "title_prettify site setting is enabled" do
-
+ context "when title_prettify site setting is enabled" do
before { SiteSetting.title_prettify = true }
it "deduplicates !" do
@@ -223,7 +204,6 @@ RSpec.describe TextCleaner do
expect(TextCleaner.clean_title("istanbul")).to eq("İstanbul")
end
end
-
end
describe "#normalize_whitespaces" do
@@ -242,7 +222,7 @@ RSpec.describe TextCleaner do
end
end
- context "invalid byte sequence" do
+ describe "invalid byte sequence" do
let(:with_invalid_bytes) { "abc\u3042\x81" }
let(:without_invalid_bytes) { "abc\u3042" }
diff --git a/spec/lib/text_sentinel_spec.rb b/spec/lib/text_sentinel_spec.rb
index 510894c47d9..78372f99410 100644
--- a/spec/lib/text_sentinel_spec.rb
+++ b/spec/lib/text_sentinel_spec.rb
@@ -4,13 +4,11 @@
require 'text_sentinel'
RSpec.describe TextSentinel do
-
it "allows utf-8 chars" do
expect(TextSentinel.new("йȝîûηыეமிᚉ⠛").text).to eq("йȝîûηыეமிᚉ⠛")
end
- context "entropy" do
-
+ describe "entropy" do
it "returns 0 for an empty string" do
expect(TextSentinel.new("").entropy).to eq(0)
end
@@ -42,10 +40,9 @@ RSpec.describe TextSentinel do
it "handles repeated foreign characters" do
expect(TextSentinel.new("又一个测试话题" * 3).entropy).to eq(18)
end
-
end
- context 'body_sentinel' do
+ describe 'body_sentinel' do
[ 'evil trout is evil',
"去年十社會警告",
"P.S. Пробирочка очень толковая и весьма умная, так что не обнимайтесь.",
@@ -74,8 +71,7 @@ RSpec.describe TextSentinel do
end
end
- context "validity" do
-
+ describe "validity" do
let(:valid_string) { "This is a cool topic about Discourse" }
it "allows a valid string" do
@@ -142,23 +138,19 @@ RSpec.describe TextSentinel do
it "allows a long string with colons" do
expect(TextSentinel.new("error in org.gradle.internal.graph.CachingDirectedGraphWalker:colon", max_word_length: 30)).to be_valid
end
-
end
- context 'title_sentinel' do
-
+ describe 'title_sentinel' do
it "uses a sensible min entropy value when min title length is less than title_min_entropy" do
SiteSetting.min_topic_title_length = 3
SiteSetting.title_min_entropy = 10
expect(TextSentinel.title_sentinel('Hey')).to be_valid
end
-
end
- context 'seems_unpretentious?' do
+ describe '#seems_unpretentious?' do
it 'works with nil title' do
expect(TextSentinel.title_sentinel(nil).seems_unpretentious?).to eq(true)
end
end
-
end
diff --git a/spec/lib/theme_settings_manager_spec.rb b/spec/lib/theme_settings_manager_spec.rb
index 999650a4bfd..11c1599dcef 100644
--- a/spec/lib/theme_settings_manager_spec.rb
+++ b/spec/lib/theme_settings_manager_spec.rb
@@ -3,7 +3,6 @@
require 'theme_settings_manager'
RSpec.describe ThemeSettingsManager do
-
let!(:theme) { Fabricate(:theme) }
let(:theme_settings) do
yaml = File.read("#{Rails.root}/spec/fixtures/theme_settings/valid_settings.yaml")
@@ -16,7 +15,7 @@ RSpec.describe ThemeSettingsManager do
theme_settings.find { |setting| setting.name == name }
end
- context "Enum" do
+ describe "Enum" do
it "only accepts values from its choices" do
enum_setting = find_by_name(:enum_setting)
expect { enum_setting.value = "trust level 2" }.to raise_error(Discourse::InvalidParameters)
@@ -32,7 +31,7 @@ RSpec.describe ThemeSettingsManager do
end
end
- context "Bool" do
+ describe "Bool" do
it "is either true or false" do
bool_setting = find_by_name(:boolean_setting)
expect(bool_setting.value).to eq(true) # default
@@ -51,7 +50,7 @@ RSpec.describe ThemeSettingsManager do
end
end
- context "Integer" do
+ describe "Integer" do
it "is always an integer" do
int_setting = find_by_name(:integer_setting)
int_setting.value = 1.6
@@ -86,7 +85,7 @@ RSpec.describe ThemeSettingsManager do
end
end
- context "Float" do
+ describe "Float" do
it "is always a float" do
float_setting = find_by_name(:float_setting)
float_setting.value = 1.615
@@ -114,7 +113,7 @@ RSpec.describe ThemeSettingsManager do
end
end
- context "String" do
+ describe "String" do
it "can have min or max length" do
string_setting = find_by_name(:string_setting_02)
expect { string_setting.value = "a" }.to raise_error(Discourse::InvalidParameters)
@@ -142,14 +141,14 @@ RSpec.describe ThemeSettingsManager do
end
end
- context "List" do
+ describe "List" do
it "can have a list type" do
list_setting = find_by_name(:compact_list_setting)
expect(list_setting.list_type).to eq("compact")
end
end
- context "Upload" do
+ describe "Upload" do
let!(:upload) { Fabricate(:upload) }
it "saves the upload id" do
diff --git a/spec/lib/theme_settings_parser_spec.rb b/spec/lib/theme_settings_parser_spec.rb
index d17cad79c6a..5590bbf529b 100644
--- a/spec/lib/theme_settings_parser_spec.rb
+++ b/spec/lib/theme_settings_parser_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe ThemeSettingsParser do
expect(loader.find_by_name(:enum_setting)[:type]).to eq(types[:enum])
end
- context "description locale" do
+ describe "description locale" do
it "favors I18n.locale" do
I18n.locale = :ar
SiteSetting.default_locale = "en"
@@ -72,7 +72,7 @@ RSpec.describe ThemeSettingsParser do
end
end
- context "enum setting" do
+ describe "enum setting" do
it "should never have less than 1 choices" do
choices = loader.find_by_name(:enum_setting)[:opts][:choices]
expect(choices.class).to eq(Array)
@@ -84,7 +84,7 @@ RSpec.describe ThemeSettingsParser do
end
end
- context "list setting" do
+ describe "list setting" do
it "supports list type" do
list_type = loader.find_by_name(:compact_list_setting)[:opts][:list_type]
expect(list_type).to eq("compact")
diff --git a/spec/lib/topic_creator_spec.rb b/spec/lib/topic_creator_spec.rb
index cb90c464809..0b448a7cc17 100644
--- a/spec/lib/topic_creator_spec.rb
+++ b/spec/lib/topic_creator_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe TopicCreator do
end
describe '#create' do
- context 'topic success cases' do
+ context 'with topic success cases' do
before do
TopicCreator.any_instance.expects(:save_topic).returns(true)
TopicCreator.any_instance.expects(:watch_topic).returns(true)
@@ -45,7 +45,7 @@ RSpec.describe TopicCreator do
expect(topic.custom_fields["import_id"]).to eq("bar")
end
- context 'regular user' do
+ context 'with regular user' do
before { SiteSetting.min_trust_to_create_topic = TrustLevel[0] }
it "should be possible for a regular user to create a topic" do
@@ -81,7 +81,7 @@ RSpec.describe TopicCreator do
end
end
- context 'tags' do
+ context 'with tags' do
fab!(:tag1) { Fabricate(:tag, name: "fun") }
fab!(:tag2) { Fabricate(:tag, name: "fun2") }
fab!(:tag3) { Fabricate(:tag, name: "fun3") }
@@ -96,7 +96,7 @@ RSpec.describe TopicCreator do
SiteSetting.min_trust_level_to_tag_topics = 0
end
- context 'regular tags' do
+ context 'with regular tags' do
it "user can add tags to topic" do
topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(tags: [tag1.name]))
expect(topic).to be_valid
@@ -123,7 +123,7 @@ RSpec.describe TopicCreator do
end
end
- context 'staff-only tags' do
+ context 'with staff-only tags' do
before do
create_staff_only_tags(['alpha'])
end
@@ -141,7 +141,7 @@ RSpec.describe TopicCreator do
end
end
- context 'minimum_required_tags is present' do
+ context 'when minimum_required_tags is present' do
fab!(:category) { Fabricate(:category, name: "beta", minimum_required_tags: 2) }
it "fails for regular user if minimum_required_tags is not satisfied" do
@@ -176,7 +176,7 @@ RSpec.describe TopicCreator do
end
end
- context 'required tag group' do
+ context 'with required tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1]) }
fab!(:category) { Fabricate(:category, name: "beta", category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)]) }
@@ -343,7 +343,7 @@ RSpec.describe TopicCreator do
)
end
- context "and allows other tags" do
+ context "when allowing other tags" do
before { category.update!(allow_global_tags: true) }
it "allows topics to use tags that aren't restricted by any category" do
@@ -403,9 +403,8 @@ RSpec.describe TopicCreator do
end
end
- context 'personal message' do
-
- context 'success cases' do
+ context 'with personal message' do
+ context 'with success cases' do
before do
TopicCreator.any_instance.expects(:save_topic).returns(true)
TopicCreator.any_instance.expects(:watch_topic).returns(true)
@@ -429,7 +428,7 @@ RSpec.describe TopicCreator do
end
end
- context 'failure cases' do
+ context 'with failure cases' do
it "should be rollback the changes when email is invalid" do
SiteSetting.manual_polling_enabled = true
SiteSetting.reply_by_email_address = "sam+%{reply_key}@sam.com"
@@ -452,7 +451,7 @@ RSpec.describe TopicCreator do
end
end
- context 'to emails' do
+ context 'with to emails' do
it 'works for staff' do
SiteSetting.min_trust_to_send_email_messages = 'staff'
expect(TopicCreator.create(admin, Guardian.new(admin), pm_to_email_valid_attrs)).to be_valid
@@ -477,7 +476,7 @@ RSpec.describe TopicCreator do
end
end
- context 'setting timestamps' do
+ context 'when setting timestamps' do
it 'supports Time instances' do
freeze_time
@@ -506,7 +505,7 @@ RSpec.describe TopicCreator do
end
end
- context 'external_id' do
+ context 'with external_id' do
it 'adds external_id' do
topic = TopicCreator.create(user, Guardian.new(user), valid_attrs.merge(
external_id: 'external_id'
diff --git a/spec/lib/topic_publisher_spec.rb b/spec/lib/topic_publisher_spec.rb
index 825acd7de99..fc17d51134b 100644
--- a/spec/lib/topic_publisher_spec.rb
+++ b/spec/lib/topic_publisher_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
require 'topic_publisher'
-RSpec.describe TopicPublisher do
- context "shared drafts" do
+RSpec.describe TopicPublisher do
+ describe "shared drafts" do
fab!(:shared_drafts_category) { Fabricate(:category) }
fab!(:category) { Fabricate(:category) }
@@ -11,7 +11,7 @@ RSpec.describe TopicPublisher do
SiteSetting.shared_drafts_category = shared_drafts_category.id
end
- context "publishing" do
+ context "when publishing" do
fab!(:topic) { Fabricate(:topic, category: shared_drafts_category, visible: false) }
fab!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) }
fab!(:moderator) { Fabricate(:moderator) }
@@ -72,7 +72,5 @@ RSpec.describe TopicPublisher do
expect(topic.tags).to contain_exactly(tag)
end
end
-
end
-
end
diff --git a/spec/lib/topic_query/private_message_lists_spec.rb b/spec/lib/topic_query/private_message_lists_spec.rb
index 6c06e1608c1..d1c9409b574 100644
--- a/spec/lib/topic_query/private_message_lists_spec.rb
+++ b/spec/lib/topic_query/private_message_lists_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe TopicQuery::PrivateMessageLists do
expect(topics).to eq([])
end
- context "Calculating minimum unread count for a topic" do
+ context "when calculating minimum unread count for a topic" do
before do
group.update!(publish_read_state: true)
group.add(user)
diff --git a/spec/lib/topic_query_spec.rb b/spec/lib/topic_query_spec.rb
index 9cbb8cc68b6..47a5c8a92df 100644
--- a/spec/lib/topic_query_spec.rb
+++ b/spec/lib/topic_query_spec.rb
@@ -3,7 +3,6 @@
require 'topic_view'
RSpec.describe TopicQuery do
-
# TODO:
# This fab! here has impact on all tests.
#
@@ -20,7 +19,7 @@ RSpec.describe TopicQuery do
fab!(:moderator) { Fabricate(:moderator) }
fab!(:admin) { Fabricate(:admin) }
- context 'secure category' do
+ describe 'secure category' do
it "filters categories out correctly" do
category = Fabricate(:category_with_definition)
group = Fabricate(:group)
@@ -45,12 +44,10 @@ RSpec.describe TopicQuery do
group.save
expect(TopicQuery.new(user).list_latest.topics.count).to eq(2)
-
end
-
end
- context "custom filters" do
+ describe "custom filters" do
it "allows custom filters to be applied" do
topic1 = Fabricate(:topic)
_topic2 = Fabricate(:topic)
@@ -66,7 +63,6 @@ RSpec.describe TopicQuery do
end
describe "#list_topics_by" do
-
it "allows users to view their own invisible topics" do
_topic = Fabricate(:topic, user: user)
_invisible_topic = Fabricate(:topic, user: user, visible: false)
@@ -159,7 +155,7 @@ RSpec.describe TopicQuery do
end
end
- context 'tracked' do
+ describe 'tracked' do
it "filters tracked topics correctly" do
SiteSetting.tagging_enabled = true
@@ -228,7 +224,7 @@ RSpec.describe TopicQuery do
end
end
- context 'deleted filter' do
+ describe 'deleted filter' do
it "filters deleted topics correctly" do
_topic = Fabricate(:topic, deleted_at: 1.year.ago)
@@ -264,7 +260,7 @@ RSpec.describe TopicQuery do
end
end
- context 'category filter' do
+ describe 'category filter' do
let(:category) { Fabricate(:category_with_definition) }
let(:diff_category) { Fabricate(:category_with_definition, name: "Different Category") }
@@ -283,7 +279,7 @@ RSpec.describe TopicQuery do
expect(TopicQuery.new(moderator, category: 'made up slug').list_latest.topics.size).to eq(2)
end
- context 'subcategories' do
+ context 'with subcategories' do
let!(:subcategory) { Fabricate(:category_with_definition, parent_category_id: category.id) }
let(:subsubcategory) { Fabricate(:category_with_definition, parent_category_id: subcategory.id) }
@@ -385,7 +381,7 @@ RSpec.describe TopicQuery do
end
end
- context 'tag filter' do
+ describe 'tag filter' do
fab!(:tag) { Fabricate(:tag) }
fab!(:other_tag) { Fabricate(:tag) }
fab!(:uppercase_tag) { Fabricate(:tag, name: "HeLlO") }
@@ -394,7 +390,7 @@ RSpec.describe TopicQuery do
SiteSetting.tagging_enabled = true
end
- context "no category filter" do
+ context "with no category filter" do
fab!(:tagged_topic1) { Fabricate(:topic, tags: [tag]) }
fab!(:tagged_topic2) { Fabricate(:topic, tags: [other_tag]) }
fab!(:tagged_topic3) { Fabricate(:topic, tags: [tag, other_tag]) }
@@ -460,7 +456,7 @@ RSpec.describe TopicQuery do
end
end
- context 'remove_muted_tags' do
+ context 'when remove_muted_tags is enabled' do
fab!(:topic) { Fabricate(:topic, tags: [tag]) }
before do
@@ -473,7 +469,7 @@ RSpec.describe TopicQuery do
end
end
- context "and categories too" do
+ context "with categories too" do
let(:category1) { Fabricate(:category_with_definition) }
let(:category2) { Fabricate(:category_with_definition) }
@@ -489,7 +485,7 @@ RSpec.describe TopicQuery do
end
end
- context 'muted categories' do
+ describe 'muted categories' do
it 'is removed from top, new and latest lists' do
category = Fabricate(:category_with_definition)
topic = Fabricate(:topic, category: category)
@@ -521,7 +517,7 @@ RSpec.describe TopicQuery do
end
end
- context 'mute_all_categories_by_default' do
+ describe 'mute_all_categories_by_default' do
fab!(:category) { Fabricate(:category_with_definition) }
fab!(:topic) { Fabricate(:topic, category: category) }
@@ -559,7 +555,7 @@ RSpec.describe TopicQuery do
end
end
- context 'already seen topics' do
+ describe 'already seen topics' do
it 'is removed from new and visible on latest lists' do
category = Fabricate(:category_with_definition)
topic = Fabricate(:topic, category: category)
@@ -572,7 +568,7 @@ RSpec.describe TopicQuery do
end
end
- context 'muted tags' do
+ describe 'muted tags' do
it 'is removed from new and latest lists' do
SiteSetting.tagging_enabled = true
SiteSetting.remove_muted_tags_from_latest = 'always'
@@ -628,7 +624,7 @@ RSpec.describe TopicQuery do
end
end
- context 'a bunch of topics' do
+ describe 'a bunch of topics' do
fab!(:regular_topic) do
Fabricate(:topic, title: 'this is a regular topic',
user: creator,
@@ -691,7 +687,7 @@ RSpec.describe TopicQuery do
let(:topics) { topic_query.list_latest.topics }
- context 'list_latest' do
+ context 'with list_latest' do
it "returns the topics in the correct order" do
expect(topics.map(&:id)).to eq([pinned_topic, future_topic, closed_topic, archived_topic, regular_topic].map(&:id))
@@ -702,8 +698,7 @@ RSpec.describe TopicQuery do
expect(TopicQuery.new(admin).list_latest.topics.include?(invisible_topic)).to eq(true)
end
- context 'sort_order' do
-
+ context 'with sort_order' do
def ids_in_order(order, descending = true)
TopicQuery.new(admin, order: order, ascending: descending ? 'false' : 'true').list_latest.topics.map(&:id)
end
@@ -757,11 +752,8 @@ RSpec.describe TopicQuery do
# returns the topics in reverse sheep order if requested" do
expect(ids_in_order('sheep', false)).to eq([invisible_topic, regular_topic, closed_topic, pinned_topic, future_topic, archived_topic].map(&:id))
-
end
-
end
-
end
context 'after clearing a pinned topic' do
@@ -773,10 +765,9 @@ RSpec.describe TopicQuery do
expect(topics).to eq([future_topic, closed_topic, archived_topic, pinned_topic, regular_topic])
end
end
-
end
- context 'categorized' do
+ describe 'categorized' do
fab!(:category) { Fabricate(:category_with_definition) }
let(:topic_category) { category.topic }
fab!(:topic_no_cat) { Fabricate(:topic) }
@@ -825,8 +816,7 @@ RSpec.describe TopicQuery do
end
end
- context 'unread / read topics' do
-
+ describe 'unread / read topics' do
context 'with no data' do
it "has no unread topics" do
expect(topic_query.list_unread.topics).to be_blank
@@ -868,7 +858,7 @@ RSpec.describe TopicQuery do
TopicUser.update_last_read(user, fully_read.id, 1, 1, 0)
end
- context 'list_unread' do
+ context 'with list_unread' do
it 'lists topics correctly' do
_new_topic = Fabricate(:post, user: creator).topic
@@ -877,7 +867,7 @@ RSpec.describe TopicQuery do
end
end
- context 'user with auto_track_topics list_unread' do
+ context 'with user with auto_track_topics list_unread' do
before do
user.user_option.auto_track_topics_after_msecs = 0
user.user_option.save
@@ -887,20 +877,17 @@ RSpec.describe TopicQuery do
expect(topic_query.list_unread.topics).to eq([partially_read])
end
end
-
end
-
end
describe '#list_new' do
-
context 'without a new topic' do
it "has no new topics" do
expect(topic_query.list_new.topics).to be_blank
end
end
- context 'preload api' do
+ context 'when preloading api' do
it "preloads data correctly" do
TopicList.preloaded_custom_fields << "tag"
TopicList.preloaded_custom_fields << "age"
@@ -925,7 +912,6 @@ RSpec.describe TopicQuery do
# if we attempt to access non preloaded fields explode
expect { new_topic.custom_fields["boom"] }.to raise_error(StandardError)
-
end
end
@@ -944,7 +930,7 @@ RSpec.describe TopicQuery do
expect(topic_query.list_new.topics).to eq([])
end
- context "muted topics" do
+ context "with muted topics" do
before do
new_topic.notify_muted!(user)
end
@@ -954,7 +940,7 @@ RSpec.describe TopicQuery do
expect(topic_query.list_latest.topics).to be_blank
end
- context 'un-muted' do
+ context 'when un-muted' do
before do
new_topic.notify_tracking!(user)
end
@@ -966,7 +952,6 @@ RSpec.describe TopicQuery do
end
end
end
-
end
describe '#list_posted' do
@@ -976,7 +961,7 @@ RSpec.describe TopicQuery do
expect(topics).to be_blank
end
- context 'created topics' do
+ context 'with created topics' do
let!(:created_topic) { create_post(user: user).topic }
it "includes the created topic" do
@@ -984,7 +969,7 @@ RSpec.describe TopicQuery do
end
end
- context "topic you've posted in" do
+ context "with topic you've posted in" do
let(:other_users_topic) { create_post(user: creator).topic }
let!(:your_post) { create_post(user: user, topic: other_users_topic) }
@@ -993,15 +978,14 @@ RSpec.describe TopicQuery do
end
end
- context "topic you haven't posted in" do
+ context "with topic you haven't posted in" do
let(:other_users_topic) { create_post(user: creator).topic }
it "does not include the topic" do
expect(topics).to be_blank
end
- context "but interacted with" do
-
+ context "with topic you interacted with" do
it "is not included if read" do
TopicUser.update_last_read(user, other_users_topic.id, 0, 0, 0)
@@ -1075,7 +1059,6 @@ RSpec.describe TopicQuery do
end
describe '#list_related_for' do
-
let(:user) do
Fabricate(:admin)
end
@@ -1132,7 +1115,7 @@ RSpec.describe TopicQuery do
end
end
- context 'suggested_for' do
+ describe 'suggested_for' do
def clear_cache!
Discourse.redis.keys('random_topic_cache*').each { |k| Discourse.redis.del k }
end
@@ -1150,7 +1133,7 @@ RSpec.describe TopicQuery do
end
end
- context "anonymously browsing with invisible, closed and archived" do
+ context "when anonymously browsing with invisible, closed and archived" do
let!(:topic) { Fabricate(:topic) }
let!(:regular_topic) { Fabricate(:post, user: creator).topic }
let!(:closed_topic) { Fabricate(:topic, user: creator, closed: true) }
@@ -1163,7 +1146,6 @@ RSpec.describe TopicQuery do
end
context 'when logged in' do
-
def suggested_for(topic)
topic_query.list_suggested_for(topic).topics.map { |t| t.id }
end
@@ -1180,8 +1162,7 @@ RSpec.describe TopicQuery do
expect(suggested_topics).to be_blank
end
- context 'random suggested' do
-
+ context 'with random suggested' do
let!(:new_topic) { Fabricate(:topic, created_at: 2.days.ago) }
let!(:old_topic) { Fabricate(:topic, created_at: 3.years.ago) }
@@ -1209,7 +1190,6 @@ RSpec.describe TopicQuery do
expect(topics.length).to eq(1)
expect(topics).not_to include(old_topic)
end
-
end
context 'with private messages' do
@@ -1254,7 +1234,7 @@ RSpec.describe TopicQuery do
another_group.add(user)
end
- describe 'as user not part of group' do
+ context 'as user not part of group' do
let!(:user) { Fabricate(:user) }
it 'should not return topics by the group user' do
@@ -1262,7 +1242,7 @@ RSpec.describe TopicQuery do
end
end
- describe 'as user part of group' do
+ context 'as user part of group' do
let!(:user) { group_user }
it 'should return the group topics' do
@@ -1270,7 +1250,7 @@ RSpec.describe TopicQuery do
end
end
- context "by tag filter" do
+ context "with tag filter" do
let(:tag) { Fabricate(:tag) }
let!(:user) { group_user }
@@ -1284,7 +1264,6 @@ RSpec.describe TopicQuery do
end
context 'with some existing topics' do
-
let!(:old_partially_read) {
topic = Fabricate(:post, user: creator).topic
Fabricate(:post, user: creator, topic: topic)
@@ -1330,7 +1309,6 @@ RSpec.describe TopicQuery do
end
it "operates correctly" do
-
# Note, this is a pretty slow integration test
# it tests that suggested is returned in the expected order
# hence we run suggested_for twice here to save on all the setup
@@ -1348,7 +1326,6 @@ RSpec.describe TopicQuery do
expect(suggested_for(topic)).to contain_exactly(partially_read.id, old_partially_read.id)
end
-
end
end
end
@@ -1405,7 +1382,7 @@ RSpec.describe TopicQuery do
end
end
- context "shared drafts" do
+ describe "shared drafts" do
fab!(:category) { Fabricate(:category_with_definition) }
fab!(:shared_drafts_category) { Fabricate(:category_with_definition) }
fab!(:topic) { Fabricate(:topic, category: shared_drafts_category) }
@@ -1421,7 +1398,7 @@ RSpec.describe TopicQuery do
SiteSetting.shared_drafts_min_trust_level = TrustLevel[3]
end
- context "destination_category_id" do
+ context "with destination_category_id" do
it "doesn't allow regular users to query destination_category_id" do
list = TopicQuery.new(user, destination_category_id: category.id).list_latest
expect(list.topics).not_to include(topic)
@@ -1451,7 +1428,7 @@ RSpec.describe TopicQuery do
end
end
- context "latest" do
+ context "with latest" do
it "doesn't include shared topics unless filtering by category" do
list = TopicQuery.new(moderator).list_latest
expect(list.topics).not_to include(topic)
@@ -1477,7 +1454,7 @@ RSpec.describe TopicQuery do
end
end
- context "unread" do
+ context "with unread" do
let!(:partially_read) do
topic = Fabricate(:topic, category: shared_drafts_category)
Fabricate(:post, user: creator, topic: topic).topic
diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rb
index 030db8dc279..252d40ecc76 100644
--- a/spec/lib/topic_view_spec.rb
+++ b/spec/lib/topic_view_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe TopicView do
let(:topic_view) { TopicView.new(topic.id, evil_trout) }
- context "preload" do
+ describe "preload" do
it "allows preloading of data" do
preloaded_topic_view = nil
preloader = lambda do |view|
@@ -51,7 +51,7 @@ RSpec.describe TopicView do
expect { TopicView.new(topic.id, admin) }.not_to raise_error
end
- context "filter options" do
+ describe "filter options" do
fab!(:p0) { Fabricate(:post, topic: topic) }
fab!(:p1) { Fabricate(:post, topic: topic, post_type: Post.types[:moderator_action]) }
fab!(:p2) { Fabricate(:post, topic: topic, post_type: Post.types[:small_action]) }
@@ -70,7 +70,7 @@ RSpec.describe TopicView do
end
end
- context 'custom filters' do
+ describe 'custom filters' do
fab!(:p0) { Fabricate(:post, topic: topic) }
fab!(:p1) { Fabricate(:post, topic: topic, wiki: true) }
@@ -93,7 +93,7 @@ RSpec.describe TopicView do
end
end
- context "setup_filtered_posts" do
+ describe "setup_filtered_posts" do
describe "filters posts with ignored users" do
fab!(:ignored_user) { Fabricate(:ignored_user, user: evil_trout, ignored_user: user) }
let!(:post) { Fabricate(:post, topic: topic, user: first_poster) }
@@ -110,7 +110,7 @@ RSpec.describe TopicView do
expect(tv.next_page).to eq(nil)
end
- describe "when an ignored user made the original post" do
+ context "when an ignored user made the original post" do
let!(:post) { Fabricate(:post, topic: topic, user: user) }
it "filters out ignored user posts only" do
@@ -119,7 +119,7 @@ RSpec.describe TopicView do
end
end
- describe "when an anonymous user made a post" do
+ context "when an anonymous user made a post" do
let!(:post4) { Fabricate(:post, topic: topic, user: anonymous) }
it "filters out ignored user posts only" do
@@ -128,7 +128,7 @@ RSpec.describe TopicView do
end
end
- describe "when an anonymous (non signed-in) user is viewing a Topic" do
+ context "when an anonymous (non signed-in) user is viewing a Topic" do
let!(:post4) { Fabricate(:post, topic: topic, user: anonymous) }
it "filters out ignored user posts only" do
@@ -137,7 +137,7 @@ RSpec.describe TopicView do
end
end
- describe "when a staff user is ignored" do
+ context "when a staff user is ignored" do
let!(:admin) { Fabricate(:user, admin: true) }
let!(:admin_ignored_user) { Fabricate(:ignored_user, user: evil_trout, ignored_user: admin) }
let!(:post4) { Fabricate(:post, topic: topic, user: admin) }
@@ -150,7 +150,7 @@ RSpec.describe TopicView do
end
end
- context "chunk_size" do
+ describe "chunk_size" do
it "returns `chunk_size` by default" do
expect(TopicView.new(topic.id, evil_trout).chunk_size).to eq(TopicView.chunk_size)
end
@@ -224,7 +224,7 @@ RSpec.describe TopicView do
expect { TopicView.new(topic.id, nil) }.to raise_error(Discourse::NotLoggedIn)
end
- context 'log_check_personal_message is enabled' do
+ context 'when log_check_personal_message is enabled' do
fab!(:group) { Fabricate(:group) }
fab!(:private_message) { Fabricate(:private_message_topic, allowed_groups: [group]) }
@@ -274,7 +274,7 @@ RSpec.describe TopicView do
expect(topic_view.absolute_url).to eq("http://test.localhost/t/#{topic.slug}/#{topic.id}")
end
- context 'subfolder' do
+ context 'with subfolder' do
it "provides the correct absolute url" do
set_subfolder "/forum"
expect(topic_view.absolute_url).to eq("http://test.localhost/forum/t/#{topic.slug}/#{topic.id}")
@@ -479,7 +479,7 @@ RSpec.describe TopicView do
end
end
- context 'whispers' do
+ describe 'whispers' do
it "handles their visibility properly" do
SiteSetting.enable_whispers = true
p1 = Fabricate(:post, topic: topic, user: evil_trout)
@@ -498,7 +498,6 @@ RSpec.describe TopicView do
end
describe '#posts' do
-
# Create the posts in a different order than the sort_order
let!(:p5) { Fabricate(:post, topic: topic, user: evil_trout) }
let!(:p2) { Fabricate(:post, topic: topic, user: evil_trout) }
@@ -700,7 +699,7 @@ RSpec.describe TopicView do
end
end
- context "page_title" do
+ describe "page_title" do
fab!(:tag1) { Fabricate(:tag) }
fab!(:tag2) { Fabricate(:tag, topic_count: 2) }
fab!(:op_post) { Fabricate(:post, topic: topic) }
@@ -710,7 +709,7 @@ RSpec.describe TopicView do
subject { TopicView.new(topic.id, evil_trout).page_title }
context "when a post number is specified" do
- context "admins" do
+ context "with admins" do
it "see post number and username for all posts" do
title = TopicView.new(topic.id, admin, post_number: 0).page_title
expect(title).to eq(topic.title)
@@ -724,7 +723,7 @@ RSpec.describe TopicView do
end
end
- context "regular users" do
+ context "with regular users" do
it "see post number and username for regular posts" do
title = TopicView.new(topic.id, evil_trout, post_number: 0).page_title
expect(title).to eq(topic.title)
@@ -748,20 +747,20 @@ RSpec.describe TopicView do
end
end
- context "uncategorized topic" do
- context "topic_page_title_includes_category is false" do
+ context "with uncategorized topic" do
+ context "when topic_page_title_includes_category is false" do
before { SiteSetting.topic_page_title_includes_category = false }
it { is_expected.to eq(topic.title) }
end
- context "topic_page_title_includes_category is true" do
+ context "when topic_page_title_includes_category is true" do
before { SiteSetting.topic_page_title_includes_category = true }
it { is_expected.to eq(topic.title) }
- context "tagged topic" do
+ context "with tagged topic" do
before { topic.tags << [tag1, tag2] }
- context "tagging enabled" do
+ context "with tagging enabled" do
before { SiteSetting.tagging_enabled = true }
it { is_expected.to start_with(topic.title) }
@@ -769,7 +768,7 @@ RSpec.describe TopicView do
it { is_expected.to end_with(tag2.name) } # tag2 has higher topic count
end
- context "tagging disabled" do
+ context "with tagging disabled" do
before { SiteSetting.tagging_enabled = false }
it { is_expected.to start_with(topic.title) }
@@ -780,22 +779,22 @@ RSpec.describe TopicView do
end
end
- context "categorized topic" do
+ context "with categorized topic" do
let(:category) { Fabricate(:category) }
before { topic.update(category_id: category.id) }
- context "topic_page_title_includes_category is false" do
+ context "when topic_page_title_includes_category is false" do
before { SiteSetting.topic_page_title_includes_category = false }
it { is_expected.to eq(topic.title) }
end
- context "topic_page_title_includes_category is true" do
+ context "when topic_page_title_includes_category is true" do
before { SiteSetting.topic_page_title_includes_category = true }
it { is_expected.to start_with(topic.title) }
it { is_expected.to end_with(category.name) }
- context "tagged topic" do
+ context "with tagged topic" do
before do
SiteSetting.tagging_enabled = true
topic.tags << [tag1, tag2]
diff --git a/spec/lib/trust_level_spec.rb b/spec/lib/trust_level_spec.rb
index d89712b198b..c64f64f5245 100644
--- a/spec/lib/trust_level_spec.rb
+++ b/spec/lib/trust_level_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe TrustLevel do
describe 'levels' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@levels = TrustLevel.levels
end
diff --git a/spec/lib/upload_creator_spec.rb b/spec/lib/upload_creator_spec.rb
index bd244d2f5a2..2838d136bf6 100644
--- a/spec/lib/upload_creator_spec.rb
+++ b/spec/lib/upload_creator_spec.rb
@@ -215,7 +215,7 @@ RSpec.describe UploadCreator do
expect(upload.original_filename).to eq('large_and_unoptimized.png')
end
- context "jpeg image quality settings" do
+ context "with jpeg image quality settings" do
before do
SiteSetting.png_to_jpg_quality = 75
SiteSetting.recompress_original_jpg_quality = 40
@@ -247,7 +247,7 @@ RSpec.describe UploadCreator do
expect(upload.original_filename).to eq('animated.gif')
end
- context "png image quality settings" do
+ context "with png image quality settings" do
before do
SiteSetting.png_to_jpg_quality = 100
SiteSetting.recompress_original_jpg_quality = 90
@@ -333,7 +333,7 @@ RSpec.describe UploadCreator do
end
end
- context 'uploading to s3' do
+ context 'when uploading to s3' do
let(:filename) { "should_be_jpeg.png" }
let(:file) { file_from_fixtures(filename) }
let(:pdf_filename) { "small.pdf" }
@@ -413,7 +413,7 @@ RSpec.describe UploadCreator do
end
end
- context "secure media functionality" do
+ context "with secure media functionality" do
let(:filename) { "logo.jpg" }
let(:file) { file_from_fixtures(filename) }
let(:opts) { {} }
@@ -513,7 +513,7 @@ RSpec.describe UploadCreator do
end
end
- context 'custom emojis' do
+ context 'with custom emojis' do
let(:animated_filename) { "animated.gif" }
let(:animated_file) { file_from_fixtures(animated_filename) }
@@ -658,7 +658,7 @@ RSpec.describe UploadCreator do
end
describe '#should_downsize?' do
- context "GIF image" do
+ context "with GIF image" do
let(:gif_file) { file_from_fixtures("animated.gif") }
before do
diff --git a/spec/lib/upload_recovery_spec.rb b/spec/lib/upload_recovery_spec.rb
index dcb3163c668..ec4fb5c27bf 100644
--- a/spec/lib/upload_recovery_spec.rb
+++ b/spec/lib/upload_recovery_spec.rb
@@ -111,7 +111,7 @@ RSpec.describe UploadRecovery do
.to eq(File.read(file_from_fixtures("smallest.png")))
end
- context 'S3 store' do
+ describe 'S3 store' do
before do
setup_s3
stub_s3_store
diff --git a/spec/lib/url_helper_spec.rb b/spec/lib/url_helper_spec.rb
index bddeca0dbd7..343cee94387 100644
--- a/spec/lib/url_helper_spec.rb
+++ b/spec/lib/url_helper_spec.rb
@@ -1,18 +1,14 @@
# frozen_string_literal: true
RSpec.describe UrlHelper do
-
describe "#relaxed parse" do
-
it "can handle double #" do
url = UrlHelper.relaxed_parse("https://test.com#test#test")
expect(url.to_s).to eq("https://test.com#test%23test")
end
-
end
describe "#is_local" do
-
it "is true when the file has been uploaded" do
store = stub
store.expects(:has_been_uploaded?).returns(true)
@@ -42,11 +38,9 @@ RSpec.describe UrlHelper do
Discourse.stubs(:store).returns(store)
expect(UrlHelper.is_local("/plugins/all.js")).to eq(true)
end
-
end
describe "#absolute" do
-
it "returns an absolute URL for CDN" do
begin
Rails.configuration.action_controller.asset_host = "//cdn.awesome.com"
@@ -74,26 +68,21 @@ RSpec.describe UrlHelper do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
expect(UrlHelper.absolute("/path/to/file")).to eq("http://my.cdn.com/path/to/file")
end
-
end
describe "#absolute_without_cdn" do
-
it "changes a relative url to an absolute one using base url even when cdn is enabled" do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
expect(UrlHelper.absolute_without_cdn("/path/to/file")).to eq("http://test.localhost/path/to/file")
end
-
end
describe "#schemaless" do
-
it "removes http schemas only" do
expect(UrlHelper.schemaless("http://www.discourse.org")).to eq("//www.discourse.org")
expect(UrlHelper.schemaless("https://secure.discourse.org")).to eq("https://secure.discourse.org")
expect(UrlHelper.schemaless("ftp://ftp.discourse.org")).to eq("ftp://ftp.discourse.org")
end
-
end
describe "#escape_uri" do
@@ -185,7 +174,7 @@ RSpec.describe UrlHelper do
)
end
- context "and secure_media setting is disabled" do
+ context "when secure_media setting is disabled" do
before { SiteSetting.secure_media = false }
it "returns the local_cdn_url" do
diff --git a/spec/lib/validators/allowed_ip_address_validator_spec.rb b/spec/lib/validators/allowed_ip_address_validator_spec.rb
index 37b7ea2ae72..2d02412ee37 100644
--- a/spec/lib/validators/allowed_ip_address_validator_spec.rb
+++ b/spec/lib/validators/allowed_ip_address_validator_spec.rb
@@ -1,12 +1,11 @@
# frozen_string_literal: true
RSpec.describe AllowedIpAddressValidator do
-
let(:record) { Fabricate.build(:user, trust_level: TrustLevel[0], ip_address: '99.232.23.123') }
let(:validator) { described_class.new(attributes: :ip_address) }
subject(:validate) { validator.validate_each(record, :ip_address, record.ip_address) }
- context "ip address should be blocked" do
+ context "when ip address should be blocked" do
it 'should add an error' do
ScreenedIpAddress.stubs(:should_block?).returns(true)
validate
@@ -15,7 +14,7 @@ RSpec.describe AllowedIpAddressValidator do
end
end
- context "ip address isn't allowed for registration" do
+ context "when ip address isn't allowed for registration" do
it 'should add an error' do
SpamHandler.stubs(:should_prevent_registration_from_ip?).returns(true)
validate
@@ -24,7 +23,7 @@ RSpec.describe AllowedIpAddressValidator do
end
end
- context "ip address should not be blocked" do
+ context "when ip address should not be blocked" do
it "shouldn't add an error" do
ScreenedIpAddress.stubs(:should_block?).returns(false)
validate
@@ -32,7 +31,7 @@ RSpec.describe AllowedIpAddressValidator do
end
end
- context 'ip_address is nil' do
+ context 'when ip_address is nil' do
it "shouldn't add an error" do
ScreenedIpAddress.expects(:should_block?).never
record.ip_address = nil
@@ -40,5 +39,4 @@ RSpec.describe AllowedIpAddressValidator do
expect(record.errors[:ip_address]).not_to be_present
end
end
-
end
diff --git a/spec/lib/validators/email_validator_spec.rb b/spec/lib/validators/email_validator_spec.rb
index 459478409eb..fc3dd1c5615 100644
--- a/spec/lib/validators/email_validator_spec.rb
+++ b/spec/lib/validators/email_validator_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe EmailValidator do
user.errors[:email].present?
end
- context "blocked email" do
+ describe "blocked email" do
it "doesn't add an error when email doesn't match a blocked email" do
expect(blocks?('[email protected]')).to eq(false)
end
@@ -39,7 +39,7 @@ RSpec.describe EmailValidator do
end
end
- context "auto approve email domains" do
+ describe "auto approve email domains" do
it "works as expected" do
SiteSetting.auto_approve_email_domains = "example.com"
diff --git a/spec/lib/validators/max_username_length_validator_spec.rb b/spec/lib/validators/max_username_length_validator_spec.rb
index 257aa772373..edb4af02902 100644
--- a/spec/lib/validators/max_username_length_validator_spec.rb
+++ b/spec/lib/validators/max_username_length_validator_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe MaxUsernameLengthValidator do
expect(validator.error_message).to eq(I18n.t("site_settings.errors.max_username_length_range"))
end
- context "checks for valid ranges" do
+ describe "checks for valid ranges" do
it "fails for values below the valid range" do
expect do
SiteSetting.max_username_length = 5
diff --git a/spec/lib/validators/min_username_length_validator_spec.rb b/spec/lib/validators/min_username_length_validator_spec.rb
index 16c1879bb38..f181eb3f92d 100644
--- a/spec/lib/validators/min_username_length_validator_spec.rb
+++ b/spec/lib/validators/min_username_length_validator_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe MinUsernameLengthValidator do
expect(validator.error_message).to eq(I18n.t("site_settings.errors.min_username_length_range"))
end
- context "checks for valid ranges" do
+ describe "checks for valid ranges" do
it "fails for values below the valid range" do
expect do
SiteSetting.min_username_length = 0
diff --git a/spec/lib/validators/password_validator_spec.rb b/spec/lib/validators/password_validator_spec.rb
index 8f6c7512732..cf04416456c 100644
--- a/spec/lib/validators/password_validator_spec.rb
+++ b/spec/lib/validators/password_validator_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe PasswordValidator do
-
def password_error_message(key)
I18n.t("activerecord.errors.models.user.attributes.password.#{key.to_s}")
end
@@ -9,15 +8,15 @@ RSpec.describe PasswordValidator do
let(:validator) { described_class.new(attributes: :password) }
subject(:validate) { validator.validate_each(record, :password, @password) }
- context "password required" do
+ describe "password required" do
let(:record) { u = Fabricate.build(:user, password: @password); u.password_required!; u }
- context "password is not common" do
+ context "when password is not common" do
before do
CommonPasswords.stubs(:common_password?).returns(false)
end
- context "min password length is 8" do
+ context "when min password length is 8" do
before { SiteSetting.min_password_length = 8 }
it "doesn't add an error when password is good" do
@@ -54,7 +53,7 @@ RSpec.describe PasswordValidator do
end
end
- context "min password length is 12" do
+ context "when min password length is 12" do
before { SiteSetting.min_password_length = 12 }
it "adds an error when password length is 11" do
@@ -65,7 +64,7 @@ RSpec.describe PasswordValidator do
end
end
- context "password is commonly used" do
+ context "when password is commonly used" do
before do
SiteSetting.min_password_length = 8
CommonPasswords.stubs(:common_password?).returns(true)
@@ -86,7 +85,7 @@ RSpec.describe PasswordValidator do
end
end
- context "password_unique_characters is 5" do
+ context "when password_unique_characters is 5" do
before do
SiteSetting.password_unique_characters = 5
end
@@ -155,7 +154,7 @@ RSpec.describe PasswordValidator do
end
end
- context "password not required" do
+ describe "password not required" do
let(:record) { Fabricate.build(:user, password: @password) }
it "doesn't add an error if password is not required" do
@@ -175,5 +174,4 @@ RSpec.describe PasswordValidator do
expect(record.errors[:password]).to be_present
end
end
-
end
diff --git a/spec/lib/validators/post_validator_spec.rb b/spec/lib/validators/post_validator_spec.rb
index 5993b92123f..b167130e9a5 100644
--- a/spec/lib/validators/post_validator_spec.rb
+++ b/spec/lib/validators/post_validator_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe PostValidator do
end
end
- describe "when post's topic is a PM between a human and a non human user" do
+ context "when post's topic is a PM between a human and a non human user" do
fab!(:robot) { Fabricate(:user, id: -3) }
fab!(:user) { Fabricate(:user) }
@@ -43,7 +43,7 @@ RSpec.describe PostValidator do
end
end
- context "stripped_length" do
+ describe "stripped_length" do
it "adds an error for short raw" do
post.raw = "abc"
validator.stripped_length(post)
@@ -102,7 +102,7 @@ RSpec.describe PostValidator do
end
end
- context "too_many_posts" do
+ describe "too_many_posts" do
it "should be invalid when the user has posted too much" do
post.user.expects(:posted_too_much_in_topic?).returns(true)
validator.max_posts_validator(post)
@@ -123,7 +123,7 @@ RSpec.describe PostValidator do
end
end
- context "too_many_mentions" do
+ describe "too_many_mentions" do
before do
SiteSetting.newuser_max_mentions_per_post = 2
SiteSetting.max_mentions_per_post = 3
@@ -180,7 +180,7 @@ RSpec.describe PostValidator do
end
end
- context "too_many_embedded_media" do
+ describe "too_many_embedded_media" do
before do
SiteSetting.min_trust_to_post_embedded_media = 0
SiteSetting.newuser_max_embedded_media = 2
@@ -223,7 +223,7 @@ RSpec.describe PostValidator do
end
end
- context "invalid post" do
+ describe "invalid post" do
it "should be invalid" do
validator.validate(post)
expect(post.errors.count).to be > 0
@@ -250,7 +250,7 @@ RSpec.describe PostValidator do
Discourse.redis.del(@pm_key)
end
- context "post is unique" do
+ context "when post is unique" do
let(:new_post) do
Fabricate.build(:post, user: user, raw: "unique content", topic: topic)
end
@@ -268,7 +268,7 @@ RSpec.describe PostValidator do
end
end
- context "post is not unique" do
+ context "when post is not unique" do
def build_post(is_pm:, raw:)
Fabricate.build(
:post,
@@ -314,8 +314,7 @@ RSpec.describe PostValidator do
end
end
- context "force_edit_last_validator" do
-
+ describe "force_edit_last_validator" do
fab!(:user) { Fabricate(:user) }
fab!(:other_user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
@@ -392,7 +391,7 @@ RSpec.describe PostValidator do
end
end
- context "admin editing a static page" do
+ describe "admin editing a static page" do
before do
post.acting_user = build(:admin)
SiteSetting.tos_topic_id = post.topic_id
@@ -401,9 +400,8 @@ RSpec.describe PostValidator do
include_examples "almost no validations"
end
- context "staged user" do
+ describe "staged user" do
before { post.acting_user = build(:user, staged: true) }
include_examples "almost no validations"
end
-
end
diff --git a/spec/lib/validators/string_setting_validator_spec.rb b/spec/lib/validators/string_setting_validator_spec.rb
index 79024da0fea..3d6b270fb1c 100644
--- a/spec/lib/validators/string_setting_validator_spec.rb
+++ b/spec/lib/validators/string_setting_validator_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe StringSettingValidator do
-
describe '#valid_value?' do
shared_examples "for all StringSettingValidator opts" do
it "returns true for blank values" do
@@ -64,7 +63,7 @@ RSpec.describe StringSettingValidator do
end
end
- context 'combinations of options' do
+ context 'with combinations of options' do
it "min and regex" do
v = described_class.new(regex: '^[\w]+$', min: 3)
expect(v.valid_value?('chocolate')).to eq(true)
@@ -94,7 +93,5 @@ RSpec.describe StringSettingValidator do
expect(v.valid_value?('ba')).to eq(false)
end
end
-
end
-
end
diff --git a/spec/lib/validators/user_full_name_validator_spec.rb b/spec/lib/validators/user_full_name_validator_spec.rb
index 8a9802bb273..c25472fd6b3 100644
--- a/spec/lib/validators/user_full_name_validator_spec.rb
+++ b/spec/lib/validators/user_full_name_validator_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe UserFullNameValidator do
subject(:validate) { validator.validate_each(record, :name, @name) }
let(:record) { Fabricate.build(:user, name: @name) }
- context "name not required" do
+ context "when name is not required" do
before { SiteSetting.full_name_required = false }
it "allows no name" do
@@ -21,7 +21,7 @@ RSpec.describe UserFullNameValidator do
end
end
- context "name required" do
+ context "when name is required" do
before { SiteSetting.full_name_required = true }
it "adds error for nil name" do
diff --git a/spec/lib/validators/username_setting_validator_spec.rb b/spec/lib/validators/username_setting_validator_spec.rb
index c59105acd32..98c994fd994 100644
--- a/spec/lib/validators/username_setting_validator_spec.rb
+++ b/spec/lib/validators/username_setting_validator_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe UsernameSettingValidator do
expect(validator.valid_value?('no way')).to eq(false)
end
- context "regex support" do
+ context "with regex support" do
fab!(:darthvader) { Fabricate(:user, username: 'darthvader') }
fab!(:luke) { Fabricate(:user, username: 'luke') }
diff --git a/spec/lib/version_spec.rb b/spec/lib/version_spec.rb
index 726bd3b8e12..a06f67e63ec 100644
--- a/spec/lib/version_spec.rb
+++ b/spec/lib/version_spec.rb
@@ -3,7 +3,7 @@
require 'version'
RSpec.describe Discourse::VERSION do
- context "has_needed_version?" do
+ describe ".has_needed_version?" do
it "works for major comparisons" do
expect(Discourse.has_needed_version?('1.0.0', '1.0.0')).to eq(true)
expect(Discourse.has_needed_version?('2.0.0', '1.0.0')).to eq(true)
@@ -43,7 +43,7 @@ RSpec.describe Discourse::VERSION do
end
end
- context "find_compatible_resource" do
+ describe ".find_compatible_resource" do
shared_examples "test compatible resource" do
it "returns nil when the current version is above all pinned versions" do
expect(Discourse.find_compatible_resource(version_list, "2.6.0")).to be_nil
@@ -86,7 +86,7 @@ RSpec.describe Discourse::VERSION do
include_examples "test compatible resource"
end
- context "handle a compatible resource out of order" do
+ context "when handling a compatible resource out of order" do
let(:version_list) { <<~YML
2.4.2.beta1: twofourtwobetaone
2.5.0.beta4: twofivebetafour
@@ -99,7 +99,7 @@ RSpec.describe Discourse::VERSION do
end
end
- context "find_compatible_git_resource" do
+ describe ".find_compatible_git_resource" do
let!(:git_directory) do
path = nil
diff --git a/spec/lib/wizard/step_updater_spec.rb b/spec/lib/wizard/step_updater_spec.rb
index 429c8e7599b..5a0f4ab7df1 100644
--- a/spec/lib/wizard/step_updater_spec.rb
+++ b/spec/lib/wizard/step_updater_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Wizard::StepUpdater do
fab!(:user) { Fabricate(:admin) }
let(:wizard) { Wizard::Builder.new(user).build }
- context "introduction" do
+ describe "introduction" do
it "updates the introduction step" do
locale = SiteSettings::DefaultsProvider::DEFAULT_LOCALE
updater = wizard.create_updater('introduction',
@@ -42,7 +42,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context "privacy" do
+ describe "privacy" do
it "updates to open correctly" do
updater = wizard.create_updater('privacy', login_required: false, invite_only: false, must_approve_users: false)
updater.update
@@ -64,7 +64,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context "styling" do
+ describe "styling" do
it "updates fonts" do
updater = wizard.create_updater('styling',
body_font: 'open_sans',
@@ -78,7 +78,7 @@ RSpec.describe Wizard::StepUpdater do
expect(SiteSetting.heading_font).to eq('oswald')
end
- context "colors" do
+ context "with colors" do
context "with an existing color scheme" do
fab!(:color_scheme) { Fabricate(:color_scheme, name: 'existing', via_wizard: true) }
@@ -122,7 +122,7 @@ RSpec.describe Wizard::StepUpdater do
Theme.delete_all
end
- context 'dark theme' do
+ context 'with dark theme' do
it "creates the theme" do
updater = wizard.create_updater('styling',
color_scheme: 'Dark',
@@ -140,7 +140,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context 'light theme' do
+ context 'with light theme' do
it "creates the theme" do
updater = wizard.create_updater('styling',
color_scheme: ColorScheme::LIGHT_THEME_ID,
@@ -184,7 +184,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context "auto dark mode" do
+ context "with auto dark mode" do
before do
dark_scheme = ColorScheme.where(name: "Dark").first
SiteSetting.default_dark_mode_color_scheme_id = dark_scheme.id
@@ -215,7 +215,7 @@ RSpec.describe Wizard::StepUpdater do
end
- context "homepage style" do
+ context "with homepage style" do
it "updates the fields correctly" do
SiteSetting.top_menu = "latest|categories|unread|top"
updater = wizard.create_updater('styling',
@@ -265,7 +265,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context "branding" do
+ describe "branding" do
it "updates the fields correctly" do
upload = Fabricate(:upload)
upload2 = Fabricate(:upload)
@@ -285,7 +285,7 @@ RSpec.describe Wizard::StepUpdater do
end
end
- context "corporate" do
+ describe "corporate" do
it "updates the fields properly" do
p = Fabricate(:post, raw: 'company_name - governing_law - city_for_disputes template')
SiteSetting.tos_topic_id = p.topic_id
diff --git a/spec/lib/wizard/wizard_builder_spec.rb b/spec/lib/wizard/wizard_builder_spec.rb
index 29fb96adaf4..564e5785350 100644
--- a/spec/lib/wizard/wizard_builder_spec.rb
+++ b/spec/lib/wizard/wizard_builder_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Wizard::Builder do
expect(wizard.steps).to be_blank
end
- context 'privacy step' do
+ describe 'privacy step' do
let(:privacy_step) { wizard.steps.find { |s| s.id == 'privacy' } }
it 'should set the right default value for the fields' do
@@ -55,7 +55,7 @@ RSpec.describe Wizard::Builder do
end
end
- context 'styling' do
+ describe 'styling' do
let(:styling_step) { wizard.steps.find { |s| s.id == 'styling' } }
let(:font_field) { styling_step.fields[1] }
fab!(:theme) { Fabricate(:theme) }
@@ -65,8 +65,8 @@ RSpec.describe Wizard::Builder do
expect(font_field.choices.size).to eq(DiscourseFonts.fonts.size)
end
- context "colors" do
- describe "when the default theme has not been override" do
+ context "with colors" do
+ context "when the default theme has not been override" do
before do
SiteSetting.find_by(name: "default_theme_id").destroy!
end
@@ -77,7 +77,7 @@ RSpec.describe Wizard::Builder do
end
end
- describe "when the default theme has been override and the color scheme doesn't have a base scheme" do
+ context "when the default theme has been override and the color scheme doesn't have a base scheme" do
let(:color_scheme) { Fabricate(:color_scheme, base_scheme_id: nil) }
before do
@@ -91,7 +91,7 @@ RSpec.describe Wizard::Builder do
end
end
- describe "when the default theme has been overridden by a theme without a color scheme" do
+ context "when the default theme has been overridden by a theme without a color scheme" do
before do
theme.set_default!
end
@@ -102,7 +102,7 @@ RSpec.describe Wizard::Builder do
end
end
- describe "when the default theme has been overridden by a theme with a color scheme" do
+ context "when the default theme has been overridden by a theme with a color scheme" do
before do
theme.update(color_scheme_id: ColorScheme.find_by_name("Dark").id)
theme.set_default!
@@ -116,7 +116,7 @@ RSpec.describe Wizard::Builder do
end
end
- context 'branding' do
+ describe 'branding' do
let(:branding_step) { wizard.steps.find { |s| s.id == 'branding' } }
it 'should set the right default value for the fields' do
diff --git a/spec/lib/wizard/wizard_spec.rb b/spec/lib/wizard/wizard_spec.rb
index e9b3c8cda75..a493fbfda2c 100644
--- a/spec/lib/wizard/wizard_spec.rb
+++ b/spec/lib/wizard/wizard_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Wizard do
SiteSetting.wizard_enabled = true
end
- context "defaults" do
+ describe "defaults" do
it "has default values" do
wizard = Wizard.new(Fabricate.build(:moderator))
expect(wizard.steps).to be_empty
diff --git a/spec/mailers/invite_mailer_spec.rb b/spec/mailers/invite_mailer_spec.rb
index 8d2c76640d0..bc4e994ffb4 100644
--- a/spec/mailers/invite_mailer_spec.rb
+++ b/spec/mailers/invite_mailer_spec.rb
@@ -1,12 +1,9 @@
# frozen_string_literal: true
RSpec.describe InviteMailer do
-
describe "send_invite" do
-
- context "invite to site" do
-
- context "default invite message" do
+ context "when inviting to site" do
+ context "with default invite message" do
fab!(:invite) { Fabricate(:invite) }
let(:invite_mail) { InviteMailer.send_invite(invite) }
@@ -35,7 +32,7 @@ RSpec.describe InviteMailer do
end
end
- context "custom invite message" do
+ context "with custom invite message" do
fab!(:invite) {
Fabricate(
:invite,
@@ -43,7 +40,7 @@ RSpec.describe InviteMailer do
)
}
- context "custom message includes invite link" do
+ context "when custom message includes invite link" do
let(:custom_invite_mail) { InviteMailer.send_invite(invite) }
it 'renders the invitee email' do
@@ -78,11 +75,11 @@ RSpec.describe InviteMailer do
end
end
- context "invite to topic" do
+ context "when inviting to topic" do
let(:trust_level_2) { build(:user, trust_level: 2) }
let(:topic) { Fabricate(:topic, excerpt: "Topic invite support is now available in Discourse!", user: trust_level_2) }
- context "default invite message" do
+ context "with default invite message" do
let(:invite) do
topic.invite(topic.user, '[email protected]')
Invite.find_by(invited_by_id: topic.user.id)
@@ -131,7 +128,7 @@ RSpec.describe InviteMailer do
end
end
- context "custom invite message" do
+ context "with custom invite message" do
let(:invite) do
topic.invite(
topic.user,
@@ -154,5 +151,4 @@ RSpec.describe InviteMailer do
end
end
end
-
end
diff --git a/spec/mailers/rejection_mailer_spec.rb b/spec/mailers/rejection_mailer_spec.rb
index cf20ab2caa5..279c4c3ee45 100644
--- a/spec/mailers/rejection_mailer_spec.rb
+++ b/spec/mailers/rejection_mailer_spec.rb
@@ -1,10 +1,8 @@
# frozen_string_literal: true
RSpec.describe RejectionMailer do
-
describe "send_rejection" do
-
- context 'sends rejection email' do
+ context 'when sending rejection email' do
fab! (:user) { Fabricate(:user) }
let (:template_args) { { former_title: "Mail Subject", destination: user.email, site_name: SiteSetting.title } }
let (:reject_mail) { RejectionMailer.send_rejection("email_reject_topic_not_found", user.email, template_args) }
diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb
index 755e3ef981e..1a7c28097fd 100644
--- a/spec/mailers/user_notifications_spec.rb
+++ b/spec/mailers/user_notifications_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe UserNotifications do
-
let(:user) { Fabricate(:admin) }
describe "#get_context_posts" do
@@ -50,11 +49,9 @@ RSpec.describe UserNotifications do
SiteSetting.private_email = true
expect(UserNotifications.get_context_posts(post3, topic_user, user).count).to eq(0)
end
-
end
describe ".signup" do
-
subject { UserNotifications.signup(user) }
it "works" do
@@ -63,11 +60,9 @@ RSpec.describe UserNotifications do
expect(subject.from).to eq([SiteSetting.notification_email])
expect(subject.body).to be_present
end
-
end
describe ".forgot_password" do
-
subject { UserNotifications.forgot_password(user) }
it "works" do
@@ -141,7 +136,6 @@ RSpec.describe UserNotifications do
end
describe '.digest' do
-
subject { UserNotifications.digest(user) }
after do
@@ -149,7 +143,6 @@ RSpec.describe UserNotifications do
end
context "without new topics" do
-
it "doesn't send the email" do
expect(subject.to).to be_blank
end
@@ -169,7 +162,6 @@ RSpec.describe UserNotifications do
end
context "with new topics" do
-
let!(:popular_topic) { Fabricate(:topic, user: Fabricate(:coding_horror), created_at: 1.hour.ago) }
it "works" do
@@ -299,7 +291,6 @@ RSpec.describe UserNotifications do
expect(html).to match(' xml:lang="pl-PL"')
end
end
-
end
describe '.user_replied' do
@@ -638,7 +629,7 @@ RSpec.describe UserNotifications do
end
end
- context "one group in pm" do
+ context "with one group in pm" do
before do
topic.allowed_groups = [group]
end
@@ -646,7 +637,7 @@ RSpec.describe UserNotifications do
include_examples "includes first group name"
end
- context "multiple groups in pm" do
+ context "with multiple groups in pm" do
let(:group2) { Fabricate(:group) }
before do
@@ -656,7 +647,7 @@ RSpec.describe UserNotifications do
include_examples "includes first group name"
end
- context "no groups in pm" do
+ context "with no groups in pm" do
it "includes %{optional_pm} in subject" do
expect(mail.subject).to include("[PM] ")
end
@@ -749,7 +740,7 @@ RSpec.describe UserNotifications do
end
shared_examples "supports reply by email" do
- context "reply_by_email" do
+ context "with reply_by_email" do
it "should have allow_reply_by_email set when that feature is enabled" do
expects_build_with(has_entry(:allow_reply_by_email, true))
end
@@ -757,7 +748,7 @@ RSpec.describe UserNotifications do
end
shared_examples "no reply by email" do
- context "reply_by_email" do
+ context "with reply_by_email" do
it "doesn't support reply by email" do
expects_build_with(Not(has_entry(:allow_reply_by_email, true)))
end
@@ -765,7 +756,7 @@ RSpec.describe UserNotifications do
end
shared_examples "respect for private_email" do
- context "private_email" do
+ context "with private_email" do
it "doesn't support reply by email" do
SiteSetting.private_email = true
@@ -789,7 +780,7 @@ RSpec.describe UserNotifications do
# The parts of emails that are derived from templates are translated
shared_examples "sets user locale" do
- context "set locale for translating templates" do
+ context "with set locale for translating templates" do
it "sets the locale" do
expects_build_with(has_key(:locale))
end
@@ -992,7 +983,7 @@ RSpec.describe UserNotifications do
include_examples "sets user locale"
end
- context "shows the right name in 'From' field" do
+ context "when showing the right name in 'From' field" do
let(:inviter) { Fabricate(:user) }
let(:invitee) { Fabricate(:user) }
@@ -1043,22 +1034,21 @@ RSpec.describe UserNotifications do
end
# notification emails derived from templates are translated into the user's locale
- shared_context "notification derived from template" do
+ shared_context "with notification derived from template" do
let(:user) { Fabricate(:user, locale: locale) }
let(:mail_type) { mail_type }
let(:notification) { Fabricate(:notification, user: user) }
end
describe "notifications from template" do
-
- context "user locale is allowed" do
+ context "when user locale is allowed" do
before do
SiteSetting.allow_user_locale = true
end
%w(signup signup_after_approval confirm_old_email notify_old_email confirm_new_email
forgot_password admin_login account_created).each do |mail_type|
- include_examples "notification derived from template" do
+ include_examples "with notification derived from template" do
let(:locale) { "fr" }
let(:mail_type) { mail_type }
it "sets the locale" do
@@ -1068,14 +1058,14 @@ RSpec.describe UserNotifications do
end
end
- context "user locale is not allowed" do
+ context "when user locale is not allowed" do
before do
SiteSetting.allow_user_locale = false
end
%w(signup signup_after_approval notify_old_email confirm_old_email confirm_new_email
forgot_password admin_login account_created).each do |mail_type|
- include_examples "notification derived from template" do
+ include_examples "with notification derived from template" do
let(:locale) { "fr" }
let(:mail_type) { mail_type }
it "sets the locale" do
@@ -1197,7 +1187,7 @@ RSpec.describe UserNotifications do
expect(mail.body).to include("May 25, 2020, 4:00pm")
end
- context "user doesn't have timezone set" do
+ context "when user doesn't have timezone set" do
before do
user.user_option.timezone = nil
end
@@ -1229,7 +1219,7 @@ RSpec.describe UserNotifications do
expect(mail.body).to include("May 25, 2020, 4:00pm")
end
- context "user doesn't have timezone set" do
+ context "when user doesn't have timezone set" do
before do
user.user_option.timezone = nil
end
diff --git a/spec/mailers/version_mailer_spec.rb b/spec/mailers/version_mailer_spec.rb
index a31db7be80b..8819df6ee16 100644
--- a/spec/mailers/version_mailer_spec.rb
+++ b/spec/mailers/version_mailer_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe VersionMailer do
subject { VersionMailer.send_notice }
- context 'contact_email is blank' do
+ context 'when contact_email is blank' do
before { SiteSetting.contact_email = '' }
it "doesn't send the email" do
@@ -11,7 +11,7 @@ RSpec.describe VersionMailer do
end
end
- context 'contact_email is set' do
+ context 'when contact_email is set' do
before { SiteSetting.contact_email = '[email protected]' }
it "works" do
@@ -20,6 +20,5 @@ RSpec.describe VersionMailer do
expect(subject.from).to eq([SiteSetting.notification_email])
expect(subject.body).to be_present
end
-
end
end
diff --git a/spec/models/associated_group_spec.rb b/spec/models/associated_group_spec.rb
index f44485d5411..55f0ec6cb5d 100644
--- a/spec/models/associated_group_spec.rb
+++ b/spec/models/associated_group_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe AssociatedGroup do
expect(described_class.has_provider?).to eq(true)
end
- context "cleanup!" do
+ describe ".cleanup!" do
before do
associated_group.last_used = 8.days.ago
associated_group.save
diff --git a/spec/models/badge_spec.rb b/spec/models/badge_spec.rb
index cc39d7b9c07..7e1c30ce9f1 100644
--- a/spec/models/badge_spec.rb
+++ b/spec/models/badge_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Badge do
-
it 'has a valid system attribute for new badges' do
expect(Badge.create!(name: "test", badge_type_id: 1).system?).to be false
end
@@ -140,7 +139,7 @@ RSpec.describe Badge do
end
end
- context "First Quote" do
+ describe "First Quote" do
let(:quoted_post_badge) do
Badge.find(Badge::FirstQuote)
end
@@ -165,12 +164,10 @@ RSpec.describe Badge do
user_badge = post2.user.user_badges.find_by(badge_id: quoted_post_badge.id)
expect(user_badge.granted_at).to eq_time(post2.created_at)
-
end
end
- context "WikiEditor badge" do
-
+ describe "WikiEditor badge" do
it "is awarded" do
wiki_editor_badge = Badge.find(Badge::WikiEditor)
post = Fabricate(:post, wiki: true)
@@ -181,11 +178,9 @@ RSpec.describe Badge do
expect(UserBadge.where(user_id: post.user.id, badge_id: Badge::WikiEditor).count).to eq(1)
end
-
end
- context "PopularLink badge" do
-
+ describe "PopularLink badge" do
let(:popular_link_badge) do
Badge.find(Badge::PopularLink)
end
@@ -222,7 +217,6 @@ RSpec.describe Badge do
end
describe "#seed" do
-
let(:regular_badge) do
Badge.find(Badge::Regular)
end
diff --git a/spec/models/bookmark_spec.rb b/spec/models/bookmark_spec.rb
index 4a753810573..7c89b6a41ad 100644
--- a/spec/models/bookmark_spec.rb
+++ b/spec/models/bookmark_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe Bookmark do
fab!(:post) { Fabricate(:post) }
- context "validations" do
+ describe "Validations" do
it "does not allow a user to create a bookmark with only one polymorphic column" do
user = Fabricate(:user)
bm = Bookmark.create(bookmarkable_id: post.id, user: user)
diff --git a/spec/models/category_featured_topic_spec.rb b/spec/models/category_featured_topic_spec.rb
index 9a90c562756..3d41bbd1c34 100644
--- a/spec/models/category_featured_topic_spec.rb
+++ b/spec/models/category_featured_topic_spec.rb
@@ -1,11 +1,10 @@
# frozen_string_literal: true
RSpec.describe CategoryFeaturedTopic do
-
it { is_expected.to belong_to :category }
it { is_expected.to belong_to :topic }
- context 'feature_topics_for' do
+ describe '.feature_topics_for' do
fab!(:user) { Fabricate(:user) }
fab!(:category) { Fabricate(:category) }
let!(:category_post) { PostCreator.create(user, raw: "I put this post in the category", title: "categorize THIS", category: category.id) }
@@ -69,5 +68,4 @@ RSpec.describe CategoryFeaturedTopic do
end
end
-
end
diff --git a/spec/models/category_group_spec.rb b/spec/models/category_group_spec.rb
index 659ebcf6e79..723ac6f098c 100644
--- a/spec/models/category_group_spec.rb
+++ b/spec/models/category_group_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe CategoryGroup do
-
describe '#permission_types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@permission_types = CategoryGroup.permission_types
end
diff --git a/spec/models/category_list_spec.rb b/spec/models/category_list_spec.rb
index 127e3420ab6..73475088249 100644
--- a/spec/models/category_list_spec.rb
+++ b/spec/models/category_list_spec.rb
@@ -12,8 +12,7 @@ RSpec.describe CategoryList do
fab!(:admin) { Fabricate(:admin) }
let(:category_list) { CategoryList.new(Guardian.new(user), include_topics: true) }
- context "security" do
-
+ describe "security" do
it "properly hide secure categories" do
cat = Fabricate(:category_with_definition)
Fabricate(:topic, category: cat)
@@ -92,7 +91,6 @@ RSpec.describe CategoryList do
end
context "with a category" do
-
fab!(:topic_category) { Fabricate(:category_with_definition, num_featured_topics: 2) }
context "with a topic in a category" do
@@ -130,7 +128,7 @@ RSpec.describe CategoryList do
end
end
- context "notification level" do
+ context "with notification level" do
it "returns 'regular' as default notification level" do
category = category_list.categories.find { |c| c.id == topic_category.id }
expect(category.notification_level).to eq(NotificationLevels.all[:regular])
@@ -151,7 +149,6 @@ RSpec.describe CategoryList do
expect(category.notification_level).to eq(NotificationLevels.all[:regular])
end
end
-
end
describe 'category order' do
@@ -170,7 +167,7 @@ RSpec.describe CategoryList do
uncategorized.save
end
- context 'fixed_category_positions is enabled' do
+ context 'when fixed_category_positions is enabled' do
before do
SiteSetting.fixed_category_positions = true
end
@@ -194,7 +191,7 @@ RSpec.describe CategoryList do
end
end
- context 'fixed_category_positions is disabled' do
+ context 'when fixed_category_positions is disabled' do
before do
SiteSetting.fixed_category_positions = false
end
@@ -241,7 +238,7 @@ RSpec.describe CategoryList do
end
end
- context 'some categories are muted' do
+ context 'when some categories are muted' do
let!(:cat1) { Fabricate(:category_with_definition) }
let!(:muted_cat) { Fabricate(:category_with_definition) }
let!(:cat3) { Fabricate(:category_with_definition) }
diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb
index 14e8754d028..942b38180cd 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe Category do
expect(cats.errors[:name]).to be_present
end
- context 'associations' do
+ describe 'Associations' do
it 'should delete associated sidebar_section_links when 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)
@@ -289,7 +289,7 @@ RSpec.describe Category do
end
describe 'non-english characters' do
- context 'uses ascii slug generator' do
+ context 'when using ascii slug generator' do
before do
SiteSetting.slug_generation_method = 'ascii'
@category = Fabricate(:category_with_definition, name: "测试")
@@ -302,7 +302,7 @@ RSpec.describe Category do
end
end
- context 'uses none slug generator' do
+ context 'when using none slug generator' do
before do
SiteSetting.slug_generation_method = 'none'
@category = Fabricate(:category_with_definition, name: "测试")
@@ -318,7 +318,7 @@ RSpec.describe Category do
end
end
- context 'uses encoded slug generator' do
+ context 'when using encoded slug generator' do
before do
SiteSetting.slug_generation_method = 'encoded'
@category = Fabricate(:category_with_definition, name: "测试")
diff --git a/spec/models/category_user_spec.rb b/spec/models/category_user_spec.rb
index 35a9cb8ff20..5e0a7b9e579 100644
--- a/spec/models/category_user_spec.rb
+++ b/spec/models/category_user_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe CategoryUser do
notification_level: NotificationLevels.all[:regular]).exists?).to eq(true)
end
- context 'integration' do
+ describe 'integration' do
before do
Jobs.run_immediately!
NotificationEmailer.enable
@@ -268,7 +268,7 @@ RSpec.describe CategoryUser do
end
describe ".muted_category_ids" do
- context "max category nesting 2" do
+ context "with max category nesting 2" do
fab!(:category1) { Fabricate(:category) }
fab!(:category2) { Fabricate(:category, parent_category: category1) }
fab!(:category3) { Fabricate(:category, parent_category: category1) }
@@ -290,7 +290,8 @@ RSpec.describe CategoryUser do
expect(CategoryUser.muted_category_ids(user)).to contain_exactly(category3.id)
end
end
- context "max category nesting 3" do
+
+ context "with max category nesting 3" do
let(:category1) { Fabricate(:category) }
let(:category2) { Fabricate(:category, parent_category: category1) }
let(:category3) { Fabricate(:category, parent_category: category2) }
diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb
index 156d2107427..ae526a5253d 100644
--- a/spec/models/color_scheme_spec.rb
+++ b/spec/models/color_scheme_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe ColorScheme do
expect(third.hex).to eq 'F00D33'
end
- context "hex_for_name without anything enabled" do
+ context "with hex_for_name without anything enabled" do
before do
ColorScheme.hex_cache.clear
end
diff --git a/spec/models/directory_item_spec.rb b/spec/models/directory_item_spec.rb
index cd62dd2144d..ae46e29e29d 100644
--- a/spec/models/directory_item_spec.rb
+++ b/spec/models/directory_item_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe DirectoryItem do
-
describe '#period_types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@period_types = DirectoryItem.period_types
end
@@ -18,7 +17,7 @@ RSpec.describe DirectoryItem do
end
end
- context 'inactive and silenced users' do
+ describe 'inactive and silenced users' do
it 'removes silenced users correctly' do
post = create_post
DirectoryItem.refresh_period!(:daily)
@@ -47,7 +46,7 @@ RSpec.describe DirectoryItem do
end
end
- context 'refresh' do
+ describe '.refresh!' do
before do
freeze_time DateTime.parse('2017-02-02 12:00')
UserActionManager.enable
@@ -144,7 +143,7 @@ RSpec.describe DirectoryItem do
expect(monthly_directory_item.days_visited).to eq(3)
end
- context 'must approve users' do
+ context 'when must_approve_users is true' do
before do
SiteSetting.must_approve_users = true
end
@@ -155,6 +154,5 @@ RSpec.describe DirectoryItem do
expect(DirectoryItem.where(user_id: user.id).count).to eq(0)
end
end
-
end
end
diff --git a/spec/models/discourse_connect_spec.rb b/spec/models/discourse_connect_spec.rb
index a383f489edd..fa2de7795ed 100644
--- a/spec/models/discourse_connect_spec.rb
+++ b/spec/models/discourse_connect_spec.rb
@@ -138,7 +138,7 @@ RSpec.describe DiscourseConnect do
expect(user.name).to eq("Bob O'Bob")
end
- context "reviewables" do
+ describe "reviewables" do
let(:sso) do
new_discourse_sso.tap do |sso|
sso.username = "staged"
@@ -639,7 +639,7 @@ RSpec.describe DiscourseConnect do
expect(sso.nonce).to_not be_nil
end
- context 'nonce error' do
+ describe 'nonce error' do
it "generates correct error message when nonce has already been used" do
_ , payload = DiscourseConnect.generate_url(secure_session: secure_session).split("?")
@@ -672,7 +672,7 @@ RSpec.describe DiscourseConnect do
end
end
- context 'user locale' do
+ describe 'user locale' do
it 'sets default user locale if specified' do
SiteSetting.allow_user_locale = true
@@ -702,7 +702,7 @@ RSpec.describe DiscourseConnect do
end
end
- context 'trusting emails' do
+ describe 'trusting emails' do
let(:sso) do
sso = new_discourse_sso
sso.username = "test"
@@ -775,7 +775,7 @@ RSpec.describe DiscourseConnect do
end
- context 'welcome emails' do
+ describe 'welcome emails' do
let(:sso) {
sso = new_discourse_sso
sso.username = "test"
@@ -797,7 +797,7 @@ RSpec.describe DiscourseConnect do
end
end
- context 'setting title for a user' do
+ describe 'setting title for a user' do
let(:sso) {
sso = new_discourse_sso
sso.username = 'test'
@@ -824,7 +824,7 @@ RSpec.describe DiscourseConnect do
end
end
- context 'setting bio for a user' do
+ describe 'setting bio for a user' do
let(:sso) do
sso = new_discourse_sso
sso.username = "test"
diff --git a/spec/models/draft_spec.rb b/spec/models/draft_spec.rb
index 751cffbe378..9b83889f673 100644
--- a/spec/models/draft_spec.rb
+++ b/spec/models/draft_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Draft do
-
fab!(:user) do
Fabricate(:user)
end
@@ -10,7 +9,7 @@ RSpec.describe Draft do
Fabricate(:post)
end
- context 'system user' do
+ describe 'system user' do
it "can not set drafts" do
# fake a sequence
DraftSequence.create!(user_id: Discourse.system_user.id, draft_key: "abc", sequence: 10)
@@ -26,7 +25,7 @@ RSpec.describe Draft do
end
end
- context 'backup_drafts_to_pm_length' do
+ describe 'backup_drafts_to_pm_length' do
it "correctly backs up drafts to a personal message" do
SiteSetting.backup_drafts_to_pm_length = 1
@@ -224,7 +223,7 @@ RSpec.describe Draft do
end
- context 'key expiry' do
+ describe 'key expiry' do
it 'nukes new topic draft after a topic is created' do
Draft.set(user, Draft::NEW_TOPIC, 0, 'my draft')
_t = Fabricate(:topic, user: user, advance_draft: true)
@@ -295,6 +294,5 @@ RSpec.describe Draft do
expect(drafts[0].post_preloaded?).to eq(true)
expect(drafts[0].post.id).to eq(post.id)
end
-
end
end
diff --git a/spec/models/email_change_request_spec.rb b/spec/models/email_change_request_spec.rb
index 1e882e3348b..c1466c595de 100644
--- a/spec/models/email_change_request_spec.rb
+++ b/spec/models/email_change_request_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe EmailChangeRequest do
- context 'validations' do
+ describe 'Validations' do
describe '#new_email' do
describe 'when email is invalid' do
it 'should not be valid' do
diff --git a/spec/models/email_log_spec.rb b/spec/models/email_log_spec.rb
index 08ec1b6489a..5ef05b26d3e 100644
--- a/spec/models/email_log_spec.rb
+++ b/spec/models/email_log_spec.rb
@@ -1,14 +1,13 @@
# frozen_string_literal: true
RSpec.describe EmailLog do
-
it { is_expected.to belong_to :user }
it { is_expected.to validate_presence_of :to_address }
it { is_expected.to validate_presence_of :email_type }
fab!(:user) { Fabricate(:user) }
- context 'unique email per post' do
+ describe 'unique email per post' do
it 'only allows through one email per post' do
post = Fabricate(:post)
user = post.user
@@ -35,7 +34,7 @@ RSpec.describe EmailLog do
end
end
- context 'after_create' do
+ describe 'after_create' do
context 'with user' do
it 'updates the last_emailed_at value for the user' do
expect {
diff --git a/spec/models/email_token_spec.rb b/spec/models/email_token_spec.rb
index a7ded830c61..04ebd0e9fcf 100644
--- a/spec/models/email_token_spec.rb
+++ b/spec/models/email_token_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe EmailToken do
expect(EmailToken.confirm(email_token.token)).to be_blank
end
- context 'taken email address' do
+ context 'with taken email address' do
before do
@other_user = Fabricate(:coding_horror)
email_token.update_attribute :email, @other_user.email
@@ -75,15 +75,14 @@ RSpec.describe EmailToken do
end
end
- context 'welcome message' do
+ context 'with welcome message' do
it 'sends a welcome message when the user is activated' do
user = EmailToken.confirm(email_token.token)
expect(user.send_welcome_message).to eq true
end
-
end
- context 'success' do
+ context 'with success' do
let!(:confirmed_user) { EmailToken.confirm(email_token.token) }
it "returns the correct user" do
@@ -105,7 +104,7 @@ RSpec.describe EmailToken do
end
end
- context 'confirms the token and redeems invite' do
+ context 'when confirms the token and redeems invite' do
before do
SiteSetting.must_approve_users = true
Jobs.run_immediately!
@@ -140,7 +139,7 @@ RSpec.describe EmailToken do
end
end
- context 'does not redeem the invite if token is password_reset' do
+ context 'when does not redeem the invite if token is password_reset' do
before do
SiteSetting.must_approve_users = true
Jobs.run_immediately!
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 648de0272e2..c9623d3e369 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Group do
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group) }
- context 'validations' do
+ describe 'Validations' do
describe '#grant_trust_level' do
describe 'when trust level is not valid' do
it 'should not be valid' do
@@ -66,7 +66,7 @@ RSpec.describe Group do
end
describe '#builtin' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@builtin = Group.builtin
end
@@ -602,7 +602,7 @@ RSpec.describe Group do
end
end
- context "group management" do
+ describe "group management" do
fab!(:group) { Fabricate(:group) }
it "by default has no managers" do
@@ -1123,7 +1123,7 @@ RSpec.describe Group do
end
end
- context "Unicode usernames and group names" do
+ describe "Unicode usernames and group names" do
before { SiteSetting.unicode_usernames = true }
it "should normalize the name" do
diff --git a/spec/models/invite_redeemer_spec.rb b/spec/models/invite_redeemer_spec.rb
index 2cdbd4ecedb..fc4c82244fc 100644
--- a/spec/models/invite_redeemer_spec.rb
+++ b/spec/models/invite_redeemer_spec.rb
@@ -242,7 +242,7 @@ RSpec.describe InviteRedeemer do
expect(invite.invited_users.first).to be_present
end
- context 'invite_link' do
+ context 'with invite_link' do
fab!(:invite_link) { Fabricate(:invite, email: nil, max_redemptions_allowed: 5, expires_at: 1.month.from_now, emailed_status: Invite.emailed_status_types[:not_required]) }
let(:invite_redeemer) { InviteRedeemer.new(invite: invite_link, email: '[email protected]') }
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index 6013de49937..e21b5169090 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Invite do
let(:xss_email) { "<b onmouseover=alert('wufff!')>email</b><script>alert('test');</script>@test.com" }
let(:escaped_email) { "&lt;b onmouseover=alert(&#39;wufff!&#39;)&gt;email&lt;/b&gt;&lt;script&gt;alert(&#39;test&#39;);&lt;/script&gt;@test.com" }
- context 'validators' do
+ describe 'Validators' do
it { is_expected.to validate_presence_of :invited_by_id }
it { is_expected.to rate_limit }
@@ -49,7 +49,7 @@ RSpec.describe Invite do
end
end
- context 'before_save' do
+ describe 'before_save' do
it 'regenerates the email token when email is changed' do
invite = Fabricate(:invite, email: '[email protected]')
token = invite.email_token
@@ -94,7 +94,7 @@ RSpec.describe Invite do
)
end
- context 'via email' do
+ context 'with email' do
it 'can be created and a job is enqueued to email the invite' do
invite = Invite.generate(user, email: '[email protected]')
expect(invite.email).to eq('[email protected]')
@@ -116,7 +116,7 @@ RSpec.describe Invite do
end
end
- context 'via link' do
+ context 'with link' do
it 'does not enqueue a job to email the invite' do
invite = Invite.generate(user, skip_email: true)
expect(invite.emailed_status).to eq(Invite.emailed_status_types[:not_required])
@@ -178,7 +178,7 @@ RSpec.describe Invite do
end
end
- context 'invite to a topic' do
+ context 'when inviting to a topic' do
fab!(:topic) { Fabricate(:topic) }
let(:invite) { Invite.generate(topic.user, email: '[email protected]', topic: topic) }
@@ -287,7 +287,7 @@ RSpec.describe Invite do
end
end
- context 'invite to a topic' do
+ context 'when inviting to a topic' do
fab!(:topic) { Fabricate(:private_message_topic) }
fab!(:another_topic) { Fabricate(:private_message_topic) }
@@ -319,7 +319,7 @@ RSpec.describe Invite do
end
end
- context 'scopes' do
+ describe 'scopes' do
fab!(:inviter) { Fabricate(:user) }
fab!(:pending_invite) { Fabricate(:invite, invited_by: inviter, email: '[email protected]') }
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
index d17e71b0ead..d43bcf31be8 100644
--- a/spec/models/notification_spec.rb
+++ b/spec/models/notification_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe Notification do
it { is_expected.to belong_to :topic }
describe '#types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@types = Notification.types
end
@@ -109,7 +109,6 @@ RSpec.describe Notification do
}.not_to change(user.notifications, :count)
end
end
-
end
describe 'high priority creation' do
@@ -131,10 +130,9 @@ RSpec.describe Notification do
end
describe 'unread counts' do
-
fab!(:user) { Fabricate(:user) }
- context 'a regular notification' do
+ context 'with a regular notification' do
it 'increases unread_notifications' do
expect { Fabricate(:notification, user: user); user.reload }.to change(user, :unread_notifications)
end
@@ -148,7 +146,7 @@ RSpec.describe Notification do
end
end
- context 'a private message' do
+ 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
@@ -166,7 +164,7 @@ RSpec.describe Notification do
end
end
- context 'a bookmark reminder message' do
+ 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
@@ -179,7 +177,6 @@ RSpec.describe Notification do
expect { Fabricate(:bookmark_reminder_notification, user: user); user.reload }.to change(user, :unread_high_priority_notifications)
end
end
-
end
describe 'message bus' do
@@ -209,7 +206,7 @@ RSpec.describe Notification do
partial_user.notifications.create!(notification_type: Notification.types[:mentioned], data: '{}')
end
- context 'destroy' do
+ context 'when destroying' do
let!(:notification) { Fabricate(:notification) }
it 'updates the notification count on destroy' do
diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb
index 467be426ad7..072e6549786 100644
--- a/spec/models/optimized_image_spec.rb
+++ b/spec/models/optimized_image_spec.rb
@@ -245,8 +245,7 @@ RSpec.describe OptimizedImage do
end
describe ".create_for" do
-
- context "versioning" do
+ context "with versioning" do
let(:filename) { 'logo.png' }
let(:file) { file_from_fixtures(filename) }
@@ -287,7 +286,6 @@ RSpec.describe OptimizedImage do
end
context "when using an internal store" do
-
let(:store) { FakeInternalStore.new }
before { Discourse.stubs(:store).returns(store) }
@@ -297,11 +295,9 @@ RSpec.describe OptimizedImage do
OptimizedImage.expects(:resize).returns(false)
expect(OptimizedImage.create_for(upload, 100, 200)).to eq(nil)
end
-
end
context "when the thumbnail is properly generated" do
-
before do
OptimizedImage.expects(:resize).returns(true)
end
@@ -329,9 +325,7 @@ RSpec.describe OptimizedImage do
oi = OptimizedImage.create_for(upload, 100, 200, format: 'gif')
expect(oi.url).to eq("/internally/stored/optimized/image.gif")
end
-
end
-
end
describe "external store" do
@@ -350,7 +344,7 @@ RSpec.describe OptimizedImage do
end
context "when the thumbnail is properly generated" do
- context "secure media disabled" do
+ context "with secure media disabled" do
let(:s3_upload) { Fabricate(:upload_s3) }
let(:optimized_path) { %r{/optimized/\d+X.*/#{s3_upload.sha1}_2_100x200\.png} }
@@ -396,7 +390,6 @@ RSpec.describe OptimizedImage do
end
end
end
-
end
class FakeInternalStore
diff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rb
index bd5473bd97d..ade7b9c92c0 100644
--- a/spec/models/post_action_spec.rb
+++ b/spec/models/post_action_spec.rb
@@ -20,8 +20,7 @@ RSpec.describe PostAction do
expect(pa).not_to be_valid
end
- context "messaging" do
-
+ describe "messaging" do
it "notifies moderators (integration test)" do
post = create_post
mod = moderator
@@ -88,7 +87,7 @@ RSpec.describe PostAction do
expect(topic.message_archived?(mod)).to eq(true)
end
- context "category group moderators" do
+ context "with category group moderators" do
fab!(:group_user) { Fabricate(:group_user) }
let(:group) { group_user.group }
@@ -109,7 +108,6 @@ RSpec.describe PostAction do
expect(readable_by_groups).to include(group.id)
end
end
-
end
describe "update_counters" do
@@ -679,7 +677,7 @@ RSpec.describe PostAction do
expect(post.hidden).to eq(false)
end
- context "topic auto closing" do
+ context "with topic auto closing" do
fab!(:topic) { Fabricate(:topic) }
let(:post1) { create_post(topic: topic) }
let(:post2) { create_post(topic: topic) }
@@ -735,7 +733,7 @@ RSpec.describe PostAction do
expect(topic_status_update.status_type).to eq(TopicTimer.types[:open])
end
- context "on a staff post" do
+ context "when on a staff post" do
fab!(:staff_user) { Fabricate(:user, moderator: true) }
fab!(:topic) { Fabricate(:topic, user: staff_user) }
@@ -988,7 +986,7 @@ RSpec.describe PostAction do
expect(event).to be_present
end
- context "resolving flags" do
+ context "when resolving flags" do
let(:result) { PostActionCreator.spam(eviltrout, post) }
let(:post_action) { result.post_action }
let(:reviewable) { result.reviewable }
diff --git a/spec/models/post_action_type_spec.rb b/spec/models/post_action_type_spec.rb
index 2eaf9b74259..1fe7429819c 100644
--- a/spec/models/post_action_type_spec.rb
+++ b/spec/models/post_action_type_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe PostActionType do
-
- context "callbacks" do
+ describe "Callbacks" do
describe '#expiry_cache' do
it 'should clear the cache on save' do
cache = ApplicationSerializer.fragment_cache
@@ -21,7 +20,7 @@ RSpec.describe PostActionType do
end
describe '#types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@types = PostActionType.types
end
diff --git a/spec/models/post_analyzer_spec.rb b/spec/models/post_analyzer_spec.rb
index 9f76550a254..fa873cabb2c 100644
--- a/spec/models/post_analyzer_spec.rb
+++ b/spec/models/post_analyzer_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe PostAnalyzer do
-
let(:default_topic_id) { 12 }
let(:url) { 'https://twitter.com/evil_trout/status/345954894420787200' }
@@ -79,7 +78,7 @@ RSpec.describe PostAnalyzer do
end
end
- context "links" do
+ describe "links" do
let(:raw_no_links) { "hello world my name is evil trout" }
let(:raw_one_link_md) { "[jlawr](http://www.imdb.com/name/nm2225369)" }
let(:raw_two_links_html) { "<a href='http://disneyland.disney.go.com/'>disney</a> <a href='http://reddit.com'>reddit</a>" }
diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb
index 962be121cd4..59ac9a11080 100644
--- a/spec/models/post_mover_spec.rb
+++ b/spec/models/post_mover_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe PostMover do
fab!(:evil_trout) { Fabricate(:evil_trout) }
describe '#move_types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@move_types = PostMover.move_types
end
@@ -21,7 +21,7 @@ RSpec.describe PostMover do
end
describe 'move_posts' do
- context 'topics' do
+ context 'with topics' do
before { freeze_time }
fab!(:user) { Fabricate(:user, admin: true) }
@@ -64,7 +64,7 @@ RSpec.describe PostMover do
action_code: "split_topic")
end
- context 'success' do
+ context 'with success' do
it "correctly handles notifications and bread crumbs" do
old_topic = p2.topic
@@ -125,8 +125,7 @@ RSpec.describe PostMover do
end
end
- context "errors" do
-
+ context "with errors" do
it "raises an error when one of the posts doesn't exist" do
non_existent_post_id = Post.maximum(:id)&.next || 1
expect { topic.move_posts(user, [non_existent_post_id], title: "new testing topic name") }.to raise_error(Discourse::InvalidParameters)
@@ -143,7 +142,7 @@ RSpec.describe PostMover do
end
end
- context "successfully moved" do
+ context "when successfully moved" do
before do
TopicUser.update_last_read(user, topic.id, p4.post_number, p4.post_number, 0)
TopicLink.extract_from(p2)
@@ -158,7 +157,7 @@ RSpec.describe PostMover do
)
end
- context "post replies" do
+ context "with post replies" do
describe "when a post with replies is moved" do
it "should update post replies correctly" do
topic.move_posts(
@@ -203,7 +202,7 @@ RSpec.describe PostMover do
end
end
- describe "when only one reply is left behind" do
+ context "when only one reply is left behind" do
it "should update post replies correctly" do
p5 = Fabricate(
:post,
@@ -225,7 +224,7 @@ RSpec.describe PostMover do
end
end
- context "to a new topic" do
+ context "when moved to a new topic" do
it "works correctly" do
topic.expects(:add_moderator_post).once
new_topic = topic.move_posts(user, [p2.id, p4.id], title: "new testing topic name", category_id: category.id, tags: ["tag1", "tag2"])
@@ -436,7 +435,7 @@ RSpec.describe PostMover do
expect(new_topic_user2.bookmarked).to eq(true)
end
- context "read state and other stats per user" do
+ context "with read state and other stats per user" do
def create_topic_user(user, opts = {})
notification_level = opts.delete(:notification_level) || :regular
@@ -535,7 +534,7 @@ RSpec.describe PostMover do
end
end
- context "to an existing topic" do
+ context "when moved to an existing topic" do
fab!(:destination_topic) { Fabricate(:topic, user: another_user) }
fab!(:destination_op) { Fabricate(:post, topic: destination_topic, user: another_user, created_at: 1.day.ago) }
@@ -710,7 +709,7 @@ RSpec.describe PostMover do
expect(Notification.exists?(admin_notification.id)).to eq(true)
end
- context "post timings" do
+ context "with post timings" do
fab!(:some_user) { Fabricate(:user) }
it "successfully moves timings" do
@@ -757,7 +756,7 @@ RSpec.describe PostMover do
expect(TopicUser.find_by(topic: destination_topic, user: user).liked).to eq(true)
end
- context "read state and other stats per user" do
+ context "with read state and other stats per user" do
def create_topic_user(user, topic, opts = {})
notification_level = opts.delete(:notification_level) || :regular
@@ -913,8 +912,7 @@ RSpec.describe PostMover do
end
end
- context "to a message" do
-
+ context "when moved to a message" do
it "works correctly" do
topic.expects(:add_moderator_post).once
new_topic = topic.move_posts(user, [p2.id, p4.id], title: "new testing topic name", archetype: "private_message")
@@ -1032,7 +1030,7 @@ RSpec.describe PostMover do
end
end
- context "moving the first post" do
+ context "when moving the first post" do
it "copies the OP, doesn't delete it" do
topic.expects(:add_moderator_post).once
new_topic = topic.move_posts(user, [p1.id, p2.id], title: "new testing topic name")
@@ -1099,14 +1097,13 @@ RSpec.describe PostMover do
end
end
- context "moving replies" do
+ context "when moving replies" do
include_examples "moves email related stuff" do
let!(:old_post) { p3 }
end
end
- context "to an existing topic with a deleted post" do
-
+ context "when moving to an existing topic with a deleted post" do
before do
topic.expects(:add_moderator_post)
end
@@ -1142,7 +1139,7 @@ RSpec.describe PostMover do
end
end
- context "to an existing closed topic" do
+ context "when moving to an existing closed topic" do
fab!(:destination_topic) { Fabricate(:topic, closed: true) }
it "works correctly for admin" do
@@ -1182,7 +1179,7 @@ RSpec.describe PostMover do
end
end
- context 'messages' do
+ context 'with messages' do
fab!(:user) { Fabricate(:user) }
fab!(:another_user) { Fabricate(:user) }
fab!(:regular_user) { Fabricate(:trust_level_4) }
@@ -1208,7 +1205,7 @@ RSpec.describe PostMover do
@like = PostActionCreator.like(another_user, p4)
end
- context 'move to new message' do
+ context 'when moving to new message' do
it "adds post users as topic allowed users" do
TopicUser.change(user, personal_message, notification_level: TopicUser.notification_levels[:muted])
TopicUser.change(another_user, personal_message, notification_level: TopicUser.notification_levels[:tracking])
@@ -1271,7 +1268,7 @@ RSpec.describe PostMover do
end
end
- context 'move to existing message' do
+ context 'when moving to existing message' do
it "adds post users as topic allowed users" do
personal_message.move_posts(admin, [p2.id, p5.id], destination_topic_id: another_personal_message.id, archetype: "private_message")
@@ -1325,7 +1322,7 @@ RSpec.describe PostMover do
end
end
- context 'banner topic' do
+ context 'with banner topic' do
fab!(:regular_user) { Fabricate(:trust_level_4) }
fab!(:topic) { Fabricate(:topic) }
fab!(:personal_message) { Fabricate(:private_message_topic, user: regular_user) }
@@ -1333,7 +1330,7 @@ RSpec.describe PostMover do
fab!(:p1) { Fabricate(:post, topic: banner_topic, user: evil_trout) }
fab!(:p2) { Fabricate(:post, topic: banner_topic, reply_to_post_number: p1.post_number, user: regular_user) }
- context 'move to existing topic' do
+ context 'when moving to existing topic' do
it "allows moving banner topic posts in regular topic" do
banner_topic.move_posts(admin, [p2.id], destination_topic_id: topic.id)
expect(p2.reload.topic_id).to eq(topic.id)
diff --git a/spec/models/post_reply_spec.rb b/spec/models/post_reply_spec.rb
index e9ae402c675..b09482a84a7 100644
--- a/spec/models/post_reply_spec.rb
+++ b/spec/models/post_reply_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe PostReply do
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:other_post) { Fabricate(:post, topic: topic) }
- context "validation" do
+ describe "Validations" do
it "should ensure that the posts belong in the same topic" do
expect(PostReply.new(post: post, reply: other_post)).to be_valid
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index e7512813d60..0fffe4dbdcc 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Post do
let(:upload_path) { Discourse.store.upload_path }
describe '#hidden_reasons' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@hidden_reasons = Post.hidden_reasons
end
@@ -24,7 +24,7 @@ RSpec.describe Post do
end
describe '#types' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@types = Post.types
end
@@ -40,7 +40,7 @@ RSpec.describe Post do
end
describe '#cook_methods' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@cook_methods = Post.cook_methods
end
@@ -97,8 +97,7 @@ RSpec.describe Post do
end
describe "revisions and deleting/recovery" do
-
- context 'a post without links' do
+ context 'with a post without links' do
let(:post) { Fabricate(:post, post_args) }
before do
@@ -122,7 +121,7 @@ RSpec.describe Post do
end
end
- context 'a post with links' do
+ context 'with a post with links' do
let(:post) { Fabricate(:post_with_external_links) }
before do
post.trash!
@@ -138,7 +137,7 @@ RSpec.describe Post do
end
end
- context 'a post with notices' do
+ context 'with a post with notices' do
let(:post) do
post = Fabricate(:post, post_args)
post.upsert_custom_fields(Post::NOTICE => { type: Post.notices[:returning_user], last_posted_at: 1.day.ago })
@@ -320,13 +319,12 @@ RSpec.describe Post do
expect(post_with_two_embedded_media.embedded_media_count).to eq(2)
end
- context "validation" do
-
+ context "with validation" do
before do
SiteSetting.newuser_max_embedded_media = 1
end
- context 'newuser' do
+ context 'with newuser' do
it "allows a new user to post below the limit" do
expect(post_one_image).to be_valid
end
@@ -353,9 +351,7 @@ RSpec.describe Post do
post_two_images.user.trust_level = TrustLevel[1]
expect(post_two_images).to be_valid
end
-
end
-
end
describe "maximum attachments" do
@@ -372,13 +368,12 @@ RSpec.describe Post do
expect(post_two_attachments.attachment_count).to eq(2)
end
- context "validation" do
-
+ context "with validation" do
before do
SiteSetting.newuser_max_attachments = 1
end
- context 'newuser' do
+ context 'with newuser' do
it "allows a new user to post below the limit" do
expect(post_one_attachment).to be_valid
end
@@ -401,12 +396,10 @@ RSpec.describe Post do
post_two_attachments.user.trust_level = TrustLevel[1]
expect(post_two_attachments).to be_valid
end
-
end
-
end
- context "links" do
+ describe "links" do
fab!(:newuser) { Fabricate(:user, trust_level: TrustLevel[0]) }
let(:no_links) { post_with_body("hello world my name is evil trout", newuser) }
let(:one_link) { post_with_body("[jlawr](http://www.imdb.com/name/nm2225369)", newuser) }
@@ -446,7 +439,6 @@ RSpec.describe Post do
end
describe "total host usage" do
-
it "has none for a regular post" do
expect(no_links.total_hosts_usage).to be_blank
end
@@ -463,11 +455,8 @@ RSpec.describe Post do
it "contains the new post's links, PLUS the previous one" do
expect(two_links.total_hosts_usage).to eq('disneyland.disney.go.com' => 2, 'reddit.com' => 1)
end
-
end
-
end
-
end
describe "maximums" do
@@ -494,13 +483,12 @@ RSpec.describe Post do
expect(post_two_links.link_count).to eq(2)
end
- context "validation" do
-
+ context "with validation" do
before do
SiteSetting.newuser_max_links = 1
end
- context 'newuser' do
+ context 'with newuser' do
it "returns true when within the amount of links allowed" do
expect(post_one_link).to be_valid
end
@@ -515,7 +503,7 @@ RSpec.describe Post do
expect(post_two_links).to be_valid
end
- context "min_trust_to_post_links" do
+ context "with min_trust_to_post_links" do
it "considers oneboxes links" do
SiteSetting.min_trust_to_post_links = 3
post_onebox.user.trust_level = TrustLevel[2]
@@ -541,15 +529,11 @@ RSpec.describe Post do
expect(post_one_link).to be_valid
end
end
-
end
-
end
describe "@mentions" do
-
- context 'raw_mentions' do
-
+ context 'with raw_mentions' do
it "returns an empty array with no matches" do
post = Fabricate.build(:post, post_args.merge(raw: "Hello Jake and Finn!"))
expect(post.raw_mentions).to eq([])
@@ -591,16 +575,14 @@ RSpec.describe Post do
post = Fabricate.build(:post, post_args.merge(raw: "@org-board"))
expect(post.raw_mentions).to eq(['org-board'])
end
-
end
- context "max mentions" do
-
+ context "with max mentions" do
fab!(:newuser) { Fabricate(:user, trust_level: TrustLevel[0]) }
let(:post_with_one_mention) { post_with_body("@Jake is the person I'm mentioning", newuser) }
let(:post_with_two_mentions) { post_with_body("@Jake @Finn are the people I'm mentioning", newuser) }
- context 'new user' do
+ context 'with new user' do
before do
SiteSetting.newuser_max_mentions_per_post = 1
SiteSetting.max_mentions_per_post = 5
@@ -615,7 +597,7 @@ RSpec.describe Post do
end
end
- context "not a new user" do
+ context "when not a new user" do
before do
SiteSetting.newuser_max_mentions_per_post = 0
SiteSetting.max_mentions_per_post = 1
@@ -631,12 +613,10 @@ RSpec.describe Post do
expect(post_with_two_mentions).not_to be_valid
end
end
-
end
-
end
- context 'validation' do
+ describe 'validation' do
it 'validates our default post' do
expect(Fabricate.build(:post, post_args)).to be_valid
end
@@ -646,8 +626,7 @@ RSpec.describe Post do
end
end
- context "raw_hash" do
-
+ describe "raw_hash" do
let(:raw) { "this is our test post body" }
let(:post) { post_with_body(raw) }
@@ -673,8 +652,7 @@ RSpec.describe Post do
end
end
- context 'revise' do
-
+ describe 'revise' do
let(:post) { Fabricate(:post, post_args) }
let(:first_version_at) { post.last_version_at }
@@ -684,16 +662,13 @@ RSpec.describe Post do
expect(post.revise(post.user, raw: post.raw)).to eq(false)
end
- describe 'with the same body' do
-
+ context 'with the same body' do
it "doesn't change version" do
expect { post.revise(post.user, raw: post.raw); post.reload }.not_to change(post, :version)
end
-
end
- describe 'grace period editing & edit windows' do
-
+ context 'with grace period editing & edit windows' do
before { SiteSetting.editing_grace_period = 1.minute.to_i }
it 'works' do
@@ -732,10 +707,9 @@ RSpec.describe Post do
expect(post.revisions.size).to eq(2)
expect(post.last_version_at.to_i).to eq(new_revised_at.to_i)
end
-
end
- describe 'rate limiter' do
+ context 'with rate limiter' do
let(:changed_by) { coding_horror }
it "triggers a rate limiter" do
@@ -744,7 +718,7 @@ RSpec.describe Post do
end
end
- describe 'with a new body' do
+ context 'with a new body' do
let(:changed_by) { coding_horror }
let!(:result) { post.revise(changed_by, raw: 'updated body') }
@@ -758,8 +732,7 @@ RSpec.describe Post do
expect(post.revisions.first.user).to be_present
end
- context 'second poster posts again quickly' do
-
+ context 'when second poster posts again quickly' do
it 'is a grace period edit, because the second poster posted again quickly' do
SiteSetting.editing_grace_period = 1.minute.to_i
post.revise(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.seconds)
@@ -769,11 +742,8 @@ RSpec.describe Post do
expect(post.public_version).to eq(2)
expect(post.revisions.size).to eq(1)
end
-
end
-
end
-
end
describe 'before save' do
@@ -793,7 +763,6 @@ RSpec.describe Post do
end
describe 'after save' do
-
let(:post) { Fabricate(:post, post_args) }
it "has correct info set" do
@@ -808,8 +777,7 @@ RSpec.describe Post do
expect(post.replies).to be_blank
end
- describe 'extract_quoted_post_numbers' do
-
+ context 'with extract_quoted_post_numbers' do
let!(:post) { Fabricate(:post, post_args) }
let(:reply) { Fabricate.build(:post, post_args) }
@@ -833,8 +801,7 @@ RSpec.describe Post do
end
end
- describe 'a new reply' do
-
+ context 'with a new reply' do
fab!(:topic) { Fabricate(:topic) }
let(:other_user) { coding_horror }
let(:reply_text) { "[quote=\"Evil Trout, post:1\"]\nhello\n[/quote]\nHmmm!" }
@@ -870,8 +837,7 @@ RSpec.describe Post do
expect(post.reply_count).to eq(1)
end
- context 'a multi-quote reply' do
-
+ context 'with a multi-quote reply' do
let!(:multi_reply) do
raw = "[quote=\"Evil Trout, post:1\"]post1 quote[/quote]\nAha!\n[quote=\"Evil Trout, post:2\"]post2 quote[/quote]\nNeat-o"
PostCreator.new(other_user, raw: raw, topic_id: topic.id, reply_to_post_number: post.post_number).create
@@ -883,12 +849,10 @@ RSpec.describe Post do
expect(reply.replies.include?(multi_reply)).to eq(true)
end
end
-
end
-
end
- context 'summary' do
+ describe 'summary' do
let!(:p1) { Fabricate(:post, post_args.merge(score: 4, percent_rank: 0.33)) }
let!(:p2) { Fabricate(:post, post_args.merge(score: 10, percent_rank: 0.66)) }
let!(:p3) { Fabricate(:post, post_args.merge(score: 5, percent_rank: 0.99)) }
@@ -901,9 +865,8 @@ RSpec.describe Post do
end
end
- context 'sort_order' do
- context 'regular topic' do
-
+ describe 'sort_order' do
+ context 'with a regular topic' do
let!(:p1) { Fabricate(:post, post_args) }
let!(:p2) { Fabricate(:post, post_args) }
let!(:p3) { Fabricate(:post, post_args) }
@@ -914,8 +877,7 @@ RSpec.describe Post do
end
end
- context "reply_history" do
-
+ describe "reply_history" do
let!(:p1) { Fabricate(:post, post_args) }
let!(:p2) { Fabricate(:post, post_args.merge(reply_to_post_number: p1.post_number)) }
let!(:p3) { Fabricate(:post, post_args) }
@@ -930,8 +892,7 @@ RSpec.describe Post do
end
- context "reply_ids" do
-
+ describe "reply_ids" do
fab!(:topic) { Fabricate(:topic) }
let!(:p1) { Fabricate(:post, topic: topic, post_number: 1) }
let!(:p2) { Fabricate(:post, topic: topic, post_number: 2, reply_to_post_number: 1) }
@@ -1624,7 +1585,7 @@ RSpec.describe Post do
end
end
- context 'topic updated_at' do
+ describe 'topic updated_at' do
let :topic do
create_post.topic
end
@@ -1657,7 +1618,7 @@ RSpec.describe Post do
end
end
- context "have_uploads" do
+ describe "have_uploads" do
it "should find all posts with the upload" do
ids = []
ids << Fabricate(:post, cooked: "A post with upload <img src='/#{upload_path}/1/defghijklmno.png'>").id
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index ab8233c7ea1..e68de4c75ab 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -265,12 +265,12 @@ RSpec.describe Report do
expect(report.total).to eq 1
end
- context 'no private messages' do
+ context 'with no private messages' do
it 'returns an empty report' do
expect(report.data).to be_blank
end
- context 'some public posts' do
+ context 'with some public posts' do
it 'returns an empty report' do
Fabricate(:post, topic: topic, user: user); Fabricate(:post, topic: topic, user: user)
expect(report.data).to be_blank
@@ -279,7 +279,7 @@ RSpec.describe Report do
end
end
- context 'some private messages' do
+ context 'with some private messages' do
before do
Fabricate(:private_message_post, created_at: 25.hours.ago, user: user)
Fabricate(:private_message_post, created_at: 1.hour.ago, user: user)
@@ -292,7 +292,7 @@ RSpec.describe Report do
expect(report.total).to eq 3
end
- context 'and some public posts' do
+ context 'with some public posts' do
before do
Fabricate(:post, user: user, topic: topic)
Fabricate(:post, user: user, topic: topic)
@@ -306,7 +306,7 @@ RSpec.describe Report do
end
end
- context 'private message from system user' do
+ context 'with private message from system user' do
before do
Fabricate(:private_message_post, created_at: 1.hour.ago, user: Discourse.system_user)
end
@@ -321,7 +321,7 @@ RSpec.describe Report do
describe 'user to user private messages' do
let(:report) { Report.find('user_to_user_private_messages') }
- context 'private message from system user' do
+ context 'with private message from system user' do
before do
Fabricate(:private_message_post, created_at: 1.hour.ago, user: Discourse.system_user)
end
@@ -626,7 +626,7 @@ RSpec.describe Report do
freeze_time(Date.today)
end
- context "moderators order" do
+ context "with moderators order" do
before do
Fabricate(:post, user: sam)
Fabricate(:post, user: jeff)
@@ -638,7 +638,7 @@ RSpec.describe Report do
end
end
- context "time read" do
+ context "with time read" do
before do
sam.user_visits.create(visited_at: 2.days.ago, time_read: 200)
sam.user_visits.create(visited_at: 1.day.ago, time_read: 100)
@@ -657,7 +657,7 @@ RSpec.describe Report do
end
end
- context "flags" do
+ context "with flags" do
before do
flagged_post = Fabricate(:post)
result = PostActionCreator.off_topic(jeff, flagged_post)
@@ -671,7 +671,7 @@ RSpec.describe Report do
end
end
- context "topics" do
+ context "with topics" do
before do
Fabricate(:topic, user: sam)
Fabricate(:topic, user: sam)
@@ -685,7 +685,7 @@ RSpec.describe Report do
expect(report.data[1][:username]).to eq('sam')
end
- context "private messages" do
+ context "with private messages" do
before do
Fabricate(:private_message_topic, user: jeff)
end
@@ -697,7 +697,7 @@ RSpec.describe Report do
end
end
- context "posts" do
+ context "with posts" do
before do
Fabricate(:post, user: sam)
Fabricate(:post, user: sam)
@@ -711,7 +711,7 @@ RSpec.describe Report do
expect(report.data[1][:username]).to eq('sam')
end
- context "private messages" do
+ context "with private messages" do
before do
Fabricate(:private_message_post, user: jeff)
end
@@ -723,7 +723,7 @@ RSpec.describe Report do
end
end
- context "private messages" do
+ context "with private messages" do
before do
Fabricate(:post, user: sam)
Fabricate(:post, user: jeff)
@@ -739,7 +739,7 @@ RSpec.describe Report do
end
end
- context "revisions" do
+ context "with revisions" do
before do
post = Fabricate(:post)
post.revise(sam, raw: 'updated body', edit_reason: 'not cool')
@@ -750,7 +750,7 @@ RSpec.describe Report do
expect(report.data[0][:username]).to eq('sam')
end
- context "revise own post" do
+ context "when revising own post" do
before do
post = Fabricate(:post, user: sam)
post.revise(sam, raw: 'updated body')
@@ -763,7 +763,7 @@ RSpec.describe Report do
end
end
- context "previous data" do
+ context "with previous data" do
before do
Fabricate(:topic, user: sam, created_at: 1.year.ago)
end
@@ -802,7 +802,7 @@ RSpec.describe Report do
include_examples 'category filtering'
- context "on subcategories" do
+ context "with subcategories" do
let(:report) { Report.find('flags', filters: { category: c0.id, 'include_subcategories': true }) }
include_examples 'category filtering on subcategories'
@@ -832,7 +832,7 @@ RSpec.describe Report do
include_examples 'category filtering'
- context "on subcategories" do
+ context "with subcategories" do
let(:report) { Report.find('topics', filters: { category: c0.id, 'include_subcategories': true }) }
include_examples 'category filtering on subcategories'
@@ -923,7 +923,7 @@ RSpec.describe Report do
include_examples 'category filtering'
- context "on subcategories" do
+ context "with subcategories" do
let(:report) { Report.find('posts', filters: { category: c0.id, 'include_subcategories': true }) }
include_examples 'category filtering on subcategories'
@@ -955,7 +955,7 @@ RSpec.describe Report do
include_examples 'category filtering'
- context "on subcategories" do
+ context "with subcategories" do
let(:report) { Report.find('topics_with_no_response', filters: { category: c0.id, 'include_subcategories': true }) }
include_examples 'category filtering on subcategories'
@@ -991,7 +991,7 @@ RSpec.describe Report do
include_examples 'category filtering'
- context "on subcategories" do
+ context "with subcategories" do
let(:report) { Report.find('likes', filters: { category: c0.id, 'include_subcategories': true }) }
include_examples 'category filtering on subcategories'
diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb
index 6a11e7110bb..b745ebf4bb7 100644
--- a/spec/models/reviewable_queued_post_spec.rb
+++ b/spec/models/reviewable_queued_post_spec.rb
@@ -5,11 +5,11 @@ RSpec.describe ReviewableQueuedPost, type: :model do
fab!(:category) { Fabricate(:category) }
fab!(:moderator) { Fabricate(:moderator) }
- context "creating a post" do
+ describe "creating a post" do
let!(:topic) { Fabricate(:topic, category: category) }
let(:reviewable) { Fabricate(:reviewable_queued_post, topic: topic) }
- context "create" do
+ context "when creating" do
it "triggers queued_post_created" do
event = DiscourseEvent.track(:queued_post_created) { reviewable.save! }
expect(event).to be_present
@@ -33,9 +33,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do
end
end
- context "actions" do
-
- context "approve_post" do
+ describe "actions" do
+ context "with approve_post" do
it 'triggers an extensibility event' do
event = DiscourseEvent.track(:approved_post) { reviewable.perform(moderator, :approve_post) }
expect(event).to be_present
@@ -96,7 +95,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
end
- context "reject_post" do
+ context "with reject_post" do
it 'triggers an extensibility event' do
event = DiscourseEvent.track(:rejected_post) { reviewable.perform(moderator, :reject_post) }
expect(event).to be_present
@@ -115,7 +114,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
end
end
- context "delete_user" do
+ context "with delete_user" do
it "deletes the user and rejects the post" do
other_reviewable = Fabricate(:reviewable_queued_post, created_by: reviewable.created_by)
@@ -132,7 +131,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
end
end
- context "creating a topic" do
+ describe "creating a topic" do
let(:reviewable) { Fabricate(:reviewable_queued_post_topic, category: category) }
before do
@@ -141,8 +140,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
SiteSetting.min_trust_level_to_tag_topics = 0
end
- context "editing" do
-
+ context "when editing" do
it "is editable and returns the fields" do
fields = reviewable.editable_for(Guardian.new(moderator))
expect(fields.has?('category_id')).to eq(true)
diff --git a/spec/models/reviewable_score_spec.rb b/spec/models/reviewable_score_spec.rb
index 09b6d0a6ffc..03765b9ead3 100644
--- a/spec/models/reviewable_score_spec.rb
+++ b/spec/models/reviewable_score_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe ReviewableScore, type: :model do
-
- context "transitions" do
+ describe "transitions" do
fab!(:user) { Fabricate(:user, trust_level: 3) }
fab!(:post) { Fabricate(:post) }
fab!(:moderator) { Fabricate(:moderator) }
@@ -156,7 +155,7 @@ RSpec.describe ReviewableScore, type: :model do
end
describe ".user_flag_score" do
- context "a user with no flags" do
+ context "with a user with no flags" do
it "returns 1.0 + trust_level" do
expect(ReviewableScore.user_flag_score(Fabricate.build(:user, trust_level: 2))).to eq(3.0)
expect(ReviewableScore.user_flag_score(Fabricate.build(:user, trust_level: 3))).to eq(4.0)
@@ -168,7 +167,7 @@ RSpec.describe ReviewableScore, type: :model do
end
end
- context "a user with some flags" do
+ context "with a user with some flags" do
fab!(:user) { Fabricate(:user) }
let(:user_stat) { user.user_stat }
@@ -204,5 +203,4 @@ RSpec.describe ReviewableScore, type: :model do
expect(ReviewableScore.calculate_score(user, 2, 3)).to eq(flag_score + 2 + 3)
end
end
-
end
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index c404f14ef99..342380bb869 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe Reviewable, type: :model do
-
describe ".create" do
fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }
@@ -136,7 +135,7 @@ RSpec.describe Reviewable, type: :model do
expect(Reviewable.list_for(user, status: :pending)).to be_blank
end
- context 'Reviewing as an admin' do
+ context 'as an admin' do
before { user.update_columns(moderator: false, admin: true) }
it 'can filter by the target_created_by_id attribute' do
@@ -393,7 +392,7 @@ RSpec.describe Reviewable, type: :model do
expect(Reviewable.valid_type?("User")).to eq(false)
end
- context "events" do
+ describe "events" do
let!(:moderator) { Fabricate(:moderator) }
let(:reviewable) { Fabricate(:reviewable) }
@@ -411,7 +410,7 @@ RSpec.describe Reviewable, type: :model do
end
end
- context "message bus notifications" do
+ describe "message bus notifications" do
fab!(:moderator) { Fabricate(:moderator) }
let(:post) { Fabricate(:post) }
@@ -596,7 +595,7 @@ RSpec.describe Reviewable, type: :model do
end
end
- context "priorities" do
+ describe "priorities" do
it "returns 0 for unknown priorities" do
expect(Reviewable.min_score_for_priority(:wat)).to eq(0.0)
end
@@ -624,7 +623,7 @@ RSpec.describe Reviewable, type: :model do
end
end
- context "custom filters" do
+ describe "custom filters" do
after do
Reviewable.clear_custom_filters!
end
@@ -684,7 +683,7 @@ RSpec.describe Reviewable, type: :model do
end
end
- context 'default actions' do
+ describe 'default actions' do
let(:reviewable) { Reviewable.new }
let(:actions) { Reviewable::Actions.new(reviewable, Guardian.new) }
diff --git a/spec/models/reviewable_user_spec.rb b/spec/models/reviewable_user_spec.rb
index ffd345db217..9ec1b729173 100644
--- a/spec/models/reviewable_user_spec.rb
+++ b/spec/models/reviewable_user_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe ReviewableUser, type: :model do
-
fab!(:moderator) { Fabricate(:moderator) }
let(:user) do
user = Fabricate(:user)
@@ -10,8 +9,9 @@ RSpec.describe ReviewableUser, type: :model do
end
fab!(:admin) { Fabricate(:admin) }
- context "actions_for" do
+ describe "#actions_for" do
fab!(:reviewable) { Fabricate(:reviewable) }
+
it "returns correct actions in the pending state" do
actions = reviewable.actions_for(Guardian.new(moderator))
expect(actions.has?(:approve_user)).to eq(true)
@@ -77,9 +77,10 @@ RSpec.describe ReviewableUser, type: :model do
end
end
- context "perform" do
+ describe "#perform" do
fab!(:reviewable) { Fabricate(:reviewable) }
- context "approve" do
+
+ context "when approving" do
it "allows us to approve a user" do
result = reviewable.perform(moderator, :approve_user)
expect(result.success?).to eq(true)
@@ -185,7 +186,7 @@ RSpec.describe ReviewableUser, type: :model do
expect(@reviewable.reviewable_by_moderator).to eq(true)
end
- context "email jobs" do
+ context "with email jobs" do
it "enqueues a 'signup after approval' email if must_approve_users is true" do
expect_enqueued_with(job: :critical_user_email, args: { type: :signup_after_approval }) do
@reviewable.perform(admin, :approve_user)
@@ -221,5 +222,4 @@ RSpec.describe ReviewableUser, type: :model do
expect(event[:params].first).to eq(user)
end
end
-
end
diff --git a/spec/models/screened_email_spec.rb b/spec/models/screened_email_spec.rb
index 4601128a30d..11045500e8d 100644
--- a/spec/models/screened_email_spec.rb
+++ b/spec/models/screened_email_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe ScreenedEmail do
-
let(:email) { '[email protected]' }
let(:similar_email) { '[email protected]' }
@@ -23,8 +22,7 @@ RSpec.describe ScreenedEmail do
end
describe '#block' do
- context 'email is not being blocked' do
-
+ context 'when email is not being blocked' do
it 'creates a new record with default action of :block' do
record = ScreenedEmail.block(email)
expect(record).not_to be_new_record
@@ -40,7 +38,7 @@ RSpec.describe ScreenedEmail do
end
end
- context 'email is already being blocked' do
+ context 'when email is already being blocked' do
let!(:existing) { Fabricate(:screened_email, email: email) }
it "doesn't create a new record" do
@@ -94,17 +92,16 @@ RSpec.describe ScreenedEmail do
end
end
- context "action_type is :block" do
+ context "when action_type is :block" do
let!(:screened_email) { Fabricate(:screened_email, email: email, action_type: ScreenedEmail.actions[:block]) }
it { is_expected.to eq(true) }
include_examples "when a ScreenedEmail record matches"
end
- context "action_type is :do_nothing" do
+ context "when action_type is :do_nothing" do
let!(:screened_email) { Fabricate(:screened_email, email: email, action_type: ScreenedEmail.actions[:do_nothing]) }
it { is_expected.to eq(false) }
include_examples "when a ScreenedEmail record matches"
end
end
-
end
diff --git a/spec/models/screened_ip_address_spec.rb b/spec/models/screened_ip_address_spec.rb
index 9b2607506eb..418ce51d591 100644
--- a/spec/models/screened_ip_address_spec.rb
+++ b/spec/models/screened_ip_address_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe ScreenedIpAddress do
end
describe '#watch' do
- context 'ip_address is not being watched' do
+ context 'when ip_address is not being watched' do
it 'should create a new record' do
record = described_class.watch(ip_address)
expect(record).not_to be_new_record
@@ -123,7 +123,7 @@ RSpec.describe ScreenedIpAddress do
end
end
- context 'ip_address is already being watched' 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
expect { described_class.watch(ip_address_arg) }.to_not change { described_class.count }
@@ -134,21 +134,21 @@ RSpec.describe ScreenedIpAddress do
end
end
- context 'using exact match' do
+ context 'when using exact match' do
fab!(:existing) { Fabricate(:screened_ip_address) }
let(:ip_address_arg) { existing.ip_address }
include_examples 'exact match of ip address'
end
- context 'using subnet mask 255.255.255.0' do
+ context 'when using subnet mask 255.255.255.0' do
fab!(:existing) { Fabricate(:screened_ip_address, ip_address: '99.232.23.124/24') }
- context 'at exact address' do
+ context 'with exact address' do
let(:ip_address_arg) { '99.232.23.124' }
include_examples 'exact match of ip address'
end
- context 'at address in same subnet' do
+ context 'with address in same subnet' do
let(:ip_address_arg) { '99.232.23.135' }
include_examples 'exact match of ip address'
end
@@ -197,7 +197,7 @@ RSpec.describe ScreenedIpAddress do
expect(described_class.should_block?('222.234.23.12')).to eq(false)
end
- context 'IPv4' do
+ context 'with IPv4' do
it 'returns false when when record matches and action is :do_nothing' do
Fabricate(:screened_ip_address, ip_address: '111.234.23.11', action_type: described_class.actions[:do_nothing])
expect(described_class.should_block?('111.234.23.11')).to eq(false)
@@ -209,7 +209,7 @@ RSpec.describe ScreenedIpAddress do
end
end
- context 'IPv6' do
+ context 'with IPv6' do
it 'returns false when when record matches and action is :do_nothing' do
Fabricate(:screened_ip_address, ip_address: '2001:db8::ff00:42:8329', action_type: described_class.actions[:do_nothing])
expect(described_class.should_block?('2001:db8::ff00:42:8329')).to eq(false)
@@ -232,7 +232,7 @@ RSpec.describe ScreenedIpAddress do
expect(described_class.is_allowed?('222.12.12.12')).to eq(false)
end
- context 'IPv4' do
+ context 'with IPv4' do
it 'returns true when when record matches and action is :do_nothing' do
Fabricate(:screened_ip_address, ip_address: '111.234.23.11', action_type: described_class.actions[:do_nothing])
expect(described_class.is_allowed?('111.234.23.11')).to eq(true)
@@ -244,7 +244,7 @@ RSpec.describe ScreenedIpAddress do
end
end
- context 'IPv6' do
+ context 'with IPv6' do
it 'returns true when when record matches and action is :do_nothing' do
Fabricate(:screened_ip_address, ip_address: '2001:db8::ff00:42:8329', action_type: described_class.actions[:do_nothing])
expect(described_class.is_allowed?('2001:db8::ff00:42:8329')).to eq(true)
@@ -258,13 +258,12 @@ RSpec.describe ScreenedIpAddress do
end
describe '#block_admin_login?' do
- context 'no allow_admin records exist' do
-
+ context 'when no allow_admin records exist' do
it "returns false when use_admin_ip_allowlist is false" do
expect(described_class.block_admin_login?(Fabricate.build(:user), '123.12.12.12')).to eq(false)
end
- context "use_admin_ip_allowlist is true" do
+ context "when use_admin_ip_allowlist is true" do
before { SiteSetting.use_admin_ip_allowlist = true }
it "returns false when user is nil" do
@@ -285,7 +284,7 @@ RSpec.describe ScreenedIpAddress do
end
end
- context 'allow_admin record exists' do
+ context 'when allow_admin record exists' do
before do
@permitted_ip_address = '111.234.23.11'
Fabricate(:screened_ip_address, ip_address: @permitted_ip_address, action_type: described_class.actions[:allow_admin])
@@ -295,7 +294,7 @@ RSpec.describe ScreenedIpAddress do
expect(described_class.block_admin_login?(Fabricate.build(:admin), '123.12.12.12')).to eq(false)
end
- context "use_admin_ip_allowlist is true" do
+ context "when use_admin_ip_allowlist is true" do
before { SiteSetting.use_admin_ip_allowlist = true }
it "returns false when user is nil" do
diff --git a/spec/models/screened_url_spec.rb b/spec/models/screened_url_spec.rb
index 284fb26076d..430b255c124 100644
--- a/spec/models/screened_url_spec.rb
+++ b/spec/models/screened_url_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe ScreenedUrl do
-
let(:url) { 'http://shopppping.com/bad/drugz' }
let(:domain) { 'shopppping.com' }
@@ -103,7 +102,7 @@ RSpec.describe ScreenedUrl do
end
describe '#watch' do
- context 'url is not being blocked' do
+ context 'when url is not being blocked' do
it 'creates a new record with default action of :do_nothing' do
record = described_class.watch(url, domain)
expect(record).not_to be_new_record
@@ -117,7 +116,7 @@ RSpec.describe ScreenedUrl do
end
end
- context 'url is already being blocked' do
+ context 'when url is already being blocked' do
let!(:existing) { Fabricate(:screened_url, url: url, domain: domain) }
it "doesn't create a new record" do
diff --git a/spec/models/search_log_spec.rb b/spec/models/search_log_spec.rb
index 1cac6f9ecef..773fa56f250 100644
--- a/spec/models/search_log_spec.rb
+++ b/spec/models/search_log_spec.rb
@@ -1,14 +1,12 @@
# frozen_string_literal: true
RSpec.describe SearchLog, type: :model do
-
after do
SearchLog.clear_debounce_cache!
end
describe ".log" do
-
- context "invalid arguments" do
+ context "with invalid arguments" do
it "no search type returns error" do
status, _ = SearchLog.log(
term: 'bounty hunter',
@@ -157,7 +155,6 @@ RSpec.describe SearchLog, type: :model do
)
expect(action).to eq(:created)
end
-
end
end
@@ -202,7 +199,7 @@ RSpec.describe SearchLog, type: :model do
end
end
- context "trending" do
+ describe "trending" do
fab!(:user) { Fabricate(:user) }
before do
SearchLog.log(term: 'ruby', search_type: :header, ip_address: '127.0.0.1')
@@ -234,8 +231,7 @@ RSpec.describe SearchLog, type: :model do
end
end
- context "clean_up" do
-
+ describe "clean_up" do
it "will remove 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')
@@ -252,7 +248,5 @@ RSpec.describe SearchLog, type: :model do
expect(SearchLog.where(term: 'rey').first).to be_present
expect(SearchLog.where(term: 'finn').first).to be_present
end
-
end
-
end
diff --git a/spec/models/sidebar_section_link_spec.rb b/spec/models/sidebar_section_link_spec.rb
index d4456dc2ab9..e497a45b98c 100644
--- a/spec/models/sidebar_section_link_spec.rb
+++ b/spec/models/sidebar_section_link_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe SidebarSectionLink do
fab!(:user) { Fabricate(:user) }
- context "validations" do
+ describe "Validations" do
it 'is not valid when linkable already exists for the current user' do
category_sidebar_section_link = Fabricate(:category_sidebar_section_link, user: user)
diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rb
index 762b37fe9f2..df2d9a4c581 100644
--- a/spec/models/site_setting_spec.rb
+++ b/spec/models/site_setting_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe SiteSetting do
-
describe 'topic_title_length' do
it 'returns a range of min/max topic title length' do
expect(SiteSetting.topic_title_length).to eq(
@@ -29,7 +28,6 @@ RSpec.describe SiteSetting do
end
describe 'in test we do some judo to ensure SiteSetting is always reset between tests' do
-
it 'is always the correct default' do
expect(SiteSetting.contact_email).to eq('')
end
@@ -81,9 +79,7 @@ RSpec.describe SiteSetting do
end
describe "min_redirected_to_top_period" do
-
- context "has_enough_top_topics" do
-
+ context "when has_enough_top_topics" do
before do
SiteSetting.topics_per_period_in_top_page = 2
SiteSetting.top_page_default_timeframe = 'daily'
@@ -98,11 +94,9 @@ RSpec.describe SiteSetting do
it "should_return_a_time_period" do
expect(SiteSetting.min_redirected_to_top_period(1.days.ago)).to eq(:daily)
end
-
end
- context "does_not_have_enough_top_topics" do
-
+ context "when does_not_have_enough_top_topics" do
before do
SiteSetting.topics_per_period_in_top_page = 20
SiteSetting.top_page_default_timeframe = 'daily'
@@ -112,9 +106,7 @@ RSpec.describe SiteSetting do
it "should_return_a_time_period" do
expect(SiteSetting.min_redirected_to_top_period(1.days.ago)).to eq(nil)
end
-
end
-
end
describe "scheme" do
@@ -132,7 +124,7 @@ RSpec.describe SiteSetting do
end
end
- context "shared_drafts_enabled?" do
+ describe ".shared_drafts_enabled?" do
it "returns false by default" do
expect(SiteSetting.shared_drafts_enabled?).to eq(false)
end
@@ -148,7 +140,7 @@ RSpec.describe SiteSetting do
end
end
- context 'deprecated site settings' do
+ describe 'deprecated site settings' do
before do
SiteSetting.force_https = true
@orig_logger = Rails.logger
diff --git a/spec/models/sitemap_spec.rb b/spec/models/sitemap_spec.rb
index 23bf57efed5..552dd58e649 100644
--- a/spec/models/sitemap_spec.rb
+++ b/spec/models/sitemap_spec.rb
@@ -109,7 +109,7 @@ RSpec.describe Sitemap do
it_behaves_like 'Excludes hidden and restricted topics'
end
- context 'sitemap for recent topics' do
+ context 'with sitemap for recent topics' do
let(:sitemap) do
described_class.new(
enabled: true, last_posted_at: 1.minute.ago, name: described_class::RECENT_SITEMAP_NAME
@@ -134,7 +134,7 @@ RSpec.describe Sitemap do
it_behaves_like 'Excludes hidden and restricted topics'
end
- context 'news sitemap' do
+ context 'with news sitemap' do
let(:sitemap) do
described_class.new(
enabled: true, last_posted_at: 1.minute.ago, name: described_class::NEWS_SITEMAP_NAME
diff --git a/spec/models/tag_group_spec.rb b/spec/models/tag_group_spec.rb
index 2caa05349e7..1891acda29e 100644
--- a/spec/models/tag_group_spec.rb
+++ b/spec/models/tag_group_spec.rb
@@ -84,7 +84,7 @@ RSpec.describe TagGroup do
include_examples "correct visible tag groups"
- context "staff-only tag group restricted to a public category" do
+ context "with staff-only tag group restricted to a public category" do
before do
public_category.allowed_tag_groups = [public_tag_group.name, staff_only_tag_group.name]
private_category.allowed_tag_groups = [private_tag_group.name, staff_only_tag_group.name]
diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb
index b3353d8f4f7..4d9be093bc7 100644
--- a/spec/models/tag_spec.rb
+++ b/spec/models/tag_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Tag do
SiteSetting.min_trust_level_to_tag_topics = 0
end
- context 'associations' do
+ describe 'Associations' do
it 'should delete associated sidebar_section_links when 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)
@@ -185,7 +185,7 @@ RSpec.describe Tag do
end
end
- context "topic counts" do
+ describe "topic counts" do
it "should exclude private message topics" do
topic
Fabricate(:private_message_topic, tags: [tag])
@@ -195,7 +195,7 @@ RSpec.describe Tag do
end
end
- context "unused tags scope" do
+ describe "unused tags scope" do
let!(:tags) do
[ Fabricate(:tag, name: "used_publically", topic_count: 2, pm_topic_count: 0),
Fabricate(:tag, name: "used_privately", topic_count: 0, pm_topic_count: 3),
@@ -212,7 +212,7 @@ RSpec.describe Tag do
end
end
- context "full_url" do
+ describe "full_url" do
let(:tag) { Fabricate(:tag, name: "🚀") }
it "percent encodes emojis" do
@@ -220,7 +220,7 @@ RSpec.describe Tag do
end
end
- context "synonyms" do
+ describe "synonyms" do
let(:synonym) { Fabricate(:tag, target_tag: tag) }
it "can be a synonym for another tag" do
diff --git a/spec/models/tag_user_spec.rb b/spec/models/tag_user_spec.rb
index 53dd65eb632..8d2e1f86fde 100644
--- a/spec/models/tag_user_spec.rb
+++ b/spec/models/tag_user_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe TagUser do
TagUser.notification_levels[:watching]
end
- context "notification_level_visible" do
+ describe "notification_level_visible" do
let!(:tag1) { Fabricate(:tag) }
let!(:tag2) { Fabricate(:tag) }
let!(:tag3) { Fabricate(:tag) }
@@ -69,7 +69,7 @@ RSpec.describe TagUser do
end
end
- context "change" do
+ describe "change" do
it "watches or tracks on change" do
user = Fabricate(:user)
tag = Fabricate(:tag)
@@ -111,7 +111,7 @@ RSpec.describe TagUser do
end
end
- context "batch_set" do
+ describe "batch_set" do
it "watches and unwatches tags correctly" do
user = Fabricate(:user)
@@ -160,7 +160,7 @@ RSpec.describe TagUser do
end
end
- context "integration" do
+ describe "integration" do
fab!(:user) { Fabricate(:user) }
fab!(:watched_tag) { Fabricate(:tag) }
let(:muted_tag) { Fabricate(:tag) }
diff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rb
index 8b99f55ef2c..ce2a1b6220d 100644
--- a/spec/models/theme_field_spec.rb
+++ b/spec/models/theme_field_spec.rb
@@ -402,7 +402,7 @@ HTML
end
end
- context "SVG sprite theme fields" do
+ describe "SVG sprite theme fields" do
let(:upload) { Fabricate(:upload) }
let(:theme) { Fabricate(:theme) }
let(:theme_field) { ThemeField.create!(theme: theme, target_id: 0, name: SvgSprite.theme_sprite_variable_name, upload: upload, value: "", value_baked: "baked", type_id: ThemeField.types[:theme_upload_var]) }
@@ -429,8 +429,7 @@ HTML
end
end
- context 'local js assets' do
-
+ describe 'local js assets' do
let :js_content do
"// not transpiled; console.log('hello world');"
end
@@ -515,5 +514,4 @@ HTML
expect(theme.scss_variables).not_to include("theme_uploads")
end
end
-
end
diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb
index 51711214153..2689f613e6d 100644
--- a/spec/models/theme_spec.rb
+++ b/spec/models/theme_spec.rb
@@ -222,7 +222,7 @@ HTML
end
end
- context "plugin api" do
+ describe "plugin api" do
def transpile(html)
f = ThemeField.create!(target_id: Theme.targets[:mobile], theme_id: 1, name: "after_header", value: html)
f.ensure_baked!
@@ -267,7 +267,7 @@ HTML
end
end
- context 'theme upload vars' do
+ describe 'theme upload vars' do
let :image do
file_from_fixtures("logo.png")
end
@@ -298,7 +298,7 @@ HTML
end
end
- context "theme settings" do
+ describe "theme settings" do
it "allows values to be used in scss" do
theme.set_field(target: :settings, name: :yaml, value: "background_color: red\nfont_size: 25px")
theme.set_field(target: :common, name: :scss, value: 'body {background-color: $background_color; font-size: $font-size}')
diff --git a/spec/models/top_topic_spec.rb b/spec/models/top_topic_spec.rb
index 27a4620c9ad..6542779e295 100644
--- a/spec/models/top_topic_spec.rb
+++ b/spec/models/top_topic_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe TopTopic do
-
describe '#sorted_periods' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@sorted_periods = TopTopic.sorted_periods
end
@@ -20,8 +19,7 @@ RSpec.describe TopTopic do
it { is_expected.to belong_to :topic }
- context "refresh!" do
-
+ describe ".refresh!" do
fab!(:t1) { Fabricate(:topic) }
fab!(:t2) { Fabricate(:topic) }
@@ -30,7 +28,6 @@ RSpec.describe TopTopic do
end
context "after calculating" do
-
before do
TopTopic.refresh!
end
@@ -42,7 +39,6 @@ RSpec.describe TopTopic do
end
describe "#compute_top_score_for" do
-
fab!(:user) { Fabricate(:user) }
fab!(:coding_horror) { Fabricate(:coding_horror) }
@@ -139,7 +135,6 @@ RSpec.describe TopTopic do
expect(top_topics.where(topic_id: topic_1.id).pluck_first(:yearly_score)).to eq(27)
expect(top_topics.where(topic_id: topic_2.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(18.301029995664)
expect(top_topics.where(topic_id: topic_3.id).pluck_first(:yearly_score)).to be_within(0.0000000001).of(10.602059991328)
-
end
end
end
diff --git a/spec/models/topic_converter_spec.rb b/spec/models/topic_converter_spec.rb
index a8cdf0cbb2c..084d50f0d19 100644
--- a/spec/models/topic_converter_spec.rb
+++ b/spec/models/topic_converter_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe TopicConverter do
-
- context 'convert_to_public_topic' do
+ describe 'convert_to_public_topic' do
fab!(:admin) { Fabricate(:admin) }
fab!(:author) { Fabricate(:user) }
fab!(:category) { Fabricate(:category, topic_count: 1) }
@@ -14,7 +13,7 @@ RSpec.describe TopicConverter do
Category.find(SiteSetting.uncategorized_category_id)
end
- context 'success' do
+ context 'with success' do
it "converts private message to regular topic" do
SiteSetting.allow_uncategorized_topics = true
topic = nil
@@ -44,7 +43,7 @@ RSpec.describe TopicConverter do
expect(topic.category_id).to eq(SiteSetting.uncategorized_category_id)
end
- describe 'when uncategorized category is not allowed' do
+ context 'when uncategorized category is not allowed' do
before do
SiteSetting.allow_uncategorized_topics = false
category.update!(read_restricted: false)
@@ -65,7 +64,7 @@ RSpec.describe TopicConverter do
end
end
- describe 'when a custom category_id is given' do
+ context 'when a custom category_id is given' do
it 'should convert private message into the right category' do
topic = TopicConverter.new(first_post.topic, admin).convert_to_public_topic(category.id)
@@ -118,14 +117,14 @@ RSpec.describe TopicConverter do
end
end
- context 'convert_to_private_message' do
+ describe 'convert_to_private_message' do
fab!(:admin) { Fabricate(:admin) }
fab!(:author) { Fabricate(:user) }
fab!(:category) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, user: author, category_id: category.id) }
fab!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
- context 'success' do
+ context 'with success' do
it "converts regular topic to private message" do
private_message = topic.convert_to_private_message(post.user)
expect(private_message).to be_valid
@@ -207,7 +206,7 @@ RSpec.describe TopicConverter do
end
end
- context 'topic has replies' do
+ context 'when topic has replies' do
before do
@replied_user = Fabricate(:coding_horror)
create_post(topic: topic, user: @replied_user)
@@ -234,7 +233,7 @@ RSpec.describe TopicConverter do
end
end
- context 'user_profiles with newly converted PM as featured topic' do
+ context 'with user_profiles with newly converted PM as featured topic' do
it "sets all matching user_profile featured topic ids to nil" do
author.user_profile.update(featured_topic: topic)
topic.convert_to_private_message(admin)
@@ -242,6 +241,5 @@ RSpec.describe TopicConverter do
expect(author.user_profile.reload.featured_topic).to eq(nil)
end
end
-
end
end
diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb
index a112a126ffc..bedfb02978a 100644
--- a/spec/models/topic_embed_spec.rb
+++ b/spec/models/topic_embed_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe TopicEmbed do
it { is_expected.to validate_presence_of :embed_url }
describe '.import' do
-
fab!(:user) { Fabricate(:user) }
let(:title) { "How to turn a fish from good to evil in 30 seconds" }
let(:url) { 'http://eviltrout.com/123' }
@@ -23,7 +22,7 @@ RSpec.describe TopicEmbed do
expect(TopicEmbed.count).to eq(0)
end
- context 'creation of a post' do
+ context 'when creating a post' do
let!(:post) { TopicEmbed.import(user, url, title, contents) }
let(:topic_embed) { TopicEmbed.find_by(post: post) }
@@ -128,7 +127,7 @@ RSpec.describe TopicEmbed do
end
end
- context "post creation supports markdown rendering" do
+ context "when post creation supports markdown rendering" do
before do
SiteSetting.embed_support_markdown = true
end
@@ -215,7 +214,7 @@ RSpec.describe TopicEmbed do
end
end
- context 'post with allowed classes "foo" and "emoji"' do
+ context 'with post with allowed classes "foo" and "emoji"' do
fab!(:user) { Fabricate(:user) }
let(:url) { 'http://eviltrout.com/123' }
let(:contents) { "my normal size emoji <p class='foo'>Hi</p> <img class='emoji other foo' src='/images/smiley.jpg'>" }
@@ -247,7 +246,7 @@ RSpec.describe TopicEmbed do
end
end
- context 'post with author metadata' do
+ context 'with post with author metadata' do
fab!(:user) { Fabricate(:user, username: 'eviltrout') }
let(:url) { 'http://eviltrout.com/321' }
let(:contents) { '<html><head><meta name="author" content="eviltrout"></head><body>rich and morty</body></html>' }
@@ -263,7 +262,7 @@ RSpec.describe TopicEmbed do
end
end
- context 'post with no allowed classes' do
+ context 'with post with no allowed classes' do
fab!(:user) { Fabricate(:user) }
let(:url) { 'http://eviltrout.com/123' }
let(:contents) { "my normal size emoji <p class='foo'>Hi</p> <img class='emoji other foo' src='/images/smiley.jpg'>" }
@@ -291,7 +290,7 @@ RSpec.describe TopicEmbed do
end
end
- context "non-ascii URL" do
+ context "with non-ascii URL" do
let(:url) { 'http://eviltrout.com/test/ماهی' }
let(:contents) { "<title>سلام</title><body>این یک پاراگراف آزمون است.</body>" }
@@ -305,7 +304,7 @@ RSpec.describe TopicEmbed do
end
end
- context "encoded URL" do
+ context "with encoded URL" do
let(:url) { 'http://example.com/hello%20world' }
let(:contents) { "<title>Hello World!</title><body></body>" }
@@ -319,7 +318,7 @@ RSpec.describe TopicEmbed do
end
end
- context "non-http URL" do
+ context "with non-http URL" do
it "throws an error" do
url = '/test.txt'
@@ -327,7 +326,7 @@ RSpec.describe TopicEmbed do
end
end
- context "emails" do
+ context "with emails" do
let(:url) { 'http://example.com/foo' }
let(:contents) { '<p><a href="mailto:foo%40example.com">URL encoded @ symbol</a></p><p><a href="mailto:[email protected]">normal mailto link</a></p>' }
@@ -343,7 +342,7 @@ RSpec.describe TopicEmbed do
end
end
- context "malformed href" do
+ context "with malformed href" do
let(:url) { 'http://example.com/foo' }
let(:contents) { '<p><a href="(http://foo.bar)">Baz</a></p>' }
@@ -356,7 +355,7 @@ RSpec.describe TopicEmbed do
end
end
- context 'canonical links' do
+ context 'with canonical links' do
let(:url) { 'http://eviltrout.com/123?asd' }
let(:canonical_url) { 'http://eviltrout.com/123' }
let(:content) { "<head><link rel=\"canonical\" href=\"#{canonical_url}\"></head>" }
diff --git a/spec/models/topic_link_click_spec.rb b/spec/models/topic_link_click_spec.rb
index 4d3fc35cd55..4f43fc456df 100644
--- a/spec/models/topic_link_click_spec.rb
+++ b/spec/models/topic_link_click_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe TopicLinkClick do
-
it { is_expected.to belong_to :topic_link }
it { is_expected.to belong_to :user }
it { is_expected.to validate_presence_of :topic_link_id }
@@ -10,7 +9,7 @@ RSpec.describe TopicLinkClick do
URI.parse('http://test.host')
end
- context 'topic_links' do
+ describe 'topic_links' do
before do
@topic = Fabricate(:topic)
@post = Fabricate(:post_with_external_links, user: @topic.user, topic: @topic)
@@ -22,7 +21,7 @@ RSpec.describe TopicLinkClick do
expect(@topic_link.clicks).to eq(0)
end
- context 'create' do
+ describe '.create' do
before do
TopicLinkClick.create(topic_link: @topic_link, ip_address: '192.168.1.1')
end
@@ -37,10 +36,8 @@ RSpec.describe TopicLinkClick do
end
end
- context 'create_from' do
-
+ describe '.create_from' do
it "works correctly" do
-
# returns nil to prevent exploits
click = TopicLinkClick.create_from(url: "http://url-that-doesnt-exist.com", post_id: @post.id, ip: '127.0.0.1')
expect(click).to eq(nil)
@@ -93,7 +90,7 @@ RSpec.describe TopicLinkClick do
end
- context "relative urls" do
+ context "with relative urls" do
let(:host) { URI.parse(Discourse.base_url).host }
it 'returns the url' do
@@ -113,8 +110,7 @@ RSpec.describe TopicLinkClick do
expect(redirect).to eq(url)
end
- context "cdn links" do
-
+ context "with cdn links" do
before do
Rails.configuration.action_controller.asset_host = "https://cdn.discourse.org/stuff"
end
@@ -161,8 +157,7 @@ RSpec.describe TopicLinkClick do
end
- context "s3 cdns" do
-
+ context "with s3 cdns" do
it "works with s3 urls" do
setup_s3
SiteSetting.s3_cdn_url = "https://discourse-s3-cdn.global.ssl.fastly.net"
@@ -236,7 +231,7 @@ RSpec.describe TopicLinkClick do
end
end
- context 'same base URL with different query' do
+ context 'with same base URL with different query' do
it 'are handled differently' do
post = Fabricate(:post, raw: <<~RAW)
no query param: http://example.com/a
@@ -282,11 +277,7 @@ RSpec.describe TopicLinkClick do
expect(@click.topic_link).to eq(@topic_link)
expect(@url).to eq(@topic_link.url)
end
-
end
-
end
-
end
-
end
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index e95c78a31f9..19f94bad351 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe TopicLink do
-
it { is_expected.to validate_presence_of :url }
def test_uri
@@ -74,11 +73,9 @@ RSpec.describe TopicLink do
expect(new_ids).to contain_exactly(*old_ids)
end
-
end
describe 'internal links' do
-
it "extracts onebox" do
other_topic = Fabricate(:topic, user: user)
Fabricate(:post, topic: other_topic, user: user, raw: "some content for the first post")
@@ -99,8 +96,7 @@ RSpec.describe TopicLink do
expect(link.url).to eq(url)
end
- context 'topic link' do
-
+ context 'with topic link' do
fab!(:other_topic) do
Fabricate(:topic, user: user)
end
@@ -111,7 +107,6 @@ RSpec.describe TopicLink do
end
it 'works' do
-
# ensure other_topic has a post
post
@@ -237,7 +232,7 @@ RSpec.describe TopicLink do
end
end
- context "link to a user on discourse" do
+ context "with link to a user on discourse" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: "<a href='/u/#{user.username_lower}'>user</a>") }
before do
@@ -249,7 +244,7 @@ RSpec.describe TopicLink do
end
end
- context "link to a discourse resource like a FAQ" do
+ context "with link to a discourse resource like a FAQ" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: "<a href='/faq'>faq link here</a>") }
before do
TopicLink.extract_from(post)
@@ -260,7 +255,7 @@ RSpec.describe TopicLink do
end
end
- context "mention links" do
+ context "with mention links" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: "Hey #{user.username_lower}") }
before do
@@ -272,7 +267,7 @@ RSpec.describe TopicLink do
end
end
- context "email address" do
+ context "with email address" do
it "does not extract a link" do
post = Fabricate(:post, topic: topic, user: user, raw: "Valid email: [email protected]\n\nInvalid email: rfc822;[email protected]")
TopicLink.extract_from(post)
@@ -280,7 +275,7 @@ RSpec.describe TopicLink do
end
end
- context "mail link" do
+ context "with mail link" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: "[email][email protected][/email]") }
it 'does not extract a link' do
@@ -289,7 +284,7 @@ RSpec.describe TopicLink do
end
end
- context "quote links" do
+ context "with quote links" do
it "sets quote correctly" do
linked_post = Fabricate(:post, topic: topic, user: user, raw: "my test post")
quoting_post = Fabricate(:post, raw: "[quote=\"#{user.username}, post: #{linked_post.post_number}, topic: #{topic.id}\"]\nquote\n[/quote]")
@@ -302,7 +297,7 @@ RSpec.describe TopicLink do
end
end
- context "link to a local attachments" do
+ context "with link to a local attachments" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: '<a class="attachment" href="/uploads/default/208/87bb3d8428eb4783.rb?foo=bar">ruby.rb</a>') }
it "extracts the link" do
@@ -322,7 +317,7 @@ RSpec.describe TopicLink do
end
- context "link to an attachments uploaded on S3" do
+ context "with link to an attachments uploaded on S3" do
let(:post) { Fabricate(:post, topic: topic, user: user, raw: '<a class="attachment" href="//s3.amazonaws.com/bucket/2104a0211c9ce41ed67989a1ed62e9a394c1fbd1446.rb">ruby.rb</a>') }
it "extracts the link" do
@@ -519,5 +514,4 @@ RSpec.describe TopicLink do
expect { TopicLink.extract_from(post) }.to_not raise_error
end
end
-
end
diff --git a/spec/models/topic_list_spec.rb b/spec/models/topic_list_spec.rb
index 18dfb84a2f1..89401996d18 100644
--- a/spec/models/topic_list_spec.rb
+++ b/spec/models/topic_list_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe TopicList do
end
end
- context "preload" do
+ describe "preload" do
it "allows preloading of data" do
preloaded_topic = false
preloader = lambda do |topics, topic_list|
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb
index 81074386128..b21761e952e 100644
--- a/spec/models/topic_spec.rb
+++ b/spec/models/topic_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Topic do
fab!(:group) { Fabricate(:group) }
fab!(:trust_level_2) { Fabricate(:user, trust_level: SiteSetting.min_trust_level_to_allow_invite) }
- context 'validations' do
+ describe 'Validations' do
let(:topic) { Fabricate.build(:topic) }
describe "#featured_link" do
@@ -160,7 +160,6 @@ RSpec.describe Topic do
end
end
end
-
end
it { is_expected.to rate_limit }
@@ -210,8 +209,8 @@ RSpec.describe Topic do
end
end
- context 'slug' do
- context 'encoded generator' do
+ describe 'slug' do
+ context 'with encoded generator' do
before { SiteSetting.slug_generation_method = 'encoded' }
context 'with ascii letters' do
@@ -247,7 +246,7 @@ RSpec.describe Topic do
end
end
- context 'none generator' do
+ context 'with none generator' do
let!(:title) { "熱帶風暴畫眉" }
let!(:slug) { "topic" }
let!(:topic) { Fabricate.build(:topic, title: title) }
@@ -286,7 +285,7 @@ RSpec.describe Topic do
end
end
- context 'slug computed hooks' do
+ describe 'slug computed hooks' do
before do
invert_slug = ->(topic, slug, title) { slug.reverse }
Topic.slug_computed_callbacks << invert_slug
@@ -318,7 +317,7 @@ RSpec.describe Topic do
end
end
- context "updating a title to be shorter" do
+ describe "updating a title to be shorter" do
let!(:topic) { Fabricate(:topic) }
it "doesn't update it to be shorter due to cleaning using TextCleaner" do
@@ -327,7 +326,7 @@ RSpec.describe Topic do
end
end
- context 'private message title' do
+ describe 'private message title' do
before do
SiteSetting.min_topic_title_length = 15
SiteSetting.min_personal_message_title_length = 3
@@ -344,7 +343,7 @@ RSpec.describe Topic do
end
end
- context 'admin topic title' do
+ describe 'admin topic title' do
it 'allows really short titles' do
pm = Fabricate.build(:private_message_topic, user: admin, title: 'a')
expect(pm).to be_valid
@@ -356,7 +355,7 @@ RSpec.describe Topic do
end
end
- context 'topic title uniqueness' do
+ describe 'topic title uniqueness' do
fab!(:category1) { Fabricate(:category) }
fab!(:category2) { Fabricate(:category) }
@@ -428,11 +427,9 @@ RSpec.describe Topic do
expect(new_topic_different_cat.errors[:title]).to include(I18n.t("errors.messages.too_short", count: 134))
end
end
-
end
- context 'html in title' do
-
+ describe 'html in title' do
def build_topic_with_title(title)
build(:topic, title: title).tap { |t| t.valid? }
end
@@ -472,14 +469,14 @@ RSpec.describe Topic do
expect(topic_script.fancy_title).not_to include("<script>")
end
- context "emoji shortcuts enabled" do
+ context "with emoji shortcuts enabled" do
before { SiteSetting.enable_emoji_shortcuts = true }
it "converts emoji shortcuts into emoji" do
expect(topic_shortcut_emoji.fancy_title).to eq("I love candy :slight_smile:")
end
- context "emojis disabled" do
+ context "with emojis disabled" do
before { SiteSetting.enable_emoji = false }
it "does not convert emoji shortcuts" do
@@ -488,7 +485,7 @@ RSpec.describe Topic do
end
end
- context "emoji shortcuts disabled" do
+ context "with emoji shortcuts disabled" do
before { SiteSetting.enable_emoji_shortcuts = false }
it "does not convert emoji shortcuts" do
@@ -507,10 +504,10 @@ RSpec.describe Topic do
end
end
- context 'fancy title' do
+ describe 'fancy title' do
let(:topic) { Fabricate.build(:topic, title: %{"this topic" -- has ``fancy stuff''}) }
- context 'title_fancy_entities disabled' do
+ context 'with title_fancy_entities disabled' do
before do
SiteSetting.title_fancy_entities = false
end
@@ -520,7 +517,7 @@ RSpec.describe Topic do
end
end
- context 'title_fancy_entities enabled' do
+ context 'with title_fancy_entities enabled' do
before do
SiteSetting.title_fancy_entities = true
end
@@ -551,7 +548,7 @@ RSpec.describe Topic do
expect(topic.fancy_title).to eq(long_title)
end
- context 'readonly mode' do
+ context 'when in readonly mode' do
before do
Discourse.enable_readonly_mode
end
@@ -574,10 +571,10 @@ RSpec.describe Topic do
end
end
- context 'category validation' do
+ describe 'category validation' do
fab!(:category) { Fabricate(:category_with_definition) }
- context 'allow_uncategorized_topics is false' do
+ context 'when allow_uncategorized_topics is false' do
before do
SiteSetting.allow_uncategorized_topics = false
end
@@ -598,7 +595,7 @@ RSpec.describe Topic do
end
end
- context 'allow_uncategorized_topics is true' do
+ context 'when allow_uncategorized_topics is true' do
before do
SiteSetting.allow_uncategorized_topics = true
end
@@ -688,7 +685,7 @@ RSpec.describe Topic do
expect(topics).to eq([])
end
- context "secure categories" do
+ context "with secure categories" do
before do
category.update!(read_restricted: true)
topic.update!(category: category)
@@ -703,12 +700,10 @@ RSpec.describe Topic do
expect(Topic.similar_to("has evil trout made any topics?", "i am wondering has evil trout made any topics?", user)).to include(topic)
end
end
-
end
-
end
- context 'post_numbers' do
+ describe 'post_numbers' do
let!(:topic) { Fabricate(:topic) }
let!(:p1) { Fabricate(:post, topic: topic, user: topic.user) }
let!(:p2) { Fabricate(:post, topic: topic, user: topic.user) }
@@ -726,7 +721,7 @@ RSpec.describe Topic do
describe '#invite' do
fab!(:topic) { Fabricate(:topic, user: user) }
- context 'rate limits' do
+ context 'with rate limits' do
before do
SiteSetting.max_topic_invitations_per_day = 1
RateLimiter.enable
@@ -809,7 +804,7 @@ RSpec.describe Topic do
.and not_change { Post.where(post_type: Post.types[:small_action]).count }
end
- context "from a muted user" do
+ context "when from a muted user" do
before { Fabricate(:muted_user, user: user1, muted_user: user) }
it 'fails with an error' do
@@ -821,7 +816,7 @@ RSpec.describe Topic do
end
end
- context "from a ignored user" do
+ context "when from a ignored user" do
before { Fabricate(:ignored_user, user: user1, ignored_user: user) }
it 'fails with an error' do
@@ -1028,7 +1023,7 @@ RSpec.describe Topic do
end
end
- context 'private message' do
+ describe 'private message' do
fab!(:topic) do
PostCreator.new(
Fabricate(:user),
@@ -1047,11 +1042,9 @@ RSpec.describe Topic do
expect(TopicQuery.new(evil_trout).list_latest.topics).not_to include(topic)
end
- context 'invite' do
-
- context 'existing user' do
-
- context 'by group name' do
+ context 'with invite' do
+ context 'with existing user' do
+ context 'when using group name' do
it 'can add admin to allowed groups' do
admins = Group[:admins]
admins.update!(messageable_level: Group::ALIAS_LEVELS[:everyone])
@@ -1169,7 +1162,7 @@ RSpec.describe Topic do
end
end
- context "user actions" do
+ context "with user actions" do
it "should set up actions correctly" do
UserActionManager.enable
@@ -1185,7 +1178,7 @@ RSpec.describe Topic do
end
- context 'bumping topics' do
+ describe 'bumping topics' do
let!(:topic) { Fabricate(:topic, bumped_at: 1.year.ago) }
it 'updates the bumped_at field when a new post is made' do
@@ -1196,7 +1189,7 @@ RSpec.describe Topic do
}.to change(topic, :bumped_at)
end
- context 'editing posts' do
+ context 'when editing posts' do
before do
@earlier_post = Fabricate(:post, topic: topic, user: topic.user)
@last_post = Fabricate(:post, topic: topic, user: topic.user)
@@ -1234,7 +1227,7 @@ RSpec.describe Topic do
end
end
- context 'moderator posts' do
+ describe 'moderator posts' do
fab!(:topic) { Fabricate(:topic) }
it 'creates a moderator post' do
@@ -1267,7 +1260,7 @@ RSpec.describe Topic do
end
end
- context 'update_status' do
+ describe 'update_status' do
fab!(:post) do
Fabricate(:post).tap { |p| p.topic.update!(bumped_at: 1.hour.ago) }
end
@@ -1280,10 +1273,10 @@ RSpec.describe Topic do
@user.admin = true
end
- context 'visibility' do
+ context 'with visibility' do
let(:category) { Fabricate(:category_with_definition) }
- context 'disable' do
+ context 'when disabled' do
it 'should not be visible and have correct counts' do
topic.update_status('visible', false, @user)
topic.reload
@@ -1316,7 +1309,7 @@ RSpec.describe Topic do
end
end
- context 'enable' do
+ context 'when enabled' do
before do
topic.update_status('visible', false, @user)
topic.reload
@@ -1346,8 +1339,8 @@ RSpec.describe Topic do
end
end
- context 'pinned' do
- context 'disable' do
+ context 'with pinned' do
+ context 'when disabled' do
before do
topic.update_status('pinned', false, @user)
topic.reload
@@ -1360,7 +1353,7 @@ RSpec.describe Topic do
end
end
- context 'enable' do
+ context 'when enabled' do
before do
topic.update_attribute :pinned_at, nil
topic.update_status('pinned', true, @user)
@@ -1376,12 +1369,12 @@ RSpec.describe Topic do
end
end
- context 'archived' do
+ context 'with archived' do
it 'should create a staff action log entry' do
expect { topic.update_status('archived', true, @user) }.to change { UserHistory.where(action: UserHistory.actions[:topic_archived]).count }.by(1)
end
- context 'disable' do
+ context 'when disabled' do
before do
@archived_topic = Fabricate(:topic, archived: true, bumped_at: 1.hour.ago)
@original_bumped_at = @archived_topic.bumped_at
@@ -1396,7 +1389,7 @@ RSpec.describe Topic do
end
end
- context 'enable' do
+ context 'when enabled' do
before do
topic.update_attribute :archived, false
topic.update_status('archived', true, @user)
@@ -1412,7 +1405,7 @@ RSpec.describe Topic do
end
shared_examples_for 'a status that closes a topic' do
- context 'disable' do
+ context 'when disabled' do
before do
@closed_topic = Fabricate(:topic, closed: true, bumped_at: 1.hour.ago)
@original_bumped_at = @closed_topic.bumped_at
@@ -1427,7 +1420,7 @@ RSpec.describe Topic do
end
end
- context 'enable' do
+ context 'when enabled' do
before do
topic.update_attribute :closed, false
topic.update_status(status, true, @user)
@@ -1443,7 +1436,7 @@ RSpec.describe Topic do
end
end
- context 'closed' do
+ context 'when closed' do
let(:status) { 'closed' }
it_behaves_like 'a status that closes a topic'
@@ -1459,11 +1452,11 @@ RSpec.describe Topic do
end
end
- context 'autoclosed' do
+ context 'when autoclosed' do
let(:status) { 'autoclosed' }
it_behaves_like 'a status that closes a topic'
- context 'topic was set to close when it was created' do
+ context 'when topic was set to close when it was created' do
it 'includes the autoclose duration in the moderator post' do
freeze_time(Time.new(2000, 1, 1))
topic.created_at = 3.days.ago
@@ -1472,7 +1465,7 @@ RSpec.describe Topic do
end
end
- context 'topic was set to close after it was created' do
+ context 'when topic was set to close after it was created' do
it 'includes the autoclose duration in the moderator post' do
freeze_time(Time.new(2000, 1, 1))
@@ -1493,7 +1486,6 @@ RSpec.describe Topic do
end
describe "banner" do
-
fab!(:topic) { Fabricate(:topic) }
fab!(:user) { topic.user }
let(:banner) { { html: "<p>BANNER</p>", url: topic.url, key: topic.id } }
@@ -1528,11 +1520,9 @@ RSpec.describe Topic do
user.user_profile.reload
expect(user.user_profile.dismissed_banner_key).to be_nil
end
-
end
describe "remove_banner!" do
-
it "resets the topic archetype" do
topic.expects(:add_moderator_post)
@@ -1544,11 +1534,9 @@ RSpec.describe Topic do
expect(message.channel).to eq("/site/banner")
expect(message.data).to eq(nil)
end
-
end
- context "bannered_until date" do
-
+ context "with bannered_until date" do
it 'sets bannered_until to be caught by ensure_consistency' do
bannered_until = 5.days.from_now
topic.make_banner!(user, bannered_until.to_s)
@@ -1567,8 +1555,7 @@ RSpec.describe Topic do
end
- context 'last_poster info' do
-
+ context 'with last_poster info' do
before do
@post = create_post
@user = @post.user
@@ -1592,12 +1579,10 @@ RSpec.describe Topic do
topic_user = @second_user.topic_users.find_by(topic_id: @topic.id)
expect(topic_user.posted?).to eq(true)
end
-
end
end
describe 'with category' do
-
before do
@category = Fabricate(:category_with_definition)
end
@@ -1618,9 +1603,8 @@ RSpec.describe Topic do
expect(topic.meta_data['hello']).to eq('world')
end
- context 'updating' do
-
- context 'existing key' do
+ context 'when updating' do
+ context 'with existing key' do
before do
topic.update_meta_data('hello' => 'bane')
end
@@ -1630,7 +1614,7 @@ RSpec.describe Topic do
end
end
- context 'new key' do
+ context 'with a new key' do
before do
topic.update_meta_data('city' => 'gotham')
end
@@ -1639,10 +1623,9 @@ RSpec.describe Topic do
expect(topic.meta_data['city']).to eq('gotham')
expect(topic.meta_data['hello']).to eq('world')
end
-
end
- context 'new key' do
+ context 'with a new key' do
before_all do
topic.update_meta_data('other' => 'key')
topic.save!
@@ -1656,13 +1639,10 @@ RSpec.describe Topic do
expect(Topic.find(topic.id).custom_fields["other"]).to eq("key")
end
end
-
end
-
end
describe 'after create' do
-
fab!(:topic) { Fabricate(:topic) }
it 'is a regular topic by default' do
@@ -1675,7 +1655,7 @@ RSpec.describe Topic do
expect(topic.moderator_posts_count).to eq(0)
end
- context 'post' do
+ context 'with post' do
let(:post) { Fabricate(:post, topic: topic, user: topic.user) }
it 'has the same archetype as the topic' do
@@ -1743,7 +1723,6 @@ RSpec.describe Topic do
end
describe 'user that is watching the new category' do
-
before do
Jobs.run_immediately!
@@ -1901,9 +1880,7 @@ RSpec.describe Topic do
expect(category.topic_count).to eq(0)
end
end
-
end
-
end
describe 'scopes' do
@@ -2117,7 +2094,7 @@ RSpec.describe Topic do
end
describe '.for_digest' do
- context "no edit grace period" do
+ context "with no edit grace period" do
before do
SiteSetting.editing_grace_period = 0
end
@@ -2367,7 +2344,7 @@ RSpec.describe Topic do
end
describe 'trash!' do
- context "its category's topic count" do
+ context "with category's topic count" do
fab!(:category) { Fabricate(:category_with_definition) }
it "subtracts 1 if topic is being deleted" do
@@ -2397,7 +2374,7 @@ RSpec.describe Topic do
end
describe 'recover!' do
- context "its category's topic count" do
+ context "with category's topic count" do
fab!(:category) { Fabricate(:category_with_definition) }
it "adds 1 if topic is deleted" do
@@ -2426,7 +2403,7 @@ RSpec.describe Topic do
end
end
- context "new user limits" do
+ describe "new user limits" do
before do
SiteSetting.max_topics_in_first_day = 1
SiteSetting.max_replies_in_first_day = 1
@@ -2475,7 +2452,7 @@ RSpec.describe Topic do
end
end
- context "per day personal message limit" do
+ describe "per day personal message limit" do
before do
SiteSetting.max_personal_messages_per_day = 1
SiteSetting.max_topics_per_day = 0
@@ -2624,7 +2601,7 @@ RSpec.describe Topic do
expect(topic.last_posted_at).to eq_time(post1.created_at)
end
- context 'featured link' do
+ describe 'featured link' do
before { SiteSetting.topic_featured_link_enabled = true }
fab!(:topic) { Fabricate(:topic) }
@@ -3114,5 +3091,4 @@ RSpec.describe Topic do
end
end
end
-
end
diff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rb
index 72b49cfacd0..9154166b229 100644
--- a/spec/models/topic_timer_spec.rb
+++ b/spec/models/topic_timer_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe TopicTimer, type: :model do
before { freeze_time }
- context "validations" do
+ describe "Validations" do
describe "pending_timers scope" do
it "does not return deleted timers" do
topic_timer.trash!
@@ -36,6 +36,7 @@ RSpec.describe TopicTimer, type: :model do
end
end
end
+
describe '#status_type' do
it 'should ensure that only one active public topic status update exists' do
topic_timer.update!(topic: topic)
@@ -102,7 +103,7 @@ RSpec.describe TopicTimer, type: :model do
end
end
- context 'callbacks' do
+ describe 'Callbacks' do
describe 'when #execute_at and #user_id are not changed' do
it 'should not schedule another to update topic' do
Jobs.expects(:enqueue_at).never
diff --git a/spec/models/topic_tracking_state_spec.rb b/spec/models/topic_tracking_state_spec.rb
index 960ab7b8d6b..1aeb673ee57 100644
--- a/spec/models/topic_tracking_state_spec.rb
+++ b/spec/models/topic_tracking_state_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe TopicTrackingState do
-
fab!(:user) { Fabricate(:user) }
fab!(:whisperers_group) { Fabricate(:group) }
@@ -459,7 +458,7 @@ RSpec.describe TopicTrackingState do
expect(report.length).to eq(1)
end
- context 'muted tags' do
+ describe 'muted tags' do
it "remove_muted_tags_from_latest is set to always" do
SiteSetting.remove_muted_tags_from_latest = 'always'
tag1 = Fabricate(:tag)
@@ -580,7 +579,7 @@ RSpec.describe TopicTrackingState do
end
- context "tag support" do
+ describe "tag support" do
before do
SiteSetting.tagging_enabled = true
diff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rb
index da4e4f0077f..b61e0eedb3b 100644
--- a/spec/models/topic_user_spec.rb
+++ b/spec/models/topic_user_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe TopicUser do
end
describe '#notification_levels' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@notification_levels = TopicUser.notification_levels
end
@@ -55,7 +55,7 @@ RSpec.describe TopicUser do
end
describe '#notification_reasons' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@notification_reasons = TopicUser.notification_reasons
end
@@ -97,12 +97,10 @@ RSpec.describe TopicUser do
end
describe "unpinned" do
-
it "defaults to blank" do
ensure_topic_user
expect(topic_user.cleared_pinned_at).to be_blank
end
-
end
describe 'notifications' do
@@ -171,7 +169,6 @@ RSpec.describe TopicUser do
end
describe 'visited at' do
-
it 'set upon initial visit' do
freeze_time yesterday
@@ -193,14 +190,11 @@ RSpec.describe TopicUser do
topic_user = TopicUser.get(topic, user)
expect(topic_user.first_visited_at.to_i).to eq(yesterday.to_i)
expect(topic_user.last_visited_at.to_i).to eq(Time.zone.now.to_i)
-
end
end
describe 'read tracking' do
-
context "without auto tracking" do
-
let(:topic_user) { TopicUser.get(topic, user) }
it 'should create a new record for a visit' do
@@ -240,7 +234,7 @@ RSpec.describe TopicUser do
end
end
- context 'private messages' do
+ context 'with private messages' do
fab!(:target_user) { Fabricate(:user) }
let(:post) do
@@ -316,8 +310,7 @@ RSpec.describe TopicUser do
end
end
- context 'auto tracking' do
-
+ context 'with auto tracking' do
let(:post_creator) { PostCreator.new(new_user, raw: Fabricate.build(:post).raw, topic_id: topic.id) }
before do
@@ -410,7 +403,6 @@ RSpec.describe TopicUser do
end
describe 'change a flag' do
-
it "only inserts a row once, even on repeated calls" do
topic; user
@@ -434,9 +426,7 @@ RSpec.describe TopicUser do
it 'has a key in the lookup for this forum topic' do
expect(TopicUser.lookup_for(user, [topic]).has_key?(topic.id)).to eq(true)
end
-
end
-
end
it "can scope by tracking" do
@@ -468,7 +458,6 @@ RSpec.describe TopicUser do
end
describe "mailing_list_mode" do
-
it "will receive email notification for every topic" do
user1 = Fabricate(:user)
diff --git a/spec/models/translation_override_spec.rb b/spec/models/translation_override_spec.rb
index fce0f7b307d..a715fe9aa64 100644
--- a/spec/models/translation_override_spec.rb
+++ b/spec/models/translation_override_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe TranslationOverride do
- context 'validations' do
+ describe 'Validations' do
describe '#value' do
before do
I18n.backend.store_translations(
@@ -132,7 +132,7 @@ RSpec.describe TranslationOverride do
expect(ovr.compiled_js).to_not match(/Invalid Format/i)
end
- context "site cache" do
+ describe "site cache" do
def cached_value(guardian, translation_key, locale:)
types_name, name_key, attribute = translation_key.split('.')
@@ -171,19 +171,19 @@ RSpec.describe TranslationOverride do
end
end
- context "post_action_types" do
+ context "with post_action_types" do
let(:translation_keys) { ['post_action_types.off_topic.description'] }
include_examples "resets site text"
end
- context "topic_flag_types" do
+ context "with topic_flag_types" do
let(:translation_keys) { ['topic_flag_types.spam.description'] }
include_examples "resets site text"
end
- context "multiple keys" do
+ context "with multiple keys" do
let(:translation_keys) { ['post_action_types.off_topic.description', 'topic_flag_types.spam.description'] }
include_examples "resets site text"
diff --git a/spec/models/trust_level3_requirements_spec.rb b/spec/models/trust_level3_requirements_spec.rb
index bf38db8001e..9f8dfa3d150 100644
--- a/spec/models/trust_level3_requirements_spec.rb
+++ b/spec/models/trust_level3_requirements_spec.rb
@@ -448,8 +448,7 @@ RSpec.describe TrustLevel3Requirements do
end
end
- context "requirements with defaults" do
-
+ describe "requirements with defaults" do
before do
tl3_requirements.stubs(:min_days_visited).returns(50)
tl3_requirements.stubs(:min_topics_replied_to).returns(10)
diff --git a/spec/models/upload_reference_spec.rb b/spec/models/upload_reference_spec.rb
index ed63151ceb1..50a027a3f90 100644
--- a/spec/models/upload_reference_spec.rb
+++ b/spec/models/upload_reference_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe UploadReference do
- context 'badge uploads' do
+ describe 'badge uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload references' do
@@ -18,7 +18,7 @@ RSpec.describe UploadReference do
end
end
- context 'category uploads' do
+ describe 'category uploads' do
fab!(:upload1) { Fabricate(:upload) }
fab!(:upload2) { Fabricate(:upload) }
@@ -35,7 +35,7 @@ RSpec.describe UploadReference do
end
end
- context 'custom emoji uploads' do
+ describe 'custom emoji uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload references' do
@@ -51,7 +51,7 @@ RSpec.describe UploadReference do
end
end
- context 'group uploads' do
+ describe 'group uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload references' do
@@ -68,7 +68,7 @@ RSpec.describe UploadReference do
end
end
- context 'post uploads' do
+ describe 'post uploads' do
fab!(:upload) { Fabricate(:upload) }
fab!(:post) { Fabricate(:post, raw: "[](#{upload.short_url})") }
@@ -85,7 +85,7 @@ RSpec.describe UploadReference do
end
end
- context 'site setting uploads' do
+ describe 'site setting uploads' do
let(:provider) { SiteSettings::DbProvider.new(SiteSetting) }
fab!(:upload) { Fabricate(:upload) }
fab!(:upload2) { Fabricate(:upload) }
@@ -114,7 +114,7 @@ RSpec.describe UploadReference do
end
end
- context 'theme field uploads' do
+ describe 'theme field uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload refererences' do
@@ -139,7 +139,7 @@ RSpec.describe UploadReference do
end
end
- context 'theme setting uploads' do
+ describe 'theme setting uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload refererences' do
@@ -162,7 +162,7 @@ RSpec.describe UploadReference do
end
end
- context 'user uploads' do
+ describe 'user uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload references' do
@@ -179,7 +179,7 @@ RSpec.describe UploadReference do
end
end
- context 'user avatar uploads' do
+ describe 'user avatar uploads' do
fab!(:upload1) { Fabricate(:upload) }
fab!(:upload2) { Fabricate(:upload) }
@@ -196,7 +196,7 @@ RSpec.describe UploadReference do
end
end
- context 'user export uploads' do
+ describe 'user export uploads' do
fab!(:upload) { Fabricate(:upload) }
it 'creates upload references' do
@@ -219,7 +219,7 @@ RSpec.describe UploadReference do
end
end
- context 'user profile uploads' do
+ describe 'user profile uploads' do
fab!(:user) { Fabricate(:user) }
fab!(:upload1) { Fabricate(:upload) }
fab!(:upload2) { Fabricate(:upload) }
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index e62336f6c36..ac0464254fe 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -392,7 +392,7 @@ RSpec.describe Upload do
expect(upload.secure).to eq(false)
end
- context "local attachment" do
+ context "with local attachment" do
before do
SiteSetting.authorized_extensions = "pdf"
end
@@ -428,7 +428,7 @@ RSpec.describe Upload do
expect(upload.secure).to eq(false)
end
- context "secure media enabled" do
+ context "with secure media enabled" do
before do
enable_secure_media
end
diff --git a/spec/models/user_action_spec.rb b/spec/models/user_action_spec.rb
index e3e9d91a503..d47309c01a4 100644
--- a/spec/models/user_action_spec.rb
+++ b/spec/models/user_action_spec.rb
@@ -162,7 +162,6 @@ RSpec.describe UserAction do
end
describe 'when user likes' do
-
fab!(:post) { Fabricate(:post) }
let(:likee) { post.user }
fab!(:liker) { coding_horror }
@@ -180,7 +179,7 @@ RSpec.describe UserAction do
expect(likee_stream.count).to eq(@old_count + 1)
end
- context "successful like" do
+ context "with successful like" do
before do
PostActionCreator.like(liker, post)
@liker_action = liker.user_actions.find_by(action_type: UserAction::LIKE)
@@ -198,7 +197,7 @@ RSpec.describe UserAction do
expect(liker.user_stat.reload.likes_given).to eq(0)
end
- context 'private message' do
+ context 'with private message' do
fab!(:post) { Fabricate(:private_message_post) }
let(:likee) { post.topic.topic_allowed_users.first.user }
let(:liker) { post.topic.topic_allowed_users.last.user }
@@ -217,8 +216,7 @@ RSpec.describe UserAction do
end
- context "liking a private message" do
-
+ context "when liking a private message" do
before do
post.topic.update_columns(category_id: nil, archetype: Archetype::private_message)
end
diff --git a/spec/models/user_auth_token_spec.rb b/spec/models/user_auth_token_spec.rb
index 8a2f6a33c09..d5f0d1bd575 100644
--- a/spec/models/user_auth_token_spec.rb
+++ b/spec/models/user_auth_token_spec.rb
@@ -6,7 +6,6 @@ RSpec.describe UserAuthToken do
fab!(:user) { Fabricate(:user) }
it "can remove old expired tokens" do
-
SiteSetting.verbose_auth_token_logging = true
freeze_time Time.zone.now
@@ -265,7 +264,7 @@ RSpec.describe UserAuthToken do
expect(lookup.auth_token_seen).to eq(true)
end
- context "suspicious login" do
+ context "with suspicious login" do
fab!(:admin) { Fabricate(:admin) }
it "is not checked when generated for non-staff" do
@@ -285,7 +284,5 @@ RSpec.describe UserAuthToken do
expect(Jobs::SuspiciousLogin.jobs.size).to eq(0)
end
-
end
-
end
diff --git a/spec/models/user_badge_spec.rb b/spec/models/user_badge_spec.rb
index 1b6c4096416..dd7b6ecb059 100644
--- a/spec/models/user_badge_spec.rb
+++ b/spec/models/user_badge_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe UserBadge do
fab!(:badge) { Fabricate(:badge) }
fab!(:user) { Fabricate(:user) }
- context 'validations' do
+ describe 'Validations' do
let(:subject) { BadgeGranter.grant(badge, user) }
it { is_expected.to validate_presence_of(:badge_id) }
diff --git a/spec/models/user_email_spec.rb b/spec/models/user_email_spec.rb
index 4a5e22818dc..d60219c1b5b 100644
--- a/spec/models/user_email_spec.rb
+++ b/spec/models/user_email_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe UserEmail do
fab!(:user) { Fabricate(:user) }
- context "validation" do
+ describe "Validations" do
it "allows only one primary email" do
expect {
Fabricate(:secondary_email, user: user, primary: true)
@@ -50,7 +50,7 @@ RSpec.describe UserEmail do
end
end
- context "indexes" do
+ describe "Indexes" do
it "allows only one primary email" do
expect {
Fabricate.build(:secondary_email, user: user, primary: true).save(validate: false)
diff --git a/spec/models/user_history_spec.rb b/spec/models/user_history_spec.rb
index ff8215008e8..5dc7c024753 100644
--- a/spec/models/user_history_spec.rb
+++ b/spec/models/user_history_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe UserHistory do
-
describe '#actions' do
- context "verify enum sequence" do
+ context "when verifying enum sequence" do
before do
@actions = UserHistory.actions
end
diff --git a/spec/models/user_option_spec.rb b/spec/models/user_option_spec.rb
index 406bacb352d..36193aba7a0 100644
--- a/spec/models/user_option_spec.rb
+++ b/spec/models/user_option_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe UserOption do
-
describe "#ensure_consistency!" do
it "recreates missing user option records" do
user = Fabricate(:user)
@@ -104,7 +103,7 @@ RSpec.describe UserOption do
expect(user.user_option.redirected_to_top).to eq(nil)
end
- context "and when top is in the `SiteSetting.top_menu`" 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
@@ -112,8 +111,7 @@ RSpec.describe UserOption do
expect(user.user_option.redirected_to_top).to eq(nil)
end
- context "and there are enough topics" do
-
+ context "when there are enough topics" do
before { SiteSetting.expects(:min_redirected_to_top_period).returns(:monthly) }
describe "a new user" do
@@ -154,21 +152,16 @@ RSpec.describe UserOption do
expect(user.user_option.redirected_to_top).to eq(reason: I18n.t('redirected_to_top_reasons.not_seen_in_a_month'),
period: :monthly)
end
-
end
-
end
-
end
-
end
-
end
describe '.user_tzinfo' do
fab!(:user) { Fabricate(:user) }
- context 'user with valid timezone given' do
+ context 'with user with valid timezone given' do
before do
user.user_option.update(timezone: 'Europe/Paris')
end
@@ -178,7 +171,7 @@ RSpec.describe UserOption do
end
end
- context 'user with invalid timezone given' do
+ context 'with user with invalid timezone given' do
before do
user.user_option.update(timezone: 'Catopia/Catcity')
end
diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb
index 01bd4677115..5213371d762 100644
--- a/spec/models/user_profile_spec.rb
+++ b/spec/models/user_profile_spec.rb
@@ -105,7 +105,7 @@ RSpec.describe UserProfile do
expect(user_profile).not_to be_valid
end
- context "website validation" do
+ context "with website validation" do
let(:user_profile) { Fabricate.build(:user_profile, user: Fabricate(:user)) }
it "should not allow invalid URLs" do
@@ -222,7 +222,7 @@ RSpec.describe UserProfile do
expect(user_profile.bio_processed).to eq("<p>I love http://discourse.org</p>")
end
- context 'tl3_links_no_follow is false' do
+ context 'when tl3_links_no_follow is false' do
before { SiteSetting.tl3_links_no_follow = false }
it 'includes the link without nofollow if the user is trust level 3 or higher' do
@@ -248,7 +248,7 @@ RSpec.describe UserProfile do
end
end
- context 'tl3_links_no_follow is true' do
+ context 'when tl3_links_no_follow is true' do
before { SiteSetting.tl3_links_no_follow = true }
it 'includes the link with nofollow if the user is trust level 3 or higher' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index e2c00facf33..95de72a0a83 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe User do
it { is_expected.to have_many(:pending_posts).class_name('ReviewableQueuedPost').with_foreign_key(:created_by_id) }
- context 'associations' do
+ describe 'Associations' do
it 'should delete sidebar_section_links when a user is destroyed' do
Fabricate(:category_sidebar_section_link, user: user)
Fabricate(:tag_sidebar_section_link, user: user)
@@ -20,7 +20,7 @@ RSpec.describe User do
end
end
- context 'validations' do
+ describe 'Validations' do
describe '#username' do
it { is_expected.to validate_presence_of :username }
@@ -309,7 +309,7 @@ RSpec.describe User do
end
end
- context 'enqueue_staff_welcome_message' do
+ describe 'enqueue_staff_welcome_message' do
fab!(:first_admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }
@@ -465,7 +465,7 @@ RSpec.describe User do
expect(event[:params].first).to eq(subject)
end
- context 'after_save' do
+ context 'with after_save' do
before { subject.save! }
it "has correct settings" do
@@ -1157,7 +1157,7 @@ RSpec.describe User do
expect(user.user_visits.first.visited_at).to eq_time(date.to_date)
end
- context "called twice" do
+ context "when called twice" do
it "doesn't increase days_visited twice" do
freeze_time
user.update_last_seen!
@@ -2091,7 +2091,7 @@ RSpec.describe User do
expect(Fabricate(:user, silenced_till: 1.month.from_now)).to be_silenced
end
- context "finders" do
+ context "with finders" do
let!(:user0) { Fabricate(:user, silenced_till: 1.month.ago) }
let!(:user1) { Fabricate(:user, silenced_till: 1.month.from_now) }
@@ -2429,7 +2429,7 @@ RSpec.describe User do
describe 'check_site_contact_username' do
before { SiteSetting.site_contact_username = contact_user.username }
- context 'admin' do
+ context 'when admin' do
let(:contact_user) { Fabricate(:admin) }
it 'clears site_contact_username site setting when admin privilege is revoked' do
@@ -2438,7 +2438,7 @@ RSpec.describe User do
end
end
- context 'moderator' do
+ context 'when moderator' do
let(:contact_user) { Fabricate(:moderator) }
it 'clears site_contact_username site setting when moderator privilege is revoked' do
@@ -2447,7 +2447,7 @@ RSpec.describe User do
end
end
- context 'admin and moderator' do
+ context 'when admin and moderator' do
let(:contact_user) { Fabricate(:moderator, admin: true) }
it 'does not change site_contact_username site setting when admin privilege is revoked' do
@@ -2493,7 +2493,7 @@ RSpec.describe User do
end
end
- context "human?" do
+ describe "#human?" do
it "returns true for a regular user" do
expect(Fabricate(:user)).to be_human
end
@@ -2503,7 +2503,7 @@ RSpec.describe User do
end
end
- context "Unicode username" do
+ describe "Unicode username" do
before { SiteSetting.unicode_usernames = true }
let(:user) { Fabricate(:user, username: "Lo\u0308we") } # NFD
diff --git a/spec/models/user_stat_spec.rb b/spec/models/user_stat_spec.rb
index cbb7df41071..2c7ae6f2ccb 100644
--- a/spec/models/user_stat_spec.rb
+++ b/spec/models/user_stat_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe UserStat do
-
it "is created automatically when a user is created" do
user = Fabricate(:evil_trout)
expect(user.user_stat).to be_present
@@ -11,11 +10,10 @@ RSpec.describe UserStat do
end
describe '#update_view_counts' do
-
let(:user) { Fabricate(:user) }
let(:stat) { user.user_stat }
- context 'topics_entered' do
+ context 'with topics_entered' do
context 'without any views' do
it "doesn't increase the user's topics_entered" do
expect { UserStat.update_view_counts; stat.reload }.not_to change(stat, :topics_entered)
@@ -42,11 +40,10 @@ RSpec.describe UserStat do
stat.reload
expect(stat.topics_entered).to eq(1)
end
-
end
end
- context 'posts_read_count' do
+ context 'with posts_read_count' do
context 'without any post timings' do
it "doesn't increase the user's posts_read_count" do
expect { UserStat.update_view_counts; stat.reload }.not_to change(stat, :posts_read_count)
diff --git a/spec/models/username_validator_spec.rb b/spec/models/username_validator_spec.rb
index e9a0f4a077a..b96a0a8f296 100644
--- a/spec/models/username_validator_spec.rb
+++ b/spec/models/username_validator_spec.rb
@@ -106,11 +106,11 @@ RSpec.describe UsernameValidator do
context 'when Unicode usernames are enabled' do
before { SiteSetting.unicode_usernames = true }
- context "ASCII usernames" do
+ context "with ASCII usernames" do
include_examples 'ASCII username'
end
- context "Unicode usernames" do
+ context "with Unicode usernames" do
before { SiteSetting.min_username_length = 1 }
it 'is invalid when the username is too short' do
diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb
index 387a782f366..bd8743ee64f 100644
--- a/spec/models/web_hook_spec.rb
+++ b/spec/models/web_hook_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe WebHook do
end
end
- context 'web hooks' do
+ context 'with web hooks' do
fab!(:post_hook) { Fabricate(:web_hook, payload_url: " https://example.com ") }
fab!(:topic_hook) { Fabricate(:topic_web_hook) }
@@ -107,7 +107,7 @@ RSpec.describe WebHook do
expect(job_args["payload"]).to eq(payload)
end
- context 'includes wildcard hooks' do
+ context 'when including wildcard hooks' do
fab!(:wildcard_hook) { Fabricate(:wildcard_web_hook) }
describe '#enqueue_hooks' do
@@ -588,7 +588,7 @@ RSpec.describe WebHook do
expect(payload["user_id"]).to eq(user.id)
end
- context 'user promoted hooks' do
+ context 'with user promoted hooks' do
fab!(:user_promoted_web_hook) { Fabricate(:user_promoted_web_hook) }
fab!(:another_user) { Fabricate(:user, trust_level: 2) }
@@ -608,7 +608,7 @@ RSpec.describe WebHook do
end
end
- context 'like created hooks' do
+ context 'with like created hooks' do
fab!(:like_web_hook) { Fabricate(:like_web_hook) }
fab!(:another_user) { Fabricate(:user) }
diff --git a/spec/multisite/request_tracker_spec.rb b/spec/multisite/request_tracker_spec.rb
index 947d9706bc0..82d35592cd6 100644
--- a/spec/multisite/request_tracker_spec.rb
+++ b/spec/multisite/request_tracker_spec.rb
@@ -110,7 +110,7 @@ RSpec.describe "RequestTracker in multisite", type: :multisite do
end
end
- context "10 seconds limiter" do
+ context "with a 10 seconds limiter" do
before do
global_setting :max_reqs_per_ip_per_10_seconds, 1
end
@@ -119,7 +119,7 @@ RSpec.describe "RequestTracker in multisite", type: :multisite do
include_examples "user id rate limiters behavior", "id_10_secs_limit"
end
- context "60 seconds limiter" do
+ context "with a 60 seconds limiter" do
before do
global_setting :max_reqs_per_ip_per_minute, 1
end
@@ -128,7 +128,7 @@ RSpec.describe "RequestTracker in multisite", type: :multisite do
include_examples "user id rate limiters behavior", "id_60_secs_limit"
end
- context "assets 10 seconds limiter" do
+ context "with assets 10 seconds limiter" do
before do
global_setting :max_asset_reqs_per_ip_per_10_seconds, 1
end
diff --git a/spec/multisite/s3_store_spec.rb b/spec/multisite/s3_store_spec.rb
index 24298024248..33c61ca72b7 100644
--- a/spec/multisite/s3_store_spec.rb
+++ b/spec/multisite/s3_store_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
Fabricate.build(:upload, sha1: upload_sha1, id: 1, original_filename: original_filename)
end
- context 'uploading to s3' do
+ describe 'uploading to s3' do
before(:each) do
setup_s3
end
@@ -92,7 +92,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
end
end
- context 'removal from s3' do
+ describe 'removal from s3' do
before do
setup_s3
end
@@ -172,7 +172,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
end
end
- context 'secure uploads' do
+ describe 'secure uploads' do
let(:store) { FileStore::S3Store.new }
let(:client) { Aws::S3::Client.new(stub_responses: true) }
let(:resource) { Aws::S3::Resource.new(client: client) }
diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb
index 8a6733e33cd..7ddfd84d8bb 100644
--- a/spec/requests/about_controller_spec.rb
+++ b/spec/requests/about_controller_spec.rb
@@ -1,9 +1,7 @@
# frozen_string_literal: true
RSpec.describe AboutController do
-
- describe '.index' do
-
+ describe '#index' do
it "should display the about page for anonymous user when login_required is false" do
SiteSetting.login_required = false
get "/about"
@@ -27,7 +25,7 @@ RSpec.describe AboutController do
expect(response.status).to eq(200)
end
- context "crawler view" do
+ context "with crawler view" do
it "should include correct title" do
get '/about', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
expect(response.status).to eq(200)
diff --git a/spec/requests/admin/backups_controller_spec.rb b/spec/requests/admin/backups_controller_spec.rb
index e84100492fd..f3cfdda31a0 100644
--- a/spec/requests/admin/backups_controller_spec.rb
+++ b/spec/requests/admin/backups_controller_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe Admin::BackupsController do
expect(response.status).to eq(403)
end
- context "html format" do
+ context "with html format" do
it "preloads important data" do
get "/admin/backups.html"
expect(response.status).to eq(200)
@@ -57,7 +57,7 @@ RSpec.describe Admin::BackupsController do
end
end
- context "json format" do
+ context "with json format" do
it "returns a list of all the backups" do
begin
create_backup_files(backup_filename, backup_filename2)
diff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rb
index a1a6bf7935a..93c872e9a80 100644
--- a/spec/requests/admin/dashboard_controller_spec.rb
+++ b/spec/requests/admin/dashboard_controller_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe Admin::DashboardController do
end
describe '#index' do
- context 'version checking is enabled' do
+ context 'when version checking is enabled' do
before do
SiteSetting.version_checks = true
end
@@ -40,7 +40,7 @@ RSpec.describe Admin::DashboardController do
end
end
- context 'version checking is disabled' do
+ context 'when version checking is disabled' do
before do
SiteSetting.version_checks = false
end
diff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rb
index 8778f8cc964..3801250af4f 100644
--- a/spec/requests/admin/email_controller_spec.rb
+++ b/spec/requests/admin/email_controller_spec.rb
@@ -289,7 +289,7 @@ RSpec.describe Admin::EmailController do
expect(json["errors"]).to include("Discourse::InvalidParameters")
end
- context 'bounced email log entry exists' do
+ context 'when bounced email log entry exists' do
fab!(:email_log) { Fabricate(:email_log, bounced: true, bounce_key: SecureRandom.hex) }
let(:error_message) { "Email::Receiver::BouncedEmailError" }
diff --git a/spec/requests/admin/groups_controller_spec.rb b/spec/requests/admin/groups_controller_spec.rb
index 653eda77099..7687f1767d7 100644
--- a/spec/requests/admin/groups_controller_spec.rb
+++ b/spec/requests/admin/groups_controller_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe Admin::GroupsController do
expect(group.members_visibility_level).to eq(Group.visibility_levels[:staff])
end
- context "custom_fields" do
+ context "with custom_fields" do
before do
plugin = Plugin::Instance.new
plugin.register_editable_group_custom_field :test
@@ -355,7 +355,7 @@ RSpec.describe Admin::GroupsController do
SiteSetting.moderators_manage_categories_and_groups = true
end
- context "the user is a moderator" do
+ context "when the user is a moderator" do
before do
user.update!(moderator: true)
sign_in(user)
@@ -404,7 +404,7 @@ RSpec.describe Admin::GroupsController do
end
end
- context "the user is not a moderator or admin" do
+ context "when the user is not a moderator or admin" do
before do
user.update!(moderator: false, admin: false)
sign_in(user)
diff --git a/spec/requests/admin/impersonate_controller_spec.rb b/spec/requests/admin/impersonate_controller_spec.rb
index 0724aa36230..a95527a4c1d 100644
--- a/spec/requests/admin/impersonate_controller_spec.rb
+++ b/spec/requests/admin/impersonate_controller_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe Admin::ImpersonateController do
expect(session[:current_user_id]).to eq(admin.id)
end
- context 'success' do
+ context 'with success' do
it "succeeds and logs the impersonation" do
expect do
post "/admin/impersonate.json", params: { username_or_email: user.username }
diff --git a/spec/requests/admin/reports_controller_spec.rb b/spec/requests/admin/reports_controller_spec.rb
index 4a36d9a46e1..a15f33929f0 100644
--- a/spec/requests/admin/reports_controller_spec.rb
+++ b/spec/requests/admin/reports_controller_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Admin::ReportsController do
end
describe '#bulk' do
- context "valid params" do
+ context "with valid params" do
it "renders the reports as JSON" do
Fabricate(:topic)
get "/admin/reports/bulk.json", params: {
@@ -29,8 +29,8 @@ RSpec.describe Admin::ReportsController do
end
end
- context "invalid params" do
- context "nonexistent report" do
+ context "with invalid params" do
+ context "with nonexistent report" do
it "returns not found reports" do
get "/admin/reports/bulk.json", params: {
reports: {
@@ -46,7 +46,7 @@ RSpec.describe Admin::ReportsController do
end
end
- context "invalid start or end dates" do
+ context "with invalid start or end dates" do
it "doesn't return 500 error" do
get "/admin/reports/bulk.json", params: {
reports: {
@@ -67,7 +67,7 @@ RSpec.describe Admin::ReportsController do
end
describe '#show' do
- context "invalid id form" do
+ context "with invalid id form" do
let(:invalid_id) { "!!&asdfasdf" }
it "returns 404" do
@@ -76,15 +76,15 @@ RSpec.describe Admin::ReportsController do
end
end
- context "valid type form" do
- context 'missing report' do
+ context "with valid type form" do
+ context 'with missing report' do
it "returns a 404 error" do
get "/admin/reports/nonexistent.json"
expect(response.status).to eq(404)
end
end
- context 'a report is found' do
+ context 'when a report is found' do
it "renders the report as JSON" do
Fabricate(:topic)
get "/admin/reports/topics.json"
diff --git a/spec/requests/admin/site_settings_controller_spec.rb b/spec/requests/admin/site_settings_controller_spec.rb
index 2efffcf5064..9759ac3045e 100644
--- a/spec/requests/admin/site_settings_controller_spec.rb
+++ b/spec/requests/admin/site_settings_controller_spec.rb
@@ -255,7 +255,7 @@ RSpec.describe Admin::SiteSettingsController do
SiteSetting.setting(:default_tags_watching, "")
end
- context "user options" do
+ context "with user options" do
def expect_user_count(site_setting_name:, user_setting_name:, current_site_setting_value:, new_site_setting_value:,
current_user_setting_value: nil, new_user_setting_value: nil)
diff --git a/spec/requests/admin/site_texts_controller_spec.rb b/spec/requests/admin/site_texts_controller_spec.rb
index 8bd843d9485..579e1c56752 100644
--- a/spec/requests/admin/site_texts_controller_spec.rb
+++ b/spec/requests/admin/site_texts_controller_spec.rb
@@ -164,7 +164,7 @@ RSpec.describe Admin::SiteTextsController do
expect(value).to eq('education.new-topic override')
end
- context 'plural keys' do
+ context 'with plural keys' do
before do
I18n.backend.store_translations(:en, colour: { one: '%{count} colour', other: '%{count} colours' })
end
@@ -191,21 +191,21 @@ RSpec.describe Admin::SiteTextsController do
end
end
- context 'English' do
+ context 'with English' do
let(:locale) { :en }
let(:expected_translations) { { one: '%{count} colour', other: '%{count} colours' } }
include_examples 'finds correct plural keys'
end
- context 'language with different plural keys and missing translations' do
+ context 'with language with different plural keys and missing translations' do
let(:locale) { :ru }
let(:expected_translations) { { one: '%{count} colour', few: '%{count} colours', other: '%{count} colours' } }
include_examples 'finds correct plural keys'
end
- context 'language with different plural keys and partial translation' do
+ context 'with language with different plural keys and partial translation' do
before do
I18n.backend.store_translations(:ru, colour: { few: '%{count} цвета', many: '%{count} цветов' })
end
@@ -321,7 +321,7 @@ RSpec.describe Admin::SiteTextsController do
expect(site_text['value']).to eq('education.new-topic override')
end
- context 'plural keys' do
+ context 'with plural keys' do
before do
I18n.backend.store_translations(:en, colour: { one: '%{count} colour', other: '%{count} colours' })
end
@@ -346,21 +346,21 @@ RSpec.describe Admin::SiteTextsController do
end
end
- context 'English' do
+ context 'with English' do
let(:locale) { :en }
let(:expected_translations) { { one: '%{count} colour', other: '%{count} colours' } }
include_examples 'has correct plural keys'
end
- context 'language with different plural keys and missing translations' do
+ context 'with language with different plural keys and missing translations' do
let(:locale) { :ru }
let(:expected_translations) { { one: '%{count} colour', few: '%{count} colours', other: '%{count} colours' } }
include_examples 'has correct plural keys'
end
- context 'language with different plural keys and partial translation' do
+ context 'with language with different plural keys and partial translation' do
before do
I18n.backend.store_translations(:ru, colour: { few: '%{count} цвета' })
end
@@ -551,7 +551,7 @@ RSpec.describe Admin::SiteTextsController do
end
end
- context "reseeding" do
+ context "when reseeding" do
before do
staff_category = Fabricate(
:category,
diff --git a/spec/requests/admin/staff_action_logs_controller_spec.rb b/spec/requests/admin/staff_action_logs_controller_spec.rb
index d0b679120d7..ea88562e81d 100644
--- a/spec/requests/admin/staff_action_logs_controller_spec.rb
+++ b/spec/requests/admin/staff_action_logs_controller_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Admin::StaffActionLogsController do
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 1")
end
- context 'When staff actions are extended' do
+ context 'when staff actions are extended' do
let(:plugin_extended_action) { :confirmed_ham }
before { UserHistory.stubs(:staff_actions).returns([plugin_extended_action]) }
after { UserHistory.unstub(:staff_actions) }
diff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rb
index 3e2cfc096e4..eb561f08bf1 100644
--- a/spec/requests/admin/users_controller_spec.rb
+++ b/spec/requests/admin/users_controller_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe Admin::UsersController do
end
describe '#show' do
- context 'an existing user' do
+ context 'with an existing user' do
it 'returns success' do
get "/admin/users/#{user.id}.json"
expect(response.status).to eq(200)
@@ -64,7 +64,7 @@ RSpec.describe Admin::UsersController do
end
end
- context 'a non-existing user' do
+ context 'with a non-existing user' do
it 'returns 404 error' do
get "/admin/users/0.json"
expect(response.status).to eq(404)
@@ -778,7 +778,7 @@ RSpec.describe Admin::UsersController do
expect(response.status).to eq(403)
end
- context "user has post" do
+ context "when user has post" do
let(:topic) { Fabricate(:topic, user: delete_me) }
let!(:post) { Fabricate(:post, topic: topic, user: delete_me) }
@@ -803,7 +803,7 @@ RSpec.describe Admin::UsersController do
expect(User.where(id: delete_me.id).count).to eq(0)
end
- context "user has reviewable flagged post which was handled" do
+ context "when user has reviewable flagged post which was handled" do
let!(:reviewable) { Fabricate(:reviewable_flagged_post, created_by: admin, target_created_by: delete_me, target: post, topic: topic, status: 4) }
it "deletes the user record" do
@@ -862,7 +862,7 @@ RSpec.describe Admin::UsersController do
expect(ScreenedIpAddress.exists?(ip_address: ip_address)).to eq(false)
end
- context "param block_url" do
+ context "with param block_url" do
before do
@post = Fabricate(:post_with_external_links, user: delete_me)
TopicLink.extract_from(@post)
@@ -1392,5 +1392,4 @@ RSpec.describe Admin::UsersController do
expect(sl.reload.ip_address).to eq('127.0.0.2')
end
end
-
end
diff --git a/spec/requests/admin/watched_words_controller_spec.rb b/spec/requests/admin/watched_words_controller_spec.rb
index d3037b9fae5..41f1c4bddc0 100644
--- a/spec/requests/admin/watched_words_controller_spec.rb
+++ b/spec/requests/admin/watched_words_controller_spec.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'csv'
+
RSpec.describe Admin::WatchedWordsController do
fab!(:admin) { Fabricate(:admin) }
@@ -27,7 +28,7 @@ RSpec.describe Admin::WatchedWordsController do
end
describe '#create' do
- context 'logged in as admin' do
+ context 'when logged in as admin' do
before do
sign_in(admin)
end
@@ -58,7 +59,7 @@ RSpec.describe Admin::WatchedWordsController do
end
describe '#upload' do
- context 'logged in as admin' do
+ context 'when logged in as admin' do
before do
sign_in(admin)
Fabricate(:tag, name: 'tag1')
@@ -119,14 +120,14 @@ RSpec.describe Admin::WatchedWordsController do
end
describe '#download' do
- context 'not logged in as admin' do
+ context 'when not logged in as admin' do
it "doesn't allow performing #download" do
get "/admin/customize/watched_words/action/block/download"
expect(response.status).to eq(404)
end
end
- context 'logged in as admin' do
+ context 'when logged in as admin' do
before do
sign_in(admin)
Fabricate(:tag, name: 'tag1')
@@ -163,7 +164,7 @@ RSpec.describe Admin::WatchedWordsController do
end
describe '#clear_all' do
- context 'non admins' do
+ context 'with non admins' do
it "doesn't allow them to perform #clear_all" do
word = Fabricate(:watched_word, action: WatchedWord.actions[:block])
delete "/admin/customize/watched_words/action/block"
@@ -172,7 +173,7 @@ RSpec.describe Admin::WatchedWordsController do
end
end
- context 'admins' do
+ context 'with admins' do
before do
sign_in(admin)
end
diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index 03e3f6c9fbd..c23aece7e98 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -733,7 +733,7 @@ RSpec.describe ApplicationController do
expect(response.headers['X-Robots-Tag']).to be_nil
end
- context "default locale" do
+ context "with default locale" do
before do
SiteSetting.default_locale = :fr
sign_in(Fabricate(:user))
@@ -793,8 +793,8 @@ RSpec.describe ApplicationController do
{ HTTP_ACCEPT_LANGUAGE: locale }
end
- context "allow_user_locale disabled" do
- context "accept-language header differs from default locale" do
+ context "with allow_user_locale disabled" do
+ context "when accept-language header differs from default locale" do
before do
SiteSetting.allow_user_locale = false
SiteSetting.default_locale = "en"
@@ -821,8 +821,8 @@ RSpec.describe ApplicationController do
end
end
- context "set_locale_from_accept_language_header enabled" do
- context "accept-language header differs from default locale" do
+ context "with set_locale_from_accept_language_header enabled" do
+ context "when accept-language header differs from default locale" do
before do
SiteSetting.allow_user_locale = true
SiteSetting.set_locale_from_accept_language_header = true
@@ -872,7 +872,7 @@ RSpec.describe ApplicationController do
end
end
- context "the preferred locale includes a region" do
+ context "when the preferred locale includes a region" do
it "returns the locale and region separated by an underscore" do
SiteSetting.allow_user_locale = true
SiteSetting.set_locale_from_accept_language_header = true
@@ -884,7 +884,7 @@ RSpec.describe ApplicationController do
end
end
- context 'accept-language header is not set' do
+ context 'when accept-language header is not set' do
it 'uses the site default locale' do
SiteSetting.allow_user_locale = true
SiteSetting.default_locale = 'en'
@@ -1048,7 +1048,7 @@ RSpec.describe ApplicationController do
admin # to skip welcome wizard at home page `/`
end
- context "login_required" do
+ context "with login_required" do
before do
SiteSetting.login_required = true
end
@@ -1072,7 +1072,7 @@ RSpec.describe ApplicationController do
end
end
- context "login not required" do
+ context "with login not required" do
before do
SiteSetting.login_required = false
end
diff --git a/spec/requests/badges_controller_spec.rb b/spec/requests/badges_controller_spec.rb
index 80859055655..19e59632de8 100644
--- a/spec/requests/badges_controller_spec.rb
+++ b/spec/requests/badges_controller_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe BadgesController do
SiteSetting.enable_badges = true
end
- context 'index' do
+ describe '#index' do
it 'should return a list of all badges' do
get "/badges.json"
@@ -19,7 +19,7 @@ RSpec.describe BadgesController do
end
end
- context 'show' do
+ describe '#show' do
it "should return a badge" do
get "/badges/#{badge.id}.json"
expect(response.status).to eq(200)
@@ -42,7 +42,7 @@ RSpec.describe BadgesController do
end
end
- context "user profiles" do
+ describe "user profiles" do
let(:titled_badge) { Fabricate(:badge, name: 'Protector of the Realm', allow_title: true) }
let!(:grant) { UserBadge.create!(user_id: user.id, badge_id: titled_badge.id, granted_at: 1.minute.ago, granted_by_id: -1) }
diff --git a/spec/requests/bootstrap_controller_spec.rb b/spec/requests/bootstrap_controller_spec.rb
index b2c658dba2d..31bb8b3a8b0 100644
--- a/spec/requests/bootstrap_controller_spec.rb
+++ b/spec/requests/bootstrap_controller_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe BootstrapController do
-
let(:theme) { Fabricate(:theme, enabled: true) }
before do
@@ -80,7 +79,7 @@ RSpec.describe BootstrapController do
expect(response.parsed_body).to be_present
end
- context "authentication data is present" do
+ context "when authentication data is present" do
it "returns authentication data" do
cookie_data = 'someauthenticationdata'
cookies['authentication_data'] = cookie_data
diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb
index 17cd298b804..3fa4a8d7435 100644
--- a/spec/requests/categories_controller_spec.rb
+++ b/spec/requests/categories_controller_spec.rb
@@ -5,8 +5,7 @@ RSpec.describe CategoriesController do
let!(:category) { Fabricate(:category, user: admin) }
fab!(:user) { Fabricate(:user) }
- context 'index' do
-
+ describe '#index' do
it 'web crawler view has correct urls for subfolder install' do
set_subfolder "/forum"
get '/categories', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
@@ -240,7 +239,7 @@ RSpec.describe CategoriesController do
end
end
- context 'extensibility event' do
+ describe 'extensibility event' do
before do
sign_in(admin)
end
diff --git a/spec/requests/directory_items_controller_spec.rb b/spec/requests/directory_items_controller_spec.rb
index a58f73da178..af9bc5caab2 100644
--- a/spec/requests/directory_items_controller_spec.rb
+++ b/spec/requests/directory_items_controller_spec.rb
@@ -18,8 +18,7 @@ RSpec.describe DirectoryItemsController do
end
context "without data" do
-
- context "and a logged in user" do
+ context "with a logged in user" do
before { sign_in(user) }
it "succeeds" do
diff --git a/spec/requests/email_controller_spec.rb b/spec/requests/email_controller_spec.rb
index f66ff9b249a..051573e3609 100644
--- a/spec/requests/email_controller_spec.rb
+++ b/spec/requests/email_controller_spec.rb
@@ -162,7 +162,7 @@ RSpec.describe EmailController do
fab!(:user) { Fabricate(:user) }
let(:unsubscribe_key) { UnsubscribeKey.create_key_for(user, key_type, post: post) }
- context 'Unsubscribe from digest' do
+ context 'when unsubscribing from digest' do
let(:key_type) { UnsubscribeKey::DIGEST_TYPE }
let(:post) { nil }
@@ -245,7 +245,7 @@ RSpec.describe EmailController do
end
end
- context 'Unsubscribe from a post' do
+ context 'when unsubscribing from a post' do
fab!(:post) { Fabricate(:post) }
let(:user) { post.user }
let(:key_type) { UnsubscribeKey::TOPIC_TYPE }
diff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rb
index 64618116489..a926d93164e 100644
--- a/spec/requests/embed_controller_spec.rb
+++ b/spec/requests/embed_controller_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe EmbedController do
-
let(:embed_url) { "http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
let(:embed_url_secure) { "https://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
let(:discourse_username) { "eviltrout" }
@@ -16,7 +15,7 @@ RSpec.describe EmbedController do
expect(response.body).to match(I18n.t('embed.error'))
end
- context "by topic id" do
+ describe "by topic id" do
let(:headers) { { 'REFERER' => 'http://eviltrout.com/some-page' } }
before do
@@ -39,7 +38,6 @@ RSpec.describe EmbedController do
end
context "with api key" do
-
let(:api_key) { Fabricate(:api_key) }
context "with valid embed url" do
@@ -205,7 +203,7 @@ RSpec.describe EmbedController do
expect(response.body).to include(".test-osama-15")
end
- context "success" do
+ context "with success" do
after do
expect(response.status).to eq(200)
expect(response.headers['X-Frame-Options']).to be_nil
@@ -267,7 +265,7 @@ RSpec.describe EmbedController do
Fabricate(:embeddable_host, host: 'https://example.com/1234', class_name: 'example')
end
- context "success" do
+ context "with success" do
it "works with the first host" do
get '/embed/comments',
params: { embed_url: embed_url },
@@ -301,7 +299,7 @@ RSpec.describe EmbedController do
end
end
- context "CSP frame-ancestors enabled" do
+ context "with CSP frame-ancestors enabled" do
before do
SiteSetting.content_security_policy_frame_ancestors = true
end
diff --git a/spec/requests/extra_locales_controller_spec.rb b/spec/requests/extra_locales_controller_spec.rb
index 0ad7a1d7a20..d194356e7db 100644
--- a/spec/requests/extra_locales_controller_spec.rb
+++ b/spec/requests/extra_locales_controller_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe ExtraLocalesController do
- context 'show' do
-
+ describe '#show' do
it "won't work with a weird parameter" do
get "/extra-locales/-invalid..character!!"
expect(response.status).to eq(404)
@@ -29,8 +28,7 @@ RSpec.describe ExtraLocalesController do
expect(response.status).to eq(400)
end
- context "logged in as a moderator" do
-
+ context "when logged in as a moderator" do
let(:moderator) { Fabricate(:moderator) }
before { sign_in(moderator) }
@@ -74,7 +72,7 @@ RSpec.describe ExtraLocalesController do
end
end
- context "overridden translations" do
+ context "with overridden translations" do
after { I18n.reload! }
it "works for anonymous users" do
diff --git a/spec/requests/finish_installation_controller_spec.rb b/spec/requests/finish_installation_controller_spec.rb
index 726983ee019..1bbdac01cfc 100644
--- a/spec/requests/finish_installation_controller_spec.rb
+++ b/spec/requests/finish_installation_controller_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe FinishInstallationController do
-
describe '#index' do
- context "has_login_hint is false" do
+ context "when has_login_hint is false" do
before do
SiteSetting.has_login_hint = false
end
@@ -14,7 +13,7 @@ RSpec.describe FinishInstallationController do
end
end
- context "has_login_hint is true" do
+ context "when has_login_hint is true" do
before do
SiteSetting.has_login_hint = true
end
@@ -27,7 +26,7 @@ RSpec.describe FinishInstallationController do
end
describe '#register' do
- context "has_login_hint is false" do
+ context "when has_login_hint is false" do
before do
SiteSetting.has_login_hint = false
end
@@ -38,7 +37,7 @@ RSpec.describe FinishInstallationController do
end
end
- context "has_login_hint is true" do
+ context "when has_login_hint is true" do
before do
SiteSetting.has_login_hint = true
GlobalSetting.stubs(:developer_emails).returns("[email protected]")
@@ -68,7 +67,7 @@ RSpec.describe FinishInstallationController do
expect(response).not_to be_redirect
end
- context "working params" do
+ context "with working params" do
let(:params) do
{
@@ -115,7 +114,7 @@ RSpec.describe FinishInstallationController do
end
describe '#confirm_email' do
- context "has_login_hint is false" do
+ context "when has_login_hint is false" do
before do
SiteSetting.has_login_hint = false
end
diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb
index e9402e18f02..397dd43c9ed 100644
--- a/spec/requests/groups_controller_spec.rb
+++ b/spec/requests/groups_controller_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe GroupsController do
end
end
- context 'searchable' do
+ context 'with searchable' do
it 'should return the searched groups' do
testing_group = Fabricate(:group, name: 'testing')
@@ -85,7 +85,7 @@ RSpec.describe GroupsController do
end
end
- context 'sortable' do
+ context 'with sortable' do
before do
group
sign_in(user)
@@ -175,7 +175,7 @@ RSpec.describe GroupsController do
)
end
- context 'viewing groups of another user' do
+ context 'when viewing groups of another user' do
describe 'when an invalid username is given' do
it 'should return the right response' do
group
@@ -254,7 +254,7 @@ RSpec.describe GroupsController do
end
end
- context 'viewing as an admin' do
+ context 'when viewing as an admin' do
before do
sign_in(admin)
group.add(admin)
@@ -283,7 +283,7 @@ RSpec.describe GroupsController do
)
end
- context 'filterable by type' do
+ context 'when filterable by type' do
def expect_type_to_return_right_groups(type, expected_group_ids)
get "/groups.json", params: { type: type }
@@ -672,7 +672,7 @@ RSpec.describe GroupsController do
let(:category) { Fabricate(:category) }
let(:tag) { Fabricate(:tag) }
- context "custom_fields" do
+ context "with custom_fields" do
before do
user.update!(admin: true)
sign_in(user)
@@ -889,7 +889,7 @@ RSpec.describe GroupsController do
expect(event[:params].first).to eq(group)
end
- context "user default notifications" do
+ context "with user default notifications" do
it "should update default notification preference for existing users" do
group.update!(default_notification_level: NotificationLevels.all[:watching])
user1 = Fabricate(:user)
@@ -1275,7 +1275,7 @@ RSpec.describe GroupsController do
expect(response).to be_forbidden
end
- context 'public group' do
+ context 'with public group' do
it 'should be forbidden' do
group.update!(
public_admission: true,
@@ -1383,7 +1383,7 @@ RSpec.describe GroupsController do
expect(response.status).to eq(403)
end
- context "is able to add several members to a group" do
+ context "when is able to add several members to a group" do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user, username: "UsEr2") }
@@ -1564,7 +1564,7 @@ RSpec.describe GroupsController do
expect(new_user.reload.group_ids.include?(group.id)).to eq(true)
end
- context 'public group' do
+ context 'with public group' do
before do
group.update!(
public_admission: true,
@@ -1572,7 +1572,7 @@ RSpec.describe GroupsController do
)
end
- context 'admin' do
+ context 'when admin' do
it "can make incremental adds" do
expect do
put "/groups/#{group.id}/members.json",
@@ -1668,7 +1668,7 @@ RSpec.describe GroupsController do
expect(response_body["skipped_usernames"].first).to eq("system")
end
- context "is able to remove a member" do
+ context "when is able to remove a member" do
it "removes by id" do
expect do
delete "/groups/#{group.id}/members.json", params: { user_id: user.id }
@@ -1711,10 +1711,10 @@ RSpec.describe GroupsController do
expect(response.status).to eq(200)
end
- context 'public group' do
+ context 'with public group' do
let(:group) { Fabricate(:public_group, users: [other_user]) }
- context "admin" do
+ context "when admin" do
it "removes by username" do
expect do
delete "/groups/#{group.id}/members.json",
@@ -1737,7 +1737,7 @@ RSpec.describe GroupsController do
end
describe '#remove_members' do
- context "is able to remove several members from a group" do
+ context "when is able to remove several members from a group" do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user, username: "UsEr2") }
let(:group1) { Fabricate(:group, users: [user1, user2]) }
@@ -2240,7 +2240,7 @@ RSpec.describe GroupsController do
group.group_users.where(user: user).last.update(owner: user)
end
- context "validating smtp" do
+ context "when validating smtp" do
let(:protocol) { "smtp" }
let(:username) { "[email protected]" }
let(:password) { "password" }
@@ -2261,7 +2261,7 @@ RSpec.describe GroupsController do
end
end
- context "validating imap" do
+ context "when validating imap" do
let(:protocol) { "imap" }
let(:username) { "[email protected]" }
let(:password) { "password" }
@@ -2309,7 +2309,7 @@ RSpec.describe GroupsController do
end
end
- context "user does not have access to the group" do
+ context "when user does not have access to the group" do
before do
group.group_users.destroy_all
end
@@ -2320,7 +2320,7 @@ RSpec.describe GroupsController do
end
end
- context "rate limited" do
+ context "when rate limited" do
it "rate limits anon searches per user" do
RateLimiter.enable
RateLimiter.clear_all!
diff --git a/spec/requests/inline_onebox_controller_spec.rb b/spec/requests/inline_onebox_controller_spec.rb
index 75f0ea78378..f07eab6457c 100644
--- a/spec/requests/inline_onebox_controller_spec.rb
+++ b/spec/requests/inline_onebox_controller_spec.rb
@@ -1,13 +1,12 @@
# frozen_string_literal: true
RSpec.describe InlineOneboxController do
-
it "requires the user to be logged in" do
get "/inline-onebox.json", params: { urls: [] }
expect(response.status).to eq(403)
end
- context "logged in" do
+ context "when logged in" do
let!(:user) { sign_in(Fabricate(:user)) }
it "returns empty JSON for empty input" do
@@ -17,7 +16,7 @@ RSpec.describe InlineOneboxController do
expect(json['inline-oneboxes']).to eq([])
end
- context "topic link" do
+ context "with topic link" do
fab!(:topic) { Fabricate(:topic) }
it "returns information for a valid link" do
diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb
index c6acc95bc99..0d391ddda1e 100644
--- a/spec/requests/invites_controller_spec.rb
+++ b/spec/requests/invites_controller_spec.rb
@@ -197,7 +197,7 @@ RSpec.describe InvitesController do
end
end
- context 'invite to topic' do
+ context 'with invite to topic' do
fab!(:topic) { Fabricate(:topic) }
it 'works' do
@@ -215,7 +215,7 @@ RSpec.describe InvitesController do
expect(response.status).to eq(400)
end
- context 'topic is private' do
+ context 'when topic is private' do
fab!(:group) { Fabricate(:group) }
fab!(:secured_category) do |category|
@@ -245,7 +245,7 @@ RSpec.describe InvitesController do
end
end
- context 'invite to group' do
+ context 'with invite to group' do
fab!(:group) { Fabricate(:group) }
it 'works for admins' do
@@ -299,7 +299,7 @@ RSpec.describe InvitesController do
end
end
- context 'email invite' do
+ context 'with email invite' do
subject(:create_invite) { post '/invites.json', params: params }
let(:params) { { email: email } }
@@ -374,7 +374,7 @@ RSpec.describe InvitesController do
end
end
- context 'link invite' do
+ context 'with link invite' do
it 'works' do
sign_in(admin)
@@ -752,7 +752,7 @@ RSpec.describe InvitesController do
end
context 'with password' do
- context 'user was invited via email' do
+ context 'when user was invited via email' do
before { invite.update_column(:emailed_status, Invite.emailed_status_types[:pending]) }
it 'does not send an activation email and activates the user' do
@@ -786,7 +786,7 @@ RSpec.describe InvitesController do
end
end
- context 'user was invited via link' do
+ context 'when user was invited via link' do
before { invite.update_column(:emailed_status, Invite.emailed_status_types[:not_required]) }
it 'sends an activation email and does not activate the user' do
@@ -870,7 +870,7 @@ RSpec.describe InvitesController do
end
end
- context 'new registrations are disabled' do
+ context 'when new registrations are disabled' do
fab!(:topic) { Fabricate(:topic) }
fab!(:invite) { Invite.generate(topic.user, email: '[email protected]', topic: topic) }
@@ -885,7 +885,7 @@ RSpec.describe InvitesController do
end
end
- context 'user is already logged in' do
+ context 'when user is already logged in' do
fab!(:invite) { Fabricate(:invite, email: '[email protected]') }
fab!(:user) { sign_in(Fabricate(:user)) }
@@ -899,7 +899,7 @@ RSpec.describe InvitesController do
end
end
- context 'topic invites' do
+ context 'with topic invites' do
fab!(:invite) { Fabricate(:invite, email: '[email protected]') }
fab!(:secured_category) do
@@ -937,7 +937,7 @@ RSpec.describe InvitesController do
end
end
- context 'staged user' do
+ context 'with staged user' do
fab!(:invite) { Fabricate(:invite) }
fab!(:staged_user) { Fabricate(:user, staged: true, email: invite.email) }
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index 890b8b9c07e..537542eee7d 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -446,7 +446,7 @@ RSpec.describe ListController do
end
describe 'category' do
- context 'in a category' do
+ context 'when in a category' do
let(:category) { Fabricate(:category_with_definition) }
let(:group) { Fabricate(:group) }
let(:private_category) { Fabricate(:private_category, group: group) }
@@ -496,7 +496,7 @@ RSpec.describe ListController do
end
end
- context 'another category exists with a number at the beginning of its name' do
+ context 'when another category exists with a number at the beginning of its name' do
# One category has another category's id at the beginning of its name
let!(:other_category) {
# Our validations don't allow this to happen now, but did historically
@@ -514,7 +514,7 @@ RSpec.describe ListController do
end
end
- context 'a child category' do
+ context 'with a child category' do
let(:sub_category) { Fabricate(:category_with_definition, parent_category_id: category.id) }
context 'when parent and child are requested' do
@@ -596,16 +596,20 @@ RSpec.describe ListController do
end
end
- context "renders correct title" do
+ context "for category default view" do
let!(:amazing_category) { Fabricate(:category_with_definition, name: "Amazing Category") }
- it 'for category default view' do
+ it "renders correct title" do
get "/c/#{amazing_category.slug}/#{amazing_category.id}"
expect(response.body).to have_tag "title", text: "Amazing Category - Discourse"
end
+ end
- it 'for category latest view' do
+ context "for category latest view" do
+ let!(:amazing_category) { Fabricate(:category_with_definition, name: "Amazing Category") }
+
+ it 'renders correct title' do
SiteSetting.short_site_description = "Best community"
get "/c/#{amazing_category.slug}/#{amazing_category.id}/l/latest"
@@ -638,7 +642,7 @@ RSpec.describe ListController do
expect(json["topic_list"]["topics"].size).to eq(2)
end
- context "unicode usernames" do
+ context "with unicode usernames" do
before do
SiteSetting.unicode_usernames = true
end
@@ -872,16 +876,18 @@ RSpec.describe ListController do
expect(response.status).to eq(200)
end
- context "does not create a redirect loop" do
- it "with encoded slugs" do
+ context "with encoded slugs" do
+ it "does not create a redirect loop" do
category = Fabricate(:category)
category.update_columns(slug: CGI.escape("systèmes"))
get "/c/syst%C3%A8mes/#{category.id}"
expect(response.status).to eq(200)
end
+ end
- it "with lowercase encoded slugs" do
+ context "with lowercase encoded slugs" do
+ it "does not create a redirect loop" do
category = Fabricate(:category)
category.update_columns(slug: CGI.escape("systèmes").downcase)
diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb
index 032c539c13c..441fc5c8cc0 100644
--- a/spec/requests/omniauth_callbacks_controller_spec.rb
+++ b/spec/requests/omniauth_callbacks_controller_spec.rb
@@ -79,7 +79,7 @@ RSpec.describe Users::OmniauthCallbacksController do
end
end
- context 'Google Oauth2' do
+ describe 'Google Oauth2' do
before do
SiteSetting.enable_google_oauth2_logins = true
end
@@ -157,7 +157,7 @@ RSpec.describe Users::OmniauthCallbacksController do
end
end
- context "in readonly mode" do
+ context "when in readonly mode" do
use_redis_snapshotting
it "should return a 503" do
@@ -168,7 +168,7 @@ RSpec.describe Users::OmniauthCallbacksController do
end
end
- context "in staff writes only mode" do
+ context "when in staff writes only mode" do
use_redis_snapshotting
before do
@@ -785,7 +785,7 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["username"]).to eq(fixed_username)
end
- context "groups are enabled" do
+ context "when groups are enabled" do
let(:strategy_class) { Auth::OmniAuthStrategies::DiscourseGoogleOauth2 }
let(:groups_url) { "#{strategy_class::GROUPS_DOMAIN}#{strategy_class::GROUPS_PATH}" }
let(:groups_scope) { strategy_class::DEFAULT_SCOPE + strategy_class::GROUPS_SCOPE }
diff --git a/spec/requests/onebox_controller_spec.rb b/spec/requests/onebox_controller_spec.rb
index 880963d232f..cb531a54229 100644
--- a/spec/requests/onebox_controller_spec.rb
+++ b/spec/requests/onebox_controller_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe OneboxController do
expect(response.body).to include('blockquote')
end
- context 'local categories' do
+ context 'with local categories' do
fab!(:category) { Fabricate(:category) }
it 'oneboxes a public category' do
diff --git a/spec/requests/post_actions_controller_spec.rb b/spec/requests/post_actions_controller_spec.rb
index 00f0ec80cce..bfa0544d0d4 100644
--- a/spec/requests/post_actions_controller_spec.rb
+++ b/spec/requests/post_actions_controller_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe PostActionsController do
expect(response.status).to eq(403)
end
- context 'logged in' do
+ context 'when logged in' do
before do
sign_in(user)
end
diff --git a/spec/requests/post_readers_controller_spec.rb b/spec/requests/post_readers_controller_spec.rb
index 944af846e88..f5c004cc3df 100644
--- a/spec/requests/post_readers_controller_spec.rb
+++ b/spec/requests/post_readers_controller_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe PostReadersController do
@post = Fabricate(:post, topic: @group_message, post_number: 3)
end
- context 'When the user has access to readers data' do
+ context 'when the user has access to readers data' do
before do
@group.update!(publish_read_state: true)
@group.add(admin)
diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb
index b7f3bad0ae3..f29d2935b2c 100644
--- a/spec/requests/posts_controller_spec.rb
+++ b/spec/requests/posts_controller_spec.rb
@@ -22,7 +22,7 @@ RSpec.shared_examples 'finding and showing post' do
expect(response.status).to eq(404)
end
- context "deleted post" do
+ context "with deleted post" do
before do
post.trash!(user)
end
@@ -50,7 +50,7 @@ RSpec.shared_examples 'finding and showing post' do
expect(response.status).to eq(200)
end
- context "category group moderator" do
+ context "with category group moderator" do
fab!(:group_user) { Fabricate(:group_user) }
let(:user_gm) { group_user.user }
let(:group) { group_user.group }
@@ -251,7 +251,7 @@ RSpec.describe PostsController do
delete "/posts/#{post.id}.json"
end
- context "permanently destroy" do
+ context "with permanently destroy" do
let!(:post) { Fabricate(:post, topic_id: topic.id, post_number: 3) }
before do
@@ -364,7 +364,7 @@ RSpec.describe PostsController do
end
end
- context "deleting flagged posts" do
+ context "when deleting flagged posts" do
before do
sign_in(moderator)
PostActionCreator.off_topic(moderator, post1)
@@ -809,7 +809,7 @@ RSpec.describe PostsController do
SiteSetting.enable_whispers = true
end
- context 'api' do
+ context 'with api' do
it 'memoizes duplicate requests' do
raw = "this is a test post 123 #{SecureRandom.hash}"
title = "this is a title #{SecureRandom.hash}"
@@ -932,7 +932,7 @@ RSpec.describe PostsController do
sign_in(user)
end
- context "fast typing" do
+ context "when fast typing" do
before do
SiteSetting.min_first_post_typing_time = 3000
SiteSetting.auto_silence_fast_typers_max_trust_level = 1
@@ -1358,7 +1358,7 @@ RSpec.describe PostsController do
end
end
- context "errors" do
+ context "with errors" do
it "does not succeed" do
post "/posts.json", params: { raw: 'test' }
expect(response).not_to be_successful
@@ -1378,7 +1378,7 @@ RSpec.describe PostsController do
expect(response.parsed_body["errors"]).to include(I18n.t(:spamming_host))
end
- context "allow_uncategorized_topics is false" do
+ context "when allow_uncategorized_topics is false" do
before do
SiteSetting.allow_uncategorized_topics = false
end
@@ -1523,7 +1523,7 @@ RSpec.describe PostsController do
end
end
- context "topic bump" do
+ context "with topic bump" do
shared_examples "it works" do
it "should be able to skip topic bumping" do
original_bumped_at = 1.day.ago
@@ -1550,7 +1550,7 @@ RSpec.describe PostsController do
end
end
- context "admins" do
+ context "with admins" do
before do
sign_in(admin)
end
@@ -1558,7 +1558,7 @@ RSpec.describe PostsController do
include_examples "it works"
end
- context "moderators" do
+ context "with moderators" do
before do
sign_in(moderator)
end
@@ -1566,7 +1566,7 @@ RSpec.describe PostsController do
include_examples "it works"
end
- context "TL4 users" do
+ context "with TL4 users" do
fab!(:trust_level_4) { Fabricate(:trust_level_4) }
before do
@@ -1576,7 +1576,7 @@ RSpec.describe PostsController do
include_examples "it works"
end
- context "users" do
+ context "with users" do
fab!(:topic) { Fabricate(:topic) }
[:user].each do |user|
@@ -1593,7 +1593,7 @@ RSpec.describe PostsController do
end
end
- describe "featured links" do
+ context "with featured links" do
it "allows to create topics with featured links" do
sign_in(user_trust_level_1)
@@ -1724,7 +1724,7 @@ RSpec.describe PostsController do
end
end
- context "deleted post" do
+ context "with deleted post" do
fab!(:deleted_post) { Fabricate(:post, user: admin, version: 3) }
fab!(:deleted_post_revision) { Fabricate(:post_revision, user: admin, post: deleted_post) }
@@ -1737,7 +1737,7 @@ RSpec.describe PostsController do
end
end
- context "deleted topic" do
+ context "with deleted topic" do
fab!(:deleted_topic) { Fabricate(:topic, user: admin) }
fab!(:post) { Fabricate(:post, user: admin, topic: deleted_topic, version: 3) }
fab!(:post_revision) { Fabricate(:post_revision, user: admin, post: post) }
@@ -2072,7 +2072,7 @@ RSpec.describe PostsController do
end
describe '#latest' do
- context 'private posts' do
+ context 'with private posts' do
describe 'when not logged in' do
it 'should return the right response' do
Fabricate(:post)
@@ -2118,7 +2118,7 @@ RSpec.describe PostsController do
end
end
- context 'public posts' do
+ context 'with public posts' do
it 'returns public posts with topic rss feed' do
public_post
private_post
diff --git a/spec/requests/published_pages_controller_spec.rb b/spec/requests/published_pages_controller_spec.rb
index ecd97d9f174..7236fb089ad 100644
--- a/spec/requests/published_pages_controller_spec.rb
+++ b/spec/requests/published_pages_controller_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe PublishedPagesController do
SiteSetting.enable_page_publishing = true
end
- context "check slug availability" do
+ context "when checking slug availability" do
it "returns true for a new slug" do
get "/pub/check-slug.json?slug=cool-slug-man"
expect(response).to be_successful
@@ -38,13 +38,13 @@ RSpec.describe PublishedPagesController do
end
end
- context "show" do
+ describe "#show" do
it "returns 404 for a missing article" do
get "/pub/no-article-here-no-thx"
expect(response.status).to eq(404)
end
- context "private topic" do
+ context "with private topic" do
fab!(:group) { Fabricate(:group) }
fab!(:private_category) { Fabricate(:private_category, group: group) }
@@ -57,7 +57,7 @@ RSpec.describe PublishedPagesController do
expect(response.status).to eq(403)
end
- context "published page is public" do
+ context "when published page is public" do
fab!(:public_published_page) {
Fabricate(:published_page, public: true, slug: "a-public-page")
}
@@ -85,7 +85,7 @@ RSpec.describe PublishedPagesController do
expect(response.status).to eq(404)
end
- context "the article is valid" do
+ context "when the article is valid" do
before do
SiteSetting.tagging_enabled = true
published_page.topic.tags = [Fabricate(:tag, name: "recipes")]
@@ -123,13 +123,13 @@ RSpec.describe PublishedPagesController do
expect(response.body).to include("<body class=\"published-page #{published_page.slug} topic-#{published_page.topic_id} recipes uncategorized\">")
end
- context "login is required" do
+ context "when login is required" do
before do
SiteSetting.login_required = true
SiteSetting.show_published_pages_login_required = false
end
- context "a user is connected" do
+ context "when a user is connected" do
before do
sign_in(user)
end
@@ -140,12 +140,12 @@ RSpec.describe PublishedPagesController do
end
end
- context "no user connected" do
+ context "with no user connected" do
it "redirects to login page" do
expect(get(published_page.path)).to redirect_to("/login")
end
- context "show public pages with login required is enabled" do
+ context "when login required is enabled" do
before do
SiteSetting.show_published_pages_login_required = true
end
@@ -160,7 +160,7 @@ RSpec.describe PublishedPagesController do
end
end
- context "publishing" do
+ describe "publishing" do
fab!(:topic) { Fabricate(:topic) }
it "returns invalid access for non-staff" do
@@ -216,8 +216,7 @@ RSpec.describe PublishedPagesController do
end
end
- context "destroy" do
-
+ describe "#destroy" do
it "returns invalid access for non-staff" do
sign_in(user)
delete "/pub/by-topic/#{published_page.topic_id}.json"
@@ -256,5 +255,4 @@ RSpec.describe PublishedPagesController do
expect(response.status).to eq(404)
end
end
-
end
diff --git a/spec/requests/push_notification_controller_spec.rb b/spec/requests/push_notification_controller_spec.rb
index ce4a279b7e6..03642188da7 100644
--- a/spec/requests/push_notification_controller_spec.rb
+++ b/spec/requests/push_notification_controller_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe PushNotificationController do
fab!(:user) { Fabricate(:user) }
- context "logged out" do
+ context "when logged out" do
it "should not allow subscribe" do
post '/push_notifications/subscribe.json', params: {
username: "test",
@@ -21,7 +21,7 @@ RSpec.describe PushNotificationController do
end
end
- context "logged in" do
+ context "when logged in" do
before { sign_in(user) }
it "should subscribe" do
@@ -108,5 +108,4 @@ RSpec.describe PushNotificationController do
expect(user.push_subscriptions).to eq([])
end
end
-
end
diff --git a/spec/requests/qunit_controller_spec.rb b/spec/requests/qunit_controller_spec.rb
index 0b3cf0f1ca8..0060ea9d15a 100644
--- a/spec/requests/qunit_controller_spec.rb
+++ b/spec/requests/qunit_controller_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe QunitController do
end
end
- context "non-admin users on production" do
+ context "with non-admin users on production" do
before do
# We need to call sign_in before stubbing the method because SessionController#become
# checks for the current env when the file is loaded.
@@ -51,7 +51,7 @@ RSpec.describe QunitController do
end
end
- context "admin users" do
+ context "with admin users" do
before do
sign_in(Fabricate(:admin))
end
diff --git a/spec/requests/reviewables_controller_spec.rb b/spec/requests/reviewables_controller_spec.rb
index daa6ae11916..3a19ce3ecca 100644
--- a/spec/requests/reviewables_controller_spec.rb
+++ b/spec/requests/reviewables_controller_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe ReviewablesController do
-
- context "anonymous" do
+ context "when anonymous" do
it "denies listing" do
get "/review.json"
expect(response.code).to eq("403")
@@ -29,7 +28,7 @@ RSpec.describe ReviewablesController do
end
end
- context "regular user" do
+ context "when regular user" do
before do
sign_in(Fabricate(:user))
end
@@ -192,7 +191,7 @@ RSpec.describe ReviewablesController do
expect(json["errors"][0]).to eq(I18n.t("reviewables.already_handled_and_user_not_exist"))
end
- context "supports filtering by range" do
+ context "when filtering by range" do
let(:from) { 3.days.ago.strftime('%F') }
let(:to) { 1.day.ago.strftime('%F') }
@@ -323,7 +322,7 @@ RSpec.describe ReviewablesController do
end
describe "#show" do
- context "basics" do
+ context "with basics" do
fab!(:reviewable) { Fabricate(:reviewable) }
before do
sign_in(Fabricate(:moderator))
@@ -343,7 +342,7 @@ RSpec.describe ReviewablesController do
end
end
- context "conversation" do
+ context "with conversation" do
fab!(:post) { Fabricate(:post) }
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
@@ -389,7 +388,7 @@ RSpec.describe ReviewablesController do
end
describe "#explain" do
- context "basics" do
+ context "with basics" do
fab!(:reviewable) { Fabricate(:reviewable) }
before do
@@ -483,7 +482,7 @@ RSpec.describe ReviewablesController do
expect(job).to be_blank
end
- context "claims" do
+ context "with claims" do
fab!(:qp) { Fabricate(:reviewable_queued_post) }
it "fails when reviewables must be claimed" do
diff --git a/spec/requests/robots_txt_controller_spec.rb b/spec/requests/robots_txt_controller_spec.rb
index a241cb2c6f2..a9a739dc8b9 100644
--- a/spec/requests/robots_txt_controller_spec.rb
+++ b/spec/requests/robots_txt_controller_spec.rb
@@ -23,8 +23,7 @@ RSpec.describe RobotsTxtController do
end
describe '#index' do
-
- context "header for when the content is overridden" do
+ context "when the content is overridden" do
it "is not prepended if there are no overrides" do
sign_in(Fabricate(:admin))
get '/robots.txt'
@@ -45,7 +44,7 @@ RSpec.describe RobotsTxtController do
end
end
- context 'subfolder' do
+ context 'with subfolder' do
it 'prefixes the rules with the directory' do
set_subfolder "/forum"
@@ -54,8 +53,7 @@ RSpec.describe RobotsTxtController do
end
end
- context 'allow_index_in_robots_txt is true' do
-
+ context 'when allow_index_in_robots_txt is true' do
def expect_allowed_and_disallowed_sections(allow_index, disallow_index)
expect(allow_index).to be_present
expect(disallow_index).to be_present
diff --git a/spec/requests/search_controller_spec.rb b/spec/requests/search_controller_spec.rb
index 566f3e2eaa6..b8292cb6a90 100644
--- a/spec/requests/search_controller_spec.rb
+++ b/spec/requests/search_controller_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe SearchController do
Fabricate(:post, raw: "#{user.username} is a cool person")
end
- context "integration" do
+ context "with integration" do
before do
SearchIndexer.enable
end
@@ -174,7 +174,7 @@ RSpec.describe SearchController do
expect(data['users'][0]['id']).to eq(user.id)
end
- context 'searching by topic id' do
+ context 'when searching by topic id' do
it 'should not be restricted by minimum search term length' do
SiteSetting.min_search_term_length = 20000
@@ -241,7 +241,7 @@ RSpec.describe SearchController do
expect(response.status).to eq(200)
end
- context 'rate limited' do
+ context 'when rate limited' do
it 'rate limits anon searches per user' do
SiteSetting.rate_limit_search_anon_user = 2
RateLimiter.enable
@@ -288,7 +288,7 @@ RSpec.describe SearchController do
expect(json["grouped_search_result"]["error"]).to eq(I18n.t("rate_limiter.slow_down"))
end
- context "and a logged in user" do
+ context "with a logged in user" do
before { sign_in(user) }
it 'rate limits logged in searches' do
@@ -374,7 +374,7 @@ RSpec.describe SearchController do
expect(SearchLog.where(term: 'bantha')).to be_blank
end
- context 'rate limited' do
+ context 'when rate limited' do
it 'rate limits anon searches per user' do
SiteSetting.rate_limit_search_anon_user = 2
RateLimiter.enable
@@ -423,7 +423,7 @@ RSpec.describe SearchController do
end
- context "and a logged in user" do
+ context "with a logged in user" do
before { sign_in(user) }
it 'rate limits searches' do
@@ -452,7 +452,7 @@ RSpec.describe SearchController do
end
end
- context "search priority" do
+ context "with search priority" do
fab!(:very_low_priority_category) do
Fabricate(
:category,
@@ -550,7 +550,7 @@ RSpec.describe SearchController do
end
end
- context "search context" do
+ context "with search context" do
it "raises an error with an invalid context type" do
get "/search/query.json", params: {
term: 'test', search_context: { type: 'security', id: 'hole' }
diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb
index 0f4a1830308..adebaface7f 100644
--- a/spec/requests/session_controller_spec.rb
+++ b/spec/requests/session_controller_spec.rb
@@ -54,14 +54,14 @@ RSpec.describe SessionController do
end
end
- context 'missing token' do
+ context 'with missing token' do
it 'returns the right response' do
get "/session/email-login"
expect(response.status).to eq(404)
end
end
- context 'valid token' do
+ context 'with valid token' do
it 'returns information' do
get "/session/email-login/#{email_token.token}.json"
@@ -88,7 +88,7 @@ RSpec.describe SessionController do
expect(response.status).to eq(403)
end
- context 'user has 2-factor logins' do
+ context 'when user has 2-factor logins' do
let!(:user_second_factor) { Fabricate(:user_second_factor_totp, user: user) }
let!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user: user) }
@@ -102,7 +102,7 @@ RSpec.describe SessionController do
end
end
- context 'user has security key enabled' do
+ context 'when user has security key enabled' do
let!(:user_security_key) { Fabricate(:user_security_key, user: user) }
it "includes that information in the response" do
@@ -144,14 +144,14 @@ RSpec.describe SessionController do
end
end
- context 'missing token' do
+ context 'with missing token' do
it 'returns the right response' do
post "/session/email-login"
expect(response.status).to eq(404)
end
end
- context 'invalid token' do
+ context 'with invalid token' do
it 'returns the right response' do
post "/session/email-login/adasdad.json"
@@ -176,7 +176,7 @@ RSpec.describe SessionController do
end
end
- context 'valid token' do
+ context 'with valid token' do
it 'returns success' do
post "/session/email-login/#{email_token.token}.json"
@@ -284,7 +284,7 @@ RSpec.describe SessionController do
expect(session[:current_user_id]).to eq(nil)
end
- context 'user has 2-factor logins' do
+ context 'when user has 2-factor logins' do
let!(:user_second_factor) { Fabricate(:user_second_factor_totp, user: user) }
let!(:user_second_factor_backup) { Fabricate(:user_second_factor_backup, user: user) }
@@ -362,7 +362,7 @@ RSpec.describe SessionController do
end
end
- context "user has only security key enabled" do
+ context "when user has only security key enabled" do
let!(:user_security_key) do
Fabricate(
:user_security_key,
@@ -437,7 +437,7 @@ RSpec.describe SessionController do
end
end
- context "user has security key and totp enabled" do
+ context "when user has security key and totp enabled" do
let!(:user_security_key) do
Fabricate(
:user_security_key,
@@ -479,7 +479,7 @@ RSpec.describe SessionController do
end
end
- context 'logoff support' do
+ describe 'logoff support' do
it 'can log off users cleanly' do
user = Fabricate(:user)
sign_in(user)
@@ -552,7 +552,7 @@ RSpec.describe SessionController do
sso
end
- context 'in staff writes only mode' do
+ context 'when in staff writes only mode' do
use_redis_snapshotting
before do
@@ -1266,7 +1266,7 @@ RSpec.describe SessionController do
end
end
- context "in readonly mode" do
+ context "when in readonly mode" do
use_redis_snapshotting
before do
@@ -1663,7 +1663,7 @@ RSpec.describe SessionController do
end
describe '#create' do
- context 'read only mode' do
+ context 'when read only mode' do
use_redis_snapshotting
before do
@@ -1687,7 +1687,7 @@ RSpec.describe SessionController do
end
end
- context 'staff writes only mode' do
+ context 'when in staff writes only mode' do
use_redis_snapshotting
before do
@@ -1712,7 +1712,7 @@ RSpec.describe SessionController do
end
end
- context 'local login is disabled' do
+ context 'when local login is disabled' do
before do
SiteSetting.enable_local_logins = false
@@ -1723,7 +1723,7 @@ RSpec.describe SessionController do
it_behaves_like "failed to continue local login"
end
- context 'SSO is enabled' do
+ context 'when SSO is enabled' do
before do
SiteSetting.discourse_connect_url = "https://www.example.com/sso"
SiteSetting.enable_discourse_connect = true
@@ -1735,7 +1735,7 @@ RSpec.describe SessionController do
it_behaves_like "failed to continue local login"
end
- context 'local login via email is disabled' do
+ context 'when local login via email is disabled' do
before do
SiteSetting.enable_local_logins_via_email = false
EmailToken.confirm(email_token.token)
@@ -2112,7 +2112,7 @@ RSpec.describe SessionController do
end
end
- context 'login has leading and trailing space' do
+ context 'when login has leading and trailing space' do
let(:username) { " #{user.username} " }
let(:email) { " #{user.email} " }
@@ -2248,7 +2248,7 @@ RSpec.describe SessionController do
)
end
- context "and the 'must approve users' site setting is enabled" do
+ context "when the 'must approve users' site setting is enabled" do
before { SiteSetting.must_approve_users = true }
it "shows the 'not approved' error message" do
@@ -2261,7 +2261,7 @@ RSpec.describe SessionController do
end
end
- context 'rate limited' do
+ context 'when rate limited' do
it 'rate limits login' do
SiteSetting.max_logins_per_ip_per_hour = 2
RateLimiter.enable
@@ -2421,14 +2421,14 @@ RSpec.describe SessionController do
end
describe '#one_time_password' do
- context 'missing token' do
+ context 'with missing token' do
it 'returns the right response' do
get "/session/otp"
expect(response.status).to eq(404)
end
end
- context 'invalid token' do
+ context 'with invalid token' do
it 'returns the right response' do
get "/session/otp/asd1231dasd123"
@@ -2594,7 +2594,7 @@ RSpec.describe SessionController do
context 'for an existing username' do
fab!(:user) { Fabricate(:user) }
- context 'local login is disabled' do
+ context 'when local login is disabled' do
before do
SiteSetting.enable_local_logins = false
post "/session/forgot_password.json", params: { login: user.username }
@@ -2602,7 +2602,7 @@ RSpec.describe SessionController do
it_behaves_like "failed to continue local login"
end
- context 'SSO is enabled' do
+ context 'when SSO is enabled' do
before do
SiteSetting.discourse_connect_url = "https://www.example.com/sso"
SiteSetting.enable_discourse_connect = true
@@ -2614,7 +2614,7 @@ RSpec.describe SessionController do
it_behaves_like "failed to continue local login"
end
- context "local logins are disabled" do
+ context "when local logins are disabled" do
before do
SiteSetting.enable_local_logins = false
@@ -2625,7 +2625,7 @@ RSpec.describe SessionController do
it_behaves_like "failed to continue local login"
end
- context "local logins via email are disabled" do
+ context "when local logins via email are disabled" do
before do
SiteSetting.enable_local_logins_via_email = false
end
@@ -2648,7 +2648,7 @@ RSpec.describe SessionController do
end
end
- context 'do nothing to system username' do
+ context 'when doing nothing to system username' do
let(:system) { Discourse.system_user }
it 'generates no token for system username' do
diff --git a/spec/requests/similar_topics_controller_spec.rb b/spec/requests/similar_topics_controller_spec.rb
index 2a4d124ab22..26675738a24 100644
--- a/spec/requests/similar_topics_controller_spec.rb
+++ b/spec/requests/similar_topics_controller_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe SimilarTopicsController do
- context 'similar_to' do
+ describe 'similar_to' do
let(:title) { 'this title is long enough to search for' }
let(:raw) { 'this body is long enough to search for' }
@@ -40,7 +40,7 @@ RSpec.describe SimilarTopicsController do
SiteSetting.minimum_topics_similar = 30
end
- describe "With enough topics" do
+ context "with enough topics" do
it "deletes to Topic.similar_to if there are more topics than `minimum_topics_similar`" do
Topic.stubs(:count).returns(50)
post
@@ -54,7 +54,7 @@ RSpec.describe SimilarTopicsController do
expect(similar_topics.first["topic_id"]).to eq(topic.id)
end
- describe "with a logged in user" do
+ context "with a logged in user" do
before do
private_post; post
reindex_posts
diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb
index 6650a801ea0..9f068f447bb 100644
--- a/spec/requests/static_controller_spec.rb
+++ b/spec/requests/static_controller_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe StaticController do
end
end
- describe 'local store' do
+ context 'with local store' do
it 'returns the default favicon if favicon has not been configured' do
get '/favicon/proxied'
@@ -37,7 +37,7 @@ RSpec.describe StaticController do
end
end
- describe 'external store' do
+ context 'with external store' do
let(:upload) do
Upload.create!(
url: '//s3-upload-bucket.s3-us-east-1.amazonaws.com/somewhere/a.png',
@@ -208,7 +208,7 @@ RSpec.describe StaticController do
expect(response.status).to eq(404)
end
- context "modal pages" do
+ context "with modal pages" do
it "should return the right response for /signup" do
get "/signup"
expect(response.status).to eq(200)
@@ -266,7 +266,7 @@ RSpec.describe StaticController do
end
end
- context "crawler view" do
+ context "with crawler view" do
it "should include correct title" do
get '/faq', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
expect(response.status).to eq(200)
@@ -274,7 +274,7 @@ RSpec.describe StaticController do
end
end
- context "plugin api extensions" do
+ context "with plugin api extensions" do
after do
Rails.application.reload_routes!
StaticController::CUSTOM_PAGES.clear
diff --git a/spec/requests/svg_sprite_controller_spec.rb b/spec/requests/svg_sprite_controller_spec.rb
index 70a8536d8a4..56494671697 100644
--- a/spec/requests/svg_sprite_controller_spec.rb
+++ b/spec/requests/svg_sprite_controller_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
RSpec.describe SvgSpriteController do
-
- context 'show' do
+ describe '#show' do
before do
SvgSprite.expire_cache
end
@@ -36,7 +35,7 @@ RSpec.describe SvgSpriteController do
end
end
- context 'search' do
+ describe '#search' do
it "should not work for anons" do
get "/svg-sprite/search/fa-bolt"
expect(response.status).to eq(404)
@@ -76,7 +75,7 @@ RSpec.describe SvgSpriteController do
end
end
- context 'icon_picker_search' do
+ describe '#icon_picker_search' do
it 'should work with no filter and max out at 200 results' do
user = sign_in(Fabricate(:user))
get '/svg-sprite/picker-search'
@@ -101,7 +100,7 @@ RSpec.describe SvgSpriteController do
end
end
- context 'svg_icon' do
+ describe '#svg_icon' do
it "requires .svg extension" do
get "/svg-sprite/#{Discourse.current_hostname}/icon/bolt"
expect(response.status).to eq(404)
diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb
index f1f65f761d4..bf19d91c0e0 100644
--- a/spec/requests/tags_controller_spec.rb
+++ b/spec/requests/tags_controller_spec.rb
@@ -13,7 +13,6 @@ RSpec.describe TagsController do
end
describe '#index' do
-
fab!(:test_tag) { Fabricate(:tag, name: 'test') }
fab!(:topic_tag) { Fabricate(:tag, name: 'topic-test', topic_count: 1) }
fab!(:synonym) { Fabricate(:tag, name: 'synonym', target_tag: topic_tag) }
@@ -43,7 +42,7 @@ RSpec.describe TagsController do
)
end
- context "enabled" do
+ context "when enabled" do
before do
SiteSetting.pm_tags_allowed_for_groups = "1|2|3"
sign_in(admin)
@@ -64,7 +63,7 @@ RSpec.describe TagsController do
end
end
- context "disabled" do
+ context "when disabled" do
before do
SiteSetting.pm_tags_allowed_for_groups = ""
sign_in(admin)
@@ -140,7 +139,7 @@ RSpec.describe TagsController do
expect(response.parsed_body["extras"]["categories"]).to be_empty
end
- context "restricted to a category" do
+ context "when restricted to a category" do
before do
category.tags = [Tag.find_by_name("staff1")]
end
@@ -168,7 +167,7 @@ RSpec.describe TagsController do
end
end
- context "listed by group" do
+ context "when listed by group" do
before do
SiteSetting.tags_listed_by_group = true
end
@@ -393,7 +392,7 @@ RSpec.describe TagsController do
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(true)
end
- context 'tag belongs to a tag group' do
+ context 'when tag belongs to a tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag]) }
it "returns tag groups if tag groups are visible" do
@@ -408,7 +407,7 @@ RSpec.describe TagsController do
expect(response.parsed_body['tag_info'].has_key?('tag_group_names')).to eq(false)
end
- context "restricted to a private category" do
+ context "when restricted to a private category" do
let!(:private_category) do
Fabricate(:private_category,
group: Fabricate(:group),
@@ -551,7 +550,7 @@ RSpec.describe TagsController do
fab!(:multi_tag_topic) { Fabricate(:topic, tags: [tag, other_tag]) }
fab!(:all_tag_topic) { Fabricate(:topic, tags: [tag, other_tag, third_tag]) }
- context 'tagging disabled' do
+ context 'with tagging disabled' do
it "returns 404" do
SiteSetting.tagging_enabled = false
get "/tag/#{tag.name}/l/latest.json"
@@ -559,7 +558,7 @@ RSpec.describe TagsController do
end
end
- context 'tagging enabled' do
+ context 'with tagging enabled' do
def parse_topic_ids
response.parsed_body["topic_list"]["topics"]
.map { |topic| topic["id"] }
@@ -651,7 +650,6 @@ RSpec.describe TagsController do
end
context "when logged in" do
-
before do
sign_in(user)
end
@@ -662,7 +660,7 @@ RSpec.describe TagsController do
expect(response.status).to eq(200)
end
- context "muted tags" do
+ context "with muted tags" do
before do
TagUser.create!(
user_id: user.id,
@@ -744,7 +742,7 @@ RSpec.describe TagsController do
end
describe '#search' do
- context 'tagging disabled' do
+ context 'with tagging disabled' do
it "returns 404" do
SiteSetting.tagging_enabled = false
get "/tags/filter/search.json", params: { q: 'stuff' }
@@ -752,7 +750,7 @@ RSpec.describe TagsController do
end
end
- context 'tagging enabled' do
+ context 'with tagging enabled' do
it "can return some tags" do
tag_names = ['stuff', 'stinky', 'stumped']
tag_names.each { |name| Fabricate(:tag, name: name) }
@@ -903,7 +901,7 @@ RSpec.describe TagsController do
end
describe '#destroy' do
- context 'tagging enabled' do
+ context 'with tagging enabled' do
before do
sign_in(admin)
end
@@ -936,7 +934,7 @@ RSpec.describe TagsController do
expect(response.status).to eq(403)
end
- context 'logged in' do
+ context 'when logged in' do
before do
sign_in(admin)
end
@@ -1025,7 +1023,7 @@ RSpec.describe TagsController do
expect(response.status).to eq(403)
end
- context 'signed in as admin' do
+ context 'when signed in as admin' do
before { sign_in(admin) }
it 'can make a tag a synonym of another tag' do
@@ -1072,7 +1070,7 @@ RSpec.describe TagsController do
expect(response.status).to eq(403)
end
- context 'signed in as admin' do
+ context 'when signed in as admin' do
before { sign_in(admin) }
it "can remove a synonym from a tag" do
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index f7b1e3e9228..b67f235d8b6 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -126,8 +126,7 @@ RSpec.describe TopicsController do
expect(result['errors']).to be_present
end
- context 'success' do
-
+ context 'with success' do
before { sign_in(admin) }
it "returns success" do
@@ -176,7 +175,7 @@ RSpec.describe TopicsController do
end
end
- context 'failure' do
+ context 'with failure' do
it "returns JSON with a false success" do
sign_in(moderator)
post "/t/#{topic.id}/move-posts.json", params: {
@@ -190,7 +189,7 @@ RSpec.describe TopicsController do
end
describe "moving replied posts" do
- context 'success' do
+ context 'with success' do
it "moves the child posts too" do
sign_in(moderator)
p1 = Fabricate(:post, topic: topic, user: moderator)
@@ -274,7 +273,7 @@ RSpec.describe TopicsController do
fab!(:topic) { p1.topic }
fab!(:p2) { Fabricate(:post, user: moderator, topic: topic) }
- context 'success' do
+ context 'with success' do
it "returns success" do
post "/t/#{topic.id}/move-posts.json", params: {
post_ids: [p2.id],
@@ -312,7 +311,7 @@ RSpec.describe TopicsController do
end
end
- context 'failure' do
+ context 'with failure' do
fab!(:p2) { Fabricate(:post, user: moderator) }
it "returns JSON with a false success" do
post "/t/#{topic.id}/move-posts.json", params: {
@@ -413,7 +412,7 @@ RSpec.describe TopicsController do
expect(result['errors']).to be_present
end
- context 'success' do
+ context 'with success' do
before { sign_in(admin) }
it "returns success" do
@@ -461,7 +460,7 @@ RSpec.describe TopicsController do
end
end
- context 'failure' do
+ context 'with failure' do
it "returns JSON with a false success" do
sign_in(moderator)
post "/t/#{message.id}/move-posts.json", params: {
@@ -491,7 +490,7 @@ RSpec.describe TopicsController do
])
end
- context 'success' do
+ context 'with success' do
it "returns success" do
post "/t/#{message.id}/move-posts.json", params: {
post_ids: [p2.id],
@@ -506,7 +505,7 @@ RSpec.describe TopicsController do
end
end
- context 'failure' do
+ context 'with failure' do
it "returns JSON with a false success" do
post "/t/#{message.id}/move-posts.json", params: {
post_ids: [p2.id],
@@ -546,7 +545,7 @@ RSpec.describe TopicsController do
expect(response).to be_forbidden
end
- context 'moves all the posts to the destination topic' do
+ context 'when moving all the posts to the destination topic' do
it "returns success" do
sign_in(moderator)
post "/t/#{topic.id}/merge-topic.json", params: {
@@ -632,7 +631,7 @@ RSpec.describe TopicsController do
expect(response).to be_forbidden
end
- context 'moves all the posts to the destination message' do
+ context 'when moving all the posts to the destination message' do
it "returns success" do
sign_in(moderator)
post "/t/#{message.id}/merge-topic.json", params: {
@@ -1247,7 +1246,7 @@ RSpec.describe TopicsController do
expect(topic.reload.category_id).not_to eq(category.id)
end
- context 'updating shared drafts' do
+ context 'when updating shared drafts' do
fab!(:topic) { Fabricate(:topic, category: shared_drafts_category) }
fab!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: Fabricate(:category)) }
@@ -1488,7 +1487,7 @@ RSpec.describe TopicsController do
end
end
- context 'tags' do
+ context 'with tags' do
before do
SiteSetting.tagging_enabled = true
end
@@ -1611,7 +1610,7 @@ RSpec.describe TopicsController do
end
end
- context 'updating to a category with restricted tags' do
+ context 'when updating to a category with restricted tags' do
fab!(:restricted_category) { Fabricate(:category) }
fab!(:tag1) { Fabricate(:tag) }
fab!(:tag2) { Fabricate(:tag) }
@@ -1739,7 +1738,7 @@ RSpec.describe TopicsController do
end
end
- context "allow_uncategorized_topics is false" do
+ context "when allow_uncategorized_topics is false" do
before do
SiteSetting.allow_uncategorized_topics = false
end
@@ -2009,7 +2008,7 @@ RSpec.describe TopicsController do
expect(response.status).to eq(200)
end
- context 'a topic with nil slug exists' do
+ context 'when a topic with nil slug exists' do
before do
nil_slug_topic = Fabricate(:topic)
Topic.connection.execute("update topics set slug=null where id = #{nil_slug_topic.id}") # can't find a way to set slug column to null using the model
@@ -2021,7 +2020,7 @@ RSpec.describe TopicsController do
end
end
- context 'permission errors' do
+ context 'with permission errors' do
fab!(:allowed_user) { Fabricate(:user) }
fab!(:allowed_group) { Fabricate(:group) }
fab!(:accessible_group) { Fabricate(:group, public_admission: true) }
@@ -2080,7 +2079,7 @@ RSpec.describe TopicsController do
SiteSetting.detailed_404 = false
end
- context 'anonymous' do
+ context 'when anonymous' do
expected = {
normal_topic: 200,
secure_topic: 404,
@@ -2094,7 +2093,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'anonymous with login required' do
+ context 'when anonymous with login required' do
before do
SiteSetting.login_required = true
end
@@ -2111,7 +2110,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'anonymous with login required, requesting json' do
+ context 'when anonymous with login required, requesting json' do
before do
SiteSetting.login_required = true
end
@@ -2128,7 +2127,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: true
end
- context 'normal user' do
+ context 'when normal user' do
before do
sign_in(user)
end
@@ -2146,7 +2145,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'allowed user' do
+ context 'when allowed user' do
before do
sign_in(allowed_user)
end
@@ -2164,7 +2163,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'moderator' do
+ context 'when moderator' do
before do
sign_in(moderator)
end
@@ -2182,7 +2181,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'admin' do
+ context 'when admin' do
before do
sign_in(admin)
end
@@ -2206,7 +2205,7 @@ RSpec.describe TopicsController do
SiteSetting.detailed_404 = true
end
- context 'anonymous' do
+ context 'when anonymous' do
expected = {
normal_topic: 200,
secure_topic: 403,
@@ -2220,7 +2219,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: true
end
- context 'anonymous with login required' do
+ context 'when anonymous with login required' do
before do
SiteSetting.login_required = true
end
@@ -2237,7 +2236,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'normal user' do
+ context 'when normal user' do
before do
sign_in(user)
end
@@ -2255,7 +2254,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: true
end
- context 'allowed user' do
+ context 'when allowed user' do
before do
sign_in(allowed_user)
end
@@ -2273,7 +2272,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'moderator' do
+ context 'when moderator' do
before do
sign_in(moderator)
end
@@ -2291,7 +2290,7 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
- context 'admin' do
+ context 'when admin' do
before do
sign_in(admin)
end
@@ -2309,7 +2308,6 @@ RSpec.describe TopicsController do
include_examples "various scenarios", expected, request_json: false
end
end
-
end
it 'records a view' do
@@ -2336,7 +2334,7 @@ RSpec.describe TopicsController do
end.to change { IncomingLink.count }.by(1)
end
- context 'print' do
+ context 'with print' do
it "doesn't renders the print view when disabled" do
SiteSetting.max_prints_per_hour_per_user = 0
@@ -2382,7 +2380,7 @@ RSpec.describe TopicsController do
expect(topic_user.last_visited_at).to eq_time(topic_user.first_visited_at)
end
- context 'consider for a promotion' do
+ context 'when considering for a promotion' do
before do
SiteSetting.tl1_requires_topics_entered = 0
SiteSetting.tl1_requires_read_posts = 0
@@ -2399,7 +2397,7 @@ RSpec.describe TopicsController do
end
end
- context 'filters' do
+ context 'with filters' do
def extract_post_stream
json = response.parsed_body
json["post_stream"]["posts"].map { |post| post["id"] }
@@ -2553,7 +2551,7 @@ RSpec.describe TopicsController do
context "when 'login required' site setting has been enabled" do
before { SiteSetting.login_required = true }
- context 'and the user is logged in' do
+ context 'when the user is logged in' do
before { sign_in(user) }
it 'shows the topic' do
@@ -2562,7 +2560,7 @@ RSpec.describe TopicsController do
end
end
- context 'and the user is not logged in' do
+ context 'when the user is not logged in' do
let(:api_key) { Fabricate(:api_key, user: topic.user) }
it 'redirects browsers to the login page' do
@@ -3077,8 +3075,7 @@ RSpec.describe TopicsController do
expect(TopicUser.get(post1.topic, post1.user).last_read_post_number).to eq(2)
end
- context "private message" do
-
+ context "with private message" do
fab!(:group) do
Fabricate(:group, messageable_level: Group::ALIAS_LEVELS[:everyone]).tap do |g|
g.add(user_2)
@@ -3288,7 +3285,7 @@ RSpec.describe TopicsController do
expect(response).to be_forbidden
end
- context "bookmarks with reminders" do
+ context "with bookmarks with reminders" do
it "deletes all the bookmarks for the user in the topic" do
sign_in(user)
post = create_post
@@ -3438,7 +3435,7 @@ RSpec.describe TopicsController do
end
end
- context 'category' do
+ context 'with category' do
fab!(:subcategory) { Fabricate(:category, parent_category_id: category.id) }
fab!(:category_topic) { Fabricate(:topic, category: category) }
fab!(:subcategory_topic) { Fabricate(:topic, category: subcategory) }
@@ -3460,7 +3457,7 @@ RSpec.describe TopicsController do
end
end
- context 'tag' do
+ context 'with tag' do
fab!(:tag_topic) { Fabricate(:topic) }
fab!(:topic_tag) { Fabricate(:topic_tag, topic: tag_topic, tag: tag) }
@@ -3471,7 +3468,7 @@ RSpec.describe TopicsController do
end
end
- context 'tag and category' do
+ context 'with tag and category' do
fab!(:tag_topic) { Fabricate(:topic) }
fab!(:topic_tag) { Fabricate(:topic_tag, topic: tag_topic, tag: tag) }
fab!(:tag_and_category_topic) { Fabricate(:topic, category: category) }
@@ -3484,7 +3481,7 @@ RSpec.describe TopicsController do
end
end
- context "specific topics" do
+ context "with specific topics" do
fab!(:topic2) { Fabricate(:topic) }
fab!(:topic3) { Fabricate(:topic) }
@@ -3596,7 +3593,7 @@ RSpec.describe TopicsController do
expect(response).to be_forbidden
end
- context "success" do
+ context "with success" do
it "returns success" do
sign_in(admin)
put "/t/#{topic.id}/convert-topic/private.json"
@@ -3622,7 +3619,7 @@ RSpec.describe TopicsController do
expect(response).to be_forbidden
end
- context "success" do
+ context "with success" do
it "returns success" do
sign_in(admin)
put "/t/#{topic.id}/convert-topic/public.json?category_id=#{category.id}"
@@ -3873,7 +3870,7 @@ RSpec.describe TopicsController do
end
end
- context 'logged in as an admin' do
+ context 'when logged in as an admin' do
it 'allows admins to set the slow mode interval' do
sign_in(admin)
@@ -3887,7 +3884,7 @@ RSpec.describe TopicsController do
end
end
- context 'logged in as a regular user' do
+ context 'when logged in as a regular user' do
it 'does nothing if the user is not TL4' do
user.update!(trust_level: TrustLevel[3])
sign_in(user)
@@ -3913,7 +3910,7 @@ RSpec.describe TopicsController do
end
end
- context 'auto-disable slow mode' do
+ context 'with auto-disable slow mode' do
before { sign_in(admin) }
let!(:timestamp) { 1.week.from_now.to_formatted_s(:iso8601) }
@@ -3963,7 +3960,7 @@ RSpec.describe TopicsController do
end
describe '#invite' do
- describe 'when not logged in' do
+ context 'when not logged in' do
it "should return the right response" do
post "/t/#{topic.id}/invite.json", params: {
@@ -3973,12 +3970,12 @@ RSpec.describe TopicsController do
end
end
- describe 'when logged in' do
+ context 'when logged in' do
before do
sign_in(user)
end
- describe 'as a valid user' do
+ context 'as a valid user' do
fab!(:user_topic) { Fabricate(:topic, user: user) }
it 'should return the right response' do
@@ -3995,7 +3992,7 @@ RSpec.describe TopicsController do
end
end
- describe 'when user is a group manager' do
+ context 'when user is a group manager' do
fab!(:group) { Fabricate(:group).tap { |g| g.add_owner(user) } }
fab!(:private_category) { Fabricate(:private_category, group: group) }
@@ -4019,7 +4016,7 @@ RSpec.describe TopicsController do
expect(Invite.find_by(email: recipient).groups).to contain_exactly(group)
end
- describe 'when group is available to automatic groups only' do
+ context 'when group is available to automatic groups only' do
before do
group.update!(automatic: true)
end
@@ -4033,7 +4030,7 @@ RSpec.describe TopicsController do
end
end
- describe 'when user is not part of the required group' do
+ context 'when user is not part of the required group' do
it 'should return the right response' do
post "/t/#{group_private_topic.id}/invite.json", params: {
user: user
@@ -4052,7 +4049,7 @@ RSpec.describe TopicsController do
end
end
- describe 'when topic id is invalid' do
+ context 'when topic id is invalid' do
it 'should return the right response' do
id = topic.id
topic.destroy!
@@ -4069,7 +4066,7 @@ RSpec.describe TopicsController do
expect(response.status).to eq(400)
end
- describe "when PM has reached maximum allowed numbers of recipients" do
+ context "when PM has reached maximum allowed numbers of recipients" do
fab!(:pm) { Fabricate(:private_message_topic, user: user) }
fab!(:moderator_pm) { Fabricate(:private_message_topic, user: moderator) }
@@ -4098,7 +4095,7 @@ RSpec.describe TopicsController do
end
end
- describe 'when user does not have permission to invite to the topic' do
+ context 'when user does not have permission to invite to the topic' do
fab!(:topic) { pm }
it "should return the right response" do
@@ -4111,7 +4108,7 @@ RSpec.describe TopicsController do
end
end
- describe "when inviting a group to a topic" do
+ context "when inviting a group to a topic" do
fab!(:group) { Fabricate(:group) }
before do
@@ -4146,22 +4143,22 @@ RSpec.describe TopicsController do
admins.update!(messageable_level: Group::ALIAS_LEVELS[:everyone])
end
- describe 'as an anon user' do
+ context 'as an anon user' do
it 'should be forbidden' do
invite_group(pm, 403)
end
end
- describe 'as a normal user' do
+ context 'as a normal user' do
before { sign_in(user) }
- describe 'when user does not have permission to view the topic' do
+ context 'when user does not have permission to view the topic' do
it 'should be forbidden' do
invite_group(pm, 403)
end
end
- describe 'when user has permission to view the topic' do
+ context 'when user has permission to view the topic' do
before do
pm.allowed_users << user
end
@@ -4173,7 +4170,7 @@ RSpec.describe TopicsController do
end
end
- describe 'as an admin user' do
+ context 'as an admin user' do
before do
sign_in(admin)
end
@@ -4228,7 +4225,7 @@ RSpec.describe TopicsController do
fab!(:other_cat) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, category: shared_drafts_category, visible: false) }
- context "anonymous" do
+ context "when anonymous" do
it "doesn't allow staff to update the shared draft" do
put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id }
expect(response.code.to_i).to eq(403)
@@ -4366,7 +4363,7 @@ RSpec.describe TopicsController do
expect(body).to include('<link rel="prev" href="' + topic.relative_url + "?page=2")
end
- context "canonical_url" do
+ context "with canonical_url" do
fab!(:topic_embed) { Fabricate(:topic_embed, embed_url: "https://markvanlan.com") }
let!(:user_agent) { "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" }
@@ -4382,7 +4379,7 @@ RSpec.describe TopicsController do
end
end
- context "wayback machine" do
+ context "with wayback machine" do
it "renders crawler layout" do
get topic.url, env: { "HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", "HTTP_VIA" => "HTTP/1.0 web.archive.org (Wayback Save Page)" }
body = response.body
@@ -4395,7 +4392,7 @@ RSpec.describe TopicsController do
end
describe "#reset_bump_date" do
- context "errors" do
+ context "with errors" do
it "needs you to be logged in" do
put "/t/#{topic.id}/reset-bump-date.json"
expect(response.status).to eq(403)
diff --git a/spec/requests/uploads_controller_spec.rb b/spec/requests/uploads_controller_spec.rb
index f0a4fef5ef6..63f48e41339 100644
--- a/spec/requests/uploads_controller_spec.rb
+++ b/spec/requests/uploads_controller_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe UploadsController do
expect(response.status).to eq(403)
end
- context 'logged in' do
+ context 'when logged in' do
before do
sign_in(user)
end
@@ -308,8 +308,8 @@ RSpec.describe UploadsController do
.to eq(%Q|attachment; filename="#{upload.original_filename}"; filename*=UTF-8''#{upload.original_filename}|)
end
- context "prevent anons from downloading files" do
- it "returns 404 when an anonymous user tries to download a file" do
+ context "when user is anonymous" do
+ it "returns 404" do
upload = upload_file("small.pdf", "pdf")
delete "/session/#{user.username}.json"
diff --git a/spec/requests/user_api_keys_controller_spec.rb b/spec/requests/user_api_keys_controller_spec.rb
index 8c72463d549..c7f5824f745 100644
--- a/spec/requests/user_api_keys_controller_spec.rb
+++ b/spec/requests/user_api_keys_controller_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe UserApiKeysController do
-
let :public_key do
<<~TXT
-----BEGIN PUBLIC KEY-----
@@ -44,7 +43,7 @@ RSpec.describe UserApiKeysController do
}
end
- context 'new' do
+ describe '#new' do
it "supports a head request cleanly" do
head "/user-api-key/new"
expect(response.status).to eq(200)
@@ -52,8 +51,7 @@ RSpec.describe UserApiKeysController do
end
end
- context 'create' do
-
+ describe '#create' do
it "does not allow anon" do
post "/user-api-key.json", params: args
expect(response.status).to eq(403)
diff --git a/spec/requests/user_avatars_controller_spec.rb b/spec/requests/user_avatars_controller_spec.rb
index 307a92b2a33..9a59f660e34 100644
--- a/spec/requests/user_avatars_controller_spec.rb
+++ b/spec/requests/user_avatars_controller_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe UserAvatarsController do
- context 'show_proxy_letter' do
+ describe '#show_proxy_letter' do
it 'returns not found if external avatar is set somewhere else' do
SiteSetting.external_system_avatars_url = "https://somewhere.else.com/avatar.png"
get "/letter_avatar_proxy/v2/letter/a/aaaaaa/20.png"
@@ -15,8 +15,8 @@ RSpec.describe UserAvatarsController do
end
end
- context 'show' do
- context 'invalid' do
+ describe '#show' do
+ context 'when invalid' do
after do
FileUtils.rm(Discourse.store.path_for(upload))
end
diff --git a/spec/requests/user_badges_controller_spec.rb b/spec/requests/user_badges_controller_spec.rb
index 55631aedb16..119c6de0fae 100644
--- a/spec/requests/user_badges_controller_spec.rb
+++ b/spec/requests/user_badges_controller_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe UserBadgesController do
fab!(:admin) { Fabricate(:admin) }
fab!(:badge) { Fabricate(:badge) }
- context 'index' do
+ describe '#index' do
fab!(:badge) { Fabricate(:badge, target_posts: true, show_posts: false) }
it 'does not leak private info' do
p = create_post
@@ -27,7 +27,7 @@ RSpec.describe UserBadgesController do
end
end
- context 'index' do
+ describe '#index' do
let!(:user_badge) { UserBadge.create(badge: badge, user: user, granted_by: Discourse.system_user, granted_at: Time.now) }
it 'requires username or badge_id to be specified' do
@@ -70,7 +70,7 @@ RSpec.describe UserBadgesController do
expect(parsed["user_badges"].first.has_key?('count')).to eq(true)
end
- context 'hidden profiles' do
+ context 'with hidden profiles' do
before do
user.user_option.update_columns(hide_profile_and_presence: true)
end
@@ -89,7 +89,7 @@ RSpec.describe UserBadgesController do
end
end
- context 'create' do
+ describe '#create' do
it 'requires username to be specified' do
post "/user_badges.json", params: { badge_id: badge.id }
expect(response.status).to eq(400)
@@ -233,7 +233,7 @@ RSpec.describe UserBadgesController do
end
end
- context 'destroy' do
+ describe '#destroy' do
let!(:user_badge) { UserBadge.create(badge: badge, user: user, granted_by: Discourse.system_user, granted_at: Time.now) }
it 'checks that the user is authorized to revoke a badge' do
@@ -261,7 +261,7 @@ RSpec.describe UserBadgesController do
end
end
- context "favorite" do
+ describe "#favorite" do
let!(:user_badge) { UserBadge.create(badge: badge, user: user, granted_by: Discourse.system_user, granted_at: Time.now) }
it "checks that the user is authorized to favorite the badge" do
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 25bc0c57ee1..69b493817ac 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe UsersController do
UsersController.any_instance.stubs(:honeypot_or_challenge_fails?).returns(false)
end
- context 'invalid token' do
+ context 'with invalid token' do
it 'return success' do
put "/u/activate-account/invalid-tooken"
expect(response.status).to eq(200)
@@ -67,8 +67,8 @@ RSpec.describe UsersController do
end
end
- context 'valid token' do
- context 'welcome message' do
+ context 'with valid token' do
+ context 'with welcome message' do
it 'enqueues a welcome message if the user object indicates so' do
SiteSetting.send_welcome_message = true
user_deferred.update(active: false)
@@ -86,7 +86,7 @@ RSpec.describe UsersController do
end
end
- context "honeypot" do
+ context "with honeypot" do
it "raises an error if the honeypot is invalid" do
UsersController.any_instance.stubs(:honeypot_or_challenge_fails?).returns(true)
put "/u/activate-account/#{email_token.token}"
@@ -94,7 +94,7 @@ RSpec.describe UsersController do
end
end
- context 'response' do
+ context 'with response' do
it 'correctly logs on user' do
email_token
@@ -115,7 +115,7 @@ RSpec.describe UsersController do
end
end
- context 'user is not approved' do
+ context 'when user is not approved' do
before do
SiteSetting.must_approve_users = true
end
@@ -169,7 +169,7 @@ RSpec.describe UsersController do
describe '#password_reset' do
let(:token) { SecureRandom.hex }
- context "you can view it even if login is required" do
+ context "when login is required" do
it "returns success" do
SiteSetting.login_required = true
get "/u/password-reset/#{token}"
@@ -178,7 +178,7 @@ RSpec.describe UsersController do
end
end
- context 'missing token' do
+ context 'with missing token' do
it 'disallows login' do
get "/u/password-reset/#{token}"
@@ -203,7 +203,7 @@ RSpec.describe UsersController do
end
end
- context 'invalid token' do
+ context 'with invalid token' do
it 'disallows login' do
get "/u/password-reset/ev!l_trout@!"
@@ -228,7 +228,7 @@ RSpec.describe UsersController do
end
end
- context 'valid token' do
+ context 'with valid token' do
let!(:user_auth_token) { UserAuthToken.generate!(user_id: user1.id) }
let!(:email_token) { Fabricate(:email_token, user: user1, scope: EmailToken.scopes[:password_reset]) }
@@ -308,7 +308,7 @@ RSpec.describe UsersController do
expect(UserAuthToken.where(id: user_auth_token.id).count).to eq(1)
end
- context "rate limiting" do
+ context "with rate limiting" do
before { RateLimiter.clear_all!; RateLimiter.enable }
it "rate limits reset passwords" do
@@ -352,7 +352,7 @@ RSpec.describe UsersController do
end
end
- context '2 factor authentication required' do
+ context 'when 2 factor authentication is required' do
fab!(:second_factor) { Fabricate(:user_second_factor_totp, user: user1) }
it 'does not change with an invalid token' do
@@ -394,7 +394,7 @@ RSpec.describe UsersController do
end
end
- context 'security key authentication required' do
+ context 'when security key authentication is required' do
let!(:user_security_key) do
Fabricate(
:user_security_key,
@@ -472,7 +472,7 @@ RSpec.describe UsersController do
end
end
- context 'submit change' do
+ context 'with submit change' do
let(:email_token) { Fabricate(:email_token, user: user1, scope: EmailToken.scopes[:password_reset]) }
it "fails when the password is blank" do
@@ -527,14 +527,12 @@ RSpec.describe UsersController do
end
describe '#admin_login' do
- context 'enqueues mail' do
- it 'enqueues mail with admin email and sso enabled' do
- put "/u/admin-login", params: { email: admin.email }
- expect(response.status).to eq(200)
- expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
- args = Jobs::CriticalUserEmail.jobs.first["args"].first
- expect(args["user_id"]).to eq(admin.id)
- end
+ it 'enqueues mail with admin email and sso enabled' do
+ put "/u/admin-login", params: { email: admin.email }
+ expect(response.status).to eq(200)
+ expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
+ args = Jobs::CriticalUserEmail.jobs.first["args"].first
+ expect(args["user_id"]).to eq(admin.id)
end
context 'when email is incorrect' do
@@ -765,7 +763,7 @@ RSpec.describe UsersController do
expect(args["type"]).to eq("signup")
end
- context "`must approve users` site setting is enabled" do
+ context "when `must approve users` site setting is enabled" do
before { SiteSetting.must_approve_users = true }
it 'creates a user correctly' do
@@ -786,7 +784,7 @@ RSpec.describe UsersController do
end
end
- context 'users already exists with given email' do
+ context 'when users already exists with given email' do
let!(:existing) { Fabricate(:user, email: post_user_params[:email]) }
it 'returns an error if hide_email_address_taken is disabled' do
@@ -828,7 +826,7 @@ RSpec.describe UsersController do
end
end
- context "creating as active" do
+ context "when creating as active" do
it "won't create the user as active" do
post "/u.json", params: post_user_params.merge(active: true)
expect(response.status).to eq(200)
@@ -938,7 +936,7 @@ RSpec.describe UsersController do
end
end
- context "creating as staged" do
+ context "when creating as staged" do
it "won't create the user as staged" do
post "/u.json", params: post_user_params.merge(staged: true)
expect(response.status).to eq(200)
@@ -1029,7 +1027,7 @@ RSpec.describe UsersController do
expect(json['message']).to be_present
end
- context 'authentication records for' do
+ context 'with authentication records for' do
before do
OmniAuth.config.test_mode = true
@@ -1653,14 +1651,14 @@ RSpec.describe UsersController do
expect(response.status).to eq(200)
end
- context 'username is available' do
+ context 'when username is available' do
before do
get "/u/check_username.json", params: { username: 'BruceWayne' }
end
include_examples 'when username is available'
end
- context 'username is unavailable' do
+ context 'when username is unavailable' do
before do
get "/u/check_username.json", params: { username: user1.username }
end
@@ -1675,7 +1673,7 @@ RSpec.describe UsersController do
end
end
- context 'has invalid characters' do
+ context 'when has invalid characters' do
before do
get "/u/check_username.json", params: { username: 'bad username' }
end
@@ -1687,7 +1685,7 @@ RSpec.describe UsersController do
end
end
- context 'is too long' do
+ context 'when is too long' do
before do
get "/u/check_username.json", params: { username: SecureRandom.alphanumeric(SiteSetting.max_username_length.to_i + 1) }
end
@@ -1700,7 +1698,7 @@ RSpec.describe UsersController do
end
describe 'different case of existing username' do
- context "it's my username" do
+ context "when it's my username" do
fab!(:user) { Fabricate(:user, username: 'hansolo') }
before do
sign_in(user)
@@ -1710,7 +1708,7 @@ RSpec.describe UsersController do
include_examples 'when username is available'
end
- context "it's someone else's username" do
+ context "when it's someone else's username" do
fab!(:user) { Fabricate(:user, username: 'hansolo') }
fab!(:someone_else) { Fabricate(:user) }
before do
@@ -1721,7 +1719,7 @@ RSpec.describe UsersController do
include_examples 'when username is unavailable'
end
- context "an admin changing it for someone else" do
+ context "when an admin changing it for someone else" do
fab!(:user) { Fabricate(:user, username: 'hansolo') }
before do
sign_in(admin)
@@ -2005,7 +2003,7 @@ RSpec.describe UsersController do
end
context "as a staff user" do
- context "uneditable field" do
+ context "with uneditable field" do
fab!(:user_field) { Fabricate(:user_field, editable: false) }
it "allows staff to edit the field" do
@@ -2096,7 +2094,7 @@ RSpec.describe UsersController do
expect(response.parsed_body['user']['watched_tags'].count).to eq(2)
end
- context 'a locale is chosen that differs from I18n.locale' do
+ context 'when a locale is chosen that differs from I18n.locale' do
before do
SiteSetting.allow_user_locale = true
end
@@ -2123,7 +2121,7 @@ RSpec.describe UsersController do
end
context "with user fields" do
- context "an editable field" do
+ context "with an editable field" do
fab!(:user_field) { Fabricate(:user_field) }
fab!(:optional_field) { Fabricate(:user_field, required: false) }
@@ -2197,7 +2195,7 @@ RSpec.describe UsersController do
end
end
- context "uneditable field" do
+ context "with uneditable field" do
fab!(:user_field) { Fabricate(:user_field, editable: false) }
it "does not update the user field" do
@@ -2208,7 +2206,7 @@ RSpec.describe UsersController do
end
end
- context "custom_field" do
+ context "with custom_field" do
before do
plugin = Plugin::Instance.new
plugin.register_editable_user_custom_field :test2
@@ -2298,7 +2296,7 @@ RSpec.describe UsersController do
expect(json['user']['id']).to eq user.id
end
- context 'experimental sidebar' do
+ context 'with experimental sidebar' do
before do
SiteSetting.enable_experimental_sidebar_hamburger = true
end
@@ -2573,7 +2571,7 @@ RSpec.describe UsersController do
end
end
- context "approval is enabled" do
+ context "when approval is enabled" do
before do
SiteSetting.must_approve_users = true
end
@@ -2848,7 +2846,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(422)
end
- context 'selectable avatars is enabled' do
+ context 'when selectable avatars is enabled' do
before do
SiteSetting.selectable_avatars = [avatar1, avatar2]
@@ -2861,7 +2859,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(422)
end
- context 'selectable avatars is properly setup' do
+ context 'when selectable avatars is properly setup' do
it 'raises an error when url is not in selectable avatars list' do
put "/u/#{user1.username}/preferences/avatar/select.json", params: { url: url }
expect(response.status).to eq(422)
@@ -3463,14 +3461,14 @@ RSpec.describe UsersController do
end
describe '#topic_tracking_state' do
- context 'anon' do
+ context 'when anon' do
it "raises an error on anon for topic_tracking_state" do
get "/u/#{user1.username}/topic-tracking-state.json"
expect(response.status).to eq(403)
end
end
- context 'logged on' do
+ context 'when logged on' do
it "detects new topic" do
sign_in(user1)
@@ -3497,7 +3495,7 @@ RSpec.describe UsersController do
expect(json["user_summary"]["post_count"]).to eq(0)
end
- context '`hide_profile_and_presence` user option is checked' do
+ context 'when `hide_profile_and_presence` user option is checked' do
before_all do
user1.user_option.update_columns(hide_profile_and_presence: true)
end
@@ -3515,7 +3513,7 @@ RSpec.describe UsersController do
end
end
- context 'avatar flair in Most... sections' do
+ context 'with avatar flair in Most... sections' do
it "returns data for automatic groups flair" do
liker = Fabricate(:user, admin: true, moderator: true, trust_level: 1)
create_and_like_post(user_deferred, liker)
@@ -3831,7 +3829,7 @@ RSpec.describe UsersController do
end
describe '#show' do
- context "anon" do
+ context "when anon" do
let(:user) { Discourse.system_user }
it "returns success" do
@@ -3876,7 +3874,7 @@ RSpec.describe UsersController do
end
end
- context "logged in" do
+ context "when logged in" do
before do
sign_in(user1)
end
@@ -3932,7 +3930,7 @@ RSpec.describe UsersController do
end
end
- context "fetching a user by external_id" do
+ context "when fetching a user by external_id" do
before { user1.create_single_sign_on_record(external_id: '997', last_payload: '') }
it "returns fetch for a matching external_id" do
@@ -4036,7 +4034,7 @@ RSpec.describe UsersController do
end
describe "#show_card" do
- context "anon" do
+ context "when anon" do
let(:user) { Discourse.system_user }
it "returns success" do
@@ -4056,7 +4054,7 @@ RSpec.describe UsersController do
end
end
- context "logged in" do
+ context "when logged in" do
before do
sign_in(user1)
end
@@ -4102,7 +4100,7 @@ RSpec.describe UsersController do
expect(response).to redirect_to '/login'
end
- context '`hide_profile_and_presence` user option is checked' do
+ context 'when `hide_profile_and_presence` user option is checked' do
before do
user2.user_option.update_columns(hide_profile_and_presence: true)
end
@@ -4260,7 +4258,7 @@ RSpec.describe UsersController do
expect(response.status).to eq(200)
end
- context 'limit' do
+ context 'with limit' do
it "returns an error if value is invalid" do
get "/u/search/users.json", params: { limit: '-1' }
expect(response.status).to eq(400)
@@ -4291,7 +4289,7 @@ RSpec.describe UsersController do
end
end
- context 'groups' do
+ context 'with groups' do
fab!(:mentionable_group) do
Fabricate(:group,
mentionable_level: Group::ALIAS_LEVELS[:everyone],
@@ -4501,7 +4499,7 @@ RSpec.describe UsersController do
end
end
- context '`include_staged_users`' do
+ context 'with `include_staged_users`' do
it "includes staged users when the param is true" do
get "/u/search/users.json", params: { term: staged_user.name, include_staged_users: true }
json = response.parsed_body
@@ -4521,7 +4519,7 @@ RSpec.describe UsersController do
end
end
- context '`last_seen_users`' do
+ context 'with `last_seen_users`' do
it "returns results when the param is true" do
get "/u/search/users.json", params: { last_seen_users: true }
diff --git a/spec/requests/users_email_controller_spec.rb b/spec/requests/users_email_controller_spec.rb
index aa1e6dce57b..655d302e177 100644
--- a/spec/requests/users_email_controller_spec.rb
+++ b/spec/requests/users_email_controller_spec.rb
@@ -3,7 +3,6 @@
require 'rotp'
RSpec.describe UsersEmailController do
-
fab!(:user) { Fabricate(:user) }
let!(:email_token) { Fabricate(:email_token, user: user) }
fab!(:moderator) { Fabricate(:moderator) }
@@ -77,7 +76,7 @@ RSpec.describe UsersEmailController do
expect(user.email).to eq('[email protected]')
end
- context 'second factor required' do
+ context 'when second factor is required' do
fab!(:second_factor) { Fabricate(:user_second_factor_totp, user: user) }
fab!(:backup_code) { Fabricate(:user_second_factor_backup, user: user) }
@@ -118,7 +117,7 @@ RSpec.describe UsersEmailController do
expect(user.reload.email).to eq('[email protected]')
end
- context "rate limiting" do
+ context "with rate limiting" do
before { RateLimiter.clear_all!; RateLimiter.enable }
it "rate limits by IP" do
@@ -169,7 +168,7 @@ RSpec.describe UsersEmailController do
end
end
- context "security key required" do
+ context "when security key is required" do
fab!(:user_security_key) do
Fabricate(
:user_security_key,
@@ -273,7 +272,7 @@ RSpec.describe UsersEmailController do
expect(body).to include("alert-error")
end
- context 'valid old token' do
+ context 'with valid old token' do
it 'confirms with a correct token' do
sign_in(moderator)
updater = EmailUpdater.new(guardian: moderator.guardian, user: moderator)
@@ -341,7 +340,7 @@ RSpec.describe UsersEmailController do
context 'when the new email address is taken' do
fab!(:other_user) { Fabricate(:coding_horror) }
- context 'hide_email_address_taken is disabled' do
+ context 'when hide_email_address_taken is disabled' do
before do
SiteSetting.hide_email_address_taken = false
end
@@ -357,7 +356,7 @@ RSpec.describe UsersEmailController do
end
end
- context 'hide_email_address_taken is enabled' do
+ context 'when hide_email_address_taken is enabled' do
before do
SiteSetting.hide_email_address_taken = true
end
@@ -392,7 +391,7 @@ RSpec.describe UsersEmailController do
expect(response).to_not be_successful
end
- context 'success' do
+ context 'with success' do
it 'has an email token' do
expect do
put "/u/#{user.username}/preferences/email.json", params: { email: '[email protected]' }
diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rb
index 95596b7f3e9..070c8039924 100644
--- a/spec/requests/webhooks_controller_spec.rb
+++ b/spec/requests/webhooks_controller_spec.rb
@@ -6,8 +6,7 @@ RSpec.describe WebhooksController do
let(:email) { "[email protected]" }
let(:message_id) { "[email protected]" }
- context "mailgun" do
-
+ describe "#mailgun" do
let(:token) { "705a8ccd2ce932be8e98c221fe701c1b4a0afcb8bbd57726de" }
let(:timestamp) { Time.now.to_i }
let(:data) { "#{timestamp}#{token}" }
@@ -81,7 +80,7 @@ RSpec.describe WebhooksController do
end
end
- context "sendgrid" do
+ describe "#sendgrid" do
it "works" do
user = Fabricate(:user, email: email)
email_log = Fabricate(:email_log, user: user, message_id: message_id, to_address: email)
@@ -106,7 +105,7 @@ RSpec.describe WebhooksController do
end
end
- context "mailjet" do
+ describe "#mailjet" do
it "works" do
user = Fabricate(:user, email: email)
email_log = Fabricate(:email_log, user: user, message_id: message_id, to_address: email)
@@ -127,7 +126,7 @@ RSpec.describe WebhooksController do
end
end
- context "mandrill" do
+ describe "#mandrill" do
it "works" do
user = Fabricate(:user, email: email)
email_log = Fabricate(:email_log, user: user, message_id: message_id, to_address: email)
@@ -155,7 +154,7 @@ RSpec.describe WebhooksController do
end
end
- context "mandrill_head" do
+ describe "#mandrill_head" do
it "works" do
head "/webhooks/mandrill.json"
@@ -163,7 +162,7 @@ RSpec.describe WebhooksController do
end
end
- context "postmark" do
+ describe "#postmark" do
it "works" do
user = Fabricate(:user, email: email)
email_log = Fabricate(:email_log, user: user, message_id: message_id, to_address: email)
@@ -198,7 +197,7 @@ RSpec.describe WebhooksController do
end
end
- context "sparkpost" do
+ describe "#sparkpost" do
it "works" do
user = Fabricate(:user, email: email)
email_log = Fabricate(:email_log, user: user, message_id: message_id, to_address: email)
diff --git a/spec/requests/wizard_controller_spec.rb b/spec/requests/wizard_controller_spec.rb
index a540c08b3c6..afdad545a96 100644
--- a/spec/requests/wizard_controller_spec.rb
+++ b/spec/requests/wizard_controller_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe WizardController do
- context 'wizard enabled' do
+ context 'when wizard is enabled' do
before do
SiteSetting.wizard_enabled = true
end
diff --git a/spec/script/import_scripts/phpbb3/support/bbcode/xml_to_markdown_spec.rb b/spec/script/import_scripts/phpbb3/support/bbcode/xml_to_markdown_spec.rb
index 00e6034611f..2fc51e546bd 100644
--- a/spec/script/import_scripts/phpbb3/support/bbcode/xml_to_markdown_spec.rb
+++ b/spec/script/import_scripts/phpbb3/support/bbcode/xml_to_markdown_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
expect(convert(xml)).to eq('_this is italic **and bold** text_')
end
- context "bold text" do
+ context "with bold text" do
it "converts bold text" do
xml = '<r><B><s>[b]</s>this is bold text<e>[/b]</e></B></r>'
expect(convert(xml)).to eq('**this is bold text**')
@@ -51,7 +51,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "italic text" do
+ context "with italic text" do
it "converts italic text" do
xml = '<r><I><s>[i]</s>this is italic text<e>[/i]</e></I></r>'
expect(convert(xml)).to eq('_this is italic text_')
@@ -85,7 +85,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "underlined text" do
+ context "with underlined text" do
it "converts underlined text" do
xml = '<r><U><s>[u]</s>this is underlined text<e>[/u]</e></U></r>'
expect(convert(xml)).to eq('[u]this is underlined text[/u]')
@@ -119,8 +119,8 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "code blocks" do
- context "inline code blocks enabled" do
+ context "with code blocks" do
+ context "with inline code blocks enabled" do
let(:opts) { { allow_inline_code: true } }
it "converts single line code blocks" do
@@ -129,7 +129,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "inline code blocks disabled" do
+ context "with inline code blocks disabled" do
it "converts single line code blocks" do
xml = '<r>foo <CODE><s>[code]</s>some code<e>[/code]</e></CODE> bar</r>'
@@ -190,7 +190,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "lists" do
+ context "with lists" do
it "converts unordered lists" do
xml = <<~XML
<r><LIST><s>[list]</s>
@@ -306,7 +306,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "images" do
+ context "with images" do
it "converts image" do
xml = <<~XML
<r><IMG src="https://example.com/foo.png"><s>[img]</s>
@@ -330,7 +330,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "links" do
+ context "with links" do
it "converts links created without BBCode" do
xml = '<r><URL url="https://en.wikipedia.org/wiki/Capybara">https://en.wikipedia.org/wiki/Capybara</URL></r>'
expect(convert(xml)).to eq('https://en.wikipedia.org/wiki/Capybara')
@@ -391,7 +391,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "quotes" do
+ context "with quotes" do
it "converts simple quote" do
xml = <<~XML
<r><QUOTE><s>[quote]</s>Lorem<br/>
@@ -603,7 +603,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
expect(convert(xml, opts)).to eq(":smiley: :astonished:")
end
- context "attachments" do
+ context "with attachments" do
it "converts attachments" do
opts = {
upload_md_from_file: lambda do |filename, index|
@@ -639,7 +639,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "line breaks" do
+ context "with line breaks" do
it "converts line breaks" do
xml = <<~XML
<t>Lorem ipsum dolor sit amet.<br/>
@@ -745,7 +745,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "whitespace" do
+ context "with whitespace" do
it "doesn't strip whitespaces from inline tags" do
xml = <<~XML
<r>Lorem<B><s>[b]</s> ipsum <e>[/b]</e></B>dolor<br/>
@@ -766,7 +766,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "unknown element" do
+ context "with unknown element" do
it "converts an unknown element right below the root element" do
xml = '<r><UNKNOWN><s>[unknown]</s>foo<e>[/unknown]</e></UNKNOWN></r>'
expect(convert(xml)).to eq('foo')
@@ -778,7 +778,7 @@ RSpec.describe ImportScripts::PhpBB3::BBCode::XmlToMarkdown do
end
end
- context "font size" do
+ context "with font size" do
it "converts sizes to either <small> or <big>" do
xml = <<~XML
<r><SIZE size="50"><s>[size=50]</s>very small<e>[/size]</e></SIZE><br/>
diff --git a/spec/serializers/about_serializer_spec.rb b/spec/serializers/about_serializer_spec.rb
index f9ea686dd09..bbf4b1edcc0 100644
--- a/spec/serializers/about_serializer_spec.rb
+++ b/spec/serializers/about_serializer_spec.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
RSpec.describe AboutSerializer do
-
fab!(:user) { Fabricate(:user) }
- context "login_required is enabled" do
+ context "when login_required is enabled" do
before do
SiteSetting.login_required = true
SiteSetting.contact_url = "https://example.com/contact"
@@ -24,7 +23,7 @@ RSpec.describe AboutSerializer do
end
end
- context "login_required is disabled" do
+ context "when login_required is disabled" do
before do
SiteSetting.login_required = false
SiteSetting.contact_url = "https://example.com/contact"
diff --git a/spec/serializers/admin_user_list_serializer_spec.rb b/spec/serializers/admin_user_list_serializer_spec.rb
index c85c9e8743b..955e726719e 100644
--- a/spec/serializers/admin_user_list_serializer_spec.rb
+++ b/spec/serializers/admin_user_list_serializer_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe AdminUserListSerializer do
end
end
- context "emails" do
+ describe "emails" do
fab!(:admin) { Fabricate(:user, admin: true, email: "[email protected]") }
fab!(:moderator) { Fabricate(:user, moderator: true, email: "[email protected]") }
fab!(:user) { Fabricate(:user, email: "[email protected]") }
diff --git a/spec/serializers/basic_post_serializer_spec.rb b/spec/serializers/basic_post_serializer_spec.rb
index 46945d3dbe9..db694fb39e0 100644
--- a/spec/serializers/basic_post_serializer_spec.rb
+++ b/spec/serializers/basic_post_serializer_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe BasicPostSerializer do
- context "name" do
+ describe "#name" do
let(:user) { Fabricate.build(:user) }
let(:post) { Fabricate.build(:post, user: user) }
let(:serializer) { BasicPostSerializer.new(post, scope: Guardian.new, root: false) }
@@ -17,7 +17,5 @@ RSpec.describe BasicPostSerializer do
SiteSetting.enable_names = false
expect(json[:name]).to be_blank
end
-
end
-
end
diff --git a/spec/serializers/emoji_serializer_spec.rb b/spec/serializers/emoji_serializer_spec.rb
index 3aaef42de6e..6c70de3fe15 100644
--- a/spec/serializers/emoji_serializer_spec.rb
+++ b/spec/serializers/emoji_serializer_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe EmojiSerializer do
end
end
- context "missing uploads" do
+ describe "missing uploads" do
before do
custom_emoji.upload.destroy!
end
@@ -45,7 +45,5 @@ RSpec.describe EmojiSerializer do
expect(result[:url]).to be_blank
end
-
end
-
end
diff --git a/spec/serializers/group_show_serializer_spec.rb b/spec/serializers/group_show_serializer_spec.rb
index acdd054bc22..76cb00f6342 100644
--- a/spec/serializers/group_show_serializer_spec.rb
+++ b/spec/serializers/group_show_serializer_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe GroupShowSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:group) { Fabricate(:group) }
- context 'admin user' do
+ context 'with an admin user' do
fab!(:user) { Fabricate(:admin) }
fab!(:group) { Fabricate(:group, users: [user]) }
@@ -16,7 +16,7 @@ RSpec.describe GroupShowSerializer do
end
end
- context 'group owner' do
+ context 'with a group owner' do
before do
group.add_owner(user)
end
@@ -62,7 +62,7 @@ RSpec.describe GroupShowSerializer do
fab!(:group) { Fabricate(:group, email_username: '[email protected]', email_password: 'pa$$w0rd') }
subject { described_class.new(group, scope: guardian, root: false) }
- describe 'for a user' do
+ context 'for a user' do
let(:guardian) { Guardian.new(Fabricate(:user)) }
it 'are not visible' do
@@ -71,7 +71,7 @@ RSpec.describe GroupShowSerializer do
end
end
- describe 'for an admin' do
+ context 'for an admin' do
let(:guardian) { Guardian.new(Fabricate(:admin)) }
it 'are visible' do
@@ -114,7 +114,7 @@ RSpec.describe GroupShowSerializer do
)
end
- describe "for a user" do
+ context "for a user" do
let(:guardian) { Guardian.new(Fabricate(:user)) }
it "are not visible" do
@@ -123,7 +123,7 @@ RSpec.describe GroupShowSerializer do
end
end
- describe "for admin" do
+ context "for admin" do
let(:guardian) { Guardian.new(Fabricate(:admin)) }
it "are correct" do
diff --git a/spec/serializers/post_revision_serializer_spec.rb b/spec/serializers/post_revision_serializer_spec.rb
index 0c305382136..37e13340171 100644
--- a/spec/serializers/post_revision_serializer_spec.rb
+++ b/spec/serializers/post_revision_serializer_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe PostRevisionSerializer do
fab!(:post) { Fabricate(:post, version: 2) }
- context 'hidden tags' do
+ context 'with hidden tags' do
fab!(:public_tag) { Fabricate(:tag, name: 'public') }
fab!(:public_tag2) { Fabricate(:tag, name: 'visible') }
fab!(:hidden_tag) { Fabricate(:tag, name: 'hidden') }
diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb
index f9849649e3f..e47a83c104f 100644
--- a/spec/serializers/post_serializer_spec.rb
+++ b/spec/serializers/post_serializer_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe PostSerializer do
fab!(:post) { Fabricate(:post) }
- context "a post with lots of actions" do
+ context "with a post with lots of actions" do
fab!(:actor) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
let(:acted_ids) {
@@ -57,7 +57,7 @@ RSpec.describe PostSerializer do
end
end
- context "a post with reviewable content" do
+ context "with a post with reviewable content" do
let!(:reviewable) { PostActionCreator.spam(Fabricate(:user), post).reviewable }
it "includes the reviewable data" do
@@ -68,7 +68,7 @@ RSpec.describe PostSerializer do
end
end
- context "a post by a nuked user" do
+ context "with a post by a nuked user" do
before do
post.update!(
user_id: nil,
@@ -88,7 +88,7 @@ RSpec.describe PostSerializer do
end
end
- context "a post by a suspended user" do
+ context "with a post by a suspended user" do
def subject
PostSerializer.new(post, scope: Guardian.new(Fabricate(:admin)), root: false).as_json
end
@@ -108,7 +108,7 @@ RSpec.describe PostSerializer do
end
end
- context "display_username" do
+ describe "#display_username" do
let(:user) { post.user }
let(:serializer) { PostSerializer.new(post, scope: Guardian.new, root: false) }
let(:json) { serializer.as_json }
@@ -124,11 +124,11 @@ RSpec.describe PostSerializer do
end
end
- context "a hidden post with add_raw enabled" do
+ context "with a hidden post with add_raw enabled" do
let(:user) { Fabricate.build(:user, id: -99999) }
let(:raw) { "Raw contents of the post." }
- context "a public post" do
+ context "with a public post" do
let(:post) { Fabricate.build(:post, raw: raw, user: user) }
it "includes the raw post for everyone" do
@@ -138,7 +138,7 @@ RSpec.describe PostSerializer do
end
end
- context "a hidden post" do
+ context "with a hidden post" do
let(:post) { Fabricate.build(:post, raw: raw, user: user, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
it "shows the raw post only if authorized to see it" do
@@ -160,7 +160,7 @@ RSpec.describe PostSerializer do
end
end
- context "a hidden revised post" do
+ context "with a hidden revised post" do
fab!(:post) { Fabricate(:post, raw: 'Hello world!', hidden: true) }
before do
@@ -181,7 +181,7 @@ RSpec.describe PostSerializer do
end
end
- context "a public wiki post" do
+ context "with a public wiki post" do
let(:post) { Fabricate.build(:post, raw: raw, user: user, wiki: true) }
it "can view edit history" do
@@ -191,7 +191,7 @@ RSpec.describe PostSerializer do
end
end
- context "a hidden wiki post" do
+ context "with a hidden wiki post" do
let(:post) {
Fabricate.build(
:post,
@@ -213,7 +213,7 @@ RSpec.describe PostSerializer do
end
- context "a post with notices" do
+ context "with a post with notices" do
fab!(:user) { Fabricate(:user, trust_level: 1) }
fab!(:user_tl1) { Fabricate(:user, trust_level: 1) }
fab!(:user_tl2) { Fabricate(:user, trust_level: 2) }
@@ -243,7 +243,7 @@ RSpec.describe PostSerializer do
end
end
- context "post with bookmarks" do
+ context "with a post with bookmarks" do
let(:current_user) { Fabricate(:user) }
let(:topic_view) { TopicView.new(post.topic, current_user) }
let(:serialized) do
@@ -256,7 +256,7 @@ RSpec.describe PostSerializer do
context "when a Bookmark record exists for the user on the post" do
let!(:bookmark) { Fabricate(:bookmark_next_business_day_reminder, user: current_user, bookmarkable: post) }
- context "bookmarks with reminders" do
+ context "with bookmarks with reminders" do
it "returns true" do
expect(serialized.as_json[:bookmarked]).to eq(true)
end
@@ -268,7 +268,7 @@ RSpec.describe PostSerializer do
end
end
- context "posts when group moderation is enabled" do
+ context "with posts when group moderation is enabled" do
fab!(:topic) { Fabricate(:topic) }
fab!(:group_user) { Fabricate(:group_user) }
fab!(:post) { Fabricate(:post, topic: topic) }
@@ -289,7 +289,7 @@ RSpec.describe PostSerializer do
end
- context "post with small action" do
+ context "with a post with small action" do
fab!(:post) { Fabricate(:small_action, action_code: "public_topic") }
it "returns `action_code` based on `login_required` site setting" do
diff --git a/spec/serializers/reviewable_queued_post_serializer_spec.rb b/spec/serializers/reviewable_queued_post_serializer_spec.rb
index c0975a0c375..09734a18852 100644
--- a/spec/serializers/reviewable_queued_post_serializer_spec.rb
+++ b/spec/serializers/reviewable_queued_post_serializer_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe ReviewableQueuedPostSerializer do
fab!(:admin) { Fabricate(:admin) }
- context "new topic" do
+ describe "new topic" do
fab!(:reviewable) { Fabricate(:reviewable_queued_post_topic) }
it "allows us to edit category / title" do
@@ -37,7 +37,7 @@ RSpec.describe ReviewableQueuedPostSerializer do
end
end
- context "reply to an existing topic" do
+ describe "reply to an existing topic" do
fab!(:reviewable) { Fabricate(:reviewable_queued_post) }
it "includes correct user fields" do
@@ -64,5 +64,4 @@ RSpec.describe ReviewableQueuedPostSerializer do
expect(raw_field[:type]).to eq(:editor)
end
end
-
end
diff --git a/spec/serializers/reviewable_score_serializer_spec.rb b/spec/serializers/reviewable_score_serializer_spec.rb
index 0e9c881f29f..1a52cbe9a8f 100644
--- a/spec/serializers/reviewable_score_serializer_spec.rb
+++ b/spec/serializers/reviewable_score_serializer_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe ReviewableScoreSerializer do
fab!(:admin) { Fabricate(:admin) }
describe '#reason' do
- context 'regular links' do
+ context 'with regular links' do
it 'adds a link for watched words' do
serialized = serialized_score('watched_word')
link_url = "#{Discourse.base_url}/admin/customize/watched_words"
@@ -25,7 +25,7 @@ RSpec.describe ReviewableScoreSerializer do
end
end
- context 'site setting links' do
+ context 'with site setting links' do
reasons = %w[
post_count trust_level new_topics_unless_trust_level fast_typer auto_silence_regex
staged must_approve_users invite_only email_spam suspect_user contains_media
diff --git a/spec/serializers/single_sign_on_record_serializer_spec.rb b/spec/serializers/single_sign_on_record_serializer_spec.rb
index 65bd6647836..be9f842ac14 100644
--- a/spec/serializers/single_sign_on_record_serializer_spec.rb
+++ b/spec/serializers/single_sign_on_record_serializer_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe SingleSignOnRecordSerializer do
SingleSignOnRecord.create!(user_id: user.id, external_id: '12345', external_email: user.email, last_payload: 'foobar')
end
- context "admin" do
+ context "with an admin" do
fab!(:admin) { Fabricate(:admin) }
let :serializer do
SingleSignOnRecordSerializer.new(sso, scope: Guardian.new(admin), root: false)
@@ -20,7 +20,7 @@ RSpec.describe SingleSignOnRecordSerializer do
end
end
- context "moderator" do
+ context "with a moderator" do
let(:moderator) { Fabricate(:moderator) }
let :serializer do
SingleSignOnRecordSerializer.new(sso, scope: Guardian.new(moderator), root: false)
diff --git a/spec/serializers/topic_view_serializer_spec.rb b/spec/serializers/topic_view_serializer_spec.rb
index 7041e5db364..75681814d82 100644
--- a/spec/serializers/topic_view_serializer_spec.rb
+++ b/spec/serializers/topic_view_serializer_spec.rb
@@ -347,7 +347,7 @@ RSpec.describe TopicViewSerializer do
end
end
- context "details" do
+ context "with details" do
it "returns the details object" do
PostCreator.create!(user, topic_id: topic.id, raw: "this is my post content")
topic.topic_links.create!(user: user, url: 'https://discourse.org', domain: 'discourse.org', clicks: 100)
@@ -398,7 +398,7 @@ RSpec.describe TopicViewSerializer do
expect(json[:details][:can_publish_page]).to eq(true)
end
- context "can_edit_tags" do
+ context "with can_edit_tags" do
before do
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_to_edit_wiki_post = 2
@@ -418,7 +418,7 @@ RSpec.describe TopicViewSerializer do
end
end
- context "can_edit" do
+ context "with can_edit" do
fab!(:group_user) { Fabricate(:group_user) }
fab!(:category) { Fabricate(:category, reviewable_by_group: group_user.group) }
fab!(:topic) { Fabricate(:topic, category: category) }
@@ -440,10 +440,10 @@ RSpec.describe TopicViewSerializer do
end
end
- context "published_page" do
+ context "with published_page" do
fab!(:published_page) { Fabricate(:published_page, topic: topic) }
- context "page publishing is disabled" do
+ context "when page publishing is disabled" do
before do
SiteSetting.enable_page_publishing = false
end
@@ -454,26 +454,26 @@ RSpec.describe TopicViewSerializer do
end
end
- context "page publishing is enabled" do
+ context "when page publishing is enabled" do
before do
SiteSetting.enable_page_publishing = true
end
- context "not staff" do
+ context "when not staff" do
it "doesn't return the published page" do
json = serialize_topic(topic, user)
expect(json[:published_page]).to be_blank
end
end
- context "staff" do
+ context "when staff" do
it "returns the published page" do
json = serialize_topic(topic, admin)
expect(json[:published_page]).to be_present
expect(json[:published_page][:slug]).to eq(published_page.slug)
end
- context "secure media is enabled" do
+ context "when secure media is enabled" do
before do
setup_s3
SiteSetting.secure_media = true
@@ -488,7 +488,7 @@ RSpec.describe TopicViewSerializer do
end
end
- context "viewing private messages when enable_category_group_moderation is enabled" do
+ context "when viewing private messages when enable_category_group_moderation is enabled" do
fab!(:pm_topic) do
Fabricate(:private_message_topic, topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: user),
@@ -509,7 +509,7 @@ RSpec.describe TopicViewSerializer do
end
describe '#user_last_posted_at' do
- context 'When the slow mode is disabled' do
+ context 'when the slow mode is disabled' do
it 'returns nil' do
Fabricate(:topic_user, user: user, topic: topic, last_posted_at: 6.hours.ago)
@@ -519,7 +519,7 @@ RSpec.describe TopicViewSerializer do
end
end
- context 'When the slow mode is enabled' do
+ context 'when the slow mode is enabled' do
before { topic.update!(slow_mode_seconds: 1000) }
it 'returns nil if no user is given' do
diff --git a/spec/serializers/wizard_serializer_spec.rb b/spec/serializers/wizard_serializer_spec.rb
index 4db13e18552..329b6a6c507 100644
--- a/spec/serializers/wizard_serializer_spec.rb
+++ b/spec/serializers/wizard_serializer_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe WizardSerializer do
ColorScheme.hex_cache.clear
end
- context "color scheme" do
+ describe "color scheme" do
it "works with base colors" do
expect(Theme.where(id: SiteSetting.default_theme_id).first&.color_scheme).to be_nil
@@ -35,7 +35,7 @@ RSpec.describe WizardSerializer do
end
end
- context "steps" do
+ describe "steps" do
let(:wizard) { Wizard::Builder.new(admin).build }
let(:serializer) { WizardSerializer.new(wizard, scope: Guardian.new(admin)) }
diff --git a/spec/services/anonymous_shadow_creator_spec.rb b/spec/services/anonymous_shadow_creator_spec.rb
index c10576db093..29b23e0924d 100644
--- a/spec/services/anonymous_shadow_creator_spec.rb
+++ b/spec/services/anonymous_shadow_creator_spec.rb
@@ -1,17 +1,15 @@
# frozen_string_literal: true
RSpec.describe AnonymousShadowCreator do
-
it "returns no shadow by default" do
expect(AnonymousShadowCreator.get(Fabricate.build(:user))).to eq(nil)
end
- context "Anonymous posting is enabled" do
+ context "when anonymous posting is enabled" do
+ fab!(:user) { Fabricate(:user, trust_level: 3) }
before { SiteSetting.allow_anonymous_posting = true }
- fab!(:user) { Fabricate(:user, trust_level: 3) }
-
it "returns no shadow if trust level is not met" do
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
end
diff --git a/spec/services/auto_silence_spec.rb b/spec/services/auto_silence_spec.rb
index 6b714d08f2b..2f0c787a950 100644
--- a/spec/services/auto_silence_spec.rb
+++ b/spec/services/auto_silence_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe SpamRule::AutoSilence do
-
before do
SiteSetting.hide_post_sensitivity = Reviewable.sensitivity[:disabled]
Reviewable.set_priorities(high: 4.0)
@@ -90,13 +89,13 @@ RSpec.describe SpamRule::AutoSilence do
end
end
- describe 'silence_user' do
+ describe '#silence_user' do
let!(:admin) { Fabricate(:admin) } # needed for SystemMessage
let(:user) { Fabricate(:user) }
let!(:post) { Fabricate(:post, user: user) }
subject { described_class.new(user) }
- context 'user is not silenced' do
+ context 'when user is not silenced' do
it 'prevents the user from making new posts' do
subject.silence_user
expect(user).to be_silenced
@@ -120,7 +119,7 @@ RSpec.describe SpamRule::AutoSilence do
end
end
- context 'user is already silenced' do
+ context 'when user is already silenced' do
before do
UserSilencer.silence(user)
end
@@ -139,7 +138,7 @@ RSpec.describe SpamRule::AutoSilence do
let(:post) { Fabricate(:post, user: user) }
let(:post2) { Fabricate(:post, user: user) }
- context "higher trust levels or staff" do
+ context "with higher trust levels or staff" do
it "should not autosilence any of them" do
PostActionCreator.spam(flagger, post)
PostActionCreator.spam(flagger2, post)
@@ -169,7 +168,7 @@ RSpec.describe SpamRule::AutoSilence do
end
end
- context 'new user' do
+ context 'with new user' do
subject { described_class.new(user) }
let(:stats) { subject.user_spam_stats }
@@ -217,7 +216,7 @@ RSpec.describe SpamRule::AutoSilence do
end
end
- context "silenced, but has higher trust level now" do
+ context "when silenced, but has higher trust level now" do
let(:user) { Fabricate(:user, silenced_till: 1.year.from_now, trust_level: TrustLevel[1]) }
subject { described_class.new(user) }
diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rb
index 4ec520cf800..ca23c204272 100644
--- a/spec/services/badge_granter_spec.rb
+++ b/spec/services/badge_granter_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe BadgeGranter do
-
fab!(:badge) { Fabricate(:badge) }
fab!(:user) { Fabricate(:user) }
@@ -390,7 +389,7 @@ RSpec.describe BadgeGranter do
end
end
- context "update_badges" do
+ describe "update_badges" do
fab!(:user) { Fabricate(:user) }
fab!(:liker) { Fabricate(:user) }
@@ -496,7 +495,7 @@ RSpec.describe BadgeGranter do
end
end
- context 'notification locales' do
+ describe 'notification locales' do
it 'is using default locales when user locales are not set' do
SiteSetting.allow_user_locale = true
expect(BadgeGranter.notification_locale('')).to eq(SiteSetting.default_locale)
diff --git a/spec/services/flag_sockpuppets_spec.rb b/spec/services/flag_sockpuppets_spec.rb
index 075da98b451..f67bd67f1aa 100644
--- a/spec/services/flag_sockpuppets_spec.rb
+++ b/spec/services/flag_sockpuppets_spec.rb
@@ -1,11 +1,10 @@
# frozen_string_literal: true
RSpec.describe SpamRule::FlagSockpuppets do
-
fab!(:user1) { Fabricate(:user, ip_address: '182.189.119.174') }
fab!(:post1) { Fabricate(:post, user: user1, topic: Fabricate(:topic, user: user1)) }
- describe 'perform' do
+ describe '#perform' do
let(:rule) { described_class.new(post1) }
subject(:perform) { rule.perform }
@@ -16,7 +15,7 @@ RSpec.describe SpamRule::FlagSockpuppets do
expect(perform).to eq(false)
end
- context 'flag_sockpuppets is enabled' do
+ context 'when flag_sockpuppets is enabled' do
before { SiteSetting.flag_sockpuppets = true }
it 'flags posts when it should' do
@@ -33,7 +32,7 @@ RSpec.describe SpamRule::FlagSockpuppets do
end
end
- describe 'reply_is_from_sockpuppet?' do
+ describe '#reply_is_from_sockpuppet?' do
it 'is false for the first post in a topic' do
expect(described_class.new(post1).reply_is_from_sockpuppet?).to eq(false)
end
@@ -110,7 +109,7 @@ RSpec.describe SpamRule::FlagSockpuppets do
end
end
- describe 'flag_sockpuppet_users' do
+ describe '#flag_sockpuppet_users' do
fab!(:post2) { Fabricate(:post, user: Fabricate(:user, ip_address: user1.ip_address), topic: post1.topic) }
let(:system) { Discourse.system_user }
let(:spam) { PostActionType.types[:spam] }
diff --git a/spec/services/group_action_logger_spec.rb b/spec/services/group_action_logger_spec.rb
index a4f8d35941a..2a49e253ef5 100644
--- a/spec/services/group_action_logger_spec.rb
+++ b/spec/services/group_action_logger_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe GroupActionLogger do
end
describe '#log_add_user_to_group' do
- describe 'as a group owner' do
+ context 'as a group owner' do
it 'should create the right record' do
subject.log_add_user_to_group(user)
@@ -68,7 +68,7 @@ RSpec.describe GroupActionLogger do
end
describe '#log_remove_user_from_group' do
- describe 'as group owner' do
+ context 'as group owner' do
it 'should create the right record' do
subject.log_remove_user_from_group(user)
diff --git a/spec/services/group_message_spec.rb b/spec/services/group_message_spec.rb
index 855a6ffc5f8..b650c5b8de9 100644
--- a/spec/services/group_message_spec.rb
+++ b/spec/services/group_message_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe GroupMessage do
-
let(:moderators_group) { Group[:moderators].name }
let!(:admin) { Fabricate.build(:admin, id: 999) }
@@ -61,12 +60,12 @@ RSpec.describe GroupMessage do
end
end
- context 'user_automatically_silenced' do
+ context 'with user_automatically_silenced' do
subject { GroupMessage.new(moderators_group, :user_automatically_silenced, user: user).message_params }
include_examples 'common message params for group messages'
end
- context 'spam_post_blocked' do
+ context 'with spam_post_blocked' do
subject { GroupMessage.new(moderators_group, :spam_post_blocked, user: user).message_params }
include_examples 'common message params for group messages'
end
diff --git a/spec/services/heat_settings_updater_spec.rb b/spec/services/heat_settings_updater_spec.rb
index c4cf01e1c0a..0a26d2335a6 100644
--- a/spec/services/heat_settings_updater_spec.rb
+++ b/spec/services/heat_settings_updater_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
RSpec.describe HeatSettingsUpdater do
- describe '#update' do
- subject(:update_settings) { HeatSettingsUpdater.update }
+ describe '.update' do
+ subject(:update_settings) { described_class.update }
def expect_default_values
[:topic_views_heat, :topic_post_like_heat].each do |prefix|
@@ -20,7 +20,7 @@ RSpec.describe HeatSettingsUpdater do
expect_default_values
end
- context 'low activity' do
+ context 'with low activity' do
let!(:hottest_topic1) { Fabricate(:topic, views: 3000, posts_count: 10, like_count: 2) }
let!(:hottest_topic2) { Fabricate(:topic, views: 3000, posts_count: 10, like_count: 2) }
let!(:warm_topic1) { Fabricate(:topic, views: 1500, posts_count: 10, like_count: 1) }
@@ -51,7 +51,7 @@ RSpec.describe HeatSettingsUpdater do
end
end
- context 'similar activity' do
+ context 'with similar activity' do
let!(:hottest_topic1) { Fabricate(:topic, views: 3530, posts_count: 100, like_count: 201) }
let!(:hottest_topic2) { Fabricate(:topic, views: 3530, posts_count: 100, like_count: 201) }
let!(:warm_topic1) { Fabricate(:topic, views: 2020, posts_count: 100, like_count: 99) }
@@ -71,7 +71,7 @@ RSpec.describe HeatSettingsUpdater do
end
end
- context 'increased activity' do
+ context 'with increased activity' do
let!(:hottest_topic1) { Fabricate(:topic, views: 10_100, posts_count: 100, like_count: 230) }
let!(:hottest_topic2) { Fabricate(:topic, views: 10_012, posts_count: 100, like_count: 220) }
let!(:warm_topic1) { Fabricate(:topic, views: 4020, posts_count: 99, like_count: 126) }
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index 152b1b20537..b758ce66749 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe InlineUploads do
end
describe '.process' do
- describe 'local uploads' do
+ context 'with local uploads' do
fab!(:upload) { Fabricate(:upload) }
fab!(:upload2) { Fabricate(:upload) }
fab!(:upload3) { Fabricate(:upload) }
@@ -249,7 +249,7 @@ RSpec.describe InlineUploads do
MD
end
- context "subfolder" do
+ context "with subfolder" do
before do
set_subfolder "/community"
end
@@ -650,7 +650,7 @@ RSpec.describe InlineUploads do
end
end
- describe "s3 uploads" do
+ context "with s3 uploads" do
let(:upload) { Fabricate(:upload_s3) }
let(:upload2) { Fabricate(:upload_s3) }
let(:upload3) { Fabricate(:upload) }
diff --git a/spec/services/notification_emailer_spec.rb b/spec/services/notification_emailer_spec.rb
index e9a9ae89d79..f0a87ebf332 100644
--- a/spec/services/notification_emailer_spec.rb
+++ b/spec/services/notification_emailer_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe NotificationEmailer do
-
before do
freeze_time
NotificationEmailer.enable
@@ -32,7 +31,7 @@ RSpec.describe NotificationEmailer do
end
end
- context "inactive user" do
+ context "with an inactive user" do
before { notification.user.active = false }
it "doesn't enqueue a job" do
@@ -85,7 +84,7 @@ RSpec.describe NotificationEmailer do
end
end
- context "active but unapproved user" do
+ context "with an active but unapproved user" do
before do
SiteSetting.must_approve_users = true
notification.user.approved = false
@@ -99,7 +98,7 @@ RSpec.describe NotificationEmailer do
end
end
- context "small action" do
+ context "with a small action" do
it "doesn't enqueue a job" do
Post.any_instance.expects(:post_type).returns(Post.types[:small_action])
@@ -140,7 +139,7 @@ RSpec.describe NotificationEmailer do
[true, false].each do |no_delay|
- context 'user_mentioned' do
+ context 'with user_mentioned' do
let(:no_delay) { no_delay }
let(:type) { :user_mentioned }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -162,7 +161,7 @@ RSpec.describe NotificationEmailer do
end
- context 'user_replied' do
+ context 'with user_replied' do
let(:no_delay) { no_delay }
let(:type) { :user_replied }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -171,7 +170,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'user_quoted' do
+ context 'with user_quoted' do
let(:no_delay) { no_delay }
let(:type) { :user_quoted }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -180,7 +179,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'user_linked' do
+ context 'with user_linked' do
let(:no_delay) { no_delay }
let(:type) { :user_linked }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -189,7 +188,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'user_posted' do
+ context 'with user_posted' do
let(:no_delay) { no_delay }
let(:type) { :user_posted }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -198,7 +197,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'user_private_message' do
+ context 'with user_private_message' do
let(:no_delay) { no_delay }
let(:type) { :user_private_message }
let(:delay) { SiteSetting.personal_email_time_window_seconds }
@@ -216,7 +215,7 @@ RSpec.describe NotificationEmailer do
end
- context 'user_invited_to_private_message' do
+ context 'with user_invited_to_private_message' do
let(:no_delay) { no_delay }
let(:type) { :user_invited_to_private_message }
let(:delay) { SiteSetting.personal_email_time_window_seconds }
@@ -225,7 +224,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'user_invited_to_topic' do
+ context 'with user_invited_to_topic' do
let(:no_delay) { no_delay }
let(:type) { :user_invited_to_topic }
let(:delay) { SiteSetting.personal_email_time_window_seconds }
@@ -234,7 +233,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'watching the first post' do
+ context 'when watching the first post' do
let(:no_delay) { no_delay }
let(:type) { :user_watching_first_post }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
@@ -243,7 +242,7 @@ RSpec.describe NotificationEmailer do
include_examples "enqueue_public"
end
- context 'post_approved' do
+ context 'with post_approved' do
let(:no_delay) { no_delay }
let(:type) { :post_approved }
let(:delay) { SiteSetting.email_time_window_mins.minutes }
diff --git a/spec/services/post_action_notifier_spec.rb b/spec/services/post_action_notifier_spec.rb
index 7a822f48224..eb8d625fbfc 100644
--- a/spec/services/post_action_notifier_spec.rb
+++ b/spec/services/post_action_notifier_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
RSpec.describe PostActionNotifier do
-
before do
PostActionNotifier.enable
Jobs.run_immediately!
@@ -133,8 +132,7 @@ RSpec.describe PostActionNotifier do
expect(notification_data['revision_number']).to eq post.post_revisions.last.number
end
- context "edit notifications are disabled" do
-
+ context "when edit notifications are disabled" do
before { SiteSetting.disable_system_edit_notifications = true }
it 'notifies a user of the revision made by another user' do
@@ -148,10 +146,9 @@ RSpec.describe PostActionNotifier do
post.revise(Discourse.system_user, raw: "world is the new body of the message")
}.not_to change(post.user.notifications, :count)
end
-
end
- context "category edit notifications are disabled" do
+ context "when category edit notifications are disabled" do
it 'notifies a user of the revision made by another user' do
SiteSetting.disable_category_edit_notifications = false
@@ -167,10 +164,9 @@ RSpec.describe PostActionNotifier do
post.revise(evil_trout, category_id: Fabricate(:category).id)
}.not_to change(post.user.notifications, :count)
end
-
end
- context "tags edit notifications are disabled" do
+ context "when tags edit notifications are disabled" do
it 'notifies a user of the revision made by another user' do
SiteSetting.disable_tags_edit_notifications = false
@@ -186,7 +182,6 @@ RSpec.describe PostActionNotifier do
post.revise(evil_trout, tags: [Fabricate(:tag).name])
}.not_to change(post.user.notifications, :count)
end
-
end
context 'when using plugin API to add custom recipients' do
@@ -213,7 +208,7 @@ RSpec.describe PostActionNotifier do
end
end
- context 'private message' do
+ context 'with private message' do
fab!(:user) { Fabricate(:user) }
fab!(:mention_post) { Fabricate(:post, user: user, raw: 'Hello @eviltrout') }
let(:topic) do
@@ -239,7 +234,7 @@ RSpec.describe PostActionNotifier do
end
end
- context 'moderator action post' do
+ context 'with moderator action post' do
fab!(:user) { Fabricate(:user) }
fab!(:first_post) { Fabricate(:post, user: user, raw: 'A useless post for you.') }
let(:topic) { first_post.topic }
@@ -250,5 +245,4 @@ RSpec.describe PostActionNotifier do
}.to_not change { Notification.count }
end
end
-
end
diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb
index 82aa4616faa..c7b1cd903c1 100644
--- a/spec/services/post_alerter_spec.rb
+++ b/spec/services/post_alerter_spec.rb
@@ -47,7 +47,7 @@ RSpec.describe PostAlerter do
PostAlerter.post_created(post)
end
- context "private message" do
+ context "with private message" do
it "notifies for pms correctly" do
pm = Fabricate(:topic, archetype: 'private_message', category_id: nil)
op = Fabricate(:post, user: pm.user)
@@ -83,7 +83,7 @@ RSpec.describe PostAlerter do
end
- context "group inboxes" do
+ context "with group inboxes" do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
fab!(:group) { Fabricate(:group, users: [user2], name: "TestGroup", default_notification_level: 2) }
@@ -245,7 +245,7 @@ RSpec.describe PostAlerter do
end
end
- context "unread" do
+ context "with unread" do
it "does not return whispers as unread posts" do
_whisper = Fabricate(:post, raw: 'this is a whisper post',
user: admin,
@@ -257,7 +257,7 @@ RSpec.describe PostAlerter do
end
end
- context 'edits' do
+ context 'with edits' do
it 'notifies correctly on edits' do
Jobs.run_immediately!
PostActionNotifier.enable
@@ -343,7 +343,7 @@ RSpec.describe PostAlerter do
end
end
- context 'quotes' do
+ context 'with quotes' do
fab!(:category) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, category: category) }
@@ -417,7 +417,7 @@ RSpec.describe PostAlerter do
expect(events).to include(event_name: :before_create_notifications_for_users, params: [[evil_trout], post])
end
- context "notifications when prioritizing full names" do
+ context "with notifications when prioritizing full names" do
before do
SiteSetting.prioritize_username_in_ux = false
SiteSetting.display_name_on_posts = true
@@ -483,7 +483,7 @@ RSpec.describe PostAlerter do
end
end
- context 'linked' do
+ context 'with linked' do
let(:post1) { create_post }
let(:user) { post1.user }
let(:linking_post) { create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}") }
@@ -541,7 +541,7 @@ RSpec.describe PostAlerter do
end
end
- context '@here' do
+ context 'with @here' do
let(:post) { create_post_with_alerts(raw: "Hello @here how are you?", user: tl2_user, topic: topic) }
fab!(:other_post) { Fabricate(:post, topic: topic) }
@@ -587,7 +587,7 @@ RSpec.describe PostAlerter do
end
end
- context '@group mentions' do
+ context 'with @group mentions' do
fab!(:group) { Fabricate(:group, name: 'group', mentionable_level: Group::ALIAS_LEVELS[:everyone]) }
let(:post) { create_post_with_alerts(raw: "Hello @group how are you?") }
@@ -639,7 +639,7 @@ RSpec.describe PostAlerter do
end
end
- context '@mentions' do
+ context 'with @mentions' do
let(:mention_post) { create_post_with_alerts(user: user, raw: 'Hello @eviltrout') }
let(:topic) { mention_post.topic }
@@ -712,7 +712,7 @@ RSpec.describe PostAlerter do
TopicUser.change(user.id, topic.id, notification_level: TopicUser.notification_levels[level_name])
end
- context "topic" do
+ context "with topic" do
fab!(:topic) { Fabricate(:topic, user: alice) }
[:watching, :tracking, :regular].each do |notification_level|
@@ -740,7 +740,7 @@ RSpec.describe PostAlerter do
end
end
- context "message to users" do
+ context "with message to users" do
fab!(:pm_topic) do
Fabricate(:private_message_topic,
user: alice,
@@ -811,8 +811,7 @@ RSpec.describe PostAlerter do
end
end
- context "message to group" do
-
+ context "with message to group" do
fab!(:some_group) { Fabricate(:group, name: 'some_group', mentionable_level: Group::ALIAS_LEVELS[:everyone]) }
fab!(:pm_topic) do
Fabricate(:private_message_topic,
@@ -961,9 +960,10 @@ RSpec.describe PostAlerter do
end
end
- describe "push_notification" do
+ describe ".push_notification" do
let(:mention_post) { create_post_with_alerts(user: user, raw: 'Hello @eviltrout :heart:') }
let(:topic) { mention_post.topic }
+
before do
SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"
2.times do |i|
@@ -1090,7 +1090,7 @@ RSpec.describe PostAlerter do
end
end
- describe "create_notification_alert" do
+ describe ".create_notification_alert" do
it "does nothing for suspended users" do
evil_trout.update_columns(suspended_till: 1.year.from_now)
@@ -1196,7 +1196,7 @@ RSpec.describe PostAlerter do
end
end
- context "replies" do
+ context "with replies" do
it "triggers :before_create_notifications_for_users" do
_post = Fabricate(:post, user: user, topic: topic)
reply = Fabricate(:post, topic: topic, reply_to_post_number: 1)
@@ -1324,8 +1324,8 @@ RSpec.describe PostAlerter do
end
end
- context "category" do
- context "watching" do
+ context "with category" do
+ context "with watching" do
it "triggers :before_create_notifications_for_users" do
topic = Fabricate(:topic, category: category)
post = Fabricate(:post, topic: topic)
@@ -1399,8 +1399,8 @@ RSpec.describe PostAlerter do
end
end
- context "tags" do
- context "watching" do
+ context "with tags" do
+ context "with watching" do
it "triggers :before_create_notifications_for_users" do
tag = Fabricate(:tag)
topic = Fabricate(:topic, tags: [tag])
@@ -1461,7 +1461,7 @@ RSpec.describe PostAlerter do
end
end
- context "on change" do
+ context "with on change" do
fab!(:user) { Fabricate(:user) }
fab!(:other_tag) { Fabricate(:tag) }
fab!(:watched_tag) { Fabricate(:tag) }
@@ -1493,7 +1493,7 @@ RSpec.describe PostAlerter do
end
end
- context "private message" do
+ context "with private message" do
fab!(:post) { Fabricate(:private_message_post) }
fab!(:other_tag) { Fabricate(:tag) }
fab!(:other_tag2) { Fabricate(:tag) }
@@ -1651,7 +1651,7 @@ RSpec.describe PostAlerter do
end
end
- context "SMTP (group_smtp_email)" do
+ context "with SMTP (group_smtp_email)" do
before do
SiteSetting.enable_smtp = true
SiteSetting.email_in = true
diff --git a/spec/services/post_owner_changer_spec.rb b/spec/services/post_owner_changer_spec.rb
index 7bdef0ba7fa..c8511237118 100644
--- a/spec/services/post_owner_changer_spec.rb
+++ b/spec/services/post_owner_changer_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe PostOwnerChanger do
- describe "change_owner!" do
+ describe "#change_owner!" do
fab!(:editor) { Fabricate(:admin) }
fab!(:user_a) { Fabricate(:user) }
let(:p1) { create_post(post_number: 1) }
@@ -90,7 +90,7 @@ RSpec.describe PostOwnerChanger do
expect(TopicUser.find_by(topic_id: topic.id, user_id: user_a.id).posted).to eq(true)
end
- context "sets topic notification level for the new owner" do
+ context "when setting topic notification level for the new owner" do
let(:p4) { create_post(post_number: 2, topic: topic) }
it "'watching' if the first post gets a new owner" do
@@ -106,7 +106,7 @@ RSpec.describe PostOwnerChanger do
end
end
- context "integration tests" do
+ context "with integration tests" do
let(:p1user) { p1.user }
let(:p2user) { p2.user }
@@ -192,8 +192,7 @@ RSpec.describe PostOwnerChanger do
}.to_not change { user_stat.reload.post_count }
end
- context 'private message topic' do
- # fab!(:topic) { Fabricate(:private_message_topic) }
+ context 'with private message topic' do
let(:pm) do
create_post(
archetype: 'private_message',
diff --git a/spec/services/topic_timestamp_changer_spec.rb b/spec/services/topic_timestamp_changer_spec.rb
index e92fab58444..b1eaad93220 100644
--- a/spec/services/topic_timestamp_changer_spec.rb
+++ b/spec/services/topic_timestamp_changer_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
RSpec.describe TopicTimestampChanger do
- describe "change!" do
+ describe "#change!" do
let(:old_timestamp) { Time.zone.now }
let(:topic) { Fabricate(:topic, created_at: old_timestamp) }
let!(:p1) { Fabricate(:post, topic: topic, created_at: old_timestamp) }
let!(:p2) { Fabricate(:post, topic: topic, created_at: old_timestamp + 1.day) }
- context 'new timestamp is in the future' do
+ context 'when new timestamp is in the future' do
let(:new_timestamp) { old_timestamp + 2.day }
it 'should raise the right error' do
@@ -16,7 +16,7 @@ RSpec.describe TopicTimestampChanger do
end
end
- context 'new timestamp is in the past' do
+ context 'when new timestamp is in the past' do
let(:new_timestamp) { old_timestamp - 2.day }
it 'changes the timestamp of the topic and opening post' do
@@ -40,7 +40,7 @@ RSpec.describe TopicTimestampChanger do
expect(p2.updated_at).to eq_time(new_timestamp + 1.day)
end
- describe 'when posts have timestamps in the future' do
+ context 'when posts have timestamps in the future' do
it 'should set the new timestamp as the default timestamp' do
new_timestamp = freeze_time
diff --git a/spec/services/user_anonymizer_spec.rb b/spec/services/user_anonymizer_spec.rb
index 8cee096d0bf..f2c50945661 100644
--- a/spec/services/user_anonymizer_spec.rb
+++ b/spec/services/user_anonymizer_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe UserAnonymizer do
end
end
- describe "make_anonymous" do
+ describe ".make_anonymous" do
let(:original_email) { "[email protected]" }
let(:user) { Fabricate(:user, username: "edward", email: original_email) }
fab!(:another_user) { Fabricate(:evil_trout) }
@@ -65,7 +65,7 @@ RSpec.describe UserAnonymizer do
expect(user.user_option.mailing_list_mode).to eq(false)
end
- context "Site Settings do not require full name" do
+ context "when Site Settings do not require full name" do
before do
SiteSetting.full_name_required = false
end
@@ -113,7 +113,7 @@ RSpec.describe UserAnonymizer do
end
end
- context "Site Settings require full name" do
+ context "when Site Settings require full name" do
before do
SiteSetting.full_name_required = true
end
@@ -225,7 +225,7 @@ RSpec.describe UserAnonymizer do
expect(user.user_api_keys).to be_empty
end
- context "executes job" do
+ context "when executing jobs" do
before do
Jobs.run_immediately!
end
@@ -378,5 +378,4 @@ RSpec.describe UserAnonymizer do
expect(Invite.exists?(id: invite.id)).to eq(false)
end
end
-
end
diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb
index 4c5e0ef3f29..2865440acd2 100644
--- a/spec/services/user_destroyer_spec.rb
+++ b/spec/services/user_destroyer_spec.rb
@@ -1,11 +1,10 @@
# frozen_string_literal: true
RSpec.describe UserDestroyer do
-
fab!(:user) { Fabricate(:user_with_secondary_email) }
fab!(:admin) { Fabricate(:admin) }
- describe 'new' do
+ describe '.new' do
it 'raises an error when user is nil' do
expect { UserDestroyer.new(nil) }.to raise_error(Discourse::InvalidParameters)
end
@@ -15,7 +14,7 @@ RSpec.describe UserDestroyer do
end
end
- describe 'destroy' do
+ describe '#destroy' do
it 'raises an error when user is nil' do
expect { UserDestroyer.new(admin).destroy(nil) }.to raise_error(Discourse::InvalidParameters)
end
@@ -71,7 +70,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user deletes self' do
+ context 'when user deletes self' do
let(:destroy_opts) { { delete_posts: true, context: "/u/username/preferences/account" } }
subject(:destroy) { UserDestroyer.new(user).destroy(user, destroy_opts) }
@@ -83,7 +82,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'context is missing' do
+ context 'when context is missing' do
it "logs warning message if context is missing" do
logger = track_log_messages do
UserDestroyer.new(admin).destroy(user)
@@ -137,13 +136,13 @@ RSpec.describe UserDestroyer do
end
end
- context 'user has posts' do
+ context 'when user has posts' do
let!(:topic_starter) { Fabricate(:user) }
let!(:topic) { Fabricate(:topic, user: topic_starter) }
let!(:first_post) { Fabricate(:post, user: topic_starter, topic: topic) }
let!(:post) { Fabricate(:post, user: user, topic: topic) }
- context "delete_posts is false" do
+ context "when delete_posts is false" do
subject(:destroy) { UserDestroyer.new(admin).destroy(user) }
before do
user.stubs(:post_count).returns(1)
@@ -157,10 +156,10 @@ RSpec.describe UserDestroyer do
end
end
- context "delete_posts is true" do
+ context "when delete_posts is true" do
let(:destroy_opts) { { delete_posts: true } }
- context "staff deletes user" do
+ context "when staff deletes user" do
subject(:destroy) { UserDestroyer.new(admin).destroy(user, destroy_opts) }
include_examples "successfully destroy a user"
@@ -186,7 +185,7 @@ RSpec.describe UserDestroyer do
expect(spammer_topic.user_id).to eq(nil)
end
- context "delete_as_spammer is true" do
+ context "when delete_as_spammer is true" do
before { destroy_opts[:delete_as_spammer] = true }
@@ -204,7 +203,7 @@ RSpec.describe UserDestroyer do
end
end
- context "users deletes self" do
+ context "when users deletes self" do
subject(:destroy) { UserDestroyer.new(user).destroy(user, destroy_opts) }
include_examples "successfully destroy a user"
@@ -219,7 +218,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user was invited' do
+ context 'when user was invited' do
it "should delete the invite of user" do
invite = Fabricate(:invite)
topic_invite = invite.topic_invites.create!(topic: Fabricate(:topic))
@@ -235,7 +234,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user created category' do
+ context 'when user created category' do
let!(:topic) { Fabricate(:topic, user: user) }
let!(:first_post) { Fabricate(:post, user: user, topic: topic) }
let!(:second_post) { Fabricate(:post, user: user, topic: topic) }
@@ -252,7 +251,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user has no posts, but user_stats table has post_count > 0' do
+ context 'when user has no posts, but user_stats table has post_count > 0' do
before do
# out of sync user_stat data shouldn't break UserDestroyer
user.user_stat.update_attribute(:post_count, 1)
@@ -263,7 +262,7 @@ RSpec.describe UserDestroyer do
include_examples "successfully destroy a user"
end
- context 'user has deleted posts' 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
expect { UserDestroyer.new(admin).destroy(user) }.to change { User.count }.by(-1)
@@ -271,8 +270,8 @@ RSpec.describe UserDestroyer do
end
end
- context 'user has no posts' do
- context 'and destroy succeeds' do
+ context 'when user has no posts' do
+ context 'when destroy succeeds' do
let(:destroy_opts) { {} }
subject(:destroy) { UserDestroyer.new(admin).destroy(user) }
@@ -280,7 +279,7 @@ RSpec.describe UserDestroyer do
include_examples "email block list"
end
- context 'and destroy fails' do
+ context 'when destroy fails' do
subject(:destroy) { UserDestroyer.new(admin).destroy(user) }
it 'should not log the action' do
@@ -291,8 +290,8 @@ RSpec.describe UserDestroyer do
end
end
- context 'user has posts with links' do
- context 'external links' do
+ context 'when user has posts with links' do
+ context 'with external links' do
before do
@post = Fabricate(:post_with_external_links, user: user)
TopicLink.extract_from(@post)
@@ -309,7 +308,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'internal links' do
+ context 'with internal links' do
before do
@post = Fabricate(:post_with_external_links, user: user)
TopicLink.extract_from(@post)
@@ -335,13 +334,13 @@ RSpec.describe UserDestroyer do
end
end
- context 'ip address screening' do
+ context 'with ip address screening' do
it "doesn't create screened_ip_address records by default" do
ScreenedIpAddress.expects(:watch).never
UserDestroyer.new(admin).destroy(user)
end
- context "block_ip is true" do
+ context "when block_ip is true" do
it "creates a new screened_ip_address record" do
ScreenedIpAddress.expects(:watch).with(user.ip_address).returns(stub_everything)
UserDestroyer.new(admin).destroy(user, block_ip: true)
@@ -356,7 +355,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user created a category' do
+ context 'when user created a category' do
let!(:category) { Fabricate(:category_with_definition, user: user) }
it "assigns the system user to the categories" do
@@ -385,7 +384,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user liked things' do
+ context 'when user liked things' do
before do
@topic = Fabricate(:topic, user: Fabricate(:user))
@post = Fabricate(:post, user: @topic.user, topic: @topic)
@@ -400,7 +399,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user belongs to groups that grant trust level' do
+ context 'when user belongs to groups that grant trust level' do
let(:group) { Fabricate(:group, grant_trust_level: 4) }
before do
@@ -436,7 +435,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user has staff action logs' do
+ context 'when user has staff action logs' do
before do
logger = StaffActionLogger.new(user)
logger.log_site_setting_change(
@@ -467,7 +466,7 @@ RSpec.describe UserDestroyer do
end
end
- context 'user got an email' do
+ context 'when user got an email' do
let!(:email_log) { Fabricate(:email_log, user: user) }
it "does not delete the email log" do
@@ -477,5 +476,4 @@ RSpec.describe UserDestroyer do
end
end
end
-
end
diff --git a/spec/services/user_merger_spec.rb b/spec/services/user_merger_spec.rb
index 8dc6ce2776d..d1c69c6364d 100644
--- a/spec/services/user_merger_spec.rb
+++ b/spec/services/user_merger_spec.rb
@@ -96,7 +96,7 @@ RSpec.describe UserMerger do
expect(category_ids).to be_empty
end
- context "developer flag" do
+ context "with developer flag" do
it "moves the developer flag when the target user isn't a developer yet" do
Developer.create!(user_id: source_user.id)
merge_users!
@@ -115,7 +115,7 @@ RSpec.describe UserMerger do
end
end
- context "drafts" do
+ context "with drafts" do
def create_draft(user, key, text)
seq = DraftSequence.next!(user, key)
Draft.set(user, key, seq, text)
@@ -154,7 +154,7 @@ RSpec.describe UserMerger do
expect(EmailLog.where(user_id: target_user.id).count).to eq(1)
end
- context "likes" do
+ context "with likes" do
def given_daily_like_count_for(user, date)
GivenDailyLike.find_for(user.id, date).pluck(:likes_given)[0] || 0
end
@@ -316,7 +316,7 @@ RSpec.describe UserMerger do
expect(IgnoredUser.where(ignored_user_id: source_user.id).count).to eq(0)
end
- context "notifications" do
+ context "with notifications" do
it "updates notifications" do
Fabricate(:notification, user: source_user)
Fabricate(:notification, user: source_user)
@@ -329,7 +329,7 @@ RSpec.describe UserMerger do
end
end
- context "post actions" do
+ context "with post actions" do
it "merges post actions" do
type_ids = PostActionType.public_type_ids + [PostActionType.flag_types.values.first]
@@ -380,7 +380,7 @@ RSpec.describe UserMerger do
expect(post_revision.reload.user).to eq(target_user)
end
- context "post timings" do
+ context "with post timings" do
def create_post_timing(post, user, msecs)
PostTiming.create!(
topic_id: post.topic_id,
@@ -422,7 +422,7 @@ RSpec.describe UserMerger do
end
end
- context "posts" do
+ context "with posts" do
it "updates user ids of posts" do
source_user.update_attribute(:moderator, true)
@@ -562,7 +562,7 @@ RSpec.describe UserMerger do
expect(TopicLinkClick.where(user_id: walter.id).count).to eq(1)
end
- context "topic timers" do
+ context "with topic timers" do
def create_topic_timer(topic, user, status_type, deleted_by = nil)
timer = Fabricate(:topic_timer, topic: topic, user: user, status_type: TopicTimer.types[status_type])
timer.trash!(deleted_by) if deleted_by
@@ -667,7 +667,7 @@ RSpec.describe UserMerger do
expect(Upload.where(user_id: source_user.id).count).to eq(0)
end
- context "user actions" do
+ context "with user actions" do
# action_type and user_id are not nullable
# target_topic_id and acting_user_id are nullable, but always have a value
@@ -764,7 +764,7 @@ RSpec.describe UserMerger do
expect(UserArchivedMessage.where(user_id: source_user.id).count).to eq(0)
end
- context "badges" do
+ context "with badges" do
def create_badge(badge, user, opts = {})
UserBadge.create!(
badge: badge,
@@ -929,7 +929,7 @@ RSpec.describe UserMerger do
expect(events).to include(event_name: :merging_users, params: [source_user, target_user])
end
- context "site settings" do
+ context "with site settings" do
it "updates usernames in site settings" do
SiteSetting.site_contact_username = source_user.username
SiteSetting.embed_by_username = source_user.username
diff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rb
index 8532ce1916d..7539b4e4ad0 100644
--- a/spec/services/user_updater_spec.rb
+++ b/spec/services/user_updater_spec.rb
@@ -69,10 +69,10 @@ RSpec.describe UserUpdater do
).count).to eq(1)
end
- context "staged user" do
+ context "with a staged user" do
let(:staged_user) { Fabricate(:staged) }
- context "allow_changing_staged_user_tracking is false" do
+ context "when allow_changing_staged_user_tracking is false" do
before { SiteSetting.allow_changing_staged_user_tracking = false }
it "doesn't update muted categories and watched tags" do
@@ -83,7 +83,7 @@ RSpec.describe UserUpdater do
end
end
- context "allow_changing_staged_user_tracking is true" do
+ context "when allow_changing_staged_user_tracking is true" do
before { SiteSetting.allow_changing_staged_user_tracking = true }
it "updates muted categories and watched tags" do
@@ -424,11 +424,11 @@ RSpec.describe UserUpdater do
end
end
- context 'title is from a badge' do
+ context 'when title is from a badge' do
fab!(:user) { Fabricate(:user, title: 'Emperor') }
fab!(:badge) { Fabricate(:badge, name: 'Minion') }
- context 'badge can be used as a title' do
+ context 'when badge can be used as a title' do
before do
badge.update(allow_title: true)
end
diff --git a/spec/services/username_changer_spec.rb b/spec/services/username_changer_spec.rb
index 5045fa0d9f0..fa6721b4216 100644
--- a/spec/services/username_changer_spec.rb
+++ b/spec/services/username_changer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe UsernameChanger do
describe '#change' do
let(:user) { Fabricate(:user) }
- context 'success' do
+ context 'when everything goes well' do
let!(:old_username) { user.username }
it 'should change the username' do
@@ -46,7 +46,7 @@ RSpec.describe UsernameChanger do
end
end
- context 'failure' do
+ context 'when something goes wrong' do
let(:wrong_username) { "" }
let(:username_before_change) { user.username }
let(:username_lower_before_change) { user.username_lower }
@@ -61,7 +61,7 @@ RSpec.describe UsernameChanger do
end
end
- describe 'change the case of my username' do
+ context 'when changing the case of my username' do
let!(:myself) { Fabricate(:user, username: 'hansolo') }
it 'should change the username' do
@@ -107,7 +107,7 @@ RSpec.describe UsernameChanger do
end
end
- context 'posts and revisions' do
+ context 'when there are posts and revisions' do
let(:user) { Fabricate(:user, username: 'foo') }
let(:topic) { Fabricate(:topic, user: user) }
@@ -130,7 +130,7 @@ RSpec.describe UsernameChanger do
post.reload
end
- context 'mentions' do
+ context 'when there are mentions' do
it 'rewrites cooked correctly' do
post = create_post_and_change_username(raw: "Hello @foo")
expect(post.cooked).to eq(%Q(<p>Hello <a class="mention" href="/u/bar">@bar</a></p>))
@@ -296,7 +296,7 @@ RSpec.describe UsernameChanger do
expect(post.cooked).to match_html('<p><a class="mention">@bar</a> and <a class="mention">@someuser</a></p>')
end
- context "Unicode usernames" do
+ context "when using Unicode usernames" do
before { SiteSetting.unicode_usernames = true }
let(:user) { Fabricate(:user, username: 'թռչուն') }
@@ -331,7 +331,7 @@ RSpec.describe UsernameChanger do
end
end
- context 'quotes' do
+ context 'when there are quotes' do
let(:quoted_post) { create_post(user: user, topic: topic, post_number: 1, raw: "quoted post") }
let(:avatar_url) { user.avatar_template_url.gsub("{size}", "40") }
@@ -402,7 +402,7 @@ RSpec.describe UsernameChanger do
HTML
end
- context 'simple quote' do
+ context 'when there is a simple quote' do
let(:raw) do <<~RAW
Lorem ipsum
@@ -447,7 +447,7 @@ RSpec.describe UsernameChanger do
end
end
- context 'oneboxes' do
+ context 'when there are oneboxes' do
let(:quoted_post) { create_post(user: user, topic: topic, post_number: 1, raw: "quoted post") }
let(:avatar_url) { user_avatar_url(user) }
let(:evil_trout) { Fabricate(:evil_trout) }
@@ -533,7 +533,7 @@ RSpec.describe UsernameChanger do
end
end
- context 'notifications' do
+ context 'when there are notifications' do
def create_notification(type, notified_user, post, data = {})
Fabricate(
:notification,
@@ -617,7 +617,7 @@ RSpec.describe UsernameChanger do
]
]
- context "unicode_usernames is off" do
+ context "when unicode_usernames is off" do
before do
SiteSetting.unicode_usernames = false
end
@@ -646,7 +646,7 @@ RSpec.describe UsernameChanger do
end
end
- context "unicode_usernames is on" do
+ context "when unicode_usernames is on" do
before do
SiteSetting.unicode_usernames = true
end
@@ -666,5 +666,4 @@ RSpec.describe UsernameChanger do
end
end
end
-
end
diff --git a/spec/services/username_checker_service_spec.rb b/spec/services/username_checker_service_spec.rb
index 1cb3eee2074..7ac08b3d38c 100644
--- a/spec/services/username_checker_service_spec.rb
+++ b/spec/services/username_checker_service_spec.rb
@@ -1,16 +1,14 @@
# frozen_string_literal: true
RSpec.describe UsernameCheckerService do
-
- describe 'check_username' do
-
+ describe '#check_username' do
before do
@service = UsernameCheckerService.new
@nil_email = nil
@email = '[email protected]'
end
- context 'Username invalid' do
+ context 'when username is invalid' do
it 'rejects too short usernames' do
result = @service.check_username('a', @nil_email)
expect(result).to have_key(:errors)
@@ -31,7 +29,7 @@ RSpec.describe UsernameCheckerService do
expect(result).to have_key(:errors)
end
- describe 'reserved usernames' do
+ context 'with reserved usernames' do
before do
SiteSetting.reserved_usernames = 'test|donkey'
end
@@ -63,5 +61,4 @@ RSpec.describe UsernameCheckerService do
expect(result[:available]).to eq(true)
end
end
-
end
diff --git a/spec/services/wildcard_domain_checker_spec.rb b/spec/services/wildcard_domain_checker_spec.rb
index ce077bd7c34..8a941df607c 100644
--- a/spec/services/wildcard_domain_checker_spec.rb
+++ b/spec/services/wildcard_domain_checker_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe WildcardDomainChecker do
-
- describe 'check_domain' do
- context 'valid domain' do
+ describe '.check_domain' do
+ context 'when domain is valid' do
it 'returns correct domain' do
result1 = WildcardDomainChecker.check_domain('*.discourse.org', 'anything.is.possible.discourse.org')
expect(result1[0]).to eq('anything.is.possible.discourse.org')
@@ -16,7 +15,7 @@ RSpec.describe WildcardDomainChecker do
end
end
- context 'invalid domain' do
+ context 'when domain is invalid' do
it "doesn't return the domain" do
result1 = WildcardDomainChecker.check_domain('*.discourse.org', 'bad-domain.discourse.org.evil.com')
expect(result1).to eq(nil)
diff --git a/spec/services/wildcard_url_checker_spec.rb b/spec/services/wildcard_url_checker_spec.rb
index e5c8cc925df..89522a0a47a 100644
--- a/spec/services/wildcard_url_checker_spec.rb
+++ b/spec/services/wildcard_url_checker_spec.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
RSpec.describe WildcardUrlChecker do
-
- describe 'check_url' do
- context 'valid url' do
+ describe '.check_url' do
+ context 'when url is valid' do
it 'returns true' do
result1 = described_class.check_url('https://*.discourse.org', 'https://anything.is.possible.discourse.org')
expect(result1).to eq(true)
@@ -22,7 +21,7 @@ RSpec.describe WildcardUrlChecker do
end
end
- context 'invalid domain' do
+ context 'when url is invalid' do
it "returns false" do
result1 = described_class.check_url('https://*.discourse.org', 'https://bad-domain.discourse.org.evil.com')
expect(result1).to eq(false)
diff --git a/spec/services/word_watcher_spec.rb b/spec/services/word_watcher_spec.rb
index 9b280547b29..842f66303dd 100644
--- a/spec/services/word_watcher_spec.rb
+++ b/spec/services/word_watcher_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-describe WordWatcher do
+RSpec.describe WordWatcher do
let(:raw) do
<<~RAW.strip
Do you like liquorice?
@@ -50,16 +50,18 @@ describe WordWatcher do
let!(:word3) { Fabricate(:watched_word, action: WatchedWord.actions[:block], case_sensitive: true).word }
let!(:word4) { Fabricate(:watched_word, action: WatchedWord.actions[:block], case_sensitive: true).word }
- context "format of the result regexp" do
- it "is correct when watched_words_regular_expressions = true" do
+ context "when watched_words_regular_expressions = true" do
+ it "returns the proper regexp" do
SiteSetting.watched_words_regular_expressions = true
regexps = described_class.word_matcher_regexp_list(:block)
expect(regexps).to be_an(Array)
expect(regexps.map(&:inspect)).to contain_exactly("/(#{word1})|(#{word2})/i", "/(#{word3})|(#{word4})/")
end
+ end
- it "is correct when watched_words_regular_expressions = false" do
+ context "when watched_words_regular_expressions = false" do
+ it "returns the proper regexp" do
SiteSetting.watched_words_regular_expressions = false
regexps = described_class.word_matcher_regexp_list(:block)
@@ -133,20 +135,18 @@ describe WordWatcher do
expect(matches[1]).to eq("acknowledge")
end
- context "word boundary" do
- it "handles word boundary" do
- Fabricate(:watched_word, word: "love", action: WatchedWord.actions[:require_approval])
- expect(described_class.new("I Love, bananas.").word_matches_for_action?(:require_approval)[1]).to eq("Love")
- expect(described_class.new("I LOVE; apples.").word_matches_for_action?(:require_approval)[1]).to eq("LOVE")
- expect(described_class.new("love: is a thing.").word_matches_for_action?(:require_approval)[1]).to eq("love")
- expect(described_class.new("I love. oranges").word_matches_for_action?(:require_approval)[1]).to eq("love")
- expect(described_class.new("I :love. pineapples").word_matches_for_action?(:require_approval)[1]).to eq("love")
- expect(described_class.new("peace ,love and understanding.").word_matches_for_action?(:require_approval)[1]).to eq("love")
- end
+ it "handles word boundary" do
+ Fabricate(:watched_word, word: "love", action: WatchedWord.actions[:require_approval])
+ expect(described_class.new("I Love, bananas.").word_matches_for_action?(:require_approval)[1]).to eq("Love")
+ expect(described_class.new("I LOVE; apples.").word_matches_for_action?(:require_approval)[1]).to eq("LOVE")
+ expect(described_class.new("love: is a thing.").word_matches_for_action?(:require_approval)[1]).to eq("love")
+ expect(described_class.new("I love. oranges").word_matches_for_action?(:require_approval)[1]).to eq("love")
+ expect(described_class.new("I :love. pineapples").word_matches_for_action?(:require_approval)[1]).to eq("love")
+ expect(described_class.new("peace ,love and understanding.").word_matches_for_action?(:require_approval)[1]).to eq("love")
end
- context 'multiple matches' do
- context 'non regexp words' do
+ context 'when there are multiple matches' do
+ context 'with non regexp words' do
it 'lists all matching words' do
%w{bananas hate hates}.each do |word|
Fabricate(:watched_word, word: word, action: WatchedWord.actions[:block])
@@ -160,7 +160,7 @@ describe WordWatcher do
end
end
- context 'regexp words' do
+ context 'with regexp words' do
before do
SiteSetting.watched_words_regular_expressions = true
end
@@ -178,7 +178,7 @@ describe WordWatcher do
end
end
- context "emojis" do
+ context "when word is an emoji" do
it "handles emoji" do
Fabricate(:watched_word, word: ":joy:", action: WatchedWord.actions[:require_approval])
@@ -201,7 +201,7 @@ describe WordWatcher do
end
end
- context "regular expressions" do
+ context "when word is a regular expression" do
before do
SiteSetting.watched_words_regular_expressions = true
end
diff --git a/spec/support/onebox_helpers.rb b/spec/support/onebox_helpers.rb
index 9509df20c6f..f07f845ef8e 100644
--- a/spec/support/onebox_helpers.rb
+++ b/spec/support/onebox_helpers.rb
@@ -11,7 +11,7 @@ module OneboxHelpers
preview.css(tag_name).first[attribute]
end
- RSpec.shared_context "engines" do
+ RSpec.shared_context "with engines" do
before do
fixture = defined?(@onebox_fixture) ? @onebox_fixture : described_class.onebox_name
stub_request(:get, defined?(@uri) ? @uri : @link).to_return(status: 200, body: onebox_response(fixture))