|
64 | 64 | create(:topic_star, user: starring_user2, topic: topic) |
65 | 65 | end |
66 | 66 |
|
67 | | - it "creates activities for all users who starred the topic" do |
| 67 | + it "creates activities for all users who starred the topic except the sender" do |
68 | 68 | expect { |
69 | 69 | builder.process! |
70 | | - }.to change { Activity.count }.by(3) # 2 starring users + sender gets auto-starred |
| 70 | + }.to change { Activity.count }.by(2) # 2 starring users, sender is excluded |
71 | 71 |
|
72 | 72 | activities = Activity.where(activity_type: "topic_message_received") |
73 | | - expect(activities.pluck(:user_id)).to match_array([starring_user1.id, starring_user2.id, sender_user.id]) |
| 73 | + expect(activities.pluck(:user_id)).to match_array([starring_user1.id, starring_user2.id]) |
74 | 74 | end |
75 | 75 |
|
76 | | - it "marks sender's activity as read if they have topic starred" do |
| 76 | + it "does not create an activity for the sender even if they starred the topic" do |
77 | 77 | # Sender also has the topic starred |
78 | 78 | create(:topic_star, user: sender_user, topic: topic) |
79 | 79 |
|
80 | 80 | builder.process! |
81 | 81 |
|
82 | 82 | sender_activity = Activity.find_by(user: sender_user, subject: message) |
83 | | - expect(sender_activity).to be_present |
84 | | - expect(sender_activity.read_at).to be_present |
85 | | - expect(sender_activity.read_at).to be_within(1.second).of(Time.current) |
| 83 | + expect(sender_activity).to be_nil |
86 | 84 | end |
87 | 85 |
|
88 | 86 | it "does not mark other users' activities as read" do |
|
130 | 128 | it "handles topic with no stars" do |
131 | 129 | expect { |
132 | 130 | builder.process! |
133 | | - }.to change { Activity.count }.by(1) |
| 131 | + }.not_to change { Activity.count } |
134 | 132 |
|
135 | 133 | expect(TopicStar.exists?(user: sender_user, topic: topic)).to be true |
136 | 134 |
|
137 | 135 | activity = Activity.find_by(user: sender_user, subject: message) |
138 | | - expect(activity).to be_present |
139 | | - expect(activity.read_at).to be_present |
| 136 | + expect(activity).to be_nil |
140 | 137 | end |
141 | 138 |
|
142 | 139 | it "handles sender who is not a registered user" do |
|
166 | 163 |
|
167 | 164 | expect { |
168 | 165 | builder.process! |
169 | | - }.to change { Activity.count }.by(2) |
| 166 | + }.to change { Activity.count }.by(1) |
170 | 167 |
|
171 | 168 | sender_activity = Activity.find_by(user: sender_user, subject: message) |
172 | | - expect(sender_activity.read_at).to be_present |
| 169 | + expect(sender_activity).to be_nil |
173 | 170 |
|
174 | 171 | other_activity = Activity.find_by(user: other_user, subject: message) |
175 | 172 | expect(other_activity.read_at).to be_nil |
|
0 commit comments