csv_import_magic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (327) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +36 -0
  4. data/app/assets/javascripts/csv_import_magic/application.js +13 -0
  5. data/app/assets/stylesheets/csv_import_magic/_theme.scss +75 -0
  6. data/app/assets/stylesheets/csv_import_magic/application.scss +1 -0
  7. data/app/controllers/csv_import_magic/base_controller.rb +4 -0
  8. data/app/controllers/csv_import_magic/importers_controller.rb +64 -0
  9. data/app/models/importer.rb +77 -0
  10. data/app/services/csv_import_magic/failure.rb +54 -0
  11. data/app/services/csv_import_magic/importer.rb +53 -0
  12. data/app/views/csv_import_magic/importers/edit.html.erb +43 -0
  13. data/app/views/csv_import_magic/importers/show.html.erb +31 -0
  14. data/app/views/layouts/csv_import_magic.html.erb +31 -0
  15. data/app/workers/csv_import_magic/importer_worker.rb +13 -0
  16. data/config/initializers/initializer.rb +1 -0
  17. data/config/locales/en.yml +71 -0
  18. data/config/routes.rb +3 -0
  19. data/db/migrate/20170111145652_create_companies.rb +15 -0
  20. data/db/migrate/20170111145657_create_importers.rb +15 -0
  21. data/db/migrate/20170112125734_create_user.rb +8 -0
  22. data/lib/csv_import_magic/engine.rb +5 -0
  23. data/lib/csv_import_magic/models.rb +18 -0
  24. data/lib/csv_import_magic/orm/active_record.rb +5 -0
  25. data/lib/csv_import_magic/version.rb +3 -0
  26. data/lib/csv_import_magic.rb +12 -0
  27. data/lib/generators/active_record/csv_import_magic_generator.rb +35 -0
  28. data/lib/generators/active_record/templates/csv_parser.rb +19 -0
  29. data/lib/generators/csv_import_magic/controllers_generator.rb +14 -0
  30. data/lib/generators/csv_import_magic/csv_import_magic_generator.rb +17 -0
  31. data/lib/generators/csv_import_magic/install_generator.rb +58 -0
  32. data/lib/generators/csv_import_magic/orm_helpers.rb +19 -0
  33. data/lib/generators/csv_import_magic/views_generator.rb +65 -0
  34. data/lib/generators/templates/migration.rb +10 -0
  35. data/lib/generators/templates/views/shareds/_csv_importer.html.erb +19 -0
  36. data/spec/controllers/csv_import_magic/importers_controller_spec.rb +106 -0
  37. data/spec/dummy/README.rdoc +28 -0
  38. data/spec/dummy/Rakefile +6 -0
  39. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  40. data/spec/dummy/app/assets/stylesheets/application.css +16 -0
  41. data/spec/dummy/app/controllers/application_controller.rb +7 -0
  42. data/spec/dummy/app/csv_parsers/company_parser.rb +15 -0
  43. data/spec/dummy/app/csv_parsers/foo_parser.rb +9 -0
  44. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  45. data/spec/dummy/app/models/company.rb +5 -0
  46. data/spec/dummy/app/models/user.rb +4 -0
  47. data/spec/dummy/app/views/application/index.html.erb +22 -0
  48. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  49. data/spec/dummy/bin/bundle +3 -0
  50. data/spec/dummy/bin/rails +4 -0
  51. data/spec/dummy/bin/rake +4 -0
  52. data/spec/dummy/bin/setup +29 -0
  53. data/spec/dummy/config/application.rb +26 -0
  54. data/spec/dummy/config/boot.rb +5 -0
  55. data/spec/dummy/config/database.yml +25 -0
  56. data/spec/dummy/config/environment.rb +5 -0
  57. data/spec/dummy/config/environments/development.rb +41 -0
  58. data/spec/dummy/config/environments/production.rb +79 -0
  59. data/spec/dummy/config/environments/test.rb +42 -0
  60. data/spec/dummy/config/initializers/assets.rb +11 -0
  61. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  62. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  63. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/spec/dummy/config/initializers/inflections.rb +16 -0
  65. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  66. data/spec/dummy/config/initializers/session_store.rb +3 -0
  67. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/spec/dummy/config/locales/csv_import_magic.pt-BR.yml +71 -0
  69. data/spec/dummy/config/locales/pt-BR.yml +271 -0
  70. data/spec/dummy/config/routes.rb +5 -0
  71. data/spec/dummy/config/secrets.yml +22 -0
  72. data/spec/dummy/config.ru +4 -0
  73. data/spec/dummy/db/development.sqlite3 +0 -0
  74. data/spec/dummy/db/schema.rb +51 -0
  75. data/spec/dummy/db/test.sqlite3 +0 -0
  76. data/spec/dummy/log/development.log +5489 -0
  77. data/spec/dummy/log/test.log +87086 -0
  78. data/spec/dummy/public/404.html +67 -0
  79. data/spec/dummy/public/422.html +67 -0
  80. data/spec/dummy/public/500.html +66 -0
  81. data/spec/dummy/public/favicon.ico +0 -0
  82. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-37276-r4n40q.csv +2 -0
  83. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-38136-8h3q2p.csv +2 -0
  84. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-38466-1nr5kco.csv +2 -0
  85. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-39668-101mi6q.csv +2 -0
  86. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-40284-81g0ud.csv +2 -0
  87. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-40408-17a0uvl.csv +2 -0
  88. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-40523-pj6wl4.csv +2 -0
  89. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42084-10luep0.csv +2 -0
  90. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42191-11tldaf.csv +2 -0
  91. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42321-baundn.csv +2 -0
  92. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42420-1qm2isf.csv +2 -0
  93. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42570-gywnhk.csv +2 -0
  94. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42696-1pg04re.csv +2 -0
  95. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42823-vekf7j.csv +2 -0
  96. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-42910-ewzmcp.csv +2 -0
  97. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-43235-1fa52ga.csv +2 -0
  98. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-43323-p159hh.csv +2 -0
  99. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-45345-1r8v081.csv +2 -0
  100. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-46182-1dx0tpn.csv +2 -0
  101. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-46278-fd4m8e.csv +2 -0
  102. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-46382-9y135a.csv +2 -0
  103. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-48570-1k4k7t0.csv +2 -0
  104. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56058-b7otnp.csv +2 -0
  105. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56173-187smu1.csv +2 -0
  106. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56280-ax6el0.csv +2 -0
  107. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56372-pyd0uc.csv +2 -0
  108. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56475-16dw7ov.csv +2 -0
  109. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56578-odd4y0.csv +2 -0
  110. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56672-l11ojb.csv +2 -0
  111. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170117-56794-88h4nd.csv +2 -0
  112. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-10138-13br6m2.csv +2 -0
  113. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-19400-ra06q5.csv +2 -0
  114. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-19543-rfxxty.csv +2 -0
  115. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-19652-1neho6l.csv +2 -0
  116. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-19786-rxjv36.csv +2 -0
  117. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-21648-ssn05e.csv +2 -0
  118. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-23496-ddy2xt.csv +2 -0
  119. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-30892-1c27rs4.csv +2 -0
  120. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-30994-qfqs3h.csv +2 -0
  121. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-32470-1mk1udp.csv +2 -0
  122. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-32716-13g9myq.csv +2 -0
  123. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-32807-12b8cgg.csv +2 -0
  124. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-32901-1vp2axx.csv +2 -0
  125. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-32992-1jwfjfd.csv +2 -0
  126. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-33081-1j1d591.csv +2 -0
  127. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-33180-36l1t8.csv +2 -0
  128. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-33299-13p8l1x.csv +2 -0
  129. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-38626-sigf3m.csv +2 -0
  130. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-38797-1kqkwkw.csv +2 -0
  131. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-39057-1x8b2fn.csv +2 -0
  132. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-39157-1087rtq.csv +2 -0
  133. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-39268-168s29f.csv +2 -0
  134. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-39355-s8x1si.csv +2 -0
  135. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-39483-r08bs.csv +2 -0
  136. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-40181-vdjtbv.csv +2 -0
  137. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-42041-w1imo1.csv +2 -0
  138. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-42229-1e22hz4.csv +2 -0
  139. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-42996-9neptt.csv +2 -0
  140. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-43889-584l0q.csv +2 -0
  141. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-44738-ew2i2a.csv +2 -0
  142. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-7981-1uei1o4.csv +2 -0
  143. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-8075-15sar1.csv +2 -0
  144. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-8167-zc1h0z.csv +2 -0
  145. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-8265-bnndjd.csv +2 -0
  146. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170118-8364-4u0il1.csv +2 -0
  147. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-22243-b3wyrt.csv +2 -0
  148. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-22711-1uvny32.csv +2 -0
  149. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-56031-votbjp.csv +2 -0
  150. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-56135-j5mcgr.csv +2 -0
  151. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-56240-l2w835.csv +2 -0
  152. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-57815-i1ahvu.csv +2 -0
  153. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-58056-66wtac.csv +2 -0
  154. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-58268-1dty7ny.csv +2 -0
  155. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-63803-1mc7fo4.csv +2 -0
  156. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-74528-duefru.csv +2 -0
  157. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-82684-glhzzy.csv +2 -0
  158. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-82810-wamt7d.csv +2 -0
  159. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-82946-1vdlbhd.csv +2 -0
  160. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-83065-1u153xf.csv +2 -0
  161. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-83165-1c32fyg.csv +2 -0
  162. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-84188-1wch9sz.csv +2 -0
  163. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-86886-1erfhrx.csv +2 -0
  164. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170119-87029-1vof5gs.csv +2 -0
  165. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-12481-joulms.csv +2 -0
  166. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-12708-h8hiiu.csv +2 -0
  167. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-12804-h1kvkh.csv +2 -0
  168. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-12985-tjysyw.csv +2 -0
  169. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-13084-3zodzd.csv +2 -0
  170. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-13449-1bpmult.csv +2 -0
  171. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-13540-2g5zwb.csv +2 -0
  172. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-15095-wb4mk0.csv +2 -0
  173. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-15202-8ib7ha.csv +2 -0
  174. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-16523-1s896hk.csv +2 -0
  175. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-16637-eboq9e.csv +2 -0
  176. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170120-87818-1j4mz4q.csv +2 -0
  177. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-65471-17j2vti.csv +2 -0
  178. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-65694-1kptcuq.csv +2 -0
  179. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-66245-crezgc.csv +2 -0
  180. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-66415-1krzmy1.csv +2 -0
  181. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-66524-ndzegu.csv +2 -0
  182. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-66655-pjqteu.csv +2 -0
  183. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-66854-r2dyv2.csv +2 -0
  184. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-67000-1t9vfos.csv +2 -0
  185. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-67391-15d0sso.csv +2 -0
  186. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-67538-1gbudl.csv +2 -0
  187. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-67640-p8dmlm.csv +2 -0
  188. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-68349-ziyxe9.csv +2 -0
  189. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-68617-14k1fap.csv +2 -0
  190. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-68815-v1izav.csv +2 -0
  191. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-68984-wcittg.csv +2 -0
  192. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-69642-1hi7zb2.csv +2 -0
  193. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-69802-mq57e0.csv +2 -0
  194. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-73509-mbxhb6.csv +2 -0
  195. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-80682-oask81.csv +2 -0
  196. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-80872-1vkh6vb.csv +2 -0
  197. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-81056-63swkp.csv +2 -0
  198. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-81212-1k8weuv.csv +2 -0
  199. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-81379-6lpon9.csv +2 -0
  200. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-82575-1eioq1a.csv +2 -0
  201. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-84919-1qnjxhv.csv +2 -0
  202. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-85131-1g8jrl5.csv +2 -0
  203. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-85343-yezbz5.csv +2 -0
  204. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-85513-1l2pzgy.csv +2 -0
  205. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-86070-pwkn99.csv +2 -0
  206. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-86277-14ckax5.csv +2 -0
  207. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-86458-1u26pb1.csv +2 -0
  208. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-86599-q2d5io.csv +2 -0
  209. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-86739-hfrzzf.csv +2 -0
  210. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170125-87110-1ky9gnk.csv +2 -0
  211. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-27355-hl9693.csv +2 -0
  212. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-27618-1pqa3bs.csv +2 -0
  213. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-27755-1di5xra.csv +2 -0
  214. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-27974-cx2o7z.csv +2 -0
  215. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-28133-1q0tz4z.csv +2 -0
  216. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-28419-1ia3064.csv +2 -0
  217. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-28556-veg3ez.csv +2 -0
  218. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-28784-15yhmp3.csv +2 -0
  219. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29002-igofgq.csv +2 -0
  220. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29143-1v25x8a.csv +2 -0
  221. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29291-1qs4kex.csv +2 -0
  222. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29522-5i1a.csv +2 -0
  223. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29660-165adk7.csv +2 -0
  224. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-29945-1lvmnay.csv +2 -0
  225. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-30103-9qqoc.csv +2 -0
  226. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-30381-1de3q2.csv +2 -0
  227. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-30864-1mthr0r.csv +2 -0
  228. data/spec/dummy/public/system/importers/attachment_errors/000/000/001/original/failures20170126-30993-wxw7ja.csv +2 -0
  229. data/spec/dummy/public/system/importers/attachment_errors/000/000/002/original/failures20170119-55532-1ujy7xh.csv +2 -0
  230. data/spec/dummy/public/system/importers/attachment_errors/000/000/003/original/failures20170119-87695-1j8psm5.csv +2 -0
  231. data/spec/dummy/public/system/importers/attachment_errors/000/000/003/original/failures20170125-84785-u7rdmo.csv +2 -0
  232. data/spec/dummy/public/system/importers/attachment_errors/000/000/006/original/failures20170118-40447-4jsf3l.csv +2 -0
  233. data/spec/dummy/public/system/importers/attachment_errors/000/000/007/original/failures20170118-44958-l51x0w.csv +2 -0
  234. data/spec/dummy/public/system/importers/attachments/000/000/001/original/companies.csv +3 -0
  235. data/spec/dummy/public/system/importers/attachments/000/000/001/original/companies_invalid.csv +3 -0
  236. data/spec/dummy/public/system/importers/attachments/000/000/002/original/companies.csv +3 -0
  237. data/spec/dummy/public/system/importers/attachments/000/000/002/original/companies_invalid.csv +3 -0
  238. data/spec/dummy/public/system/importers/attachments/000/000/003/original/companies.csv +3 -0
  239. data/spec/dummy/public/system/importers/attachments/000/000/003/original/companies_invalid.csv +3 -0
  240. data/spec/dummy/public/system/importers/attachments/000/000/004/original/companies.csv +3 -0
  241. data/spec/dummy/public/system/importers/attachments/000/000/005/original/companies.csv +3 -0
  242. data/spec/dummy/public/system/importers/attachments/000/000/006/original/companies_invalid.csv +3 -0
  243. data/spec/dummy/public/system/importers/attachments/000/000/007/original/companies_invalid.csv +3 -0
  244. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-A/-AzUQ_sdncLrgXJW-mT29l7lXefApIPQNpdCv9ETYkI.cache +0 -0
  245. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0f/0fmItA1G7uruwRE5HZE9TzG9K4A0NbbxGakdWz0cpDE.cache +0 -0
  246. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2M/2MSWm1oJk8doLU2cxusKHCU78PUDwQ1lrIlu5gXMx_U.cache +1 -0
  247. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2k/2kXdUd2P4uN67x_E2mUy-AtGn9Fn_h5rQ0PJZi9HzBU.cache +1 -0
  248. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4b/4bvq3aQAVWrr_CUPXfVFCwfZMnmX-ecl9ZtwAisBlFI.cache +1 -0
  249. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6-/6-dQ3OmAEd4QXytW4TS1xdUNozHlLKSCawN0oN1oEYw.cache +1 -0
  250. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/63/63b-SgBWtX-UDgRq-Bsol3W40ijIWiT7uxcHRoVXS-M.cache +1 -0
  251. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7l/7lUIJIvW1FW_GFVqqnVsKSxpeMaZ3noc0g8Eca5eHhQ.cache +0 -0
  252. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9S/9S1VAatjEVICqM1Cojv-CKBUvl0oELWaNfTyFr_S700.cache +0 -0
  253. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/A9/A9Vpp3VfKYpkCR6f1lAoM4J-w6QQ3fyn3x3TncKXf7U.cache +3 -0
  254. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Av/AvR3LtLvNoPexMzvvUDPuM1V-yuaMddpBdG1RVgQh9Y.cache +0 -0
  255. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Df/Dfad3HZGzx9mtzeig2tWlnuHQl9vAzoUutfVJwWKC5I.cache +0 -0
  256. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dh/DhZ6bJZj4K7QCbNBTmMjFy3HDpC58SqfiPPoCCsAro4.cache +1 -0
  257. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Hw/HwRNsYmzR0cy4L_V_8SLZiZ9_G6_8E7XiaDV21i9sjA.cache +0 -0
  258. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/I9/I97QBZ0SyWLebPjfYrwCNlM-Omla1LKRTGiTgmMKi2Q.cache +0 -0
  259. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/J7/J7Ihmq6t6WbnmJaBScToEb-AR0U1NqHePsGdxAdJoLo.cache +0 -0
  260. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KF/KFqlYW7ohx2fJX05v2au1k6Gw7wuzN7UWz2BN90RsAQ.cache +1 -0
  261. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LL/LLb4gLbgLgFS-LgcrmKXC--d1IaGB8XM_Yrm48bkwdw.cache +0 -0
  262. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LX/LXS-BomSubWXJSpkNXCH8m0l2y4sB66BaFb2UuAx14o.cache +1 -0
  263. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lq/LqbLgHiwEzXq7mJX3Dtq5XicBULM8CtvDJdv4Ye45ZY.cache +1 -0
  264. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Nh/Nhtorvc2xM84CWBcqtMIxoqKR4NCkCksOUQ_3UiyegA.cache +1 -0
  265. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Oy/OyEUtus13InbtOxcvt5WdsbydEkrviBwJXD6z9GQaRA.cache +1 -0
  266. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/P6/P6-U-RxLXuRTDz8kHA2kBc3jUHSnNlbEHBOnUa97wyY.cache +1 -0
  267. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Po/Pos0iHsH-rUXDrrdalDi2H6yWVQTcz2ZPyRmQ_RnBPM.cache +1 -0
  268. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Q1/Q1xmk8Ni14zSYsTX_IvrbX1vbGANki_Udrwx7OBgh9w.cache +0 -0
  269. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qo/QogFhnK16HrvDyiH323Z3xlwwofVibvzgZDmBjqh5VQ.cache +3 -0
  270. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/RI/RIagqSB7X-LbJU0ZwntNWf_KMkOm3kCkc7zR57rP1Bc.cache +1 -0
  271. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/T4/T4WcrrL47jCKFOb5Q1cmn1keh_w3X2OguI_ifzRpS3k.cache +1 -0
  272. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/TA/TAbsAe1o7EI19gckGhtzbtjqOoSVRRLQrc5n3mnCT28.cache +0 -0
  273. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/TG/TGe7XAuizvtm9LtzDo5fR7GrEnyWPL8nBr2eESxA0x0.cache +0 -0
  274. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/V8/V8kjWO7PZcVGI9mBNq17FYWc_muWwcDQF9xWGfnSOjM.cache +1 -0
  275. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VV/VVtm8HzHyOByhegKNGl09Ak3sHcSr0e70iHSmy75T6A.cache +0 -0
  276. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vb/VbBBjIpX-u1j_Fko8QfFQ61-bfDS8BaYgGATVKIfp3I.cache +0 -0
  277. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WR/WRP18y_66NlZHU4W5qM0P1MN8oS5eAlN9UEZrXh3vd0.cache +1 -0
  278. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wd/WdUHknjRY-ueTBCEgU4-NzM_BFaTimaeFED6MbFfQLE.cache +0 -0
  279. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bo/bopbSF0DLQEMLjRvN8Mn4xd-mGx46j9yvENVDA8R9jk.cache +0 -0
  280. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/e4/e4DrxyTxBlZlpP4PQ0zELpYhl4G2eiBksI0_HwQhrVY.cache +0 -0
  281. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gZ/gZp3uXMHuYQC4hzCr7bQfetKNdJAtbQmg3so2KpW1Dw.cache +2 -0
  282. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  283. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iK/IKrFvYc5CMyfkKHP7JFW_bS4-tOG1rVwPFcC-OUpENU.cache +0 -0
  284. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iK/IkTLxpKuWrwxrM98yl3Ddv4RjOLzyUS5QHQvZ0Cniv8.cache +1 -0
  285. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iK/iKpMoxBcOmuavL2xUzgc7LQLnT7EKCaZirHx4KMbdw8.cache +1 -0
  286. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/je/jeA_WQ150_Af65U1CnVdHsqqZefOHl2ObGMLRQp--sc.cache +2 -0
  287. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l1/l1LHMvhocUYdhOc0tOfdy4slQYK2SD4fj6x4mH4wkvI.cache +0 -0
  288. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lo/loI7P5Fiwnq6YZdxqJFAErc6rV61HWRuL5tVaffS3JY.cache +1 -0
  289. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m9/m95ShgmvfDO8RuwZpC7gUW0i-FO-k914CWkXd5-LO3I.cache +1 -0
  290. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/my/myHmSL0lcXz8Mgm5gNVoigImnF7acMaTlwl3z_g2lPM.cache +0 -0
  291. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oo/oocXRRNDTZPTtm859sgr9TxpBrPby6ND88ROtiCfgSU.cache +0 -0
  292. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p-/p-3_4sMWwoC1eQcdH2fmcIdmlxQBFx6evUCdgfgPyKM.cache +1 -0
  293. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  294. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rn/rnSEYPKQcSZ-D3R7o3aM_1AtiXyLciuL3S3Qa6k_EfI.cache +0 -0
  295. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sV/sVzlvz069Fh5_GPu0TcrgDBWIHhnwEZ2Rg1AtpEqA9s.cache +0 -0
  296. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uV/uVH7RdIENZh9BUaGeb6OUciC9H0hTIKsRpAxXMG5R28.cache +1 -0
  297. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xQ/xQEI_TWc5k3ouSH2fSRrrWRpsLyeG7QQxmcgPjkwbc8.cache +0 -0
  298. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xQ/xQUUINnLqsr-zxPaIIULgXPE5jh2QtmbdRSYCnhpER4.cache +0 -0
  299. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xb/xblMCu_z727eCkuWjKJEyre92sVUkcGCpQqGThWe2bk.cache +2 -0
  300. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yg/ygMyHfDIhhvlowOd5aTDhtXbZCLisqxhDWpdvXd8O5M.cache +0 -0
  301. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yg/ygrgsR6-nQLxLaFwAquCXfjIZgUTEoYbI5EFH0KlfW0.cache +1 -0
  302. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yh/yh3Aqjs6HjjQubE9-htvIwUg4cFhMRCl7JyBFYBt0xo.cache +1 -0
  303. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/z0/z0QrtOYRAsWOTFYmpCJqXXyGlHxHUxxKBV3_LMxKV2Y.cache +0 -0
  304. data/spec/examples.txt +50 -0
  305. data/spec/factories/importer.rb +10 -0
  306. data/spec/factories/user.rb +6 -0
  307. data/spec/fixtures/companies.csv +3 -0
  308. data/spec/fixtures/companies_invalid.csv +3 -0
  309. data/spec/lib/csv_import_magic/models_spec.rb +51 -0
  310. data/spec/lib/generators/active_record/csv_import_magic_generator_spec.rb +74 -0
  311. data/spec/lib/generators/active_record/namespaced/csv_import_magic_generator_spec.rb +78 -0
  312. data/spec/lib/generators/csv_import_magic/controllers_generator_spec.rb +34 -0
  313. data/spec/lib/generators/csv_import_magic/install_generator_spec.rb +79 -0
  314. data/spec/lib/generators/csv_import_magic/rails_5/install_generator_spec.rb +62 -0
  315. data/spec/lib/generators/csv_import_magic/views_generator_spec.rb +204 -0
  316. data/spec/models/importer_spec.rb +82 -0
  317. data/spec/rails_helper.rb +61 -0
  318. data/spec/services/csv_import_magic/failure_spec.rb +23 -0
  319. data/spec/services/csv_import_magic/importer_spec.rb +57 -0
  320. data/spec/spec_helper.rb +70 -0
  321. data/spec/support/database_cleaner.rb +12 -0
  322. data/spec/support/factory_girl.rb +12 -0
  323. data/spec/support/paperclip.rb +3 -0
  324. data/spec/support/shoulda_matchers.rb +6 -0
  325. data/spec/support/simplecov.rb +12 -0
  326. data/spec/workers/csv_import_magic/importer_worker_spec.rb +31 -0
  327. metadata +758 -0
@@ -0,0 +1,61 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
4
+
5
+ require File.expand_path('../dummy/config/environment', __FILE__)
6
+ # Prevent database truncation if the environment is production
7
+ abort('The Rails environment is running in production mode!') if Rails.env.production?
8
+ require 'spec_helper'
9
+ require 'rspec/rails'
10
+ require 'factory_girl_rails'
11
+ require 'paperclip/matchers'
12
+
13
+ # Add additional requires below this line. Rails is not loaded until this point!
14
+ # Requires supporting ruby files with custom matchers and macros, etc, in
15
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
16
+ # run as spec files by default. This means that files in spec/support that end
17
+ # in _spec.rb will both be required and run as specs, causing the specs to be
18
+ # run twice. It is recommended that you do not name files matching this glob to
19
+ # end with _spec.rb. You can configure this pattern with the --pattern
20
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
21
+ #
22
+ # The following line is provided for convenience purposes. It has the downside
23
+ # of increasing the boot-up time by auto-requiring all files in the support
24
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
25
+ # require only the support files necessary.
26
+ #
27
+ Dir[File.join(ENGINE_RAILS_ROOT, 'spec/factories/**/*.rb')].each { |f| require f }
28
+ Dir[File.join(ENGINE_RAILS_ROOT, 'spec/support/**/*.rb')].each { |f| require f }
29
+
30
+ # Checks for pending migrations before tests are run.
31
+ # If you are not using ActiveRecord, you can remove this line.
32
+ # ActiveRecord::Migration.maintain_test_schema!
33
+
34
+ RSpec.configure do |config|
35
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
36
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
37
+
38
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
39
+ # examples within a transaction, remove the following line or assign false
40
+ # instead of true.
41
+ config.use_transactional_fixtures = false
42
+
43
+ # RSpec Rails can automatically mix in different behaviours to your tests
44
+ # based on their file location, for example enabling you to call `get` and
45
+ # `post` in specs under `spec/controllers`.
46
+ #
47
+ # You can disable this behaviour by removing the line below, and instead
48
+ # explicitly tag your specs with their type, e.g.:
49
+ #
50
+ # RSpec.describe UsersController, :type => :controller do
51
+ # # ...
52
+ # end
53
+ #
54
+ # The different available types are documented in the features, such as in
55
+ # https://relishapp.com/rspec/rspec-rails/docs
56
+ config.infer_spec_type_from_file_location!
57
+
58
+ # Extensions
59
+ config.include ActiveSupport::Testing::TimeHelpers
60
+ config.include ActionDispatch::TestProcess
61
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CsvImportMagic::Failure, type: :service do
4
+ let(:csv_parsed) { CsvImportMagic::Importer.new(import.id).call }
5
+ subject { described_class.new(csv_parsed, import.id) }
6
+
7
+ describe '#generate' do
8
+ context 'creates and upload the failures file' do
9
+ let(:attachment) { fixture_file_upload(Rails.root.join('../fixtures/companies_invalid.csv')) }
10
+ let!(:import) { create :importer, attachment: attachment, source: 'company', columns: %w(name street number neighborhood city state country) }
11
+
12
+ it 'when invalid record' do
13
+ expect do
14
+ subject.generate
15
+ import.reload
16
+ end.to change(import, :message).from(nil).to('Alguns registros não foram importados pois contém erros!')
17
+
18
+ expect(import.status).to eq('error')
19
+ expect(import.attachment_error).to be_present
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CsvImportMagic::Importer, type: :service do
4
+ let(:importer) { described_class.new(import.id) }
5
+
6
+ describe '#call' do
7
+ context 'with resource params' do
8
+ let!(:user) { create(:user) }
9
+ let(:importer) { described_class.new(import.id, model: 'User', id: user.id, relation: 'companies') }
10
+ let(:attachment) { fixture_file_upload(Rails.root.join('../fixtures/companies.csv')) }
11
+ let(:import) { create :importer, attachment: attachment, source: 'company', columns: %w(name street number neighborhood city state country) }
12
+
13
+ it 'create an company for every row, with relation' do
14
+ expect { importer.call }.to change(Company, :count).by(2)
15
+ expect(Company.all.pluck(:name)).to match_array(%w(bar foo))
16
+ expect(Company.all.pluck(:street)).to match_array(['R: Teste', 'R: Teste'])
17
+ expect(Company.all.pluck(:number)).to match_array(%w(1 2))
18
+ expect(Company.all.pluck(:neighborhood)).to match_array(['Joao de Barro', 'Joao de Barro'])
19
+ expect(Company.all.pluck(:city)).to match_array(%w(Aracatuba Birigui))
20
+ expect(Company.all.pluck(:state)).to match_array(%w(SP SP))
21
+ expect(Company.all.pluck(:user_id)).to match_array([user.id, user.id])
22
+ end
23
+ end
24
+
25
+ context 'with valid columns' do
26
+ let(:attachment) { fixture_file_upload(Rails.root.join('../fixtures/companies.csv')) }
27
+ let(:import) { create :importer, attachment: attachment, source: 'company', columns: %w(name street number neighborhood city state country) }
28
+
29
+ it 'create an company for every row' do
30
+ expect { importer.call }.to change(Company, :count).by(2)
31
+ expect(Company.all.pluck(:name)).to match_array(%w(bar foo))
32
+ expect(Company.all.pluck(:street)).to match_array(['R: Teste', 'R: Teste'])
33
+ expect(Company.all.pluck(:number)).to match_array(%w(1 2))
34
+ expect(Company.all.pluck(:neighborhood)).to match_array(['Joao de Barro', 'Joao de Barro'])
35
+ expect(Company.all.pluck(:city)).to match_array(%w(Aracatuba Birigui))
36
+ expect(Company.all.pluck(:state)).to match_array(%w(SP SP))
37
+ expect(Company.all.pluck(:user_id)).to match_array([nil, nil])
38
+ end
39
+ end
40
+
41
+ context 'with ignored columns' do
42
+ let(:attachment) { fixture_file_upload(Rails.root.join('../fixtures/companies.csv')) }
43
+ let(:import) { create :importer, attachment: attachment, source: 'company', columns: %w(name street number ignore city state country) }
44
+
45
+ it 'create an company for every row' do
46
+ expect { importer.call }.to change(Company, :count).by(2)
47
+ expect(Company.all.pluck(:name)).to match_array(%w(bar foo))
48
+ expect(Company.all.pluck(:street)).to match_array(['R: Teste', 'R: Teste'])
49
+ expect(Company.all.pluck(:number)).to match_array(%w(1 2))
50
+ expect(Company.all.pluck(:neighborhood)).to match_array([nil, nil])
51
+ expect(Company.all.pluck(:city)).to match_array(%w(Aracatuba Birigui))
52
+ expect(Company.all.pluck(:state)).to match_array(%w(SP SP))
53
+ expect(Company.all.pluck(:user_id)).to match_array([nil, nil])
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,70 @@
1
+ RSpec.configure do |config|
2
+ # rspec-expectations config goes here. You can use an alternate
3
+ # assertion/expectation library such as wrong or the stdlib/minitest
4
+ # assertions if you prefer.
5
+ config.expect_with :rspec do |expectations|
6
+ # This option will default to `true` in RSpec 4. It makes the `description`
7
+ # and `failure_message` of custom matchers include text for helper methods
8
+ # defined using `chain`, e.g.:
9
+ # be_bigger_than(2).and_smaller_than(4).description
10
+ # # => "be bigger than 2 and smaller than 4"
11
+ # ...rather than:
12
+ # # => "be bigger than 2"
13
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14
+ end
15
+
16
+ # rspec-mocks config goes here. You can use an alternate test double
17
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
18
+ config.mock_with :rspec do |mocks|
19
+ # Prevents you from mocking or stubbing a method that does not exist on
20
+ # a real object. This is generally recommended, and will default to
21
+ # `true` in RSpec 4.
22
+ mocks.verify_partial_doubles = true
23
+ end
24
+
25
+ # These two settings work together to allow you to limit a spec run
26
+ # to individual examples or groups you care about by tagging them with
27
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
28
+ # get run.
29
+ config.filter_run :focus
30
+ config.run_all_when_everything_filtered = true
31
+
32
+ # Allows RSpec to persist some state between runs in order to support
33
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
34
+ # you configure your source control system to ignore this file.
35
+ config.example_status_persistence_file_path = 'spec/examples.txt'
36
+
37
+ # Limits the available syntax to the non-monkey patched syntax that is
38
+ # recommended. For more details, see:
39
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
40
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
41
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
42
+ config.disable_monkey_patching!
43
+
44
+ # Many RSpec users commonly either run the entire suite or an individual
45
+ # file, and it's useful to allow more verbose output when running an
46
+ # individual spec file.
47
+ if config.files_to_run.one?
48
+ # Use the documentation formatter for detailed output,
49
+ # unless a formatter has already been configured
50
+ # (e.g. via a command-line flag).
51
+ config.default_formatter = 'doc'
52
+ end
53
+
54
+ # Print the 10 slowest examples and example groups at the
55
+ # end of the spec run, to help surface which specs are running
56
+ # particularly slow.
57
+ config.profile_examples = 10
58
+
59
+ # Run specs in random order to surface order dependencies. If you find an
60
+ # order dependency and want to debug it, you can fix the order by providing
61
+ # the seed, which is printed after each run.
62
+ # --seed 1234
63
+ config.order = :random
64
+
65
+ # Seed global randomization in this process using the `--seed` CLI option.
66
+ # Setting this allows you to use `--seed` to deterministically reproduce
67
+ # test failures related to randomization by passing the same `--seed` value
68
+ # as the one that triggered the failure.
69
+ Kernel.srand config.seed
70
+ end
@@ -0,0 +1,12 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.strategy = :transaction
4
+ DatabaseCleaner.clean_with(:truncation)
5
+ end
6
+
7
+ config.around(:each) do |example|
8
+ DatabaseCleaner.cleaning do
9
+ example.run
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+
4
+ config.before(:suite) do
5
+ begin
6
+ DatabaseCleaner.start
7
+ FactoryGirl.lint
8
+ ensure
9
+ DatabaseCleaner.clean
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Paperclip::Shoulda::Matchers
3
+ end
@@ -0,0 +1,6 @@
1
+ Shoulda::Matchers.configure do |config|
2
+ config.integrate do |with|
3
+ with.test_framework :rspec
4
+ with.library :rails
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ if ENV['coverage'] == 'on'
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start 'rails' do
5
+ minimum_coverage 100
6
+
7
+ # Groups
8
+ add_group 'Services', 'app/services'
9
+ add_group 'Workers', 'app/workers'
10
+ add_group 'Generators', 'lib/generators'
11
+ end
12
+ end
@@ -0,0 +1,31 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CsvImportMagic::ImporterWorker, type: :worker do
4
+ let(:worker) { described_class.new }
5
+ let!(:importer) { create :importer }
6
+
7
+ describe '#perform' do
8
+ let(:report) { double(CSVImporter::Report, created_rows: [1, 2], updated_rows: [], invalid_rows: []) }
9
+ let(:config) { double(:config, identifiers: [:foo]) }
10
+ let(:csv_parsed) { double(CompanyParser, report: report, config: config, valid_header?: true) }
11
+ let(:service) { double(CsvImportMagic::Importer, call: csv_parsed) }
12
+ let(:failures) { double(CsvImportMagic::Failure, generate: true) }
13
+
14
+ before do
15
+ instance_of_importer = double
16
+ allow(CsvImportMagic::Importer).to receive(:new).with(importer.id, nil).and_return(instance_of_importer)
17
+ allow(instance_of_importer).to receive(:call).and_return(csv_parsed)
18
+ end
19
+
20
+ it 'calls CsvImportMagic::Importer service' do
21
+ expect(CsvImportMagic::Importer).to receive(:new).with(importer.id, nil).and_return(service)
22
+ worker.perform(importer_id: importer.id, resources: nil)
23
+ end
24
+
25
+ it 'calls CsvImportMagic::Failure service' do
26
+ expect(CsvImportMagic::Failure).to receive(:new).with(csv_parsed, importer.id).and_return(failures)
27
+ expect(failures).to receive(:generate)
28
+ worker.perform(importer_id: importer.id, resources: nil)
29
+ end
30
+ end
31
+ end