mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
commit
bf56db8d77
@ -523,7 +523,7 @@ class ContentController < ApplicationController
|
||||
@navbar_actions << {
|
||||
label: "New #{content_type.name.downcase}",
|
||||
href: main_app.new_polymorphic_path(content_type)
|
||||
}
|
||||
} if current_user.can_create?(content_type)
|
||||
|
||||
discussions_link = ForumsLinkbuilderService.worldbuilding_url(content_type)
|
||||
if discussions_link.present?
|
||||
@ -551,11 +551,11 @@ class ContentController < ApplicationController
|
||||
href: main_app.polymorphic_path(content_type)
|
||||
}
|
||||
end
|
||||
#
|
||||
# @navbar_actions << {
|
||||
# label: "New #{content_type.name.downcase}",
|
||||
# href: main_app.new_polymorphic_path(content_type)
|
||||
# }
|
||||
|
||||
@navbar_actions << {
|
||||
label: "New #{content_type.name.downcase}",
|
||||
href: main_app.new_polymorphic_path(content_type)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -13,7 +13,9 @@ class SubscriptionService < Service
|
||||
# Add any one-time referral bonuses
|
||||
add_any_referral_bonuses(user, plan_id)
|
||||
|
||||
user.update(selected_billing_plan_id: related_plan.id)
|
||||
# We intentionally skip callbacks on this to ensure the billing plan changes even on invalid users
|
||||
user.update_column(:selected_billing_plan_id, related_plan.id)
|
||||
|
||||
user.subscriptions.create(
|
||||
billing_plan: related_plan,
|
||||
start_date: DateTime.now,
|
||||
|
||||
@ -88,5 +88,22 @@
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="col s12 m6 l4">
|
||||
<div class="card <%= content_type.color %> lighten-3" style="height: 440px;">
|
||||
<div class="card-content fixed-card-content">
|
||||
<p class="center grey-text text-lighten-1" style="margin-top: 50px; margin-bottom: 20px;">
|
||||
<i class="material-icons large"><%= content_type.icon %></i>
|
||||
</p>
|
||||
<p>
|
||||
An active
|
||||
<%= link_to 'Notebook.ai Premium', subscription_path, class: 'blue-text text-darken-2' %> subscription
|
||||
is required to create additional
|
||||
<%= content_type.name.downcase %> pages, but pages you've already created will always
|
||||
be available here.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@ -48,6 +48,36 @@ RSpec.describe SubscriptionsController, type: :controller do
|
||||
@user.update(stripe_customer_id: 'stripe-id')
|
||||
sign_in @user
|
||||
|
||||
@free_plan = BillingPlan.create(
|
||||
name: 'Starter',
|
||||
stripe_plan_id: 'starter',
|
||||
monthly_cents: 0, # $0.00/mo
|
||||
available: true,
|
||||
|
||||
# Content creation and other permissions:
|
||||
universe_limit: 5,
|
||||
allows_core_content: true,
|
||||
allows_extended_content: false,
|
||||
allows_collective_content: false,
|
||||
allows_collaboration: false,
|
||||
bonus_bandwidth_kb: 123155
|
||||
)
|
||||
|
||||
@beta_plan = BillingPlan.create(
|
||||
name: 'Early Adopters',
|
||||
stripe_plan_id: 'early-adopters',
|
||||
monthly_cents: 0, # $0.00/mo
|
||||
available: true,
|
||||
|
||||
# Content creation and other permissions:
|
||||
universe_limit: 5,
|
||||
allows_core_content: true,
|
||||
allows_extended_content: false,
|
||||
allows_collective_content: false,
|
||||
allows_collaboration: false,
|
||||
bonus_bandwidth_kb: 123155
|
||||
)
|
||||
|
||||
@premium_plan = BillingPlan.create(
|
||||
name: 'Premium',
|
||||
stripe_plan_id: 'premium',
|
||||
@ -73,21 +103,6 @@ RSpec.describe SubscriptionsController, type: :controller do
|
||||
allows_collaboration: true,
|
||||
bonus_bandwidth_kb: 123155
|
||||
)
|
||||
|
||||
@free_plan = BillingPlan.create(
|
||||
name: 'Starter',
|
||||
stripe_plan_id: 'starter',
|
||||
monthly_cents: 0, # $0.00/mo
|
||||
available: true,
|
||||
|
||||
# Content creation and other permissions:
|
||||
universe_limit: 5,
|
||||
allows_core_content: true,
|
||||
allows_extended_content: false,
|
||||
allows_collective_content: false,
|
||||
allows_collaboration: false,
|
||||
bonus_bandwidth_kb: 123155
|
||||
)
|
||||
end
|
||||
|
||||
describe "User with no plan (fallback to Starter) tries to upgrade" do
|
||||
@ -101,7 +116,6 @@ RSpec.describe SubscriptionsController, type: :controller do
|
||||
describe "User on Starter" do
|
||||
before do
|
||||
# Create a Starter subscription for the user
|
||||
@user.active_subscriptions.create(billing_plan: @free_plan, start_date: Time.now - 5.days, end_date: Time.now + 5.days)
|
||||
@user.update(selected_billing_plan_id: @free_plan.id)
|
||||
end
|
||||
|
||||
@ -169,12 +183,10 @@ RSpec.describe SubscriptionsController, type: :controller do
|
||||
describe "User on Premium" do
|
||||
before do
|
||||
# Create a premium subscription for the user
|
||||
@user.active_subscriptions.create(billing_plan: @premium_plan, start_date: Time.now - 5.days, end_date: Time.now + 5.days)
|
||||
expect(@user.active_subscriptions.map(&:billing_plan_id)).to eq([@premium_plan.id])
|
||||
@user.update(selected_billing_plan_id: BillingPlan.find_by(stripe_plan_id: 'premium').id)
|
||||
end
|
||||
|
||||
it "allows downgrading to Starter" do
|
||||
|
||||
# Downgrade to Starter
|
||||
post :change, params: { stripe_plan_id: 'starter' }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user