Add and apply RSpec/FilePath rubocop rule

This way we make sure editors which support navigating between one class
and its test file can find the alternative files.
This commit is contained in:
Javi Martín
2021-08-09 16:43:33 +02:00
parent 126f7bfb97
commit 535a039a31
7 changed files with 3 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
require "rails_helper"
describe RemoteTranslationsController, :remote_translations do
describe "POST create", :delay_jobs do
let(:debate) { create(:debate) }
let(:remote_translations_params) do
[{ remote_translatable_id: debate.id.to_s,
remote_translatable_type: debate.class.to_s,
locale: :es }].to_json
end
before do
request.env["HTTP_REFERER"] = "any_path"
end
it "create correctly remote translation" do
post :create, params: { remote_translations: remote_translations_params }
expect(RemoteTranslation.count).to eq(1)
end
it "create remote translation when same remote translation with error_message is enqueued" do
create(:remote_translation, remote_translatable: debate, locale: :es, error_message: "Has errors")
post :create, params: { remote_translations: remote_translations_params }
expect(RemoteTranslation.count).to eq(2)
end
it "not create remote translation when same remote translation is enqueued" do
create(:remote_translation, remote_translatable: debate, locale: :es)
post :create, params: { remote_translations: remote_translations_params }
expect(RemoteTranslation.count).to eq(1)
end
it "redirect_to request referer after create" do
post :create, params: { remote_translations: remote_translations_params }
expect(subject).to redirect_to("any_path")
end
end
end