added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
require "rails_helper"
describe Reaction do
describe "Validations" do
it { is_expected.to validate_presence_of(:value) }
it { is_expected.to validate_presence_of(:encrypted_user_id) }
end
let(:user) { create(:user) }
let(:other_user) { create(:user) }
context "#values_count_with_participated" do
it "should indicate counts and when the given user has already used the requested reaction" do
reaction = create(:reaction, encrypted_user_id: user.encrypted_id, value: ":smile:")
create(:reaction, encrypted_user_id: other_user.encrypted_id, value: ":smile:")
create(:reaction, encrypted_user_id: other_user.encrypted_id, value: ":smirk:")
expect(subject.class.values_count_with_participated(user.encrypted_id)).to match_array([
hash_including({
# A real reaction ID is only required/meaningful when the current user has reacted.
# Otherwise the value is meaningless.
id: reaction.id.to_s,
value: ":smile:",
count: 2,
participated: true
}),
hash_including({
# id is not relevant here because the user did not react
value: ":smirk:",
count: 1,
participated: false
})
])
end
it "should work with a filtered set" do
create(:reaction, encrypted_user_id: user.encrypted_id)
create(:reaction, encrypted_user_id: other_user.encrypted_id)
create(:reaction, encrypted_user_id: other_user.encrypted_id, value: ":smirk:")
filtered = Reaction.where(value: ":smirk:")
expect(filtered.values_count_with_participated(user.encrypted_id)).to match([
hash_including({
value: ":smirk:",
count: 1,
participated: false
})
])
end
end
end