|
30 | 30 | [topic], |
31 | 31 | ) |
32 | 32 |
|
33 | | - expect(TopicUser.find_by(user: moderator).notification_level).to eq( |
34 | | - TopicUser.notification_levels[:watching], |
35 | | - ) |
| 33 | + notification_level = moderator.user_option.notification_level_when_replying |
| 34 | + |
| 35 | + expect(TopicUser.find_by(user: moderator).notification_level).to eq(notification_level) |
36 | 36 |
|
37 | 37 | expect_enqueued_with(job: :unassign_notification) { assigner.unassign } |
38 | 38 |
|
39 | 39 | expect(TopicQuery.new(moderator, assigned: moderator.username).list_latest.topics).to eq([]) |
40 | 40 |
|
| 41 | + expect(TopicUser.find_by(user: moderator).notification_level).to eq(notification_level) |
| 42 | + end |
| 43 | + |
| 44 | + it "uses the notification_level_when_replying of the assignee" do |
| 45 | + moderator.user_option.update!( |
| 46 | + notification_level_when_replying: TopicUser.notification_levels[:regular], |
| 47 | + ) |
| 48 | + |
| 49 | + assigner.assign(moderator) |
| 50 | + |
| 51 | + expect(TopicUser.find_by(user: moderator).notification_level).to eq( |
| 52 | + TopicUser.notification_levels[:regular], |
| 53 | + ) |
| 54 | + end |
| 55 | + |
| 56 | + it "defaults the notification level to watching" do |
| 57 | + moderator.user_option.update!(notification_level_when_replying: nil) |
| 58 | + |
| 59 | + assigner.assign(moderator) |
| 60 | + |
41 | 61 | expect(TopicUser.find_by(user: moderator).notification_level).to eq( |
42 | 62 | TopicUser.notification_levels[:watching], |
43 | 63 | ) |
|
111 | 131 | end |
112 | 132 |
|
113 | 133 | it "does not update notification level if already watching" do |
114 | | - TopicUser.change( |
115 | | - moderator.id, |
116 | | - topic.id, |
117 | | - notification_level: TopicUser.notification_levels[:watching], |
118 | | - ) |
| 134 | + notification_level = moderator.user_option.notification_level_when_replying |
| 135 | + |
| 136 | + TopicUser.change(moderator.id, topic.id, notification_level:) |
119 | 137 |
|
120 | 138 | expect do assigner_self.assign(moderator) end.to_not change { |
121 | 139 | TopicUser.last.notifications_reason_id |
122 | 140 | } |
123 | 141 | end |
124 | 142 |
|
125 | 143 | it "does not update notification level when unassigned" do |
| 144 | + notification_level = moderator.user_option.notification_level_when_replying |
| 145 | + |
126 | 146 | assigner.assign(moderator) |
127 | 147 |
|
128 | | - expect(TopicUser.find_by(user: moderator).notification_level).to eq( |
129 | | - TopicUser.notification_levels[:watching], |
130 | | - ) |
| 148 | + expect(TopicUser.find_by(user: moderator).notification_level).to eq(notification_level) |
131 | 149 |
|
132 | 150 | assigner.unassign |
133 | 151 |
|
134 | 152 | expect(TopicUser.find_by(user: moderator, topic: topic).notification_level).to eq( |
135 | | - TopicUser.notification_levels[:watching], |
| 153 | + notification_level, |
136 | 154 | ) |
137 | 155 | end |
138 | 156 |
|
|
0 commit comments