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

Commit

Permalink
Merge pull request #918 from 18F/develop
Browse files Browse the repository at this point in the history
Deploy #2 7/20/2016
  • Loading branch information
jessieay committed Jul 20, 2016
2 parents 7cefad7 + 9bcace2 commit f7a76dc
Show file tree
Hide file tree
Showing 21 changed files with 204 additions and 82 deletions.
3 changes: 0 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ engines:
enabled: true
brakeman:
enabled: true
exclude_fingerprints:
- 38eaf3a4c38ed941e5397a84c9f95b91a7c3dee9f70c0993131dd3be89180f75
- 122ff3e2371af7128b8dbc9444b16a83269494193f99b5f53a8a61565226d7f7
eslint:
enabled: true
csslint:
Expand Down
9 changes: 8 additions & 1 deletion app/models/auction_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def attributes
delivery_due_at: delivery_due_at,
ended_at: ended_at,
started_at: started_at,
user: user
user: user,
paid_at: paid_at
).delete_if { |_key, value| value.nil? }
end

Expand Down Expand Up @@ -67,6 +68,12 @@ def started_at
parse_datetime("started_at")
end

def paid_at
if params[:auction][:paid_at] == '1'
Time.current
end
end

def parse_datetime(field)
if params[:auction][field]
DateTimeParser.new(params[:auction], field).parse
Expand Down
12 changes: 6 additions & 6 deletions app/services/update_auction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def perform
attr_reader :auction, :params, :current_user

def assign_attributes
auction.assign_attributes(attributes)
auction.assign_attributes(parsed_attributes)
end

def update_auction_ended_job
Expand All @@ -50,7 +50,7 @@ def create_auction_ended_job
end

def updating_ended_at?
attributes.key?(:ended_at)
parsed_attributes.key?(:ended_at)
end

def perform_approved_auction_tasks
Expand All @@ -73,11 +73,11 @@ def vendor_ineligible?
end

def auction_accepted?
attributes[:result] == 'accepted'
parsed_attributes[:result] == 'accepted'
end

def auction_rejected?
attributes[:result] == 'rejected'
parsed_attributes[:result] == 'rejected'
end

def winning_bidder_is_eligible_to_be_paid?
Expand Down Expand Up @@ -108,8 +108,8 @@ def winning_bidder
WinningBid.new(auction).find.bidder
end

def attributes
@_attributes ||= AuctionParser.new(params, user).attributes
def parsed_attributes
@_parsed_attributes ||= AuctionParser.new(params, user).attributes
end

def user
Expand Down
6 changes: 5 additions & 1 deletion app/view_models/admin/action_item_list_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def result
end

def c2_proposal_url
auction.c2_proposal_url
if auction.purchase_card == 'default'
auction.c2_proposal_url
else
'N/A'
end
end

def paid?
Expand Down
51 changes: 26 additions & 25 deletions app/view_models/admin/auction_show_view_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(auction:, current_user:)
end

def csv_report_partial
if over?
if auction_status.over?
'admin/auctions/csv_report'
else
'components/null'
Expand Down Expand Up @@ -38,10 +38,8 @@ def admin_data
'Customer' => customer.agency_name,
'Billable to' => auction.billable_to,
'Purchase card' => auction.purchase_card,
'Paid at' => formatted_date(auction.paid_at),
'C2 proposal URL' => auction.c2_proposal_url,
'C2 approved at' => auction.c2_approved_at
}
'Paid at' => formatted_date(auction.paid_at)
}.merge(c2_fields)
end

def id
Expand All @@ -56,10 +54,6 @@ def summary
auction.summary
end

def capitalized_type
auction.type.dasherize.capitalize
end

def relative_time
status_presenter.relative_time
end
Expand All @@ -70,14 +64,6 @@ def veiled_bids
end
end

def eligibility_label
if AuctionThreshold.new(auction).small_business?
'Small-business only'
else
'SAM.gov only'
end
end

def label
status_presenter.label
end
Expand All @@ -104,12 +90,31 @@ def admin_edit_auction_partial

private

