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

Commit

Permalink
work_in_progress status for admin auction show
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed Sep 2, 2016
1 parent 1cf69b0 commit fa6c9ed
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/models/admin_auction_status_presenter_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def initialize(auction:)
def create
if auction.payment_confirmed? || auction.c2_paid?
Object.const_get("C2StatusPresenter::#{c2_status}").new(auction: auction)
elsif work_in_progress?
AdminAuctionStatusPresenter::WorkInProgress.new(auction: auction)
elsif !auction.pending_delivery?
Object.const_get("AdminAuctionStatusPresenter::#{status}").new(auction: auction)
else
Expand All @@ -17,6 +19,10 @@ def create

private

def work_in_progress?
AuctionStatus.new(auction).work_in_progress?
end

def status
auction.status.camelize
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/auction_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def expiring?
available? && auction.ended_at < (Time.current + 12.hours)
end

def work_in_progress?
auction.delivery_url.present? && !(auction.pending_acceptance? || auction.accepted? || auction.rejected?)
end

private

attr_reader :auction
Expand Down
6 changes: 5 additions & 1 deletion app/models/bid_status_presenter_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def over_winning_bidder_message
BidStatusPresenter::Over::Vendor::Winner::PendingPayment
elsif auction.rejected?
BidStatusPresenter::Over::Vendor::Winner::Rejected
elsif auction.delivery_url.present?
elsif work_in_progress?
BidStatusPresenter::Over::Vendor::Winner::WorkInProgress
elsif auction.payment_confirmed?
BidStatusPresenter::Over::Vendor::Winner::PaymentConfirmed
Expand Down Expand Up @@ -100,6 +100,10 @@ def ineligible?
!EligibilityFactory.new(auction).create.eligible?(user)
end

def work_in_progress?
auction_status.work_in_progress?
end

def over?
auction_status.over?
end
Expand Down
28 changes: 28 additions & 0 deletions app/presenters/admin_auction_status_presenter/work_in_progress.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class AdminAuctionStatusPresenter::WorkInProgress < AdminAuctionStatusPresenter::Base
def header
I18n.t('statuses.admin_auction_status_presenter.work_in_progress.header')
end

def body
I18n.t(
'statuses.admin_auction_status_presenter.work_in_progress.body',
winner_url: winner_url,
delivery_url: auction.delivery_url,
delivery_deadline: delivery_deadline
)
end

private

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

def delivery_deadline
DcTimePresenter.convert_and_format(auction.delivery_due_at)
end
end
6 changes: 6 additions & 0 deletions config/locales/statuses/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ en:
<a href=%{issue_url}>the issue associated with this auction</a>.
Then enter the pull request URL, below, and click "start work."
admin_auction_status_presenter:
work_in_progress:
header: Work in progress
body: >
%{winner_url} initiated a <a href=%{delivery_url}>pull
request</a>, and should complete their work no later than
%{delivery_deadline}.
pending_acceptance:
body: >
%{winner_url} made a <a href=%{delivery_url}>pull request</a> and marked this auction as
Expand Down
11 changes: 11 additions & 0 deletions features/admin_views_auction_work_in_progress.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Admin views work in progress auction
As an administrator
I want to see that an auction is a work in progress
So I can know what the delivery URL is

Scenario: Viewing a work in progress auction on its admin show page
Given I am an administrator
And I am signed in
And there is an auction with work in progress
When I visit the admin auction page for that auction
Then I should see the work in progress status box for admins
4 changes: 4 additions & 0 deletions features/step_definitions/auction_create_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
end
end

Given(/^there is an auction with work in progress$/) do
@auction = FactoryGirl.create(:auction, :closed, :with_bids, :delivered)
end

When(/^the auction ends$/) do
Timecop.return
Timecop.travel(@auction.ended_at + 5.minutes)
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/auction_status_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
)
end

Then(/^I should see the work in progress status box for admins$/) do
expect(page).to have_content(
I18n.t('statuses.admin_auction_status_presenter.work_in_progress.header')
)
end

Then(/^I should see the pending acceptance status box$/) do
expect(page).to have_content(
I18n.t('statuses.bid_status_presenter.over.winner.pending_acceptance.header')
Expand Down

0 comments on commit fa6c9ed

Please sign in to comment.