|
21 | 21 | .with(category.description, target_locale)
|
22 | 22 | .returns("C'est une catégorie de test")
|
23 | 23 |
|
| 24 | + res = DiscourseTranslator::CategoryTranslator.translate(category, target_locale) |
| 25 | + |
| 26 | + expect(res.name).to eq("Catégorie de Test") |
| 27 | + expect(res.description).to eq("C'est une catégorie de test") |
| 28 | + end |
| 29 | + |
| 30 | + it "translates the category name and description" do |
| 31 | + localized = |
| 32 | + Fabricate( |
| 33 | + :category_localization, |
| 34 | + category: category, |
| 35 | + locale: target_locale, |
| 36 | + name: "X", |
| 37 | + description: "Y", |
| 38 | + ) |
| 39 | + translator |
| 40 | + .expects(:translate_text!) |
| 41 | + .with(category.name, target_locale) |
| 42 | + .returns("Catégorie de Test") |
| 43 | + translator |
| 44 | + .expects(:translate_text!) |
| 45 | + .with(category.description, target_locale) |
| 46 | + .returns("C'est une catégorie de test") |
| 47 | + |
24 | 48 | DiscourseTranslator::CategoryTranslator.translate(category, target_locale)
|
25 | 49 |
|
26 |
| - expect(category.name).to eq("Catégorie de Test") |
27 |
| - expect(category.description).to eq("C'est une catégorie de test") |
| 50 | + localized.reload |
| 51 | + expect(localized.name).to eq("Catégorie de Test") |
| 52 | + expect(localized.description).to eq("C'est une catégorie de test") |
28 | 53 | end
|
29 | 54 |
|
30 | 55 | it "handles locale format standardization" do
|
31 |
| - translator.expects(:translate_text!).with(category.name, :fr_CA).returns("Catégorie de Test") |
| 56 | + translator.expects(:translate_text!).with(category.name, :fr).returns("Catégorie de Test") |
32 | 57 | translator
|
33 | 58 | .expects(:translate_text!)
|
34 |
| - .with(category.description, :fr_CA) |
| 59 | + .with(category.description, :fr) |
35 | 60 | .returns("C'est une catégorie de test")
|
36 | 61 |
|
37 |
| - DiscourseTranslator::CategoryTranslator.translate(category, "fr-CA") |
| 62 | + res = DiscourseTranslator::CategoryTranslator.translate(category, "fr") |
38 | 63 |
|
39 |
| - expect(category.name).to eq("Catégorie de Test") |
40 |
| - expect(category.description).to eq("C'est une catégorie de test") |
| 64 | + expect(res.name).to eq("Catégorie de Test") |
| 65 | + expect(res.description).to eq("C'est une catégorie de test") |
41 | 66 | end
|
42 | 67 |
|
43 | 68 | it "returns nil if category is blank" do
|
|
56 | 81 | .with(category.description, :es)
|
57 | 82 | .returns("Esta es una categoría de prueba")
|
58 | 83 |
|
59 |
| - DiscourseTranslator::CategoryTranslator.translate(category) |
| 84 | + res = DiscourseTranslator::CategoryTranslator.translate(category) |
60 | 85 |
|
61 |
| - expect(category.name).to eq("Categoría de Prueba") |
62 |
| - expect(category.description).to eq("Esta es una categoría de prueba") |
| 86 | + expect(res.name).to eq("Categoría de Prueba") |
| 87 | + expect(res.description).to eq("Esta es una categoría de prueba") |
| 88 | + expect(res.locale).to eq("es") |
63 | 89 | end
|
64 | 90 | end
|
65 | 91 | end
|
0 commit comments