FIX: Redirect to the pricing table page when enabled (#239)
If the pricing table is enabled the `/s` route should redirect to the pricing table route and vice versa. Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
parent
937d099692
commit
eecb17698f
|
@ -1,3 +1,16 @@
|
||||||
import Route from "@ember/routing/route";
|
import Route from "@ember/routing/route";
|
||||||
|
import { service } from "@ember/service";
|
||||||
|
|
||||||
export default Route.extend();
|
export default class SubscribeRoute extends Route {
|
||||||
|
@service router;
|
||||||
|
@service siteSettings;
|
||||||
|
|
||||||
|
beforeModel() {
|
||||||
|
const pricingTableEnabled =
|
||||||
|
this.siteSettings.discourse_subscriptions_pricing_table_enabled;
|
||||||
|
|
||||||
|
if (pricingTableEnabled) {
|
||||||
|
this.router.transitionTo("subscriptions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import Route from "@ember/routing/route";
|
||||||
|
import { service } from "@ember/service";
|
||||||
|
|
||||||
|
export default class SubscriptionsRoute extends Route {
|
||||||
|
@service router;
|
||||||
|
@service siteSettings;
|
||||||
|
|
||||||
|
beforeModel() {
|
||||||
|
const pricingTableEnabled =
|
||||||
|
this.siteSettings.discourse_subscriptions_pricing_table_enabled;
|
||||||
|
|
||||||
|
if (!pricingTableEnabled) {
|
||||||
|
this.router.transitionTo("subscribe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -102,4 +102,19 @@ RSpec.describe "Pricing Table", type: :system, js: true do
|
||||||
text: "Log in or create an account to subscribe.",
|
text: "Log in or create an account to subscribe.",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "Redirects to the pricing table page if enabled" do
|
||||||
|
sign_in(admin)
|
||||||
|
visit("/s")
|
||||||
|
|
||||||
|
try_until_success { expect(current_url).to match("/s/subscriptions") }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "Redirects to /s if pricing table is not enabled" do
|
||||||
|
sign_in(admin)
|
||||||
|
SiteSetting.discourse_subscriptions_campaign_enabled = false
|
||||||
|
visit("/s/subscriptions")
|
||||||
|
|
||||||
|
try_until_success { expect(current_url).to match("/s") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue