lcms-engine 0.3.1 → 0.4.0

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 +4 -4
  2. data/.dockerignore +25 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +23 -73
  5. data/.nvmrc +1 -1
  6. data/.overcommit.yml +8 -2
  7. data/.prettierrc +7 -0
  8. data/.rubocop.yml +5 -2
  9. data/.ruby-version +1 -1
  10. data/.stylelintignore +9 -0
  11. data/.stylelintrc +8 -0
  12. data/CHANGELOG.md +36 -2
  13. data/Dockerfile +3 -3
  14. data/Gemfile.lock +344 -297
  15. data/README.md +20 -18
  16. data/app/assets/config/lcms_engine_manifest.js +4 -2
  17. data/app/assets/javascripts/lcms/engine/admin/{application.js → lcms_engine_application.js} +1 -3
  18. data/app/assets/javascripts/lcms/engine/initializers/foundation.js +1 -1
  19. data/app/assets/javascripts/lcms/engine/{application.js → lcms_engine_application.js} +0 -0
  20. data/app/assets/stylesheets/lcms/engine/admin/collections.scss +2 -1
  21. data/app/assets/stylesheets/lcms/engine/admin/components.scss +60 -19
  22. data/app/assets/stylesheets/lcms/engine/admin/curriculums.scss +12 -10
  23. data/app/assets/stylesheets/lcms/engine/admin/lessons.scss +21 -15
  24. data/app/assets/stylesheets/lcms/engine/admin/materials.scss +25 -17
  25. data/app/assets/stylesheets/lcms/engine/admin/resources.scss +8 -7
  26. data/app/assets/stylesheets/lcms/engine/admin/standards.scss +4 -1
  27. data/app/assets/stylesheets/lcms/engine/admin/users.scss +1 -1
  28. data/app/assets/stylesheets/lcms/engine/base/_colors.scss +8 -10
  29. data/app/assets/stylesheets/lcms/engine/base/_ld-colors.scss +10 -10
  30. data/app/assets/stylesheets/lcms/engine/components/_assoc-picker.scss +4 -5
  31. data/app/assets/stylesheets/lcms/engine/components/lesson/_activity.scss +6 -2
  32. data/app/assets/stylesheets/lcms/engine/components/lesson/_callout.scss +19 -5
  33. data/app/assets/stylesheets/lcms/engine/components/lesson/_columns.scss +4 -3
  34. data/app/assets/stylesheets/lcms/engine/components/lesson/_curriculum-map.scss +16 -7
  35. data/app/assets/stylesheets/lcms/engine/components/lesson/_def.scss +2 -2
  36. data/app/assets/stylesheets/lcms/engine/components/lesson/_expand.scss +9 -9
  37. data/app/assets/stylesheets/lcms/engine/components/lesson/_foundational-divider.scss +0 -1
  38. data/app/assets/stylesheets/lcms/engine/components/lesson/_group.scss +3 -1
  39. data/app/assets/stylesheets/lcms/engine/components/lesson/_icons.scss +1 -1
  40. data/app/assets/stylesheets/lcms/engine/components/lesson/_image-wrap.scss +2 -2
  41. data/app/assets/stylesheets/lcms/engine/components/lesson/_inset.scss +7 -2
  42. data/app/assets/stylesheets/lcms/engine/components/lesson/_materials.scss +1 -1
  43. data/app/assets/stylesheets/lcms/engine/components/lesson/_multiple-choice.scss +4 -1
  44. data/app/assets/stylesheets/lcms/engine/components/lesson/_override.scss +28 -9
  45. data/app/assets/stylesheets/lcms/engine/components/lesson/_pd.scss +7 -7
  46. data/app/assets/stylesheets/lcms/engine/components/lesson/_pv.scss +5 -4
  47. data/app/assets/stylesheets/lcms/engine/components/lesson/_section.scss +10 -3
  48. data/app/assets/stylesheets/lcms/engine/components/lesson/_selection-control.scss +14 -8
  49. data/app/assets/stylesheets/lcms/engine/components/lesson/_sidebar.scss +25 -10
  50. data/app/assets/stylesheets/lcms/engine/components/lesson/_title.scss +3 -1
  51. data/app/assets/stylesheets/lcms/engine/components/lesson/_unit-map.scss +1 -1
  52. data/app/assets/stylesheets/lcms/engine/components/material/_material.scss +3 -3
  53. data/app/assets/stylesheets/lcms/engine/components/material/_overlay.scss +12 -4
  54. data/app/assets/stylesheets/lcms/engine/components/material/_preview.scss +1 -1
  55. data/app/assets/stylesheets/lcms/engine/components/support/_survey.scss +3 -1
  56. data/app/assets/stylesheets/lcms/engine/layout/_footer.scss +29 -11
  57. data/app/assets/stylesheets/lcms/engine/layout/_header.scss +5 -5
  58. data/app/assets/stylesheets/lcms/engine/layout/_navigation.scss +4 -6
  59. data/app/assets/stylesheets/lcms/engine/layout/_page.scss +2 -2
  60. data/app/assets/stylesheets/lcms/engine/{admin.scss → lcms_engine_admin.scss} +26 -15
  61. data/app/assets/stylesheets/lcms/engine/lcms_engine_application.scss +9 -0
  62. data/app/assets/stylesheets/lcms/engine/pdf.scss +5 -26
  63. data/app/assets/stylesheets/lcms/engine/pdf_plain.scss +5 -23
  64. data/app/assets/stylesheets/lcms/engine/print/_base.scss +41 -12
  65. data/app/assets/stylesheets/lcms/engine/print/_cover.scss +12 -12
  66. data/app/assets/stylesheets/lcms/engine/print/_footer.scss +8 -3
  67. data/app/assets/stylesheets/lcms/engine/print/_gdoc-base.scss +10 -37
  68. data/app/assets/stylesheets/lcms/engine/print/_helpers.scss +5 -2
  69. data/app/assets/stylesheets/lcms/engine/print/_lesson-base.scss +2 -14
  70. data/app/assets/stylesheets/lcms/engine/print/_material-base.scss +1 -3
  71. data/app/assets/stylesheets/lcms/engine/print/_print.scss +15 -8
  72. data/app/assets/stylesheets/lcms/engine/print/_toc.scss +24 -9
  73. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base-typography.scss +24 -6
  74. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base.scss +10 -3
  75. data/app/assets/stylesheets/lcms/engine/print/gdoc/_colors.scss +3 -3
  76. data/app/assets/stylesheets/lcms/engine/print/gdoc/_header.scss +2 -2
  77. data/app/assets/stylesheets/lcms/engine/print/gdoc/_helpers.scss +1 -0
  78. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_activity.scss +1 -1
  79. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_agenda.scss +8 -2
  80. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_callout.scss +16 -6
  81. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_def.scss +1 -1
  82. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_dialogue.scss +3 -1
  83. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_expand.scss +5 -2
  84. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image-wrap.scss +5 -3
  85. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image.scss +1 -1
  86. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_optbreak.scss +1 -0
  87. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_section.scss +4 -1
  88. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_smp.scss +1 -0
  89. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_tables.scss +11 -3
  90. data/app/assets/stylesheets/lcms/engine/print/gdoc/material/_header.scss +5 -2
  91. data/app/assets/stylesheets/lcms/engine/print/lesson/_base-typography.scss +33 -9
  92. data/app/assets/stylesheets/lcms/engine/print/lesson/_group.scss +3 -1
  93. data/app/assets/stylesheets/lcms/engine/print/lesson/_image.scss +3 -1
  94. data/app/assets/stylesheets/lcms/engine/print/lesson/_materials.scss +1 -1
  95. data/app/assets/stylesheets/lcms/engine/print/lesson/_pd.scss +8 -4
  96. data/app/assets/stylesheets/lcms/engine/print/lesson/_section.scss +1 -1
  97. data/app/assets/stylesheets/lcms/engine/print/material/_header.scss +4 -1
  98. data/app/assets/stylesheets/lcms/engine/themes/_material.scss +11 -11
  99. data/app/assets/stylesheets/lcms/engine/utils/_colorcodes.scss +15 -5
  100. data/app/assets/stylesheets/lcms/engine/utils/_functions.scss +1 -1
  101. data/app/assets/stylesheets/lcms/engine/utils/_helpers.scss +23 -11
  102. data/app/assets/stylesheets/lcms/engine/utils/_placeholders.scss +1 -1
  103. data/app/assets/stylesheets/lcms/engine/utils/_variables.scss +11 -11
  104. data/app/assets/stylesheets/lcms/engine/vendors/{mathjax.css → mathjax.scss} +0 -0
  105. data/app/assets/stylesheets/lcms/engine/vendors/react-tagsinput.css +48 -0
  106. data/app/controllers/concerns/lcms/engine/reimportable.rb +1 -1
  107. data/app/controllers/lcms/engine/admin/access_codes_controller.rb +8 -3
  108. data/app/controllers/lcms/engine/admin/admin_controller.rb +5 -39
  109. data/app/controllers/lcms/engine/admin/association_picker_controller.rb +4 -1
  110. data/app/controllers/lcms/engine/admin/batch_reimports_controller.rb +2 -2
  111. data/app/controllers/lcms/engine/admin/curriculums_controller.rb +21 -2
  112. data/app/controllers/lcms/engine/admin/documents_controller.rb +26 -14
  113. data/app/controllers/lcms/engine/admin/materials_controller.rb +23 -13
  114. data/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +2 -2
  115. data/app/controllers/lcms/engine/admin/resources_controller.rb +9 -7
  116. data/app/controllers/lcms/engine/admin/settings_controller.rb +1 -1
  117. data/app/controllers/lcms/engine/admin/standards_controller.rb +2 -2
  118. data/app/controllers/lcms/engine/admin/users_controller.rb +10 -7
  119. data/app/controllers/lcms/engine/application_controller.rb +1 -1
  120. data/app/controllers/lcms/engine/resources_controller.rb +5 -5
  121. data/app/controllers/lcms/engine/welcome_controller.rb +11 -0
  122. data/app/entities/lcms/engine/hierarchical_position.rb +1 -2
  123. data/app/entities/lcms/engine/media_embed.rb +1 -1
  124. data/app/entities/lcms/engine/pagination.rb +14 -10
  125. data/app/entities/lcms/engine/roman_numerals.rb +1 -1
  126. data/app/exceptions/lcms/engine/document_error.rb +8 -0
  127. data/app/exceptions/lcms/engine/material_error.rb +8 -0
  128. data/app/helpers/admin/components_helper.rb +1 -1
  129. data/app/helpers/lcms/engine/path_helper.rb +32 -0
  130. data/app/helpers/lcms/engine/resource_helper.rb +1 -1
  131. data/app/helpers/lcms/engine/view_helper.rb +0 -8
  132. data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
  133. data/app/javascript/components/admin/ImportStatus.jsx +88 -58
  134. data/app/javascript/components/admin/Initializer.jsx +33 -35
  135. data/app/javascript/components/admin/MultiSelectedOperation.jsx +43 -19
  136. data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +68 -48
  137. data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +18 -7
  138. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +42 -18
  139. data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +47 -28
  140. data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +54 -33
  141. data/app/javascript/components/admin/curriculum/DirectoryPicker.jsx +80 -53
  142. data/app/javascript/components/admin/picker/PickerButton.jsx +16 -11
  143. data/app/javascript/components/admin/picker/pickerModal.jsx +6 -6
  144. data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +61 -40
  145. data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +54 -40
  146. data/app/javascript/components/admin/resource-picker/ResourcePickerResource.jsx +14 -3
  147. data/app/javascript/components/admin/resource-picker/ResourcePickerWindow.jsx +50 -21
  148. data/app/javascript/components/paginate/PageView.jsx +20 -8
  149. data/app/javascript/components/paginate/PaginationBoxView.jsx +78 -66
  150. data/app/javascript/components/paginate/PaginationListView.jsx +59 -45
  151. data/app/javascript/packs/lcms_engine_admin.js +15 -0
  152. data/app/javascript/packs/{application.js → lcms_engine_application.js} +5 -4
  153. data/app/javascript/packs/server_rendering.js +1 -0
  154. data/app/javascript/vendor/jstree/jstree.min.js +6 -0
  155. data/app/javascript/vendor/jstree/themes/default/32px.png +0 -0
  156. data/app/javascript/vendor/jstree/themes/default/40px.png +0 -0
  157. data/app/javascript/vendor/jstree/themes/default/style.css +1106 -0
  158. data/app/javascript/vendor/jstree/themes/default/style.min.css +1 -0
  159. data/app/javascript/vendor/jstree/themes/default/throbber.gif +0 -0
  160. data/app/javascript/vendor/jstree/themes/default-dark/32px.png +0 -0
  161. data/app/javascript/vendor/jstree/themes/default-dark/40px.png +0 -0
  162. data/app/javascript/vendor/jstree/themes/default-dark/style.css +1150 -0
  163. data/app/javascript/vendor/jstree/themes/default-dark/style.min.css +1 -0
  164. data/app/javascript/vendor/jstree/themes/default-dark/throbber.gif +0 -0
  165. data/app/jobs/lcms/engine/document_generate_job.rb +1 -1
  166. data/app/jobs/lcms/engine/document_generate_pdf_job.rb +5 -5
  167. data/app/jobs/lcms/engine/material_generate_pdf_job.rb +4 -4
  168. data/app/models/concerns/lcms/engine/navigable.rb +6 -10
  169. data/app/models/concerns/lcms/engine/searchable.rb +7 -0
  170. data/app/models/lcms/engine/document.rb +1 -1
  171. data/app/models/lcms/engine/resource.rb +1 -1
  172. data/app/models/lcms/engine/search/repository.rb +1 -1
  173. data/app/presenters/lcms/engine/content_presenter.rb +1 -1
  174. data/app/presenters/lcms/engine/curriculum_presenter.rb +21 -18
  175. data/app/presenters/lcms/engine/document_presenter.rb +3 -1
  176. data/app/presenters/lcms/engine/resource_presenter.rb +6 -3
  177. data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
  178. data/app/queries/lcms/engine/admin_materials_query.rb +11 -2
  179. data/app/queries/lcms/engine/base_query.rb +1 -1
  180. data/app/services/lcms/engine/document_build_service.rb +2 -0
  181. data/app/services/lcms/engine/document_generator.rb +2 -2
  182. data/app/services/lcms/engine/google/drive_service.rb +7 -15
  183. data/app/services/lcms/engine/google/script_service.rb +7 -3
  184. data/app/services/lcms/engine/html_sanitizer.rb +1 -1
  185. data/app/services/lcms/engine/lti_exporter.rb +1 -1
  186. data/app/services/lcms/engine/material_preview_generator.rb +1 -1
  187. data/app/services/lcms/engine/s3_service.rb +14 -2
  188. data/app/tasks/resource_tasks.rb +2 -2
  189. data/app/views/layouts/lcms/engine/admin.html.erb +3 -3
  190. data/app/views/layouts/lcms/engine/application.html.erb +2 -2
  191. data/app/views/layouts/lcms/engine/lti.html.erb +1 -1
  192. data/app/views/lcms/engine/admin/access_codes/_form.html.erb +1 -1
  193. data/app/views/lcms/engine/admin/access_codes/index.html.erb +3 -3
  194. data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +1 -1
  195. data/app/views/lcms/engine/admin/curriculums/edit.html.erb +4 -2
  196. data/app/views/lcms/engine/admin/documents/_reimport.html.erb +1 -1
  197. data/app/views/lcms/engine/admin/documents/_search_form.html.erb +1 -1
  198. data/app/views/lcms/engine/admin/documents/import.html.erb +1 -1
  199. data/app/views/lcms/engine/admin/documents/index.html.erb +5 -3
  200. data/app/views/lcms/engine/admin/documents/new.html.erb +6 -2
  201. data/app/views/lcms/engine/admin/materials/_reimport.html.erb +1 -1
  202. data/app/views/lcms/engine/admin/materials/_search_form.html.erb +1 -1
  203. data/app/views/lcms/engine/admin/materials/import.html.erb +1 -1
  204. data/app/views/lcms/engine/admin/materials/index.html.erb +22 -18
  205. data/app/views/lcms/engine/admin/materials/new.html.erb +5 -1
  206. data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +1 -1
  207. data/app/views/lcms/engine/admin/resources/_fields.html.erb +4 -3
  208. data/app/views/lcms/engine/admin/resources/_form.html.erb +1 -1
  209. data/app/views/lcms/engine/admin/resources/_search_form.html.erb +1 -1
  210. data/app/views/lcms/engine/admin/resources/index.html.erb +7 -5
  211. data/app/views/lcms/engine/admin/shared/_header.html.erb +12 -12
  212. data/app/views/lcms/engine/admin/standards/_form.html.erb +3 -1
  213. data/app/views/lcms/engine/admin/standards/_search_form.html.erb +1 -1
  214. data/app/views/lcms/engine/admin/users/_form.html.erb +1 -1
  215. data/app/views/lcms/engine/admin/users/_search_form.html.erb +1 -1
  216. data/app/views/lcms/engine/admin/users/index.html.erb +6 -6
  217. data/app/views/lcms/engine/pages/not_found.html.erb +5 -0
  218. data/app/views/lcms/engine/resources/generic.html.erb +0 -4
  219. data/app/views/lcms/engine/resources/media.html.erb +0 -4
  220. data/app/views/lcms/engine/resources/show.html.erb +0 -2
  221. data/config/initializers/airbrake.rb +62 -10
  222. data/config/initializers/bitly.rb +1 -1
  223. data/config/initializers/carrier_wave.rb +6 -4
  224. data/config/initializers/ckeditor.rb +6 -0
  225. data/config/initializers/elasticsearch.rb +1 -1
  226. data/config/initializers/resque.rb +2 -2
  227. data/config/locales/admin/en.yml +0 -1
  228. data/config/locales/ui/en.yml +1 -0
  229. data/config/routes.rb +5 -2
  230. data/db/migrate/.keep +0 -0
  231. data/db/schema.rb +279 -311
  232. data/db/seeds.rb +0 -1
  233. data/docker-compose.ror4.yml +32 -0
  234. data/docker-compose.yml +6 -3
  235. data/docs/env-variables.md +40 -40
  236. data/docs/google-cloud-platform-setup.md +45 -17
  237. data/docs/how-to-build-and-publish.md +1 -0
  238. data/lcms-engine.gemspec +21 -15
  239. data/lib/doc_template/document.rb +3 -4
  240. data/lib/doc_template/document_toc.rb +2 -2
  241. data/lib/doc_template/objects/activity_metadata.rb +1 -1
  242. data/lib/doc_template/objects/toc_helpers.rb +4 -4
  243. data/lib/doc_template/objects/toc_metadata.rb +4 -6
  244. data/lib/doc_template/tags/answer_space_tag.rb +1 -1
  245. data/lib/doc_template/tags/base_tag.rb +2 -2
  246. data/lib/doc_template/tags/block_tag.rb +1 -1
  247. data/lib/doc_template/tags/table_tag.rb +1 -1
  248. data/lib/doc_template/template.rb +1 -1
  249. data/lib/doc_template.rb +9 -9
  250. data/lib/document_exporter/gdoc/base.rb +5 -2
  251. data/lib/document_exporter/pdf/base.rb +1 -1
  252. data/lib/document_exporter/pdf/document.rb +2 -2
  253. data/lib/document_exporter/pdf/material.rb +2 -2
  254. data/lib/document_exporter/pdf/student_material.rb +2 -2
  255. data/lib/document_exporter/pdf/teacher_material.rb +2 -2
  256. data/lib/document_renderer/part.rb +1 -3
  257. data/lib/lcms/engine/engine.rb +10 -9
  258. data/lib/lcms/engine/version.rb +1 -1
  259. data/lib/lcms/engine.rb +0 -1
  260. data/lib/lt/lcms/metadata/context.rb +56 -52
  261. data/lib/lt/lcms/metadata/service.rb +3 -2
  262. data/lib/tasks/cloud66.rake +2 -2
  263. data/lib/tasks/document.rake +4 -4
  264. data/lib/tasks/google.rake +29 -14
  265. data/lib/tasks/lcms/engine_tasks.rake +1 -1
  266. data/package.json +31 -10
  267. data/postcss.config.js +12 -0
  268. data/spec/controllers/admin/curriculums_controller_spec.rb +23 -0
  269. data/spec/controllers/admin/documents_controller_spec.rb +22 -2
  270. data/spec/controllers/admin/materials_controller_spec.rb +16 -3
  271. data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +1 -1
  272. data/spec/controllers/admin/resources_controller_spec.rb +1 -1
  273. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  274. data/spec/controllers/admin/standards_controller_spec.rb +1 -1
  275. data/spec/controllers/admin/welcome_controller_spec.rb +12 -10
  276. data/spec/controllers/resources_controller_spec.rb +3 -3
  277. data/spec/controllers/welcome_controller_spec.rb +38 -0
  278. data/spec/dummy/.traceroute.yaml +0 -2
  279. data/spec/dummy/bin/webpack +18 -0
  280. data/spec/dummy/bin/webpack-dev-server +18 -0
  281. data/spec/dummy/config/application.rb +1 -1
  282. data/spec/dummy/config/environments/test.rb +1 -1
  283. data/spec/dummy/config/initializers/assets.rb +6 -0
  284. data/spec/dummy/config/lcms-admin.yml +3 -7
  285. data/spec/dummy/config/routes.rb +6 -0
  286. data/spec/dummy/db/schema.rb +5 -5
  287. data/spec/factories/documents.rb +1 -0
  288. data/spec/factories/downloads.rb +1 -1
  289. data/spec/factories/resources.rb +2 -2
  290. data/spec/features/admin/materials/add_material_spec.rb +2 -0
  291. data/spec/features/admin/users_spec.rb +2 -2
  292. data/spec/{controllers/admin/admin_controller_spec.rb → helpers/path_helper_spec.rb} +6 -6
  293. data/spec/lib/doc_template/objects/activity_metadata_spec.rb +1 -1
  294. data/spec/lib/doc_template/objects/agenda_metadata_spec.rb +2 -0
  295. data/spec/lib/doc_template/objects/toc_metadata_spec.rb +1 -1
  296. data/spec/lib/doc_template/tags/page_break_tag_spec.rb +1 -1
  297. data/spec/lib/doc_template/tags/pd_tag_spec.rb +1 -1
  298. data/spec/models/document_spec.rb +1 -1
  299. data/spec/models/standard_spec.rb +2 -0
  300. data/spec/queries/lcms/engine/admin_materials_query_spec.rb +34 -0
  301. data/spec/rails_helper.rb +6 -17
  302. data/spec/services/document_build_service_spec.rb +4 -11
  303. data/spec/services/s3_service_spec.rb +31 -0
  304. data/spec/support/concerns/navigable.rb +2 -0
  305. data/spec/support/routes.rb +4 -0
  306. data/spec/support/shared_examples/content_tag.rb +4 -4
  307. data/templates/routes.rb +0 -1
  308. data/yarn.lock +3412 -2933
  309. metadata +146 -288
  310. data/app/assets/stylesheets/lcms/engine/application.scss +0 -36
  311. data/app/assets/stylesheets/lcms/engine/vendors/jquery.tagsinput.css +0 -1
  312. data/app/exceptions/components_api_error.rb +0 -4
  313. data/app/exceptions/document_error.rb +0 -4
  314. data/app/exceptions/material_error.rb +0 -4
  315. data/app/javascript/packs/admin.js +0 -14
  316. data/app/models/lcms/engine/component.rb +0 -88
  317. data/app/presenters/lcms/engine/social_media_presenter.rb +0 -83
  318. data/app/views/lcms/engine/shared/_social_sharing.html.erb +0 -22
  319. data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +0 -36
  320. data/db/migrate/20200218144849_drop_material_parts_table.rb +0 -7
  321. data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +0 -7
  322. data/db/migrate/20200429130353_drop_pages.rb +0 -13
  323. data/db/seeds/pages.seeds.rb +0 -26
  324. data/lib/document_exporter.rb +0 -6
  325. data/lib/lcms/engine/migration.rb +0 -16
  326. data/spec/models/component_spec.rb +0 -60
  327. data/vendor/assets/javascripts/jquery.tagsinput.js +0 -1
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class Document < PDF::Base
4
+ module Pdf
5
+ class Document < Pdf::Base
6
6
  def export
7
7
  content = super
8
8
  pdf = CombinePDF.parse(content)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class Material < PDF::Base
4
+ module Pdf
5
+ class Material < Pdf::Base
6
6
  private
7
7
 
8
8
  def template_path(name)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class StudentMaterial < PDF::Base
4
+ module Pdf
5
+ class StudentMaterial < Pdf::Base
6
6
  def export
7
7
  pdf = CombinePDF.new
8
8
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class TeacherMaterial < PDF::Base
4
+ module Pdf
5
+ class TeacherMaterial < Pdf::Base
6
6
  def export
7
7
  content = super
8
8
  pdf = CombinePDF.parse(content)
@@ -29,10 +29,8 @@ module DocumentRenderer
29
29
  def should_render?(part, omit_optional: true)
30
30
  if part[:optional] && omit_optional
31
31
  false unless @excludes.include?(part[:anchor])
32
- elsif @excludes.include?(part[:anchor])
33
- false
34
32
  else
35
- true
33
+ !@excludes.include?(part[:anchor])
36
34
  end
37
35
  end
38
36
  end
@@ -66,9 +66,16 @@ module Lcms
66
66
  # Check if the DB exists
67
67
  next unless ActiveRecord::Base.connection
68
68
 
69
+ # Possible decorators
70
+ decorators = %W[
71
+ #{Rails.root}/app/decorators/**/*_decorator*.rb
72
+ #{Rails.root}/app/**/lcms/engine/*_decorator*.rb
73
+ ]
74
+
69
75
  Dir
70
- .glob("#{Rails.root}/app/decorators/**/*_decorator*.rb")
71
- .each(&method(:require_dependency))
76
+ .glob(decorators)
77
+ .sort
78
+ .each(&method(:require))
72
79
  rescue ActiveRecord::NoDatabaseError
73
80
  puts 'ActiveRecord::NoDatabaseError thrown!'
74
81
  end
@@ -88,13 +95,7 @@ module Lcms
88
95
  end
89
96
 
90
97
  initializer 'lcms.engine.assets.precompile' do |app|
91
- app.config.assets.precompile += %w(
92
- lcms_engine_manifest.js
93
- )
94
- # app.config.assets.precompile += %w(
95
- # ckeditor/*
96
- # gdoc.css
97
- # )
98
+ app.config.assets.precompile += %w(lcms_engine_manifest.js ckeditor/config.js)
98
99
  end
99
100
 
100
101
  initializer 'webpacker.proxy' do |app|
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- VERSION = '0.3.1'
5
+ VERSION = '0.4.0'
6
6
  RAILS_5_VERSION = 5.2
7
7
  end
8
8
  end
data/lib/lcms/engine.rb CHANGED
@@ -23,4 +23,3 @@ module Lcms
23
23
  end
24
24
 
25
25
  require 'lcms/engine/engine'
26
- require 'lcms/engine/migration'
@@ -71,41 +71,45 @@ module Lt
71
71
  end
72
72
 
73
73
  def find_or_create_resource
74
- # if the resource exists, return it
75
- resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory)
76
- return update(resource) if resource
77
-
78
- # else, build missing parents until we build the resource itself.
79
- parent = nil
80
- directory.each_with_index do |name, index|
81
- resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory[0..index])
82
- if resource
83
- parent = resource
84
- next
85
- end
74
+ # rubocop:disable Metrics/BlockLength
75
+ ::Lcms::Engine::Resource.with_advisory_lock('find_or_create_resource') do
76
+ # if the resource exists, return it
77
+ resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory)
78
+ return update(resource) if resource
79
+
80
+ # else, build missing parents until we build the resource itself.
81
+ parent = nil
82
+ directory.each_with_index do |name, index|
83
+ resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory[0..index])
84
+ if resource
85
+ parent = resource
86
+ next
87
+ end
86
88
 
87
- resource = build_new_resource(parent, name, index)
88
- unless last_item?(index)
89
- resource.save!
90
- unless resource.subject?
91
- self.class.send("update_#{resource.curriculum_type}s_level_position_for", resource.self_and_siblings)
89
+ resource = build_new_resource(parent, name, index)
90
+ unless last_item?(index)
91
+ resource.save!
92
+ unless resource.subject?
93
+ self.class.send("update_#{resource.curriculum_type}s_level_position_for", resource.self_and_siblings)
94
+ end
95
+ parent = resource
96
+ next
92
97
  end
93
- parent = resource
94
- next
95
- end
96
98
 
97
- if mid_assessment?
98
- set_mid_assessment_position(parent, resource)
99
- elsif prerequisite?
100
- set_prerequisite_position(parent, resource)
101
- elsif opr?
102
- set_opr_position(parent, resource)
103
- else
104
- set_lesson_position(parent, resource)
99
+ if mid_assessment?
100
+ set_mid_assessment_position(parent, resource)
101
+ elsif prerequisite?
102
+ set_prerequisite_position(parent, resource)
103
+ elsif opr?
104
+ set_opr_position(parent, resource)
105
+ else
106
+ set_lesson_position(parent, resource)
107
+ end
105
108
  end
106
- end
107
109
 
108
- update resource
110
+ update resource
111
+ end
112
+ # rubocop:enable Metrics/BlockLength
109
113
  end
110
114
 
111
115
  private
@@ -143,7 +147,7 @@ module Lt
143
147
  # ELA G1 M1 U2 Lesson 1
144
148
  curr ||= directory
145
149
  res = ::Lcms::Engine::Resource.new(metadata: metadata)
146
- ::Lcms::Engine::Breadcrumbs.new(res).title.split(' / ')[0...-1].push(curr.last.titleize).join(' ')
150
+ ::Lcms::Engine::Breadcrumbs.new(res).title.split(' / ')[0...-1].push(curr.last.to_s.titleize).join(' ')
147
151
  end
148
152
  end
149
153
 
@@ -164,7 +168,7 @@ module Lt
164
168
 
165
169
  def grade
166
170
  @grade ||= begin
167
- value = context[:grade].try(:downcase)
171
+ value = context[:grade].to_s.downcase
168
172
  value = "grade #{value.to_i}" if number?(value)
169
173
  value # if Grades::GRADES.include?(value)
170
174
  end
@@ -175,16 +179,18 @@ module Lt
175
179
  end
176
180
 
177
181
  def lesson
178
- @lesson ||= begin
179
- return nil if assessment? # assessment is a unit now, so lesson -> nil
180
-
181
- num = if ela? && prerequisite?
182
- ::Lcms::Engine::RomanNumerals.to_roman(context[:lesson].to_i)&.downcase
183
- else
184
- context[:lesson].presence
185
- end
186
- "lesson #{num}" if num.present?
187
- end
182
+ @lesson ||=
183
+ if assessment?
184
+ # assessment is a unit now, so lesson -> nil
185
+ nil
186
+ else
187
+ num = if ela? && prerequisite?
188
+ ::Lcms::Engine::RomanNumerals.to_roman(context[:lesson].to_i)&.downcase
189
+ else
190
+ context[:lesson].presence
191
+ end
192
+ "lesson #{num}" if num.present?
193
+ end
188
194
  end
189
195
 
190
196
  def mid_assessment?
@@ -240,20 +246,18 @@ module Lt
240
246
  end
241
247
 
242
248
  def unit
243
- @unit ||= begin
244
- if assessment?
245
- type # assessment-mid || assessment-end
246
- else
247
- ela? ? "unit #{context[:unit]}" : "topic #{context[:topic]}"
248
- end
249
- end
249
+ @unit ||= if assessment?
250
+ type # assessment-mid || assessment-end
251
+ else
252
+ ela? ? "unit #{context[:unit]}" : "topic #{context[:topic]}"
253
+ end
250
254
  end
251
255
 
252
- def update(resource)
256
+ def update(resource) # rubocop:disable Metrics/AbcSize
253
257
  return if resource.nil?
254
258
 
255
259
  # if resource changed to prerequisite, fix positioning
256
- prereq = context['type'].to_s.casecmp('prereq').zero?
260
+ prereq = context['type'].to_s.casecmp('prereq').to_i.zero?
257
261
  fix_prereq_position(resource) if prereq && !resource.prerequisite?
258
262
 
259
263
  # Update resource with document metadata
@@ -261,7 +265,7 @@ module Lt
261
265
  resource.teaser = context['teaser'] if context['teaser'].present?
262
266
  resource.description = context['description'] if context['description'].present?
263
267
  resource.tag_list << 'prereq' if prereq
264
- resource.tag_list << 'opr' if context['type'].to_s.casecmp('opr').zero?
268
+ resource.tag_list << 'opr' if context['type'].to_s.casecmp('opr').to_i.zero?
265
269
  resource.save
266
270
 
267
271
  resource
@@ -40,11 +40,12 @@ module Lt
40
40
  if material?
41
41
  @metadata = DocTemplate::Tables::MaterialMetadata.parse content
42
42
  @errors.concat @metadata.errors
43
- raise ::MaterialError, 'No metadata present' if !@metadata&.table_exist? || @metadata&.data&.empty?
43
+ raise ::Lcms::Engine::MaterialError, 'No metadata present' \
44
+ if !@metadata&.table_exist? || @metadata&.data&.empty?
44
45
  else
45
46
  @metadata = DocTemplate::Tables::Metadata.parse content
46
47
  @errors.concat @metadata.errors
47
- raise ::DocumentError, 'No metadata present' unless @metadata&.table_exist?
48
+ raise ::Lcms::Engine::DocumentError, 'No metadata present' unless @metadata&.table_exist?
48
49
 
49
50
  @agenda = DocTemplate::Tables::Agenda.parse content
50
51
  @section_metadata = DocTemplate::Tables::Section.parse content,
@@ -27,7 +27,7 @@ namespace :cloud66 do # rubocop:disable Metrics/BlockLength
27
27
  desc 'Exports tables to be synced'
28
28
  task export: :environment do
29
29
  cmd = <<-BASH
30
- pg_dump -U #{ENV['POSTGRESQL_USERNAME']} #{ENV['POSTGRESQL_DATABASE']} \
30
+ pg_dump -U #{ENV.fetch('POSTGRESQL_USERNAME', nil)} #{ENV.fetch('POSTGRESQL_DATABASE', nil)} \
31
31
  --no-owner \
32
32
  --table=users \
33
33
  --table=access_codes \
@@ -40,7 +40,7 @@ namespace :cloud66 do # rubocop:disable Metrics/BlockLength
40
40
  task import: :environment do
41
41
  raise 'No data file. Please execute `cloud66:swap:export` prior loading the data.' unless File.exist?(swap_file)
42
42
 
43
- cmd = "psql -U #{ENV['POSTGRESQL_USERNAME']} #{ENV['POSTGRESQL_DATABASE']}"
43
+ cmd = "psql -U #{ENV.fetch('POSTGRESQL_USERNAME', nil)} #{ENV.fetch('POSTGRESQL_DATABASE', nil)}"
44
44
  # Drops old tables
45
45
  system "#{cmd} -c 'drop table access_codes, users;'"
46
46
  # Create new and load the data
@@ -39,10 +39,10 @@ namespace :document do
39
39
  topic['lessons'].push(
40
40
  'file_name' => file_name,
41
41
  'identifier' => 'ENY-' \
42
- "G#{grade_key.split('-').last}-" \
43
- "M#{module_key.split('-').last}-" \
44
- "T#{topic_key.split('-').last}-" \
45
- "L#{lesson_number}",
42
+ "G#{grade_key.split('-').last}-" \
43
+ "M#{module_key.split('-').last}-" \
44
+ "T#{topic_key.split('-').last}-" \
45
+ "L#{lesson_number}",
46
46
  'name' => document.metadata['title_text'],
47
47
  'standards' => document.metadata['standard'],
48
48
  'description' => Nokogiri::HTML(document.metadata['description']).text,
@@ -4,22 +4,37 @@ require 'googleauth'
4
4
  require 'googleauth/stores/file_token_store'
5
5
  require 'lt/google/api/auth/cli'
6
6
 
7
- OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'
8
-
9
7
  namespace :google do
10
- desc 'set up google credentials'
11
- task setup_auth: :environment do
8
+ desc 'Set up google credentials. Specify `domain` argument which will be used as a base for redirect URI'
9
+ task :setup_auth, [:domain] => [:environment] do |_task, args|
12
10
  service = ::Lt::Google::Api::Auth::Cli.new
13
- if service.credentials.nil?
14
- authorizer = service.authorizer
15
- url = authorizer.get_authorization_url(base_url: OOB_URI)
16
- puts "Open \n>> #{url}\n in your browser and enter the resulting code:"
17
- code = $stdin.gets.strip
18
- authorizer.get_and_store_credentials_from_code(
19
- user_id: ::Lt::Google::Api::Auth::Cli::USER_ID, code: code, base_url: OOB_URI
20
- )
21
- else
22
- puts 'No need in action, everything is already set up'
11
+
12
+ # Check if there is existing auth token
13
+ if service.credentials.present?
14
+ puts <<~TEXT
15
+ Auth token already exists. Do you want to request new one?
16
+ Type Y for Yes, N for No
17
+ TEXT
18
+ next unless $stdin.gets.to_s.strip.downcase == 'y'
23
19
  end
20
+
21
+ authorizer = service.authorizer
22
+ url = authorizer.get_authorization_url(base_url: args[:domain])
23
+
24
+ puts <<~TEXT
25
+ Open this URL in your browser:
26
+ >>>>>
27
+ #{url}
28
+ >>>>>
29
+ Copy auth code and paste it below.
30
+ TEXT
31
+
32
+ code = $stdin.gets.to_s.strip
33
+
34
+ authorizer.get_and_store_credentials_from_code(
35
+ user_id: ::Lt::Google::Api::Auth::Cli::USER_ID,
36
+ code: code,
37
+ base_url: args[:domain]
38
+ )
24
39
  end
25
40
  end
@@ -70,7 +70,7 @@ def enhance_assets_precompile
70
70
  end
71
71
 
72
72
  # Compile packs after we've compiled all other assets during precompilation
73
- skip_webpacker_precompile = %w(no false n f).include?(ENV['WEBPACKER_PRECOMPILE'])
73
+ skip_webpacker_precompile = %w(no false n f).include?(ENV.fetch('WEBPACKER_PRECOMPILE', nil))
74
74
 
75
75
  unless skip_webpacker_precompile
76
76
  if Rake::Task.task_defined?('assets:precompile')
data/package.json CHANGED
@@ -5,31 +5,52 @@
5
5
  "dependencies": {
6
6
  "@babel/core": "^7.6.0",
7
7
  "@babel/preset-react": "^7.0.0",
8
- "@rails/webpacker": "~4",
8
+ "@rails/webpacker": "~5.4.3",
9
9
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
10
10
  "classnames": "^2.2.6",
11
- "lodash": "^4.17.20",
11
+ "foundation-sites": "^6.7.4",
12
+ "jquery": "^3.6.0",
13
+ "lodash": "^4.17.21",
12
14
  "prop-types": "^15.7.2",
13
15
  "react": "^16.9.0",
14
16
  "react-dom": "^16.9.0",
15
- "react_ujs": "^2.6.0"
17
+ "react-tagsinput": "^3.19.0",
18
+ "react_ujs": "^2.6.0",
19
+ "webpack": "^4.46.0",
20
+ "webpack-cli": "^3.3.12"
16
21
  },
17
22
  "devDependencies": {
18
- "eslint": "^6.5.1",
19
- "eslint-plugin-import": "^2.18.2",
20
- "eslint-plugin-react": "^7.16.0",
21
- "webpack": "~4",
22
- "webpack-dev-server": "^3.8.1"
23
+ "babel-eslint": "^10.1.0",
24
+ "eslint": "^7.23.0",
25
+ "eslint-config-prettier": "^8.1.0",
26
+ "eslint-config-react-app": "^6.0.0",
27
+ "eslint-plugin-flowtype": "^5.6.0",
28
+ "eslint-plugin-import": "^2.22.1",
29
+ "eslint-plugin-jsx-a11y": "^6.4.1",
30
+ "eslint-plugin-prettier": "^3.3.1",
31
+ "eslint-plugin-react": "^7.23.1",
32
+ "eslint-plugin-react-hooks": "^4.2.0",
33
+ "prettier": "^2.2.1",
34
+ "stylelint": "^13.12.0",
35
+ "stylelint-config-prettier": "^8.0.2",
36
+ "stylelint-config-sass-guidelines": "^8.0.0",
37
+ "stylelint-prettier": "^1.2.0",
38
+ "stylelint-selector-bem-pattern": "^2.1.0",
39
+ "webpack-dev-server": "^3"
23
40
  },
24
41
  "scripts": {
25
- "lint:scss": "sass-lint '**/*.scss' -v -q"
42
+ "lint": "eslint --ext .js --ext .jsx app/javascript && stylelint 'app/assets/stylesheets/**/*.{css,scss}' --quiet",
43
+ "lint:js": "eslint --ext .js --ext .jsx app/javascript",
44
+ "lint:js:fix": "eslint --ext .js --ext .jsx app/javascript --quiet --fix",
45
+ "lint:scss": "stylelint 'app/assets/stylesheets/**/*.{css,scss}' --quiet",
46
+ "lint:scss:fix": "stylelint 'app/assets/stylesheets/**/*.{css,scss}' --quiet --fix"
26
47
  },
27
48
  "repository": {
28
49
  "type": "git",
29
50
  "url": "git+https://github.com/learningtapestry/lcms-engine.git"
30
51
  },
31
52
  "engines": {
32
- "node": ">=10.16.1",
53
+ "node": ">=14.17.0",
33
54
  "yarn": ">=1.17.1"
34
55
  },
35
56
  "author": "Alexander Kuznetsov <paranoic.san@gmail.com>",
data/postcss.config.js ADDED
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ plugins: [
3
+ require('postcss-import'),
4
+ require('postcss-flexbugs-fixes'),
5
+ require('postcss-preset-env')({
6
+ autoprefixer: {
7
+ flexbox: 'no-2009'
8
+ },
9
+ stage: 3
10
+ })
11
+ ]
12
+ }
@@ -12,4 +12,27 @@ describe Lcms::Engine::Admin::CurriculumsController do
12
12
 
13
13
  it { is_expected.to be_successful }
14
14
  end
15
+
16
+ describe '#children' do
17
+ let(:id) { resource.id }
18
+ let(:resource) { create(:resource, :module) }
19
+ let!(:children) { create_list(:resource, 3, parent: resource) }
20
+
21
+ subject { get :children, params: { id: id } }
22
+
23
+ it 'returns children of the requested resource' do
24
+ JSON.parse(subject.body).each do |data|
25
+ child = ::Lcms::Engine::Resource.find(data['id'])
26
+ expect(child.parent_id).to eq id
27
+ end
28
+ end
29
+
30
+ context 'when # is requested' do
31
+ let(:id) { '#' }
32
+
33
+ it 'returns root resources' do
34
+ expect(JSON.parse(subject.body).first['id']).to eq resource.id
35
+ end
36
+ end
37
+ end
15
38
  end
@@ -27,7 +27,7 @@ describe Lcms::Engine::Admin::DocumentsController do
27
27
 
28
28
  it 'redirects to document' do
29
29
  subject
30
- expect(response).to redirect_to Lcms::Engine::Admin::AdminController.document_path(document)
30
+ expect(response).to redirect_to document_path(document)
31
31
  end
32
32
 
33
33
  # TODO: Rails upgrade - move to system spec
@@ -53,7 +53,7 @@ describe Lcms::Engine::Admin::DocumentsController do
53
53
 
54
54
  it 'calls batch reimport' do
55
55
  expect(Lcms::Engine::DocumentGenerator).to \
56
- receive_message_chain(:document_parse_job, :perform_later).and_return(OpenStruct.new(job_id: 0))
56
+ receive_message_chain(:document_parse_job, :perform_later).and_return(double('response', job_id: 0))
57
57
  subject
58
58
  end
59
59
 
@@ -71,6 +71,18 @@ describe Lcms::Engine::Admin::DocumentsController do
71
71
  end
72
72
  end
73
73
  end
74
+
75
+ context 'when asynchronous import was requested' do
76
+ let(:link) { 'https://google.com/somefile' }
77
+ let(:params) { { async: '1', link: link } }
78
+
79
+ before { allow(controller).to receive(:bulk_import) }
80
+
81
+ it 'calls bulk import for that particular document' do
82
+ expect(controller).to receive(:bulk_import).with(Array.wrap(link))
83
+ subject
84
+ end
85
+ end
74
86
  end
75
87
 
76
88
  describe '#destroy' do
@@ -81,6 +93,14 @@ describe Lcms::Engine::Admin::DocumentsController do
81
93
  it 'deletes the document' do
82
94
  expect { subject }.to change(Lcms::Engine::Document, :count).by(-1)
83
95
  end
96
+
97
+ context 'when there was custom filter' do
98
+ let(:query) { { course: 'value' } }
99
+
100
+ subject { delete :destroy, params: { id: document.id, query: query } }
101
+
102
+ it { is_expected.to redirect_to "/lcms-engine/admin/documents?#{{ query: query }.to_param}" }
103
+ end
84
104
  end
85
105
 
86
106
  describe '#new' do
@@ -3,6 +3,8 @@
3
3
  require 'rails_helper'
4
4
 
5
5
  describe Lcms::Engine::Admin::MaterialsController do
6
+ include Lcms::Engine::PathHelper
7
+
6
8
  let(:user) { create :admin }
7
9
 
8
10
  before { sign_in user }
@@ -25,7 +27,7 @@ describe Lcms::Engine::Admin::MaterialsController do
25
27
 
26
28
  it 'redirects to material' do
27
29
  subject
28
- expect(response).to redirect_to Lcms::Engine::Admin::AdminController.material_path(material)
30
+ expect(response).to redirect_to material_path(material)
29
31
  end
30
32
 
31
33
  context 'when there is an error' do
@@ -51,7 +53,7 @@ describe Lcms::Engine::Admin::MaterialsController do
51
53
 
52
54
  it 'calls batch reimport' do
53
55
  expect(Lcms::Engine::DocumentGenerator).to \
54
- receive_message_chain(:material_parse_job, :perform_later).and_return(OpenStruct.new(job_id: 0))
56
+ receive_message_chain(:material_parse_job, :perform_later).and_return(double('response', job_id: 0))
55
57
  subject
56
58
  end
57
59
 
@@ -69,6 +71,17 @@ describe Lcms::Engine::Admin::MaterialsController do
69
71
  end
70
72
  end
71
73
  end
74
+
75
+ context 'when asynchronous import was requested' do
76
+ let(:params) { { async: '1', link: link } }
77
+
78
+ before { allow(controller).to receive(:bulk_import) }
79
+
80
+ it 'calls bulk import for that particular document' do
81
+ expect(controller).to receive(:bulk_import).with(Array.wrap(link))
82
+ subject
83
+ end
84
+ end
72
85
  end
73
86
 
74
87
  describe '#destroy' do
@@ -83,7 +96,7 @@ describe Lcms::Engine::Admin::MaterialsController do
83
96
 
84
97
  subject { delete :destroy, params: { id: material.id, query: query } }
85
98
 
86
- it { is_expected.to redirect_to admin_materials_path(query: query) }
99
+ it { is_expected.to redirect_to "/lcms-engine/admin/materials?#{{ query: query }.to_param}" }
87
100
  end
88
101
  end
89
102
 
@@ -22,7 +22,7 @@ describe Lcms::Engine::Admin::ResourceBulkEditsController do
22
22
  grades = resources.flat_map { |r| r.grades.list }
23
23
  expect(grades).to_not include('grade 11')
24
24
  post :create, params: { ids: ids, resource: { grades: ['grade 11'] } }
25
- expect(response).to redirect_to(:admin_resources)
25
+ expect(response).to redirect_to(lcms_engine(admin_resources_path))
26
26
  resources.each do |r|
27
27
  expect(r.reload.grades.list).to include('grade 11')
28
28
  end
@@ -27,7 +27,7 @@ describe Lcms::Engine::Admin::ResourcesController do
27
27
  subject { post :update, params: { id: resource.to_param, resource: params } }
28
28
 
29
29
  context 'with valid params' do
30
- it { is_expected.to redirect_to admin_resources_path }
30
+ it { is_expected.to redirect_to lcms_engine(admin_resources_path) }
31
31
 
32
32
  it 'passes notice' do
33
33
  subject
@@ -11,6 +11,6 @@ describe Lcms::Engine::Admin::SettingsController do
11
11
  expect(Lcms::Engine::Settings[:editing_enabled]).to be true
12
12
  patch :toggle_editing_enabled
13
13
  expect(Lcms::Engine::Settings[:editing_enabled]).to be false
14
- expect(response).to redirect_to(:admin_resources)
14
+ expect(response).to redirect_to(lcms_engine(admin_resources_path))
15
15
  end
16
16
  end
@@ -60,7 +60,7 @@ describe Lcms::Engine::Admin::StandardsController do
60
60
  subject { post :update, params: { id: standard.to_param, standard: params } }
61
61
 
62
62
  context 'with valid params' do
63
- it { is_expected.to redirect_to admin_standards_path }
63
+ it { is_expected.to redirect_to lcms_engine(admin_standards_path) }
64
64
 
65
65
  it 'passes notice' do
66
66
  subject