|
19 | 19 | end |
20 | 20 |
|
21 | 21 | describe "when translator enabled" do |
22 | | - before { SiteSetting.translator_enabled = true } |
23 | | - |
24 | | - describe "anon user" do |
25 | | - let(:serializer) { PostSerializer.new(post, scope: Guardian.new) } |
26 | | - |
27 | | - before do |
28 | | - SiteSetting.restrict_translation_by_group = "#{Group::AUTO_GROUPS[:everyone]}" |
29 | | - SiteSetting.restrict_translation_by_poster_group = "" |
30 | | - end |
| 22 | + before do |
| 23 | + SiteSetting.translator_enabled = true |
| 24 | + SiteSetting.restrict_translation_by_group = "#{Group::AUTO_GROUPS[:everyone]}" |
| 25 | + SiteSetting.restrict_translation_by_poster_group = "" |
| 26 | + end |
| 27 | + let(:serializer) { PostSerializer.new(post, scope: Guardian.new) } |
31 | 28 |
|
32 | | - it "cannot translate" do |
33 | | - expect(serializer.can_translate).to eq(false) |
34 | | - end |
| 29 | + it "cannot translate for anon" do |
| 30 | + expect(serializer.can_translate).to eq(false) |
35 | 31 | end |
36 | 32 |
|
37 | 33 | describe "logged in user" do |
|
44 | 40 | end |
45 | 41 |
|
46 | 42 | describe "user is in restrict_translation_by_group" do |
47 | | - before { SiteSetting.restrict_translation_by_group = "#{group.id}" } |
48 | | - |
49 | | - it "cannot translate when post author is not in restrict_translation_by_poster_group" do |
50 | | - SiteSetting.restrict_translation_by_poster_group = "#{group.id}" |
51 | | - |
52 | | - expect(serializer.can_translate).to eq(false) |
53 | | - end |
54 | | - |
55 | 43 | describe "post author in restrict_translation_by_poster_group and locale is :xx" do |
56 | | - before do |
| 44 | + it "can translate when post detected locale does not match i18n locale" do |
| 45 | + SiteSetting.restrict_translation_by_group = "#{group.id}" |
57 | 46 | SiteSetting.restrict_translation_by_poster_group = "#{post_user_group.id}" |
58 | 47 | I18n.stubs(:locale).returns(:pt) |
59 | | - end |
60 | | - |
61 | | - it "cannot translate when post does not have detected locale" do |
62 | | - expect(post.detected_locale).to eq(nil) |
63 | | - expect(serializer.can_translate).to eq(false) |
64 | | - end |
65 | 48 |
|
66 | | - it "cannot translate when post detected locale matches i18n locale" do |
67 | | - post.set_detected_locale("pt") |
68 | | - |
69 | | - expect(serializer.can_translate).to eq(false) |
70 | | - end |
71 | | - |
72 | | - it "can translate when post detected locale does not match i18n locale" do |
73 | 49 | post.set_detected_locale("jp") |
74 | 50 |
|
75 | 51 | expect(serializer.can_translate).to eq(true) |
|
0 commit comments