Aggiunge annunci in-app/sito, contatti e migliora UI copertina sul portale.
Include admin/API/banner nativi, form contatti e reset copertina standard con layout edit più ampio. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe AppAnnouncement do
|
||||
def create_notice!(**attrs)
|
||||
described_class.create!({
|
||||
kind: "info",
|
||||
severity: "info",
|
||||
status: "published",
|
||||
title: "Avviso",
|
||||
body: "Testo",
|
||||
show_on_app: true,
|
||||
show_on_web_public: false,
|
||||
show_on_web_private: false
|
||||
}.merge(attrs))
|
||||
end
|
||||
|
||||
it "is active on the app when published without a time window" do
|
||||
item = create_notice!(kind: "maintenance", severity: "warning", title: "Manutenzione", body: "Domani dalle 2 alle 4.")
|
||||
|
||||
expect(described_class.for_app).to include(item)
|
||||
expect(described_class.for_channel(:web_public)).not_to include(item)
|
||||
end
|
||||
|
||||
it "hides drafts and expired notices" do
|
||||
create_notice!(status: "draft", title: "Bozza", body: "Non visibile")
|
||||
create_notice!(title: "Scaduto", body: "Fine", ends_at: 1.hour.ago)
|
||||
live = create_notice!(kind: "update", title: "Aggiornamento", body: "Nuova versione")
|
||||
|
||||
expect(described_class.for_app.map(&:title)).to eq(["Aggiornamento"])
|
||||
expect(live.as_api_json(platform: "android")[:action_url]).to eq(MatchLiveTv.play_store_url)
|
||||
expect(live.as_api_json(platform: "ios")[:action_url]).to eq(MatchLiveTv.app_store_url)
|
||||
end
|
||||
|
||||
it "filters by selected channels" do
|
||||
public_item = create_notice!(
|
||||
title: "Pubblico", show_on_app: false, show_on_web_public: true
|
||||
)
|
||||
private_item = create_notice!(
|
||||
title: "Privato", show_on_app: false, show_on_web_private: true
|
||||
)
|
||||
app_item = create_notice!(title: "App")
|
||||
|
||||
expect(described_class.for_channel(:web_public)).to contain_exactly(public_item)
|
||||
expect(described_class.for_channel(:web_private)).to contain_exactly(private_item)
|
||||
expect(described_class.for_app).to contain_exactly(app_item)
|
||||
end
|
||||
|
||||
it "requires at least one channel" do
|
||||
item = described_class.new(
|
||||
kind: "info", status: "draft", title: "X", body: "Y",
|
||||
show_on_app: false, show_on_web_public: false, show_on_web_private: false
|
||||
)
|
||||
expect(item).not_to be_valid
|
||||
expect(item.errors[:base]).to be_present
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user