mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 13:36:15 +02:00
Added market share growth rate data endpoint
This commit is contained in:
parent
261e2d3162
commit
dc4c3cf616
6 changed files with 90 additions and 11 deletions
|
@ -7,10 +7,12 @@ class ReppV1StatsMarketShareTest < ActionDispatch::IntegrationTest
|
|||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
@today = Time.zone.today.strftime('%m.%y')
|
||||
end
|
||||
|
||||
def test_shows_market_share_data
|
||||
get '/repp/v1/stats/market_share', headers: @auth_headers
|
||||
def test_shows_market_share_distribution_data
|
||||
get '/repp/v1/stats/market_share_distribution', headers: @auth_headers,
|
||||
params: { q: { end_date: @today } }
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
@ -22,4 +24,22 @@ class ReppV1StatsMarketShareTest < ActionDispatch::IntegrationTest
|
|||
assert_equal json[:data][0][:name], 'Best Names'
|
||||
assert json[:data][0][:selected]
|
||||
end
|
||||
|
||||
def test_shows_market_share_growth_rate_data
|
||||
prev_date = Time.zone.today.last_month.strftime('%m.%y')
|
||||
get '/repp/v1/stats/market_share_growth_rate', headers: @auth_headers,
|
||||
params: { q: { end_date: @today,
|
||||
compare_to_date: prev_date } }
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
data = json[:data]
|
||||
assert data[:data].is_a? Hash
|
||||
assert data[:prev_data].is_a? Hash
|
||||
assert_equal data[:data][:name], @today
|
||||
assert data[:data][:domains].is_a? Array
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue