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

Commit

Permalink
Merge c186dfb into b0f748c
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessie A. Young committed Apr 21, 2016
2 parents b0f748c + c186dfb commit ab1e705
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 45 deletions.
6 changes: 4 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ def edit
fail UnauthorizedError if current_user.nil? || current_user != @user

if current_user.duns_number.blank?
flash[:notice] = "You must supply a valid DUNS number"
flash.now[:warning] = "You must supply a valid DUNS number"
elsif current_user.sam_account?
flash.now[:success] = "Your DUNS number has been verified in Sam.gov"
elsif !current_user.sam_account?
flash[:notice] = "Your DUNS number was not found in Sam.gov. Please enter
flash.now[:error] = "Your DUNS number was not found in Sam.gov. Please enter
a valid DUNS number to complete your profile. Check
https://www.sam.gov/sam/helpPage/SAM_Reg_Status_Help_Page.html to make
sure your DUNS number is correct. If you need any help email us at
Expand Down
14 changes: 0 additions & 14 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,4 @@ module ApplicationHelper
def controller_class
controller.class.name.include?('Admin') ? 'admin' : 'bidder'
end

def flash_errors
result = nil
if !flash.empty? && !flash[:error].nil?
result = content_tag :div, class: 'usa-alert usa-alert-error', role: 'alert' do
content_tag :div, class: 'usa-alert-body' do
content_tag :h3, flash[:error], class: 'use-alert-heading'
end
end
end
flash.clear

result
end
end
11 changes: 11 additions & 0 deletions app/views/application/_flashes.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% if flash.any? %>
<% flash.to_hash.slice("alert", "error", "notice", "success", "warning").each do |key, value| -%>
<div class="flashes">
<div class="usa-alert usa-alert-<%= key%>">
<div class="usa-alert-body">
<h3 class="usa-alert-heading"></h3>
<p class="usa-alert-text"><%= value %></p>
</div>
</div>
<% end -%>
<% end %>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

<div class="content-wrapper" id="<% if current_page?(root_path) %>index<% elsif current_page?(auctions_path) %>auctions<% elsif current_page?(auctions_winners_path) %>winners<% end %>">
<div class="usa-width-one-whole">
<%= flash_errors %>
<%= render "flashes" %>
<%= yield %>
</div>
Expand Down
12 changes: 0 additions & 12 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@

<h1>Complete your account</h1>

<% if flash[:notice] %>
<div class="usa-alert usa-alert-warning">
<div class="usa-alert-body">
<h3 class="usa-alert-heading">DUNS Issue</h3>
<p class="usa-alert-text"><%= flash[:notice] %></p>
</div>
</div>
<% end %>

<p>Enter your DUNS number. Remember, <a href='https://sam.gov'>SAM.gov</a> registration is required to place bids. If you need help, email us at <%= mail_to 'micropurchase@gsa.gov' %>.</p>

<%= form_for @user, method: :put do |f| %>
<%= f.label :name, 'Name' %>
<%= f.text_field :name %>
Expand Down
11 changes: 5 additions & 6 deletions features/logging_in_and_out.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: logging in and out
When I visit the home page
And I click on the Login button
Then I should see an "Authorize with GitHub" button

When I click on the "Authorize with GitHub" button
Then I should see an "Edit profile" button

Expand Down Expand Up @@ -44,12 +44,12 @@ Feature: logging in and out
When I click on the "Authorize with GitHub" button
Then I should see my name
And I should see a "Logout" button

Scenario: User logs in when viewing protected or specific information
Given I am a user with a verified SAM account
When I visit my bids page
Then I should see an "Authorize with GitHub" button

When I click on the "Authorize with GitHub" button
Then I should see my name
And I should see a "Logout" button
Expand All @@ -69,7 +69,7 @@ Feature: logging in and out
When I fill the "Name" field with "Doris Doogooder"
And I click on the "Submit" button
Then I should be on the home page

When I click on the "Edit profile" link
Then I should see "doris@doogooder.com" in the "Email Address" field
And I should see "Doris Doogooder" in the "Name" field
Expand All @@ -82,7 +82,7 @@ Feature: logging in and out
Then I should be on my profile page
And I should see "doris@doogooder.com" in the "Email Address" field
And I should see "Doris Doogooder" in the "Name" field

