Aggiunge traduzioni it/en/fr/de/es agli avvisi e toglie gli override Android/iOS.
Un avviso ha un testo per lingua; per differenziare le piattaforme si creano due avvisi. L'app riceve già il copy risolto da Accept-Language. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,12 +31,10 @@ RSpec.describe "Api::V1::Announcements", type: :request do
|
||||
AppAnnouncement.create!(
|
||||
kind: "update",
|
||||
status: "published",
|
||||
title: "Aggiorna",
|
||||
title: "Aggiorna Android",
|
||||
body: "Versione nuova",
|
||||
show_on_android: true,
|
||||
show_on_ios: false,
|
||||
android_title: "Aggiorna Android",
|
||||
android_action_url: "https://play.google.com/store/apps/details?id=com.matchlivetv.match_live_tv"
|
||||
show_on_ios: false
|
||||
)
|
||||
|
||||
get "/api/v1/announcements", params: { platform: "android" }
|
||||
@@ -51,4 +49,29 @@ RSpec.describe "Api::V1::Announcements", type: :request do
|
||||
ios_body = JSON.parse(response.body)
|
||||
expect(ios_body.map { |row| row["title"] }).to eq(["Manutenzione stasera"])
|
||||
end
|
||||
|
||||
it "GET /api/v1/announcements localizza il testo da Accept-Language" do
|
||||
AppAnnouncement.create!(
|
||||
kind: "info",
|
||||
status: "published",
|
||||
title: "Manutenzione stasera",
|
||||
body: "Dalle 23:00 il servizio sarà offline.",
|
||||
show_on_android: true,
|
||||
show_on_ios: true,
|
||||
translations: {
|
||||
"en" => { "title" => "Maintenance tonight", "body" => "The service will be offline from 23:00." }
|
||||
}
|
||||
)
|
||||
|
||||
get "/api/v1/announcements", params: { platform: "android" }, headers: { "Accept-Language" => "en-US,en;q=0.9" }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
payload = JSON.parse(response.body)
|
||||
expect(payload.first["title"]).to eq("Maintenance tonight")
|
||||
expect(payload.first["body"]).to include("offline")
|
||||
|
||||
get "/api/v1/announcements", params: { platform: "android" }, headers: { "Accept-Language" => "fr" }
|
||||
|
||||
expect(JSON.parse(response.body).first["title"]).to eq("Maintenance tonight")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user