Skip to content

Commit

Permalink
Add alternative wording for US and US Exclusive sponsorship packages
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfurey committed Feb 21, 2024
1 parent 82fb7e5 commit 7bf78b9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/com/gu/commercial/branding/Branding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object Branding {
logo = Logo.make(
title = webTitle,
sponsorshipType = sponsorship.sponsorshipType,
sponsorshipPackage = sponsorship.sponsorshipPackage,
src = sponsorship.sponsorLogo,
dimensions = sponsorship.sponsorLogoDimensions,
link = sponsorship.sponsorLink
Expand All @@ -40,6 +41,7 @@ object Branding {
Logo.make(
title = webTitle,
sponsorshipType = sponsorship.sponsorshipType,
sponsorshipPackage = sponsorship.sponsorshipPackage,
src,
dimensions = sponsorship.highContrastSponsorLogoDimensions,
link = sponsorship.sponsorLink
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/com/gu/commercial/branding/Logo.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gu.commercial.branding

import com.gu.contentapi.client.model.v1.{SponsorshipLogoDimensions, SponsorshipType}
import com.gu.contentapi.client.model.v1.{SponsorshipLogoDimensions, SponsorshipPackage, SponsorshipType}

case class Logo(
src: String,
Expand All @@ -17,6 +17,7 @@ object Logo {
def make(
title: String,
sponsorshipType: SponsorshipType,
sponsorshipPackage: Option[SponsorshipPackage],
src: String,
dimensions: Option[SponsorshipLogoDimensions],
link: String
Expand All @@ -29,6 +30,8 @@ object Logo {
case SponsorshipType.PaidContent => "Paid for by"
case SponsorshipType.Foundation =>
s"${sensitiveTitles.getOrElse(title, title)} is supported by"
case _ if sponsorshipPackage.contains(SponsorshipPackage.Us) => "Advertising partner"
case _ if sponsorshipPackage.contains(SponsorshipPackage.UsExclusive) => "Exclusive advertising partner"
case _ => "Supported by"
}
)
Expand Down
11 changes: 9 additions & 2 deletions src/test/scala/com/gu/commercial/TestModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ object TestModel {
implicit object SponsorshipTypeNamer extends HasName[SponsorshipType] {
def nameOf(t: SponsorshipType): String = t.name
}
implicit object SponsorshipPackageNamer extends HasName[SponsorshipPackage] {
def nameOf(t: SponsorshipPackage): String = t.name
}
}

object StubJsonReads {
Expand All @@ -47,8 +50,11 @@ object TestModel {
implicit val readsBooleanFromString = implicitly[Reads[String]].map(_.toBoolean) ; Json.reads[StubFields]
}

implicit val readsTestSponsorship =
{ implicit val readsType = readFrom(SponsorshipType.list) ; Json.reads[TestSponsorship] }
implicit val readsTestSponsorship = {
implicit val readsType = readFrom(SponsorshipType.list)
implicit val readsPackage = readFrom(SponsorshipPackage.list)
Json.reads[TestSponsorship]
}

implicit val readsStubSection = Json.reads[StubSection]

Expand Down Expand Up @@ -82,6 +88,7 @@ object TestModel {

case class TestSponsorship(
sponsorshipType: SponsorshipType,
sponsorshipPackage: Option[SponsorshipPackage],
sponsorName: String,
sponsorLogo: String,
sponsorLink: String,
Expand Down
32 changes: 24 additions & 8 deletions src/test/scala/com/gu/commercial/branding/LogoSpec.scala
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
package com.gu.commercial.branding

import com.gu.contentapi.client.model.v1.SponsorshipType
import com.gu.contentapi.client.model.v1.{SponsorshipPackage, SponsorshipType}
import org.scalatest.{FlatSpec, Matchers, OptionValues}

class LogoSpec extends FlatSpec with Matchers with OptionValues {

private def mkLogo(sponsorshipType: SponsorshipType, webTitle: String = "") = Logo.make(
private def mkLogo(sponsorshipType: SponsorshipType, sponsorshipPackage: Option[SponsorshipPackage], webTitle: String = "") = Logo.make(
title = webTitle,
sponsorshipType = sponsorshipType,
sponsorshipPackage = sponsorshipPackage,
src = "src",
dimensions = None,
link = "link"
)

"make" should "generate the correct label for sponsored content" in {
val logo = mkLogo(SponsorshipType.Sponsored)
"make" should "generate the correct label for sponsored content with unspecified sponsorship package" in {
val logo = mkLogo(SponsorshipType.Sponsored, None)
logo.label shouldBe "Supported by"
}

"make" should "generate the correct label for sponsored content with default sponsorship package" in {
val logo = mkLogo(SponsorshipType.Sponsored, Some(SponsorshipPackage.Default))
logo.label shouldBe "Supported by"
}

"make" should "generate the correct label for sponsored content with US sponsorship package" in {
val logo = mkLogo(SponsorshipType.Sponsored, Some(SponsorshipPackage.Us))
logo.label shouldBe "Advertising partner"
}

"make" should "generate the correct label for sponsored content with US exclusive package" in {
val logo = mkLogo(SponsorshipType.Sponsored, Some(SponsorshipPackage.UsExclusive))
logo.label shouldBe "Exclusive advertising partner"
}

it should "generate the correct label for paid content" in {
val logo = mkLogo(SponsorshipType.PaidContent)
val logo = mkLogo(SponsorshipType.PaidContent, None)
logo.label shouldBe "Paid for by"
}

it should "generate the correct label for foundation-funded content" in {
val logo = mkLogo(SponsorshipType.Foundation, webTitle = "Some title")
val logo = mkLogo(SponsorshipType.Foundation, None, webTitle = "Some title")
logo.label shouldBe "Some title is supported by"
}

it should "generate the correct label for the special inequality foundation-funded section" in {
val logo = mkLogo(SponsorshipType.Foundation, webTitle = "Inequality")
val logo = mkLogo(SponsorshipType.Foundation, None, webTitle = "Inequality")
logo.label shouldBe "The Inequality Project is supported by"
}

it should "generate the correct label for the special America's unequal future foundation-funded section" in {
val logo = mkLogo(SponsorshipType.Foundation, webTitle = "Inequality and Opportunity in America")
val logo = mkLogo(SponsorshipType.Foundation, None, webTitle = "Inequality and Opportunity in America")
logo.label shouldBe "This series is supported by"
}
}

0 comments on commit 7bf78b9

Please sign in to comment.