Scenario: User tries to enter an invalid email address
Given I am a user with a verified SAM account
When I visit the home page
Expand All @@ -92,7 +92,6 @@ Feature: logging in and out
When I click on the "Authorize with GitHub" button
Then I should be on my profile page
And I should see a profile form with my info


When I fill the "Email Address" field with "doris_the_nonvalid_email_address_person"
And I click on the "Submit" button
Expand Down
13 changes: 11 additions & 2 deletions features/sam_check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ Feature: Automatically checking a user's SAM status
And I click on the "Submit" button
Then I should become a valid SAM user
And I should not see a warning about my SAM registration
When I visit my profile page
Then I should see a success message that "Your DUNS number has been verified in Sam.gov"

Scenario: Exception during SAM check on login
Given I am a user without a verified SAM account
And a SAM check for my DUNS will raise an exception
When I sign in and verify my account information
Then I should not become a valid SAM user
And I should see a warning that my SAM registration is not complete

Scenario: Negative SAM check on login
Given I am a user without a verified SAM account
And a SAM check for my DUNS will return false
Expand All @@ -41,7 +43,9 @@ Feature: Automatically checking a user's SAM status
And I click on the "Submit" button
Then I should not become a valid SAM user
And I should see a warning that my SAM registration is not complete

When I visit my profile page
Then I should see an alert that my DUNS number was not found in Sam.gov

Scenario: Negative SAM check on DUNS change
Given I am a user without a verified SAM account
And I am signed in
Expand All @@ -51,3 +55,8 @@ Feature: Automatically checking a user's SAM status
Then I should not become a valid SAM user
And I should see a warning that my SAM registration is not complete

Scenario: No DUNS number present
Given I am a user without a DUNS number
And I am signed in
When I visit my profile page
Then I should see a warning that "You must supply a valid DUNS number"
30 changes: 30 additions & 0 deletions features/step_definitions/flash_message_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Then(/^I should see an alert that "([^"]*)"$/) do |message|
within("div.usa-alert.usa-alert-error") do
expect(page).to have_content(message)
end
end

Then(/^I should see an alert that my DUNS number was not found in Sam\.gov$/) do
within("div.usa-alert.usa-alert-error") do
expect(page).to have_content(
"Your DUNS number was not found in Sam.gov. Please enter
a valid DUNS number to complete your profile. Check
https://www.sam.gov/sam/helpPage/SAM_Reg_Status_Help_Page.html to make
sure your DUNS number is correct. If you need any help email us at
micropurchase@gsa.gov"
)
end
end

Then(/^I should see a warning that "([^"]*)"$/) do |message|
within("div.usa-alert.usa-alert-warning") do
expect(page).to have_content(message)
end
end

Then(/^I should see a success message that "([^"]*)"$/) do |message|
within("div.usa-alert.usa-alert-success") do
expect(page).to have_content(message)
end
end

7 changes: 0 additions & 7 deletions features/step_definitions/login_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
@new_duns = Faker::Company.duns_number
@new_email = Faker::Internet.email

expect(page).to have_content("Enter your DUNS number")
fill_in("user_name", with: @new_name)
fill_in("user_duns_number", with: @new_duns)
fill_in("user_email", with: @new_email)
Expand Down Expand Up @@ -115,12 +114,6 @@ def fake_value_for_attribute(attribute)
expect(field.value).to eq(@user.send(attribute))
end

Then(/^I should see an alert that "([^"]*)"$/) do |message|
within("div.usa-alert.usa-alert-error") do
expect(page).to have_content(message)
end
end

Then(/^I should see my changes$/) do
@user = User.where(github_id: @github_id).first
expect(@user).to_not be_nil
Expand Down
7 changes: 6 additions & 1 deletion features/step_definitions/setup_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
mock_sign_in(@user.github_id, @user.name)
end

Given(/^I am a user without a DUNS number$/) do
@user = FactoryGirl.create(:user, sam_account: false, github_id: '123451', duns_number: nil)
@github_id = @user.github_id
mock_sign_in(@user.github_id, @user.name)
end

Given(/^I am an administrator$/) do
@user = FactoryGirl.create(:admin_user)
@github_id = @user.github_id
Expand Down Expand Up @@ -40,4 +46,3 @@
step "I sign in"
click_on "Submit"
end

0 comments on commit ab1e705

Please sign in to comment.