uchi 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +222 -0
  3. data/app/assets/config/uchi_manifest.js +2 -0
  4. data/app/assets/javascripts/uchi/application.js +6095 -0
  5. data/app/assets/javascripts/uchi.js +4 -0
  6. data/app/assets/stylesheets/uchi/application.css +3971 -0
  7. data/app/assets/stylesheets/uchi/uchi.css +17 -0
  8. data/app/assets/tailwind/uchi.css +21 -0
  9. data/app/components/flowbite/breadcrumb.rb +33 -0
  10. data/app/components/flowbite/breadcrumb_home.rb +26 -0
  11. data/app/components/flowbite/breadcrumb_item/current.rb +33 -0
  12. data/app/components/flowbite/breadcrumb_item/first.rb +35 -0
  13. data/app/components/flowbite/breadcrumb_item.rb +48 -0
  14. data/app/components/flowbite/breadcrumb_separator.rb +30 -0
  15. data/app/components/flowbite/button/outline.rb +22 -0
  16. data/app/components/flowbite/button/pill.rb +40 -0
  17. data/app/components/flowbite/button.rb +92 -0
  18. data/app/components/flowbite/card.rb +45 -0
  19. data/app/components/flowbite/input/checkbox.rb +73 -0
  20. data/app/components/flowbite/input/date.rb +11 -0
  21. data/app/components/flowbite/input/date_time.rb +11 -0
  22. data/app/components/flowbite/input/email.rb +12 -0
  23. data/app/components/flowbite/input/field.rb +117 -0
  24. data/app/components/flowbite/input/file.rb +30 -0
  25. data/app/components/flowbite/input/hint.rb +57 -0
  26. data/app/components/flowbite/input/label.rb +82 -0
  27. data/app/components/flowbite/input/number.rb +11 -0
  28. data/app/components/flowbite/input/password.rb +11 -0
  29. data/app/components/flowbite/input/phone.rb +11 -0
  30. data/app/components/flowbite/input/radio_button.rb +50 -0
  31. data/app/components/flowbite/input/select.rb +49 -0
  32. data/app/components/flowbite/input/textarea.rb +42 -0
  33. data/app/components/flowbite/input/url.rb +12 -0
  34. data/app/components/flowbite/input/validation_error.rb +11 -0
  35. data/app/components/flowbite/input_field/checkbox.html.erb +14 -0
  36. data/app/components/flowbite/input_field/checkbox.rb +54 -0
  37. data/app/components/flowbite/input_field/date.rb +13 -0
  38. data/app/components/flowbite/input_field/date_time.rb +13 -0
  39. data/app/components/flowbite/input_field/email.rb +13 -0
  40. data/app/components/flowbite/input_field/file.rb +13 -0
  41. data/app/components/flowbite/input_field/input_field.html.erb +8 -0
  42. data/app/components/flowbite/input_field/number.rb +13 -0
  43. data/app/components/flowbite/input_field/password.rb +13 -0
  44. data/app/components/flowbite/input_field/phone.rb +13 -0
  45. data/app/components/flowbite/input_field/radio_button.html.erb +14 -0
  46. data/app/components/flowbite/input_field/radio_button.rb +86 -0
  47. data/app/components/flowbite/input_field/select.rb +31 -0
  48. data/app/components/flowbite/input_field/text.rb +8 -0
  49. data/app/components/flowbite/input_field/textarea.rb +13 -0
  50. data/app/components/flowbite/input_field/url.rb +13 -0
  51. data/app/components/flowbite/input_field.rb +192 -0
  52. data/app/components/flowbite/link.rb +21 -0
  53. data/app/components/flowbite/style.rb +13 -0
  54. data/app/components/flowbite/toast/icon.html.erb +5 -0
  55. data/app/components/flowbite/toast/icon.rb +57 -0
  56. data/app/components/flowbite/toast/toast.html.erb +11 -0
  57. data/app/components/flowbite/toast.rb +34 -0
  58. data/app/components/uchi/field/base.rb +57 -0
  59. data/app/components/uchi/field/belongs_to/edit.html.erb +1 -0
  60. data/app/components/uchi/field/belongs_to/index.html.erb +1 -0
  61. data/app/components/uchi/field/belongs_to/show.html.erb +3 -0
  62. data/app/components/uchi/field/belongs_to.rb +105 -0
  63. data/app/components/uchi/field/blank/edit.html.erb +1 -0
  64. data/app/components/uchi/field/blank/index.html.erb +1 -0
  65. data/app/components/uchi/field/blank/show.html.erb +1 -0
  66. data/app/components/uchi/field/blank.rb +16 -0
  67. data/app/components/uchi/field/boolean/edit.html.erb +1 -0
  68. data/app/components/uchi/field/boolean/index.html.erb +9 -0
  69. data/app/components/uchi/field/boolean/show.html.erb +9 -0
  70. data/app/components/uchi/field/boolean.rb +27 -0
  71. data/app/components/uchi/field/date/edit.html.erb +1 -0
  72. data/app/components/uchi/field/date/index.html.erb +1 -0
  73. data/app/components/uchi/field/date/show.html.erb +1 -0
  74. data/app/components/uchi/field/date.rb +27 -0
  75. data/app/components/uchi/field/date_time/edit.html.erb +1 -0
  76. data/app/components/uchi/field/date_time/index.html.erb +1 -0
  77. data/app/components/uchi/field/date_time/show.html.erb +1 -0
  78. data/app/components/uchi/field/date_time.rb +27 -0
  79. data/app/components/uchi/field/file/edit.html.erb +1 -0
  80. data/app/components/uchi/field/file/index.html.erb +6 -0
  81. data/app/components/uchi/field/file/show.html.erb +8 -0
  82. data/app/components/uchi/field/file.rb +37 -0
  83. data/app/components/uchi/field/has_and_belongs_to_many/edit.html.erb +9 -0
  84. data/app/components/uchi/field/has_and_belongs_to_many/index.html.erb +1 -0
  85. data/app/components/uchi/field/has_and_belongs_to_many/show.html.erb +28 -0
  86. data/app/components/uchi/field/has_and_belongs_to_many.rb +131 -0
  87. data/app/components/uchi/field/has_many/edit.html.erb +1 -0
  88. data/app/components/uchi/field/has_many/index.html.erb +1 -0
  89. data/app/components/uchi/field/has_many/show.html.erb +28 -0
  90. data/app/components/uchi/field/has_many.rb +107 -0
  91. data/app/components/uchi/field/id/index.html.erb +4 -0
  92. data/app/components/uchi/field/id/show.html.erb +4 -0
  93. data/app/components/uchi/field/id.rb +26 -0
  94. data/app/components/uchi/field/image/edit.html.erb +1 -0
  95. data/app/components/uchi/field/image/index.html.erb +6 -0
  96. data/app/components/uchi/field/image/show.html.erb +6 -0
  97. data/app/components/uchi/field/image.rb +38 -0
  98. data/app/components/uchi/field/number/edit.html.erb +1 -0
  99. data/app/components/uchi/field/number/index.html.erb +1 -0
  100. data/app/components/uchi/field/number/show.html.erb +1 -0
  101. data/app/components/uchi/field/number.rb +32 -0
  102. data/app/components/uchi/field/string/edit.html.erb +1 -0
  103. data/app/components/uchi/field/string/index.html.erb +1 -0
  104. data/app/components/uchi/field/string/show.html.erb +1 -0
  105. data/app/components/uchi/field/string.rb +33 -0
  106. data/app/components/uchi/field/text/edit.html.erb +1 -0
  107. data/app/components/uchi/field/text/index.html.erb +1 -0
  108. data/app/components/uchi/field/text/show.html.erb +1 -0
  109. data/app/components/uchi/field/text.rb +38 -0
  110. data/app/components/uchi/ui/breadcrumb/breadcrumb.html.erb +13 -0
  111. data/app/components/uchi/ui/breadcrumb.rb +14 -0
  112. data/app/components/uchi/ui/form/footer/footer.html.erb +5 -0
  113. data/app/components/uchi/ui/form/footer.rb +15 -0
  114. data/app/components/uchi/ui/form/input/collection_checkboxes.html.erb +32 -0
  115. data/app/components/uchi/ui/form/input/collection_checkboxes.rb +125 -0
  116. data/app/components/uchi/ui/frame/frame.html.erb +3 -0
  117. data/app/components/uchi/ui/frame.rb +10 -0
  118. data/app/components/uchi/ui/index/records_table/records_table.html.erb +67 -0
  119. data/app/components/uchi/ui/index/records_table/search_form/search_form.html.erb +21 -0
  120. data/app/components/uchi/ui/index/records_table/search_form.rb +49 -0
  121. data/app/components/uchi/ui/index/records_table.rb +29 -0
  122. data/app/components/uchi/ui/index/turbo_frame.rb +50 -0
  123. data/app/components/uchi/ui/page_header/page_header.html.erb +24 -0
  124. data/app/components/uchi/ui/page_header.rb +18 -0
  125. data/app/components/uchi/ui/pagination/current_link.html.erb +3 -0
  126. data/app/components/uchi/ui/pagination/current_link.rb +10 -0
  127. data/app/components/uchi/ui/pagination/gap.html.erb +3 -0
  128. data/app/components/uchi/ui/pagination/gap.rb +10 -0
  129. data/app/components/uchi/ui/pagination/item.rb +24 -0
  130. data/app/components/uchi/ui/pagination/link.html.erb +3 -0
  131. data/app/components/uchi/ui/pagination/link.rb +10 -0
  132. data/app/components/uchi/ui/pagination/next_link.html.erb +8 -0
  133. data/app/components/uchi/ui/pagination/next_link.rb +22 -0
  134. data/app/components/uchi/ui/pagination/pagination.html.erb +15 -0
  135. data/app/components/uchi/ui/pagination/previous_link.html.erb +8 -0
  136. data/app/components/uchi/ui/pagination/previous_link.rb +22 -0
  137. data/app/components/uchi/ui/pagination.rb +48 -0
  138. data/app/components/uchi/ui/show/attribute_fields/attribute_fields.html.erb +14 -0
  139. data/app/components/uchi/ui/show/attribute_fields.rb +18 -0
  140. data/app/components/uchi/ui/spinner/spinner.html.erb +7 -0
  141. data/app/components/uchi/ui/spinner.rb +15 -0
  142. data/app/controllers/uchi/application_controller.rb +4 -0
  143. data/app/controllers/uchi/controller.rb +13 -0
  144. data/app/controllers/uchi/repository_controller.rb +166 -0
  145. data/app/helpers/uchi/application_helper.rb +17 -0
  146. data/app/jobs/uchi/application_job.rb +4 -0
  147. data/app/mailers/uchi/application_mailer.rb +6 -0
  148. data/app/views/layouts/uchi/_flash_messages.html.erb +10 -0
  149. data/app/views/layouts/uchi/application.html.erb +33 -0
  150. data/app/views/uchi/repository/edit.html.erb +40 -0
  151. data/app/views/uchi/repository/index.html.erb +49 -0
  152. data/app/views/uchi/repository/new.html.erb +37 -0
  153. data/app/views/uchi/repository/show.html.erb +41 -0
  154. data/lib/generators/uchi/controller/controller_generator.rb +16 -0
  155. data/lib/generators/uchi/controller/templates/controller.rb.tt +11 -0
  156. data/lib/generators/uchi/install/install_generator.rb +13 -0
  157. data/lib/generators/uchi/repository/repository_generator.rb +16 -0
  158. data/lib/generators/uchi/repository/templates/repository.rb.tt +11 -0
  159. data/lib/tasks/uchi_tasks.rake +4 -0
  160. data/lib/uchi/application_record.rb +5 -0
  161. data/lib/uchi/engine.rb +24 -0
  162. data/lib/uchi/field/configuration.rb +142 -0
  163. data/lib/uchi/field.rb +80 -0
  164. data/lib/uchi/i18n.rb +13 -0
  165. data/lib/uchi/pagination/controller.rb +26 -0
  166. data/lib/uchi/pagination/page.rb +20 -0
  167. data/lib/uchi/pagy/LICENSE.txt +21 -0
  168. data/lib/uchi/pagy/classes/exceptions.rb +35 -0
  169. data/lib/uchi/pagy/classes/offset/offset.rb +56 -0
  170. data/lib/uchi/pagy/classes/request.rb +38 -0
  171. data/lib/uchi/pagy/modules/abilities/configurable.rb +38 -0
  172. data/lib/uchi/pagy/modules/abilities/linkable.rb +62 -0
  173. data/lib/uchi/pagy/modules/abilities/rangeable.rb +17 -0
  174. data/lib/uchi/pagy/modules/abilities/shiftable.rb +14 -0
  175. data/lib/uchi/pagy/modules/console.rb +40 -0
  176. data/lib/uchi/pagy/toolbox/helpers/loader.rb +19 -0
  177. data/lib/uchi/pagy/toolbox/helpers/page_url.rb +25 -0
  178. data/lib/uchi/pagy/toolbox/paginators/method.rb +21 -0
  179. data/lib/uchi/pagy/toolbox/paginators/offset.rb +35 -0
  180. data/lib/uchi/pagy.rb +60 -0
  181. data/lib/uchi/repository/routes.rb +62 -0
  182. data/lib/uchi/repository/translate.rb +284 -0
  183. data/lib/uchi/repository.rb +156 -0
  184. data/lib/uchi/sort_order.rb +35 -0
  185. data/lib/uchi/version.rb +5 -0
  186. data/lib/uchi.rb +18 -0
  187. data/uchi.gemspec +35 -0
  188. metadata +189 -97
  189. data/.github/dependabot.yml +0 -17
  190. data/.github/workflows/build.yml +0 -23
  191. data/.github/workflows/lint.yml +0 -30
  192. data/CHANGELOG.md +0 -29
  193. data/docs/fields.md +0 -82
  194. data/docs/repositories.md +0 -63
  195. data/package.json +0 -31
  196. data/sig/uchi.rbs +0 -4
  197. data/test/components/uchi/field/belongs_to_test.rb +0 -134
  198. data/test/components/uchi/field/blank_test.rb +0 -119
  199. data/test/components/uchi/field/boolean_test.rb +0 -163
  200. data/test/components/uchi/field/date_test.rb +0 -163
  201. data/test/components/uchi/field/date_time_test.rb +0 -152
  202. data/test/components/uchi/field/has_and_belongs_to_many_test.rb +0 -144
  203. data/test/components/uchi/field/has_many_test.rb +0 -138
  204. data/test/components/uchi/field/id_test.rb +0 -113
  205. data/test/components/uchi/field/number_test.rb +0 -163
  206. data/test/components/uchi/field/string_test.rb +0 -159
  207. data/test/components/uchi/field/text_test.rb +0 -160
  208. data/test/components/uchi/ui/form/input/collection_checkboxes_test.rb +0 -171
  209. data/test/controllers/uchi/authors_controller_test.rb +0 -120
  210. data/test/controllers/uchi/repository_controller_test.rb +0 -93
  211. data/test/controllers/uchi/scoped_repository_controller_test.rb +0 -73
  212. data/test/dummy/Rakefile +0 -6
  213. data/test/dummy/app/assets/images/.keep +0 -0
  214. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  215. data/test/dummy/app/controllers/application_controller.rb +0 -4
  216. data/test/dummy/app/controllers/concerns/.keep +0 -0
  217. data/test/dummy/app/controllers/uchi/authors_controller.rb +0 -7
  218. data/test/dummy/app/controllers/uchi/books_controller.rb +0 -7
  219. data/test/dummy/app/controllers/uchi/titles_controller.rb +0 -7
  220. data/test/dummy/app/helpers/application_helper.rb +0 -2
  221. data/test/dummy/app/jobs/application_job.rb +0 -7
  222. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  223. data/test/dummy/app/models/application_record.rb +0 -3
  224. data/test/dummy/app/models/author.rb +0 -5
  225. data/test/dummy/app/models/book.rb +0 -4
  226. data/test/dummy/app/models/concerns/.keep +0 -0
  227. data/test/dummy/app/models/title.rb +0 -3
  228. data/test/dummy/app/uchi/repositories/author.rb +0 -20
  229. data/test/dummy/app/uchi/repositories/book.rb +0 -16
  230. data/test/dummy/app/uchi/repositories/title.rb +0 -17
  231. data/test/dummy/app/views/layouts/application.html.erb +0 -27
  232. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  233. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  234. data/test/dummy/app/views/pwa/manifest.json.erb +0 -22
  235. data/test/dummy/app/views/pwa/service-worker.js +0 -26
  236. data/test/dummy/bin/dev +0 -2
  237. data/test/dummy/bin/rails +0 -4
  238. data/test/dummy/bin/rake +0 -4
  239. data/test/dummy/bin/setup +0 -34
  240. data/test/dummy/config/application.rb +0 -29
  241. data/test/dummy/config/boot.rb +0 -5
  242. data/test/dummy/config/cable.yml +0 -10
  243. data/test/dummy/config/database.yml +0 -32
  244. data/test/dummy/config/environment.rb +0 -5
  245. data/test/dummy/config/environments/development.rb +0 -69
  246. data/test/dummy/config/environments/production.rb +0 -89
  247. data/test/dummy/config/environments/test.rb +0 -53
  248. data/test/dummy/config/initializers/content_security_policy.rb +0 -25
  249. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -8
  250. data/test/dummy/config/initializers/inflections.rb +0 -16
  251. data/test/dummy/config/locales/da.yml +0 -52
  252. data/test/dummy/config/locales/en.yml +0 -31
  253. data/test/dummy/config/puma.rb +0 -38
  254. data/test/dummy/config/routes.rb +0 -9
  255. data/test/dummy/config/storage.yml +0 -34
  256. data/test/dummy/config.ru +0 -6
  257. data/test/dummy/db/migrate/20251002183635_create_authors.rb +0 -11
  258. data/test/dummy/db/migrate/20251005131726_create_books.rb +0 -9
  259. data/test/dummy/db/migrate/20251005131811_create_titles.rb +0 -11
  260. data/test/dummy/db/migrate/20251031140958_add_author_books_join_table.rb +0 -9
  261. data/test/dummy/db/schema.rb +0 -44
  262. data/test/dummy/log/.keep +0 -0
  263. data/test/dummy/public/400.html +0 -114
  264. data/test/dummy/public/404.html +0 -114
  265. data/test/dummy/public/406-unsupported-browser.html +0 -114
  266. data/test/dummy/public/422.html +0 -114
  267. data/test/dummy/public/500.html +0 -114
  268. data/test/dummy/public/icon.png +0 -0
  269. data/test/dummy/public/icon.svg +0 -3
  270. data/test/dummy/storage/.keep +0 -0
  271. data/test/dummy/test/fixtures/authors.yml +0 -11
  272. data/test/dummy/test/models/author_test.rb +0 -7
  273. data/test/dummy/tmp/.keep +0 -0
  274. data/test/dummy/tmp/pids/.keep +0 -0
  275. data/test/dummy/tmp/storage/.keep +0 -0
  276. data/test/test_helper.rb +0 -15
  277. data/test/uchi/field_test.rb +0 -77
  278. data/test/uchi/i18n_test.rb +0 -18
  279. data/test/uchi/repository/routes_test.rb +0 -49
  280. data/test/uchi/repository/translate_test.rb +0 -272
  281. data/test/uchi/repository_test.rb +0 -137
  282. data/test/uchi/sort_order_test.rb +0 -47
  283. data/test/uchi_test.rb +0 -7
