chillout 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (425) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +45 -9
  4. data/CHANGELOG.md +14 -0
  5. data/Gemfile +8 -0
  6. data/README.md +43 -7
  7. data/Rakefile +17 -2
  8. data/chillout.gemspec +21 -10
  9. data/lib/chillout/client.rb +26 -5
  10. data/lib/chillout/config.rb +15 -0
  11. data/lib/chillout/creation_listener.rb +10 -5
  12. data/lib/chillout/custom_metric.rb +27 -0
  13. data/lib/chillout/integrations/sidekiq.rb +22 -0
  14. data/lib/chillout/job.rb +12 -0
  15. data/lib/chillout/listener_injector.rb +23 -0
  16. data/lib/chillout/middleware/creations_monitor.rb +1 -1
  17. data/lib/chillout/middleware/sidekiq.rb +21 -0
  18. data/lib/chillout/railtie.rb +12 -14
  19. data/lib/chillout/server_side/dispatcher.rb +1 -1
  20. data/lib/chillout/server_side/plain_http_client.rb +22 -2
  21. data/lib/chillout/version.rb +1 -1
  22. data/lib/chillout/worker.rb +5 -5
  23. data/lib/chillout.rb +11 -0
  24. data/test/acceptance/client_sends_metrics_test.rb +21 -0
  25. data/test/acceptance/sidekiq_workers_send_metrics_test.rb +22 -0
  26. data/test/config_test.rb +31 -1
  27. data/test/custom_metric_test.rb +15 -0
  28. data/test/event_data_builder_test.rb +47 -41
  29. data/test/integration/client_test.rb +78 -4
  30. data/test/integration/worker_test.rb +3 -2
  31. data/test/middleware/creations_monitor_test.rb +28 -29
  32. data/test/middleware/sidekiq_test.rb +45 -0
  33. data/test/plain_http_client_test.rb +13 -0
  34. data/test/support/rails_3_2_13/Gemfile +5 -0
  35. data/test/support/rails_3_2_13/Rakefile +7 -0
  36. data/test/support/rails_3_2_13/app/controllers/application_controller.rb +3 -0
  37. data/test/support/rails_3_2_13/app/controllers/entities_controller.rb +70 -0
  38. data/test/support/rails_3_2_13/app/helpers/application_helper.rb +2 -0
  39. data/test/support/rails_3_2_13/app/models/entity.rb +3 -0
  40. data/test/support/rails_3_2_13/app/views/entities/_form.html.erb +21 -0
  41. data/test/support/rails_3_2_13/app/views/entities/edit.html.erb +6 -0
  42. data/test/support/rails_3_2_13/app/views/entities/index.html.erb +23 -0
  43. data/test/support/rails_3_2_13/app/views/entities/new.html.erb +5 -0
  44. data/test/support/rails_3_2_13/app/views/entities/show.html.erb +10 -0
  45. data/test/support/rails_3_2_13/app/views/layouts/application.html.erb +14 -0
  46. data/test/support/rails_3_2_13/config/application.rb +63 -0
  47. data/test/support/rails_3_2_13/config/boot.rb +6 -0
  48. data/test/support/rails_3_2_13/config/database.yml +11 -0
  49. data/test/support/rails_3_2_13/config/environment.rb +5 -0
  50. data/test/support/rails_3_2_13/config/environments/development.rb +32 -0
  51. data/test/support/rails_3_2_13/config/environments/production.rb +56 -0
  52. data/test/support/rails_3_2_13/config/environments/test.rb +37 -0
  53. data/test/support/rails_3_2_13/config/initializers/backtrace_silencers.rb +7 -0
  54. data/test/support/rails_3_2_13/config/initializers/inflections.rb +15 -0
  55. data/test/support/rails_3_2_13/config/initializers/load_schema.rb +4 -0
  56. data/test/support/rails_3_2_13/config/initializers/mime_types.rb +5 -0
  57. data/test/support/rails_3_2_13/config/initializers/secret_token.rb +7 -0
  58. data/test/support/rails_3_2_13/config/initializers/session_store.rb +8 -0
  59. data/test/support/rails_3_2_13/config/initializers/wrap_parameters.rb +14 -0
  60. data/test/support/rails_3_2_13/config/locales/en.yml +5 -0
  61. data/test/support/rails_3_2_13/config/routes.rb +3 -0
  62. data/test/support/rails_3_2_13/config.ru +4 -0
  63. data/test/support/rails_3_2_13/db/schema.rb +22 -0
  64. data/test/support/rails_3_2_13/public/404.html +26 -0
  65. data/test/support/rails_3_2_13/public/422.html +26 -0
  66. data/test/support/rails_3_2_13/public/500.html +25 -0
  67. data/test/support/rails_3_2_13/public/favicon.ico +0 -0
  68. data/test/support/rails_3_2_13/public/robots.txt +5 -0
  69. data/test/support/rails_3_2_13/script/rails +6 -0
  70. data/test/support/rails_4_0_0/Gemfile +5 -0
  71. data/test/support/rails_4_0_0/Rakefile +6 -0
  72. data/test/support/rails_4_0_0/app/controllers/application_controller.rb +5 -0
  73. data/test/support/rails_4_0_0/app/controllers/concerns/.keep +0 -0
  74. data/test/support/rails_4_0_0/app/controllers/entities_controller.rb +70 -0
  75. data/test/support/rails_4_0_0/app/helpers/application_helper.rb +2 -0
  76. data/test/support/rails_4_0_0/app/models/.keep +0 -0
  77. data/test/support/rails_4_0_0/app/models/concerns/.keep +0 -0
  78. data/test/support/rails_4_0_0/app/models/entity.rb +2 -0
  79. data/test/support/rails_4_0_0/app/views/entities/_form.html.erb +21 -0
  80. data/test/support/rails_4_0_0/app/views/entities/edit.html.erb +6 -0
  81. data/test/support/rails_4_0_0/app/views/entities/index.html.erb +23 -0
  82. data/test/support/rails_4_0_0/app/views/entities/new.html.erb +5 -0
  83. data/test/support/rails_4_0_0/app/views/entities/show.html.erb +10 -0
  84. data/test/support/rails_4_0_0/app/views/layouts/application.html.erb +14 -0
  85. data/test/support/rails_4_0_0/config/application.rb +31 -0
  86. data/test/support/rails_4_0_0/config/boot.rb +4 -0
  87. data/test/support/rails_4_0_0/config/database.yml +11 -0
  88. data/test/support/rails_4_0_0/config/environment.rb +5 -0
  89. data/test/support/rails_4_0_0/config/environments/development.rb +25 -0
  90. data/test/support/rails_4_0_0/config/environments/production.rb +67 -0
  91. data/test/support/rails_4_0_0/config/environments/test.rb +36 -0
  92. data/test/support/rails_4_0_0/config/initializers/backtrace_silencers.rb +7 -0
  93. data/test/support/rails_4_0_0/config/initializers/filter_parameter_logging.rb +4 -0
  94. data/test/support/rails_4_0_0/config/initializers/inflections.rb +16 -0
  95. data/test/support/rails_4_0_0/config/initializers/load_schema.rb +4 -0
  96. data/test/support/rails_4_0_0/config/initializers/mime_types.rb +5 -0
  97. data/test/support/rails_4_0_0/config/initializers/secret_token.rb +12 -0
  98. data/test/support/rails_4_0_0/config/initializers/session_store.rb +3 -0
  99. data/test/support/rails_4_0_0/config/initializers/wrap_parameters.rb +14 -0
  100. data/test/support/rails_4_0_0/config/locales/en.yml +23 -0
  101. data/test/support/rails_4_0_0/config/routes.rb +3 -0
  102. data/test/support/rails_4_0_0/config.ru +4 -0
  103. data/test/support/rails_4_0_0/db/schema.rb +22 -0
  104. data/test/support/rails_4_0_0/lib/assets/.keep +0 -0
  105. data/test/support/rails_4_0_0/lib/tasks/.keep +0 -0
  106. data/test/support/rails_4_0_0/public/404.html +58 -0
  107. data/test/support/rails_4_0_0/public/422.html +58 -0
  108. data/test/support/rails_4_0_0/public/500.html +57 -0
  109. data/test/support/rails_4_0_0/public/favicon.ico +0 -0
  110. data/test/support/rails_4_0_0/public/robots.txt +5 -0
  111. data/test/support/rails_4_0_0/script/bundle +3 -0
  112. data/test/support/rails_4_0_0/script/rails +4 -0
  113. data/test/support/rails_4_0_0/script/rake +4 -0
  114. data/test/support/rails_4_0_13/Gemfile +5 -0
  115. data/test/support/rails_4_0_13/Rakefile +6 -0
  116. data/test/support/rails_4_0_13/app/controllers/application_controller.rb +5 -0
  117. data/test/support/rails_4_0_13/app/controllers/concerns/.keep +0 -0
  118. data/test/support/rails_4_0_13/app/controllers/entities_controller.rb +70 -0
  119. data/test/support/rails_4_0_13/app/helpers/application_helper.rb +2 -0
  120. data/test/support/rails_4_0_13/app/models/.keep +0 -0
  121. data/test/support/rails_4_0_13/app/models/concerns/.keep +0 -0
  122. data/test/support/rails_4_0_13/app/models/entity.rb +2 -0
  123. data/test/support/rails_4_0_13/app/views/entities/_form.html.erb +21 -0
  124. data/test/support/rails_4_0_13/app/views/entities/edit.html.erb +6 -0
  125. data/test/support/rails_4_0_13/app/views/entities/index.html.erb +23 -0
  126. data/test/support/rails_4_0_13/app/views/entities/new.html.erb +5 -0
  127. data/test/support/rails_4_0_13/app/views/entities/show.html.erb +10 -0
  128. data/test/support/rails_4_0_13/app/views/layouts/application.html.erb +14 -0
  129. data/test/support/rails_4_0_13/config/application.rb +31 -0
  130. data/test/support/rails_4_0_13/config/boot.rb +4 -0
  131. data/test/support/rails_4_0_13/config/database.yml +11 -0
  132. data/test/support/rails_4_0_13/config/environment.rb +5 -0
  133. data/test/support/rails_4_0_13/config/environments/development.rb +25 -0
  134. data/test/support/rails_4_0_13/config/environments/production.rb +67 -0
  135. data/test/support/rails_4_0_13/config/environments/test.rb +36 -0
  136. data/test/support/rails_4_0_13/config/initializers/backtrace_silencers.rb +7 -0
  137. data/test/support/rails_4_0_13/config/initializers/filter_parameter_logging.rb +4 -0
  138. data/test/support/rails_4_0_13/config/initializers/inflections.rb +16 -0
  139. data/test/support/rails_4_0_13/config/initializers/load_schema.rb +4 -0
  140. data/test/support/rails_4_0_13/config/initializers/mime_types.rb +5 -0
  141. data/test/support/rails_4_0_13/config/initializers/secret_token.rb +12 -0
  142. data/test/support/rails_4_0_13/config/initializers/session_store.rb +3 -0
  143. data/test/support/rails_4_0_13/config/initializers/wrap_parameters.rb +14 -0
  144. data/test/support/rails_4_0_13/config/locales/en.yml +23 -0
  145. data/test/support/rails_4_0_13/config/routes.rb +3 -0
  146. data/test/support/rails_4_0_13/config.ru +4 -0
  147. data/test/support/rails_4_0_13/db/schema.rb +22 -0
  148. data/test/support/rails_4_0_13/lib/assets/.keep +0 -0
  149. data/test/support/rails_4_0_13/lib/tasks/.keep +0 -0
  150. data/test/support/rails_4_0_13/public/404.html +58 -0
  151. data/test/support/rails_4_0_13/public/422.html +58 -0
  152. data/test/support/rails_4_0_13/public/500.html +57 -0
  153. data/test/support/rails_4_0_13/public/favicon.ico +0 -0
  154. data/test/support/rails_4_0_13/public/robots.txt +5 -0
  155. data/test/support/rails_4_0_13/script/bundle +3 -0
  156. data/test/support/rails_4_0_13/script/rails +4 -0
  157. data/test/support/rails_4_0_13/script/rake +4 -0
  158. data/test/support/rails_4_1_0/Gemfile +5 -0
  159. data/test/support/rails_4_1_0/Rakefile +6 -0
  160. data/test/support/rails_4_1_0/app/controllers/application_controller.rb +5 -0
  161. data/test/support/rails_4_1_0/app/controllers/concerns/.keep +0 -0
  162. data/test/support/rails_4_1_0/app/controllers/entities_controller.rb +70 -0
  163. data/test/support/rails_4_1_0/app/helpers/application_helper.rb +2 -0
  164. data/test/support/rails_4_1_0/app/models/.keep +0 -0
  165. data/test/support/rails_4_1_0/app/models/concerns/.keep +0 -0
  166. data/test/support/rails_4_1_0/app/models/entity.rb +2 -0
  167. data/test/support/rails_4_1_0/app/views/entities/_form.html.erb +21 -0
  168. data/test/support/rails_4_1_0/app/views/entities/edit.html.erb +6 -0
  169. data/test/support/rails_4_1_0/app/views/entities/index.html.erb +23 -0
  170. data/test/support/rails_4_1_0/app/views/entities/new.html.erb +5 -0
  171. data/test/support/rails_4_1_0/app/views/entities/show.html.erb +10 -0
  172. data/test/support/rails_4_1_0/app/views/layouts/application.html.erb +14 -0
  173. data/test/support/rails_4_1_0/config/application.rb +31 -0
  174. data/test/support/rails_4_1_0/config/boot.rb +4 -0
  175. data/test/support/rails_4_1_0/config/database.yml +11 -0
  176. data/test/support/rails_4_1_0/config/environment.rb +5 -0
  177. data/test/support/rails_4_1_0/config/environments/development.rb +25 -0
  178. data/test/support/rails_4_1_0/config/environments/production.rb +67 -0
  179. data/test/support/rails_4_1_0/config/environments/test.rb +36 -0
  180. data/test/support/rails_4_1_0/config/initializers/backtrace_silencers.rb +7 -0
  181. data/test/support/rails_4_1_0/config/initializers/filter_parameter_logging.rb +4 -0
  182. data/test/support/rails_4_1_0/config/initializers/inflections.rb +16 -0
  183. data/test/support/rails_4_1_0/config/initializers/load_schema.rb +4 -0
  184. data/test/support/rails_4_1_0/config/initializers/mime_types.rb +5 -0
  185. data/test/support/rails_4_1_0/config/initializers/secret_token.rb +12 -0
  186. data/test/support/rails_4_1_0/config/initializers/session_store.rb +3 -0
  187. data/test/support/rails_4_1_0/config/initializers/wrap_parameters.rb +14 -0
  188. data/test/support/rails_4_1_0/config/locales/en.yml +23 -0
  189. data/test/support/rails_4_1_0/config/routes.rb +3 -0
  190. data/test/support/rails_4_1_0/config.ru +4 -0
  191. data/test/support/rails_4_1_0/db/schema.rb +22 -0
  192. data/test/support/rails_4_1_0/lib/assets/.keep +0 -0
  193. data/test/support/rails_4_1_0/lib/tasks/.keep +0 -0
  194. data/test/support/rails_4_1_0/public/404.html +58 -0
  195. data/test/support/rails_4_1_0/public/422.html +58 -0
  196. data/test/support/rails_4_1_0/public/500.html +57 -0
  197. data/test/support/rails_4_1_0/public/favicon.ico +0 -0
  198. data/test/support/rails_4_1_0/public/robots.txt +5 -0
  199. data/test/support/rails_4_1_0/script/bundle +3 -0
  200. data/test/support/rails_4_1_0/script/rails +4 -0
  201. data/test/support/rails_4_1_0/script/rake +4 -0
  202. data/test/support/rails_4_1_16/Gemfile +5 -0
  203. data/test/support/rails_4_1_16/Rakefile +6 -0
  204. data/test/support/rails_4_1_16/app/controllers/application_controller.rb +5 -0
  205. data/test/support/rails_4_1_16/app/controllers/concerns/.keep +0 -0
  206. data/test/support/rails_4_1_16/app/controllers/entities_controller.rb +70 -0
  207. data/test/support/rails_4_1_16/app/helpers/application_helper.rb +2 -0
  208. data/test/support/rails_4_1_16/app/models/.keep +0 -0
  209. data/test/support/rails_4_1_16/app/models/concerns/.keep +0 -0
  210. data/test/support/rails_4_1_16/app/models/entity.rb +2 -0
  211. data/test/support/rails_4_1_16/app/views/entities/_form.html.erb +21 -0
  212. data/test/support/rails_4_1_16/app/views/entities/edit.html.erb +6 -0
  213. data/test/support/rails_4_1_16/app/views/entities/index.html.erb +23 -0
  214. data/test/support/rails_4_1_16/app/views/entities/new.html.erb +5 -0
  215. data/test/support/rails_4_1_16/app/views/entities/show.html.erb +10 -0
  216. data/test/support/rails_4_1_16/app/views/layouts/application.html.erb +14 -0
  217. data/test/support/rails_4_1_16/config/application.rb +31 -0
  218. data/test/support/rails_4_1_16/config/boot.rb +4 -0
  219. data/test/support/rails_4_1_16/config/database.yml +11 -0
  220. data/test/support/rails_4_1_16/config/environment.rb +5 -0
  221. data/test/support/rails_4_1_16/config/environments/development.rb +25 -0
  222. data/test/support/rails_4_1_16/config/environments/production.rb +67 -0
  223. data/test/support/rails_4_1_16/config/environments/test.rb +36 -0
  224. data/test/support/rails_4_1_16/config/initializers/backtrace_silencers.rb +7 -0
  225. data/test/support/rails_4_1_16/config/initializers/filter_parameter_logging.rb +4 -0
  226. data/test/support/rails_4_1_16/config/initializers/inflections.rb +16 -0
  227. data/test/support/rails_4_1_16/config/initializers/load_schema.rb +4 -0
  228. data/test/support/rails_4_1_16/config/initializers/mime_types.rb +5 -0
  229. data/test/support/rails_4_1_16/config/initializers/secret_token.rb +12 -0
  230. data/test/support/rails_4_1_16/config/initializers/session_store.rb +3 -0
  231. data/test/support/rails_4_1_16/config/initializers/wrap_parameters.rb +14 -0
  232. data/test/support/rails_4_1_16/config/locales/en.yml +23 -0
  233. data/test/support/rails_4_1_16/config/routes.rb +3 -0
  234. data/test/support/rails_4_1_16/config.ru +4 -0
  235. data/test/support/rails_4_1_16/db/schema.rb +22 -0
  236. data/test/support/rails_4_1_16/lib/assets/.keep +0 -0
  237. data/test/support/rails_4_1_16/lib/tasks/.keep +0 -0
  238. data/test/support/rails_4_1_16/public/404.html +58 -0
  239. data/test/support/rails_4_1_16/public/422.html +58 -0
  240. data/test/support/rails_4_1_16/public/500.html +57 -0
  241. data/test/support/rails_4_1_16/public/favicon.ico +0 -0
  242. data/test/support/rails_4_1_16/public/robots.txt +5 -0
  243. data/test/support/rails_4_1_16/script/bundle +3 -0
  244. data/test/support/rails_4_1_16/script/rails +4 -0
  245. data/test/support/rails_4_1_16/script/rake +4 -0
  246. data/test/support/rails_4_2_0/Gemfile +5 -0
  247. data/test/support/rails_4_2_0/Rakefile +6 -0
  248. data/test/support/rails_4_2_0/app/controllers/application_controller.rb +5 -0
  249. data/test/support/rails_4_2_0/app/controllers/concerns/.keep +0 -0
  250. data/test/support/rails_4_2_0/app/controllers/entities_controller.rb +70 -0
  251. data/test/support/rails_4_2_0/app/helpers/application_helper.rb +2 -0
  252. data/test/support/rails_4_2_0/app/models/.keep +0 -0
  253. data/test/support/rails_4_2_0/app/models/concerns/.keep +0 -0
  254. data/test/support/rails_4_2_0/app/models/entity.rb +2 -0
  255. data/test/support/rails_4_2_0/app/views/entities/_form.html.erb +21 -0
  256. data/test/support/rails_4_2_0/app/views/entities/edit.html.erb +6 -0
  257. data/test/support/rails_4_2_0/app/views/entities/index.html.erb +23 -0
  258. data/test/support/rails_4_2_0/app/views/entities/new.html.erb +5 -0
  259. data/test/support/rails_4_2_0/app/views/entities/show.html.erb +10 -0
  260. data/test/support/rails_4_2_0/app/views/layouts/application.html.erb +14 -0
  261. data/test/support/rails_4_2_0/config/application.rb +31 -0
  262. data/test/support/rails_4_2_0/config/boot.rb +4 -0
  263. data/test/support/rails_4_2_0/config/database.yml +11 -0
  264. data/test/support/rails_4_2_0/config/environment.rb +5 -0
  265. data/test/support/rails_4_2_0/config/environments/development.rb +25 -0
  266. data/test/support/rails_4_2_0/config/environments/production.rb +67 -0
  267. data/test/support/rails_4_2_0/config/environments/test.rb +36 -0
  268. data/test/support/rails_4_2_0/config/initializers/backtrace_silencers.rb +7 -0
  269. data/test/support/rails_4_2_0/config/initializers/filter_parameter_logging.rb +4 -0
  270. data/test/support/rails_4_2_0/config/initializers/inflections.rb +16 -0
  271. data/test/support/rails_4_2_0/config/initializers/load_schema.rb +4 -0
  272. data/test/support/rails_4_2_0/config/initializers/mime_types.rb +5 -0
  273. data/test/support/rails_4_2_0/config/initializers/secret_token.rb +12 -0
  274. data/test/support/rails_4_2_0/config/initializers/session_store.rb +3 -0
  275. data/test/support/rails_4_2_0/config/initializers/wrap_parameters.rb +14 -0
  276. data/test/support/rails_4_2_0/config/locales/en.yml +23 -0
  277. data/test/support/rails_4_2_0/config/routes.rb +3 -0
  278. data/test/support/rails_4_2_0/config.ru +4 -0
  279. data/test/support/rails_4_2_0/db/schema.rb +22 -0
  280. data/test/support/rails_4_2_0/lib/assets/.keep +0 -0
  281. data/test/support/rails_4_2_0/lib/tasks/.keep +0 -0
  282. data/test/support/rails_4_2_0/public/404.html +58 -0
  283. data/test/support/rails_4_2_0/public/422.html +58 -0
  284. data/test/support/rails_4_2_0/public/500.html +57 -0
  285. data/test/support/rails_4_2_0/public/favicon.ico +0 -0
  286. data/test/support/rails_4_2_0/public/robots.txt +5 -0
  287. data/test/support/rails_4_2_0/script/bundle +3 -0
  288. data/test/support/rails_4_2_0/script/rails +4 -0
  289. data/test/support/rails_4_2_0/script/rake +4 -0
  290. data/test/support/rails_4_2_8/Gemfile +5 -0
  291. data/test/support/rails_4_2_8/Rakefile +6 -0
  292. data/test/support/rails_4_2_8/app/controllers/application_controller.rb +5 -0
  293. data/test/support/rails_4_2_8/app/controllers/concerns/.keep +0 -0
  294. data/test/support/rails_4_2_8/app/controllers/entities_controller.rb +70 -0
  295. data/test/support/rails_4_2_8/app/helpers/application_helper.rb +2 -0
  296. data/test/support/rails_4_2_8/app/models/.keep +0 -0
  297. data/test/support/rails_4_2_8/app/models/concerns/.keep +0 -0
  298. data/test/support/rails_4_2_8/app/models/entity.rb +2 -0
  299. data/test/support/rails_4_2_8/app/views/entities/_form.html.erb +21 -0
  300. data/test/support/rails_4_2_8/app/views/entities/edit.html.erb +6 -0
  301. data/test/support/rails_4_2_8/app/views/entities/index.html.erb +23 -0
  302. data/test/support/rails_4_2_8/app/views/entities/new.html.erb +5 -0
  303. data/test/support/rails_4_2_8/app/views/entities/show.html.erb +10 -0
  304. data/test/support/rails_4_2_8/app/views/layouts/application.html.erb +14 -0
  305. data/test/support/rails_4_2_8/config/application.rb +34 -0
  306. data/test/support/rails_4_2_8/config/boot.rb +4 -0
  307. data/test/support/rails_4_2_8/config/database.yml +11 -0
  308. data/test/support/rails_4_2_8/config/environment.rb +5 -0
  309. data/test/support/rails_4_2_8/config/environments/development.rb +25 -0
  310. data/test/support/rails_4_2_8/config/environments/production.rb +73 -0
  311. data/test/support/rails_4_2_8/config/environments/test.rb +36 -0
  312. data/test/support/rails_4_2_8/config/initializers/backtrace_silencers.rb +7 -0
  313. data/test/support/rails_4_2_8/config/initializers/filter_parameter_logging.rb +4 -0
  314. data/test/support/rails_4_2_8/config/initializers/inflections.rb +16 -0
  315. data/test/support/rails_4_2_8/config/initializers/load_schema.rb +4 -0
  316. data/test/support/rails_4_2_8/config/initializers/mime_types.rb +5 -0
  317. data/test/support/rails_4_2_8/config/initializers/secret_token.rb +12 -0
  318. data/test/support/rails_4_2_8/config/initializers/session_store.rb +3 -0
  319. data/test/support/rails_4_2_8/config/initializers/wrap_parameters.rb +14 -0
  320. data/test/support/rails_4_2_8/config/locales/en.yml +23 -0
  321. data/test/support/rails_4_2_8/config/routes.rb +3 -0
  322. data/test/support/rails_4_2_8/config.ru +4 -0
  323. data/test/support/rails_4_2_8/db/schema.rb +22 -0
  324. data/test/support/rails_4_2_8/lib/assets/.keep +0 -0
  325. data/test/support/rails_4_2_8/lib/tasks/.keep +0 -0
  326. data/test/support/rails_4_2_8/public/404.html +58 -0
  327. data/test/support/rails_4_2_8/public/422.html +58 -0
  328. data/test/support/rails_4_2_8/public/500.html +57 -0
  329. data/test/support/rails_4_2_8/public/favicon.ico +0 -0
  330. data/test/support/rails_4_2_8/public/robots.txt +5 -0
  331. data/test/support/rails_4_2_8/script/bundle +3 -0
  332. data/test/support/rails_4_2_8/script/rails +4 -0
  333. data/test/support/rails_4_2_8/script/rake +4 -0
  334. data/test/support/rails_5_0_3/Gemfile +5 -0
  335. data/test/support/rails_5_0_3/Rakefile +6 -0
  336. data/test/support/rails_5_0_3/app/controllers/application_controller.rb +5 -0
  337. data/test/support/rails_5_0_3/app/controllers/concerns/.keep +0 -0
  338. data/test/support/rails_5_0_3/app/controllers/entities_controller.rb +70 -0
  339. data/test/support/rails_5_0_3/app/helpers/application_helper.rb +2 -0
  340. data/test/support/rails_5_0_3/app/models/.keep +0 -0
  341. data/test/support/rails_5_0_3/app/models/concerns/.keep +0 -0
  342. data/test/support/rails_5_0_3/app/models/entity.rb +2 -0
  343. data/test/support/rails_5_0_3/app/views/entities/_form.html.erb +21 -0
  344. data/test/support/rails_5_0_3/app/views/entities/edit.html.erb +6 -0
  345. data/test/support/rails_5_0_3/app/views/entities/index.html.erb +23 -0
  346. data/test/support/rails_5_0_3/app/views/entities/new.html.erb +5 -0
  347. data/test/support/rails_5_0_3/app/views/entities/show.html.erb +10 -0
  348. data/test/support/rails_5_0_3/app/views/layouts/application.html.erb +14 -0
  349. data/test/support/rails_5_0_3/config/application.rb +30 -0
  350. data/test/support/rails_5_0_3/config/boot.rb +4 -0
  351. data/test/support/rails_5_0_3/config/database.yml +11 -0
  352. data/test/support/rails_5_0_3/config/environment.rb +5 -0
  353. data/test/support/rails_5_0_3/config/environments/development.rb +25 -0
  354. data/test/support/rails_5_0_3/config/environments/production.rb +73 -0
  355. data/test/support/rails_5_0_3/config/environments/test.rb +36 -0
  356. data/test/support/rails_5_0_3/config/initializers/backtrace_silencers.rb +7 -0
  357. data/test/support/rails_5_0_3/config/initializers/filter_parameter_logging.rb +4 -0
  358. data/test/support/rails_5_0_3/config/initializers/inflections.rb +16 -0
  359. data/test/support/rails_5_0_3/config/initializers/load_schema.rb +4 -0
  360. data/test/support/rails_5_0_3/config/initializers/mime_types.rb +5 -0
  361. data/test/support/rails_5_0_3/config/initializers/secret_token.rb +12 -0
  362. data/test/support/rails_5_0_3/config/initializers/session_store.rb +3 -0
  363. data/test/support/rails_5_0_3/config/initializers/wrap_parameters.rb +14 -0
  364. data/test/support/rails_5_0_3/config/locales/en.yml +23 -0
  365. data/test/support/rails_5_0_3/config/routes.rb +3 -0
  366. data/test/support/rails_5_0_3/config.ru +4 -0
  367. data/test/support/rails_5_0_3/db/schema.rb +22 -0
  368. data/test/support/rails_5_0_3/lib/assets/.keep +0 -0
  369. data/test/support/rails_5_0_3/lib/tasks/.keep +0 -0
  370. data/test/support/rails_5_0_3/public/404.html +58 -0
  371. data/test/support/rails_5_0_3/public/422.html +58 -0
  372. data/test/support/rails_5_0_3/public/500.html +57 -0
  373. data/test/support/rails_5_0_3/public/favicon.ico +0 -0
  374. data/test/support/rails_5_0_3/public/robots.txt +5 -0
  375. data/test/support/rails_5_0_3/script/bundle +3 -0
  376. data/test/support/rails_5_0_3/script/rails +4 -0
  377. data/test/support/rails_5_0_3/script/rake +4 -0
  378. data/test/support/rails_5_1_1/Gemfile +6 -0
  379. data/test/support/rails_5_1_1/Rakefile +6 -0
  380. data/test/support/rails_5_1_1/app/controllers/application_controller.rb +5 -0
  381. data/test/support/rails_5_1_1/app/controllers/concerns/.keep +0 -0
  382. data/test/support/rails_5_1_1/app/controllers/entities_controller.rb +70 -0
  383. data/test/support/rails_5_1_1/app/helpers/application_helper.rb +2 -0
  384. data/test/support/rails_5_1_1/app/jobs/create_entity_job.rb +6 -0
  385. data/test/support/rails_5_1_1/app/models/.keep +0 -0
  386. data/test/support/rails_5_1_1/app/models/concerns/.keep +0 -0
  387. data/test/support/rails_5_1_1/app/models/entity.rb +2 -0
  388. data/test/support/rails_5_1_1/app/views/entities/_form.html.erb +21 -0
  389. data/test/support/rails_5_1_1/app/views/entities/edit.html.erb +6 -0
  390. data/test/support/rails_5_1_1/app/views/entities/index.html.erb +23 -0
  391. data/test/support/rails_5_1_1/app/views/entities/new.html.erb +5 -0
  392. data/test/support/rails_5_1_1/app/views/entities/show.html.erb +10 -0
  393. data/test/support/rails_5_1_1/app/views/layouts/application.html.erb +14 -0
  394. data/test/support/rails_5_1_1/config/application.rb +30 -0
  395. data/test/support/rails_5_1_1/config/boot.rb +4 -0
  396. data/test/support/rails_5_1_1/config/database.yml +11 -0
  397. data/test/support/rails_5_1_1/config/environment.rb +5 -0
  398. data/test/support/rails_5_1_1/config/environments/development.rb +25 -0
  399. data/test/support/rails_5_1_1/config/environments/production.rb +73 -0
  400. data/test/support/rails_5_1_1/config/environments/test.rb +36 -0
  401. data/test/support/rails_5_1_1/config/initializers/backtrace_silencers.rb +7 -0
  402. data/test/support/rails_5_1_1/config/initializers/filter_parameter_logging.rb +4 -0
  403. data/test/support/rails_5_1_1/config/initializers/inflections.rb +16 -0
  404. data/test/support/rails_5_1_1/config/initializers/load_schema.rb +4 -0
  405. data/test/support/rails_5_1_1/config/initializers/mime_types.rb +5 -0
  406. data/test/support/rails_5_1_1/config/initializers/secret_token.rb +12 -0
  407. data/test/support/rails_5_1_1/config/initializers/session_store.rb +3 -0
  408. data/test/support/rails_5_1_1/config/initializers/wrap_parameters.rb +14 -0
  409. data/test/support/rails_5_1_1/config/locales/en.yml +23 -0
  410. data/test/support/rails_5_1_1/config/routes.rb +3 -0
  411. data/test/support/rails_5_1_1/config.ru +4 -0
  412. data/test/support/rails_5_1_1/db/schema.rb +22 -0
  413. data/test/support/rails_5_1_1/lib/assets/.keep +0 -0
  414. data/test/support/rails_5_1_1/lib/tasks/.keep +0 -0
  415. data/test/support/rails_5_1_1/public/404.html +58 -0
  416. data/test/support/rails_5_1_1/public/422.html +58 -0
  417. data/test/support/rails_5_1_1/public/500.html +57 -0
  418. data/test/support/rails_5_1_1/public/favicon.ico +0 -0
  419. data/test/support/rails_5_1_1/public/robots.txt +5 -0
  420. data/test/support/rails_5_1_1/script/bundle +3 -0
  421. data/test/support/rails_5_1_1/script/rails +4 -0
  422. data/test/support/rails_5_1_1/script/rake +4 -0
  423. data/test/test_helper.rb +149 -11
  424. data/test/worker_test.rb +1 -1
  425. metadata +974 -143
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ require 'sidekiq'
3
+
4
+ class SidekiqWorkersSendMetricsTest < AcceptanceTestCase
5
+
6
+ def test_sidekiq_worker_sends_metrics
7
+ test_sidekiq_worker = TestSidekiqServer.new
8
+ test_endpoint = TestEndpoint.new(port: 8081)
9
+
10
+ test_endpoint.listen
11
+ test_sidekiq_worker.boot(chillout_port: 8081)
12
+ test_sidekiq_worker.push_job
13
+
14
+ if ENV['STRATEGY'] != 'active_job'
15
+ assert test_endpoint.has_received_information_about_startup
16
+ end
17
+ assert test_endpoint.has_one_creation_for_entity_resource
18
+ ensure
19
+ test_sidekiq_worker.shutdown if test_sidekiq_worker
20
+ end
21
+
22
+ end if ENV['SIDEKIQ_SUPPORTED']
data/test/config_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'minitest/stub_const'
2
3
 
3
4
  class ConfigTest < ChilloutTestCase
4
5
 
@@ -23,4 +24,33 @@ class ConfigTest < ChilloutTestCase
23
24
  assert_equal @config.api_key, @config.authentication_password
24
25
  end
25
26
 
26
- end
27
+ def test_default_strategy_is_thread
28
+ assert_equal :thread, @config.strategy
29
+ end
30
+
31
+ def test_can_assign_thread
32
+ @config.strategy = "thread"
33
+ assert_equal :thread, @config.strategy
34
+ end
35
+
36
+ def test_cannot_assing_bullshit
37
+ assert_raises(ArgumentError) do
38
+ @config.strategy = "bullshit"
39
+ end
40
+ end
41
+
42
+ def test_can_assign_active_job_strategy
43
+ Object.stub_remove_const(:ActiveJob) do
44
+ refute defined?(ActiveJob)
45
+ assert_raises(ArgumentError) do
46
+ @config.strategy = :active_job
47
+ end
48
+ end
49
+
50
+ Object.stub_const(:ActiveJob, :WhatEver) do
51
+ @config.strategy = :active_job
52
+ assert_equal :active_job, @config.strategy
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class CustomMetricTest < ChilloutTestCase
4
+ def setup
5
+ @creations_container = MiniTest::Mock.new
6
+ end
7
+
8
+ def test_custom_creation
9
+ @creations_container.expect(:nil?, false, [])
10
+ @creations_container.expect(:increment!, nil, ['foo'])
11
+ @custom_metric = Chillout::CustomMetric.new(@creations_container)
12
+ @custom_metric.track('foo')
13
+ @creations_container.verify
14
+ end
15
+ end
@@ -4,7 +4,8 @@ require 'chillout/creations_container'
4
4
 
5
5
  module Chillout
6
6
  class EventDataBuilderTest < ChilloutTestCase
7
- setup do
7
+ def setup
8
+ super
8
9
  @shell_env = { 'PATH' => '/bin:/usr/bin' }
9
10
  @api_key = "s3cr3t"
10
11
 
@@ -18,46 +19,51 @@ module Chillout
18
19
  @timestamp = Time.now.iso8601
19
20
  end
20
21
 
21
- context "build from creations container" do
22
- setup do
23
- @creations_container = CreationsContainer.new
24
- 5.times { @creations_container.increment!("User") }
25
- 3.times { @creations_container.increment!("Cart") }
26
- 8.times { @creations_container.increment!("CartItem") }
27
-
28
- @event_data_builder = EventDataBuilder.new(@config)
29
- @event_data = @event_data_builder.build_from_creations_container(@creations_container, @timestamp)
30
- end
31
-
32
- def test_metric_type
33
- assert_param :metric, "creations"
34
- end
35
-
36
- def test_timestamp
37
- assert_param :timestamp, @timestamp
38
- end
39
-
40
- def test_each_counter
41
- assert_creations :User, 5
42
- assert_creations :Cart, 3
43
- assert_creations :CartItem, 8
44
- end
45
-
46
- def test_environment
47
- assert_content :environment, "development"
48
- end
49
-
50
- def test_notifier_name
51
- assert_notifier :name, "chillout"
52
- end
53
-
54
- def test_notifier_version
55
- assert_notifier :version, "0.1"
56
- end
57
-
58
- def test_notifier_url
59
- assert_notifier :url, "http://github.com/arkency/chillout"
60
- end
22
+ def build_from_creations_container
23
+ @creations_container = CreationsContainer.new
24
+ 5.times { @creations_container.increment!("User") }
25
+ 3.times { @creations_container.increment!("Cart") }
26
+ 8.times { @creations_container.increment!("CartItem") }
27
+
28
+ @event_data_builder = EventDataBuilder.new(@config)
29
+ @event_data = @event_data_builder.build_from_creations_container(@creations_container, @timestamp)
30
+ end
31
+
32
+ def test_metric_type
33
+ build_from_creations_container
34
+ assert_param :metric, "creations"
35
+ end
36
+
37
+ def test_timestamp
38
+ build_from_creations_container
39
+ assert_param :timestamp, @timestamp
40
+ end
41
+
42
+ def test_each_counter
43
+ build_from_creations_container
44
+ assert_creations :User, 5
45
+ assert_creations :Cart, 3
46
+ assert_creations :CartItem, 8
47
+ end
48
+
49
+ def test_environment
50
+ build_from_creations_container
51
+ assert_content :environment, "development"
52
+ end
53
+
54
+ def test_notifier_name
55
+ build_from_creations_container
56
+ assert_notifier :name, "chillout"
57
+ end
58
+
59
+ def test_notifier_version
60
+ build_from_creations_container
61
+ assert_notifier :version, "0.1"
62
+ end
63
+
64
+ def test_notifier_url
65
+ build_from_creations_container
66
+ assert_notifier :url, "http://github.com/arkency/chillout"
61
67
  end
62
68
 
63
69
  private
@@ -1,10 +1,15 @@
1
1
  require 'test_helper'
2
+ require 'active_job'
3
+ require 'active_job/test_helper'
2
4
 
3
5
  class ClientIntegrationTest < ChilloutTestCase
6
+ include ActiveJob::TestHelper
7
+
4
8
  def test_check_api_connection_with_200_ok_response
5
9
  @_api_key = "xyz123"
6
10
  url = api_url("check")
7
- stub_request(:get, url).to_return(:body => "OK", :status => 200)
11
+ stub_request(:get, url).with(basic_auth: ['xyz123', 'xyz123']).
12
+ to_return(:body => "OK", :status => 200)
8
13
 
9
14
  client = Chillout::Client.new(@_api_key)
10
15
  check_result = client.check_api_connection
@@ -14,7 +19,8 @@ class ClientIntegrationTest < ChilloutTestCase
14
19
  def test_check_api_connection_with_other_response
15
20
  @_api_key = "xyz123"
16
21
  url = api_url("check")
17
- stub_request(:get, url).to_return(:body => "Not Found", :status => 404)
22
+ stub_request(:get, url).with(basic_auth: ['xyz123', 'xyz123']).
23
+ to_return(:body => "Not Found", :status => 404)
18
24
 
19
25
  client = Chillout::Client.new(@_api_key)
20
26
  check_result = client.check_api_connection
@@ -24,10 +30,78 @@ class ClientIntegrationTest < ChilloutTestCase
24
30
  def test_check_api_connection_with_raised_exception_on_request
25
31
  @_api_key = "xyz123"
26
32
  url = api_url("check")
27
- stub_request(:get, url).to_raise(StandardError)
33
+ stub_request(:get, url).with(basic_auth: ['xyz123', 'xyz123']).
34
+ to_raise(StandardError)
28
35
 
29
36
  client = Chillout::Client.new(@_api_key)
30
37
  check_result = client.check_api_connection
31
38
  refute check_result.successful?, "Check was successful"
32
39
  end
33
- end
40
+
41
+ def test_client_creats_new_worker_thread_after_exception
42
+ @_api_key = "xyz123"
43
+ stub_request(:post, api_url("clients")).with(basic_auth: ['xyz123', 'xyz123']).
44
+ to_return(:body => "OK", :status => 200)
45
+ stub_request(:post, api_url("metrics")).with(basic_auth: ['xyz123', 'xyz123']).
46
+ to_return(:body => "OK", :status => 200)
47
+
48
+ client = Chillout::Client.new(@_api_key)
49
+ client.enqueue(Chillout::CreationsContainer.new)
50
+ assert client.worker_running?
51
+
52
+ client.enqueue(nil)
53
+ sleep(6)
54
+ refute client.worker_running?
55
+
56
+ client.enqueue(Chillout::CreationsContainer.new)
57
+ assert client.worker_running?
58
+
59
+ client.enqueue(nil)
60
+ sleep(6)
61
+ refute client.worker_running?
62
+ end
63
+
64
+ def test_active_job_queueing
65
+ assert_enqueued_jobs 0
66
+ client = Chillout::Client.new("xyz123", strategy: :active_job)
67
+ container = Chillout::CreationsContainer.new
68
+ container.increment!("User")
69
+
70
+ assert_enqueued_jobs 1, only: Chillout::Job, queue: "chillout" do
71
+ client.enqueue(container)
72
+ end
73
+ end
74
+
75
+ def test_active_job_performing
76
+ @_api_key = "xyz123"
77
+ stub_request(:post, api_url("metrics")).with(basic_auth: ['xyz123', 'xyz123']).
78
+ to_return(:body => "OK", :status => 200)
79
+
80
+ client = Chillout::Client.new("xyz123", strategy: :active_job)
81
+ container = Chillout::CreationsContainer.new
82
+ container.increment!("User")
83
+
84
+ perform_enqueued_jobs do
85
+ assert_performed_jobs 1, only: Chillout::Job do
86
+ client.enqueue(container)
87
+ end
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ def self.active_job_4_test_helper?
94
+ instance_method(:assert_performed_jobs).arity == 1 && instance_method(:assert_enqueued_jobs).arity == 1
95
+ end
96
+
97
+ if active_job_4_test_helper?
98
+ prepend(Module.new(){
99
+ def assert_performed_jobs(number, only: nil, &block)
100
+ super(number, &block)
101
+ end
102
+ def assert_enqueued_jobs(number, only: nil, queue: nil, &block)
103
+ super(number, &block)
104
+ end
105
+ })
106
+ end
107
+ end
@@ -15,7 +15,7 @@ class WorkerIntegrationTest < ChilloutTestCase
15
15
  client = Chillout::Client.new(@_api_key, :logger => null_logger)
16
16
  worker_check = Proc.new do
17
17
  client.enqueue(Chillout::CreationsContainer.new)
18
- assert client.worker_running?
18
+ client.worker_running? ? Process.exit!(0) : Process.exit!(28)
19
19
  end
20
20
 
21
21
  assert_successful_exit Process.fork(&worker_check)
@@ -23,8 +23,9 @@ class WorkerIntegrationTest < ChilloutTestCase
23
23
 
24
24
  def test_worker_running_lazily
25
25
  client = Chillout::Client.new(@_api_key, :logger => null_logger)
26
- client.enqueue(Chillout::CreationsContainer.new)
26
+ assert !client.worker_running?
27
27
 
28
+ client.enqueue(Chillout::CreationsContainer.new)
28
29
  assert client.worker_running?
29
30
  end
30
31
 
@@ -3,47 +3,46 @@ require 'test_helper'
3
3
  module Chillout
4
4
  module Middleware
5
5
  class CreationsMonitorTest < ChilloutTestCase
6
- setup do
6
+ def setup
7
7
  @env = { 'HOST' => 'example.net' }
8
- @logger = stub(:info => "")
9
- @client = stub(:logger => @logger)
8
+ @logger = stub(info: "", debug: "")
9
+ @client = stub(logger: @logger)
10
10
  end
11
11
 
12
- context "for call with model creation" do
13
- setup do
14
- @app = lambda do |env|
15
- Thread.current[:creations] = :creations
16
- [200, env, ['hello']]
17
- end
18
- @middleware = CreationsMonitor.new(@app, @client)
12
+ def call_with_model_creation
13
+ @app = lambda do |env|
14
+ Thread.current[:creations] = :creations
15
+ [200, env, ['hello']]
19
16
  end
17
+ @middleware = CreationsMonitor.new(@app, @client)
18
+ end
20
19
 
21
- def test_behaves_like_rack_middleware
22
- @client.stubs(:enqueue)
23
- response = @middleware.call(@env)
24
- assert_equal [200, @env, ['hello']], response
25
- end
20
+ def test_behaves_like_rack_middleware
21
+ call_with_model_creation
22
+ @client.stubs(:enqueue)
23
+ response = @middleware.call(@env)
24
+ assert_equal [200, @env, ['hello']], response
25
+ end
26
26
 
27
- def test_clients_queue_receive_creations
28
- @client.expects(:enqueue).with(:creations)
27
+ def test_clients_queue_receive_creations
28
+ call_with_model_creation
29
+ @client.expects(:enqueue).with(:creations)
29
30
 
30
- @middleware.call(@env)
31
- end
31
+ @middleware.call(@env)
32
32
  end
33
33
 
34
- context "for call without model creation" do
35
- setup do
36
- @app = lambda do |env|
37
- [200, env, ['hello']]
38
- end
39
- @middleware = CreationsMonitor.new(@app, @client)
34
+ def call_without_model_creation
35
+ @app = lambda do |env|
36
+ [200, env, ['hello']]
40
37
  end
38
+ @middleware = CreationsMonitor.new(@app, @client)
39
+ end
41
40
 
42
- def test_behaves_like_rack_middleware
43
- response = @middleware.call(@env)
41
+ def test_behaves_like_rack_middleware
42
+ call_without_model_creation
43
+ response = @middleware.call(@env)
44
44
 
45
- assert_equal [200, @env, ['hello']], response
46
- end
45
+ assert_equal [200, @env, ['hello']], response
47
46
  end
48
47
  end
49
48
  end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+ require 'sidekiq/testing'
3
+ require 'chillout/middleware/sidekiq'
4
+
5
+ module Chillout
6
+ module Middleware
7
+ class SidekiqTest < ChilloutTestCase
8
+
9
+ def setup
10
+ @client = mock("Client")
11
+ @integration = Integrations::Sidekiq.new
12
+ @integration.enable(@client, ::Sidekiq::Testing)
13
+ end
14
+
15
+ def teardown
16
+ @integration.disable
17
+ end
18
+
19
+ class FakeJob
20
+ MOCK_CREATIONS = Object.new.freeze
21
+ include Sidekiq::Worker
22
+ def perform
23
+ Chillout.creations = MOCK_CREATIONS
24
+ end
25
+ end
26
+
27
+ def test_enqueues_and_clears_creations
28
+ @client.expects(:enqueue).with(FakeJob::MOCK_CREATIONS)
29
+ Sidekiq::Testing.inline! { FakeJob.perform_async }
30
+ assert_nil Chillout.creations
31
+ end
32
+
33
+ class EmptyJob
34
+ include Sidekiq::Worker
35
+ def perform; end
36
+ end
37
+
38
+ def test_does_nothing_when_no_creations
39
+ Sidekiq::Testing.inline! { EmptyJob.perform_async }
40
+ assert_nil Chillout.creations
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -32,5 +32,18 @@ module Chillout
32
32
  })
33
33
  end
34
34
  end
35
+
36
+ def test_customized_host_port_and_ssl
37
+ ENV['CHILLOUT_CLIENT_HOST'] = 'localhost'
38
+ ENV['CHILLOUT_CLIENT_PORT'] = '8080'
39
+ ENV['CHILLOUT_CLIENT_SSL'] = 'false'
40
+ client = PlainHttpClient.new
41
+ assert_equal 'localhost', client.host
42
+ assert_equal 8080, client.port
43
+ assert_equal false, client.ssl
44
+ ENV.delete('CHILLOUT_CLIENT_HOST')
45
+ ENV.delete('CHILLOUT_CLIENT_PORT')
46
+ ENV.delete('CHILLOUT_CLIENT_SSL')
47
+ end
35
48
  end
36
49
  end
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.13'
4
+ gem 'sqlite3'
5
+ gem 'chillout', :path => '../../../'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Rails3213::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ # protect_from_forgery
3
+ end
@@ -0,0 +1,70 @@
1
+ class EntitiesController < ApplicationController
2
+ def index
3
+ @entities = Entity.all
4
+
5
+ respond_to do |format|
6
+ format.html # index.html.erb
7
+ format.json { render :json => @entities }
8
+ end
9
+ end
10
+
11
+ def show
12
+ @entity = Entity.find(params[:id])
13
+
14
+ respond_to do |format|
15
+ format.html # show.html.erb
16
+ format.json { render :json => @entity }
17
+ end
18
+ end
19
+
20
+ def new
21
+ @entity = Entity.new
22
+
23
+ respond_to do |format|
24
+ format.html # new.html.erb
25
+ format.json { render :json => @entity }
26
+ end
27
+ end
28
+
29
+ def edit
30
+ @entity = Entity.find(params[:id])
31
+ end
32
+
33
+ def create
34
+ @entity = Entity.new(params[:entity])
35
+
36
+ respond_to do |format|
37
+ if @entity.save
38
+ format.html { redirect_to @entity, :notice => 'Entity was successfully created.' }
39
+ format.json { render :json => @entity, :status => :created, :location => @entity }
40
+ else
41
+ format.html { render :action => "new" }
42
+ format.json { render :json => @entity.errors, :status => :unprocessable_entity }
43
+ end
44
+ end
45
+ end
46
+
47
+ def update
48
+ @entity = Entity.find(params[:id])
49
+
50
+ respond_to do |format|
51
+ if @entity.update_attributes(params[:entity])
52
+ format.html { redirect_to @entity, :notice => 'Entity was successfully updated.' }
53
+ format.json { head :no_content }
54
+ else
55
+ format.html { render :action => "edit" }
56
+ format.json { render :json => @entity.errors, :status => :unprocessable_entity }
57
+ end
58
+ end
59
+ end
60
+
61
+ def destroy
62
+ @entity = Entity.find(params[:id])
63
+ @entity.destroy
64
+
65
+ respond_to do |format|
66
+ format.html { redirect_to entities_url }
67
+ format.json { head :no_content }
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class Entity < ActiveRecord::Base
2
+ attr_accessible :name
3
+ end
@@ -0,0 +1,21 @@
1
+ <%= form_for(@entity) do |f| %>
2
+ <% if @entity.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@entity.errors.count, "error") %> prohibited this entity from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @entity.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing entity</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @entity %> |
6
+ <%= link_to 'Back', entities_path %>
@@ -0,0 +1,23 @@
1
+ <h1>Listing entities</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @entities.each do |entity| %>
12
+ <tr>
13
+ <td><%= entity.name %></td>
14
+ <td><%= link_to 'Show', entity %></td>
15
+ <td><%= link_to 'Edit', edit_entity_path(entity) %></td>
16
+ <td><%= link_to 'Destroy', entity, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Entity', new_entity_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New entity</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', entities_path %>
@@ -0,0 +1,10 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @entity.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_entity_path(@entity) %> |
10
+ <%= link_to 'Back', entities_path %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SampleRailsApp</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>