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

Commit

Permalink
Merge 0041c82 into 15d2308
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieay committed Apr 27, 2016
2 parents 15d2308 + 0041c82 commit b412169
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 141 deletions.
9 changes: 3 additions & 6 deletions features/auctions.feature
Expand Up @@ -15,13 +15,12 @@ Feature: Basic Auction Views
Scenario: Many auctions
Given there are many different auctions
When I visit the home page
Then the auctions should be in reverse chronological order
Then there should be meta tags for the index page for 5 open and 1 future auctions
Then there should be meta tags for the index page for 1 open and 1 future auctions

Scenario: Visiting a auction detail page
Given there is an open auction
And there is also an unpublished auction

When I visit the auction page
Then I should see the auction's title
And I should see the auction's description
Expand All @@ -30,8 +29,6 @@ Feature: Basic Auction Views
And I should see when the auction ends
And I should see a current bid amount
And there should be meta tags for the open auction
#When I visit the unpublished auction
#Then I should see a routing error

Scenario: There are no auctions
When I visit the home page
Expand All @@ -43,7 +40,7 @@ Feature: Basic Auction Views
When I visit the home page
Then I should see the number of bid for the auction
And I should see the auction's summary

When I click on the link to the bids
Then I should see the bid history

Expand Down
6 changes: 3 additions & 3 deletions features/logging_in_and_out.feature
Expand Up @@ -68,13 +68,13 @@ Feature: logging in and out
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@doogooder.com"
When I fill the "Email Address" field with "doris@example.com"
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
Then I should see "doris@example.com" in the "Email Address" field
And I should see "Doris Doogooder" in the "Name" field

When I click on the "Logout" button
Expand All @@ -83,7 +83,7 @@ Feature: logging in and out

When I click on the "Authorize with GitHub" button
And I visit my profile page
And I should see "doris@doogooder.com" in the "Email Address" field
And I should see "doris@example.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
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/admin_auctions_steps.rb
Expand Up @@ -45,7 +45,7 @@
@deadline_day = Presenter::DcTime.convert(@time_in_days.business_days.from_now).strftime("%m/%d/%Y")
fill_in("due_in_days", with: @time_in_days)

@billable = "the tock line item for CALC"
@billable = "the tock line item for CALC"
fill_in("auction_billable_to", with: @billable)

select("published", from: "auction_published")
Expand Down Expand Up @@ -77,7 +77,7 @@
@deadline_day = Presenter::DcTime.convert(Time.now + 5.days).strftime("%m/%d/%Y")
fill_in("auction_delivery_deadline", with: @deadline_day)

@billable = "the tock line item for CALC"
@billable = "the tock line item for CALC"
fill_in("auction_billable_to", with: @billable)

select("published", from: "auction_published")
Expand Down
6 changes: 2 additions & 4 deletions features/step_definitions/admin_dashboard_steps.rb
@@ -1,15 +1,13 @@
Given(/^there are complete and successful auctions$/) do
@complete_and_successful = Array.new(5) do
FactoryGirl.create(:auction, :complete_and_successful)
end
@complete_and_successful = FactoryGirl.create_list(:auction, 2, :complete_and_successful)
end

When(/^I visit the admin action items page$/) do
visit admin_action_items_path
end

When(/^I visit the preview page for the unpublished auction$/) do
visit admin_preview_auction_path(@unpublished_auction)
visit admin_preview_auction_path(@unpublished_auction)
end

Then(/^I should see a preview of the auction$/) do
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/admin_users_steps.rb
Expand Up @@ -13,8 +13,8 @@
end

Given(/^there are users in the system$/) do
@number_of_users = 11
@number_of_users.times { FactoryGirl.create(:user) }
@number_of_users = 1
FactoryGirl.create(:user)
end

Then(/^I expect the page to show me the number of regular users$/) do
Expand Down
31 changes: 7 additions & 24 deletions features/step_definitions/auction_steps.rb
@@ -1,5 +1,3 @@
# coding: utf-8

# FIXME: Assign to variable based on type and use name as selector (rather than overwriting @auction)
Given(/^there is an? (.+) auction$/) do |label|
@auction = case label
Expand All @@ -25,19 +23,9 @@
end

Given(/^there are many different auctions$/) do
Timecop.freeze do
Timecop.scale(1.hour)

@closed_auctions = 3.times.to_a.map do
FactoryGirl.create(:auction, :closed, title: Faker::Commerce.product_name)
end

