supplejack_api 1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +80 -0
  3. data/Rakefile +42 -0
  4. data/app/assets/javascripts/supplejack_api/application.js +26 -0
  5. data/app/assets/stylesheets/supplejack_api/application.css +30 -0
  6. data/app/controllers/supplejack_api/admin/base_controller.rb +24 -0
  7. data/app/controllers/supplejack_api/admin/sessions_controller.rb +25 -0
  8. data/app/controllers/supplejack_api/admin/site_activities_controller.rb +21 -0
  9. data/app/controllers/supplejack_api/admin/users_controller.rb +55 -0
  10. data/app/controllers/supplejack_api/application_controller.rb +70 -0
  11. data/app/controllers/supplejack_api/concepts_controller.rb +52 -0
  12. data/app/controllers/supplejack_api/concerns/ignore_metrics.rb +14 -0
  13. data/app/controllers/supplejack_api/concerns/records_controller_metrics.rb +26 -0
  14. data/app/controllers/supplejack_api/concerns/set_items_controller_metrics.rb +20 -0
  15. data/app/controllers/supplejack_api/concerns/user_sets_controller_metrics.rb +26 -0
  16. data/app/controllers/supplejack_api/harvester/concepts_controller.rb +41 -0
  17. data/app/controllers/supplejack_api/harvester/fragments_controller.rb +30 -0
  18. data/app/controllers/supplejack_api/harvester/records_controller.rb +68 -0
  19. data/app/controllers/supplejack_api/metrics_api_controller.rb +44 -0
  20. data/app/controllers/supplejack_api/partners_controller.rb +39 -0
  21. data/app/controllers/supplejack_api/records_controller.rb +71 -0
  22. data/app/controllers/supplejack_api/schema_controller.rb +19 -0
  23. data/app/controllers/supplejack_api/set_items_controller.rb +38 -0
  24. data/app/controllers/supplejack_api/sources_controller.rb +67 -0
  25. data/app/controllers/supplejack_api/status_controller.rb +67 -0
  26. data/app/controllers/supplejack_api/user_sets_controller.rb +97 -0
  27. data/app/controllers/supplejack_api/users_controller.rb +49 -0
  28. data/app/helpers/supplejack_api/application_helper.rb +39 -0
  29. data/app/helpers/supplejack_api/facets_helper.rb +30 -0
  30. data/app/mailers/supplejack_api/request_limit_mailer.rb +43 -0
  31. data/app/models/supplejack_api/api_concept/concept_fragment.rb +31 -0
  32. data/app/models/supplejack_api/api_record/record_fragment.rb +15 -0
  33. data/app/models/supplejack_api/concept.rb +46 -0
  34. data/app/models/supplejack_api/concept_search.rb +86 -0
  35. data/app/models/supplejack_api/concerns/queryable_by_date.rb +31 -0
  36. data/app/models/supplejack_api/concerns/record.rb +108 -0
  37. data/app/models/supplejack_api/concerns/record_fragmentable.rb +24 -0
  38. data/app/models/supplejack_api/concerns/searchable.rb +430 -0
  39. data/app/models/supplejack_api/concerns/user_set.rb +219 -0
  40. data/app/models/supplejack_api/daily_metrics.rb +20 -0
  41. data/app/models/supplejack_api/faceted_metrics.rb +55 -0
  42. data/app/models/supplejack_api/fragment.rb +82 -0
  43. data/app/models/supplejack_api/interaction_models/record.rb +60 -0
  44. data/app/models/supplejack_api/interaction_models/set.rb +13 -0
  45. data/app/models/supplejack_api/interaction_updaters/all_usage_metric.rb +41 -0
  46. data/app/models/supplejack_api/interaction_updaters/set_metrics.rb +32 -0
  47. data/app/models/supplejack_api/interaction_updaters/usage_metrics.rb +73 -0
  48. data/app/models/supplejack_api/partner.rb +24 -0
  49. data/app/models/supplejack_api/preview_record.rb +30 -0
  50. data/app/models/supplejack_api/record.rb +18 -0
  51. data/app/models/supplejack_api/record_search.rb +12 -0
  52. data/app/models/supplejack_api/schema_definition.rb +147 -0
  53. data/app/models/supplejack_api/search.rb +14 -0
  54. data/app/models/supplejack_api/set_item.rb +57 -0
  55. data/app/models/supplejack_api/site_activity.rb +59 -0
  56. data/app/models/supplejack_api/source.rb +28 -0
  57. data/app/models/supplejack_api/source_activity.rb +36 -0
  58. data/app/models/supplejack_api/source_authority.rb +42 -0
  59. data/app/models/supplejack_api/supplejack_schema.rb +37 -0
  60. data/app/models/supplejack_api/support/concept/searchable.rb +79 -0
  61. data/app/models/supplejack_api/support/concept/storable.rb +59 -0
  62. data/app/models/supplejack_api/support/fragment_helpers.rb +96 -0
  63. data/app/models/supplejack_api/support/harvestable.rb +105 -0
  64. data/app/models/supplejack_api/support/searchable.rb +115 -0
  65. data/app/models/supplejack_api/support/status_logger.rb +23 -0
  66. data/app/models/supplejack_api/support/storable.rb +49 -0
  67. data/app/models/supplejack_api/support/validation_logger.rb +23 -0
  68. data/app/models/supplejack_api/usage_metrics.rb +25 -0
  69. data/app/models/supplejack_api/user.rb +211 -0
  70. data/app/models/supplejack_api/user_activity.rb +65 -0
  71. data/app/models/supplejack_api/user_set.rb +17 -0
  72. data/app/serializers/supplejack_api/application_serializer.rb +12 -0
  73. data/app/serializers/supplejack_api/concept_record_serializer.rb +23 -0
  74. data/app/serializers/supplejack_api/concept_search_serializer.rb +12 -0
  75. data/app/serializers/supplejack_api/concept_serializer.rb +100 -0
  76. data/app/serializers/supplejack_api/concerns/record_serializable.rb +119 -0
  77. data/app/serializers/supplejack_api/concerns/search_serializable.rb +24 -0
  78. data/app/serializers/supplejack_api/record_search_serializer.rb +64 -0
  79. data/app/serializers/supplejack_api/record_serializer.rb +13 -0
  80. data/app/serializers/supplejack_api/search_serializer.rb +13 -0
  81. data/app/serializers/supplejack_api/source_authority_serializer.rb +23 -0
  82. data/app/serializers/supplejack_api/user_serializer.rb +13 -0
  83. data/app/serializers/supplejack_api/user_set_record_serializer.rb +14 -0
  84. data/app/serializers/supplejack_api/user_set_serializer.rb +77 -0
  85. data/app/services/metrics_api/v3/api.rb +30 -0
  86. data/app/services/metrics_api/v3/endpoints/facets.rb +23 -0
  87. data/app/services/metrics_api/v3/endpoints/global.rb +26 -0
  88. data/app/services/metrics_api/v3/endpoints/helpers.rb +14 -0
  89. data/app/services/metrics_api/v3/endpoints/root.rb +97 -0
  90. data/app/services/metrics_api/v3/presenters/daily_metric.rb +23 -0
  91. data/app/services/metrics_api/v3/presenters/extended_metadata.rb +41 -0
  92. data/app/services/metrics_api/v3/presenters/record.rb +26 -0
  93. data/app/services/metrics_api/v3/presenters/view.rb +28 -0
  94. data/app/views/layouts/supplejack_api/_head.html.erb +17 -0
  95. data/app/views/layouts/supplejack_api/_top_nav.html.erb +33 -0
  96. data/app/views/layouts/supplejack_api/application.html.erb +33 -0
  97. data/app/views/supplejack_api/admin/sessions/new.html.erb +25 -0
  98. data/app/views/supplejack_api/admin/shared/_links.erb +34 -0
  99. data/app/views/supplejack_api/admin/site_activities/index.csv.erb +22 -0
  100. data/app/views/supplejack_api/admin/site_activities/index.html.erb +54 -0
  101. data/app/views/supplejack_api/admin/users/edit.html.erb +16 -0
  102. data/app/views/supplejack_api/admin/users/index.csv.erb +22 -0
  103. data/app/views/supplejack_api/admin/users/index.html.erb +57 -0
  104. data/app/views/supplejack_api/admin/users/show.html.erb +33 -0
  105. data/app/views/supplejack_api/request_limit_mailer/at100percent.text.erb +13 -0
  106. data/app/views/supplejack_api/request_limit_mailer/at100percent_admin.text.erb +1 -0
  107. data/app/views/supplejack_api/request_limit_mailer/at90percent.text.erb +13 -0
  108. data/app/views/supplejack_api/request_limit_mailer/at90percent_admin.text.erb +1 -0
  109. data/app/workers/supplejack_api/daily_metrics_worker.rb +112 -0
  110. data/app/workers/supplejack_api/interaction_metrics_worker.rb +45 -0
  111. data/config/cucumber.yml +16 -0
  112. data/config/initializers/force_eagerload.rb +11 -0
  113. data/config/initializers/interaction_updaters.rb +7 -0
  114. data/config/routes.rb +81 -0
  115. data/db/binding_records.development.json +7 -0
  116. data/db/binding_records.staging.json +7 -0
  117. data/db/concepts.json +33 -0
  118. data/db/concepts_data.json +569745 -0
  119. data/db/source_authorities.json +119 -0
  120. data/lib/generators/supplejack_api/install_generator.rb +124 -0
  121. data/lib/mongoid/paperclip.rb +53 -0
  122. data/lib/mongoid/string.rb +20 -0
  123. data/lib/sunspot/mongoid.rb +51 -0
  124. data/lib/sunspot/resque_session_proxy.rb +72 -0
  125. data/lib/sunspot/sunspot_spellcheck.rb +98 -0
  126. data/lib/supplejack_api.rb +13 -0
  127. data/lib/supplejack_api/admin/sortable.rb +40 -0
  128. data/lib/supplejack_api/engine.rb +46 -0
  129. data/lib/supplejack_api/harvester_constraint.rb +28 -0
  130. data/lib/supplejack_api/stylesheets.rb +36 -0
  131. data/lib/supplejack_api/utils.rb +75 -0
  132. data/lib/supplejack_api/version.rb +11 -0
  133. data/lib/tasks/resque.rake +22 -0
  134. data/lib/url_validator.rb +38 -0
  135. data/spec/controllers/supplejack_api/admin/base_controller_spec.rb +55 -0
  136. data/spec/controllers/supplejack_api/admin/site_activities_controller_spec.rb +43 -0
  137. data/spec/controllers/supplejack_api/admin/users_controller_spec.rb +79 -0
  138. data/spec/controllers/supplejack_api/application_controller_spec.rb +133 -0
  139. data/spec/controllers/supplejack_api/concepts_controller_spec.rb +83 -0
  140. data/spec/controllers/supplejack_api/concerns/records_controller_metrics_spec.rb +60 -0
  141. data/spec/controllers/supplejack_api/harvester/concepts_controller_spec.rb +57 -0
  142. data/spec/controllers/supplejack_api/harvester/records_controller_spec.rb +138 -0
  143. data/spec/controllers/supplejack_api/metrics_api_controller_spec.rb +71 -0
  144. data/spec/controllers/supplejack_api/partners_controller_spec.rb +77 -0
  145. data/spec/controllers/supplejack_api/records_controller_spec.rb +143 -0
  146. data/spec/controllers/supplejack_api/set_items_controller_spec.rb +78 -0
  147. data/spec/controllers/supplejack_api/sources_controller_spec.rb +161 -0
  148. data/spec/controllers/supplejack_api/status_controller_spec.rb +120 -0
  149. data/spec/controllers/supplejack_api/user_sets_controller_spec.rb +233 -0
  150. data/spec/controllers/supplejack_api/users_controller_spec.rb +61 -0
  151. data/spec/dummy/README.rdoc +268 -0
  152. data/spec/dummy/Rakefile +7 -0
  153. data/spec/dummy/app/assets/javascripts/application.js +23 -0
  154. data/spec/dummy/app/assets/stylesheets/application.css +22 -0
  155. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  156. data/spec/dummy/app/helpers/application_helper.rb +9 -0
  157. data/spec/dummy/app/supplejack_api/concept_schema.rb +83 -0
  158. data/spec/dummy/app/supplejack_api/record_schema.rb +64 -0
  159. data/spec/dummy/app/supplejack_api/record_schema.txt +66 -0
  160. data/spec/dummy/app/views/layouts/application.html.erb +23 -0
  161. data/spec/dummy/app/workers/supplejack_api/clear_index_buffer.rb +32 -0
  162. data/spec/dummy/app/workers/supplejack_api/flush_old_records_worker.rb +17 -0
  163. data/spec/dummy/app/workers/supplejack_api/index_buffer.rb +49 -0
  164. data/spec/dummy/app/workers/supplejack_api/index_source_worker.rb +39 -0
  165. data/spec/dummy/app/workers/supplejack_api/index_worker.rb +82 -0
  166. data/spec/dummy/app/workers/supplejack_api/store_user_activity_worker.rb +24 -0
  167. data/spec/dummy/config.ru +11 -0
  168. data/spec/dummy/config/application.rb +76 -0
  169. data/spec/dummy/config/application.yml +31 -0
  170. data/spec/dummy/config/application.yml.example +36 -0
  171. data/spec/dummy/config/boot.rb +17 -0
  172. data/spec/dummy/config/environment.rb +12 -0
  173. data/spec/dummy/config/environments/development.rb +42 -0
  174. data/spec/dummy/config/environments/production.rb +76 -0
  175. data/spec/dummy/config/environments/test.rb +46 -0
  176. data/spec/dummy/config/initializers/backtrace_silencers.rb +14 -0
  177. data/spec/dummy/config/initializers/devise.rb +214 -0
  178. data/spec/dummy/config/initializers/inflections.rb +22 -0
  179. data/spec/dummy/config/initializers/kaminari_config.rb +17 -0
  180. data/spec/dummy/config/initializers/mime_types.rb +12 -0
  181. data/spec/dummy/config/initializers/mongoid.rb +9 -0
  182. data/spec/dummy/config/initializers/quiet_logger.rb +23 -0
  183. data/spec/dummy/config/initializers/resque.rb +18 -0
  184. data/spec/dummy/config/initializers/secret_token.rb +14 -0
  185. data/spec/dummy/config/initializers/session_store.rb +15 -0
  186. data/spec/dummy/config/initializers/simple_form.rb +149 -0
  187. data/spec/dummy/config/initializers/simple_form_foundation.rb +33 -0
  188. data/spec/dummy/config/initializers/state_machine.rb +8 -0
  189. data/spec/dummy/config/initializers/sunspot.rb +32 -0
  190. data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
  191. data/spec/dummy/config/locales/devise.en.yml +63 -0
  192. data/spec/dummy/config/locales/en.yml +66 -0
  193. data/spec/dummy/config/locales/simple_form.en.yml +33 -0
  194. data/spec/dummy/config/mongoid.travis.yml +34 -0
  195. data/spec/dummy/config/mongoid.yml +36 -0
  196. data/spec/dummy/config/resque-pool.yml +18 -0
  197. data/spec/dummy/config/resque_schedule.yml +12 -0
  198. data/spec/dummy/config/routes.rb +11 -0
  199. data/spec/dummy/config/secrets.yml +8 -0
  200. data/spec/dummy/config/sunspot.yml +38 -0
  201. data/spec/dummy/db/concepts.json +37 -0
  202. data/spec/dummy/db/source_authorities.json +116 -0
  203. data/spec/dummy/public/404.html +35 -0
  204. data/spec/dummy/public/422.html +35 -0
  205. data/spec/dummy/public/500.html +34 -0
  206. data/spec/dummy/public/favicon.ico +8 -0
  207. data/spec/dummy/script/rails +6 -0
  208. data/spec/dummy/solr/collection1/conf/elevate.xml +36 -0
  209. data/spec/dummy/solr/collection1/conf/mapping-FoldToASCII.txt +3813 -0
  210. data/spec/dummy/solr/collection1/conf/schema.xml +292 -0
  211. data/spec/dummy/solr/collection1/conf/solrconfig.xml +1780 -0
  212. data/spec/dummy/solr/collection1/conf/spellings.txt +2 -0
  213. data/spec/dummy/solr/collection1/conf/stopwords.txt +58 -0
  214. data/spec/dummy/solr/collection1/conf/synonyms.txt +31 -0
  215. data/spec/factories/concepts.rb +16 -0
  216. data/spec/factories/daily_metrics.rb +10 -0
  217. data/spec/factories/faceted_metrics.rb +25 -0
  218. data/spec/factories/fragment.rb +14 -0
  219. data/spec/factories/partners.rb +14 -0
  220. data/spec/factories/record_interaction.rb +17 -0
  221. data/spec/factories/records.rb +47 -0
  222. data/spec/factories/set_interaction.rb +15 -0
  223. data/spec/factories/source_authorities.rb +19 -0
  224. data/spec/factories/sources.rb +16 -0
  225. data/spec/factories/usage_metrics.rb +20 -0
  226. data/spec/factories/user_activities.rb +14 -0
  227. data/spec/factories/user_sets.rb +27 -0
  228. data/spec/factories/users.rb +23 -0
  229. data/spec/helpers/application_helper_spec.rb +35 -0
  230. data/spec/models/concept_spec.rb +163 -0
  231. data/spec/models/fragment_spec.rb +15 -0
  232. data/spec/models/site_activity_spec.rb +103 -0
  233. data/spec/models/source_activity_spec.rb +56 -0
  234. data/spec/models/source_authority_spec.rb +42 -0
  235. data/spec/models/supplejack_api/api_concept/concept_fragment_spec.rb +189 -0
  236. data/spec/models/supplejack_api/api_record/record_fragment_spec.rb +189 -0
  237. data/spec/models/supplejack_api/concept_spec.rb +0 -0
  238. data/spec/models/supplejack_api/interaction_updaters/all_usage_metric_spec.rb +41 -0
  239. data/spec/models/supplejack_api/interaction_updaters/set_metrics_spec.rb +32 -0
  240. data/spec/models/supplejack_api/interaction_updaters/usage_metrics_spec.rb +44 -0
  241. data/spec/models/supplejack_api/partner_spec.rb +20 -0
  242. data/spec/models/supplejack_api/record_search_spec.rb +429 -0
  243. data/spec/models/supplejack_api/record_spec.rb +280 -0
  244. data/spec/models/supplejack_api/schema_definition_spec.rb +272 -0
  245. data/spec/models/supplejack_api/search_spec.rb +243 -0
  246. data/spec/models/supplejack_api/set_item_spec.rb +123 -0
  247. data/spec/models/supplejack_api/source_spec.rb +22 -0
  248. data/spec/models/supplejack_api/support/fragment_helpers_spec.rb +216 -0
  249. data/spec/models/supplejack_api/support/harvestable_spec.rb +177 -0
  250. data/spec/models/supplejack_api/support/searchable_spec.rb +85 -0
  251. data/spec/models/supplejack_api/support/storable_spec.rb +18 -0
  252. data/spec/models/supplejack_api/user_activity_spec.rb +88 -0
  253. data/spec/models/supplejack_api/user_set_spec.rb +559 -0
  254. data/spec/models/supplejack_api/user_spec.rb +348 -0
  255. data/spec/routing/concepts_routing_spec.rb +22 -0
  256. data/spec/routing/harvester_constraint_spec.rb +66 -0
  257. data/spec/routing/harvester_routing_spec.rb +51 -0
  258. data/spec/routing/partner_routing_spec.rb +34 -0
  259. data/spec/routing/records_routing_spec.rb +26 -0
  260. data/spec/routing/sets_routing_spec.rb +44 -0
  261. data/spec/routing/source_routing_spec.rb +38 -0
  262. data/spec/routing/users_routing_spec.rb +18 -0
  263. data/spec/serializers/concept_record_serializer_spec.rb +30 -0
  264. data/spec/serializers/supplejack_api/application_serializer_spec.rb +14 -0
  265. data/spec/serializers/supplejack_api/concept_search_serializer_spec.rb +34 -0
  266. data/spec/serializers/supplejack_api/concept_serializer_spec.rb +92 -0
  267. data/spec/serializers/supplejack_api/record_search_serializer_spec.rb +34 -0
  268. data/spec/serializers/supplejack_api/record_serializer_spec.rb +271 -0
  269. data/spec/serializers/supplejack_api/search_serializer_spec.rb +90 -0
  270. data/spec/serializers/supplejack_api/user_serializer_spec.rb +22 -0
  271. data/spec/serializers/supplejack_api/user_set_serializer_spec.rb +96 -0
  272. data/spec/services/metrics_api/v3/api_spec.rb +23 -0
  273. data/spec/services/metrics_api/v3/endpoints/facets_spec.rb +25 -0
  274. data/spec/services/metrics_api/v3/endpoints/global_spec.rb +22 -0
  275. data/spec/services/metrics_api/v3/endpoints/root_spec.rb +49 -0
  276. data/spec/services/metrics_api/v3/presenters/extended_metadata_spec.rb +49 -0
  277. data/spec/spec_helper.rb +70 -0
  278. data/spec/support/api/schemas/metrics/daily_metrics_metadata.json +24 -0
  279. data/spec/support/api/schemas/metrics/extended_metrics.json +26 -0
  280. data/spec/support/api/schemas/metrics/extended_response.json +6 -0
  281. data/spec/support/api/schemas/metrics/facets_response.json +6 -0
  282. data/spec/support/api/schemas/metrics/record_metadata.json +33 -0
  283. data/spec/support/api/schemas/metrics/top_level_response.json +6 -0
  284. data/spec/support/api/schemas/metrics/view_metadata.json +33 -0
  285. data/spec/support/api_schema_matcher.rb +14 -0
  286. data/spec/support/devise.rb +10 -0
  287. data/spec/workers/supplejack_api/daily_metrics_worker_spec.rb +140 -0
  288. data/spec/workers/supplejack_api/flush_old_records_worker_spec.rb +20 -0
  289. data/spec/workers/supplejack_api/index_worker_spec.rb +52 -0
  290. data/spec/workers/supplejack_api/source_index_worker_spec.rb +61 -0
  291. metadata +1231 -0
@@ -0,0 +1,120 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ require 'spec_helper'
9
+
10
+ module SupplejackApi
11
+ describe StatusController, type: :controller do
12
+ routes { SupplejackApi::Engine.routes }
13
+
14
+ let(:logger) { double(:logger).as_null_object }
15
+
16
+ before do
17
+ allow(Support::StatusLogger).to receive(:logger) { logger }
18
+ end
19
+
20
+ describe "GET 'status'" do
21
+ it "returns a '200' HTTP status if both Solr and Mongo are up and running" do
22
+ allow(controller).to receive(:solr_up?).and_return(true)
23
+ allow(controller).to receive(:mongod_up?).and_return(true)
24
+
25
+ get :show
26
+ expect(response.status).to eq 200
27
+ end
28
+
29
+ it "returns a '500' HTTP response if Solr is down" do
30
+ allow(controller).to receive(:solr_up?).and_return(false)
31
+ allow(controller).to receive(:mongod_up?).and_return(true)
32
+
33
+ get :show
34
+ expect(response.status).to eq 500
35
+ end
36
+
37
+ it "returns a '500' http response if Mongo is down" do
38
+ allow(controller).to receive(:solr_up?).and_return(true)
39
+ allow(controller).to receive(:mongod_up?).and_return(false)
40
+
41
+ get :show
42
+ expect(response.status).to eq 500
43
+ end
44
+
45
+ it "logs an error message when the status call takes a long time" do
46
+ allow(controller).to receive(:solr_up?).and_raise(Timeout::Error)
47
+
48
+ expect(logger).to receive(:error)
49
+ get :show
50
+ end
51
+ end
52
+
53
+ describe "#solr_up?" do
54
+ it "returns true when solr is up and running" do
55
+ ok_xml_string = <<-EOF
56
+ <?xml version="1.0" encoding="UTF-8"?>
57
+ <response>
58
+ <str name="status">OK</str>
59
+ </response>
60
+ EOF
61
+
62
+ allow(RestClient).to receive(:get) { ok_xml_string }
63
+
64
+ expect(controller.send(:solr_up?)).to be_truthy
65
+ end
66
+
67
+ it "returns false when solr is running but failing" do
68
+ failed_xml_string = <<-EOF
69
+ <?xml version="1.0" encoding="UTF-8"?>
70
+ <response>
71
+ <str name="status">NOK</str>
72
+ </response>
73
+ EOF
74
+ allow(RestClient).to receive(:get) { failed_xml_string }
75
+
76
+ expect(controller.send(:solr_up?)).to be_falsey
77
+ end
78
+
79
+ context "solr is down" do
80
+ before(:each) do
81
+ allow(RestClient).to receive(:get).and_raise(StandardError)
82
+ end
83
+
84
+ it "returns false" do
85
+ expect(controller.send(:solr_up?)).to be_falsey
86
+ end
87
+
88
+ it "should log an error" do
89
+ expect(logger).to receive(:error)
90
+ controller.send(:solr_up?)
91
+ end
92
+ end
93
+ end
94
+
95
+ describe "#mongod_up?" do
96
+ it "returns true when mongod is up and running" do
97
+ allow(Record).to receive_message_chain(:collection, :database, :session).and_return(session)
98
+ expect(session).to receive(:command).with(ping: 1).and_return({"ok" => 1})
99
+
100
+ expect(controller.send(:mongod_up?)).to be_truthy
101
+ end
102
+
103
+ context "mongod is down" do
104
+ before(:each) do
105
+ allow(Record).to receive_message_chain(:collection, :database, :session).and_return(session)
106
+ expect(session).to receive(:command).with(ping: 1).and_return(nil)
107
+ end
108
+
109
+ it "returns false" do
110
+ expect(controller.send(:mongod_up?)).to be_falsey
111
+ end
112
+
113
+ it "should log an error" do
114
+ expect(logger).to receive(:error)
115
+ controller.send(:mongod_up?)
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,233 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ require 'spec_helper'
9
+
10
+ module SupplejackApi
11
+ describe UserSetsController, type: :controller do
12
+ routes { SupplejackApi::Engine.routes }
13
+
14
+ before(:each) do
15
+ @user = FactoryGirl.create(:user, authentication_token: "abc123")
16
+ allow(RecordSchema).to receive(:roles) { { admin: double(:admin, admin: true) } }
17
+ allow(controller).to receive(:authenticate_user!) { true }
18
+ allow(controller).to receive(:current_user) { @user }
19
+ end
20
+
21
+ describe "GET 'index'" do
22
+ before(:each) do
23
+ @sets = [FactoryGirl.build(:user_set)]
24
+ end
25
+
26
+ it "should return all the user's sets" do
27
+ expect(controller.current_user).to receive(:user_sets){@sets}
28
+ get :index
29
+ end
30
+ end
31
+
32
+ describe "GET 'admin_index'" do
33
+ context "authentication succeeded" do
34
+ before :each do
35
+ allow(controller).to receive(:authenticate_admin!) { true }
36
+ @normal_user = double(User, user_sets: []).as_null_object
37
+ allow(User).to receive(:find_by_api_key).with("nonadminkey") { @normal_user }
38
+ end
39
+
40
+ it "authenticates the user as an admin" do
41
+ expect(controller).to receive(:authenticate_admin!) { true }
42
+ get :admin_index, user_id: "nonadminkey"
43
+ end
44
+
45
+ it "finds the user from the :user_id" do
46
+ expect(User).to receive(:find_by_api_key).with("nonadminkey")
47
+ get :admin_index, user_id: "nonadminkey"
48
+ end
49
+
50
+ it "assigns the user's sets to @user_sets" do
51
+ expect(@normal_user).to receive(:user_sets) { [] }
52
+ get :admin_index, user_id: "nonadminkey"
53
+ expect(assigns(:user_sets)).to eq []
54
+ end
55
+
56
+ it "renders a error when the user is not found" do
57
+ allow(User).to receive(:find_by_api_key) { nil }
58
+ get :admin_index, user_id: "whatever"
59
+ expect(response.code).to eq "404"
60
+ expect(response.body).to eq({errors: "The user with api key: 'whatever' was not found"}.to_json)
61
+ end
62
+ end
63
+
64
+ context "authentication fails" do
65
+ it "renders a error when the admin authentication fails" do
66
+ allow(controller).to receive(:current_user) { double(:developer, admin?: false, role: 'developer') }
67
+ get :admin_index, user_id: "nonadminkey", format: "json"
68
+ expect(response.code).to eq "403"
69
+ expect(response.body).to eq({errors: "You need Administrator privileges to perform this request"}.to_json)
70
+ end
71
+ end
72
+ end
73
+
74
+ describe "#public_index" do
75
+ context "authentication succedded" do
76
+ before :each do
77
+ allow(controller).to receive(:authenticate_admin!) { true }
78
+ @admin_user = double(User).as_null_object
79
+ allow(controller).to receive(:current_user) { @admin_user }
80
+ end
81
+
82
+ it "finds all public sets" do
83
+ expect(UserSet).to receive(:public_sets).with(page: nil) { [] }
84
+ get :public_index, format: "json"
85
+ end
86
+ end
87
+ end
88
+
89
+ describe "#featured_sets_index" do
90
+ context "authentication succedded" do
91
+ before :each do
92
+ allow(controller).to receive(:authenticate_admin!) { true }
93
+ @admin_user = double(User).as_null_object
94
+ allow(controller).to receive(:current_user) { @admin_user }
95
+ end
96
+
97
+ it "finds 4 public sets" do
98
+ expect(UserSet).to receive(:featured_sets).with(4) { [] }
99
+ get :featured_sets_index, format: "json"
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "GET 'show'" do
105
+ before(:each) do
106
+ @user_set = FactoryGirl.build(:user_set)
107
+ end
108
+
109
+ it "finds the @user_set" do
110
+ expect(UserSet).to receive(:custom_find).with(@user_set.id.to_s) { @user_set }
111
+ get :show, id: @user_set.id.to_s
112
+ end
113
+
114
+ it "returns a 404 error when the set is not found" do
115
+ allow(UserSet).to receive(:custom_find) { nil }
116
+ get :show, id: @user_set.id.to_s
117
+ expect(response.code).to eq("404")
118
+ expect(response.body).to eq({errors: "Set with id: #{@user_set.id.to_s} was not found."}.to_json)
119
+ end
120
+ end
121
+
122
+ describe "POST 'create'" do
123
+ before(:each) do
124
+ @user_set = FactoryGirl.build(:user_set)
125
+ allow(controller.current_user.user_sets).to receive(:build) { @user_set }
126
+ create(:record, record_id: 12345)
127
+ allow(@user_set).to receive(:set_items).and_return(double(first: double(record_id: 12345)))
128
+ end
129
+
130
+ it "should build a new set with the params" do
131
+ expect(controller.current_user.user_sets).to receive(:build) { @user_set }
132
+ expect(@user_set).to receive(:update_attributes_and_embedded).with({"name" => "Dogs", "description" => "Ugly", "privacy" => "hidden"})
133
+ post :create, set: {"name" => "Dogs", "description" => "Ugly", "privacy" => "hidden"}
134
+ end
135
+
136
+ it "saves the user set" do
137
+ pending # This is broken because it doesn't create sets properly and I don't know how to make it create sets properly
138
+ expect(@user_set).to receive(:save).and_return(true)
139
+ post :create, set: {}
140
+ end
141
+
142
+ it "returns a 422 error when the set is invalid" do
143
+ allow(@user_set).to receive(:update_attributes_and_embedded) { false }
144
+ allow(@user_set).to receive(:errors).and_return({name: ["can't be blank"]})
145
+ post :create, set: {}
146
+ expect(response.code).to eq("422")
147
+ expect(response.body).to eq({errors: {name: ["can't be blank"]}}.to_json)
148
+ end
149
+
150
+ it "rescues from a :records format error and renders the error" do
151
+ allow(@user_set).to receive(:update_attributes_and_embedded).and_raise(UserSet::WrongRecordsFormat)
152
+ post :create, set: {}
153
+ expect(response.code).to eq("422")
154
+ expect(response.body).to eq({errors: {records: ["The records array is not in a valid format."]}}.to_json)
155
+ end
156
+ end
157
+
158
+ describe "PUT 'update'" do
159
+ before(:each) do
160
+ @user_set = FactoryGirl.create(:user_set, user_id: @user.id)
161
+ allow(@user_set).to receive(:update_attributes_and_embedded) { true }
162
+ end
163
+
164
+ context 'normal operations' do
165
+ before(:each) do
166
+ allow(controller.current_user.user_sets).to receive(:custom_find) { @user_set }
167
+ end
168
+
169
+ it "finds the @user_set through the user" do
170
+ expect(controller.current_user.user_sets).to receive(:custom_find).with(@user_set.id.to_s) { @user_set }
171
+ put :update, id: @user_set.id.to_s, set: {records: [{record_id: 13, position: 2}]}
172
+ end
173
+
174
+ it "returns a 404 error when the set is not found" do
175
+ allow(controller.current_user.user_sets).to receive(:custom_find) { nil }
176
+ put :update, id: @user_set.id.to_s
177
+ expect(response.code).to eq("404")
178
+ expect(response.body).to eq({errors: "Set with id: #{@user_set.id.to_s} was not found."}.to_json)
179
+ end
180
+
181
+ it "updates the attributes of the @user_set" do
182
+ expect(@user_set).to receive(:update_attributes_and_embedded).with({"records" => [{"record_id" => "13", "position" => "2"}]}, @user)
183
+ put :update, id: @user_set.id.to_s, set: {records: [{record_id: 13, position: 2}]}
184
+ end
185
+
186
+ it "updates the approved attribute of a @user_set" do
187
+ expect(@user_set).to receive(:update_attributes_and_embedded).with({"approved" => true}, @user)
188
+ put :update, id: @user_set.id.to_s, set: {approved: true}
189
+ end
190
+
191
+ it "returns a 406 error when the set is invalid" do
192
+ allow(@user_set).to receive(:update_attributes_and_embedded) { false }
193
+ allow(@user_set).to receive(:errors).and_return({name: ["can't be blank"]})
194
+ post :update, id: @user_set.id.to_s, set: {name: nil}
195
+ expect(response.code).to eq("422")
196
+ expect(response.body).to eq({errors: {name: ["can't be blank"]}}.to_json)
197
+ end
198
+
199
+ it "rescues from a :records format error and renders the error" do
200
+ allow(@user_set).to receive(:update_attributes_and_embedded).and_raise(UserSet::WrongRecordsFormat)
201
+ post :update, id: @user_set.id.to_s, set: {name: nil}
202
+ expect(response.code).to eq("422")
203
+ expect(response.body).to eq({errors: {records: ["The records array is not in a valid format."]}}.to_json)
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+ describe "DELETE 'destroy'" do
210
+ before(:each) do
211
+ @user_set = FactoryGirl.create(:user_set, user_id: @user.id)
212
+ allow(controller.current_user.user_sets).to receive(:custom_find) { @user_set }
213
+ end
214
+
215
+ it "returns a 404 error when the set is not found" do
216
+ allow(controller.current_user.user_sets).to receive(:custom_find) { nil }
217
+ delete :destroy, id: @user_set.id.to_s
218
+ expect(response.code).to eq("404")
219
+ expect(response.body).to eq({errors: "Set with id: #{@user_set.id.to_s} was not found."}.to_json)
220
+ end
221
+
222
+ it "finds the @user_set through the user" do
223
+ expect(controller.current_user.user_sets).to receive(:custom_find).with(@user_set.id.to_s) { @user_set }
224
+ delete :destroy, id: @user_set.id.to_s, format: :json
225
+ end
226
+
227
+ it "deletes the user set" do
228
+ expect(@user_set).to receive(:destroy)
229
+ delete :destroy, id: @user_set.id.to_s, format: :json
230
+ end
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,61 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ require 'spec_helper'
9
+
10
+ module SupplejackApi
11
+ describe UsersController, type: :controller do
12
+ routes { SupplejackApi::Engine.routes }
13
+
14
+ let(:user) { FactoryGirl.create(:user, authentication_token: 'abc123', role: 'admin') }
15
+
16
+ describe 'GET show' do
17
+ it 'should assign @user' do
18
+ get :show, id: user.id, api_key: 'abc123', format: :json
19
+ expect(assigns(:user)).to eq(user)
20
+ end
21
+ end
22
+
23
+ describe 'POST create' do
24
+ it 'should create a new user' do
25
+ allow(RecordSchema).to receive(:roles) { { admin: double(:admin, admin: true) } }
26
+ expect(User).to receive(:create).with({ 'name' => 'Ben' }).and_return(user)
27
+ post :create, api_key: 'abc123', user: { name: 'Ben' }, format: 'json'
28
+ end
29
+ end
30
+
31
+ # describe 'PUT update' do
32
+ # before :each do
33
+ # User.stub(:custom_find) { user }
34
+ # end
35
+
36
+ # it 'should find the user' do
37
+ # put :update, id: user.api_key, api_key: user.authentication_token
38
+ # assigns(:user).should eq user
39
+ # end
40
+
41
+ # it 'updates the user attributes' do
42
+ # user.should_receive(:update_attributes).with({'username' => 'john'})
43
+ # put :update, id: user.api_key, api_key: user.authentication_token, user: {username: 'john'}
44
+ # end
45
+ # end
46
+
47
+ # describe 'DELETE destroy' do
48
+ # it 'should find the user' do
49
+ # delete :destroy, id: user.id, api_key: user.authentication_token
50
+ # assigns(:user).should eq user
51
+ # end
52
+
53
+ # it 'destroys the user' do
54
+ # User.stub(:find) { user }
55
+ # user.should_receive(:destroy)
56
+ # delete :destroy, id: user.id, api_key: user.authentication_token
57
+ # end
58
+ # end
59
+
60
+ end
61
+ end
@@ -0,0 +1,268 @@
1
+ # The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
2
+ # and is licensed under the GNU General Public License, version 3.
3
+ # One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
4
+ #
5
+ # Supplejack was created by DigitalNZ at the National Library of NZ and
6
+ # the Department of Internal Affairs. http://digitalnz.org/supplejack
7
+
8
+ == Welcome to Rails
9
+
10
+ Rails is a web-application framework that includes everything needed to create
11
+ database-backed web applications according to the Model-View-Control pattern.
12
+
13
+ This pattern splits the view (also called the presentation) into "dumb"
14
+ templates that are primarily responsible for inserting pre-built data in between
15
+ HTML tags. The model contains the "smart" domain objects (such as Account,
16
+ Product, Person, Post) that holds all the business logic and knows how to
17
+ persist themselves to a database. The controller handles the incoming requests
18
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
19
+ and directing data to the view.
20
+
21
+ In Rails, the model is handled by what's called an object-relational mapping
22
+ layer entitled Active Record. This layer allows you to present the data from
23
+ database rows as objects and embellish these data objects with business logic
24
+ methods. You can read more about Active Record in
25
+ link:files/vendor/rails/activerecord/README.html.
26
+
27
+ The controller and view are handled by the Action Pack, which handles both
28
+ layers by its two parts: Action View and Action Controller. These two layers
29
+ are bundled in a single package due to their heavy interdependence. This is
30
+ unlike the relationship between the Active Record and Action Pack that is much
31
+ more separate. Each of these packages can be used independently outside of
32
+ Rails. You can read more about Action Pack in
33
+ link:files/vendor/rails/actionpack/README.html.
34
+
35
+
36
+ == Getting Started
37
+
38
+ 1. At the command prompt, create a new Rails application:
39
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
40
+
41
+ 2. Change directory to <tt>myapp</tt> and start the web server:
42
+ <tt>cd myapp; rails server</tt> (run with --help for options)
43
+
44
+ 3. Go to http://localhost:3000/ and you'll see:
45
+ "Welcome aboard: You're riding Ruby on Rails!"
46
+
47
+ 4. Follow the guidelines to start developing your application. You can find
48
+ the following resources handy:
49
+
50
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
51
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
52
+
53
+
54
+ == Debugging Rails
55
+
56
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
57
+ will help you debug it and get it back on the rails.
58
+
59
+ First area to check is the application log files. Have "tail -f" commands
60
+ running on the server.log and development.log. Rails will automatically display
61
+ debugging and runtime information to these files. Debugging info will also be
62
+ shown in the browser on requests from 127.0.0.1.
63
+
64
+ You can also log your own messages directly into the log file from your code
65
+ using the Ruby logger class from inside your controllers. Example:
66
+
67
+ class WeblogController < ActionController::Base
68
+ def destroy
69
+ @weblog = Weblog.find(params[:id])
70
+ @weblog.destroy
71
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
72
+ end
73
+ end
74
+
75
+ The result will be a message in your log file along the lines of:
76
+
77
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
78
+
79
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
80
+
81
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
82
+ several books available online as well:
83
+
84
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
85
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
86
+
87
+ These two books will bring you up to speed on the Ruby language and also on
88
+ programming in general.
89
+
90
+
91
+ == Debugger
92
+
93
+ Debugger support is available through the debugger command when you start your
94
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
95
+ execution at any point in the code, investigate and change the model, and then,
96
+ resume execution! You need to install ruby-debug to run the server in debugging
97
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
98
+
99
+ class WeblogController < ActionController::Base
100
+ def index
101
+ @posts = Post.all
102
+ debugger
103
+ end
104
+ end
105
+
106
+ So the controller will accept the action, run the first line, then present you
107
+ with a IRB prompt in the server window. Here you can do things like:
108
+
109
+ >> @posts.inspect
110
+ => "[#<Post:0x14a6be8
111
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
112
+ #<Post:0x14a6620
113
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
114
+ >> @posts.first.title = "hello from a debugger"
115
+ => "hello from a debugger"
116
+
117
+ ...and even better, you can examine how your runtime objects actually work:
118
+
119
+ >> f = @posts.first
120
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
121
+ >> f.
122
+ Display all 152 possibilities? (y or n)
123
+
124
+ Finally, when you're ready to resume execution, you can enter "cont".
125
+
126
+
127
+ == Console
128
+
129
+ The console is a Ruby shell, which allows you to interact with your
130
+ application's domain model. Here you'll have all parts of the application
131
+ configured, just like it is when the application is running. You can inspect
132
+ domain models, change values, and save to the database. Starting the script
133
+ without arguments will launch it in the development environment.
134
+
135
+ To start the console, run <tt>rails console</tt> from the application
136
+ directory.
137
+
138
+ Options:
139
+
140
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
141
+ made to the database.
142
+ * Passing an environment name as an argument will load the corresponding
143
+ environment. Example: <tt>rails console production</tt>.
144
+
145
+ To reload your controllers and models after launching the console run
146
+ <tt>reload!</tt>
147
+
148
+ More information about irb can be found at:
149
+ link:http://www.rubycentral.org/pickaxe/irb.html
150
+
151
+
152
+ == dbconsole
153
+
154
+ You can go to the command line of your database directly through <tt>rails
155
+ dbconsole</tt>. You would be connected to the database with the credentials
156
+ defined in database.yml. Starting the script without arguments will connect you
157
+ to the development database. Passing an argument will connect you to a different
158
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
159
+ PostgreSQL and SQLite 3.
160
+
161
+ == Description of Contents
162
+
163
+ The default directory structure of a generated Ruby on Rails application:
164
+
165
+ |-- app
166
+ | |-- assets
167
+ | |-- images
168
+ | |-- javascripts
169
+ | `-- stylesheets
170
+ | |-- controllers
171
+ | |-- helpers
172
+ | |-- mailers
173
+ | |-- models
174
+ | `-- views
175
+ | `-- layouts
176
+ |-- config
177
+ | |-- environments
178
+ | |-- initializers
179
+ | `-- locales
180
+ |-- db
181
+ |-- doc
182
+ |-- lib
183
+ | `-- tasks
184
+ |-- log
185
+ |-- public
186
+ |-- script
187
+ |-- test
188
+ | |-- fixtures
189
+ | |-- functional
190
+ | |-- integration
191
+ | |-- performance
192
+ | `-- unit
193
+ |-- tmp
194
+ | |-- cache
195
+ | |-- pids
196
+ | |-- sessions
197
+ | `-- sockets
198
+ `-- vendor
199
+ |-- assets
200
+ `-- stylesheets
201
+ `-- plugins
202
+
203
+ app
204
+ Holds all the code that's specific to this particular application.
205
+
206
+ app/assets
207
+ Contains subdirectories for images, stylesheets, and JavaScript files.
208
+
209
+ app/controllers
210
+ Holds controllers that should be named like weblogs_controller.rb for
211
+ automated URL mapping. All controllers should descend from
212
+ ApplicationController which itself descends from ActionController::Base.
213
+
214
+ app/models
215
+ Holds models that should be named like post.rb. Models descend from
216
+ ActiveRecord::Base by default.
217
+
218
+ app/views
219
+ Holds the template files for the view that should be named like
220
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
221
+ eRuby syntax by default.
222
+
223
+ app/views/layouts
224
+ Holds the template files for layouts to be used with views. This models the
225
+ common header/footer method of wrapping views. In your views, define a layout
226
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
227
+ Inside default.html.erb, call <% yield %> to render the view using this
228
+ layout.
229
+
230
+ app/helpers
231
+ Holds view helpers that should be named like weblogs_helper.rb. These are
232
+ generated for you automatically when using generators for controllers.
233
+ Helpers can be used to wrap functionality for your views into methods.
234
+
235
+ config
236
+ Configuration files for the Rails environment, the routing map, the database,
237
+ and other dependencies.
238
+
239
+ db
240
+ Contains the database schema in schema.rb. db/migrate contains all the
241
+ sequence of Migrations for your schema.
242
+
243
+ doc
244
+ This directory is where your application documentation will be stored when
245
+ generated using <tt>rake doc:app</tt>
246
+
247
+ lib
248
+ Application specific libraries. Basically, any kind of custom code that
249
+ doesn't belong under controllers, models, or helpers. This directory is in
250
+ the load path.
251
+
252
+ public
253
+ The directory available for the web server. Also contains the dispatchers and the
254
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
255
+ server.
256
+
257
+ script
258
+ Helper scripts for automation and generation.
259
+
260
+ test
261
+ Unit and functional tests along with fixtures. When using the rails generate
262
+ command, template test files will be generated for you and placed in this
263
+ directory.
264
+
265
+ vendor
266
+ External libraries that the application depends on. Also includes the plugins
267
+ subdirectory. If the app has frozen rails, those gems also go here, under
268
+ vendor/rails/. This directory is in the load path.