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

Commit

Permalink
Merge 99f02a4 into c93b907
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieay committed Jul 29, 2016
2 parents c93b907 + 99f02a4 commit 90cde0a
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 204 deletions.
8 changes: 0 additions & 8 deletions app/assets/stylesheets/components/_auction-show.scss
Expand Up @@ -189,14 +189,6 @@
width: 100%;
}

.issue-current-bid:not(.issue-current-bid-long) {
&::before {
content: '\2219';
margin-left: $base-padding-lite;
margin-right: $base-padding-lite;
}
}

.issue-current-bid.issue-current-bid-new-line {
&::before {
content: '\A';
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/status_presenter/available.rb
Expand Up @@ -8,7 +8,7 @@ def deadline_label
end

def relative_time
"Time remaining: #{HumanTime.new(time: auction.ended_at).distance_of_time_to_now}"
"Ending in #{HumanTime.new(time: auction.ended_at).distance_of_time_to_now}"
end

def label_class
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/status_presenter/future.rb
Expand Up @@ -8,7 +8,7 @@ def deadline_label
end

def relative_time
"Starts #{HumanTime.new(time: auction.started_at).relative_time} from now"
"Starting #{HumanTime.new(time: auction.started_at).relative_time}"
end

def label_class
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/status_presenter/over.rb
Expand Up @@ -8,7 +8,7 @@ def deadline_label
end

def relative_time
"Ended #{HumanTime.new(time: auction.ended_at).relative_time}"
auction.ended_at.strftime("Ended on: %m/%d/%Y")
end

def label_class
Expand Down
70 changes: 8 additions & 62 deletions app/view_models/auction_list_item.rb
Expand Up @@ -30,6 +30,10 @@ def capitalized_formatted_type
auction.type.dasherize.capitalize
end

def starting_price
Currency.new(auction.start_price).to_s
end

def eligibility_label
if for_small_business?
'Small-business only'
Expand Down Expand Up @@ -61,66 +65,12 @@ def project_label
def winning_bid_partial
if over? && !auction.bids.any?
'auctions/no_bids'
elsif auction.type == 'reverse' && over?
elsif over?
'auctions/over_winning_bid_details'
elsif auction.type == 'sealed_bid' && over?
'auctions/over_with_bids'
elsif auction.type == 'reverse' && available?
auction_available_bids_partial
elsif auction.type == 'sealed_bid' && available?
sealed_bid_bidder_partial
else # future
'components/null'
end
end

def auction_available_bids_partial
if auction.bids.any?
elsif auction.type == 'reverse' && available? && auction.bids.any?
'auctions/winning_bid_details'
else
'auctions/no_bids_yet'
end
end

def sealed_bid_bidder_partial
if user_is_bidder?
'auctions/sealed_bid_auction_user_is_bidder'
else
'components/null'
end
end

def winning_bidder_partial
if user_is_winning_bidder? && auction.type == 'sealed_bid'
'auctions/sealed_bid_auction_user_is_winning_bidder'
elsif user_is_winning_bidder? && auction.type == 'reverse'
'auctions/reverse_auction_user_is_winning_bidder'
else
'auctions/user_is_not_winning_bidder'
end
end

def user_is_bidder_partial
if user_is_bidder?
'auctions/user_is_bidder'
else
'components/null'
end
end

def over_user_is_winner_class
if !user_is_winning_bidder?
'issue-current-bid-long'
else
''
end
end

def current_winning_bidder_partial
if user_is_winning_bidder? && auction.type == 'reverse'
'auctions/user_is_current_winning_bidder'
else
'auctions/user_is_not_current_winning_bidder'
else # sealed or reverse with no bids or future
'auctions/starting_price'
end
end

Expand All @@ -132,10 +82,6 @@ def highlighted_bid_amount_as_currency
Currency.new(highlighted_bid.amount).to_s
end

def user_bid_amount_as_currency
Currency.new(lowest_user_bid.amount).to_s
end

private

def user_is_bidder?
Expand Down
1 change: 0 additions & 1 deletion app/views/auctions/_no_bids_yet.html.erb

This file was deleted.

6 changes: 1 addition & 5 deletions app/views/auctions/_over_winning_bid_details.html.erb
@@ -1,5 +1 @@
<%= render partial: auction.winning_bidder_partial,
locals: { auction: auction } %>
<span class="issue-winning-bid">
<%= auction.highlighted_bid_amount_as_currency %>
</span>
Winning bid: <%= auction.highlighted_bid_amount_as_currency %>
7 changes: 0 additions & 7 deletions app/views/auctions/_over_with_bids.html.erb

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions app/views/auctions/_starting_price.html.erb
@@ -0,0 +1 @@
Starting price: <%= auction.starting_price %>
4 changes: 0 additions & 4 deletions app/views/auctions/_user_is_bidder.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/auctions/_user_is_current_winning_bidder.html.erb

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/auctions/_user_is_not_winning_bidder.html.erb

This file was deleted.

5 changes: 1 addition & 4 deletions app/views/auctions/_winning_bid_details.html.erb
@@ -1,4 +1 @@
<%= render partial: auction.current_winning_bidder_partial,
locals: { auction: auction } %>
<%= auction.highlighted_bid_amount_as_currency %>
Current winning bid: <%= auction.highlighted_bid_amount_as_currency %>
20 changes: 0 additions & 20 deletions app/views/auctions/_winning_bids_on_winners_page.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions features/vendor_bids_sealed_auction.feature
Expand Up @@ -34,9 +34,6 @@ Feature: Vendor bids on a sealed-bid auction
Then I should not see the bid form
And I should see "Your bid: $3,493.00"

When I visit the home page
And I should see "Your bid: $3,493.00"

Scenario: viewing your own bid
Given there is a sealed-bid auction
And I am an authenticated vendor
Expand Down
37 changes: 24 additions & 13 deletions spec/presenters/status_presenter/available_spec.rb
@@ -1,29 +1,40 @@
require 'rails_helper'

describe StatusPresenter::Available do
context "when the auction is available" do
let(:presenter) { StatusPresenter::Available.new(auction) }
let(:auction) do
a = create(
:auction,
started_at: Time.now - 3.days,
ended_at: Time.now + 2.days,
start_price: 3500
)
create(:bid, auction: a, amount: 3000)
a
end

describe '#tag_data_value_status' do
it "has a twitter status data value with human readable time expression" do
presenter = StatusPresenter::Available.new(auction)
expect(presenter.tag_data_value_status).to eq("2 days left")
end
end

describe '#tag_data_label_2' do
it "has a twitter second label that indicates bidding is open" do
presenter = StatusPresenter::Available.new(auction)
expect(presenter.tag_data_label_2).to eq("Bidding")
end
end

describe '#tag_data_value_2' do
it "has some weird value associated with the bidding label" do
presenter = StatusPresenter::Available.new(auction)
expect(presenter.tag_data_value_2).to eq("$3,000.00 - 1 bids")
end
end

describe '#relative_time' do
it 'returns time remaining' do
presenter = StatusPresenter::Available.new(auction)
expect(presenter.relative_time).to eq("Ending in 2 days")
end
end

def auction
@_auction ||= create(
:auction,
:available,
start_price: 3500,
bids: [create(:bid, amount: 3000)]
)
end
end
32 changes: 13 additions & 19 deletions spec/presenters/status_presenter/expiring_spec.rb
@@ -1,29 +1,23 @@
require 'rails_helper'

describe StatusPresenter::Expiring do
context "when the auction is expiring soon" do
let(:presenter) { StatusPresenter::Expiring.new(auction) }
let(:auction) do
a = create(
:auction,
started_at: Time.now - 3.days,
ended_at: Time.now + 3.hours,
start_price: 3500
)
create(:bid, amount: 3000, auction: a)
a
end
describe '#label_class' do
it 'returns the correct label class' do
auction = build(:auction)

it "has a twitter status data value with human readable time expression" do
expect(presenter.tag_data_value_status).to eq("about 3 hours left")
end
presenter = StatusPresenter::Expiring.new(auction)

it "has a twitter second label that indicates bidding is open" do
expect(presenter.tag_data_label_2).to eq("Bidding")
expect(presenter.label_class).to eq 'auction-label-expiring'
end
end

describe '#label' do
it 'returns the correct label' do
auction = build(:auction)

presenter = StatusPresenter::Expiring.new(auction)

it "has some weird value associated with the bidding label" do
expect(presenter.tag_data_value_2).to eq("$3,000.00 - 1 bids")
expect(presenter.label).to eq 'Expiring'
end
end
end
48 changes: 32 additions & 16 deletions spec/presenters/status_presenter/future_spec.rb
@@ -1,29 +1,45 @@
require 'rails_helper'

describe StatusPresenter::Future do
context "when the auction is in the future" do
let(:presenter) { StatusPresenter::Future.new(auction) }
let(:auction) do
a = create(
:auction,
started_at: Time.now + 3.day,
ended_at: Time.now + 3.hours,
start_price: 3500
)
create(:bid, auction: a, amount: 3000)
a
end

it "has a twitter status data value with human readable time expression" do
describe '#tag_data_value_status' do
it "returns human readable time" do
presenter = StatusPresenter::Future.new(auction)
expect(presenter.tag_data_value_status).to eq("in 3 days")
end
end

it "has a twitter second label about the starting bid amount" do
describe '#tag_data_label_2' do
it "returns starting bid" do
presenter = StatusPresenter::Future.new(auction)
expect(presenter.tag_data_label_2).to eq("Starting bid")
end
end

it "has some weird value associated with the bidding label" do
describe '#tag_data_value_2' do
it "returns start price" do
presenter = StatusPresenter::Future.new(auction)
expect(presenter.tag_data_value_2).to eq("$3,500.00")
end
end

describe '#relative_time' do
it 'returns time until auction starts' do
time = Time.current + 1.day
auction = create(:auction, :future, ended_at: time)

presenter = StatusPresenter::Future.new(auction)

expect(presenter.relative_time).to eq 'Starting in about 23 hours'
end
end

def auction
@_auction ||= create(
:auction,
:future,
started_at: Time.now + 3.days,
start_price: 3500,
bids: [create(:bid, amount: 3000)]
)
end
end

0 comments on commit 90cde0a

Please sign in to comment.