Fix available credits count in dashboard (#8928)

This commit is contained in:
rhymes 2020-06-26 16:18:04 +02:00 committed by GitHub
parent 343fb02d07
commit 618a7b94fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View file

@ -12,12 +12,12 @@
</div>
<div class="crayons-card crayons-card--secondary p-3 m:p-6">
<strong class="fs-2xl m:fs-3xl lh-tight color-base-90"><%= @user.listings.count %></strong>
<strong class="fs-2xl m:fs-3xl lh-tight color-base-90"><%= @user.listings.size %></strong>
<span class="color-base-60 block">Listings created</span>
</div>
<div class="crayons-card crayons-card--secondary p-3 m:p-6">
<strong class="fs-2xl m:fs-3xl lh-tight color-base-90"><%= @user.credits.count %></strong>
<strong class="fs-2xl m:fs-3xl lh-tight color-base-90"><%= @user.unspent_credits_count %></strong>
<span class="color-base-60 block">Credits available</span>
</div>
</div>

View file

@ -0,0 +1,30 @@
require "rails_helper"
RSpec.describe "Dashboard", type: :system, js: true do
let(:user) { create(:user) }
let(:listing) { create(:listing) }
before do
sign_in user
end
context "when looking at analytics counters" do
it "shows the count of unspent credits" do
Credit.add_to(user, 2)
Credits::Buyer.call(
purchaser: user,
purchase: listing,
cost: 1,
)
Credit.counter_culture_fix_counts
user.reload
visit dashboard_path
within "main > header" do
expect(page).to have_text("1")
end
end
end
end