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

Commit

Permalink
Merge 8076ad1 into 956d83f
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed Jun 15, 2016
2 parents 956d83f + 8076ad1 commit e9af48a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/controllers/admin/auctions_controller.rb
Expand Up @@ -35,14 +35,16 @@ def create

def edit
@auction = Admin::EditAuctionViewModel.new(Auction.find(params[:id]))
session[:return_to] = request.referer
end

def update
auction = Auction.find(params[:id])
update_auction = UpdateAuction.new(auction, params)

if update_auction.perform
redirect_to admin_auctions_path
redirect_to(session[:return_to] || admin_auctions_path)
session[:return_to] = nil
else
error_messages = auction.errors.full_messages.to_sentence
flash[:error] = error_messages
Expand Down
6 changes: 5 additions & 1 deletion app/presenters/user_presenter.rb
Expand Up @@ -4,7 +4,11 @@ def github_json_url
end

def admin?
Admins.verify?(model.github_id)
authenticated? && Admins.verify?(model.github_id)
end

def authenticated?
!model.is_a?(Guest)
end

def in_sam?
Expand Down
8 changes: 8 additions & 0 deletions app/view_models/auction_show_view_model.rb
Expand Up @@ -140,6 +140,14 @@ def lowest_bidder_name
auction.lowest_bid.bidder.name
end

def admin_edit_auction_partial
if UserPresenter.new(current_user).admin?
'auctions/edit_auction_link'
else
'components/null'
end
end

private

def available_and_user_is_bidder?
Expand Down
3 changes: 3 additions & 0 deletions app/views/auctions/_edit_auction_link.html.erb
@@ -0,0 +1,3 @@
<div>
<%= link_to 'Edit Auction', edit_admin_auction_path(@auction.id), class: 'button-bid usa-button' %>
</div>
1 change: 1 addition & 0 deletions app/views/auctions/show.html.erb
Expand Up @@ -18,6 +18,7 @@
<div class="usa-width-one-third">
<div class="auction-detail-panel">
<div class="auction-info">
<%= render @auction.admin_edit_auction_partial %>
<div>
<p class="auction-label">Auction type:</p>
<p class="auction-label-info">
Expand Down
6 changes: 3 additions & 3 deletions features/admin_approves_delivery.feature
Expand Up @@ -8,18 +8,18 @@ Feature: Admin approves delivery of a project
Given I am an administrator
And there is an auction that needs evaluation
And I sign in
When I visit the admin edit page for that auction
When I visit the admin form for that auction
And I select the result as accepted
And I click on the "Update" button
Then the proposal should have a CAP Proposal URL
When I visit the admin edit page for that auction
When I visit the admin form for that auction
Then I should see that the auction has a CAP Proposal URL

Scenario: Marking an auction as accepted where the vendor cannot be paid
Given I am an administrator
And there is an auction where the winning vendor is not eligible to be paid
And I sign in
When I visit the admin edit page for that auction
When I visit the admin form for that auction
And I select the result as accepted
And I click on the "Update" button
Then the proposal should not have a CAP Proposal URL
Expand Down
3 changes: 2 additions & 1 deletion features/admin_edits_auction.feature
Expand Up @@ -14,7 +14,8 @@ Feature: Admin edits auctions in the admins panel
And I should be able to edit the existing auction form

When I click on the "Update" button
Then I expect my auction changes to have been saved
Then I should be on the admin auctions page
And I expect my auction changes to have been saved
And I should see the start time I set for the auction
And I should see the end time I set for the auction

Expand Down
24 changes: 24 additions & 0 deletions features/admin_views_auction.feature
@@ -0,0 +1,24 @@
Feature: Admin views public auction pages
As an administrator
I want to be able to click to edit an auction from the auction show page
So that I don't have to go back to the auctions admin panel

Scenario: Admin navigates to edit page from auction show page
Given I am an administrator
And I sign in
And there is an open auction
And I visit the auction page
Then I should see an "Edit Auction" link

When I click on the "Edit Auction" link
Then I should be on the admin form for that auction

When I click on the "Update" button
Then I should be on the auction page

Scenario: Non-admin looks at the public auction page
Given I am a user with a verified SAM account
And I sign in
And there is an open auction
When I visit the auction page
Then I should not see an "Edit Auction" link
4 changes: 4 additions & 0 deletions features/step_definitions/link_and_button_steps.rb
Expand Up @@ -20,6 +20,10 @@
expect(page).to have_selector(:link, link)
end

Then(/^I should not see an? "([^"]+)" link$/) do |link|
expect(page).to_not have_selector(:link, link)
end

Then(/^I should see an? "([^"]+)" button$/) do |button|
expect(page).to have_selector(:link_or_button, button)
end
Expand Down
11 changes: 10 additions & 1 deletion features/step_definitions/navigation_steps.rb
Expand Up @@ -35,7 +35,7 @@
visit admin_auction_path(@auction)
end

When(/^I visit the admin edit page for that auction$/) do
When(/^I visit the admin form for that auction$/) do
visit edit_admin_auction_path(@auction)
end

Expand Down Expand Up @@ -78,3 +78,12 @@
Then(/^I should be on the bid confirmation page$/) do
expect(page.current_path).to eq(confirm_auction_bids_path(@auction))
end

When(/^I should be on the admin auctions page$/) do
expect(page.current_path).to eq(admin_auctions_path)
end


Then(/^I should be on the admin form for that auction$/) do
expect(page.current_path).to eq(edit_admin_auction_path(@auction))
end

0 comments on commit e9af48a

Please sign in to comment.