Skip to content

Commit

Permalink
Fix specs after new Deutsch translations
Browse files Browse the repository at this point in the history
New deutsch translations of remote translations
interface have broke these specs where we were
using English translations at specs to do the checks
while the spec interface was in deutsch and now we
have deutsch translations for the interface application
is not returning english fallbacks anymore and a lot of
specs of this file fails.

This commits also changes the alternative language
used at spec from deutsch to spanish which is
maintaned by code not through Crowdin, so if any
developer update current spanish translations for the
user interface this specs will fail.
  • Loading branch information
Senen committed Dec 18, 2019
1 parent 7ceb42e commit 5fa02f6
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions spec/shared/features/remotely_translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,40 @@
scenario "should be present when current locale translation does not exists", :js do
visit path

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).to have_button("Translate page")
expect(page).to have_button("Traducir página")
end

scenario "should not be present when new current locale translation exists", :js do
add_translations(resource)
add_translations(resource, :es)
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end

scenario "should not be present when there are no resources to translate", :js do
skip("only index_path") if show_path?(path_name)
resource.destroy!
visit path

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end

describe "with delayed job active", :delay_jobs do
scenario "should not be present when an equal RemoteTranslation is enqueued", :js do
create(:remote_translation, remote_translatable: resource, locale: :de)
create(:remote_translation, remote_translatable: resource, locale: :es)
visit path

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button("Translate page")
expect(page).to have_content("In a short period of time refreshing the page you will be able to see all the content in your language.")
expect(page).not_to have_button("Traducir página")
expect(page).to have_content("En un breve periodo de tiempo refrescando la página podrá ver todo el contenido en su idioma")
end
end

Expand All @@ -69,14 +69,14 @@
end

scenario "is not present when a resource translation exists but its comment has not tanslations", :js do
add_translations(resource)
add_translations(resource, :es)
create(:comment, commentable: resource)
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end
end

Expand All @@ -88,55 +88,55 @@
end

scenario "display when exists resource translations but the comment does not have a translation", :js do
add_translations(resource)
add_translations(resource, :es)
create(:comment, commentable: resource)
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).to have_button("Translate page")
expect(page).to have_button("Traducir página")
end

scenario "not display when exists resource translations but his comment has tanslations", :js do
add_translations(resource)
create_comment_with_translations(resource)
add_translations(resource, :es)
create_comment_with_translations(resource, :es)
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end
end

describe "should evaluate missing translations on featured_debates" do
before { skip("only debates index path") if path_name != "debates_path" }

scenario "display when exists featured_debates without tanslations", :js do
add_translations(resource)
add_translations(resource, :es)
create_featured_debates
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).to have_button("Translate page")
expect(page).to have_button("Traducir página")
end
end

describe "should evaluate missing translations on featured_proposals" do
before { skip("only proposals index path") if path_name != "proposals_path" }

scenario "display when exists featured_proposals without tanslations", :js do
add_translations(resource)
add_translations(resource, :es)
create_featured_proposals
visit path
expect(page).not_to have_button("Translate page")

select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).to have_button("Translate page")
expect(page).to have_button("Traducir página")
end
end
end
Expand All @@ -145,42 +145,42 @@
describe "with delayed jobs", :delay_jobs do
scenario "the remote translation button should not be present", :js do
visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

click_button "Translate page"
click_button "Traducir página"

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end

scenario "the remote translation is pending to translate", :js do
visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect { click_button "Translate page" }.to change { RemoteTranslation.count }.from(0).to(1)
expect { click_button "Traducir página" }.to change { RemoteTranslation.count }.from(0).to(1)
end

scenario "should be present enqueued notice and informative text", :js do
visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

click_button "Translate page"
click_button "Traducir página"

expect(page).to have_content("Translations have been correctly requested.")
expect(page).to have_content("In a short period of time refreshing the page you will be able to see all the content in your language.")
expect(page).to have_content("Se han solicitado correctamente las traducciones.")
expect(page).to have_content("En un breve periodo de tiempo refrescando la página podrá ver todo el contenido en su idioma")
end

scenario "should be present only informative text when user visit page with all content enqueued", :js do
visit path
select("Deutsch", from: "locale-switcher")
click_button "Translate page"
expect(page).to have_content("Translations have been correctly requested.")
select("Español", from: "locale-switcher")
click_button "Traducir página"
expect(page).to have_content("Se han solicitado correctamente las traducciones.")

visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

expect(page).not_to have_button "Translate text"
expect(page).not_to have_content("Translations have been correctly requested.")
expect(page).to have_content("In a short period of time refreshing the page you will be able to see all the content in your language.")
expect(page).not_to have_button "Traducir página"
expect(page).not_to have_content("Se han solicitado correctamente las traducciones.")
expect(page).to have_content("En un breve periodo de tiempo refrescando la página podrá ver todo el contenido en su idioma")
end
end

Expand All @@ -189,20 +189,20 @@
microsoft_translate_client_response = generate_response(resource)
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

click_button "Translate page"
click_button "Traducir página"

expect(page).not_to have_button("Translate page")
expect(page).not_to have_button("Traducir página")
end

scenario "the remote translation has been translated and destoyed", :js do
microsoft_translate_client_response = generate_response(resource)
expect_any_instance_of(RemoteTranslations::Microsoft::Client).to receive(:call).and_return(microsoft_translate_client_response)
visit path
select("Deutsch", from: "locale-switcher")
select("Español", from: "locale-switcher")

click_button "Translate page"
click_button "Traducir página"

expect(RemoteTranslation.count).to eq(0)
expect(resource.translations.count).to eq(2)
Expand All @@ -211,15 +211,15 @@
end
end

def add_translations(resource)
def add_translations(resource, locale)
new_translation = resource.translations.first.dup
new_translation.update!(locale: :de)
new_translation.update!(locale: locale)
resource
end

def create_comment_with_translations(resource)
def create_comment_with_translations(resource, locale)
comment = create(:comment, commentable: resource)
add_translations(comment)
add_translations(comment, locale)
end

def index_path?(path)
Expand Down

0 comments on commit 5fa02f6

Please sign in to comment.