The personal finance app for everyone (by everyone)
Ruby
Cap the Twelve Data usage bar at 100% width (#5509)
jaysbeekay5f16c4800f57
diff --git a/app/views/settings/hostings/_twelve_data_settings.html.erb b/app/views/settings/hostings/_twelve_data_settings.html.erbindex 9dbb77289b..95fe6438a0 100644--- a/app/views/settings/hostings/_twelve_data_settings.html.erb+++ b/app/views/settings/hostings/_twelve_data_settings.html.erb@@ -47,7 +47,7 @@</p><div class="w-52 h-1.5 bg-surface-inset rounded-2xl"><div class="h-full bg-green-500 rounded-2xl"- style="width: <%= [@twelve_data_usage.data.utilization, 2].max %>%;"></div>+ style="width: <%= @twelve_data_usage.data.utilization.clamp(2, 100) %>%;"></div></div></div><div class="bg-surface-inset rounded-md px-1.5 py-0.5 w-fit">diff --git a/test/controllers/settings/hostings_controller_test.rb b/test/controllers/settings/hostings_controller_test.rbindex 6fda4a77c1..98fc89fdf4 100644--- a/test/controllers/settings/hostings_controller_test.rb+++ b/test/controllers/settings/hostings_controller_test.rb@@ -162,6 +162,44 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTestendend+ test "caps the Twelve Data usage bar at full width when usage exceeds the daily limit" do+ @provider.stubs(:usage).returns(provider_success_response(+ OpenStruct.new(used: 900, limit: 800, utilization: 112.5, plan: "free")+ ))++ with_self_hosting do+ get settings_hosting_url++ assert_response :success+ bar = css_select("div.w-52.bg-surface-inset > div.bg-green-500").sole+ assert_equal "width: 100%;", bar["style"]+ end+ end++ test "keeps the Twelve Data usage bar at the utilization when usage is within the daily limit" do+ with_self_hosting do+ get settings_hosting_url++ assert_response :success+ bar = css_select("div.w-52.bg-surface-inset > div.bg-green-500").sole+ assert_equal "width: 10%;", bar["style"]+ end+ end++ test "keeps a sliver of the Twelve Data usage bar visible when nothing is used" do+ @provider.stubs(:usage).returns(provider_success_response(+ OpenStruct.new(used: 0, limit: 800, utilization: 0, plan: "free")+ ))++ with_self_hosting do+ get settings_hosting_url++ assert_response :success+ bar = css_select("div.w-52.bg-surface-inset > div.bg-green-500").sole+ assert_equal "width: 2%;", bar["style"]+ end+ end+test "renders OpenAI model and timeout guidance in German" dosign_in users(:sure_support_staff)