Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lonelydimple/895704 to your computer and use it in GitHub Desktop.
Save lonelydimple/895704 to your computer and use it in GitHub Desktop.
require 'test_helper'
require 'capybara/rails'
class AgentRequestsUpdateToFidelityBondTest < ActionDispatch::IntegrationTest
fixtures :all
include Capybara
self.use_transactional_fixtures = false
#Scenario: agent requests a change in principal address
#Given I'm an authenticated agent belonging to an agency
#And an existing approved fidelity bond for that agency:
#|principal_name | John Smith |
#|principal_dba ||
#|principal_address1 | 100 Main Street |
#| principal_city | DSM |
#| principal_zip | 50101 |
#|principal_address2 ||
#|principal_phone ||
#| principal_state | NE |
#When I go to the fidelity bond page
#And I follow "Update Bond"
#Then the "Address" field should contain "100 Main Street"
#And the "City" field should contain "DSM"
#And I fill in "Address" with "1001 Main Street"
#And I fill in "City" with "Des Moines"
#And I press "Update"
#Then I should see "updated successfully"
#And I should see "1001 Main Street"
#And I should see "Des Moines"
#And an update should be created for the fidelity bond
#And I follow "Print Endorsement"
#And I should receive a pdf
test "agent requests a change in principal address" do
@agency = Factory(:appointed_agency, :direct_bill => true)
@fidelity_bond = Factory.create(:fidelity_bond,
:principal_name => 'John Smith',
:principal_dba => '',
:principal_address1 => '100 Main Street',
:principal_city => 'DSM',
:principal_zip => '50101',
:principal_address2 => '',
:principal_phone => '',
:principal_state => 'NE',
:appointed_agency => @agency,
:approved => true,
:individuals_covered => 10,
:penal_sum => 1000)
@user = Factory(:licensed_agent, :appointed_agency_id => @agency.id)
visit '/users/sign_in'
fill_in "Username", :with => @user.username
fill_in "Password", :with => "1"
click_button "Sign In"
visit fidelity_bond_path(@fidelity_bond)
click_link 'Update Bond'
fill_in 'Address', :with => '1001 Main Street'
fill_in 'City', :with => 'Des Moines'
click_button 'Update'
assert_match /updated successfully/, page.body
assert_equal @fidelity_bond.versions.count, 1
update = @fidelity_bond.versions.first
assert_equal update.modifications['principal_address1'].last, "1001 Main Street"
assert_not_nil update.endorsement
click_link "Print Endorsement"
assert_equal page.response_headers["Content-Type"], "application/pdf"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment