Files
grecia/spec/controllers/remote_translation_controller_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

46 lines
1.4 KiB
Ruby

require "rails_helper"
describe RemoteTranslationsController 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