Skip to content

Commit

Permalink
FIX: Campaign banner should link to pricing table when enabled (#212)
Browse files Browse the repository at this point in the history
If the new pricing table is enabled the campaign banner should link to
the pricing table route.
  • Loading branch information
oblakeerickson committed May 15, 2024
1 parent 512f37a commit 542af4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</LinkTo>
{{else}}
<LinkTo
@route="subscribe"
@route={{this.subscribeRoute}}
class="btn btn-primary campaign-banner-info-button"
>
{{d-icon "far-heart"}}
Expand Down
12 changes: 11 additions & 1 deletion assets/javascripts/discourse/components/campaign-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default Component.extend({
amountRaised: setting("discourse_subscriptions_campaign_amount_raised"),
goalTarget: setting("discourse_subscriptions_campaign_goal"),
product: setting("discourse_subscriptions_campaign_product"),
pricingTableEnabled: setting("discourse_subscriptions_pricing_table_enabled"),
showContributors: setting(
"discourse_subscriptions_campaign_show_contributors"
),
Expand Down Expand Up @@ -126,7 +127,8 @@ export default Component.extend({
const showOnRoute =
currentRoute !== "discovery.s" &&
!currentRoute.split(".")[0].includes("admin") &&
currentRoute.split(".")[0] !== "subscribe";
currentRoute.split(".")[0] !== "subscribe" &&
currentRoute.split(".")[0] !== "subscriptions";

if (!this.site.show_campaign_banner) {
return false;
Expand Down Expand Up @@ -166,6 +168,14 @@ export default Component.extend({
);
},

@discourseComputed
subscribeRoute() {
if (this.pricingTableEnabled) {
return "subscriptions";
}
return "subscribe";
},

@discourseComputed
isGoalMet() {
const currentVolume = this.subscriberGoal
Expand Down
21 changes: 21 additions & 0 deletions spec/system/pricing_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
expect(uri.path).to eq("/s/subscriptions")
end

it "Links to the pricing table page from the campaign banner" do
sign_in(admin)
SiteSetting.discourse_subscriptions_campaign_enabled = true
visit("/")

link = find(".campaign-banner-info-button")
uri = URI.parse(link[:href])
expect(uri.path).to eq("/s/subscriptions")
end

it "Links to the old page when disabled" do
sign_in(admin)
SiteSetting.discourse_subscriptions_pricing_table_enabled = false
Expand All @@ -50,6 +60,17 @@
expect(uri.path).to eq("/s")
end

it "Links to the old page from the campaign banner when disabled" do
sign_in(admin)
SiteSetting.discourse_subscriptions_pricing_table_enabled = false
SiteSetting.discourse_subscriptions_campaign_enabled = true
visit("/")

link = find(".campaign-banner-info-button")
uri = URI.parse(link[:href])
expect(uri.path).to eq("/s")
end

it "Old subscribe page still works when disabled" do
sign_in(admin)
SiteSetting.discourse_subscriptions_pricing_table_enabled = false
Expand Down

0 comments on commit 542af4c

Please sign in to comment.