Add RemoteTranslationsCaller to new namespace
- Rename to Caller - Add to new namespace RemoteTranslations - Update references to new namespace
This commit is contained in:
@@ -9,7 +9,7 @@ class RemoteTranslation < ApplicationRecord
|
||||
after_create :enqueue_remote_translation
|
||||
|
||||
def enqueue_remote_translation
|
||||
RemoteTranslationsCaller.new(self).delay.call
|
||||
RemoteTranslations::Caller.new(self).delay.call
|
||||
end
|
||||
|
||||
def self.remote_translation_enqueued?(remote_translation)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class RemoteTranslationsCaller
|
||||
class RemoteTranslations::Caller
|
||||
attr_reader :remote_translation
|
||||
|
||||
def initialize(remote_translation)
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe RemoteTranslationsCaller do
|
||||
describe RemoteTranslations::Caller do
|
||||
|
||||
before do
|
||||
RemoteTranslation.skip_callback(:create, :after, :enqueue_remote_translation)
|
||||
@@ -17,13 +17,13 @@ describe RemoteTranslationsCaller do
|
||||
let(:debate) { create(:debate) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: debate, locale: :es) }
|
||||
let(:remote_translation_caller) { described_class.new(remote_translation) }
|
||||
let(:caller) { described_class.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
response = ["Título traducido", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(debate.translations.count).to eq(2)
|
||||
end
|
||||
@@ -32,7 +32,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["TT", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to eq nil
|
||||
expect(debate.translations.count).to eq(2)
|
||||
@@ -43,7 +43,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to include("can't be blank")
|
||||
expect(debate.translations.count).to eq(1)
|
||||
@@ -54,7 +54,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["Título traducido", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(RemoteTranslation.count).to eq(0)
|
||||
end
|
||||
@@ -65,14 +65,14 @@ describe RemoteTranslationsCaller do
|
||||
let!(:proposal) { create(:proposal) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: proposal, locale: :es) }
|
||||
let(:remote_translation_caller) { described_class.new(remote_translation) }
|
||||
let(:caller) { described_class.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
response = ["Título traducido", "Descripción traducida", "Pregunta traducida",
|
||||
"Resumen traducido", nil]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(proposal.translations.count).to eq(2)
|
||||
end
|
||||
@@ -81,7 +81,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["TT", "Descripción traducida", "Pregunta traducida", "Resumen traducido", nil]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to eq nil
|
||||
expect(proposal.translations.count).to eq(2)
|
||||
@@ -92,7 +92,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["", "Descripción traducida", "Pregunta traducida", "Resumen traducido", nil]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to include("can't be blank")
|
||||
expect(proposal.translations.count).to eq(1)
|
||||
@@ -104,7 +104,7 @@ describe RemoteTranslationsCaller do
|
||||
"Resumen traducido", nil]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(RemoteTranslation.count).to eq(0)
|
||||
end
|
||||
@@ -116,13 +116,13 @@ describe RemoteTranslationsCaller do
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: budget_investment,
|
||||
locale: :es) }
|
||||
let(:remote_translation_caller) { described_class.new(remote_translation) }
|
||||
let(:caller) { described_class.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
response = ["Título traducido", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(budget_investment.translations.count).to eq(2)
|
||||
end
|
||||
@@ -131,7 +131,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["TT", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to eq nil
|
||||
expect(budget_investment.translations.count).to eq(2)
|
||||
@@ -142,7 +142,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to include("can't be blank")
|
||||
expect(budget_investment.translations.count).to eq(1)
|
||||
@@ -153,7 +153,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["Título traducido", "Descripción traducida"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(RemoteTranslation.count).to eq(0)
|
||||
end
|
||||
@@ -164,13 +164,13 @@ describe RemoteTranslationsCaller do
|
||||
let(:comment) { create(:comment) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: comment, locale: :es) }
|
||||
let(:remote_translation_caller) { described_class.new(remote_translation) }
|
||||
let(:caller) { described_class.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
response = ["Body traducido"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(comment.translations.count).to eq(2)
|
||||
end
|
||||
@@ -179,7 +179,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["BT"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to eq nil
|
||||
expect(comment.translations.count).to eq(2)
|
||||
@@ -190,7 +190,7 @@ describe RemoteTranslationsCaller do
|
||||
response = [""]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(remote_translation.error_message).to include("can't be blank")
|
||||
expect(comment.translations.count).to eq(1)
|
||||
@@ -201,7 +201,7 @@ describe RemoteTranslationsCaller do
|
||||
response = ["Body traducido"]
|
||||
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(response)
|
||||
|
||||
remote_translation_caller.call
|
||||
caller.call
|
||||
|
||||
expect(RemoteTranslation.count).to eq(0)
|
||||
end
|
||||
Reference in New Issue
Block a user