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

Commit

Permalink
Show information about bids for available auctions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed Sep 20, 2016
1 parent ecc4b11 commit e5f9b9a
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/models/admin_auction_status_presenter_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def other_purchase_card_presenter
AdminAuctionStatusPresenter::Future
elsif future? && auction.unpublished?
AdminAuctionStatusPresenter::ReadyToPublish
elsif available?
AdminAuctionStatusPresenter::Available
elsif work_in_progress?
AdminAuctionStatusPresenter::WorkInProgress
elsif !auction.pending_delivery?
Expand Down
2 changes: 1 addition & 1 deletion app/models/bid_status_presenter_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def over_message

def available_message
if admin?
BidStatusPresenter::Available::Admin
AdminAuctionStatusPresenter::Available
elsif guest?
BidStatusPresenter::Available::Guest
elsif ineligible?
Expand Down
16 changes: 15 additions & 1 deletion app/presenters/admin_auction_status_presenter/available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ def header
end

def body
I18n.t('statuses.bid_status_presenter.available.admin.body', end_date: end_date)
if total_bids > 0
I18n.t('statuses.bid_status_presenter.available.admin.has_bids',
end_date: end_date,
winner_url: winner_url,
total_bids: total_bids
)
else
I18n.t('statuses.bid_status_presenter.available.admin.body', end_date: end_date)
end
end

private

def total_bids
auction.bids.count
end

private
Expand Down
8 changes: 6 additions & 2 deletions config/locales/statuses/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ en:
solicitation.
available:
admin:
header: "Accepting bids"
body: "This auction is accepting bids until %{end_date}."
header: Accepting bids
body: This auction is accepting bids until %{end_date}.
has_bids: >
There are %{total_bids} bids on this auction, and
%{winner_url} is currently winning. This auction is
accepting bids until %{end_date}.
guest:
body: >
This auction is accepting bids until %{end_date}. %{sign_in_link} or
Expand Down
27 changes: 27 additions & 0 deletions features/admin_views_available_auction.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: Admin views available auction
As an administrator
I want to see a sidebar status for available auctions
So I can see what the progress of them is

Scenario: The auction has no bids yet
Given I am an administrator
And I sign in
And there is a budget approved auction

When I visit the auction page
Then I should see an admin status message that the auction is available with no bids

When I visit the admin auction page for that auction
Then I should see an admin status message that the auction is available with no bids


Scenario: The auction has bids
Given I am an administrator
And I sign in
And there is a budget approved auction with bids

When I visit the auction page
Then I should see an admin status message that the auction is available with bids

When I visit the admin auction page for that auction
Then I should see an admin status message that the auction is available with bids
6 changes: 5 additions & 1 deletion features/step_definitions/auction_create_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@
@auction.skills << skills
end

Given(/^there is a budget approved auction$/) do
Given(/^there is a budget approved auction with bids$/) do
@auction = FactoryGirl.create(:auction, :c2_approved, :with_bids)
end

Given(/^there is a budget approved auction$/) do
@auction = FactoryGirl.create(:auction, :c2_approved)
end

Given(/^there is a sealed-bid auction$/) do
@auction = FactoryGirl.create(:auction, :available, :sealed_bid)
end
Expand Down
20 changes: 20 additions & 0 deletions features/step_definitions/auction_status_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,23 @@
)
)
end

Then(/^I should see an admin status message that the auction is available with no bids$/) do
expect(page).to have_content(
I18n.t(
'statuses.bid_status_presenter.available.admin.body',
end_date: end_date
)
)
end

Then(/^I should see an admin status message that the auction is available with bids$/) do
expect(page.html).to include(
I18n.t(
'statuses.bid_status_presenter.available.admin.has_bids',
end_date: end_date,
total_bids: @auction.bids.count,
winner_url: winner_url
)
)
end
12 changes: 12 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ def start_date
def winning_bid
WinningBid.new(@auction).find
end

def winner
winning_bid.bidder
end

def winner_url
Url.new(
link_text: winner.email,
path_name: 'admin_user',
params: { id: winner.id }
)
end
end

World(AuctionHelpers)
Expand Down

0 comments on commit e5f9b9a

Please sign in to comment.