unico-training 7.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (652) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +13 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE +22 -0
  7. data/README.md +35 -0
  8. data/Rakefile +43 -0
  9. data/app/business/material_code_generator.rb +43 -0
  10. data/app/business/similarity_control_adjuster.rb +2 -0
  11. data/app/business/similarity_control_checker.rb +2 -0
  12. data/app/business/unico/similarity_control_adjuster.rb +129 -0
  13. data/app/business/unico/similarity_control_checker.rb +96 -0
  14. data/app/controllers/agencies_controller.rb +2 -0
  15. data/app/controllers/bank_accounts_controller.rb +2 -0
  16. data/app/controllers/banks_controller.rb +2 -0
  17. data/app/controllers/creditors_controller.rb +2 -0
  18. data/app/controllers/document_types_controller.rb +2 -0
  19. data/app/controllers/material_classes_controller.rb +2 -0
  20. data/app/controllers/materials_controller.rb +2 -0
  21. data/app/controllers/reference_units_controller.rb +2 -0
  22. data/app/controllers/registration_cadastral_certificates_controller.rb +2 -0
  23. data/app/controllers/regularization_or_administrative_sanction_reasons_controller.rb +2 -0
  24. data/app/controllers/similarity_controls_controller.rb +2 -0
  25. data/app/controllers/unico/agencies_controller.rb +5 -0
  26. data/app/controllers/unico/bank_accounts_controller.rb +17 -0
  27. data/app/controllers/unico/banks_controller.rb +3 -0
  28. data/app/controllers/unico/creditors_controller.rb +3 -0
  29. data/app/controllers/unico/document_types_controller.rb +3 -0
  30. data/app/controllers/unico/material_classes_controller.rb +3 -0
  31. data/app/controllers/unico/materials_controller.rb +27 -0
  32. data/app/controllers/unico/reference_units_controller.rb +3 -0
  33. data/app/controllers/unico/registration_cadastral_certificates_controller.rb +30 -0
  34. data/app/controllers/unico/regularization_or_administrative_sanction_reasons_controller.rb +3 -0
  35. data/app/controllers/unico/similarity_controls_controller.rb +68 -0
  36. data/app/decorators/agency_decorator.rb +3 -0
  37. data/app/decorators/bank_account_decorator.rb +3 -0
  38. data/app/decorators/bank_decorator.rb +3 -0
  39. data/app/decorators/creditor_decorator.rb +11 -0
  40. data/app/decorators/document_type_decorator.rb +3 -0
  41. data/app/decorators/material_class_decorator.rb +52 -0
  42. data/app/decorators/reference_unit_decorator.rb +3 -0
  43. data/app/decorators/registration_cadastral_certificate_decorator.rb +6 -0
  44. data/app/decorators/regularization_or_administrative_sanction_reason_decorator.rb +3 -0
  45. data/app/decorators/similarity_control_decorator.rb +5 -0
  46. data/app/enumerations/account_type.rb +3 -0
  47. data/app/enumerations/bank_account_kind.rb +3 -0
  48. data/app/enumerations/cbo_type.rb +3 -0
  49. data/app/enumerations/condominium_type.rb +3 -0
  50. data/app/enumerations/customization_model.rb +10 -0
  51. data/app/enumerations/data_type.rb +3 -0
  52. data/app/enumerations/gender.rb +3 -0
  53. data/app/enumerations/habilitation_kind.rb +4 -0
  54. data/app/enumerations/issuer.rb +11 -0
  55. data/app/enumerations/job_status.rb +3 -0
  56. data/app/enumerations/legal_nature_level.rb +3 -0
  57. data/app/enumerations/marital_status.rb +3 -0
  58. data/app/enumerations/material_classification_type.rb +3 -0
  59. data/app/enumerations/nationality.rb +3 -0
  60. data/app/enumerations/organ_responsible.rb +3 -0
  61. data/app/enumerations/personable_type.rb +4 -0
  62. data/app/enumerations/regularization_or_administrative_sanction_reason_type.rb +3 -0
  63. data/app/enumerations/regularization_or_administrative_sanction_reason_type.yml +5 -0
  64. data/app/enumerations/regulatory_act_classification.rb +3 -0
  65. data/app/enumerations/regulatory_act_type.rb +9 -0
  66. data/app/enumerations/similarity_table.rb +23 -0
  67. data/app/enumerations/state_list.rb +5 -0
  68. data/app/enumerations/status.rb +3 -0
  69. data/app/enumerations/taxable_type.rb +7 -0
  70. data/app/models/address.rb +2 -0
  71. data/app/models/agency.rb +2 -0
  72. data/app/models/bank.rb +2 -0
  73. data/app/models/bank_account.rb +2 -0
  74. data/app/models/city.rb +2 -0
  75. data/app/models/cnae.rb +2 -0
  76. data/app/models/communication_source.rb +2 -0
  77. data/app/models/company.rb +2 -0
  78. data/app/models/company_size.rb +2 -0
  79. data/app/models/condominium.rb +2 -0
  80. data/app/models/country.rb +2 -0
  81. data/app/models/creditor.rb +2 -0
  82. data/app/models/creditor_balance.rb +2 -0
  83. data/app/models/creditor_bank_account.rb +2 -0
  84. data/app/models/creditor_document.rb +2 -0
  85. data/app/models/creditor_representative.rb +2 -0
  86. data/app/models/creditor_secondary_cnae.rb +2 -0
  87. data/app/models/currency.rb +2 -0
  88. data/app/models/customer.rb +2 -0
  89. data/app/models/customization.rb +54 -0
  90. data/app/models/customization_datum.rb +39 -0
  91. data/app/models/dissemination_source.rb +2 -0
  92. data/app/models/district.rb +2 -0
  93. data/app/models/document_type.rb +2 -0
  94. data/app/models/identity.rb +2 -0
  95. data/app/models/individual.rb +2 -0
  96. data/app/models/inscriptio_cursualis/address.rb +24 -0
  97. data/app/models/inscriptio_cursualis/city.rb +22 -0
  98. data/app/models/inscriptio_cursualis/condominium.rb +15 -0
  99. data/app/models/inscriptio_cursualis/country.rb +15 -0
  100. data/app/models/inscriptio_cursualis/district.rb +16 -0
  101. data/app/models/inscriptio_cursualis/land_subdivision.rb +12 -0
  102. data/app/models/inscriptio_cursualis/neighborhood.rb +33 -0
  103. data/app/models/inscriptio_cursualis/state.rb +20 -0
  104. data/app/models/inscriptio_cursualis/street.rb +38 -0
  105. data/app/models/inscriptio_cursualis/street_type.rb +18 -0
  106. data/app/models/land_subdivision.rb +2 -0
  107. data/app/models/legal_nature.rb +2 -0
  108. data/app/models/material.rb +2 -0
  109. data/app/models/material_class.rb +2 -0
  110. data/app/models/neighborhood.rb +2 -0
  111. data/app/models/occupation_base_group.rb +2 -0
  112. data/app/models/occupation_classification.rb +2 -0
  113. data/app/models/occupation_group.rb +2 -0
  114. data/app/models/occupation_main_group.rb +2 -0
  115. data/app/models/occupation_subgroup.rb +2 -0
  116. data/app/models/partner.rb +2 -0
  117. data/app/models/person.rb +2 -0
  118. data/app/models/persona/company.rb +71 -0
  119. data/app/models/persona/company_size.rb +12 -0
  120. data/app/models/persona/creditor.rb +102 -0
  121. data/app/models/persona/identity.rb +14 -0
  122. data/app/models/persona/individual.rb +40 -0
  123. data/app/models/persona/legal_nature.rb +21 -0
  124. data/app/models/persona/partner.rb +13 -0
  125. data/app/models/persona/person.rb +57 -0
  126. data/app/models/prefecture.rb +2 -0
  127. data/app/models/reference_unit.rb +2 -0
  128. data/app/models/registration_cadastral_certificate.rb +2 -0
  129. data/app/models/regularization_or_administrative_sanction.rb +2 -0
  130. data/app/models/regularization_or_administrative_sanction_reason.rb +2 -0
  131. data/app/models/regulatory_act.rb +2 -0
  132. data/app/models/risk_degree.rb +2 -0
  133. data/app/models/similarity_control.rb +2 -0
  134. data/app/models/similarity_control_item.rb +2 -0
  135. data/app/models/similarity_control_table.rb +2 -0
  136. data/app/models/state.rb +2 -0
  137. data/app/models/street.rb +2 -0
  138. data/app/models/street_type.rb +2 -0
  139. data/app/models/unico/agency.rb +25 -0
  140. data/app/models/unico/bank.rb +18 -0
  141. data/app/models/unico/bank_account.rb +31 -0
  142. data/app/models/unico/cnae.rb +19 -0
  143. data/app/models/unico/communication_source.rb +15 -0
  144. data/app/models/unico/creditor_balance.rb +8 -0
  145. data/app/models/unico/creditor_bank_account.rb +21 -0
  146. data/app/models/unico/creditor_document.rb +37 -0
  147. data/app/models/unico/creditor_representative.rb +19 -0
  148. data/app/models/unico/creditor_secondary_cnae.rb +6 -0
  149. data/app/models/unico/currency.rb +13 -0
  150. data/app/models/unico/customer.rb +25 -0
  151. data/app/models/unico/dissemination_source.rb +19 -0
  152. data/app/models/unico/document_type.rb +21 -0
  153. data/app/models/unico/material.rb +33 -0
  154. data/app/models/unico/material_class.rb +119 -0
  155. data/app/models/unico/occupation_base_group.rb +17 -0
  156. data/app/models/unico/occupation_classification.rb +22 -0
  157. data/app/models/unico/occupation_group.rb +16 -0
  158. data/app/models/unico/occupation_main_group.rb +17 -0
  159. data/app/models/unico/occupation_subgroup.rb +17 -0
  160. data/app/models/unico/prefecture.rb +31 -0
  161. data/app/models/unico/reference_unit.rb +18 -0
  162. data/app/models/unico/registration_cadastral_certificate.rb +55 -0
  163. data/app/models/unico/regularization_or_administrative_sanction.rb +16 -0
  164. data/app/models/unico/regularization_or_administrative_sanction_reason.rb +18 -0
  165. data/app/models/unico/regulatory_act.rb +27 -0
  166. data/app/models/unico/risk_degree.rb +12 -0
  167. data/app/models/unico/similarity_control.rb +59 -0
  168. data/app/models/unico/similarity_control_item.rb +41 -0
  169. data/app/models/unico/similarity_control_table.rb +8 -0
  170. data/app/uploaders/image_uploader.rb +13 -0
  171. data/app/uploaders/individual_image_uploader.rb +9 -0
  172. data/app/uploaders/prefecture_logo_uploader.rb +5 -0
  173. data/app/uploaders/unico_uploader.rb +5 -0
  174. data/app/uploaders/uploader.rb +13 -0
  175. data/app/validators/mail_validator.rb +7 -0
  176. data/app/validators/person_validator.rb +9 -0
  177. data/app/views/agencies/_data_attributes.html.jbuilder +6 -0
  178. data/app/views/agencies/_form.html.erb +26 -0
  179. data/app/views/bank_accounts/_data_attributes.html.jbuilder +3 -0
  180. data/app/views/bank_accounts/_form.html.erb +51 -0
  181. data/app/views/bank_accounts/_main.html.erb +35 -0
  182. data/app/views/bank_accounts/_show.html.erb +70 -0
  183. data/app/views/banks/_form.html.erb +13 -0
  184. data/app/views/cnaes/_data_attributes.html.jbuilder +4 -0
  185. data/app/views/cnaes/_list_form.html.erb +12 -0
  186. data/app/views/creditor_balances/_form.html.erb +55 -0
  187. data/app/views/creditor_bank_accounts/_form.html.erb +36 -0
  188. data/app/views/creditor_documents/_form.html.erb +32 -0
  189. data/app/views/creditor_representatives/_list_form.html.erb +12 -0
  190. data/app/views/creditors/_accounts.html.erb +15 -0
  191. data/app/views/creditors/_balance.html.erb +15 -0
  192. data/app/views/creditors/_cnaes.html.erb +36 -0
  193. data/app/views/creditors/_data_attributes.html.jbuilder +7 -0
  194. data/app/views/creditors/_documents.html.erb +26 -0
  195. data/app/views/creditors/_form.html.erb +151 -0
  196. data/app/views/creditors/_form_buttons.html.erb +14 -0
  197. data/app/views/creditors/_main.html.erb +68 -0
  198. data/app/views/creditors/_modal_form.html.erb +3 -0
  199. data/app/views/creditors/_regularization_or_administrative_sanctions.html.erb +26 -0
  200. data/app/views/creditors/_representatives.html.erb +37 -0
  201. data/app/views/creditors/_show.html.erb +105 -0
  202. data/app/views/creditors/index.json.jbuilder +11 -0
  203. data/app/views/document_types/_data_attributes.html.jbuilder +4 -0
  204. data/app/views/document_types/_form.html.erb +3 -0
  205. data/app/views/document_types/_list_form.html.erb +11 -0
  206. data/app/views/material_classes/_data_attributes.json.jbuilder +4 -0
  207. data/app/views/material_classes/_form.html.erb +59 -0
  208. data/app/views/material_classes/_form_buttons.html.erb +11 -0
  209. data/app/views/material_classes/_modal_form.html.erb +8 -0
  210. data/app/views/material_classes/index.json.jbuilder +9 -0
  211. data/app/views/materials/_data_attributes.html.jbuilder +5 -0
  212. data/app/views/materials/_form.html.erb +25 -0
  213. data/app/views/materials/_main.html.erb +34 -0
  214. data/app/views/materials/index.json.jbuilder +7 -0
  215. data/app/views/reference_units/_form.html.erb +9 -0
  216. data/app/views/registration_cadastral_certificates/_actions.html.erb +11 -0
  217. data/app/views/registration_cadastral_certificates/_form.html.erb +62 -0
  218. data/app/views/registration_cadastral_certificates/_form_buttons.html.erb +9 -0
  219. data/app/views/registration_cadastral_certificates/index.html.erb +9 -0
  220. data/app/views/regularization_or_administrative_sanction_reasons/_data_attributes.html.jbuilder +3 -0
  221. data/app/views/regularization_or_administrative_sanction_reasons/_form.html.erb +2 -0
  222. data/app/views/regularization_or_administrative_sanctions/_form.html.erb +28 -0
  223. data/app/views/similarity_controls/processing.html.erb +25 -0
  224. data/app/views/similarity_controls/show.json.jbuilder +3 -0
  225. data/app/workers/base_worker.rb +62 -0
  226. data/app/workers/similarity_control_worker.rb +2 -0
  227. data/app/workers/unico/similarity_control_worker.rb +19 -0
  228. data/build.sh +17 -0
  229. data/config/database.sample.yml +8 -0
  230. data/config/database.semaphore.yml +17 -0
  231. data/config/environment.rb +0 -0
  232. data/config/initializers/active_record_block.rb +3 -0
  233. data/config/initializers/active_record_filter.rb +3 -0
  234. data/config/initializers/active_record_modal.rb +3 -0
  235. data/config/locales/account_type.yml +5 -0
  236. data/config/locales/activerecord.yml +14 -0
  237. data/config/locales/agency.yml +17 -0
  238. data/config/locales/bank.yml +12 -0
  239. data/config/locales/bank_account.yml +20 -0
  240. data/config/locales/bank_account_kind.yml +8 -0
  241. data/config/locales/cbo_type.yml +5 -0
  242. data/config/locales/communication_source.yml +10 -0
  243. data/config/locales/controllers.yml +9 -0
  244. data/config/locales/creditor.yml +35 -0
  245. data/config/locales/creditor_balance.yml +18 -0
  246. data/config/locales/creditor_bank_account.yml +17 -0
  247. data/config/locales/creditor_document.yml +15 -0
  248. data/config/locales/creditor_representative.yml +11 -0
  249. data/config/locales/customization_model.yml +11 -0
  250. data/config/locales/dissemination_source.yml +11 -0
  251. data/config/locales/document_type.yml +12 -0
  252. data/config/locales/habilitation_kind.yml +6 -0
  253. data/config/locales/issuer.yml +32 -0
  254. data/config/locales/job_status.yml +6 -0
  255. data/config/locales/material.yml +21 -0
  256. data/config/locales/material_class.yml +17 -0
  257. data/config/locales/material_classification_type.yml +6 -0
  258. data/config/locales/organ_responsible.yml +6 -0
  259. data/config/locales/prefecture.yml +10 -0
  260. data/config/locales/reference_unit.yml +11 -0
  261. data/config/locales/registration_cadastral_certificate.yml +24 -0
  262. data/config/locales/regularization_or_administrative_sanction.yml +15 -0
  263. data/config/locales/regularization_or_administrative_sanction_reason.yml +11 -0
  264. data/config/locales/regulatory_act.yml +29 -0
  265. data/config/locales/regulatory_act_classification.yml +7 -0
  266. data/config/locales/regulatory_act_type.yml +10 -0
  267. data/config/locales/similarity_control.yml +19 -0
  268. data/config/locales/similarity_table.yml +8 -0
  269. data/config/locales/state_list.yml +30 -0
  270. data/config/locales/status.yml +5 -0
  271. data/config/locales/street.yml +19 -0
  272. data/db/functions/constraints/01_add_constraints.sql +49 -0
  273. data/db/migrate/20110116144640_add_unaccent_extension.rb +5 -0
  274. data/db/migrate/20110429235848_create_people.rb +13 -0
  275. data/db/migrate/20110530180855_create_countries.rb +10 -0
  276. data/db/migrate/20110531131347_create_states.rb +11 -0
  277. data/db/migrate/20110601163113_create_cities.rb +14 -0
  278. data/db/migrate/20110601172922_add_country_id_to_states.rb +6 -0
  279. data/db/migrate/20110601201806_create_districts.rb +10 -0
  280. data/db/migrate/20110602124204_create_street_types.rb +9 -0
  281. data/db/migrate/20110602135553_create_streets.rb +17 -0
  282. data/db/migrate/20110602175632_create_neighborhoods.rb +12 -0
  283. data/db/migrate/20110602184257_add_phone_to_people.rb +7 -0
  284. data/db/migrate/20110602184907_add_email_to_people.rb +5 -0
  285. data/db/migrate/20110602185306_add_code_to_people.rb +5 -0
  286. data/db/migrate/20110602190207_create_person_identities.rb +16 -0
  287. data/db/migrate/20110602201455_create_land_subdivisions.rb +15 -0
  288. data/db/migrate/20110603131109_create_condominium_types.rb +9 -0
  289. data/db/migrate/20110603141048_create_condominiums.rb +29 -0
  290. data/db/migrate/20110603163203_remove_number_from_condominium.rb +9 -0
  291. data/db/migrate/20110606163747_remove_code_from_people.rb +5 -0
  292. data/db/migrate/20110606165434_remove_neighborhood_id_from_condominiums.rb +6 -0
  293. data/db/migrate/20110606170743_remove_code_from_countries.rb +5 -0
  294. data/db/migrate/20110606172221_remove_code_from_states.rb +5 -0
  295. data/db/migrate/20110606172748_remove_code_from_cities.rb +5 -0
  296. data/db/migrate/20110606174103_remove_code_from_districts.rb +5 -0
  297. data/db/migrate/20110607135059_create_currencies.rb +10 -0
  298. data/db/migrate/20110616191453_create_genders.rb +9 -0
  299. data/db/migrate/20110616192113_remove_gender_from_people.rb +5 -0
  300. data/db/migrate/20110616192206_add_gender_id_to_people.rb +6 -0
  301. data/db/migrate/20110621195226_create_address_types.rb +9 -0
  302. data/db/migrate/20110622170457_create_company_sizes.rb +11 -0
  303. data/db/migrate/20110622205700_create_addresses.rb +27 -0
  304. data/db/migrate/20110627190518_create_legal_natures.rb +10 -0
  305. data/db/migrate/20110627204600_add_ancestry_to_legal_natures.rb +6 -0
  306. data/db/migrate/20110629204622_create_companies.rb +24 -0
  307. data/db/migrate/20110629221035_create_contributors.rb +12 -0
  308. data/db/migrate/20110629224915_add_name_to_companies.rb +5 -0
  309. data/db/migrate/20110704052310_add_cpf_to_people.rb +5 -0
  310. data/db/migrate/20110706140744_add_cep_to_addresses.rb +5 -0
  311. data/db/migrate/20110712135510_create_prefectures.rb +27 -0
  312. data/db/migrate/20110722183838_create_address_tickets.rb +10 -0
  313. data/db/migrate/20110811202352_add_number_to_addresses.rb +5 -0
  314. data/db/migrate/20110811202544_add_zip_code_to_addresses.rb +5 -0
  315. data/db/migrate/20110811202804_add_block_to_addresses.rb +5 -0
  316. data/db/migrate/20110811202940_add_room_to_addresses.rb +5 -0
  317. data/db/migrate/20110811203043_remove_cep_from_addresses.rb +9 -0
  318. data/db/migrate/20110811204502_remove_zip_code_from_streets.rb +9 -0
  319. data/db/migrate/20110815164912_rename_table_people_to_individuals.rb +9 -0
  320. data/db/migrate/20110815165559_rename_table_contributors_to_people.rb +9 -0
  321. data/db/migrate/20110815171945_rename_table_person_identities_to_individual_identities.rb +9 -0
  322. data/db/migrate/20110815182338_rename_column_person_id_in_identity_to_individual_id.rb +9 -0
  323. data/db/migrate/20110815193318_remove_street_id_from_prefectures.rb +11 -0
  324. data/db/migrate/20110815193801_remove_neighborhood_id_from_prefectures.rb +11 -0
  325. data/db/migrate/20110815194308_remove_number_from_prefectures.rb +9 -0
  326. data/db/migrate/20110815194430_remove_zip_code_from_prefectures.rb +9 -0
  327. data/db/migrate/20110815194457_remove_complement_from_prefectures.rb +9 -0
  328. data/db/migrate/20110816024105_add_company_size_as_fk_to_companies.rb +5 -0
  329. data/db/migrate/20110816024522_add_legal_nature_as_fk_to_companies.rb +5 -0
  330. data/db/migrate/20110816030813_add_person_id_as_fk_to_companies.rb +5 -0
  331. data/db/migrate/20110816195312_create_partners.rb +18 -0
  332. data/db/migrate/20110817140815_create_customers.rb +13 -0
  333. data/db/migrate/20110817210250_add_correspondence_to_addresses.rb +5 -0
  334. data/db/migrate/20110901172241_remove_street_id_from_condominium.rb +5 -0
  335. data/db/migrate/20110902133329_alter_column_digit_to_code_on_cities.rb +5 -0
  336. data/db/migrate/20110903171330_add_neighborhood_id_to_prefectures.rb +6 -0
  337. data/db/migrate/20110905113916_add_column_default_to_countries.rb +5 -0
  338. data/db/migrate/20110905121020_add_column_default_to_cities.rb +5 -0
  339. data/db/migrate/20110905122437_remove_neighborhood_id_from_prefectures_again.rb +11 -0
  340. data/db/migrate/20110905162912_add_column_default_to_districts.rb +5 -0
  341. data/db/migrate/20110905172053_add_column_default_to_states.rb +5 -0
  342. data/db/migrate/20110905192053_remove_city_id_from_street.rb +11 -0
  343. data/db/migrate/20110905192751_add_acronym_to_street_types.rb +5 -0
  344. data/db/migrate/20110906120319_add_gender_id_to_people_again.rb +5 -0
  345. data/db/migrate/20110908133532_add_address_type_id_to_addresses.rb +7 -0
  346. data/db/migrate/20110908175305_create_neighborhoods_streets.rb +13 -0
  347. data/db/migrate/20110909194606_remove_name_from_individuals_and_companies.rb +11 -0
  348. data/db/migrate/20110912153839_remove_contact_fields_from_individuals.rb +15 -0
  349. data/db/migrate/20110912160521_remove_contact_fields_from_companies.rb +15 -0
  350. data/db/migrate/20110912173117_add_contact_columns_to_people.rb +8 -0
  351. data/db/migrate/20110914221204_add_latitude_and_longitude_to_address.rb +6 -0
  352. data/db/migrate/20110919142728_add_default_to_correspondence_in_addresses.rb +9 -0
  353. data/db/migrate/20110922143914_remove_gender_id_from_people.rb +11 -0
  354. data/db/migrate/20110922175818_rename_individual_identities_to_identities.rb +5 -0
  355. data/db/migrate/20110929113404_add_code_to_states.rb +5 -0
  356. data/db/migrate/20111005135305_remove_ancestry_from_legal_natures.rb +9 -0
  357. data/db/migrate/20111005135734_add_awesome_nested_set_columns_to_legal_natures.rb +10 -0
  358. data/db/migrate/20111013002056_remove_gender_id_from_individuals.rb +6 -0
  359. data/db/migrate/20111013002322_drop_table_genders.rb +5 -0
  360. data/db/migrate/20111013011843_add_gender_to_individuals.rb +5 -0
  361. data/db/migrate/20111013033830_remove_default_from_countries.rb +5 -0
  362. data/db/migrate/20111013034546_remove_default_from_states.rb +5 -0
  363. data/db/migrate/20111013034922_remove_default_from_cities.rb +5 -0
  364. data/db/migrate/20111014190458_change_choose_simple_default_on_companies.rb +9 -0
  365. data/db/migrate/20111017063746_use_composited_index_for_addressable_on_addresses.rb +13 -0
  366. data/db/migrate/20111017065519_add_index_on_individual_id_on_identities.rb +5 -0
  367. data/db/migrate/20111017065533_add_index_on_state_id_on_identities.rb +5 -0
  368. data/db/migrate/20111017070508_use_composited_index_on_personable_on_people.rb +15 -0
  369. data/db/migrate/20111017071127_add_index_on_country_id_on_states.rb +5 -0
  370. data/db/migrate/20111018124812_remove_coordinates_from_addresses.rb +5 -0
  371. data/db/migrate/20111030170019_remove_default_flag_from_districts.rb +5 -0
  372. data/db/migrate/20111104192714_remove_column_prefectures_city_id.rb +5 -0
  373. data/db/migrate/20111105040503_remove_column_prefectures_acronym.rb +5 -0
  374. data/db/migrate/20111107162734_add_precision_to_condominiums_built_area.rb +5 -0
  375. data/db/migrate/20111107162816_add_precision_to_condominiums_area_common_user.rb +5 -0
  376. data/db/migrate/20111114165749_add_image_to_prefectures.rb +5 -0
  377. data/db/migrate/20111124121605_remove_column_addresses_address_type_id.rb +5 -0
  378. data/db/migrate/20111124121622_drop_table_address_types.rb +5 -0
  379. data/db/migrate/20111213130749_remove_column_states_code.rb +5 -0
  380. data/db/migrate/20111226113722_add_city_id_to_districts.rb +6 -0
  381. data/db/migrate/20111226122849_drop_table_address_tickets.rb +5 -0
  382. data/db/migrate/20111226124756_remove_neighboord_id_from_land_subdivisions.rb +5 -0
  383. data/db/migrate/20111226124852_remove_district_id_from_land_subdivisions.rb +5 -0
  384. data/db/migrate/20120124181637_add_level_to_legal_natures.rb +5 -0
  385. data/db/migrate/20120127104149_readd_code_to_states.rb +5 -0
  386. data/db/migrate/20120314224041_drop_table_condominium_types_and_associations.rb +8 -0
  387. data/db/migrate/20120314225506_add_condominium_type_to_condominiums.rb +5 -0
  388. data/db/migrate/20120315161607_remove_columns_to_condominiums.rb +13 -0
  389. data/db/migrate/20120315174647_remove_condominium_id_to_adressess.rb +9 -0
  390. data/db/migrate/20120315200108_add_condominium_id_to_addresses.rb +5 -0
  391. data/db/migrate/20120316124724_add_district_id_to_neighborhoods.rb +7 -0
  392. data/db/migrate/20120316171434_remove_district_id_to_addresses.rb +7 -0
  393. data/db/migrate/20120316174453_add_index_and_foreign_key_to_addresses.rb +6 -0
  394. data/db/migrate/20120321222453_move_partners_of_economic_registrations_to_company.rb +14 -0
  395. data/db/migrate/20120521141003_create_unico_countries.rb +5 -0
  396. data/db/migrate/20120521141007_create_unico_states.rb +5 -0
  397. data/db/migrate/20120521141013_create_unico_cities.rb +5 -0
  398. data/db/migrate/20120521141021_create_unico_districts.rb +5 -0
  399. data/db/migrate/20120521141103_create_unico_neighborhoods.rb +5 -0
  400. data/db/migrate/20120521191721_rename_neighborhoods_streets_to_streets_unico_neighborhoods.rb +5 -0
  401. data/db/migrate/20120530152810_rename_streets_to_unico_streets.rb +5 -0
  402. data/db/migrate/20120530152952_rename_streets_unico_neighborhoods_to_unico_neighborhoods_unico_streets.rb +5 -0
  403. data/db/migrate/20120530153640_rename_street_types_to_unico_street_types.rb +5 -0
  404. data/db/migrate/20120530162433_rename_land_subdivisions_to_unico_land_subdivisions.rb +5 -0
  405. data/db/migrate/20120530180410_rename_condominiums_to_unico_condominiums.rb +5 -0
  406. data/db/migrate/20120531114233_rename_unico_condominiums_to_unico_condominia.rb +5 -0
  407. data/db/migrate/20120531165934_rename_addresses_to_unico_addresses.rb +5 -0
  408. data/db/migrate/20120605101823_rename_company_sizes_to_unico_company_sizes.rb +5 -0
  409. data/db/migrate/20120605103033_rename_legal_natures_to_unico_legal_natures.rb +5 -0
  410. data/db/migrate/20120605202644_rename_people_to_unico_people.rb +5 -0
  411. data/db/migrate/20120605213011_rename_companies_to_unico_companies.rb +5 -0
  412. data/db/migrate/20120605213109_rename_identities_to_unico_identities.rb +5 -0
  413. data/db/migrate/20120605213241_rename_partners_to_unico_partners.rb +5 -0
  414. data/db/migrate/20120605215523_rename_individuals_to_unico_individuals.rb +5 -0
  415. data/db/migrate/20120614175605_rename_customers_to_unico_customers.rb +5 -0
  416. data/db/migrate/20120614183133_rename_prefectures_to_unico_prefectures.rb +5 -0
  417. data/db/migrate/20120620130440_add_benefited_to_company_sizes.rb +5 -0
  418. data/db/migrate/20120620164340_remove_benefited_from_company_sizes.rb +5 -0
  419. data/db/migrate/20120714152059_rename_currencies_to_unico_currencies.rb +5 -0
  420. data/db/migrate/20120723134307_migrate_address_to_person.rb +7 -0
  421. data/db/migrate/20120904235430_add_precision_to_unico_currencies.rb +5 -0
  422. data/db/migrate/20121019142850_create_unico_risk_degrees.rb +13 -0
  423. data/db/migrate/20121019151228_create_unico_cnaes.rb +18 -0
  424. data/db/migrate/20121025165054_add_city_id_to_unico_streets.rb +13 -0
  425. data/db/migrate/20121026125540_add_syndicated_affiliated_to_unico_companies.rb +5 -0
  426. data/db/migrate/20121108231044_add_marital_status_to_individual.rb +5 -0
  427. data/db/migrate/20121108231957_add_place_of_birth_to_individual.rb +9 -0
  428. data/db/migrate/20121113155708_add_trade_name_to_unico_companies.rb +5 -0
  429. data/db/migrate/20130204185551_add_code_to_unico_countries.rb +5 -0
  430. data/db/migrate/20130204185635_add_code_to_unico_street_types.rb +5 -0
  431. data/db/migrate/20130218100005_create_unico_occupation_classifications.rb +16 -0
  432. data/db/migrate/20130218191619_add_original_id_and_original_system_to_unico_people.rb +6 -0
  433. data/db/migrate/20130307185439_add_tce_mg_code_to_cities.rb +5 -0
  434. data/db/migrate/20130410130902_add_gist_index_to_unico_people.rb +18 -0
  435. data/db/migrate/20130410235225_add_gist_index_to_unico_occupation_classifications.rb +14 -0
  436. data/db/migrate/20130411162741_add_image_to_individual.rb +5 -0
  437. data/db/migrate/20130415204954_add_nationality_and_country_of_birth_id_to_unico_individuals.rb +8 -0
  438. data/db/migrate/20130415220244_add_index_on_country_of_birth_id_on_individuals.rb +5 -0
  439. data/db/migrate/20130418122109_add_secret_token_to_unico_customers.rb +10 -0
  440. data/db/migrate/20130425134706_add_column_inactive_to_addresses.rb +5 -0
  441. data/db/migrate/20130425134838_add_column_inactive_to_people.rb +5 -0
  442. data/db/migrate/20130425174621_add_column_inactive_to_streets.rb +5 -0
  443. data/db/migrate/20130517140021_add_column_uf_to_companies.rb +5 -0
  444. data/db/migrate/20130702112232_create_unico_regulatory_acts.rb +30 -0
  445. data/db/migrate/20130702144123_create_unico_communication_sources.rb +8 -0
  446. data/db/migrate/20130702151131_create_unico_dissemination_sources.rb +14 -0
  447. data/db/migrate/20130702152037_create_unico_dissemination_sources_unico_regulatory_acts.rb +18 -0
  448. data/db/migrate/20130703134328_create_unico_creditors.rb +25 -0
  449. data/db/migrate/20130705110811_create_unico_creditor_secondary_cnaes.rb +16 -0
  450. data/db/migrate/20130705134815_create_unico_creditor_representatives.rb +17 -0
  451. data/db/migrate/20130705143512_create_unico_creditor_balances.rb +21 -0
  452. data/db/migrate/20130705155916_create_unico_document_types.rb +11 -0
  453. data/db/migrate/20130705163831_create_unico_creditor_documents.rb +21 -0
  454. data/db/migrate/20130708140521_create_unico_banks.rb +10 -0
  455. data/db/migrate/20130708141313_create_unico_agencies.rb +18 -0
  456. data/db/migrate/20130708142321_create_unico_bank_accounts.rb +17 -0
  457. data/db/migrate/20130708150305_create_unico_creditor_bank_accounts.rb +22 -0
  458. data/db/migrate/20130708163542_create_unico_regularization_or_administrative_sanction_reasons.rb +9 -0
  459. data/db/migrate/20130708170709_create_unico_regularization_or_administrative_sanctions.rb +22 -0
  460. data/db/migrate/20130708180241_create_unico_registration_cadastral_certificates.rb +27 -0
  461. data/db/migrate/20130709175321_add_organ_responsible_for_registration_to_unico_creditors.rb +5 -0
  462. data/db/migrate/20130716143951_setup_unico_hstore.rb +9 -0
  463. data/db/migrate/20130716144626_add_custom_data_to_unico_creditor.rb +5 -0
  464. data/db/migrate/20130724132535_add_application_kind_closing_date_and_capability_kind_to_creditors.rb +7 -0
  465. data/db/migrate/20130725162650_add_state_acronym_to_prefecture.rb +6 -0
  466. data/db/migrate/20130731153025_create_missing_secret_token_for_customer.rb +9 -0
  467. data/db/migrate/20130911135646_change_rerulatory_act_type_on_regulatory_acts.rb +5 -0
  468. data/db/migrate/20131001170551_create_versions.rb +18 -0
  469. data/db/migrate/20131002191733_add_domain_to_prefecture.rb +5 -0
  470. data/db/migrate/20131023160005_add_time_zone_to_prefectures.rb +5 -0
  471. data/db/migrate/20140508085731_add_object_changes_to_versions.rb +5 -0
  472. data/db/migrate/20140515191425_add_disabled_to_customers.rb +5 -0
  473. data/db/migrate/20140730124639_create_unico_reference_units.rb +9 -0
  474. data/db/migrate/20140806124608_create_table_unico_material_classes.rb +16 -0
  475. data/db/migrate/20140806124639_change_acronym_from_unico_reference_units.rb +5 -0
  476. data/db/migrate/20140929200836_add_cpf_cnpj_to_people.rb +6 -0
  477. data/db/migrate/20140930083205_add_normalized_name_to_people.rb +5 -0
  478. data/db/migrate/20140930133849_migrate_data_of_people.rb +7 -0
  479. data/db/migrate/20140930165938_add_index_to_normalized_name_on_people.rb +5 -0
  480. data/db/migrate/20150716114056_add_inactive_to_address_tables.rb +7 -0
  481. data/db/migrate/20160520184356_create_unico_materials.rb +24 -0
  482. data/db/migrate/20161201184437_create_unico_similarity_controls.rb +15 -0
  483. data/db/migrate/20161201194536_create_unico_similarity_control_items.rb +18 -0
  484. data/db/migrate/20161202111046_create_unico_similarity_control_tables.rb +13 -0
  485. data/db/migrate/20161209113445_add_job_status_to_unico_similarity_controls.rb +7 -0
  486. data/db/migrate/20170404170636_add_cnh_to_unico_individuals.rb +6 -0
  487. data/db/migrate/20170503094509_change_mobile_limit_on_people.rb +5 -0
  488. data/db/migrate/20170724135645_add_active_column_to_unico_occupation_classifications.rb +5 -0
  489. data/db/migrate/20170726135645_create_occupation_groups.rb +10 -0
  490. data/db/migrate/20170726135646_create_occupation_main_groups.rb +15 -0
  491. data/db/migrate/20170726135647_create_occupation_subgroups.rb +15 -0
  492. data/db/migrate/20170727135648_create_occupation_base_groups.rb +15 -0
  493. data/db/migrate/20170727174947_add_occupation_base_group_to_occupation_classifications.rb +6 -0
  494. data/db/migrate/20170728135645_add_type_to_unico_occupation_classifications.rb +5 -0
  495. data/db/migrate/20170728135646_drop_constraint_on_unico_occupation_classifications.rb +5 -0
  496. data/db/migrate/20170728135647_remove_lft_rgt_from_occupation_classifications.rb +13 -0
  497. data/lib/active_record/block.rb +44 -0
  498. data/lib/active_record/filter.rb +63 -0
  499. data/lib/active_record/filters/base.rb +38 -0
  500. data/lib/active_record/filters/filter.rb +65 -0
  501. data/lib/active_record/modal.rb +42 -0
  502. data/lib/belongs_to_resource.rb +111 -0
  503. data/lib/custom_data.rb +131 -0
  504. data/lib/custom_data_query.rb +15 -0
  505. data/lib/custom_postgres_copy.rb +9 -0
  506. data/lib/extensions.rb +5 -0
  507. data/lib/import/files/cities.csv +5571 -0
  508. data/lib/import/files/cnaes.csv +2385 -0
  509. data/lib/import/files/company_sizes.csv +6 -0
  510. data/lib/import/files/countries.csv +329 -0
  511. data/lib/import/files/legal_natures.csv +72 -0
  512. data/lib/import/files/material_classes.csv +215 -0
  513. data/lib/import/files/occupation_base_groups.csv +618 -0
  514. data/lib/import/files/occupation_classifications.csv +10184 -0
  515. data/lib/import/files/occupation_groups.csv +11 -0
  516. data/lib/import/files/occupation_main_groups.csv +50 -0
  517. data/lib/import/files/occupation_subgroups.csv +196 -0
  518. data/lib/import/files/states.csv +28 -0
  519. data/lib/import/files/street_types.csv +130 -0
  520. data/lib/import/files/updated_street_types.csv +291 -0
  521. data/lib/importer_helper.rb +32 -0
  522. data/lib/inscriptio_cursualis.rb +3 -0
  523. data/lib/inscriptio_cursualis/model.rb +8 -0
  524. data/lib/persona.rb +3 -0
  525. data/lib/persona/model.rb +8 -0
  526. data/lib/simple_decorator.rb +7 -0
  527. data/lib/simple_decorator/base.rb +11 -0
  528. data/lib/simple_decorator/common_decorated.rb +78 -0
  529. data/lib/simple_decorator/header.rb +43 -0
  530. data/lib/simple_decorator/plug.rb +23 -0
  531. data/lib/simple_decorator/rails_helpers.rb +16 -0
  532. data/lib/street_type_updater.rb +60 -0
  533. data/lib/tasks/importers/address.rake +56 -0
  534. data/lib/tasks/importers/inscriptio_cursualis_all.rake +45 -0
  535. data/lib/tasks/importers/persona.rake +29 -0
  536. data/lib/tasks/importers/unico_all.rake +69 -0
  537. data/lib/tasks/updaters/city/tce_mg_code.rake +22 -0
  538. data/lib/tasks/updaters/street_type.rake +15 -0
  539. data/lib/time_zone.rb +15 -0
  540. data/lib/unico.rb +13 -0
  541. data/lib/unico/engine.rb +16 -0
  542. data/lib/unico/model.rb +8 -0
  543. data/lib/unico/version.rb +5 -0
  544. data/spec/business/similarity_control_adjuster_spec.rb +54 -0
  545. data/spec/business/similarity_control_checker_spec.rb +146 -0
  546. data/spec/fixtures/integraLogo.png +0 -0
  547. data/spec/lib/active_record/modal_spec.rb +27 -0
  548. data/spec/lib/persona/model_spec.rb +15 -0
  549. data/spec/lib/simple_decorator/base_spec.rb +49 -0
  550. data/spec/lib/simple_decorator/common_decorated_spec.rb +147 -0
  551. data/spec/lib/simple_decorator/header_spec.rb +164 -0
  552. data/spec/lib/simple_decorator/plug_spec.rb +64 -0
  553. data/spec/lib/street_type_updater_spec.rb +37 -0
  554. data/spec/lib/unico/model_spec.rb +15 -0
  555. data/spec/locale_helper.rb +37 -0
  556. data/spec/models/address_spec.rb +125 -0
  557. data/spec/models/agency_spec.rb +26 -0
  558. data/spec/models/bank_account_spec.rb +37 -0
  559. data/spec/models/bank_spec.rb +27 -0
  560. data/spec/models/city_spec.rb +20 -0
  561. data/spec/models/cnae_spec.rb +16 -0
  562. data/spec/models/communication_source_spec.rb +17 -0
  563. data/spec/models/company_size_spec.rb +17 -0
  564. data/spec/models/company_spec.rb +82 -0
  565. data/spec/models/condominium_spec.rb +14 -0
  566. data/spec/models/country_spec.rb +15 -0
  567. data/spec/models/creditor_balance_spec.rb +10 -0
  568. data/spec/models/creditor_bank_account_spec.rb +20 -0
  569. data/spec/models/creditor_document_spec.rb +60 -0
  570. data/spec/models/creditor_representative_spec.rb +8 -0
  571. data/spec/models/creditor_secondary_cnae_spec.rb +8 -0
  572. data/spec/models/creditor_spec.rb +38 -0
  573. data/spec/models/currency_spec.rb +28 -0
  574. data/spec/models/customer_spec.rb +26 -0
  575. data/spec/models/dissemination_source_spec.rb +28 -0
  576. data/spec/models/district_spec.rb +18 -0
  577. data/spec/models/document_type_spec.rb +11 -0
  578. data/spec/models/identity_spec.rb +20 -0
  579. data/spec/models/individual_spec.rb +60 -0
  580. data/spec/models/inscriptio_cursualis/address_spec.rb +7 -0
  581. data/spec/models/inscriptio_cursualis/city_spec.rb +7 -0
  582. data/spec/models/inscriptio_cursualis/condominium_spec.rb +7 -0
  583. data/spec/models/inscriptio_cursualis/country_spec.rb +7 -0
  584. data/spec/models/inscriptio_cursualis/district_spec.rb +7 -0
  585. data/spec/models/inscriptio_cursualis/land_subdivision_spec.rb +7 -0
  586. data/spec/models/inscriptio_cursualis/neighborhood_spec.rb +7 -0
  587. data/spec/models/inscriptio_cursualis/state_spec.rb +7 -0
  588. data/spec/models/inscriptio_cursualis/street_spec.rb +7 -0
  589. data/spec/models/inscriptio_cursualis/street_type_spec.rb +7 -0
  590. data/spec/models/land_subdivision_spec.rb +13 -0
  591. data/spec/models/legal_nature_spec.rb +14 -0
  592. data/spec/models/material_class_spec.rb +147 -0
  593. data/spec/models/material_spec.rb +25 -0
  594. data/spec/models/neighborhood_spec.rb +73 -0
  595. data/spec/models/occupation_base_group_spec.rb +18 -0
  596. data/spec/models/occupation_classification_spec.rb +17 -0
  597. data/spec/models/occupation_group_spec.rb +17 -0
  598. data/spec/models/occupation_main_group_spec.rb +18 -0
  599. data/spec/models/occupation_subgroup_spec.rb +18 -0
  600. data/spec/models/partner_spec.rb +24 -0
  601. data/spec/models/person_spec.rb +129 -0
  602. data/spec/models/persona/company_size_spec.rb +7 -0
  603. data/spec/models/persona/company_spec.rb +7 -0
  604. data/spec/models/persona/creditor_spec.rb +7 -0
  605. data/spec/models/persona/identity_spec.rb +7 -0
  606. data/spec/models/persona/individual_spec.rb +7 -0
  607. data/spec/models/persona/legal_nature_spec.rb +7 -0
  608. data/spec/models/persona/partner_spec.rb +7 -0
  609. data/spec/models/persona/person_spec.rb +7 -0
  610. data/spec/models/prefecture_spec.rb +48 -0
  611. data/spec/models/reference_unit_spec.rb +15 -0
  612. data/spec/models/registration_cadastral_certificate_spec.rb +77 -0
  613. data/spec/models/regularization_or_administrative_sanction_reason_spec.rb +14 -0
  614. data/spec/models/regularization_or_administrative_sanction_spec.rb +21 -0
  615. data/spec/models/regulatory_act_spec.rb +23 -0
  616. data/spec/models/risk_degree_spec.rb +16 -0
  617. data/spec/models/similarity_control_item_spec.rb +12 -0
  618. data/spec/models/similarity_control_spec.rb +30 -0
  619. data/spec/models/similarity_control_table_spec.rb +10 -0
  620. data/spec/models/state_spec.rb +18 -0
  621. data/spec/models/street_spec.rb +55 -0
  622. data/spec/models/street_type_spec.rb +16 -0
  623. data/spec/models/unico/agency_spec.rb +7 -0
  624. data/spec/models/unico/bank_account_spec.rb +7 -0
  625. data/spec/models/unico/bank_spec.rb +7 -0
  626. data/spec/models/unico/communication_source_spec.rb +7 -0
  627. data/spec/models/unico/creditor_balance_spec.rb +7 -0
  628. data/spec/models/unico/creditor_bank_account_spec.rb +7 -0
  629. data/spec/models/unico/creditor_document_spec.rb +7 -0
  630. data/spec/models/unico/creditor_representative_spec.rb +7 -0
  631. data/spec/models/unico/creditor_secondary_cnae_spec.rb +7 -0
  632. data/spec/models/unico/currency_spec.rb +7 -0
  633. data/spec/models/unico/customer_spec.rb +7 -0
  634. data/spec/models/unico/dissemination_source_spec.rb +7 -0
  635. data/spec/models/unico/document_type_spec.rb +7 -0
  636. data/spec/models/unico/material_class_spec.rb +7 -0
  637. data/spec/models/unico/material_spec.rb +7 -0
  638. data/spec/models/unico/prefecture_spec.rb +7 -0
  639. data/spec/models/unico/reference_unit_spec.rb +7 -0
  640. data/spec/models/unico/registration_cadastral_certificate_spec.rb +7 -0
  641. data/spec/models/unico/regularization_or_administrative_sanction_reason_spec.rb +7 -0
  642. data/spec/models/unico/regularization_or_administrative_sanction_spec.rb +7 -0
  643. data/spec/models/unico/regulatory_act_spec.rb +7 -0
  644. data/spec/models/unico/similarity_control_item_spec.rb +7 -0
  645. data/spec/models/unico/similarity_control_spec.rb +7 -0
  646. data/spec/models/unico/similarity_control_table_spec.rb +7 -0
  647. data/spec/spec_helper.rb +79 -0
  648. data/spec/uploaders/image_uploader_spec.rb +39 -0
  649. data/spec/uploaders/prefecture_logo_uploader_spec.rb +5 -0
  650. data/spec/validators/person_validator_spec.rb +56 -0
  651. data/unico.gemspec +40 -0
  652. metadata +979 -0
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+
3
+ describe MaterialClass do
4
+ it { is_expected.to be_kind_of Unico::MaterialClass }
5
+
6
+ it { is_expected.to validate_presence_of(:masked_number) }
7
+ it { is_expected.to validate_presence_of(:description) }
8
+
9
+ it { is_expected.to validate_numericality_of(:number) }
10
+ it { is_expected.to validate_numericality_of(:class_number) }
11
+
12
+ it 'returns class_number and description as to_s method' do
13
+ subject.masked_number = '30.52.10.000.000'
14
+ subject.description = 'Hortifrutigranjeiros'
15
+
16
+ expect(subject.to_s).to eq '30.52.10.000.000 - Hortifrutigranjeiros'
17
+ end
18
+
19
+ describe 'create the masked number on validate' do
20
+ context 'when have parent_number and number' do
21
+ it 'makes mask_number using full_number and mask_size' do
22
+ subject.masked_number = '1.11.111.000'
23
+ subject.parent_number = '1.23'
24
+ subject.number = '456'
25
+ subject.mask = '9.99.999.000'
26
+ subject.valid?
27
+
28
+ expect(subject.masked_number).to eq '1.23.456.000'
29
+ end
30
+ end
31
+
32
+ context 'without parent_number' do
33
+ it 'uses mask_number value' do
34
+ subject.masked_number = '1.11.111.000'
35
+ subject.number = '456'
36
+ subject.mask = '9.99.999.000'
37
+ subject.valid?
38
+
39
+ expect(subject.masked_number).to eq '1.11.111.000'
40
+ end
41
+ end
42
+
43
+ context 'when is a first level class' do
44
+ it 'has only the number' do
45
+ subject.parent_number = ''
46
+ subject.number = '10'
47
+ subject.mask = '99.99.99.999.999'
48
+ subject.valid?
49
+
50
+ expect(subject.masked_number).to eq '10.00.00.000.000'
51
+ end
52
+ end
53
+
54
+ context 'without number' do
55
+ it 'uses class_number value' do
56
+ subject.masked_number = '1.11.111.000'
57
+ subject.parent_number = '1.23'
58
+ subject.mask = '9.99.999.000'
59
+ subject.valid?
60
+
61
+ expect(subject.masked_number).to eq '1.11.111.000'
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'fill class_number before validate' do
67
+ it 'fills the class_number removing dots from masked_number' do
68
+ subject.mask = '9.99.999.000'
69
+ subject.masked_number = '1.23.560.000'
70
+
71
+ subject.valid?
72
+
73
+ expect(subject.class_number).to eq '123560000'
74
+ end
75
+
76
+ it 'returns error when has not a number' do
77
+ subject.mask = '9.99.999.000'
78
+ subject.masked_number = '00'
79
+
80
+ subject.valid?
81
+
82
+ expect(subject.errors[:class_number]).to include 'must be greater than 0'
83
+ end
84
+ end
85
+
86
+ describe '#levels' do
87
+ it 'returns 1 when the mask has no dot' do
88
+ subject.mask = '999'
89
+
90
+ expect(subject.levels).to eq 1
91
+ end
92
+
93
+ it 'returns 2 when the mask has one dot' do
94
+ subject.mask = '99.999'
95
+
96
+ expect(subject.levels).to eq 2
97
+ end
98
+
99
+ it 'returns 3 when the mask has 2 dots' do
100
+ subject.mask = '99.999.9'
101
+
102
+ expect(subject.levels).to eq 3
103
+ end
104
+ end
105
+
106
+ describe '#class_number_level' do
107
+ before do
108
+ allow(subject).to receive_messages(mask: '99.99.999')
109
+ end
110
+
111
+ it 'returns 1 when the only filled level is the first' do
112
+ subject.masked_number = '10.00.000'
113
+
114
+ expect(subject.class_number_level).to eq 1
115
+ end
116
+
117
+ it 'returns 2 when filled until second level' do
118
+ subject.masked_number = '10.53.000'
119
+
120
+ expect(subject.class_number_level).to eq 2
121
+ end
122
+
123
+ it 'returns 2 when filled until third and last level' do
124
+ subject.masked_number = '10.53.111'
125
+
126
+ expect(subject.class_number_level).to eq 3
127
+ end
128
+ end
129
+
130
+ describe '#editable?' do
131
+ context 'when is not imported' do
132
+ before do
133
+ subject.imported = false
134
+ end
135
+
136
+ it { expect(subject).to be_editable }
137
+ end
138
+
139
+ context 'when is imported' do
140
+ before do
141
+ subject.imported = true
142
+ end
143
+
144
+ it { expect(subject).to_not be_editable }
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Material do
4
+ it { is_expected.to be_kind_of Unico::Material }
5
+
6
+ it { is_expected.to belong_to(:material_class) }
7
+ it { is_expected.to belong_to(:reference_unit) }
8
+
9
+ it { is_expected.to validate_presence_of(:material_class) }
10
+ it { is_expected.to validate_presence_of(:reference_unit) }
11
+ it { is_expected.to validate_presence_of(:detailed_description) }
12
+ it { is_expected.to validate_presence_of(:code) }
13
+ it { is_expected.to validate_presence_of(:description) }
14
+ it { is_expected.to validate_presence_of(:material_classification) }
15
+
16
+ it { is_expected.to validate_uniqueness_of(:code) }
17
+ it { is_expected.to validate_uniqueness_of(:description) }
18
+
19
+ it 'returns code and description as to_s method' do
20
+ subject.code = '30'
21
+ subject.description = 'Lorem ipsum dolor sit amet'
22
+
23
+ expect(subject.to_s).to eq "#{subject.code} - #{subject.description}"
24
+ end
25
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Neighborhood do
4
+ it { is_expected.to be_a_kind_of InscriptioCursualis::Neighborhood }
5
+
6
+ it { is_expected.to belong_to(:city) }
7
+ it { is_expected.to belong_to(:district) }
8
+
9
+ it { is_expected.to have_and_belong_to_many(:streets) }
10
+
11
+ it { is_expected.to validate_presence_of :name }
12
+ it { is_expected.to validate_presence_of :city }
13
+
14
+ context 'district' do
15
+ context 'with a city' do
16
+ before do
17
+ allow(subject).to receive(:city).and_return(city)
18
+ end
19
+
20
+ let :city do
21
+ double(:city, districts: [inside_district], marked_for_destruction?: false)
22
+ end
23
+
24
+ let :inside_district do
25
+ double(:district)
26
+ end
27
+
28
+ let :outside_district do
29
+ double(:district)
30
+ end
31
+
32
+ context 'inside district' do
33
+ it 'should be valid' do
34
+ allow(subject).to receive(:district).and_return(inside_district)
35
+
36
+ subject.valid?
37
+
38
+ expect(subject.errors[:district]).to be_empty
39
+ end
40
+ end
41
+
42
+ context 'outside district' do
43
+ it 'should be invalid' do
44
+ allow(subject).to receive(:district).and_return(outside_district)
45
+
46
+ subject.valid?
47
+
48
+ expect(subject.errors[:district]).to include 'is invalid'
49
+ end
50
+ end
51
+ end
52
+
53
+ context 'without a city' do
54
+ let :district do
55
+ double(:district)
56
+ end
57
+
58
+ it 'should not include error on district if has not a city' do
59
+ allow(subject).to receive(:district).and_return(district)
60
+
61
+ subject.valid?
62
+
63
+ expect(subject.errors[:district]).to_not include 'is invalid'
64
+ end
65
+ end
66
+ end
67
+
68
+ it 'cast to string using name' do
69
+ subject.name = 'Centro'
70
+
71
+ expect(subject.to_s).to eq 'Centro'
72
+ end
73
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe OccupationBaseGroup do
4
+ it { is_expected.to be_a_kind_of Unico::OccupationBaseGroup }
5
+
6
+ it { is_expected.to belong_to(:occupation_subgroup) }
7
+ it { is_expected.to have_many(:occupation_classifications).dependent(:restrict_with_exception) }
8
+
9
+ it { is_expected.to validate_presence_of :name }
10
+ it { is_expected.to validate_presence_of :code }
11
+
12
+ it 'cast to string using the code and name' do
13
+ subject.code = '0101'
14
+ subject.name = 'Oficiais generais das forças armadas'
15
+
16
+ expect(subject.to_s).to eq '0101 - Oficial General da Aeronáutica'
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe OccupationClassification do
4
+ it { is_expected.to be_a_kind_of Unico::OccupationClassification }
5
+
6
+ it { is_expected.to belong_to(:occupation_base_group) }
7
+
8
+ it { is_expected.to validate_presence_of :name }
9
+ it { is_expected.to validate_presence_of :code }
10
+
11
+ it 'cast to string using the code and name' do
12
+ subject.code = '010105'
13
+ subject.name = 'Oficial General da Aeronáutica'
14
+
15
+ expect(subject.to_s).to eq '010105 - Oficial General da Aeronáutica'
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe OccupationGroup do
4
+ it { is_expected.to be_a_kind_of Unico::OccupationGroup }
5
+
6
+ it { is_expected.to have_many(:occupation_main_groups).dependent(:restrict_with_exception) }
7
+
8
+ it { is_expected.to validate_presence_of :name }
9
+ it { is_expected.to validate_presence_of :code }
10
+
11
+ it 'cast to string using the code and name' do
12
+ subject.code = '0'
13
+ subject.name = 'MEMBROS DAS FORÇAS ARMADAS, POLICIAIS E BOMBEIROS MILITARES'
14
+
15
+ expect(subject.to_s).to eq '0 - MEMBROS DAS FORÇAS ARMADAS, POLICIAIS E BOMBEIROS MILITARES'
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe OccupationMainGroup do
4
+ it { is_expected.to be_a_kind_of Unico::OccupationMainGroup }
5
+
6
+ it { is_expected.to belong_to(:occupation_group) }
7
+ it { is_expected.to have_many(:occupation_subgroups).dependent(:restrict_with_exception) }
8
+
9
+ it { is_expected.to validate_presence_of :name }
10
+ it { is_expected.to validate_presence_of :code }
11
+
12
+ it 'cast to string using the code and name' do
13
+ subject.code = '01'
14
+ subject.name = 'MEMBROS DAS FORÇAS ARMADAS'
15
+
16
+ expect(subject.to_s).to eq '01 - MEMBROS DAS FORÇAS ARMADAS'
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe OccupationSubgroup do
4
+ it { is_expected.to be_a_kind_of Unico::OccupationSubgroup }
5
+
6
+ it { is_expected.to belong_to(:occupation_main_group) }
7
+ it { is_expected.to have_many(:occupation_base_groups).dependent(:restrict_with_exception) }
8
+
9
+ it { is_expected.to validate_presence_of :name }
10
+ it { is_expected.to validate_presence_of :code }
11
+
12
+ it 'cast to string using the code and name' do
13
+ subject.code = '010'
14
+ subject.name = 'MEMBROS DAS FORÇAS ARMADAS'
15
+
16
+ expect(subject.to_s).to eq '010 - MEMBROS DAS FORÇAS ARMADAS'
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Partner do
4
+ it { is_expected.to be_a_kind_of Persona::Partner }
5
+
6
+ it { is_expected.to belong_to(:company) }
7
+ it { is_expected.to belong_to(:person) }
8
+
9
+ it { is_expected.to validate_presence_of :person }
10
+ it { is_expected.to validate_presence_of :percentage }
11
+
12
+ it { is_expected.to allow_value(100).for(:percentage) }
13
+ it { is_expected.to allow_value(0.01).for(:percentage) }
14
+ it { is_expected.not_to allow_value(101).for(:percentage) }
15
+ it { is_expected.not_to allow_value(0).for(:percentage) }
16
+
17
+ context 'to_s' do
18
+ it 'should return person#to_s' do
19
+ allow(subject).to receive_messages(person: double(to_s: 'Gabriel Sobrinho'))
20
+
21
+ expect(subject.to_s).to eq 'Gabriel Sobrinho'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,129 @@
1
+ require 'spec_helper'
2
+
3
+ describe Person do
4
+ it { is_expected.to be_a_kind_of Persona::Person }
5
+
6
+ it { is_expected.to belong_to :personable }
7
+
8
+ it { is_expected.to validate_presence_of :name }
9
+ it { is_expected.to validate_presence_of :personable }
10
+
11
+ it { is_expected.to have_one(:address).conditions(correspondence: false).dependent(:destroy) }
12
+ it { is_expected.to have_one(:correspondence_address).conditions(correspondence: true).dependent(:destroy) }
13
+
14
+ it { is_expected.to allow_value('gabriel.sobrinho@gmail.com').for(:email) }
15
+ it { is_expected.not_to allow_value('gabriel.sobrinho').for(:email) }
16
+
17
+ it { is_expected.to allow_value('(00) 0000-0000').for(:phone) }
18
+ it { is_expected.not_to allow_value('00 0000-0000').for(:phone) }
19
+
20
+ it { is_expected.to allow_value('(00) 0000-0000').for(:fax) }
21
+ it { is_expected.not_to allow_value('00 0000-0000').for(:fax) }
22
+
23
+ it { is_expected.to allow_value('(00) 00000-0000').for(:mobile) }
24
+ it { is_expected.not_to allow_value('00 00000-0000').for(:mobile) }
25
+
26
+ context '#cpf' do
27
+ let :cpf do
28
+ double(:cpf)
29
+ end
30
+
31
+ let :personable do
32
+ double(:personable, cpf: cpf)
33
+ end
34
+
35
+ before do
36
+ allow(subject).to receive(:personable).and_return personable
37
+ end
38
+
39
+ it 'should return the personable cpf if personable responds to cpf' do
40
+ expect(subject.cpf).to eq cpf
41
+ end
42
+
43
+ it 'should return nil when personable does not responds to cpf' do
44
+ allow(subject).to receive(:personable).and_return double
45
+
46
+ expect(subject.cpf).to be_nil
47
+ end
48
+ end
49
+
50
+ context '#cnpj' do
51
+ let :cnpj do
52
+ double(:cnpj)
53
+ end
54
+
55
+ let :personable do
56
+ double(:personable, cnpj: cnpj)
57
+ end
58
+
59
+ before do
60
+ allow(subject).to receive(:personable).and_return personable
61
+ end
62
+
63
+ it 'should return the personable cnpj if personable responds to cnpj' do
64
+ expect(subject.cnpj).to eq cnpj
65
+ end
66
+
67
+ it 'should return nil when personable does not responds to cnpj' do
68
+ allow(subject).to receive(:personable).and_return double
69
+
70
+ expect(subject.cnpj).to be_nil
71
+ end
72
+ end
73
+
74
+ context '#state_registration' do
75
+ let :state_registration do
76
+ double(:state_registration)
77
+ end
78
+
79
+ let :personable do
80
+ double(:personable, state_registration: state_registration)
81
+ end
82
+
83
+ before do
84
+ allow(subject).to receive(:personable).and_return personable
85
+ end
86
+
87
+ it 'returns the state registration when personable responds to state_registration' do
88
+ expect(subject.state_registration).to eq state_registration
89
+ end
90
+
91
+ it 'returns nil when responsable does not repond to state_registration' do
92
+ allow(subject).to receive(:personable).and_return double
93
+
94
+ expect(subject.state_registration).to be_nil
95
+ end
96
+ end
97
+
98
+ context '#responsible' do
99
+ let :responsible do
100
+ double(:responsible)
101
+ end
102
+
103
+ let :personable do
104
+ double(:personable, responsible: responsible)
105
+ end
106
+
107
+ before do
108
+ allow(subject).to receive(:personable).and_return personable
109
+ end
110
+
111
+ it 'returns the state registration when personable responds to responsible' do
112
+ expect(subject.responsible).to eq responsible
113
+ end
114
+
115
+ it 'returns nil when responsable does not repond to responsible' do
116
+ allow(subject).to receive(:personable).and_return double
117
+
118
+ expect(subject.responsible).to be_nil
119
+ end
120
+ end
121
+
122
+ context '#to_s' do
123
+ it 'cast to string using name' do
124
+ subject.name = 'Gabriel Sobrinho'
125
+
126
+ expect(subject.to_s).to eq 'Gabriel Sobrinho'
127
+ end
128
+ end
129
+ end