Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Creates EmploymentDetail model#461

Merged
akhilgkrishnan merged 7 commits intodevelopfrom
add-employment-details-table
Jun 13, 2022
Merged

Creates EmploymentDetail model#461
akhilgkrishnan merged 7 commits intodevelopfrom
add-employment-details-table

Conversation

@mohinid
Copy link
Contributor

@mohinid mohinid commented Jun 9, 2022

Notion card

https://www.notion.so/saeloun/Add-tables-for-personal-employment-Allocated-devices-compensation-71ef49d0c38e4242bd2998120141372d

Summary

  1. Creates employment_details table with appropriate columns.
  2. Creates 1-1 association between CompanyUser and EmploymentDetail model.
  3. Adds validation for the EmploymentDetail model.
  4. Add RSpec for both EmploymentDetail and CompanyUser models.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added validations & RSpecs for User and EmploymentDetail models.

Checklist:

  • I have manually tested all workflows
  • I have performed a self-review of my own code
  • I have added automated tests for my code

@mohinid mohinid added the feature label Jun 9, 2022
@mohinid mohinid self-assigned this Jun 9, 2022
@github-actions
Copy link

github-actions bot commented Jun 9, 2022

Current Code Coverage Percent of this PR:

88.13 %

Files having coverage below 100%

Impacted Files Coverage
/app/controllers/users/invitations_controller.rb 86.36 %
/app/policies/payments/provider_policy.rb 85.71 %
/app/services/invoice_payment/checkout.rb 44.0 %
/app/services/invoice_payment/pdf_generation.rb 70.97 %
/app/services/report/filters.rb 87.1 %
/app/controllers/internal_api/v1/profile_controller.rb 96.88 %
/app/controllers/internal_api/v1/payment_settings_controller.rb 93.33 %
/app/controllers/internal_api/v1/payments/providers_controller.rb 94.74 %
/lib/benchmarking/benchmarker.rb 0.0 %

Copy link
Contributor

@rohitjoshixyz rohitjoshixyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohinid Added a few suggestions

Comment on lines 20 to 24
describe "validate comparisons" do
it "resignation date should be later than joining date" do
expect(employment_detail.resigned_at).to be > employment_detail.joined_at
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when either of them is nil? Add a spec for each

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joined_at cannot be nill. I have validation added for the same. Will add test for nil resigned_at date.

Comment on lines 8 to 9
joined_at { Faker::Date.between(from: "2020-01-01", to: "2021-01-01") }
resigned_at { Date.today }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This factory will always create a resigned employee by default.
Let's keep resigned_at nil by default

has_many :identities, dependent: :delete_all
has_one_attached :avatar
rolify strict: true
has_one :employment_detail, dependent: :destroy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this on line:62

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohinid I have got a couple of doubts related to this flow because, As per the Miru workflow the User can be part of multiple companies and the employee details vary with the position handled in each company. This EmploymentDetails model hasn't given an idea about the company which the employee is associated with. So we should add a scope for the company model.

@mohinid
Copy link
Contributor Author

mohinid commented Jun 13, 2022

@mohinid I have got a couple of doubts related to this flow because, As per the Miru workflow the User can be part of multiple companies and the employee details vary with the position handled in each company. This EmploymentDetails model hasn't given an idea about the company which the employee is associated with. So we should add a scope for the company model.

Hi @akhilgkrishnan , let's discuss today.

@rohitjoshixyz
Copy link
Contributor

@akhilgkrishnan Good catch: we could associate the employment_details table with the company_users table instead of the user model, which should address this concern @mohinid

@mohinid
Copy link
Contributor Author

mohinid commented Jun 13, 2022

Removed User reference and added reference of company_user with employment_detail. @akhilgkrishnan @rohitjoshixyz
All tests passed. Please review.

Screenshot 2022-06-13 at 3 14 13 PM

Copy link
Contributor

@rohitjoshixyz rohitjoshixyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @mohinid for making the requested changes

@akhilgkrishnan akhilgkrishnan merged commit 63068e8 into develop Jun 13, 2022
@akhilgkrishnan akhilgkrishnan deleted the add-employment-details-table branch June 13, 2022 11:16
vipulnsward pushed a commit that referenced this pull request Feb 15, 2026
* Creates EmploymentDetail model

* Update spec/models/employment_detail_spec.rb

Co-authored-by: Rohit Joshi <[email protected]>

* update validation and test for nil resigned_at date

* move employment_detail relation to line 62 in user.rb file

* update reference of company_user with employment_detail

Co-authored-by: Rohit Joshi <[email protected]>
Co-authored-by: Akhil G Krishnan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants