Skip to content

Commit

Permalink
Refactor billing APIs as stats
Browse files Browse the repository at this point in the history
  • Loading branch information
stage-rl committed Dec 11, 2023
1 parent be81f6f commit 6dca425
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Api::Billing::TenantsController < ActionController::Base
class Api::Stats::TenantsController < ActionController::Base
include AuditableApiEvents
before_action :set_tenant
rescue_from ActiveRecord::RecordNotFound, with: :save_exception
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
resources :boxes
end
end
namespace :billing do
namespace :stats do
resources :tenants, only: [] do
get :users_count
get :messages_per_period
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require "test_helper"

class BillingApiTest < ActionDispatch::IntegrationTest
class StatsApiTest < ActionDispatch::IntegrationTest
test "can read number of users" do
tenant = tenants(:solver)
get "/api/billing/tenants/#{tenant.id}/users_count", params: {}, as: :json
get "/api/stats/tenants/#{tenant.id}/users_count", params: {}, as: :json
assert_response :success
json_response = JSON.parse(response.body)
assert json_response["users_count"].positive?
end

test "can read number of messages per period" do
tenant = tenants(:solver)
get "/api/billing/tenants/#{tenant.id}/messages_per_period",
get "/api/stats/tenants/#{tenant.id}/messages_per_period",
params: { from: Time.zone.now - 100.days, till: Time.zone.now }, as: :json
assert_response :success
json_response = JSON.parse(response.body)
Expand All @@ -20,7 +20,7 @@ class BillingApiTest < ActionDispatch::IntegrationTest

test "can read number of messages" do
tenant = tenants(:solver)
get "/api/billing/tenants/#{tenant.id}/messages_count", params: {}, as: :json
get "/api/stats/tenants/#{tenant.id}/messages_count", params: {}, as: :json
assert_response :success
json_response = JSON.parse(response.body)
assert json_response["messages_count"].positive?
Expand Down

0 comments on commit 6dca425

Please sign in to comment.