@current_auctions = 5.times.to_a.map do
FactoryGirl.create(:auction, :running, title: Faker::Commerce.product_name)
end

@future_auctions = [FactoryGirl.create(:auction, :future)]
end
FactoryGirl.create(:auction, :closed, title: Faker::Commerce.product_name)
FactoryGirl.create(:auction, :running, title: Faker::Commerce.product_name)
FactoryGirl.create(:auction, :future)
end

Given(/^there is also an unpublished auction$/) do
Expand Down Expand Up @@ -82,7 +70,6 @@
expect(page).to_not have_content(number_of_bids)
end


When(/^I click on the link to the bids$/) do
number_of_bids = "#{@auction.bids.length} bids"
click_on(number_of_bids)
Expand All @@ -91,8 +78,6 @@
Then(/^I should see the bid history$/) do
h1_text = "Bids for \"#{@auction.title}\""
expect(page).to have_content(h1_text)

# FIXME: more
end

Then(/^I should not see the unpublished auction$/) do
Expand All @@ -104,16 +89,17 @@
end

Then(/^I should see a message about no auctions$/) do
expect(page).to have_content("There are no current open auctions on the site. " \
"Please check back soon to view micropurchase opportunities.")
expect(page).to have_content(
"There are no current open auctions on the site. " \
"Please check back soon to view micropurchase opportunities."
)
end

Then(/^I should see a message about no bids$/) do
expect(page).to have_content("No bids yet.")
end

When(/^I submit a bid for \$(.+)$/) do |amount|
field = find_field('Your bid:')
fill_in("Your bid:", with: amount)
step('I click on the "Submit" button')
end
Expand Down Expand Up @@ -156,6 +142,3 @@
expect(page).to have_content(label)
end
end

Then(/^the auctions should be in reverse chronological order$/) do
end
22 changes: 9 additions & 13 deletions features/step_definitions/bid_details_steps.rb
@@ -1,7 +1,3 @@
When(/^I visit the auction bids page$/) do
visit(auction_bids_path(@auction.id))
end

Then(/^I should be able to see the full details for each bid$/) do
# sort the bids so that newest is first
bids = @auction.bids.sort_by(&:created_at).reverse
Expand All @@ -27,7 +23,7 @@
within(:xpath, cel_xpath(row_number, 3)) do
expect(page).to have_content(amount)
end

# check the "date" column
within(:xpath, cel_xpath(row_number, 4)) do
expect(page).to have_content(bid.time)
Expand All @@ -45,24 +41,24 @@
unredacted_bidder_name = bid.bidder.name
unredacted_bidder_duns = bid.bidder.duns_number
bid = Presenter::Bid.new(bid)

# check the "name" column
within(:xpath, cel_xpath(row_number, 1)) do
expect(page).not_to have_content(unredacted_bidder_name)
expect(page).to have_content("[Name withheld until the auction ends]")
end

within(:xpath, cel_xpath(row_number, 2)) do
expect(page).not_to have_content(unredacted_bidder_duns)
expect(page).to have_content("[Withheld]")
end

# check the "amount" column
amount = ApplicationController.helpers.number_to_currency(bid.amount)
within(:xpath, cel_xpath(row_number, 3)) do
expect(page).to have_content(amount)
end

# check the "date" column
within(:xpath, cel_xpath(row_number, 4)) do
expect(page).to have_content(bid.time)
Expand All @@ -86,22 +82,22 @@
end

bid = Presenter::Bid.new(bid)

# check the "name" column
within(:xpath, cel_xpath(row_number, 1)) do
expect(page).to have_content(bidder_name)
end

within(:xpath, cel_xpath(row_number, 2)) do
expect(page).to have_content(bidder_duns)
end

# check the "amount" column
amount = ApplicationController.helpers.number_to_currency(bid.amount)
within(:xpath, cel_xpath(row_number, 3)) do
expect(page).to have_content(amount)
end

# check the "date" column
within(:xpath, cel_xpath(row_number, 4)) do
expect(page).to have_content(bid.time)
Expand Down
8 changes: 4 additions & 4 deletions features/step_definitions/login_steps.rb
Expand Up @@ -43,7 +43,7 @@
When(/^I fill out the profile form$/) do
@new_name = Faker::Name.name
@new_duns = Faker::Company.duns_number
@new_email = Faker::Internet.email
@new_email = "random#{rand(10000)}@example.com"

