Commit 55628458 authored by Stan Hu's avatar Stan Hu

Merge branch 'remove-api-defaults-for-gitlab-subscriptions' into 'master'

Moves seat count defaults from api to database

See merge request gitlab-org/gitlab!33786
parents 8c63464f 760a2522
...@@ -36,8 +36,8 @@ module EE ...@@ -36,8 +36,8 @@ module EE
resource :namespaces, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :namespaces, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do helpers do
params :gitlab_subscription_optional_attributes do params :gitlab_subscription_optional_attributes do
optional :seats, type: Integer, default: 0, desc: 'The number of seats purchased' optional :seats, type: Integer, desc: 'The number of seats purchased'
optional :max_seats_used, type: Integer, default: 0, desc: 'The max number of active users detected in the last month' optional :max_seats_used, type: Integer, desc: 'The max number of active users detected in the last month'
optional :plan_code, type: String, desc: 'The code of the purchased plan' optional :plan_code, type: String, desc: 'The code of the purchased plan'
optional :end_date, type: Date, desc: 'The date when subscription expires' optional :end_date, type: Date, desc: 'The date when subscription expires'
optional :auto_renew, type: Grape::API::Boolean, desc: 'Whether the subscription auto renews' optional :auto_renew, type: Grape::API::Boolean, desc: 'Whether the subscription auto renews'
......
...@@ -342,14 +342,27 @@ RSpec.describe API::Namespaces do ...@@ -342,14 +342,27 @@ RSpec.describe API::Namespaces do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(gitlab_subscription.reload.seats).to eq(150) expect(gitlab_subscription.reload.seats).to eq(150)
expect(gitlab_subscription.max_seats_used).to eq(0)
expect(gitlab_subscription.plan_name).to eq('silver') expect(gitlab_subscription.plan_name).to eq('silver')
expect(gitlab_subscription.plan_title).to eq('Silver') expect(gitlab_subscription.plan_title).to eq('Silver')
end end
it 'is sucessful using full_path when namespace path contains dots' do it 'is successful using full_path when namespace path contains dots' do
put api("/namespaces/#{namespace.full_path}/gitlab_subscription", admin), params: params do_put(namespace.id, admin, params)
expect(response).to have_gitlab_http_status(:ok)
end
it 'does not clear out existing data because of defaults' do
gitlab_subscription.update!(seats: 20, max_seats_used: 42)
do_put(namespace.id, admin, params.except(:seats))
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(gitlab_subscription.reload).to have_attributes(
seats: 20,
max_seats_used: 42
)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment