Skip to content

Commit

Permalink
Rewrite people_employees feature spec as request spec
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomTannenbaum committed Aug 2, 2024
1 parent 8cd1708 commit 0277ae5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 53 deletions.
53 changes: 0 additions & 53 deletions spec/features/people_employees_spec.rb

This file was deleted.

1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

# Helpers from gems
config.include(Devise::Test::IntegrationHelpers, type: :feature)
config.include(Devise::Test::IntegrationHelpers, type: :request)
config.include(Devise::Test::ControllerHelpers, type: :controller)
config.include(ActionView::RecordIdentifier, type: :feature)

Expand Down
53 changes: 53 additions & 0 deletions spec/requests/people_employees_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require "rails_helper"

describe 'Update or create person' do
before(:each) do
sign_in auth_users(:user), scope: :auth_user
end
it 'should update person when visited' do
stub_ptime_request(fixture_data("wally").to_json, "employees/50", 200)

Company.create!(name: "Ex-Mitarbeiter")
person_wally = people(:wally)
person_wally.ptime_employee_id = 50
person_wally.save!
expect(person_wally.name).to eq('Wally Allround')
expect(person_wally.email).to eq('[email protected]')

get "/people/#{person_wally.id}"
expect(response).to render_template(:show)

person_wally.reload
expect(person_wally.name).to eq('Changed Wally Allround')
expect(person_wally.shortname).to eq('CAL')
expect(person_wally.email).to eq('[email protected]')
expect(person_wally.marital_status).to eq('single')
expect(person_wally.title).to eq('Quarter-Stack Developer')
expect(person_wally.birthdate).to eq('1.1.2000')
expect(person_wally.location).to eq('Basel')
expect(person_wally.nationality).to eq('DE')
expect(person_wally.nationality2).to eq('DK')
end

it 'should create person when visited' do
stub_ptime_request(fixture_data("wally").to_json, "employees/50", 200)

Company.create!(name: "Ex-Mitarbeiter")
person_wally = people(:wally)
person_wally.destroy!
expect(Person.find_by(name: "Wally Allround")).to be_nil

get "/people/new?ptime_employee_id=50"

new_wally = Person.find_by(name: "Changed Wally Allround")
expect(new_wally.name).to eq('Changed Wally Allround')
expect(new_wally.shortname).to eq('CAL')
expect(new_wally.email).to eq('[email protected]')
expect(new_wally.marital_status).to eq('single')
expect(new_wally.title).to eq('Quarter-Stack Developer')
expect(new_wally.birthdate).to eq('1.1.2000')
expect(new_wally.location).to eq('Basel')
expect(new_wally.nationality).to eq('DE')
expect(new_wally.nationality2).to eq('DK')
end
end

0 comments on commit 0277ae5

Please sign in to comment.