-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paywalls
: add support for multiple images in template configuration
#2832
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Tests/UnitTests/Networking/Responses/Fixtures/PaywallData-empty_images.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"template_name": "sample_1", | ||
"localized_strings": { | ||
"en_US": { | ||
"title": "Paywall", | ||
"subtitle": "Description", | ||
"call_to_action": "Purchase now", | ||
"call_to_action_with_intro_offer": "Purchase now", | ||
"offer_details": "{{ price_per_month }} per month", | ||
"offer_details_with_intro_offer": "Start your {{ intro_duration }} trial, then {{ price_per_month }} per month" | ||
} | ||
}, | ||
"default_locale": "en_US", | ||
"config": { | ||
"packages": ["$rc_monthly"], | ||
"images": [], | ||
"colors": { | ||
"light": { | ||
"background": "#FF00AA", | ||
"foreground": "#FF00AA22", | ||
"call_to_action_background": "#FF00AACC", | ||
"call_to_action_foreground": "#FF00AA" | ||
}, | ||
"dark": null | ||
} | ||
}, | ||
"asset_base_url": "https://rc-paywalls.s3.amazonaws.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ class PaywallDataTests: BaseHTTPResponseTest { | |
expect(paywall.defaultLocale) == Locale(identifier: Self.defaultLocale) | ||
expect(paywall.assetBaseURL) == URL(string: "https://rc-paywalls.s3.amazonaws.com")! | ||
expect(paywall.config.packages) == [.monthly, .annual] | ||
expect(paywall.config.headerImageName) == "asset_name.png" | ||
expect(paywall.config.imageNames) == ["asset_name.png"] | ||
|
||
expect(paywall.config.colors.light.background.stringRepresentation) == "#FF00AA" | ||
expect(paywall.config.colors.light.foreground.stringRepresentation) == "#FF00AA22" | ||
|
@@ -45,7 +45,9 @@ class PaywallDataTests: BaseHTTPResponseTest { | |
expect(paywall.config.colors.dark?.callToActionBackground.stringRepresentation) == "#112233AA" | ||
expect(paywall.config.colors.dark?.callToActionForeground.stringRepresentation) == "#AABBCC" | ||
|
||
expect(paywall.headerImageURL) == URL(string: "https://rc-paywalls.s3.amazonaws.com/asset_name.png")! | ||
expect(paywall.imageURLs) == [ | ||
URL(string: "https://rc-paywalls.s3.amazonaws.com/asset_name.png")! | ||
] | ||
|
||
let enConfig = try XCTUnwrap(paywall.config(for: Locale(identifier: "en_US"))) | ||
expect(enConfig.title) == "Paywall" | ||
|
@@ -79,6 +81,12 @@ class PaywallDataTests: BaseHTTPResponseTest { | |
expect(localization.title) == "Tienda" | ||
} | ||
|
||
func testFailsToDecodeWithNoImages() throws { | ||
expect { | ||
let _: PaywallData = try self.decodeFixture("PaywallData-empty_images") | ||
}.to(throwError(EnsureNonEmptyArrayDecodable<String>.Error())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm this should probably be a more precise error instead. |
||
} | ||
|
||
#if !os(watchOS) | ||
func testMissingCurrentAndDefaultFails() throws { | ||
let paywall: PaywallData = try self.decodeFixture("PaywallData-missing_current_and_default_locale") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guido732 @lburdock as discussed in the doc, this is now an array. The current template only supports 1 but allows us to display multiple images in future templates.
I've added validation when decoding it to ensure that this is not empty. It would be nice if the frontend did the same to make sure we never save a template without an image.