Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Merge 480f228 into dffde5e
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed Aug 24, 2016
2 parents dffde5e + 480f228 commit 3509c8d
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/assets/stylesheets/components/_secondary_nav.scss
Expand Up @@ -44,4 +44,14 @@ $height-nav-secondary: 5rem;
font-weight: $font-bold;
}
}

.subnav-number-label {
border-radius: $round-border-radius;
font-size: 1.3rem;
margin-right: 0.5rem;
margin-left: 0.5rem;
padding: 0.1rem 0.7rem;
background-color: $color-secondary-darkest;
color: $color-white;
}
}
7 changes: 7 additions & 0 deletions app/models/auction_query.rb
Expand Up @@ -24,6 +24,13 @@ def active_auction_count
.count
end

def needs_attention_count
relation.unpublished.count +
pending_delivery.count +
relation.pending_acceptance.count +
payment_needed.count
end

def completed
relation.accepted_or_rejected
end
Expand Down
12 changes: 12 additions & 0 deletions app/view_models/admin/base_view_model.rb
Expand Up @@ -23,6 +23,18 @@ def needs_attention_auctions_nav_class
''
end

def needs_attention_auctions_count
AuctionQuery.new.needs_attention_count
end

def needs_attention_count_partial
if needs_attention_auctions_count > 0
'admin/needs_attention_auction_count'
else
'components/null'
end
end

def new_auction_nav_class
''
end
Expand Down
5 changes: 4 additions & 1 deletion app/views/admin/_auctions_subnav.html.erb
Expand Up @@ -7,7 +7,10 @@
class: view_model.auctions_nav_class %></li>
<li><%= link_to t('links_and_buttons.auctions.needs_attention'),
admin_auctions_needs_attention_path,
class: view_model.needs_attention_auctions_nav_class %></li>
class: view_model.needs_attention_auctions_nav_class %>
<%= render partial: view_model.needs_attention_count_partial,
locals: {count: view_model.needs_attention_auctions_count} %>
</li>
<li><%= link_to t('links_and_buttons.auctions.closed'),
admin_auctions_closed_path,
class: view_model.closed_auctions_nav_class %></li>
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/_needs_attention_auction_count.html.erb
@@ -0,0 +1 @@
<span class="subnav-number-label"><%= count %></span>
9 changes: 9 additions & 0 deletions features/admin_views_needs_attention_auctions.feature
Expand Up @@ -7,6 +7,15 @@ Feature: Admin view needs attention auctions
Given I am an administrator
And I sign in

Scenario: The needs attention tab should have a count
Given there is each type of auction that needs attention
When I visit the auctions admin page
Then I should see the total number of auctions needing my attention next to the needs attention link

Scenario: There are no auctions that need attention
When I visit the auctions admin page
Then I should see the no number next to the needs attention link

Scenario: Navigating to the needs attention auctions dashboard
Given I visit the auctions admin page
When I click on the needs attention link
Expand Down
@@ -0,0 +1,12 @@
Then(/^I should see the total number of auctions needing my attention next to the needs attention link$/) do
link = I18n.t('links_and_buttons.auctions.needs_attention')

expect(page).to have_content("#{link} #{AuctionQuery.new.needs_attention_count}")
end

Then(/^I should see the no number next to the needs attention link$/) do
link = I18n.t('links_and_buttons.auctions.needs_attention')

expect(page).to have_content(link)
expect(page).to_not have_css('span.subnav-number-label')
end
9 changes: 9 additions & 0 deletions features/step_definitions/auction_create_steps.rb
Expand Up @@ -204,3 +204,12 @@
When(/^there is another accepted auction$/) do
FactoryGirl.create(:auction, :accepted, :with_bidders)
end

When(/^there is each type of auction that needs attention$/) do
# And there are auctions that are either in draft state, pending delivery, needs acceptance, or needs payment
@needs_attention = []
@needs_attention << FactoryGirl.create(:auction, :unpublished)
@needs_attention << FactoryGirl.create(:auction, :payment_needed)
@needs_attention << FactoryGirl.create(:auction, :pending_acceptance)
@needs_attention << FactoryGirl.create(:auction, :closed)
end
14 changes: 14 additions & 0 deletions spec/models/auction_query_spec.rb
Expand Up @@ -120,6 +120,20 @@
end
end

describe '#needs_attention_count' do
it 'returns the sum of unpublished, pending_delivery, pending_acceptance and payment_needed auctions' do
_regular = create(:auction)
_unpublished = create(:auction, :unpublished)
_pending_delivery = create(:auction, :closed)
_pending_acceptance = create(:auction, :evaluation_needed)
_payment_needed = create(:auction, :payment_needed)

query = AuctionQuery.new

expect(query.needs_attention_count).to eq(4)
end
end

describe '#with_bid_from_user' do
it 'returns auctions where the user has placed a bid' do
auction = create(:auction, :with_bidders)
Expand Down

0 comments on commit 3509c8d

Please sign in to comment.