agilibox 1.0.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +321 -2
  3. data/Rakefile +4 -0
  4. data/app/assets/javascripts/agilibox/autocomplete.coffee +2 -0
  5. data/app/assets/javascripts/agilibox/checkboxes_dropdown.coffee +9 -0
  6. data/app/assets/javascripts/agilibox/modals.coffee +81 -55
  7. data/app/assets/stylesheets/agilibox/actions.sass +2 -0
  8. data/app/assets/stylesheets/agilibox/all.sass +5 -0
  9. data/app/assets/stylesheets/agilibox/buttons.sass +11 -0
  10. data/app/assets/stylesheets/agilibox/filters.sass +13 -3
  11. data/app/assets/stylesheets/agilibox/forms.sass +49 -0
  12. data/app/assets/stylesheets/agilibox/icons.sass +5 -0
  13. data/app/assets/stylesheets/agilibox/modals.sass +15 -7
  14. data/app/assets/stylesheets/agilibox/pagination.sass +7 -0
  15. data/app/assets/stylesheets/agilibox/print.sass +10 -0
  16. data/app/assets/stylesheets/agilibox/tables.sass +26 -0
  17. data/app/controllers/agilibox/application_controller.rb +2 -4
  18. data/app/controllers/agilibox/small_data/filters_controller.rb +8 -6
  19. data/app/controllers/concerns/agilibox/api_controller_concern.rb +69 -0
  20. data/app/controllers/concerns/agilibox/back_url_concern.rb +13 -5
  21. data/app/emails/agilibox/email.rb +113 -0
  22. data/app/filters/agilibox/small_data/filter.rb +19 -1
  23. data/app/filters/agilibox/small_data/filter_strategy.rb +1 -1
  24. data/app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb +3 -2
  25. data/app/filters/agilibox/small_data/filter_strategy_by_date_end.rb +3 -2
  26. data/app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb +56 -0
  27. data/app/filters/agilibox/small_data/filter_strategy_by_date_period.rb +5 -0
  28. data/app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb +5 -0
  29. data/app/filters/agilibox/small_data/filter_strategy_by_key_value.rb +14 -3
  30. data/app/filters/agilibox/small_data/filter_strategy_by_key_values.rb +13 -0
  31. data/app/filters/agilibox/small_data/filter_strategy_by_tags.rb +1 -1
  32. data/app/forms/agilibox/mini_form_object.rb +29 -0
  33. data/app/helpers/agilibox/all_helpers.rb +2 -0
  34. data/app/helpers/agilibox/bootstrap_helper.rb +62 -3
  35. data/app/helpers/agilibox/button_helper.rb +22 -13
  36. data/app/helpers/agilibox/filters_helper.rb +7 -8
  37. data/app/helpers/agilibox/font_awesome_helper.rb +67 -0
  38. data/app/helpers/agilibox/form_helper.rb +37 -14
  39. data/app/helpers/agilibox/i18n_helper.rb +5 -0
  40. data/app/helpers/agilibox/link_helper.rb +1 -1
  41. data/app/helpers/agilibox/pagination_helper.rb +18 -2
  42. data/app/helpers/agilibox/routes_helper.rb +6 -2
  43. data/app/helpers/agilibox/sorting_helper.rb +9 -4
  44. data/app/helpers/agilibox/text_helper.rb +51 -26
  45. data/app/helpers/h.rb +3 -0
  46. data/app/jobs/concerns/agilibox/setup_job_concern.rb +35 -0
  47. data/app/libs/agilibox/collection_update.rb +32 -0
  48. data/app/libs/agilibox/fcm/notifier.rb +28 -0
  49. data/app/libs/agilibox/fcm/request.rb +48 -0
  50. data/app/libs/agilibox/initialize_with.rb +20 -0
  51. data/app/libs/agilibox/mini_model_serializer/serialize.rb +30 -0
  52. data/app/libs/agilibox/mini_model_serializer/serializer.rb +23 -0
  53. data/app/libs/agilibox/monkey.rb +39 -0
  54. data/app/libs/agilibox/phone_number_sanitizer.rb +15 -0
  55. data/app/libs/agilibox/sortable_uuid_generator.rb +1 -1
  56. data/app/libs/agilibox/token_generator.rb +37 -0
  57. data/app/mailers/agilibox/application_mailer.rb +2 -0
  58. data/app/mailers/agilibox/generic_mailer.rb +9 -0
  59. data/app/models/concerns/agilibox/active_record_uuid_concern.rb +4 -2
  60. data/app/models/concerns/agilibox/default_values_concern.rb +4 -3
  61. data/app/models/concerns/agilibox/model_i18n.rb +37 -6
  62. data/app/models/concerns/agilibox/pluck_distinct.rb +13 -0
  63. data/app/models/concerns/agilibox/pluck_to_hash.rb +9 -0
  64. data/app/models/concerns/agilibox/polymorphic_id.rb +5 -2
  65. data/app/models/concerns/agilibox/search.rb +11 -13
  66. data/app/models/concerns/agilibox/timestamp_helpers.rb +17 -0
  67. data/app/serializers/agilibox/serializers/base.rb +47 -1
  68. data/app/serializers/agilibox/serializers/xlsx.rb +25 -23
  69. data/app/services/agilibox/service.rb +17 -0
  70. data/app/sms/agilibox/sms/application_sms.rb +42 -0
  71. data/app/sms/agilibox/sms/message.rb +25 -0
  72. data/app/sms/agilibox/sms/strategies/amazon_sns.rb +48 -0
  73. data/app/sms/agilibox/sms/strategies/base.rb +15 -0
  74. data/app/sms/agilibox/sms/strategies/test.rb +10 -0
  75. data/app/sms/agilibox/sms.rb +35 -0
  76. data/app/sorters/agilibox/sorter.rb +26 -0
  77. data/app/views/agilibox/_flash.html.slim +9 -0
  78. data/app/views/agilibox/forms/_checkboxes_dropdown.html.slim +14 -0
  79. data/app/views/agilibox/search/_form.html.slim +1 -6
  80. data/app/views/agilibox/search/_form_bs3.html.slim +13 -0
  81. data/app/views/agilibox/search/_form_bs4.html.slim +9 -0
  82. data/app/views/agilibox/search/_form_bs5.html.slim +8 -0
  83. data/app/views/kaminari/bootstrap4/_first_page.html.slim +2 -0
  84. data/app/views/kaminari/bootstrap4/_gap.html.slim +2 -0
  85. data/app/views/kaminari/bootstrap4/_last_page.html.slim +2 -0
  86. data/app/views/kaminari/bootstrap4/_next_page.html.slim +2 -0
  87. data/app/views/kaminari/bootstrap4/_page.html.slim +6 -0
  88. data/app/views/kaminari/bootstrap4/_paginator.html.slim +12 -0
  89. data/app/views/kaminari/bootstrap4/_prev_page.html.slim +2 -0
  90. data/config/cucumber.yml +9 -0
  91. data/config/locales/actions.en.yml +76 -0
  92. data/config/locales/actions.fr.yml +76 -0
  93. data/config/locales/attributes.en.yml +108 -0
  94. data/config/locales/attributes.fr.yml +108 -0
  95. data/config/locales/common.en.yml +0 -160
  96. data/config/locales/common.fr.yml +0 -171
  97. data/config/locales/dates.fr.yml +8 -0
  98. data/config/locales/errors.en.yml +5 -0
  99. data/config/locales/errors.fr.yml +5 -0
  100. data/db/migrate/20000101000000_enable_agilibox_extensions.rb +7 -0
  101. data/lib/agilibox/active_model_custom_error_messages.rb +23 -0
  102. data/lib/agilibox/active_model_type_cast.rb +52 -0
  103. data/lib/agilibox/config.rb +19 -0
  104. data/lib/agilibox/core_and_rails_ext.rb +2 -1
  105. data/lib/agilibox/cucumber_config.rb +53 -0
  106. data/lib/agilibox/cucumber_helpers/agilibox.rb +2 -0
  107. data/lib/agilibox/cucumber_helpers/ajax.rb +18 -0
  108. data/lib/agilibox/cucumber_helpers/apparition.rb +18 -0
  109. data/lib/agilibox/cucumber_helpers/capybara.rb +12 -0
  110. data/lib/agilibox/cucumber_helpers/capybara_selectors.rb +7 -0
  111. data/lib/agilibox/cucumber_helpers/chrome_headless.rb +16 -0
  112. data/lib/agilibox/cucumber_helpers/common_steps.rb +139 -0
  113. data/lib/agilibox/cucumber_helpers/cuprite.rb +20 -0
  114. data/lib/agilibox/cucumber_helpers/database_cleaner.rb +8 -0
  115. data/lib/agilibox/cucumber_helpers/factory_bot.rb +1 -0
  116. data/lib/agilibox/cucumber_helpers/rails.rb +1 -0
  117. data/lib/agilibox/cucumber_helpers/rspec.rb +6 -0
  118. data/lib/agilibox/cucumber_helpers/screenshots.rb +3 -0
  119. data/lib/agilibox/cucumber_helpers/select2.rb +23 -0
  120. data/lib/agilibox/cucumber_helpers/sign_in.rb +17 -0
  121. data/lib/agilibox/cucumber_helpers/simplecov.rb +1 -0
  122. data/lib/agilibox/cucumber_helpers/timecop.rb +3 -0
  123. data/lib/agilibox/cucumber_helpers/turbolinks.rb +34 -0
  124. data/lib/agilibox/cucumber_helpers/zonebie.rb +4 -0
  125. data/lib/agilibox/engine.rb +15 -0
  126. data/lib/agilibox/engine_file.rb +10 -0
  127. data/lib/agilibox/errors_middleware.rb +50 -0
  128. data/lib/agilibox/form_back_url.rb +4 -4
  129. data/lib/agilibox/rspec.rb +29 -0
  130. data/lib/agilibox/test_helpers.rb +13 -0
  131. data/lib/agilibox/version.rb +1 -1
  132. data/lib/tasks/cucumber.rake +76 -0
  133. metadata +165 -9
  134. data/app/filters/agilibox/small_data/filter_strategy_by_time_period.rb +0 -37
  135. data/lib/agilibox/active_record_comma_type_cast.rb +0 -12
@@ -4,163 +4,6 @@ en:
4
4
  "true" : "Yes"
5
5
  "false" : "No"
6
6
 
7
- actions: &actions
8
- actions : "Actions"
9
- index : "Index"
10
- list : "List"
11
- new : "New"
12
- create : "Create"
13
- read : "Read"
14
- show : "Show"
15
- details : "Détails"
16
- edit : "Edit"
17
- update : "Update"
18
- delete : "Delete"
19
- destroy : "Destroy"
20
- add : "Add"
21
- filter : "Filter"
22
- filter_by : "Filter by"
23
- sort : "Sort"
24
- sort_by : "Sort by"
25
- reset : "Reset"
26
- back : "Back"
27
- save : "Save"
28
- open : "Open"
29
- close : "Close"
30
- lock : "Lock"
31
- unlock : "Unlock"
32
- snooze : "Snooze"
33
- alert : "Alert"
34
- complete : "Complete"
35
- done : "Done"
36
- download : "Download"
37
- upload : "Upload"
38
- preview : "Preview"
39
- confirm : "Confirm this action ?"
40
- cancel : "Cancel"
41
- search : "Search"
42
- sign_in : "Sign in"
43
- signin : "Sign in"
44
- log_in : "Log in"
45
- login : "Log in"
46
- sign_out : "Sign out"
47
- signout : "Sign out"
48
- log_out : "Log out"
49
- logout : "Log out"
50
- sign_up : "Sign up"
51
- signup : "Sign up"
52
- browse : "Choose file..."
53
- cut : "Cut"
54
- copy : "Copy"
55
- paste : "Paste"
56
- duplicate : "Duplicate"
57
- export : "Export"
58
- export_csv : "Export CSV"
59
- export_xls : "Export XLS"
60
- export_xlsx: "Export XLSX"
61
- export_pdf : "Export PDF"
62
- import : "Import"
63
- import_csv : "Import CSV"
64
- import_xls : "Import XLS"
65
- import_xlsx: "Import XLSX"
66
- import_pdf : "Import PDF"
67
- send : "Send"
68
- comment : "Comment"
69
- add_line : "Add line"
70
- remove_line: "Remove line"
71
- pay : "Pay"
72
- paid : "Payd"
73
- continue : "Continue"
74
- rename : "Rename"
75
- email : "Send by email"
76
- print : "Print"
77
- submit : "Submit"
78
- accept : "Accept"
79
- refuse : "Refuse"
80
-
81
- attributes: &attributes
82
- id : "Id"
83
- type : "Type"
84
- code : "Code"
85
- reference : "Réference"
86
- created_at : "Created at"
87
- updated_at : "Updated at"
88
- name : "Name"
89
- title : "Title"
90
- label : "Label"
91
- first_name : "First name"
92
- last_name : "Last name"
93
- email : "E-mail"
94
- www : "Web site"
95
- phone : "Phone"
96
- mobile : "Mobile"
97
- fax : "Fax"
98
- password : "Password"
99
- password_confirmation : "Password (confirm)"
100
- description : "Description"
101
- text : "Text"
102
- date : "Date"
103
- state : "State"
104
- status : "Status"
105
- file : "File"
106
- address : "Address"
107
- address1 : "Address"
108
- address2 : "Address (rest)"
109
- street : "Address"
110
- street_bis : "Address (rest)"
111
- zip : "Zip"
112
- city : "City"
113
- country : "Country"
114
- tags : "Tags"
115
- tag_list : "Tags"
116
- budget : "Budget"
117
- probability : "Probability"
118
- access : "Access"
119
- color : "Color"
120
- data : "Data"
121
- comment : "Comment"
122
- written_by : "Written by"
123
- details : "Datails"
124
- quantity : "Quantity"
125
- due_date : "Due date"
126
- paid : "Paid ?"
127
- customer : "Customer"
128
- customer_guid : "Customer"
129
- tracking : "Tracking ID"
130
- tracking_id : "Tracking ID"
131
- unique_index : "Tracking ID"
132
- count : "Number"
133
- length : "Number"
134
- number : "Number"
135
- message : "Message"
136
- skype : "Skype"
137
- facebook : "Facebook"
138
- twitter : "Twitter"
139
- linkedin : "Linkedin"
140
- viadeo : "Viadeo"
141
- subject : "Subject"
142
- body : "Message"
143
- attachment : "Attachment"
144
- avatar : "Avatar"
145
- current_avatar : "Current avatar"
146
- logo : "Logo"
147
- active : "Active ?"
148
- user : "User"
149
- category : "Category"
150
- corporation_name : "Name"
151
- author : "Author"
152
- sender : "Author"
153
- total : "Total"
154
- version : "Version"
155
- commentable : "Origin"
156
- addressable : "Origin"
157
- attachable : "Origin"
158
- email_subject : "Subject"
159
- email_from : "Sender"
160
- email_to : "Recipient"
161
- email_attachment : "Attachment"
162
- email_body : "Message"
163
-
164
7
  errors:
165
8
  messages:
166
9
  extension_white_list_error : "This file type is not supported"
@@ -187,9 +30,6 @@ en:
187
30
  next_next_week: "In two weeks"
188
31
  custom_date: "Custom date"
189
32
 
190
- labels:
191
- <<: *attributes
192
-
193
33
  simple_form:
194
34
  "yes" : 'Yes'
195
35
  "no" : 'No'
@@ -4,174 +4,6 @@ fr:
4
4
  "true" : "Oui"
5
5
  "false" : "Non"
6
6
 
7
- date:
8
- formats:
9
- default: "%d/%m/%Y"
10
-
11
- time:
12
- formats:
13
- default: "%d/%m/%Y à %H:%M"
14
-
15
- actions: &actions
16
- actions : "Actions"
17
- index : "Liste"
18
- list : "Liste"
19
- new : "Nouveau"
20
- create : "Créer"
21
- read : "Afficher"
22
- show : "Afficher"
23
- details : "Détails"
24
- edit : "Modifier"
25
- update : "Modifier"
26
- delete : "Supprimer"
27
- destroy : "Supprimer"
28
- add : "Ajouter"
29
- filter : "Filtrer"
30
- filter_by : "Filtrer par"
31
- sort : "Trier"
32
- sort_by : "Trier par"
33
- reset : "Mettre à zéro"
34
- back : "Retour"
35
- save : "Enregistrer"
36
- open : "Ouvrir"
37
- close : "Fermer"
38
- lock : "Fermer"
39
- unlock : "Ouvrir"
40
- snooze : "Reporter"
41
- alert : "Alerter"
42
- complete : "Marquer terminé"
43
- done : "Terminer"
44
- download : "Télécharger"
45
- upload : "Envoyer"
46
- preview : "Aperçu"
47
- confirm : "Confirmer cette action ?"
48
- cancel : "Annuler"
49
- search : "Rechercher"
50
- sign_in : "Se connecter"
51
- signin : "Se connecter"
52
- log_in : "Se connecter"
53
- login : "Se connecter"
54
- sign_out : "Se déconnecter"
55
- signout : "Se déconnecter"
56
- log_out : "Se déconnecter"
57
- logout : "Se déconnecter"
58
- sign_up : "S'enregistrer"
59
- signup : "S'enregistrer"
60
- browse : "Sélectionner le fichier..."
61
- cut : "Couper"
62
- copy : "Copier"
63
- paste : "Coller"
64
- duplicate : "Dupliquer"
65
- export : "Exporter"
66
- export_csv : "Export CSV"
67
- export_xls : "Export XLS"
68
- export_xlsx: "Export XLSX"
69
- export_pdf : "Export PDF"
70
- import : "Importer"
71
- import_csv : "Import CSV"
72
- import_xls : "Import XLS"
73
- import_xlsx: "Import XLSX"
74
- import_pdf : "Import PDF"
75
- send : "Envoyer"
76
- comment : "Commenter"
77
- add_line : "Ajoute une ligne"
78
- remove_line: "Supprimer la ligne"
79
- pay : "Payer"
80
- paid : "Payée"
81
- continue : "Continuer"
82
- rename : "Renommer"
83
- email : "Envoyer par email"
84
- print : "Imprimer"
85
- submit : "Soumettre"
86
- accept : "Accepter"
87
- refuse : "Refuser"
88
-
89
- attributes: &attributes
90
- id : "Id"
91
- type : "Type"
92
- code : "Code"
93
- reference : "Référence"
94
- created_at : "Créé le"
95
- updated_at : "Modifié le"
96
- name : "Nom"
97
- title : "Titre"
98
- label : "Libellé"
99
- first_name : "Prénom"
100
- last_name : "Nom"
101
- email : "E-mail"
102
- www : "Site web"
103
- phone : "Téléphone"
104
- mobile : "Mobile"
105
- fax : "Fax"
106
- password : "Mot de passe"
107
- password_confirmation : "Mot de passe (confirmer)"
108
- description : "Description"
109
- text : "Description"
110
- date : "Date"
111
- state : "État"
112
- status : "État"
113
- file : "Fichier"
114
- address : "Adresse"
115
- address1 : "Adresse"
116
- address2 : "Adresse (suite)"
117
- street : "Adresse"
118
- street_bis : "Adresse (suite)"
119
- zip : "Code postal"
120
- city : "Ville"
121
- country : "Pays"
122
- tags : "Tags"
123
- tag_list : "Tags"
124
- budget : "Budget"
125
- probability : "Probabilité"
126
- access : "Accès"
127
- color : "Couleur"
128
- data : "Informations"
129
- comment : "Commentaire"
130
- comments : "Commentaires"
131
- written_by : "écrit par"
132
- details : "Détails"
133
- quantity : "Quantité"
134
- due_date : "Échéance"
135
- paid : "Payée ?"
136
- customer : "Client"
137
- customer_guid : "Client"
138
- tracking : "Numéro"
139
- tracking_id : "Numéro"
140
- unique_index : "Numéro"
141
- count : "Nombre"
142
- length : "Nombre"
143
- number : "Nombre"
144
- message : "Message"
145
- skype : "Skype"
146
- facebook : "Facebook"
147
- twitter : "Twitter"
148
- linkedin : "Linkedin"
149
- viadeo : "Viadeo"
150
- is_active : "Actif ?"
151
- short_name : "Initiales"
152
- subject : "Objet"
153
- body : "Message"
154
- attachment : "Pièce jointe"
155
- avatar : "Avatar"
156
- current_avatar : "Avatar actuel"
157
- logo : "Logo"
158
- active : "Actif ?"
159
- user : "Utilisateur"
160
- category : "Catégorie"
161
- corporation_name : "Nom"
162
- author : "Auteur"
163
- sender : "Auteur"
164
- total : "Total"
165
- version : "Version"
166
- commentable : "Origine"
167
- addressable : "Origine"
168
- attachable : "Origine"
169
- email_subject : "Object"
170
- email_from : "Expéditeur"
171
- email_to : "Destinataire"
172
- email_attachment : "Pièce jointe"
173
- email_body : "Message"
174
-
175
7
  errors:
176
8
  messages:
177
9
  extension_white_list_error : "Ce type de fichier n'est pas prit en charge"
@@ -198,9 +30,6 @@ fr:
198
30
  next_next_week: "Dans deux semaines"
199
31
  custom_date: "Choisir une date"
200
32
 
201
- labels:
202
- <<: *attributes
203
-
204
33
  simple_form:
205
34
  "yes" : 'Oui'
206
35
  "no" : 'Non'
@@ -0,0 +1,8 @@
1
+ fr:
2
+ date:
3
+ formats:
4
+ default: "%d/%m/%Y"
5
+
6
+ time:
7
+ formats:
8
+ default: "%d/%m/%Y à %H:%M"
@@ -0,0 +1,5 @@
1
+ en:
2
+ errors:
3
+ not_found: "Page not found"
4
+ unauthorized: "You must log in to access this page"
5
+ forbidden: "You are not authorized to access this page"
@@ -0,0 +1,5 @@
1
+ fr:
2
+ errors:
3
+ not_found: "La page demandée n'existe pas ou plus"
4
+ unauthorized: "Vous devez être connecté pour accéder à cette page"
5
+ forbidden: "Vous n'êtes pas autorisé à accéder à cette page"
@@ -0,0 +1,7 @@
1
+ class EnableAgiliboxExtensions < ActiveRecord::Migration[5.1]
2
+ def change
3
+ enable_extension "pgcrypto"
4
+ enable_extension "unaccent"
5
+ enable_extension "uuid-ossp"
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ module Agilibox::ActiveModelCustomErrorMessages
2
+ # Rails <= 6.0
3
+ module ForErrors
4
+ def full_message(attribute, message)
5
+ return message[1..] if message[0] == "^"
6
+ super
7
+ end
8
+ end
9
+
10
+ ActiveModel::Errors.prepend(ForErrors)
11
+
12
+ # Rails >= 6.1
13
+ module ForError
14
+ def full_message
15
+ return message[1..] if message[0] == "^"
16
+ super
17
+ end
18
+ end
19
+
20
+ if Module.const_defined?("ActiveModel::Error")
21
+ ActiveModel::Error.prepend(ForError)
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ module Agilibox::ActiveModelTypeCast
2
+ module Decimal
3
+ def cast_value(value)
4
+ if value.is_a?(String)
5
+ super value.tr(",", ".").gsub(/[^-0-9.]/, "")
6
+ else
7
+ super value
8
+ end
9
+ end
10
+ end
11
+
12
+ module Date
13
+ # rubocop:disable Style/RegexpLiteral
14
+ SANITIZABLE_FORMATS = [
15
+ /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/,
16
+ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/,
17
+ ]
18
+ # rubocop:enable Style/RegexpLiteral
19
+
20
+ def cast_value(value)
21
+ if sanitizable?(value)
22
+ super sanitize(value)
23
+ else
24
+ super value
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def sanitize(value)
31
+ value.delete(" ")
32
+ end
33
+
34
+ def sanitizable?(value)
35
+ return false unless value.is_a?(String)
36
+ sanitized = sanitize(value)
37
+ SANITIZABLE_FORMATS.any? { |r| r =~ sanitized }
38
+ end
39
+ end
40
+
41
+ module Boolean
42
+ def cast_value(value)
43
+ value = value.strip if value.is_a?(String)
44
+ super value
45
+ end
46
+ end
47
+ end
48
+
49
+ ActiveModel::Type::Date.prepend(Agilibox::ActiveModelTypeCast::Date)
50
+ ActiveModel::Type::Boolean.prepend(Agilibox::ActiveModelTypeCast::Boolean)
51
+ ActiveModel::Type::Decimal.prepend(Agilibox::ActiveModelTypeCast::Decimal)
52
+ ActiveModel::Type::Float.prepend(Agilibox::ActiveModelTypeCast::Decimal)
@@ -0,0 +1,19 @@
1
+ class << Agilibox
2
+ attr_writer :parent_controller
3
+
4
+ def parent_controller
5
+ @parent_controller ||= [
6
+ "ApplicationController",
7
+ "ActionController::Base",
8
+ ].map(&:safe_constantize).compact.first
9
+ end
10
+
11
+ attr_writer :parent_mailer
12
+
13
+ def parent_mailer
14
+ @parent_mailer ||= [
15
+ "ApplicationMailer",
16
+ "ActionMailer::Base",
17
+ ].map(&:safe_constantize).compact.first
18
+ end
19
+ end
@@ -1,2 +1,3 @@
1
- require_relative "active_record_comma_type_cast"
1
+ require_relative "active_model_custom_error_messages"
2
+ require_relative "active_model_type_cast"
2
3
  require_relative "form_back_url"
@@ -0,0 +1,53 @@
1
+ class << Agilibox::CucumberConfig = Class.new
2
+ undef new
3
+
4
+ attr_writer :cuprite_timeout
5
+
6
+ def cuprite_timeout
7
+ @cuprite_timeout ||= 15
8
+ end
9
+
10
+ attr_writer :cuprite_process_timeout
11
+
12
+ def cuprite_process_timeout
13
+ @cuprite_process_timeout ||= 15
14
+ end
15
+
16
+ attr_writer :window_size
17
+
18
+ def window_size
19
+ @window_size ||= [1680, 1050]
20
+ end
21
+
22
+ attr_writer :databasecleaner_tables
23
+
24
+ def databasecleaner_tables
25
+ @databasecleaner_tables ||= %w(
26
+ ar_internal_metadata
27
+ schema_migrations
28
+ spatial_ref_sys
29
+ )
30
+ end
31
+
32
+ def require_all_helpers!
33
+ files = Dir.glob Agilibox::Engine.root.join("lib", "agilibox", "cucumber_helpers", "*.rb")
34
+ files.delete_if { |f| f.match?(/apparition|chrome|cuprite|_steps/) }
35
+ files.each { |file| require file }
36
+ end
37
+
38
+ def require_apparition!
39
+ require Agilibox::Engine.root.join("lib", "agilibox", "cucumber_helpers", "apparition.rb")
40
+ end
41
+
42
+ def require_chrome_headless!
43
+ require Agilibox::Engine.root.join("lib", "agilibox", "cucumber_helpers", "chrome_headless.rb")
44
+ end
45
+
46
+ def require_cuprite!
47
+ require Agilibox::Engine.root.join("lib", "agilibox", "cucumber_helpers", "cuprite.rb")
48
+ end
49
+
50
+ def require_common_steps!
51
+ require Agilibox::Engine.root.join("lib", "agilibox", "cucumber_helpers", "common_steps.rb")
52
+ end
53
+ end
@@ -0,0 +1,2 @@
1
+ require "agilibox/test_helpers"
2
+ World(Agilibox::TestHelpers)
@@ -0,0 +1,18 @@
1
+ module CapybaraWaitAjaxRequests
2
+ def wait_ajax_requests(timeout = Capybara.default_max_wait_time)
3
+ Timeout.timeout(timeout) do
4
+ sleep 0.1 until all_ajax_requests_finished?
5
+ end
6
+ end
7
+
8
+ def all_ajax_requests_finished?
9
+ page.evaluate_script("jQuery.active").zero?
10
+ end
11
+ end
12
+
13
+ World(CapybaraWaitAjaxRequests)
14
+
15
+ # Auto wait ajax request between steps
16
+ AfterStep do |_scenario|
17
+ wait_ajax_requests if page.evaluate_script("typeof jQuery") != "undefined"
18
+ end
@@ -0,0 +1,18 @@
1
+ require "capybara/apparition"
2
+
3
+ Capybara.register_driver :agilibox_apparition do |app|
4
+ Capybara::Apparition::Driver.new(app,
5
+ :browser_options => {
6
+ :"disable-gpu" => true,
7
+ :"no-sandbox" => nil,
8
+ },
9
+ :headless => (ENV["CHROME_HEADLESS"].to_s != "false"),
10
+ :inspector => true,
11
+ :js_errors => true,
12
+ :window_size => Agilibox::CucumberConfig.window_size,
13
+ )
14
+ end
15
+
16
+ Capybara.default_driver = :agilibox_apparition
17
+ Capybara.current_driver = :agilibox_apparition
18
+ Capybara.javascript_driver = :agilibox_apparition
@@ -0,0 +1,12 @@
1
+ Capybara.register_driver :agilibox_no_driver do |_app|
2
+ raise \
3
+ "You need to add Agilibox::CucumberConfig.require_cuprite! or " \
4
+ "Agilibox::CucumberConfig.require_chrome_headless! " \
5
+ "to your features/support/env.rb"
6
+ end
7
+
8
+ Capybara.default_driver = :agilibox_no_driver
9
+ Capybara.current_driver = :agilibox_no_driver
10
+ Capybara.javascript_driver = :agilibox_no_driver
11
+
12
+ Capybara.default_max_wait_time = 3
@@ -0,0 +1,7 @@
1
+ Capybara.add_selector(:agilibox_clickable) do
2
+ xpath do |locator, **options|
3
+ %i(link button label)
4
+ .map { |selector| expression_for(selector, locator, **options) }
5
+ .reduce(:union)
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ Capybara.register_driver :agilibox_chrome_headless do |app|
2
+ window_size = Agilibox::CucumberConfig.window_size.map(&:to_s).join(",")
3
+
4
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
5
+ :chromeOptions => {args: %W(headless window-size=#{window_size})},
6
+ )
7
+
8
+ Capybara::Selenium::Driver.new(app,
9
+ :browser => :chrome,
10
+ :desired_capabilities => capabilities,
11
+ )
12
+ end
13
+
14
+ Capybara.default_driver = :agilibox_chrome_headless
15
+ Capybara.current_driver = :agilibox_chrome_headless
16
+ Capybara.javascript_driver = :agilibox_chrome_headless