@@ -1,120 +0,0 @@
1
- require "test_helper"
2
-
3
- module Uchi
4
- class AuthorsControllerTest < ActionDispatch::IntegrationTest
5
- setup do
6
- @author = Author.create!(name: "Test Author")
7
- end
8
-
9
- test "GET edit renders successfully" do
10
- get edit_uchi_author_url(id: @author.id)
11
- assert_response :success
12
- end
13
-
14
- test "GET edit renders the edit view" do
15
- get edit_uchi_author_url(id: @author.id)
16
- assert_template :edit
17
- end
18
-
19
- test "GET index responds successfully" do
20
- get uchi_authors_url
21
- assert_response :success
22
- end
23
-
24
- test "GET index renders the index view" do
25
- get uchi_authors_url
26
- assert_template :index
27
- end
28
-
29
- test "GET new renders successfully" do
30
- get new_uchi_author_url
31
- assert_response :success
32
- end
33
-
34
- test "GET new renders the new view" do
35
- get new_uchi_author_url
36
- assert_template :new
37
- end
38
-
39
- test "GET show responds successfully" do
40
- get uchi_author_url(id: @author.id)
41
- assert_response :success
42
- end
43
-
44
- test "GET show renders the show view" do
45
- get uchi_author_url(id: @author.id)
46
- assert_template :show
47
- end
48
-
49
- test "PATCH update redirects to show after successful update" do
50
- srand(42)
51
- patch uchi_author_url(id: @author.id), params: {author: {name: "Updated Name"}}
52
- assert_redirected_to uchi_author_url(id: @author.id, uniq: 0.3745401188473625)
53
- end
54
-
55
- test "PATCH update responds with 303 after successful update" do
56
- patch uchi_author_url(id: @author.id), params: {author: {name: "Updated Name"}}
57
- assert_response :see_other
58
- end
59
-
60
- test "PATCH update changes the author's attributes" do
61
- patch uchi_author_url(id: @author.id), params: {author: {name: "Updated Name"}}
62
- @author.reload
63
- assert_equal "Updated Name", @author.name
64
- end
65
-
66
- test "PATCH update flashes a translated success message after successful update" do
67
- ::I18n.with_locale(:da) do
68
- patch uchi_author_url(id: @author.id), params: {author: {name: "Updated Name"}}
69
- assert_equal "Dine ændringer til forfatteren blev gemt", flash[:success]
70
- end
71
- end
72
-
73
- test "PATCH update falls back to default success message after successful update" do
74
- patch uchi_author_url(id: @author.id), params: {author: {name: "Updated Name"}}
75
- assert_equal "Your changes have been saved", flash[:success]
76
- end
77
-
78
- test "PATCH update rerenders the edit view after unsuccessful update" do
79
- patch uchi_author_url(id: @author.id), params: {author: {name: ""}}
80
- assert_template :edit
81
- end
82
-
83
- test "PATCH responds with 422 after unsuccessful update" do
84
- patch uchi_author_url(id: @author.id), params: {author: {name: ""}}
85
- assert_response :unprocessable_entity
86
- end
87
-
88
- test "POST create redirects to show after successful creation" do
89
- post uchi_authors_url, params: {author: {name: "New Author"}}
90
- assert_redirected_to uchi_author_url(id: Author.last.id)
91
- end
92
-
93
- test "POST create responds with 303 after successful creation" do
94
- post uchi_authors_url, params: {author: {name: "New Author"}}
95
- assert_response :see_other
96
- end
97
-
98
- test "POST create flashes a translated success message after successful creation" do
99
- ::I18n.with_locale(:da) do
100
- post uchi_authors_url, params: {author: {name: "New Author"}}
101
- assert_equal "Forfatteren er blevet tilføjet", flash[:success]
102
- end
103
- end
104
-
105
- test "POST create creates a new author" do
106
- post uchi_authors_url, params: {author: {name: "New Author"}}
107
- assert_equal "New Author", Author.last.name
108
- end
109
-
110
- test "POST create rerenders the new view after unsuccessful creation" do
111
- post uchi_authors_url, params: {author: {name: ""}}
112
- assert_template :new
113
- end
114
-
115
- test "POST create responds with 422 after unsuccessful creation" do
116
- post uchi_authors_url, params: {author: {name: ""}}
117
- assert_response :unprocessable_entity
118
- end
119
- end
120
- end
@@ -1,93 +0,0 @@
1
- require "test_helper"
2
-
3
- module Uchi
4
- class RepositoryControllerTest < ActionDispatch::IntegrationTest
5
- setup do
6
- @book = Book.create!(original_title: "The Hobbit")
7
- end
8
-
9
- test "DELETE destroy deletes the record" do
10
- delete uchi_book_url(id: @book.id)
11
-
12
- assert_not Book.exists?(@book.id)
13
- end
14
-
15
- test "DELETE destroy redirects to index" do
16
- delete uchi_book_url(id: @book.id)
17
-
18
- assert_redirected_to uchi_books_url
19
- end
20
-
21
- test "GET edit responds successfully" do
22
- get edit_uchi_book_url(id: @book.id)
23
- assert_response :success
24
- end
25
-
26
- test "GET edit renders a form for updating the model" do
27
- get edit_uchi_book_url(id: @book.id)
28
- assert_select "form[action=?][method='post']", uchi_book_path(id: @book.id)
29
- end
30
-
31
- test "GET edit links back to the model" do
32
- get edit_uchi_book_url(id: @book.id)
33
- assert_select "a[href=?]", uchi_book_path(id: @book.id), text: "Cancel"
34
- end
35
-
36
- test "GET index links to show for each record" do
37
- get uchi_books_url
38
-
39
- assert_select "tr td a[data-turbo-frame='_top'][href=?]", uchi_book_path(id: @book.id)
40
- end
41
-
42
- test "GET index links to edit for each record" do
43
- get uchi_books_url
44
- assert_select "tr td a[data-turbo-frame='_top'][href=?]", edit_uchi_book_path(id: @book.id)
45
- end
46
-
47
- test "GET new responds successfully" do
48
- get new_uchi_book_url
49
- assert_response :success
50
- end
51
-
52
- test "GET new renders a form to create a new model" do
53
- get new_uchi_book_url
54
- assert_select "form[action=?][method='post']", uchi_books_path
55
- end
56
-
57
- test "GET new links back to the index" do
58
- get new_uchi_book_url
59
- assert_select "a[href=?]", uchi_books_path, text: "Cancel"
60
- end
61
-
62
- test "GET show responds successfully" do
63
- get uchi_book_url(id: @book.id)
64
- assert_response :success
65
- end
66
-
67
- test "GET show renders the show view" do
68
- get uchi_book_url(id: @book.id)
69
- assert_template :show
70
- end
71
-
72
- test "GET show includes a button to delete the record" do
73
- get uchi_book_url(id: @book.id)
74
- assert_select "form[action=?]", uchi_book_path(id: @book.id), text: "Delete"
75
- end
76
-
77
- test "GET show includes a turbo-frame that loads the titles in a scoped index view" do
78
- get uchi_book_url(id: @book.id)
79
-
80
- assert_select "turbo-frame[src]" do |node_set|
81
- tag = node_set.first
82
- src = tag.attributes["src"].value
83
- expected_src = uchi_titles_path(scope: {
84
- model: "Book",
85
- id: @book.id,
86
- field: "titles",
87
- inverse_of: "book"
88
- })
89
- assert_equal expected_src, src
90
- end
91
- end
92
- end
93
- end
@@ -1,73 +0,0 @@
1
- require "test_helper"
2
-
3
- module Uchi
4
- class ScopedRepositoryControllerTest < ActionDispatch::IntegrationTest
5
- setup do
6
- @book = Book.create!(original_title: "The Hobbit")
7
- @dk_title = Title.create!(book: @book, locale: "da-DK", title: "Hobbitten")
8
- @de_title = Title.create!(locale: "de-DE", title: "Der Hobbit", book: @book)
9
-
10
- @scope = {model: "Book", id: @book.id, field: "titles"}
11
- end
12
-
13
- test "GET edit responds successfully" do
14
- get edit_uchi_title_url(id: @dk_title.id, scope: @scope)
15
- assert_response :success
16
- end
17
-
18
- test "GET edit renders a form for updating the model" do
19
- get edit_uchi_title_url(id: @dk_title.id, scope: @scope)
20
- assert_select "form[action=?][method='post']", uchi_title_path(id: @dk_title.id)
21
- end
22
-
23
- test "GET edit links back to the scoped model" do
24
- get edit_uchi_title_url(id: @dk_title.id, scope: @scope)
25
- assert_select "a[href=?]", uchi_book_path(id: @book.id), text: "Cancel"
26
- end
27
-
28
- test "GET new responds successfully" do
29
- get new_uchi_title_url(scope: @scope)
30
- assert_response :success
31
- end
32
-
33
- test "GET new renders a form to create a new model" do
34
- get new_uchi_title_url(scope: @scope)
35
- assert_select "form[action=?][method='post']", uchi_titles_path
36
- end
37
-
38
- test "GET new links back to the scoped model" do
39
- get new_uchi_title_url(scope: @scope)
40
- assert_select "a[href=?]", uchi_book_path(id: @book.id), text: "Cancel"
41
- end
42
-
43
- test "GET index responds successfully" do
44
- get uchi_titles_url(scope: @scope)
45
- assert_response :success
46
- end
47
-
48
- test "GET index renders the index view" do
49
- get uchi_titles_url(scope: @scope)
50
- assert_template :index
51
- end
52
-
53
- test "GET index includes a turbo-frame" do
54
- get uchi_titles_url(scope: @scope)
55
- assert_select "turbo-frame"
56
- end
57
-
58
- test "GET index lists only the records associated with the parent record" do
59
- other_book = Book.create!(original_title: "1984")
60
- Title.create!(locale: "de-DE", title: "1984", book: other_book)
61
-
62
- get uchi_titles_url(scope: @scope.merge(inverse_of: "book"))
63
-
64
- assert_equal assigns(:records), [@dk_title, @de_title]
65
- end
66
-
67
- test "GET index does not include the field for the parent record" do
68
- get uchi_titles_url(scope: @scope.merge(inverse_of: "book"))
69
-
70
- assert_not assigns(:columns).find { |column| column.name == :book }
71
- end
72
- end
73
- end
data/test/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require_relative "config/application"
5
-
6
- Rails.application.load_tasks
File without changes
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,4 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
- allow_browser versions: :modern
4
- end
File without changes
@@ -1,7 +0,0 @@
1
- module Uchi
2
- class AuthorsController < Uchi::RepositoryController
3
- def repository_class
4
- Uchi::Repositories::Author
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Uchi
2
- class BooksController < Uchi::RepositoryController
3
- def repository_class
4
- Uchi::Repositories::Book
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Uchi
2
- class TitlesController < Uchi::RepositoryController
3
- def repository_class
4
- Uchi::Repositories::Title
5
- end
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,7 +0,0 @@
1
- class ApplicationJob < ActiveJob::Base
2
- # Automatically retry jobs that encountered a deadlock
3
- # retry_on ActiveRecord::Deadlocked
4
-
5
- # Most jobs are safe to ignore if the underlying records are no longer available
6
- # discard_on ActiveJob::DeserializationError
7
- end
@@ -1,4 +0,0 @@
1
- class ApplicationMailer < ActionMailer::Base
2
- default from: "from@example.com"
3
- layout "mailer"
4
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- primary_abstract_class
3
- end
@@ -1,5 +0,0 @@
1
- class Author < ApplicationRecord
2
- has_and_belongs_to_many :books
3
-
4
- validates :name, presence: true
5
- end
@@ -1,4 +0,0 @@
1
- class Book < ApplicationRecord
2
- has_and_belongs_to_many :authors
3
- has_many :titles
4
- end
File without changes
@@ -1,3 +0,0 @@
1
- class Title < ApplicationRecord
2
- belongs_to :book
3
- end
@@ -1,20 +0,0 @@
1
- module Uchi
2
- module Repositories
3
- class Author < Repository
4
- def fields
5
- [
6
- Field::Number.new(:id).on(:index, :show),
7
- Field::String.new(:name),
8
- Field::Date.new(:born_on),
9
- Field::Text.new(:biography).on(:edit, :new, :show)
10
- ]
11
- end
12
-
13
- def title(model)
14
- return nil unless model
15
-
16
- model.name
17
- end
18
- end
19
- end
20
- end
@@ -1,16 +0,0 @@
1
- module Uchi
2
- module Repositories
3
- class Book < Repository
4
- def fields
5
- [
6
- Field::HasMany.new(:titles),
7
- Field::String.new(:original_title)
8
- ]
9
- end
10
-
11
- def title(model)
12
- model.original_title
13
- end
14
- end
15
- end
16
- end
@@ -1,17 +0,0 @@
1
- module Uchi
2
- module Repositories
3
- class Title < Repository
4
- def fields
5
- [
6
- Field::BelongsTo.new(:book),
7
- Field::String.new(:locale),
8
- Field::String.new(:title)
9
- ]
10
- end
11
-
12
- def title(model)
13
- model.title
14
- end
15
- end
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= content_for(:title) || "Dummy" %></title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <meta name="apple-mobile-web-app-capable" content="yes">
7
- <meta name="mobile-web-app-capable" content="yes">
8
- <%= csrf_meta_tags %>
9
- <%= csp_meta_tag %>
10
-
11
- <%= yield :head %>
12
-
13
- <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
14
- <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
15
-
16
- <link rel="icon" href="/icon.png" type="image/png">
17
- <link rel="icon" href="/icon.svg" type="image/svg+xml">
18
- <link rel="apple-touch-icon" href="/icon.png">
19
-
20
- <%# Includes all stylesheet files in app/assets/stylesheets %>
21
- <%= stylesheet_link_tag :app %>
22
- </head>
23
-
24
- <body>
25
- <%= yield %>
26
- </body>
27
- </html>
@@ -1,13 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <style>
6
- /* Email styles need to be inline */
7
- </style>
8
- </head>
9
-
10
- <body>
11
- <%= yield %>
12
- </body>
13
- </html>
@@ -1 +0,0 @@
1
- <%= yield %>
@@ -1,22 +0,0 @@
1
- {
2
- "name": "Dummy",
3
- "icons": [
4
- {
5
- "src": "/icon.png",
6
- "type": "image/png",
7
- "sizes": "512x512"
8
- },
9
- {
10
- "src": "/icon.png",
11
- "type": "image/png",
12
- "sizes": "512x512",
13
- "purpose": "maskable"
14
- }
15
- ],
16
- "start_url": "/",
17
- "display": "standalone",
18
- "scope": "/",
19
- "description": "Dummy.",
20
- "theme_color": "red",
21
- "background_color": "red"
22
- }
@@ -1,26 +0,0 @@
1
- // Add a service worker for processing Web Push notifications:
2
- //
3
- // self.addEventListener("push", async (event) => {
4
- // const { title, options } = await event.data.json()
5
- // event.waitUntil(self.registration.showNotification(title, options))
6
- // })
7
- //
8
- // self.addEventListener("notificationclick", function(event) {
9
- // event.notification.close()
10
- // event.waitUntil(
11
- // clients.matchAll({ type: "window" }).then((clientList) => {
12
- // for (let i = 0; i < clientList.length; i++) {
13
- // let client = clientList[i]
14
- // let clientPath = (new URL(client.url)).pathname
15
- //
16
- // if (clientPath == event.notification.data.path && "focus" in client) {
17
- // return client.focus()
18
- // }
19
- // }
20
- //
21
- // if (clients.openWindow) {
22
- // return clients.openWindow(event.notification.data.path)
23
- // }
24
- // })
25
- // )
26
- // })
data/test/dummy/bin/dev DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env ruby
2
- exec "./bin/rails", "server", *ARGV
data/test/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path("../config/application", __dir__)
3
- require_relative "../config/boot"
4
- require "rails/commands"
data/test/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative "../config/boot"
3
- require "rake"
4
- Rake.application.run
data/test/dummy/bin/setup DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "fileutils"
3
-
4
- APP_ROOT = File.expand_path("..", __dir__)
5
-
6
- def system!(*args)
7
- system(*args, exception: true)
8
- end
9
-
10
- FileUtils.chdir APP_ROOT do
11
- # This script is a way to set up or update your development environment automatically.
12
- # This script is idempotent, so that you can run it at any time and get an expectable outcome.
13
- # Add necessary setup steps to this file.
14
-
15
- puts "== Installing dependencies =="
16
- system("bundle check") || system!("bundle install")
17
-
18
- # puts "\n== Copying sample files =="
19
- # unless File.exist?("config/database.yml")
20
- # FileUtils.cp "config/database.yml.sample", "config/database.yml"
21
- # end
22
-
23
- puts "\n== Preparing database =="
24
- system! "bin/rails db:prepare"
25
-
26
- puts "\n== Removing old logs and tempfiles =="
27
- system! "bin/rails log:clear tmp:clear"
28
-
29
- unless ARGV.include?("--skip-server")
30
- puts "\n== Starting development server =="
31
- $stdout.flush # flush the output before exec(2) so that it displays
32
- exec "bin/dev"
33
- end
34
- end
@@ -1,29 +0,0 @@
1
- require_relative "boot"
2
-
3
- require "rails/all"
4
-
5
- # Require the gems listed in Gemfile, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(*Rails.groups)
8
-
9
- module Dummy
10
- class Application < Rails::Application
11
- config.load_defaults Rails::VERSION::STRING.to_f
12
-
13
- # For compatibility with applications that use this config
14
- config.action_controller.include_all_helpers = false
15
-
16
- # Please, add to the `ignore` list any other `lib` subdirectories that do
17
- # not contain `.rb` files, or that should not be reloaded or eager loaded.
18
- # Common ones are `templates`, `generators`, or `middleware`, for example.
19
- config.autoload_lib(ignore: %w[assets tasks])
20
-
21
- # Configuration for the application, engines, and railties goes here.
22
- #
23
- # These settings can be overridden in specific environments using the files
24
- # in config/environments, which are processed later.
25
- #
26
- # config.time_zone = "Central Time (US & Canada)"
27
- # config.eager_load_paths << Rails.root.join("extras")
28
- end
29
- end
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
-
4
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
- $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
@@ -1,10 +0,0 @@
1
- development:
2
- adapter: async
3
-
4
- test:
5
- adapter: test
6
-
7
- production:
8
- adapter: redis
9
- url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
- channel_prefix: dummy_production