Skip to content

Commit 723402b

Browse files
committed
Remove all traces of CUSTOM_FIELD except in the migration spec
1 parent 33aab2b commit 723402b

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

plugin.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
module ::DiscourseTranslator
1717
PLUGIN_NAME = "discourse-translator".freeze
1818

19-
DETECTED_LANG_CUSTOM_FIELD = "post_detected_lang".freeze
20-
TRANSLATED_CUSTOM_FIELD = "translated_text".freeze
2119
LANG_DETECT_NEEDED = "lang_detect_needed".freeze
2220
end
2321

spec/jobs/detect_posts_language_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
posts.each do |post|
3737
post.reload
38-
expect(post.custom_fields[DiscourseTranslator::DETECTED_LANG_CUSTOM_FIELD]).to be_nil
38+
expect(post.detected_locale).to be_nil
3939
end
4040

4141
expect(Discourse.redis.smembers(redis_key)).to match_array(posts.map(&:id).map(&:to_s))

spec/lib/guardian_extension_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,18 @@
151151
describe "locale is :xx" do
152152
before { I18n.stubs(:locale).returns(:pt) }
153153

154-
it "cannot translate when post does not have DETECTED_LANG_CUSTOM_FIELD" do
154+
it "cannot translate when post does not have detected locale" do
155+
expect(post.detected_locale).to eq(nil)
155156
expect(guardian.can_translate?(post)).to eq(false)
156157
end
157158

158-
it "cannot translate when post has DETECTED_LANG_CUSTOM_FIELD matches locale" do
159+
it "cannot translate when post detected locale matches i18n locale" do
159160
post.set_detected_locale("pt")
160161

161162
expect(guardian.can_translate?(post)).to eq(false)
162163
end
163164

164-
it "can translate when post has DETECTED_LANG_CUSTOM_FIELD does not match locale" do
165+
it "can translate when post detected locale does not match i18n locale" do
165166
post.set_detected_locale("jp")
166167

167168
expect(guardian.can_translate?(post)).to eq(true)

spec/models/translation_tables_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
module DiscourseTranslator
66
describe MoveTranslationsCustomFieldsToTable do
7+
DETECTED_LANG_CUSTOM_FIELD = "post_detected_lang".freeze
8+
TRANSLATED_CUSTOM_FIELD = "translated_text".freeze
9+
710
let!(:batch_size) { 3 }
811

912
before { described_class.const_set(:BATCH_SIZE, batch_size) }

spec/serializers/post_serializer_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@
5858
I18n.stubs(:locale).returns(:pt)
5959
end
6060

61-
it "cannot translate when post does not have DETECTED_LANG_CUSTOM_FIELD" do
61+
it "cannot translate when post does not have detected locale" do
62+
expect(post.detected_locale).to eq(nil)
6263
expect(serializer.can_translate).to eq(false)
6364
end
6465

65-
it "cannot translate when post has DETECTED_LANG_CUSTOM_FIELD matches locale" do
66+
it "cannot translate when post detected locale matches i18n locale" do
6667
post.set_detected_locale("pt")
6768

6869
expect(serializer.can_translate).to eq(false)
6970
end
7071

71-
it "can translate when post has DETECTED_LANG_CUSTOM_FIELD does not match locale" do
72+
it "can translate when post detected locale does not match i18n locale" do
7273
post.set_detected_locale("jp")
7374

7475
expect(serializer.can_translate).to eq(true)

0 commit comments

Comments
 (0)