mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Fixed test
This commit is contained in:
parent
a682681625
commit
045c74b7e2
2 changed files with 9 additions and 9 deletions
|
@ -55,7 +55,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_date(date_param)
|
def to_date(date_param)
|
||||||
return if date_param.blank?
|
return Date.today if date_param.blank?
|
||||||
|
|
||||||
Date.strptime(date_param, '%m.%y')
|
Date.strptime(date_param, '%m.%y')
|
||||||
end
|
end
|
||||||
|
@ -114,19 +114,19 @@ module Repp
|
||||||
.inject(:merge)
|
.inject(:merge)
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_distribution_result(grouped)
|
def serialize_distribution_result(result)
|
||||||
grouped.map do |key, value|
|
result.map do |key, value|
|
||||||
next unless registrar_names.key?(key)
|
next unless registrar_names.key?(key)
|
||||||
|
|
||||||
name = registrar_names[key]
|
name = registrar_names[key]
|
||||||
hash = { name: registrar_names[key], y: value }
|
hash = { name: name, y: value }
|
||||||
hash.merge!({ sliced: true, selected: true }) if current_user.registrar.name == name
|
hash.merge!({ sliced: true, selected: true }) if current_user.registrar.name == name
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_growth_rate_result(grouped)
|
def serialize_growth_rate_result(result)
|
||||||
grouped.map do |key, value|
|
result.map do |key, value|
|
||||||
next unless registrar_names.key?(key)
|
next unless registrar_names.key?(key)
|
||||||
|
|
||||||
name = registrar_names[key]
|
name = registrar_names[key]
|
||||||
|
|
|
@ -21,15 +21,15 @@ class ReppV1StatsMarketShareTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
assert json[:data].is_a? Array
|
assert json[:data].is_a? Array
|
||||||
assert json[:data][0].is_a? Hash
|
assert json[:data][0].is_a? Hash
|
||||||
assert_equal json[:data][0][:name], 'Best Names'
|
assert_equal json[:data][0][:name], 'Good Names'
|
||||||
assert json[:data][0][:selected]
|
assert_nil json[:data][0][:selected]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shows_market_share_growth_rate_data
|
def test_shows_market_share_growth_rate_data
|
||||||
prev_date = Time.zone.today.last_month.strftime('%m.%y')
|
prev_date = Time.zone.today.last_month.strftime('%m.%y')
|
||||||
get '/repp/v1/stats/market_share_growth_rate', headers: @auth_headers,
|
get '/repp/v1/stats/market_share_growth_rate', headers: @auth_headers,
|
||||||
params: { q: { end_date: @today,
|
params: { q: { end_date: @today,
|
||||||
compare_to_date: prev_date } }
|
compare_to_end_date: prev_date } }
|
||||||
json = JSON.parse(response.body, symbolize_names: true)
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue