|
126 | 126 | fab!(:private_category) { Fabricate(:private_category, group: Group[:staff]) } |
127 | 127 | fab!(:private_topic) { Fabricate(:topic, category: private_category) } |
128 | 128 | fab!(:private_post) { Fabricate(:post, topic: private_topic, locale: "es") } |
| 129 | + |
| 130 | + fab!(:pm_post) { Fabricate(:post, topic: Fabricate(:private_message_topic), locale: "es") } |
| 131 | + |
129 | 132 | fab!(:public_post) { Fabricate(:post, locale: "es") } |
130 | 133 |
|
131 | | - before { SiteSetting.ai_translation_backfill_limit_to_public_content = true } |
| 134 | + before do |
| 135 | + SiteSetting.ai_translation_backfill_limit_to_public_content = true |
| 136 | + SiteSetting.experimental_content_localization_supported_locales = "ja" |
| 137 | + end |
132 | 138 |
|
133 | 139 | it "only processes posts from public categories" do |
134 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "en").once |
135 | 140 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "ja").once |
136 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "de").once |
137 | 141 |
|
138 | 142 | DiscourseAi::Translation::PostLocalizer |
139 | 143 | .expects(:localize) |
140 | 144 | .with(private_post, any_parameters) |
141 | 145 | .never |
142 | 146 |
|
| 147 | + DiscourseAi::Translation::PostLocalizer.expects(:localize).with(pm_post, any_parameters).never |
| 148 | + |
143 | 149 | job.execute({}) |
144 | 150 | end |
145 | 151 |
|
146 | 152 | it "processes all posts when setting is disabled" do |
147 | 153 | SiteSetting.ai_translation_backfill_limit_to_public_content = false |
148 | 154 |
|
149 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "en").once |
150 | 155 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "ja").once |
151 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(public_post, "de").once |
152 | | - |
153 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(private_post, "en").once |
| 156 | + DiscourseAi::Translation::PostLocalizer.expects(:localize).with(pm_post, "ja").once |
154 | 157 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(private_post, "ja").once |
155 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(private_post, "de").once |
156 | 158 |
|
157 | 159 | job.execute({}) |
158 | 160 | end |
|
162 | 164 | fab!(:old_post) { Fabricate(:post, locale: "es", created_at: 10.days.ago) } |
163 | 165 | fab!(:new_post) { Fabricate(:post, locale: "es", created_at: 2.days.ago) } |
164 | 166 |
|
165 | | - before { SiteSetting.ai_translation_backfill_max_age_days = 5 } |
| 167 | + before do |
| 168 | + SiteSetting.ai_translation_backfill_max_age_days = 5 |
| 169 | + SiteSetting.experimental_content_localization_supported_locales = "ja" |
| 170 | + end |
166 | 171 |
|
167 | 172 | it "only processes posts within the age limit" do |
168 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "en").once |
169 | 173 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "ja").once |
170 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "de").once |
171 | 174 |
|
172 | 175 | DiscourseAi::Translation::PostLocalizer |
173 | 176 | .expects(:localize) |
|
180 | 183 | it "processes all posts when setting is disabled" do |
181 | 184 | SiteSetting.ai_translation_backfill_max_age_days = 0 |
182 | 185 |
|
183 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "en").once |
184 | 186 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "ja").once |
185 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(new_post, "de").once |
186 | 187 |
|
187 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(old_post, "en").once |
188 | 188 | DiscourseAi::Translation::PostLocalizer.expects(:localize).with(old_post, "ja").once |
189 | | - DiscourseAi::Translation::PostLocalizer.expects(:localize).with(old_post, "de").once |
190 | 189 |
|
191 | 190 | job.execute({}) |
192 | 191 | end |
|
0 commit comments