Skip to content

Instantly share code, notes, and snippets.

@jordanbrock
Created March 19, 2013 06:12
Show Gist options
  • Save jordanbrock/5194039 to your computer and use it in GitHub Desktop.
Save jordanbrock/5194039 to your computer and use it in GitHub Desktop.
leads_controller_test.rb
require 'test_helper'
describe "Leads Integration Test" do
def filter_leads_by_status(status)
select status, from: :filter_lead_status
click_button "Filter"
end
before :each do
# factory_setup
@wa = Factory(:location, name: "Western Australia")
setup_user(@wa, :leads_admin)
@role_sales = Factory(:role, name: "sales")
@user.roles << @role_sales
login_user
end
describe "GET /" do
before :each do
@lead_pending = Factory(:lead, location: @wa, converted: 0, status: Lead::PENDING)
@lead_active = Factory(:lead, location: @wa, converted: 0, status: Lead::ACTIVE)
@lead_hold = Factory(:lead, location: @wa, converted: 0, status: Lead::ON_HOLD)
@lead_converted = Factory(:lead, location: @wa, converted: 1, status: Lead::CONVERTED)
@lead_closed = Factory(:lead, location: @wa, converted: 0, status: Lead::CLOSED, closed: 1)
end
it "should allow a user to filter the list of leads", js: true do
visit sales_cs_leads_path
filter_leads_by_status("On Hold")
sleep 1
assert page.has_selector? "table tbody tr", count: 1
assert page.has_selector? "#lead_#{@lead_hold.id}"
within "#lead_#{@lead_hold.id}" do
assert page.has_content? @lead_hold.name
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment