Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plausible-analytics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
varac-projects
plausible-analytics
Commits
ce649966
Commit
ce649966
authored
3 years ago
by
Uku Taht
Browse files
Options
Downloads
Patches
Plain Diff
Fix display
parent
ebdd856d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/plausible/billing/plans.ex
+7
-16
7 additions, 16 deletions
lib/plausible/billing/plans.ex
test/plausible_web/controllers/auth_controller_test.exs
+40
-0
40 additions, 0 deletions
test/plausible_web/controllers/auth_controller_test.exs
with
47 additions
and
16 deletions
lib/plausible/billing/plans.ex
+
7
−
16
View file @
ce649966
...
...
@@ -74,8 +74,7 @@ defmodule Plausible.Billing.Plans do
def
subscription_interval
(
subscription
)
do
case
for_product_id
(
subscription
.
paddle_plan_id
)
do
nil
->
enterprise_plan
=
Repo
.
get_by
(
Plausible
.
Billing
.
EnterprisePlan
,
user_id:
subscription
.
user_id
)
enterprise_plan
=
get_enterprise_plan
(
subscription
)
enterprise_plan
&&
enterprise_plan
.
billing_interval
...
...
@@ -96,11 +95,7 @@ defmodule Plausible.Billing.Plans do
if
found
do
Map
.
fetch!
(
found
,
:limit
)
else
enterprise_plan
=
Repo
.
get_by
(
Plausible
.
Billing
.
EnterprisePlan
,
user_id:
subscription
.
user_id
,
paddle_plan_id:
subscription
.
paddle_plan_id
)
enterprise_plan
=
get_enterprise_plan
(
subscription
)
if
enterprise_plan
do
enterprise_plan
.
monthly_pageview_limit
...
...
@@ -114,15 +109,11 @@ defmodule Plausible.Billing.Plans do
end
end
def
get_enterprise_plan
(
user
)
do
if
user
.
subscription
do
Repo
.
get_by
(
Plausible
.
Billing
.
EnterprisePlan
,
user_id:
user
.
id
,
paddle_plan_id:
user
.
subscription
.
paddle_plan_id
)
else
Repo
.
get_by
(
Plausible
.
Billing
.
EnterprisePlan
,
user_id:
user
.
id
)
end
def
get_enterprise_plan
(
subscription
)
do
Repo
.
get_by
(
Plausible
.
Billing
.
EnterprisePlan
,
user_id:
subscription
.
user_id
,
paddle_plan_id:
subscription
.
paddle_plan_id
)
end
def
suggested_plan
(
user
,
usage
)
do
...
...
This diff is collapsed.
Click to expand it.
test/plausible_web/controllers/auth_controller_test.exs
+
40
−
0
View file @
ce649966
...
...
@@ -489,6 +489,46 @@ defmodule PlausibleWeb.AuthControllerTest do
assert
html_response
(
conn
,
200
)
=~
"N/A billing"
end
test
"shows enterprise plan subscription"
,
%{
conn:
conn
,
user:
user
}
do
insert
(
:subscription
,
paddle_plan_id:
"123"
,
user:
user
)
insert
(
:enterprise_plan
,
paddle_plan_id:
"123"
,
user:
user
,
monthly_pageview_limit:
10_000_000
,
billing_interval:
:yearly
)
conn
=
get
(
conn
,
"/settings"
)
assert
html_response
(
conn
,
200
)
=~
"10M pageviews"
assert
html_response
(
conn
,
200
)
=~
"yearly billing"
end
test
"shows current enterprise plan subscription when user has a new one to upgrade to"
,
%{
conn:
conn
,
user:
user
}
do
insert
(
:subscription
,
paddle_plan_id:
"123"
,
user:
user
)
insert
(
:enterprise_plan
,
paddle_plan_id:
"123"
,
user:
user
,
monthly_pageview_limit:
10_000_000
,
billing_interval:
:yearly
)
insert
(
:enterprise_plan
,
paddle_plan_id:
"1234"
,
user:
user
,
monthly_pageview_limit:
20_000_000
,
billing_interval:
:yearly
)
conn
=
get
(
conn
,
"/settings"
)
assert
html_response
(
conn
,
200
)
=~
"10M pageviews"
assert
html_response
(
conn
,
200
)
=~
"yearly billing"
end
test
"shows invoices for subscribed user"
,
%{
conn:
conn
,
user:
user
}
do
insert
(
:subscription
,
paddle_plan_id:
"558018"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment