-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite people_employees feature spec as request spec
- Loading branch information
1 parent
8cd1708
commit 0277ae5
Showing
3 changed files
with
54 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |