mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Don’t use change { … }.by(0) in specs
This commit is contained in:
committed by
Loïc Guitaut
parent
3bfc254c4e
commit
91b6b5eee7
@@ -106,7 +106,7 @@ describe Notification do
|
||||
post_args[:topic].notify_muted!(user)
|
||||
expect {
|
||||
Fabricate(:post, user: user2, topic: post.topic, raw: 'hello @' + user.username)
|
||||
}.to change(user.notifications, :count).by(0)
|
||||
}.not_to change(user.notifications, :count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ describe ScreenedIpAddress do
|
||||
expect(ScreenedIpAddress.pluck(:ip_address)).not_to include("1.1.1.1", "1.1.1.2", "1.1.1.3")
|
||||
|
||||
# expect roll up to be stable
|
||||
expect { ScreenedIpAddress.roll_up }.to change { ScreenedIpAddress.count }.by(0)
|
||||
expect { ScreenedIpAddress.roll_up }.not_to change { ScreenedIpAddress.count }
|
||||
end
|
||||
|
||||
it 'rolls up IPv6 addresses' do
|
||||
@@ -358,10 +358,10 @@ describe ScreenedIpAddress do
|
||||
expect(ScreenedIpAddress.pluck(:ip_address)).not_to include("2001:db8:3333:4441:5555:6666:7777:8888", "2001:db8:3333:4441:5555:6666:7777:8889", "2001:db8:3333:4441:5555:6666:7777:888a")
|
||||
|
||||
# expect roll up to be stable
|
||||
expect { ScreenedIpAddress.roll_up }.to change { ScreenedIpAddress.count }.by(0)
|
||||
expect { ScreenedIpAddress.roll_up }.not_to change { ScreenedIpAddress.count }
|
||||
|
||||
Fabricate(:screened_ip_address, ip_address: "2001:db8:3333:4442::/64")
|
||||
expect { ScreenedIpAddress.roll_up }.to change { ScreenedIpAddress.count }.by(0)
|
||||
expect { ScreenedIpAddress.roll_up }.not_to change { ScreenedIpAddress.count }
|
||||
|
||||
Fabricate(:screened_ip_address, ip_address: "2001:db8:3333:4443::/64")
|
||||
expect { ScreenedIpAddress.roll_up }.to change { ScreenedIpAddress.count }.by(-2)
|
||||
@@ -369,7 +369,7 @@ describe ScreenedIpAddress do
|
||||
expect(ScreenedIpAddress.pluck(:ip_address)).not_to include("2001:db8:3333:4441::/64", "2001:db8:3333:4442::/64", "2001:db8:3333:4443::/64")
|
||||
|
||||
# expect roll up to be stable
|
||||
expect { ScreenedIpAddress.roll_up }.to change { ScreenedIpAddress.count }.by(0)
|
||||
expect { ScreenedIpAddress.roll_up }.not_to change { ScreenedIpAddress.count }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -806,7 +806,7 @@ describe Topic do
|
||||
|
||||
expect { topic.invite(user, user1.username) }
|
||||
.to change { Notification.count }.by(1)
|
||||
.and change { Post.where(post_type: Post.types[:small_action]).count }.by(0)
|
||||
.and not_change { Post.where(post_type: Post.types[:small_action]).count }
|
||||
end
|
||||
|
||||
context "from a muted user" do
|
||||
@@ -1787,7 +1787,7 @@ describe Topic do
|
||||
|
||||
expect do
|
||||
topic.change_category_to_id(new_category.id)
|
||||
end.to change { Notification.count }.by(0)
|
||||
end.not_to change { Notification.count }
|
||||
|
||||
expect(topic.category_id).to eq(new_category.id)
|
||||
end
|
||||
@@ -1823,7 +1823,7 @@ describe Topic do
|
||||
|
||||
expect do
|
||||
topic.change_category_to_id(new_category.id)
|
||||
end.to change { Notification.count }.by(0)
|
||||
end.not_to change { Notification.count }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1856,7 +1856,7 @@ describe Topic do
|
||||
|
||||
it 'should not set a topic timer' do
|
||||
expect { topic.change_category_to_id(new_category.id) }
|
||||
.to change { TopicTimer.with_deleted.count }.by(0)
|
||||
.not_to change { TopicTimer.with_deleted.count }
|
||||
|
||||
expect(topic.closed).to eq(true)
|
||||
expect(topic.reload.category).to eq(new_category)
|
||||
|
||||
@@ -19,7 +19,7 @@ describe TopicTag do
|
||||
|
||||
expect {
|
||||
topic_tag
|
||||
}.to change(tag, :topic_count).by(0)
|
||||
}.not_to change(tag, :topic_count)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -39,7 +39,7 @@ describe TopicTag do
|
||||
|
||||
expect {
|
||||
topic_tag.destroy
|
||||
}.to change(tag, :topic_count).by(0)
|
||||
}.not_to change(tag, :topic_count)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -319,7 +319,7 @@ RSpec.describe User do
|
||||
user.update(admin: true)
|
||||
expect {
|
||||
user.grant_admin!
|
||||
}.to change { Jobs::SendSystemMessage.jobs.count }.by 0
|
||||
}.not_to change { Jobs::SendSystemMessage.jobs.count }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2681,7 +2681,7 @@ RSpec.describe User do
|
||||
|
||||
expect do
|
||||
user.update_ip_address!('0.0.0.1')
|
||||
end.to change { UserIpAddressHistory.where(user_id: user.id).count }.by(0)
|
||||
end.not_to change { UserIpAddressHistory.where(user_id: user.id).count }
|
||||
|
||||
expect(
|
||||
UserIpAddressHistory.where(user_id: user.id).pluck(:ip_address).map(&:to_s)
|
||||
|
||||
@@ -604,7 +604,7 @@ describe WebHook do
|
||||
it 'shouldn’t trigger when the user is demoted' do
|
||||
expect {
|
||||
another_user.change_trust_level!(another_user.trust_level - 1)
|
||||
}.to change { Jobs::EmitWebHookEvent.jobs.length }.by(0)
|
||||
}.not_to change { Jobs::EmitWebHookEvent.jobs.length }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user