def status_presenter
@_status_presenter ||= StatusPresenterFactory.new(auction).create
def eligibility_label
if AuctionThreshold.new(auction).small_business?
'Small-business only'
else
'SAM.gov only'
end
end

def capitalized_type
auction.type.dasherize.capitalize
end

def over?
auction_status.over?
def c2_fields
if auction.purchase_card == 'default'
{
'C2 proposal URL' => auction.c2_proposal_url,
'C2 approved at' => auction.c2_approved_at
}
else
{ }
end
end

def status_presenter
@_status_presenter ||= StatusPresenterFactory.new(auction).create
end

def auction_status
Expand All @@ -120,10 +125,6 @@ def customer
auction.customer || NullCustomer.new
end

def rules
@_rules ||= RulesFactory.new(auction).create
end

def formatted_date(date)
DcTimePresenter.convert_and_format(date)
end
Expand Down
18 changes: 18 additions & 0 deletions app/view_models/admin/edit_auction_view_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def customer_options
([auction.customer] + Customer.sorted).uniq.compact
end

def c2_proposal_partial
if auction.purchase_card == "default"
'admin/auctions/c2_proposal_url'
else
'components/null'
end
end

def paid_at_partial
if auction.purchase_card == "default" || auction.result != "accepted"
'components/null'
elsif auction.paid_at.present?
'admin/auctions/disabled_paid_at'
else
'admin/auctions/paid_at'
end
end

private

def dc_time(field)
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/auctions/_c2_proposal_url.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= f.input :c2_proposal_url, disabled: true %>
4 changes: 4 additions & 0 deletions app/views/admin/auctions/_disabled_paid_at.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= f.input :paid_at,
as: :boolean,
input_html: { checked: true },
disabled: true %>
3 changes: 2 additions & 1 deletion app/views/admin/auctions/_edit_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= f.input :delivery_url %>
<%= f.input :result, collection: Auction.results.keys.to_a %>
<%= f.input :c2_proposal_url, disabled: true %>
<%= render partial: auction.c2_proposal_partial, locals: { f: f } %>
<%= render partial: auction.paid_at_partial, locals: { f: f } %>
1 change: 1 addition & 0 deletions app/views/admin/auctions/_paid_at.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= f.input :paid_at, as: :boolean %>
21 changes: 4 additions & 17 deletions config/brakeman.ignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
{
"ignored_warnings": [
{
"warning_type": "Redirect",
"warning_code": 18,
"fingerprint": "1f5e56ec432800fd1896435e9cd488f3c75047cdb1855add003acf99052a04f3",
"message": "Possible unprotected redirect",
"file": "app/controllers/authentications_controller.rb",
"line": 4,
"link": "http://brakemanscanner.org/docs/warning_types/redirect/",
"code": "redirect_to(LoginUser.new(request.env[\"omniauth.auth\"], session).perform)",
"render_path": null,
"location": {
"type": "method",
"class": "AuthenticationsController",
"method": "create"
},
"user_input": "SignInUser.new(request.env[\"omniauth.auth\"], session).perform",
"confidence": "High",
"note": "Fixed here: https://github.com/18F/micropurchase/commit/799d74393c394e016fba5eab9df1eb638a7d2b06"
"fingerprint": "38eaf3a4c38ed941e5397a84c9f95b91a7c3dee9f70c0993131dd3be89180f75"
},
{
"fingerprint": "122ff3e2371af7128b8dbc9444b16a83269494193f99b5f53a8a61565226d7f7"
}
],
"updated": "2015-11-17 18:38:44 -0500",
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ en:
from: "The 18F Micro-purchase team"
winning_bidder_missing_payment_method:
subject: "Please update your profile so Micro-purchase can pay you for your great work!"
para_1: "18F wants to pay you for your work! Our team recently accepted your work on \"%{auction_title}\".
We'd like to pay you %{amount}, but we need you to tell us where we can enter our credit card information.
para_1: "18F wants to pay you for your work! Our team recently accepted your work on \"%{auction_title}\".
We'd like to pay you %{amount}, but we need you to tell us where we can enter our credit card information.
To get paid, please go to %{profile_url} and enter a payment URL."
para_2: "Questions? Please contact us at microupurchase@gsa.gov"
sign_off: "Sincerely,"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ en:
issue_url: "GitHub issue URL"
github_repo: "GitHub repo URL"
c2_proposal_url: "C2 proposal URL"
paid_at: "Paid at"
paid_at: "Paid"
start_price: "Start price"
bid:
amount: "Your bid"
Expand Down
48 changes: 37 additions & 11 deletions features/admin_edits_auction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ Feature: Admin edits auctions in the admins panel
As an admin
I should be able to modify existing auctions

Background:
Scenario: Updating an auction
Given I am an administrator
And I sign in

Scenario: Updating an auction
Given there is an open auction
And there is an open auction
And there is a client account to bill to
And there is a skill in the system
And I visit the auctions admin page
Expand All @@ -26,11 +24,12 @@ Feature: Admin edits auctions in the admins panel
Then I should see new content on the page

Scenario: Associating an auction with a customer
Given there is an open auction
Given I am an administrator
And I sign in
And there is an open auction
And there is a customer
And I visit the auctions admin page

When I click to edit the auction
When I visit the admin form for that auction
Then I should see a select box with all the customers in the system

When I select a customer on the form
Expand All @@ -40,12 +39,39 @@ Feature: Admin edits auctions in the admins panel
When I click to edit the auction
Then I should see the customer selected for the auction

Scenario: Associating a auction with a skill
Given there is an open auction
Scenario: Associating an auction with a skill
Given I am an administrator
And I sign in
And there is an open auction
And there is a skill in the system
And I visit the auctions admin page
When I click to edit the auction
When I visit the admin form for that auction
And I select a skill on the form
And I click on the "Update" button
And I click to edit the auction
Then I should see the skill that I set for the auction selected

Scenario: Marking accepted auction as paid
Given I am an administrator
And I sign in
And there is an accepted auction
And the auction is for a different purchase card
When I visit the admin form for that auction
And I check the "Paid" checkbox
And I click on the "Update" button
Then I should see when the winning vendor was paid in ET

Scenario: Accepted auction already marked as paid
Given I am an administrator
And I sign in
And there is a paid auction
And the auction is for a different purchase card
When I visit the admin form for that auction
Then I should see the disabled "Paid" checkbox

Scenario: Marking non-accepted auction as paid
Given I am an administrator
And I sign in
And there is an auction that needs evaluation
And the auction is for a different purchase card
When I visit the admin form for that auction
Then I should not see the "Paid" checkbox
12 changes: 12 additions & 0 deletions features/step_definitions/admin_auction_form_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@
billable = find_field('auction_billable_to')
expect(billable.value).to eq(@billable.to_s)
end

When(/^I check the "Paid" checkbox$/) do
check('auction_paid_at')
end

When(/^I should see the disabled "Paid" checkbox$/) do
expect(page).to have_checked_field('auction_paid_at', disabled: true)
end

When(/^I should not see the "Paid" checkbox$/) do
expect(page).not_to have_field('auction_paid_at')
end
1 change: 1 addition & 0 deletions features/step_definitions/auction_attributes_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
end

Then(/^I should see when the winning vendor was paid in ET$/) do
@auction.reload
expect(page).to have_text(DcTimePresenter.convert_and_format(@auction.paid_at))
end

Expand Down
12 changes: 11 additions & 1 deletion features/step_definitions/auction_create_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
end

Given(/^there is a paid auction$/) do
@auction = FactoryGirl.create(:auction, :closed, :paid)
@auction = FactoryGirl.create(:auction, :closed, :accepted, :paid)
end

Given(/^the auction is for the default purchase card$/) do
Expand Down Expand Up @@ -172,3 +172,13 @@
@winning_bidder = WinningBid.new(@auction).find.bidder
@winning_bidder.update(payment_url: '')
end

Given(/^there is an accepted auction$/) do
@auction = FactoryGirl.create(
:auction,
:with_bidders,
:published,
result: :accepted,
accepted_at: nil,
)
end

0 comments on commit f7a76dc

Please sign in to comment.