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

Commit

Permalink
Merge d095d07 into 3732e8f
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Harris committed May 12, 2016
2 parents 3732e8f + d095d07 commit cb2f10d
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 12 deletions.
8 changes: 8 additions & 0 deletions app/presenters/user_presenter.rb
Expand Up @@ -11,6 +11,14 @@ def in_sam?
model.sam_status
end

def small_business_label
if model.sam_accepted?
small_business? ? 'Yes' : 'No'
else
'N/A'
end
end

def model
__getobj__
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/users/index.html.erb
Expand Up @@ -31,14 +31,14 @@
Users (<%= @users.length %>); w/ DUNS (<%= @admin_report.non_admin_users_with_duns.length %>); In SAM (<%= @admin_report.non_admin_users_in_sam.length %>)
</h2>

<table class="usa-table-borderless">
<table id="table-users" class="usa-table-borderless">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">DUNS Number</th>
<th scope="col">SAM.gov status</th>
<th scope="col">Contracting Officer?</th>
<th scope="col">Small Business?</th>
<th scope="col">GitHub ID</th>
<th scope="col"></th>
</tr>
Expand All @@ -50,7 +50,7 @@
<td><%= user.email %></td>
<td><%= user.duns_number %></td>
<td><%= user.in_sam? %></td>
<td><%= user.contracting_officer? %></td>
<td><%= user.small_business_label %></td>
<td><%= link_to(user.github_id, user.github_json_url) %></td>
<td><%= link_to('Edit', edit_admin_user_path(user)) %></td>
</tr>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160510180328_add_small_biz_flag_to_users.rb
@@ -0,0 +1,5 @@
class AddSmallBizFlagToUsers < ActiveRecord::Migration
def change
add_column :users, :small_business, :boolean, default: false, null: false
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160503143402) do
ActiveRecord::Schema.define(version: 20160510180328) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -72,10 +72,11 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "email"
t.string "credit_card_form_url"
t.string "github_login"
t.string "credit_card_form_url"
t.integer "sam_status", default: 0, null: false
t.boolean "contracting_officer", default: false, null: false
t.boolean "small_business", default: false, null: false
end

add_index "users", ["contracting_officer"], name: "index_users_on_contracting_officer", where: "(contracting_officer = true)", using: :btree
Expand Down
4 changes: 2 additions & 2 deletions features/admin_users.feature
Expand Up @@ -23,7 +23,7 @@ Feature: Admin Users
And there are users in the system
And I visit the admin users page
When I sign in
And I click the edit user link next to the first non-admin user
And I click the edit user link next to the first admin user
And I check the 'Contracting officer' checkbox
And I submit the changes to the user
Then I expect there to be a contracting officer in the list of users
Then I expect there to be a contracting officer in the list of admin users
28 changes: 28 additions & 0 deletions features/small_business.feature
@@ -0,0 +1,28 @@
Feature: Small Business Vendors
As an adminstrator
I want to be able to identify small-business users
So they can bid on restricted auctions

Scenario: A user that is not a small business
Given I am an administrator
And there is a user in SAM.gov who is not a small business
When I sign in
And I visit the admin users page
Then I should see a column labeled "Small Business?"
And I should see "No" for the user in the "Small Business?" column

Scenario: A user who is a small business
Given I am an administrator
And there is a user in SAM.gov who is a small business
When I sign in
And I visit the admin users page
Then I should see a column labeled "Small Business?"
And I should see "Yes" for the user in the "Small Business?" column

Scenario: A user who is not in SAM.gov
Given I am an administrator
And there is a user who is not in SAM.gov
When I sign in
And I visit the admin users page
Then I should see a column labeled "Small Business?"
And I should see "N/A" for the user in the "Small Business?" column
39 changes: 37 additions & 2 deletions features/step_definitions/admin_users_steps.rb
Expand Up @@ -23,6 +23,12 @@
end
end

When(/^I click the edit user link next to the first admin user$/) do
within(:xpath, '/html/body/div/div/table[1]') do
click_on "Edit"
end
end

When(/^I check the 'Contracting officer' checkbox$/) do
check('user_contracting_officer')
end
Expand All @@ -31,8 +37,8 @@
click_on "Update User"
end

Then(/^I expect there to be a contracting officer in the list of users$/) do
within(:xpath, "html/body/div/div/div/table[2]/tbody/tr[1]/td[5]") do
Then(/^I expect there to be a contracting officer in the list of admin users$/) do
within(:css, "table#table-admins tbody tr td:nth-child(5)") do
expect(page).to have_content("true")
end
end
Expand All @@ -44,3 +50,32 @@
Then(/^I expect the page to show me the number of admin users$/) do
expect(page).to have_text("Admins (1)")
end

Then(/^I should see a column labeled "([^"]+)"$/) do |text|
find('th', text: text)
end

Given(/^there is a user in SAM.gov who is not a small business$/) do
@user = FactoryGirl.create(:user, sam_status: :sam_accepted, small_business: false)
end

Given(/^there is a user in SAM.gov who is a small business$/) do
@user = FactoryGirl.create(:user, sam_status: :sam_accepted, small_business: true)
end

Given(/^there is a user who is not in SAM.gov$/) do
@user = FactoryGirl.create(:user, sam_status: :sam_pending)
end

Then(/^I should see "([^"]+)" for the user in the "([^"]+)" column$/) do |value, column|
user_admin_columns = ['Name', 'Email', 'DUNS Number', 'SAM.gov status',
'Small Business?', 'Github ID']

index = user_admin_columns.index(column)
fail 'Unrecognized column: #{column}' if index.nil?
css = "table#table-users tbody tr td:nth-child(#{index+1})"

within(css) do
expect(page).to have_content(value)
end
end
5 changes: 5 additions & 0 deletions features/support/env.rb
Expand Up @@ -4,6 +4,8 @@
require 'cucumber/rspec/doubles'
require 'capybara/poltergeist'
require 'webmock/cucumber'
require 'capybara-screenshot/cucumber'

Dir[Rails.root.join("spec/support/*.rb")].each { |file| require file }

Capybara.register_driver :poltergeist do |app|
Expand All @@ -12,6 +14,9 @@

Capybara.javascript_driver = :poltergeist

# Screenshots were being saved to the root directory
Capybara.save_path = Rails.root.join('tmp')

Delayed::Worker.delay_jobs = false

Before('@background_jobs_off') do
Expand Down
14 changes: 11 additions & 3 deletions spec/support/api/schemas/admin/users.json
Expand Up @@ -45,8 +45,9 @@
"email",
"sam_status",
"credit_card_form_url",
"github_login",
"contracting_officer"
"github_login",
"contracting_officer",
"small_business"
],
"properties": {
"id": {
Expand All @@ -59,6 +60,9 @@
"contracting_officer": {
"type": "boolean"
},
"small_business": {
"type": "boolean"
},
"duns_number": {
"type": "string",
"minLength": 1
Expand Down Expand Up @@ -108,7 +112,8 @@
"sam_status",
"credit_card_form_url",
"github_login",
"contracting_officer"
"contracting_officer",
"small_business"
],
"properties": {
"id": {
Expand All @@ -121,6 +126,9 @@
"contracting_officer": {
"type": "boolean"
},
"small_business": {
"type": "boolean"
},
"duns_number": {
"type": "string",
"minLength": 1
Expand Down

0 comments on commit cb2f10d

Please sign in to comment.