Fix available credits count in dashboard (#8928)
This commit is contained in:
parent
343fb02d07
commit
618a7b94fe
2 changed files with 32 additions and 2 deletions
|
|
@ -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>
|
||||
|
|
|
|||
30
spec/system/dashboards/user_visits_dashboard_spec.rb
Normal file
30
spec/system/dashboards/user_visits_dashboard_spec.rb
Normal 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
|
||||
Loading…
Add table
Reference in a new issue