DEV: Don’t use change { … }.by(0) in specs

This commit is contained in:
Loïc Guitaut
2022-07-19 16:03:03 +02:00
committed by Loïc Guitaut
parent 3bfc254c4e
commit 91b6b5eee7
44 changed files with 138 additions and 136 deletions

View File

@ -128,9 +128,9 @@ describe Imap::Sync do
.and change { IncomingEmail.count }.by(1)
expect { sync_handler.process }
.to change { Topic.count }.by(0)
.and change { Post.where(post_type: Post.types[:regular]).count }.by(0)
.and change { IncomingEmail.count }.by(0)
.to not_change { Topic.count }
.and not_change { Post.where(post_type: Post.types[:regular]).count }
.and not_change { IncomingEmail.count }
end
it 'creates a new incoming email if the message ID does not match the receiver post id regex' do
@ -155,9 +155,9 @@ describe Imap::Sync do
incoming_email = Fabricate(:incoming_email, message_id: message_id)
expect { sync_handler.process }
.to change { Topic.count }.by(0)
.and change { Post.where(post_type: Post.types[:regular]).count }.by(0)
.and change { IncomingEmail.count }.by(0)
.to not_change { Topic.count }
.and not_change { Post.where(post_type: Post.types[:regular]).count }
.and not_change { IncomingEmail.count }
incoming_email.reload
expect(incoming_email.message_id).to eq(message_id)
@ -248,7 +248,7 @@ describe Imap::Sync do
)
expect { sync_handler.process }
.to change { Topic.count }.by(0)
.to not_change { Topic.count }
.and change { Post.where(post_type: Post.types[:regular]).count }.by(1)
.and change { IncomingEmail.count }.by(1)
@ -276,9 +276,9 @@ describe Imap::Sync do
)
expect { sync_handler.process }
.to change { Topic.count }.by(0)
.and change { Post.where(post_type: Post.types[:regular]).count }.by(0)
.and change { IncomingEmail.count }.by(0)
.to not_change { Topic.count }
.and not_change { Post.where(post_type: Post.types[:regular]).count }
.and not_change { IncomingEmail.count }
topic = Topic.last
expect(topic.title).to eq(subject)
@ -618,9 +618,9 @@ describe Imap::Sync do
)
expect { sync_handler.process }
.to change { Topic.count }.by(0)
.and change { Post.where(post_type: Post.types[:regular]).count }.by(0)
.and change { IncomingEmail.count }.by(0)
.to not_change { Topic.count }
.and not_change { Post.where(post_type: Post.types[:regular]).count }
.and not_change { IncomingEmail.count }
imap_data = Topic.last.incoming_email.pluck(:imap_uid_validity, :imap_uid, :imap_group_id)
expect(imap_data).to contain_exactly([2, 111, group.id], [2, 222, group.id])