Skip to content

Commit

Permalink
add support for creating account for specific api version
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Feb 27, 2024
1 parent b8261c7 commit dcf4ec1
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Account < ApplicationRecord

before_create :set_autogenerated_registration_info!

before_create -> { self.api_version ||= DEFAULT_API_VERSION }
before_create -> { self.api_version ||= Current.api_version || DEFAULT_API_VERSION }
before_create -> { self.backend ||= CF_ACCOUNT_ID ? 'R2' : 'S3' }
before_create -> { self.slug = slug.downcase }

Expand Down
76 changes: 76 additions & 0 deletions features/api/v1/accounts/create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,82 @@ Feature: Create account
And the account "google" should not have a referral
And the account "google" should have 2 "admins"

Scenario: Anonymous creates an account (default API version)
When I send a POST request to "/accounts" with the following:
"""
{
"data": {
"type": "accounts",
"attributes": {
"name": "Version 1.6",
"slug": "v1x6"
},
"relationships": {
"plan": {
"data": { "type": "plans", "id": "$plan[0]" }
},
"admins": {
"data": [
{
"type": "user",
"attributes": { "firstName": "John", "lastName": "Doe", "email": "[email protected]", "password": "secret" }
}
]
}
}
}
}
"""
Then the response status should be "201"
And the response should contain the following headers:
"""
{ "Keygen-Version": "1.6" }
"""
And the response body should be an "account" with the following attributes:
"""
{ "apiVersion": "1.6" }
"""

Scenario: Anonymous creates an account (specific API version)
Given I send the following headers:
"""
{ "Keygen-Version": "1.5" }
"""
When I send a POST request to "/accounts" with the following:
"""
{
"data": {
"type": "accounts",
"attributes": {
"name": "Version 1.5",
"slug": "v1x5"
},
"relationships": {
"plan": {
"data": { "type": "plans", "id": "$plan[0]" }
},
"admins": {
"data": [
{
"type": "user",
"attributes": { "firstName": "John", "lastName": "Doe", "email": "[email protected]", "password": "secret" }
}
]
}
}
}
}
"""
Then the response status should be "201"
And the response should contain the following headers:
"""
{ "Keygen-Version": "1.5" }
"""
And the response body should be an "account" with the following attributes:
"""
{ "apiVersion": "1.5" }
"""

Scenario: Anonymous creates an account with a referral ID
When I send a POST request to "/accounts" with the following:
"""
Expand Down

0 comments on commit dcf4ec1

Please sign in to comment.