diff --git a/app/models/update_user.rb b/app/models/update_user.rb index b32745eb..885559da 100644 --- a/app/models/update_user.rb +++ b/app/models/update_user.rb @@ -37,6 +37,6 @@ def update_sam end def user_params - params.require(:user).permit(:name, :duns_number, :email) + params.require(:user).permit(:name, :duns_number, :email, :credit_card_form_url) end end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 58b3e2fd..75aa6e6f 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -25,5 +25,8 @@ <%= f.label :email, 'Email Address' %> <%= f.text_field :email %> + <%= f.label :credit_card_form_url, 'Credit Card Form URL' %> + <%= f.text_field :credit_card_form_url %> + <%= f.submit 'Submit', :class => 'usa-button usa-button-outline' %> <% end %> diff --git a/features/bid_details.feature b/features/bid_details.feature index 0ee31d64..933c3e3d 100644 --- a/features/bid_details.feature +++ b/features/bid_details.feature @@ -15,7 +15,7 @@ Feature: Bid Details Scenario: When the auction is open and I'm logged in Given there is an open auction - And I am allowed to bid + And I am an authenticated vendor And I have placed a bid When I visit the auction bids page Then I should see my name and DUNS only on my bids diff --git a/features/bidding.feature b/features/bidding.feature index 17c9f10c..ec666ff5 100644 --- a/features/bidding.feature +++ b/features/bidding.feature @@ -23,7 +23,7 @@ Feature: Bidding Then I should see an "Authorize with GitHub" button When I click on the "Authorize with GitHub" link - Then I should be on the profile edit page + Then I should be on my profile page And I click on the "Submit" button Then I should see the auction's title @@ -61,7 +61,7 @@ Feature: Bidding Scenario: Viewing an auction when I have not bid Given there is an open bidless auction - And I am allowed to bid + And I am an authenticated vendor When I visit the home page And I click on the Bid button @@ -71,7 +71,7 @@ Feature: Bidding Scenario: When someone else has outbid me Given there is an open auction - And I am allowed to bid + And I am an authenticated vendor When I visit the home page And I click on the "Bid" button diff --git a/features/closed_auctions.feature b/features/closed_auctions.feature index 3b21a005..d6d8cebe 100644 --- a/features/closed_auctions.feature +++ b/features/closed_auctions.feature @@ -5,7 +5,7 @@ Feature: Closed Auctions Scenario: I am the winner Given there is a closed auction - And I am allowed to bid + And I am an authenticated vendor And I have placed the lowest bid When I visit the auction page Then I should see the auction had a winning bid with name @@ -15,7 +15,7 @@ Feature: Closed Auctions Scenario: I am not the winner Given there is a closed auction - And I am allowed to bid + And I am an authenticated vendor And I have placed a bid that is not the lowest When I visit the auction page Then I should see the auction had a winning bid with name @@ -25,7 +25,7 @@ Feature: Closed Auctions Scenario: I have not bid on the auction Given there is a closed auction - And I am allowed to bid + And I am an authenticated vendor And I have not placed a bid When I visit the auction page Then I should see the auction had a winning bid with name @@ -35,7 +35,7 @@ Feature: Closed Auctions Scenario: Nobody has bid on the auction Given there is a closed bidless auction - And I am allowed to bid + And I am an authenticated vendor When I visit the auction page Then I should see when the auction ended And I should see the auction ended with no bids diff --git a/features/credit_card_url.feature b/features/credit_card_url.feature new file mode 100644 index 00000000..d481b194 --- /dev/null +++ b/features/credit_card_url.feature @@ -0,0 +1,32 @@ +Feature: Credit Card Form URL + As a vendor on the platform + I want to see the Credit Card Form URL stored for my account + So that I can make sure payments are going to the right place + + Scenario: Vendor views Credit Card Form URL + Given I am an authenticated vendor + And there is a Credit Card Form URL associated with my account + When I visit my profile page + Then I should see my credit card form URL in the "Credit Card Form URL" field + + Scenario: Vendor saves a payment URL + Given I am an authenticated vendor + And there is no Credit Card Form URL associated with my account + When I visit my profile page + And I fill in the Credit Card Form URL field on my profile page + And I click on the "Submit" button + Then I should be on the home page + + When I visit my profile page + Then I should see my credit card form URL in the "Credit Card Form URL" field + + Scenario: Vendor edits an existing Payment URL + Given I am an authenticated vendor + And there is a Credit Card Form URL associated with my account + And I visit my profile page + When I fill in the Credit Card Form URL field on my profile page + And I click on the "Submit" button + Then I should be on the home page + + When I visit my profile page + Then the new value should be stored as my Credit Card Form URL diff --git a/features/logging_in_and_out.feature b/features/logging_in_and_out.feature index 8f3f15b2..a31c38a6 100644 --- a/features/logging_in_and_out.feature +++ b/features/logging_in_and_out.feature @@ -61,7 +61,7 @@ Feature: logging in and out Then I should see an "Authorize with GitHub" button When I click on the "Authorize with GitHub" button - Then I should be on the profile edit page + Then I should be on my profile page And I should see a profile form with my info And there should be meta tags for the edit profile form @@ -79,7 +79,7 @@ Feature: logging in and out Then I should see an "Authorize with GitHub" button When I click on the "Authorize with GitHub" button - Then I should be on the profile edit page + 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 @@ -90,9 +90,9 @@ Feature: logging in and out Then I should see an "Authorize with GitHub" button When I click on the "Authorize with GitHub" button - Then I should be on the profile edit page + Then I should be on my profile page And I should see a profile form with my info - And there should be meta tags for the edit profile form + When I fill the "Email Address" field with "doris_the_nonvalid_email_address_person" And I click on the "Submit" button diff --git a/features/single_bid.feature b/features/single_bid.feature index 71842149..8da44433 100644 --- a/features/single_bid.feature +++ b/features/single_bid.feature @@ -13,7 +13,7 @@ Feature: Single-bid auctions Scenario: bidding on a single-bid auction Given there is a single-bid auction - And I am allowed to bid + And I am an authenticated vendor When I visit the home page Then I should not see "Current bid:" @@ -42,7 +42,7 @@ Feature: Single-bid auctions Scenario: viewing your own single bid Given there is a single-bid auction - And I am allowed to bid + And I am an authenticated vendor When I visit the auction page And I click on the "BID" button Then I should be on the new bid page @@ -61,7 +61,7 @@ Feature: Single-bid auctions Scenario: viewing the bid history for a closed single-bid auction Given there is a closed single-bid auction - And I am allowed to bid + And I am an authenticated vendor When I visit the auction bids page Then I should not see "Bids are sealed until the auction ends." And I should not see "See the auction rules to learn more." diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 639acd0e..74bc0f61 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -55,12 +55,62 @@ fill_in(field, with: value) end +When(/^there is no (.+) associated with my account$/) do |attribute| + attribute = attribute.parameterize('_') + @user.update_attribute(attribute, nil) +end + +def fake_value_for_attribute(attribute) + case attribute + when 'credit_card_form_url' + Faker::Internet.url + when 'name' + Faker::Name.name + when 'duns_number' + Faker::Company.duns_number + when 'email' + Faker::Internet.email + else + fail "Unknown attribute '#{attribute}'" + end +end + +When(/^there is a (.+) associated with my account$/) do |attr| + attribute = attr.parameterize('_') + @user.update_attribute(attribute, fake_value_for_attribute(attribute)) +end + +When(/^I fill in the (.+) field on my profile page$/) do |attribute| + attribute = attribute.parameterize('_') + value = fake_value_for_attribute(attribute) + + @new_values ||= {} + @new_values[attribute] = value + + step("I fill in the \"user_#{attribute}\" field with \"#{value}\"") +end + +When(/^I fill in the "(.+)" field with "([^"]*)"$/) do |field, value| + fill_in(field, with: value) +end + +Then(/^the new value should be stored as my (.+)$/) do |attribute| + attribute = attribute.parameterize('_') + field = find_field("user_#{attribute}") + + expect(@new_values).to_not be_nil + expect(@new_values[attribute]).to_not be_nil + expect(field.value).to eq(@new_values[attribute]) +end + Then(/^I should see "([^"]*)" in the "([^"]*)" field$/) do |value, field| field = find_field(field) expect(field.value).to eq(value) end Then(/^I should see my (.+) in the "([^"]*)" field$/) do |attribute, field| + @user.reload + attribute = attribute.parameterize('_') field = find_field(field) expect(field.value).to eq(@user.send(attribute)) end diff --git a/features/step_definitions/page_steps.rb b/features/step_definitions/page_steps.rb index 16b6bb83..39881e9f 100644 --- a/features/step_definitions/page_steps.rb +++ b/features/step_definitions/page_steps.rb @@ -39,6 +39,10 @@ visit my_bids_path end +When(/^I visit my profile page$/) do + visit edit_user_path(@user) +end + Then(/^I should be on the home page$/) do expect(page.current_path).to eq("/") end @@ -47,7 +51,7 @@ expect(page.current_path).to eq(auction_path(@auction)) end -Then(/^I should be on the profile edit page$/) do +Then(/^I should be on my profile page$/) do expect(page.current_path).to eq(edit_user_path(@user)) end diff --git a/features/step_definitions/setup_steps.rb b/features/step_definitions/setup_steps.rb index 447ff868..ccd996c6 100644 --- a/features/step_definitions/setup_steps.rb +++ b/features/step_definitions/setup_steps.rb @@ -31,7 +31,7 @@ step("I sign in") end -Given(/^I am allowed to bid$/) do +Given(/^I am an authenticated vendor$/) do step("I am a user with a verified SAM account") step("I sign in") end