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

Skip to content

Creates devices table and associations#507

Merged
mohinid merged 7 commits intodevelopfrom
create-devices-table
Jun 22, 2022
Merged

Creates devices table and associations#507
mohinid merged 7 commits intodevelopfrom
create-devices-table

Conversation

@mohinid
Copy link
Contributor

@mohinid mohinid commented Jun 21, 2022

Notion card

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

Summary

  1. Created devices table.
  2. Added reference of User and Company with aliases issued_to and issued_by.
  3. Added Validations
  4. Added RSpecs
  5. Updated RSpecs for User and Company.

Preview

Employee Details Schema-updated

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

On Rails console as well as RSpecs Test run.

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

@github-actions
Copy link

Current Code Coverage Percent of this PR:

89.42 %

Files having coverage below 100%

Impacted Files Coverage
/lib/custom_failure.rb 80.0 %
/app/controllers/users/invitations_controller.rb 86.36 %
/app/controllers/users/sessions_controller.rb 85.71 %
/app/services/invoice_payment/pdf_generation.rb 70.97 %
/app/services/invoice_payment/checkout.rb 44.0 %
/app/controllers/internal_api/v1/payment_settings_controller.rb 93.33 %
/app/controllers/internal_api/v1/profile_controller.rb 96.88 %
/app/controllers/internal_api/v1/companies_controller.rb 95.45 %
/app/controllers/internal_api/v1/payments/providers_controller.rb 94.74 %
/app/controllers/internal_api/v1/wise/recipients_controller.rb 90.0 %
/lib/benchmarking/benchmarker.rb 0.0 %


# Validations
after_initialize :set_default_specifications, if: :new_record?
validates :model, length: { maximum: 100 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the model attribute be renamed to model_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, what's the reason?

Copy link
Contributor Author

@mohinid mohinid Jun 21, 2022

Choose a reason for hiding this comment

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

@keshavbiswa @rohitjoshixyz Renaming it as "Name"(Top level) as if I use model_name as column name, it gives this error.

Failure/Error: it { is_expected.to belong_to(:issued_by) }
ActiveRecord::DangerousAttributeError:
model_name is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Model attribute is confusing with rails models. We can rename it to device_model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, as I mentioned. I have renamed it as "Name". Please check files once.

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

@rohitjoshixyz
Copy link
Contributor

Oh okay so the name means the device's model. Sure I am fine with this 👍. PR is already approved from me✌🏻

@mohinid
Copy link
Contributor Author

mohinid commented Jun 22, 2022

Oh okay so the name means the device's model. Sure I am fine with this 👍. PR is already approved from me✌🏻

Yes. Thanks!

Copy link
Contributor

@keshavbiswa keshavbiswa left a comment

Choose a reason for hiding this comment

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

LGTM!

@mohinid mohinid merged commit 8a5f4a0 into develop Jun 22, 2022
@mohinid mohinid deleted the create-devices-table branch June 22, 2022 07:11
Comment on lines +31 to +36
it {
expect(subject).to define_enum_for(:device_type).with_values(
laptop: "laptop",
mobile: "mobile").backed_by_column_of_type(:string)
}
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Use do end instead of {} for multi line blocks.

vipulnsward pushed a commit that referenced this pull request Feb 15, 2026
* Creates devices table and associations

* remove unrelated changes from schema

* Capitalize comments

* Renaming column 'model' as 'name'

* removing unrelated changes from schema.rb

* Adds test for enum
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.

4 participants