fill_in("user_name", with: @new_name)
fill_in("user_duns_number", with: @new_duns)
Expand Down Expand Up @@ -73,7 +73,7 @@ def fake_value_for_attribute(attribute)
when 'duns_number'
Faker::Company.duns_number
when 'email'
Faker::Internet.email
"random#{rand(10000)}@example.com"
else
fail "Unknown attribute '#{attribute}'"
end
Expand All @@ -94,7 +94,7 @@ def fake_value_for_attribute(attribute)
attribute = attribute.parameterize('_')
@new_values ||= {}
@new_values[attribute] = value

step("I fill in the \"user_#{attribute}\" field with \"#{value}\"")
end

Expand All @@ -110,7 +110,7 @@ def fake_value_for_attribute(attribute)
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)
Expand Down
9 changes: 4 additions & 5 deletions features/step_definitions/page_steps.rb
Expand Up @@ -3,7 +3,6 @@
end

When(/^I click on the "?([^"]+)"? button$/) do |button|
# will click the first if there are two with same text!
first(:link_or_button, button).click
end

Expand Down Expand Up @@ -43,6 +42,10 @@
visit my_bids_path
end

When(/^I visit the auction bids page$/) do
visit(auction_bids_path(@auction.id))
end

When(/^I visit my profile page$/) do
@user = User.find_by(github_id: @github_id)
visit edit_user_path(@user)
Expand Down Expand Up @@ -77,17 +80,13 @@

expect(page).to have_css("title", visible: false, text: "18F Micro-purchase - #{pr_auction.title}")
expect(page).to have_css("meta[property='og:title'][content='18F Micro-purchase - #{pr_auction.title}']", visible: false)
# expect(page).to have_css("meta[name='description'][content='#{pr_auction.summary}']", visible: false)
# expect(page).to have_css("meta[property='og:description'][content='#{pr_auction.summary}']", visible: false)
end

Then(/^there should be meta tags for the open auction$/) do
pr_auction = Presenter::Auction.new(@auction)

expect(page).to have_css("title", visible: false, text: "18F Micro-purchase - #{pr_auction.title}")
expect(page).to have_css("meta[property='og:title'][content='18F Micro-purchase - #{pr_auction.title}']", visible: false)
# expect(page).to have_css("meta[name='description'][content='#{pr_auction.summary}']", visible: false)
# expect(page).to have_css("meta[property='og:description'][content='#{pr_auction.summary}']", visible: false)
end

# FIXME
Expand Down
1 change: 0 additions & 1 deletion features/step_definitions/setup_steps.rb
@@ -1,4 +1,3 @@
# coding: utf-8
Given(/^I am a user with a verified SAM account$/) do
@user = FactoryGirl.create(:user, sam_status: :sam_accepted, github_id: '123451')
@github_id = @user.github_id
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/application_controller_spec.rb
Expand Up @@ -10,15 +10,15 @@
let(:format) { double('format', "html?" => true, "json?" => false) }

it 'should return an instance of WebAuthenticator' do
expect(controller.send(:authenticator)).to be_a(ApplicationController::WebAuthenticator)
expect(controller.send(:authenticator)).to be_a(WebAuthenticator)
end
end

context 'when the controller receives an API request' do
let(:format) { double('format', "html?" => false, "json?" => true) }

it 'should return an instance of ApiAuthenticator' do
expect(controller.send(:authenticator)).to be_a(ApplicationController::WebAuthenticator)
expect(controller.send(:authenticator)).to be_a(WebAuthenticator)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/factories/users.rb
@@ -1,10 +1,11 @@
FactoryGirl.define do
sequence(:github_id) { |n| n }
sequence(:email) { |n| "email#{n}@example.com" }

factory :user do
duns_number { Faker::Company.duns_number }
name { Faker::Name.name }
email { Faker::Internet.email }
email
github_id 123_456
sam_status :sam_pending
credit_card_form_url 'https://some-website.com/pay'
Expand Down
2 changes: 1 addition & 1 deletion spec/models/update_user_spec.rb
Expand Up @@ -13,7 +13,7 @@
user: {
name: Faker::Name.name,
duns_number: valid_duns_number,
email: Faker::Internet.email,
email: "random#{rand(10000)}@example.com",
credit_card_form_url: user_credit_card_url
}
)
Expand Down

0 comments on commit b412169

Please sign in to comment.