3mix-castronaut 0.5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (904) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.textile +75 -0
  3. data/Rakefile +105 -0
  4. data/app/config.rb +15 -0
  5. data/app/config.ru +24 -0
  6. data/app/controllers/application.rb +47 -0
  7. data/app/public/javascripts/application.js +3 -0
  8. data/app/public/javascripts/jquery.js +32 -0
  9. data/app/public/stylesheets/screen.css +122 -0
  10. data/app/views/layout.erb +27 -0
  11. data/app/views/login.erb +31 -0
  12. data/app/views/logout.erb +13 -0
  13. data/app/views/proxy_validate.erb +25 -0
  14. data/app/views/service_validate.erb +18 -0
  15. data/bin/castronaut +48 -0
  16. data/castronaut.rb +7 -0
  17. data/config/castronaut.example.yml +47 -0
  18. data/config/nginx_vhost.conf +24 -0
  19. data/config/thin_config.yml +13 -0
  20. data/lib/castronaut/adapters/active_record_adapter.rb +20 -0
  21. data/lib/castronaut/adapters/development/adapter.rb +13 -0
  22. data/lib/castronaut/adapters/development/user.rb +25 -0
  23. data/lib/castronaut/adapters/ldap/adapter.rb +15 -0
  24. data/lib/castronaut/adapters/ldap/user.rb +40 -0
  25. data/lib/castronaut/adapters/restful_authentication/adapter.rb +21 -0
  26. data/lib/castronaut/adapters/restful_authentication/user.rb +50 -0
  27. data/lib/castronaut/adapters.rb +17 -0
  28. data/lib/castronaut/authentication_result.rb +27 -0
  29. data/lib/castronaut/configuration.rb +95 -0
  30. data/lib/castronaut/db/001_create_cas_database.rb +47 -0
  31. data/lib/castronaut/db/002_change_username_to_identifier.rb +11 -0
  32. data/lib/castronaut/db/003_add_extra_info.rb +11 -0
  33. data/lib/castronaut/models/consumeable.rb +18 -0
  34. data/lib/castronaut/models/dispenser.rb +14 -0
  35. data/lib/castronaut/models/login_ticket.rb +53 -0
  36. data/lib/castronaut/models/proxy_granting_ticket.rb +69 -0
  37. data/lib/castronaut/models/proxy_ticket.rb +43 -0
  38. data/lib/castronaut/models/service_ticket.rb +100 -0
  39. data/lib/castronaut/models/ticket_granting_ticket.rb +70 -0
  40. data/lib/castronaut/presenters/base.rb +32 -0
  41. data/lib/castronaut/presenters/login.rb +60 -0
  42. data/lib/castronaut/presenters/logout.rb +40 -0
  43. data/lib/castronaut/presenters/process_login.rb +127 -0
  44. data/lib/castronaut/presenters/proxy_validate.rb +49 -0
  45. data/lib/castronaut/presenters/service_validate.rb +43 -0
  46. data/lib/castronaut/ticket_result.rb +27 -0
  47. data/lib/castronaut/utilities/random_string.rb +24 -0
  48. data/lib/castronaut.rb +34 -0
  49. data/lib/version.rb +5 -0
  50. data/spec/app/controllers/application_spec.rb +89 -0
  51. data/spec/castronaut/adapters/development/adapter_spec.rb +14 -0
  52. data/spec/castronaut/adapters/development/user_spec.rb +55 -0
  53. data/spec/castronaut/adapters/ldap/adapter_spec.rb +14 -0
  54. data/spec/castronaut/adapters/ldap/user_spec.rb +25 -0
  55. data/spec/castronaut/adapters/restful_authentication/adapter_spec.rb +14 -0
  56. data/spec/castronaut/adapters/restful_authentication/user_spec.rb +108 -0
  57. data/spec/castronaut/adapters_spec.rb +13 -0
  58. data/spec/castronaut/authentication_result_spec.rb +20 -0
  59. data/spec/castronaut/configuration_spec.rb +172 -0
  60. data/spec/castronaut/models/consumeable_spec.rb +39 -0
  61. data/spec/castronaut/models/dispenser_spec.rb +30 -0
  62. data/spec/castronaut/models/login_ticket_spec.rb +107 -0
  63. data/spec/castronaut/models/proxy_granting_ticket_spec.rb +302 -0
  64. data/spec/castronaut/models/proxy_ticket_spec.rb +109 -0
  65. data/spec/castronaut/models/service_ticket_spec.rb +269 -0
  66. data/spec/castronaut/models/ticket_granting_ticket_spec.rb +89 -0
  67. data/spec/castronaut/presenters/login_spec.rb +152 -0
  68. data/spec/castronaut/presenters/logout_spec.rb +85 -0
  69. data/spec/castronaut/presenters/process_login_spec.rb +300 -0
  70. data/spec/castronaut/presenters/proxy_validate_spec.rb +103 -0
  71. data/spec/castronaut/presenters/service_validate_spec.rb +86 -0
  72. data/spec/castronaut/ticket_result_spec.rb +42 -0
  73. data/spec/castronaut/utilities/random_string_spec.rb +14 -0
  74. data/spec/castronaut_spec.rb +26 -0
  75. data/spec/spec.opts +2 -0
  76. data/spec/spec_controller_helper.rb +17 -0
  77. data/spec/spec_helper.rb +49 -0
  78. data/spec/spec_rails_mocks.rb +132 -0
  79. data/vendor/activerecord/CHANGELOG +5753 -0
  80. data/vendor/activerecord/README +351 -0
  81. data/vendor/activerecord/RUNNING_UNIT_TESTS +36 -0
  82. data/vendor/activerecord/Rakefile +248 -0
  83. data/vendor/activerecord/examples/associations.png +0 -0
  84. data/vendor/activerecord/install.rb +30 -0
  85. data/vendor/activerecord/lib/active_record/aggregations.rb +189 -0
  86. data/vendor/activerecord/lib/active_record/association_preload.rb +282 -0
  87. data/vendor/activerecord/lib/active_record/associations/association_collection.rb +368 -0
  88. data/vendor/activerecord/lib/active_record/associations/association_proxy.rb +220 -0
  89. data/vendor/activerecord/lib/active_record/associations/belongs_to_association.rb +58 -0
  90. data/vendor/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
  91. data/vendor/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +111 -0
  92. data/vendor/activerecord/lib/active_record/associations/has_many_association.rb +121 -0
  93. data/vendor/activerecord/lib/active_record/associations/has_many_through_association.rb +254 -0
  94. data/vendor/activerecord/lib/active_record/associations/has_one_association.rb +98 -0
  95. data/vendor/activerecord/lib/active_record/associations/has_one_through_association.rb +32 -0
  96. data/vendor/activerecord/lib/active_record/associations.rb +2012 -0
  97. data/vendor/activerecord/lib/active_record/attribute_methods.rb +379 -0
  98. data/vendor/activerecord/lib/active_record/base.rb +2744 -0
  99. data/vendor/activerecord/lib/active_record/calculations.rb +288 -0
  100. data/vendor/activerecord/lib/active_record/callbacks.rb +312 -0
  101. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +309 -0
  102. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +176 -0
  103. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +93 -0
  104. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
  105. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +664 -0
  106. data/vendor/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +428 -0
  107. data/vendor/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +169 -0
  108. data/vendor/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +559 -0
  109. data/vendor/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +994 -0
  110. data/vendor/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
  111. data/vendor/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +418 -0
  112. data/vendor/activerecord/lib/active_record/dirty.rb +165 -0
  113. data/vendor/activerecord/lib/active_record/fixtures.rb +997 -0
  114. data/vendor/activerecord/lib/active_record/locking/optimistic.rb +148 -0
  115. data/vendor/activerecord/lib/active_record/locking/pessimistic.rb +77 -0
  116. data/vendor/activerecord/lib/active_record/migration.rb +523 -0
  117. data/vendor/activerecord/lib/active_record/named_scope.rb +168 -0
  118. data/vendor/activerecord/lib/active_record/observer.rb +197 -0
  119. data/vendor/activerecord/lib/active_record/query_cache.rb +21 -0
  120. data/vendor/activerecord/lib/active_record/reflection.rb +239 -0
  121. data/vendor/activerecord/lib/active_record/schema.rb +51 -0
  122. data/vendor/activerecord/lib/active_record/schema_dumper.rb +171 -0
  123. data/vendor/activerecord/lib/active_record/serialization.rb +98 -0
  124. data/vendor/activerecord/lib/active_record/serializers/json_serializer.rb +80 -0
  125. data/vendor/activerecord/lib/active_record/serializers/xml_serializer.rb +338 -0
  126. data/vendor/activerecord/lib/active_record/test_case.rb +47 -0
  127. data/vendor/activerecord/lib/active_record/timestamp.rb +41 -0
  128. data/vendor/activerecord/lib/active_record/transactions.rb +130 -0
  129. data/vendor/activerecord/lib/active_record/validations.rb +971 -0
  130. data/vendor/activerecord/lib/active_record/vendor/mysql.rb +1214 -0
  131. data/vendor/activerecord/lib/active_record/version.rb +9 -0
  132. data/vendor/activerecord/lib/active_record.rb +80 -0
  133. data/vendor/activerecord/lib/activerecord.rb +1 -0
  134. data/vendor/activerecord/test/assets/example.log +1 -0
  135. data/vendor/activerecord/test/assets/flowers.jpg +0 -0
  136. data/vendor/activerecord/test/cases/aaa_create_tables_test.rb +24 -0
  137. data/vendor/activerecord/test/cases/active_schema_test_mysql.rb +95 -0
  138. data/vendor/activerecord/test/cases/active_schema_test_postgresql.rb +24 -0
  139. data/vendor/activerecord/test/cases/adapter_test.rb +127 -0
  140. data/vendor/activerecord/test/cases/adapter_test_sqlserver.rb +95 -0
  141. data/vendor/activerecord/test/cases/aggregations_test.rb +128 -0
  142. data/vendor/activerecord/test/cases/ar_schema_test.rb +33 -0
  143. data/vendor/activerecord/test/cases/associations/belongs_to_associations_test.rb +431 -0
  144. data/vendor/activerecord/test/cases/associations/callbacks_test.rb +161 -0
  145. data/vendor/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +123 -0
  146. data/vendor/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +36 -0
  147. data/vendor/activerecord/test/cases/associations/eager_load_nested_include_test.rb +83 -0
  148. data/vendor/activerecord/test/cases/associations/eager_singularization_test.rb +145 -0
  149. data/vendor/activerecord/test/cases/associations/eager_test.rb +636 -0
  150. data/vendor/activerecord/test/cases/associations/extension_test.rb +47 -0
  151. data/vendor/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +706 -0
  152. data/vendor/activerecord/test/cases/associations/has_many_associations_test.rb +1034 -0
  153. data/vendor/activerecord/test/cases/associations/has_many_through_associations_test.rb +200 -0
  154. data/vendor/activerecord/test/cases/associations/has_one_associations_test.rb +345 -0
  155. data/vendor/activerecord/test/cases/associations/has_one_through_associations_test.rb +113 -0
  156. data/vendor/activerecord/test/cases/associations/inner_join_association_test.rb +88 -0
  157. data/vendor/activerecord/test/cases/associations/join_model_test.rb +714 -0
  158. data/vendor/activerecord/test/cases/associations_test.rb +262 -0
  159. data/vendor/activerecord/test/cases/attribute_methods_test.rb +238 -0
  160. data/vendor/activerecord/test/cases/base_test.rb +1997 -0
  161. data/vendor/activerecord/test/cases/binary_test.rb +34 -0
  162. data/vendor/activerecord/test/cases/calculations_test.rb +323 -0
  163. data/vendor/activerecord/test/cases/callbacks_test.rb +400 -0
  164. data/vendor/activerecord/test/cases/class_inheritable_attributes_test.rb +32 -0
  165. data/vendor/activerecord/test/cases/column_alias_test.rb +17 -0
  166. data/vendor/activerecord/test/cases/column_definition_test.rb +36 -0
  167. data/vendor/activerecord/test/cases/connection_test_firebird.rb +8 -0
  168. data/vendor/activerecord/test/cases/connection_test_mysql.rb +30 -0
  169. data/vendor/activerecord/test/cases/copy_table_test_sqlite.rb +69 -0
  170. data/vendor/activerecord/test/cases/database_statements_test.rb +12 -0
  171. data/vendor/activerecord/test/cases/datatype_test_postgresql.rb +203 -0
  172. data/vendor/activerecord/test/cases/date_time_test.rb +37 -0
  173. data/vendor/activerecord/test/cases/default_test_firebird.rb +16 -0
  174. data/vendor/activerecord/test/cases/defaults_test.rb +69 -0
  175. data/vendor/activerecord/test/cases/deprecated_finder_test.rb +30 -0
  176. data/vendor/activerecord/test/cases/dirty_test.rb +257 -0
  177. data/vendor/activerecord/test/cases/finder_respond_to_test.rb +76 -0
  178. data/vendor/activerecord/test/cases/finder_test.rb +890 -0
  179. data/vendor/activerecord/test/cases/fixtures_test.rb +626 -0
  180. data/vendor/activerecord/test/cases/helper.rb +47 -0
  181. data/vendor/activerecord/test/cases/inheritance_test.rb +262 -0
  182. data/vendor/activerecord/test/cases/invalid_date_test.rb +24 -0
  183. data/vendor/activerecord/test/cases/json_serialization_test.rb +205 -0
  184. data/vendor/activerecord/test/cases/lifecycle_test.rb +193 -0
  185. data/vendor/activerecord/test/cases/locking_test.rb +309 -0
  186. data/vendor/activerecord/test/cases/method_scoping_test.rb +462 -0
  187. data/vendor/activerecord/test/cases/migration_test.rb +1444 -0
  188. data/vendor/activerecord/test/cases/migration_test_firebird.rb +124 -0
  189. data/vendor/activerecord/test/cases/mixin_test.rb +96 -0
  190. data/vendor/activerecord/test/cases/modules_test.rb +39 -0
  191. data/vendor/activerecord/test/cases/multiple_db_test.rb +60 -0
  192. data/vendor/activerecord/test/cases/named_scope_test.rb +206 -0
  193. data/vendor/activerecord/test/cases/pk_test.rb +101 -0
  194. data/vendor/activerecord/test/cases/query_cache_test.rb +127 -0
  195. data/vendor/activerecord/test/cases/readonly_test.rb +107 -0
  196. data/vendor/activerecord/test/cases/reflection_test.rb +176 -0
  197. data/vendor/activerecord/test/cases/reserved_word_test_mysql.rb +176 -0
  198. data/vendor/activerecord/test/cases/schema_authorization_test_postgresql.rb +75 -0
  199. data/vendor/activerecord/test/cases/schema_dumper_test.rb +184 -0
  200. data/vendor/activerecord/test/cases/schema_test_postgresql.rb +102 -0
  201. data/vendor/activerecord/test/cases/serialization_test.rb +47 -0
  202. data/vendor/activerecord/test/cases/synonym_test_oracle.rb +17 -0
  203. data/vendor/activerecord/test/cases/table_name_test_sqlserver.rb +23 -0
  204. data/vendor/activerecord/test/cases/threaded_connections_test.rb +48 -0
  205. data/vendor/activerecord/test/cases/transactions_test.rb +307 -0
  206. data/vendor/activerecord/test/cases/unconnected_test.rb +32 -0
  207. data/vendor/activerecord/test/cases/validations_test.rb +1534 -0
  208. data/vendor/activerecord/test/cases/xml_serialization_test.rb +202 -0
  209. data/vendor/activerecord/test/config.rb +5 -0
  210. data/vendor/activerecord/test/connections/native_db2/connection.rb +25 -0
  211. data/vendor/activerecord/test/connections/native_firebird/connection.rb +26 -0
  212. data/vendor/activerecord/test/connections/native_frontbase/connection.rb +27 -0
  213. data/vendor/activerecord/test/connections/native_mysql/connection.rb +27 -0
  214. data/vendor/activerecord/test/connections/native_openbase/connection.rb +21 -0
  215. data/vendor/activerecord/test/connections/native_oracle/connection.rb +27 -0
  216. data/vendor/activerecord/test/connections/native_postgresql/connection.rb +21 -0
  217. data/vendor/activerecord/test/connections/native_sqlite/connection.rb +25 -0
  218. data/vendor/activerecord/test/connections/native_sqlite3/connection.rb +25 -0
  219. data/vendor/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
  220. data/vendor/activerecord/test/connections/native_sybase/connection.rb +23 -0
  221. data/vendor/activerecord/test/debug.log +358 -0
  222. data/vendor/activerecord/test/fixtures/accounts.yml +28 -0
  223. data/vendor/activerecord/test/fixtures/all/developers.yml +0 -0
  224. data/vendor/activerecord/test/fixtures/all/people.csv +0 -0
  225. data/vendor/activerecord/test/fixtures/all/tasks.yml +0 -0
  226. data/vendor/activerecord/test/fixtures/author_addresses.yml +5 -0
  227. data/vendor/activerecord/test/fixtures/author_favorites.yml +4 -0
  228. data/vendor/activerecord/test/fixtures/authors.yml +9 -0
  229. data/vendor/activerecord/test/fixtures/binaries.yml +132 -0
  230. data/vendor/activerecord/test/fixtures/books.yml +7 -0
  231. data/vendor/activerecord/test/fixtures/categories/special_categories.yml +9 -0
  232. data/vendor/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  233. data/vendor/activerecord/test/fixtures/categories.yml +14 -0
  234. data/vendor/activerecord/test/fixtures/categories_ordered.yml +7 -0
  235. data/vendor/activerecord/test/fixtures/categories_posts.yml +23 -0
  236. data/vendor/activerecord/test/fixtures/categorizations.yml +17 -0
  237. data/vendor/activerecord/test/fixtures/clubs.yml +6 -0
  238. data/vendor/activerecord/test/fixtures/comments.yml +59 -0
  239. data/vendor/activerecord/test/fixtures/companies.yml +55 -0
  240. data/vendor/activerecord/test/fixtures/computers.yml +4 -0
  241. data/vendor/activerecord/test/fixtures/courses.yml +7 -0
  242. data/vendor/activerecord/test/fixtures/customers.yml +17 -0
  243. data/vendor/activerecord/test/fixtures/developers.yml +21 -0
  244. data/vendor/activerecord/test/fixtures/developers_projects.yml +17 -0
  245. data/vendor/activerecord/test/fixtures/edges.yml +6 -0
  246. data/vendor/activerecord/test/fixtures/entrants.yml +14 -0
  247. data/vendor/activerecord/test/fixtures/fixture_database.sqlite3 +0 -0
  248. data/vendor/activerecord/test/fixtures/fixture_database_2.sqlite3 +0 -0
  249. data/vendor/activerecord/test/fixtures/fk_test_has_fk.yml +3 -0
  250. data/vendor/activerecord/test/fixtures/fk_test_has_pk.yml +2 -0
  251. data/vendor/activerecord/test/fixtures/funny_jokes.yml +10 -0
  252. data/vendor/activerecord/test/fixtures/items.yml +4 -0
  253. data/vendor/activerecord/test/fixtures/jobs.yml +7 -0
  254. data/vendor/activerecord/test/fixtures/legacy_things.yml +3 -0
  255. data/vendor/activerecord/test/fixtures/mateys.yml +4 -0
  256. data/vendor/activerecord/test/fixtures/members.yml +4 -0
  257. data/vendor/activerecord/test/fixtures/memberships.yml +20 -0
  258. data/vendor/activerecord/test/fixtures/minimalistics.yml +2 -0
  259. data/vendor/activerecord/test/fixtures/mixed_case_monkeys.yml +6 -0
  260. data/vendor/activerecord/test/fixtures/mixins.yml +29 -0
  261. data/vendor/activerecord/test/fixtures/movies.yml +7 -0
  262. data/vendor/activerecord/test/fixtures/naked/csv/accounts.csv +1 -0
  263. data/vendor/activerecord/test/fixtures/naked/yml/accounts.yml +1 -0
  264. data/vendor/activerecord/test/fixtures/naked/yml/companies.yml +1 -0
  265. data/vendor/activerecord/test/fixtures/naked/yml/courses.yml +1 -0
  266. data/vendor/activerecord/test/fixtures/owners.yml +7 -0
  267. data/vendor/activerecord/test/fixtures/parrots.yml +27 -0
  268. data/vendor/activerecord/test/fixtures/parrots_pirates.yml +7 -0
  269. data/vendor/activerecord/test/fixtures/people.yml +6 -0
  270. data/vendor/activerecord/test/fixtures/pets.yml +14 -0
  271. data/vendor/activerecord/test/fixtures/pirates.yml +9 -0
  272. data/vendor/activerecord/test/fixtures/posts.yml +49 -0
  273. data/vendor/activerecord/test/fixtures/price_estimates.yml +7 -0
  274. data/vendor/activerecord/test/fixtures/projects.yml +7 -0
  275. data/vendor/activerecord/test/fixtures/readers.yml +9 -0
  276. data/vendor/activerecord/test/fixtures/references.yml +17 -0
  277. data/vendor/activerecord/test/fixtures/reserved_words/distinct.yml +5 -0
  278. data/vendor/activerecord/test/fixtures/reserved_words/distincts_selects.yml +11 -0
  279. data/vendor/activerecord/test/fixtures/reserved_words/group.yml +14 -0
  280. data/vendor/activerecord/test/fixtures/reserved_words/select.yml +8 -0
  281. data/vendor/activerecord/test/fixtures/reserved_words/values.yml +7 -0
  282. data/vendor/activerecord/test/fixtures/ships.yml +5 -0
  283. data/vendor/activerecord/test/fixtures/sponsors.yml +9 -0
  284. data/vendor/activerecord/test/fixtures/subscribers.yml +7 -0
  285. data/vendor/activerecord/test/fixtures/subscriptions.yml +12 -0
  286. data/vendor/activerecord/test/fixtures/taggings.yml +28 -0
  287. data/vendor/activerecord/test/fixtures/tags.yml +7 -0
  288. data/vendor/activerecord/test/fixtures/tasks.yml +7 -0
  289. data/vendor/activerecord/test/fixtures/topics.yml +42 -0
  290. data/vendor/activerecord/test/fixtures/treasures.yml +10 -0
  291. data/vendor/activerecord/test/fixtures/vertices.yml +4 -0
  292. data/vendor/activerecord/test/fixtures/warehouse-things.yml +3 -0
  293. data/vendor/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb +15 -0
  294. data/vendor/activerecord/test/migrations/duplicate/1_people_have_last_names.rb +9 -0
  295. data/vendor/activerecord/test/migrations/duplicate/2_we_need_reminders.rb +12 -0
  296. data/vendor/activerecord/test/migrations/duplicate/3_foo.rb +7 -0
  297. data/vendor/activerecord/test/migrations/duplicate/3_innocent_jointable.rb +12 -0
  298. data/vendor/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb +7 -0
  299. data/vendor/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb +7 -0
  300. data/vendor/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb +12 -0
  301. data/vendor/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb +9 -0
  302. data/vendor/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb +12 -0
  303. data/vendor/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb +9 -0
  304. data/vendor/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +8 -0
  305. data/vendor/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +12 -0
  306. data/vendor/activerecord/test/migrations/missing/1000_people_have_middle_names.rb +9 -0
  307. data/vendor/activerecord/test/migrations/missing/1_people_have_last_names.rb +9 -0
  308. data/vendor/activerecord/test/migrations/missing/3_we_need_reminders.rb +12 -0
  309. data/vendor/activerecord/test/migrations/missing/4_innocent_jointable.rb +12 -0
  310. data/vendor/activerecord/test/migrations/valid/1_people_have_last_names.rb +9 -0
  311. data/vendor/activerecord/test/migrations/valid/2_we_need_reminders.rb +12 -0
  312. data/vendor/activerecord/test/migrations/valid/3_innocent_jointable.rb +12 -0
  313. data/vendor/activerecord/test/models/author.rb +137 -0
  314. data/vendor/activerecord/test/models/auto_id.rb +4 -0
  315. data/vendor/activerecord/test/models/binary.rb +2 -0
  316. data/vendor/activerecord/test/models/book.rb +4 -0
  317. data/vendor/activerecord/test/models/categorization.rb +5 -0
  318. data/vendor/activerecord/test/models/category.rb +30 -0
  319. data/vendor/activerecord/test/models/citation.rb +6 -0
  320. data/vendor/activerecord/test/models/club.rb +7 -0
  321. data/vendor/activerecord/test/models/column_name.rb +3 -0
  322. data/vendor/activerecord/test/models/comment.rb +25 -0
  323. data/vendor/activerecord/test/models/company.rb +132 -0
  324. data/vendor/activerecord/test/models/company_in_module.rb +61 -0
  325. data/vendor/activerecord/test/models/computer.rb +3 -0
  326. data/vendor/activerecord/test/models/contact.rb +16 -0
  327. data/vendor/activerecord/test/models/course.rb +3 -0
  328. data/vendor/activerecord/test/models/customer.rb +55 -0
  329. data/vendor/activerecord/test/models/default.rb +2 -0
  330. data/vendor/activerecord/test/models/developer.rb +79 -0
  331. data/vendor/activerecord/test/models/edge.rb +5 -0
  332. data/vendor/activerecord/test/models/entrant.rb +3 -0
  333. data/vendor/activerecord/test/models/guid.rb +2 -0
  334. data/vendor/activerecord/test/models/item.rb +7 -0
  335. data/vendor/activerecord/test/models/job.rb +5 -0
  336. data/vendor/activerecord/test/models/joke.rb +3 -0
  337. data/vendor/activerecord/test/models/keyboard.rb +3 -0
  338. data/vendor/activerecord/test/models/legacy_thing.rb +3 -0
  339. data/vendor/activerecord/test/models/matey.rb +4 -0
  340. data/vendor/activerecord/test/models/member.rb +9 -0
  341. data/vendor/activerecord/test/models/membership.rb +9 -0
  342. data/vendor/activerecord/test/models/minimalistic.rb +2 -0
  343. data/vendor/activerecord/test/models/mixed_case_monkey.rb +3 -0
  344. data/vendor/activerecord/test/models/movie.rb +5 -0
  345. data/vendor/activerecord/test/models/order.rb +4 -0
  346. data/vendor/activerecord/test/models/owner.rb +4 -0
  347. data/vendor/activerecord/test/models/parrot.rb +13 -0
  348. data/vendor/activerecord/test/models/person.rb +10 -0
  349. data/vendor/activerecord/test/models/pet.rb +4 -0
  350. data/vendor/activerecord/test/models/pirate.rb +9 -0
  351. data/vendor/activerecord/test/models/post.rb +85 -0
  352. data/vendor/activerecord/test/models/price_estimate.rb +3 -0
  353. data/vendor/activerecord/test/models/project.rb +29 -0
  354. data/vendor/activerecord/test/models/reader.rb +4 -0
  355. data/vendor/activerecord/test/models/reference.rb +4 -0
  356. data/vendor/activerecord/test/models/reply.rb +39 -0
  357. data/vendor/activerecord/test/models/ship.rb +3 -0
  358. data/vendor/activerecord/test/models/sponsor.rb +4 -0
  359. data/vendor/activerecord/test/models/subject.rb +4 -0
  360. data/vendor/activerecord/test/models/subscriber.rb +8 -0
  361. data/vendor/activerecord/test/models/subscription.rb +4 -0
  362. data/vendor/activerecord/test/models/tag.rb +7 -0
  363. data/vendor/activerecord/test/models/tagging.rb +10 -0
  364. data/vendor/activerecord/test/models/task.rb +3 -0
  365. data/vendor/activerecord/test/models/topic.rb +66 -0
  366. data/vendor/activerecord/test/models/treasure.rb +6 -0
  367. data/vendor/activerecord/test/models/vertex.rb +9 -0
  368. data/vendor/activerecord/test/models/warehouse_thing.rb +5 -0
  369. data/vendor/activerecord/test/schema/mysql_specific_schema.rb +12 -0
  370. data/vendor/activerecord/test/schema/postgresql_specific_schema.rb +103 -0
  371. data/vendor/activerecord/test/schema/schema.rb +429 -0
  372. data/vendor/activerecord/test/schema/schema2.rb +6 -0
  373. data/vendor/activerecord/test/schema/sqlite_specific_schema.rb +25 -0
  374. data/vendor/activerecord/test/schema/sqlserver_specific_schema.rb +5 -0
  375. data/vendor/activesupport/CHANGELOG +1193 -0
  376. data/vendor/activesupport/README +43 -0
  377. data/vendor/activesupport/lib/active_support/base64.rb +22 -0
  378. data/vendor/activesupport/lib/active_support/basic_object.rb +24 -0
  379. data/vendor/activesupport/lib/active_support/buffered_logger.rb +121 -0
  380. data/vendor/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb +15 -0
  381. data/vendor/activesupport/lib/active_support/cache/drb_store.rb +15 -0
  382. data/vendor/activesupport/lib/active_support/cache/file_store.rb +70 -0
  383. data/vendor/activesupport/lib/active_support/cache/mem_cache_store.rb +100 -0
  384. data/vendor/activesupport/lib/active_support/cache/memory_store.rb +38 -0
  385. data/vendor/activesupport/lib/active_support/cache.rb +147 -0
  386. data/vendor/activesupport/lib/active_support/callbacks.rb +275 -0
  387. data/vendor/activesupport/lib/active_support/clean_logger.rb +127 -0
  388. data/vendor/activesupport/lib/active_support/core_ext/array/access.rb +26 -0
  389. data/vendor/activesupport/lib/active_support/core_ext/array/conversions.rb +178 -0
  390. data/vendor/activesupport/lib/active_support/core_ext/array/extract_options.rb +20 -0
  391. data/vendor/activesupport/lib/active_support/core_ext/array/grouping.rb +63 -0
  392. data/vendor/activesupport/lib/active_support/core_ext/array/random_access.rb +12 -0
  393. data/vendor/activesupport/lib/active_support/core_ext/array.rb +13 -0
  394. data/vendor/activesupport/lib/active_support/core_ext/base64/encoding.rb +13 -0
  395. data/vendor/activesupport/lib/active_support/core_ext/base64.rb +4 -0
  396. data/vendor/activesupport/lib/active_support/core_ext/benchmark.rb +12 -0
  397. data/vendor/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb +41 -0
  398. data/vendor/activesupport/lib/active_support/core_ext/bigdecimal.rb +6 -0
  399. data/vendor/activesupport/lib/active_support/core_ext/blank.rb +53 -0
  400. data/vendor/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
  401. data/vendor/activesupport/lib/active_support/core_ext/cgi.rb +5 -0
  402. data/vendor/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
  403. data/vendor/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
  404. data/vendor/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  405. data/vendor/activesupport/lib/active_support/core_ext/class/removal.rb +50 -0
  406. data/vendor/activesupport/lib/active_support/core_ext/class.rb +4 -0
  407. data/vendor/activesupport/lib/active_support/core_ext/date/behavior.rb +39 -0
  408. data/vendor/activesupport/lib/active_support/core_ext/date/calculations.rb +215 -0
  409. data/vendor/activesupport/lib/active_support/core_ext/date/conversions.rb +107 -0
  410. data/vendor/activesupport/lib/active_support/core_ext/date.rb +10 -0
  411. data/vendor/activesupport/lib/active_support/core_ext/date_time/calculations.rb +112 -0
  412. data/vendor/activesupport/lib/active_support/core_ext/date_time/conversions.rb +96 -0
  413. data/vendor/activesupport/lib/active_support/core_ext/date_time.rb +12 -0
  414. data/vendor/activesupport/lib/active_support/core_ext/duplicable.rb +37 -0
  415. data/vendor/activesupport/lib/active_support/core_ext/enumerable.rb +69 -0
  416. data/vendor/activesupport/lib/active_support/core_ext/exception.rb +41 -0
  417. data/vendor/activesupport/lib/active_support/core_ext/file.rb +21 -0
  418. data/vendor/activesupport/lib/active_support/core_ext/float/rounding.rb +24 -0
  419. data/vendor/activesupport/lib/active_support/core_ext/float.rb +5 -0
  420. data/vendor/activesupport/lib/active_support/core_ext/hash/conversions.rb +259 -0
  421. data/vendor/activesupport/lib/active_support/core_ext/hash/diff.rb +19 -0
  422. data/vendor/activesupport/lib/active_support/core_ext/hash/except.rb +25 -0
  423. data/vendor/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
  424. data/vendor/activesupport/lib/active_support/core_ext/hash/keys.rb +52 -0
  425. data/vendor/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +28 -0
  426. data/vendor/activesupport/lib/active_support/core_ext/hash/slice.rb +30 -0
  427. data/vendor/activesupport/lib/active_support/core_ext/hash.rb +13 -0
  428. data/vendor/activesupport/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  429. data/vendor/activesupport/lib/active_support/core_ext/integer/inflections.rb +20 -0
  430. data/vendor/activesupport/lib/active_support/core_ext/integer.rb +7 -0
  431. data/vendor/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  432. data/vendor/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  433. data/vendor/activesupport/lib/active_support/core_ext/kernel/debugger.rb +13 -0
  434. data/vendor/activesupport/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  435. data/vendor/activesupport/lib/active_support/core_ext/kernel/requires.rb +24 -0
  436. data/vendor/activesupport/lib/active_support/core_ext/kernel.rb +5 -0
  437. data/vendor/activesupport/lib/active_support/core_ext/load_error.rb +38 -0
  438. data/vendor/activesupport/lib/active_support/core_ext/logger.rb +16 -0
  439. data/vendor/activesupport/lib/active_support/core_ext/module/aliasing.rb +70 -0
  440. data/vendor/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  441. data/vendor/activesupport/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  442. data/vendor/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
  443. data/vendor/activesupport/lib/active_support/core_ext/module/delegation.rb +64 -0
  444. data/vendor/activesupport/lib/active_support/core_ext/module/inclusion.rb +30 -0
  445. data/vendor/activesupport/lib/active_support/core_ext/module/introspection.rb +75 -0
  446. data/vendor/activesupport/lib/active_support/core_ext/module/loading.rb +23 -0
  447. data/vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb +22 -0
  448. data/vendor/activesupport/lib/active_support/core_ext/module.rb +13 -0
  449. data/vendor/activesupport/lib/active_support/core_ext/name_error.rb +17 -0
  450. data/vendor/activesupport/lib/active_support/core_ext/numeric/bytes.rb +44 -0
  451. data/vendor/activesupport/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  452. data/vendor/activesupport/lib/active_support/core_ext/numeric/time.rb +91 -0
  453. data/vendor/activesupport/lib/active_support/core_ext/numeric.rb +9 -0
  454. data/vendor/activesupport/lib/active_support/core_ext/object/conversions.rb +14 -0
  455. data/vendor/activesupport/lib/active_support/core_ext/object/extending.rb +59 -0
  456. data/vendor/activesupport/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  457. data/vendor/activesupport/lib/active_support/core_ext/object/misc.rb +59 -0
  458. data/vendor/activesupport/lib/active_support/core_ext/object.rb +4 -0
  459. data/vendor/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  460. data/vendor/activesupport/lib/active_support/core_ext/pathname.rb +7 -0
  461. data/vendor/activesupport/lib/active_support/core_ext/proc.rb +12 -0
  462. data/vendor/activesupport/lib/active_support/core_ext/process/daemon.rb +25 -0
  463. data/vendor/activesupport/lib/active_support/core_ext/process.rb +1 -0
  464. data/vendor/activesupport/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  465. data/vendor/activesupport/lib/active_support/core_ext/range/conversions.rb +27 -0
  466. data/vendor/activesupport/lib/active_support/core_ext/range/include_range.rb +30 -0
  467. data/vendor/activesupport/lib/active_support/core_ext/range/overlaps.rb +15 -0
  468. data/vendor/activesupport/lib/active_support/core_ext/range.rb +11 -0
  469. data/vendor/activesupport/lib/active_support/core_ext/rexml.rb +35 -0
  470. data/vendor/activesupport/lib/active_support/core_ext/string/access.rb +82 -0
  471. data/vendor/activesupport/lib/active_support/core_ext/string/conversions.rb +28 -0
  472. data/vendor/activesupport/lib/active_support/core_ext/string/filters.rb +26 -0
  473. data/vendor/activesupport/lib/active_support/core_ext/string/inflections.rb +148 -0
  474. data/vendor/activesupport/lib/active_support/core_ext/string/iterators.rb +21 -0
  475. data/vendor/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
  476. data/vendor/activesupport/lib/active_support/core_ext/string/unicode.rb +66 -0
  477. data/vendor/activesupport/lib/active_support/core_ext/string/xchar.rb +11 -0
  478. data/vendor/activesupport/lib/active_support/core_ext/string.rb +18 -0
  479. data/vendor/activesupport/lib/active_support/core_ext/symbol.rb +14 -0
  480. data/vendor/activesupport/lib/active_support/core_ext/test/unit/assertions.rb +64 -0
  481. data/vendor/activesupport/lib/active_support/core_ext/test.rb +1 -0
  482. data/vendor/activesupport/lib/active_support/core_ext/time/behavior.rb +13 -0
  483. data/vendor/activesupport/lib/active_support/core_ext/time/calculations.rb +276 -0
  484. data/vendor/activesupport/lib/active_support/core_ext/time/conversions.rb +89 -0
  485. data/vendor/activesupport/lib/active_support/core_ext/time/zones.rb +86 -0
  486. data/vendor/activesupport/lib/active_support/core_ext/time.rb +42 -0
  487. data/vendor/activesupport/lib/active_support/core_ext.rb +4 -0
  488. data/vendor/activesupport/lib/active_support/dependencies.rb +553 -0
  489. data/vendor/activesupport/lib/active_support/deprecation.rb +223 -0
  490. data/vendor/activesupport/lib/active_support/duration.rb +96 -0
  491. data/vendor/activesupport/lib/active_support/gzip.rb +25 -0
  492. data/vendor/activesupport/lib/active_support/inflections.rb +55 -0
  493. data/vendor/activesupport/lib/active_support/inflector.rb +313 -0
  494. data/vendor/activesupport/lib/active_support/json/decoding.rb +63 -0
  495. data/vendor/activesupport/lib/active_support/json/encoders/date.rb +14 -0
  496. data/vendor/activesupport/lib/active_support/json/encoders/date_time.rb +14 -0
  497. data/vendor/activesupport/lib/active_support/json/encoders/enumerable.rb +12 -0
  498. data/vendor/activesupport/lib/active_support/json/encoders/false_class.rb +5 -0
  499. data/vendor/activesupport/lib/active_support/json/encoders/hash.rb +47 -0
  500. data/vendor/activesupport/lib/active_support/json/encoders/nil_class.rb +5 -0
  501. data/vendor/activesupport/lib/active_support/json/encoders/numeric.rb +5 -0
  502. data/vendor/activesupport/lib/active_support/json/encoders/object.rb +6 -0
  503. data/vendor/activesupport/lib/active_support/json/encoders/regexp.rb +5 -0
  504. data/vendor/activesupport/lib/active_support/json/encoders/string.rb +36 -0
  505. data/vendor/activesupport/lib/active_support/json/encoders/symbol.rb +5 -0
  506. data/vendor/activesupport/lib/active_support/json/encoders/time.rb +14 -0
  507. data/vendor/activesupport/lib/active_support/json/encoders/true_class.rb +5 -0
  508. data/vendor/activesupport/lib/active_support/json/encoding.rb +37 -0
  509. data/vendor/activesupport/lib/active_support/json/variable.rb +10 -0
  510. data/vendor/activesupport/lib/active_support/json.rb +23 -0
  511. data/vendor/activesupport/lib/active_support/multibyte/chars.rb +137 -0
  512. data/vendor/activesupport/lib/active_support/multibyte/generators/generate_tables.rb +149 -0
  513. data/vendor/activesupport/lib/active_support/multibyte/handlers/passthru_handler.rb +9 -0
  514. data/vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +564 -0
  515. data/vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +43 -0
  516. data/vendor/activesupport/lib/active_support/multibyte.rb +9 -0
  517. data/vendor/activesupport/lib/active_support/option_merger.rb +25 -0
  518. data/vendor/activesupport/lib/active_support/ordered_hash.rb +43 -0
  519. data/vendor/activesupport/lib/active_support/ordered_options.rb +19 -0
  520. data/vendor/activesupport/lib/active_support/string_inquirer.rb +11 -0
  521. data/vendor/activesupport/lib/active_support/test_case.rb +13 -0
  522. data/vendor/activesupport/lib/active_support/testing/default.rb +9 -0
  523. data/vendor/activesupport/lib/active_support/testing/setup_and_teardown.rb +93 -0
  524. data/vendor/activesupport/lib/active_support/time_with_zone.rb +304 -0
  525. data/vendor/activesupport/lib/active_support/values/time_zone.rb +396 -0
  526. data/vendor/activesupport/lib/active_support/values/unicode_tables.dat +0 -0
  527. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  528. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  529. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  530. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  531. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  532. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  533. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  534. data/vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  535. data/vendor/activesupport/lib/active_support/vendor/memcache-client-1.5.0/memcache.rb +849 -0
  536. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/data_timezone.rb +47 -0
  537. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/data_timezone_info.rb +228 -0
  538. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Algiers.rb +55 -0
  539. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Cairo.rb +219 -0
  540. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Casablanca.rb +40 -0
  541. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Harare.rb +18 -0
  542. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  543. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  544. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  545. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  546. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Argentina/San_Juan.rb +170 -0
  547. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Bogota.rb +23 -0
  548. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Caracas.rb +23 -0
  549. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Chicago.rb +283 -0
  550. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Chihuahua.rb +136 -0
  551. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Denver.rb +204 -0
  552. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Godthab.rb +161 -0
  553. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Guatemala.rb +27 -0
  554. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Halifax.rb +274 -0
  555. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  556. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Juneau.rb +194 -0
  557. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/La_Paz.rb +22 -0
  558. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Lima.rb +35 -0
  559. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  560. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Mazatlan.rb +139 -0
  561. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Mexico_City.rb +144 -0
  562. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Monterrey.rb +131 -0
  563. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/New_York.rb +282 -0
  564. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Phoenix.rb +30 -0
  565. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Regina.rb +74 -0
  566. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Santiago.rb +205 -0
  567. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/St_Johns.rb +288 -0
  568. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/America/Tijuana.rb +196 -0
  569. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Almaty.rb +67 -0
  570. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  571. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Baku.rb +161 -0
  572. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  573. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  574. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  575. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  576. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  577. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  578. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  579. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Kabul.rb +20 -0
  580. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  581. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Karachi.rb +30 -0
  582. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  583. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  584. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  585. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  586. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  587. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Magadan.rb +163 -0
  588. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Muscat.rb +18 -0
  589. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  590. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  591. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  592. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Seoul.rb +34 -0
  593. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  594. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Singapore.rb +33 -0
  595. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Taipei.rb +59 -0
  596. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  597. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  598. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Tehran.rb +121 -0
  599. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  600. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  601. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  602. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  603. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  604. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  605. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  606. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  607. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  608. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  609. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  610. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  611. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Darwin.rb +29 -0
  612. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Hobart.rb +193 -0
  613. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  614. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Perth.rb +37 -0
  615. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Australia/Sydney.rb +185 -0
  616. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Etc/UTC.rb +16 -0
  617. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  618. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Athens.rb +185 -0
  619. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  620. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Berlin.rb +188 -0
  621. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  622. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Brussels.rb +232 -0
  623. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  624. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Budapest.rb +197 -0
  625. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  626. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Dublin.rb +276 -0
  627. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  628. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  629. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Kiev.rb +168 -0
  630. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  631. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  632. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/London.rb +288 -0
  633. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Madrid.rb +211 -0
  634. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Minsk.rb +170 -0
  635. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Moscow.rb +181 -0
  636. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Paris.rb +232 -0
  637. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Prague.rb +187 -0
  638. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Riga.rb +176 -0
  639. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Rome.rb +215 -0
  640. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  641. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Skopje.rb +13 -0
  642. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Sofia.rb +173 -0
  643. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  644. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  645. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Vienna.rb +183 -0
  646. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  647. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  648. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  649. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  650. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  651. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Guam.rb +22 -0
  652. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  653. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  654. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Midway.rb +25 -0
  655. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  656. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  657. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  658. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  659. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/info_timezone.rb +52 -0
  660. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/linked_timezone.rb +51 -0
  661. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/linked_timezone_info.rb +44 -0
  662. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/offset_rationals.rb +95 -0
  663. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/time_or_datetime.rb +292 -0
  664. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone.rb +508 -0
  665. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_definition.rb +56 -0
  666. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_info.rb +40 -0
  667. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_offset_info.rb +94 -0
  668. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_period.rb +198 -0
  669. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_transition_info.rb +138 -0
  670. data/vendor/activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo.rb +33 -0
  671. data/vendor/activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
  672. data/vendor/activesupport/lib/active_support/vendor.rb +26 -0
  673. data/vendor/activesupport/lib/active_support/version.rb +9 -0
  674. data/vendor/activesupport/lib/active_support/whiny_nil.rb +58 -0
  675. data/vendor/activesupport/lib/active_support.rb +61 -0
  676. data/vendor/activesupport/lib/activesupport.rb +1 -0
  677. data/vendor/isaac/LICENSE +26 -0
  678. data/vendor/isaac/README +78 -0
  679. data/vendor/isaac/TODO +3 -0
  680. data/vendor/isaac/VERSIONS +3 -0
  681. data/vendor/isaac/crypt/ISAAC.rb +171 -0
  682. data/vendor/isaac/isaac.gemspec +39 -0
  683. data/vendor/isaac/setup.rb +596 -0
  684. data/vendor/isaac/test/TC_ISAAC.rb +76 -0
  685. data/vendor/json/CHANGES +93 -0
  686. data/vendor/json/GPL +340 -0
  687. data/vendor/json/README +78 -0
  688. data/vendor/json/RUBY +58 -0
  689. data/vendor/json/Rakefile +309 -0
  690. data/vendor/json/TODO +1 -0
  691. data/vendor/json/VERSION +1 -0
  692. data/vendor/json/benchmarks/benchmark.txt +133 -0
  693. data/vendor/json/benchmarks/benchmark_generator.rb +48 -0
  694. data/vendor/json/benchmarks/benchmark_parser.rb +26 -0
  695. data/vendor/json/benchmarks/benchmark_rails.rb +26 -0
  696. data/vendor/json/bin/edit_json.rb +10 -0
  697. data/vendor/json/bin/prettify_json.rb +76 -0
  698. data/vendor/json/data/example.json +1 -0
  699. data/vendor/json/data/index.html +38 -0
  700. data/vendor/json/data/prototype.js +4184 -0
  701. data/vendor/json/ext/json/ext/generator/extconf.rb +9 -0
  702. data/vendor/json/ext/json/ext/generator/generator.c +875 -0
  703. data/vendor/json/ext/json/ext/generator/unicode.c +182 -0
  704. data/vendor/json/ext/json/ext/generator/unicode.h +53 -0
  705. data/vendor/json/ext/json/ext/parser/extconf.rb +9 -0
  706. data/vendor/json/ext/json/ext/parser/parser.c +1758 -0
  707. data/vendor/json/ext/json/ext/parser/parser.rl +638 -0
  708. data/vendor/json/ext/json/ext/parser/unicode.c +154 -0
  709. data/vendor/json/ext/json/ext/parser/unicode.h +58 -0
  710. data/vendor/json/install.rb +26 -0
  711. data/vendor/json/lib/json/Array.xpm +21 -0
  712. data/vendor/json/lib/json/FalseClass.xpm +21 -0
  713. data/vendor/json/lib/json/Hash.xpm +21 -0
  714. data/vendor/json/lib/json/Key.xpm +73 -0
  715. data/vendor/json/lib/json/NilClass.xpm +21 -0
  716. data/vendor/json/lib/json/Numeric.xpm +28 -0
  717. data/vendor/json/lib/json/String.xpm +96 -0
  718. data/vendor/json/lib/json/TrueClass.xpm +21 -0
  719. data/vendor/json/lib/json/add/core.rb +135 -0
  720. data/vendor/json/lib/json/add/rails.rb +58 -0
  721. data/vendor/json/lib/json/common.rb +354 -0
  722. data/vendor/json/lib/json/editor.rb +1362 -0
  723. data/vendor/json/lib/json/ext.rb +13 -0
  724. data/vendor/json/lib/json/json.xpm +1499 -0
  725. data/vendor/json/lib/json/pure/generator.rb +394 -0
  726. data/vendor/json/lib/json/pure/parser.rb +259 -0
  727. data/vendor/json/lib/json/pure.rb +75 -0
  728. data/vendor/json/lib/json/version.rb +9 -0
  729. data/vendor/json/lib/json.rb +235 -0
  730. data/vendor/json/tests/fixtures/fail1.json +1 -0
  731. data/vendor/json/tests/fixtures/fail10.json +1 -0
  732. data/vendor/json/tests/fixtures/fail11.json +1 -0
  733. data/vendor/json/tests/fixtures/fail12.json +1 -0
  734. data/vendor/json/tests/fixtures/fail13.json +1 -0
  735. data/vendor/json/tests/fixtures/fail14.json +1 -0
  736. data/vendor/json/tests/fixtures/fail18.json +1 -0
  737. data/vendor/json/tests/fixtures/fail19.json +1 -0
  738. data/vendor/json/tests/fixtures/fail2.json +1 -0
  739. data/vendor/json/tests/fixtures/fail20.json +1 -0
  740. data/vendor/json/tests/fixtures/fail21.json +1 -0
  741. data/vendor/json/tests/fixtures/fail22.json +1 -0
  742. data/vendor/json/tests/fixtures/fail23.json +1 -0
  743. data/vendor/json/tests/fixtures/fail24.json +1 -0
  744. data/vendor/json/tests/fixtures/fail25.json +1 -0
  745. data/vendor/json/tests/fixtures/fail27.json +2 -0
  746. data/vendor/json/tests/fixtures/fail28.json +2 -0
  747. data/vendor/json/tests/fixtures/fail3.json +1 -0
  748. data/vendor/json/tests/fixtures/fail4.json +1 -0
  749. data/vendor/json/tests/fixtures/fail5.json +1 -0
  750. data/vendor/json/tests/fixtures/fail6.json +1 -0
  751. data/vendor/json/tests/fixtures/fail7.json +1 -0
  752. data/vendor/json/tests/fixtures/fail8.json +1 -0
  753. data/vendor/json/tests/fixtures/fail9.json +1 -0
  754. data/vendor/json/tests/fixtures/pass1.json +56 -0
  755. data/vendor/json/tests/fixtures/pass15.json +1 -0
  756. data/vendor/json/tests/fixtures/pass16.json +1 -0
  757. data/vendor/json/tests/fixtures/pass17.json +1 -0
  758. data/vendor/json/tests/fixtures/pass2.json +1 -0
  759. data/vendor/json/tests/fixtures/pass26.json +1 -0
  760. data/vendor/json/tests/fixtures/pass3.json +6 -0
  761. data/vendor/json/tests/runner.rb +25 -0
  762. data/vendor/json/tests/test_json.rb +293 -0
  763. data/vendor/json/tests/test_json_addition.rb +161 -0
  764. data/vendor/json/tests/test_json_fixtures.rb +30 -0
  765. data/vendor/json/tests/test_json_generate.rb +100 -0
  766. data/vendor/json/tests/test_json_rails.rb +118 -0
  767. data/vendor/json/tests/test_json_unicode.rb +61 -0
  768. data/vendor/json/tools/fuzz.rb +140 -0
  769. data/vendor/json/tools/server.rb +62 -0
  770. data/vendor/rack/AUTHORS +8 -0
  771. data/vendor/rack/COPYING +18 -0
  772. data/vendor/rack/KNOWN-ISSUES +18 -0
  773. data/vendor/rack/RDOX +265 -0
  774. data/vendor/rack/README +287 -0
  775. data/vendor/rack/Rakefile +179 -0
  776. data/vendor/rack/SPEC +126 -0
  777. data/vendor/rack/bin/rackup +172 -0
  778. data/vendor/rack/contrib/rack_logo.svg +111 -0
  779. data/vendor/rack/example/lobster.ru +4 -0
  780. data/vendor/rack/example/protectedlobster.rb +14 -0
  781. data/vendor/rack/example/protectedlobster.ru +8 -0
  782. data/vendor/rack/lib/rack/adapter/camping.rb +22 -0
  783. data/vendor/rack/lib/rack/auth/abstract/handler.rb +28 -0
  784. data/vendor/rack/lib/rack/auth/abstract/request.rb +37 -0
  785. data/vendor/rack/lib/rack/auth/basic.rb +58 -0
  786. data/vendor/rack/lib/rack/auth/digest/md5.rb +124 -0
  787. data/vendor/rack/lib/rack/auth/digest/nonce.rb +51 -0
  788. data/vendor/rack/lib/rack/auth/digest/params.rb +55 -0
  789. data/vendor/rack/lib/rack/auth/digest/request.rb +40 -0
  790. data/vendor/rack/lib/rack/auth/openid.rb +437 -0
  791. data/vendor/rack/lib/rack/builder.rb +56 -0
  792. data/vendor/rack/lib/rack/cascade.rb +36 -0
  793. data/vendor/rack/lib/rack/commonlogger.rb +61 -0
  794. data/vendor/rack/lib/rack/deflater.rb +63 -0
  795. data/vendor/rack/lib/rack/directory.rb +158 -0
  796. data/vendor/rack/lib/rack/file.rb +116 -0
  797. data/vendor/rack/lib/rack/handler/cgi.rb +57 -0
  798. data/vendor/rack/lib/rack/handler/evented_mongrel.rb +8 -0
  799. data/vendor/rack/lib/rack/handler/fastcgi.rb +84 -0
  800. data/vendor/rack/lib/rack/handler/lsws.rb +52 -0
  801. data/vendor/rack/lib/rack/handler/mongrel.rb +78 -0
  802. data/vendor/rack/lib/rack/handler/scgi.rb +57 -0
  803. data/vendor/rack/lib/rack/handler/webrick.rb +57 -0
  804. data/vendor/rack/lib/rack/handler.rb +44 -0
  805. data/vendor/rack/lib/rack/lint.rb +401 -0
  806. data/vendor/rack/lib/rack/lobster.rb +65 -0
  807. data/vendor/rack/lib/rack/mock.rb +160 -0
  808. data/vendor/rack/lib/rack/recursive.rb +57 -0
  809. data/vendor/rack/lib/rack/reloader.rb +64 -0
  810. data/vendor/rack/lib/rack/request.rb +209 -0
  811. data/vendor/rack/lib/rack/response.rb +166 -0
  812. data/vendor/rack/lib/rack/session/abstract/id.rb +140 -0
  813. data/vendor/rack/lib/rack/session/cookie.rb +71 -0
  814. data/vendor/rack/lib/rack/session/memcache.rb +97 -0
  815. data/vendor/rack/lib/rack/session/pool.rb +73 -0
  816. data/vendor/rack/lib/rack/showexceptions.rb +344 -0
  817. data/vendor/rack/lib/rack/showstatus.rb +105 -0
  818. data/vendor/rack/lib/rack/static.rb +38 -0
  819. data/vendor/rack/lib/rack/urlmap.rb +48 -0
  820. data/vendor/rack/lib/rack/utils.rb +318 -0
  821. data/vendor/rack/lib/rack.rb +81 -0
  822. data/vendor/rack/test/cgi/lighttpd.conf +20 -0
  823. data/vendor/rack/test/cgi/test +9 -0
  824. data/vendor/rack/test/cgi/test.fcgi +8 -0
  825. data/vendor/rack/test/cgi/test.ru +7 -0
  826. data/vendor/rack/test/spec_rack_auth_basic.rb +69 -0
  827. data/vendor/rack/test/spec_rack_auth_digest.rb +169 -0
  828. data/vendor/rack/test/spec_rack_auth_openid.rb +137 -0
  829. data/vendor/rack/test/spec_rack_builder.rb +50 -0
  830. data/vendor/rack/test/spec_rack_camping.rb +51 -0
  831. data/vendor/rack/test/spec_rack_cascade.rb +50 -0
  832. data/vendor/rack/test/spec_rack_cgi.rb +89 -0
  833. data/vendor/rack/test/spec_rack_commonlogger.rb +32 -0
  834. data/vendor/rack/test/spec_rack_deflater.rb +70 -0
  835. data/vendor/rack/test/spec_rack_directory.rb +56 -0
  836. data/vendor/rack/test/spec_rack_fastcgi.rb +89 -0
  837. data/vendor/rack/test/spec_rack_file.rb +50 -0
  838. data/vendor/rack/test/spec_rack_handler.rb +24 -0
  839. data/vendor/rack/test/spec_rack_lint.rb +303 -0
  840. data/vendor/rack/test/spec_rack_lobster.rb +45 -0
  841. data/vendor/rack/test/spec_rack_mock.rb +152 -0
  842. data/vendor/rack/test/spec_rack_mongrel.rb +170 -0
  843. data/vendor/rack/test/spec_rack_recursive.rb +77 -0
  844. data/vendor/rack/test/spec_rack_request.rb +401 -0
  845. data/vendor/rack/test/spec_rack_response.rb +167 -0
  846. data/vendor/rack/test/spec_rack_session_cookie.rb +49 -0
  847. data/vendor/rack/test/spec_rack_session_memcache.rb +132 -0
  848. data/vendor/rack/test/spec_rack_session_pool.rb +84 -0
  849. data/vendor/rack/test/spec_rack_showexceptions.rb +21 -0
  850. data/vendor/rack/test/spec_rack_showstatus.rb +72 -0
  851. data/vendor/rack/test/spec_rack_static.rb +37 -0
  852. data/vendor/rack/test/spec_rack_urlmap.rb +175 -0
  853. data/vendor/rack/test/spec_rack_utils.rb +174 -0
  854. data/vendor/rack/test/spec_rack_webrick.rb +106 -0
  855. data/vendor/rack/test/testrequest.rb +45 -0
  856. data/vendor/sinatra/CHANGELOG +64 -0
  857. data/vendor/sinatra/LICENSE +22 -0
  858. data/vendor/sinatra/README.rdoc +533 -0
  859. data/vendor/sinatra/Rakefile +111 -0
  860. data/vendor/sinatra/images/404.png +0 -0
  861. data/vendor/sinatra/images/500.png +0 -0
  862. data/vendor/sinatra/lib/sinatra/rack/handler/mongrel.rb +85 -0
  863. data/vendor/sinatra/lib/sinatra/test/methods.rb +76 -0
  864. data/vendor/sinatra/lib/sinatra/test/rspec.rb +10 -0
  865. data/vendor/sinatra/lib/sinatra/test/spec.rb +10 -0
  866. data/vendor/sinatra/lib/sinatra/test/unit.rb +13 -0
  867. data/vendor/sinatra/lib/sinatra.rb +1477 -0
  868. data/vendor/sinatra/sinatra.gemspec +78 -0
  869. data/vendor/sinatra/test/app_test.rb +299 -0
  870. data/vendor/sinatra/test/application_test.rb +318 -0
  871. data/vendor/sinatra/test/builder_test.rb +101 -0
  872. data/vendor/sinatra/test/custom_error_test.rb +62 -0
  873. data/vendor/sinatra/test/erb_test.rb +136 -0
  874. data/vendor/sinatra/test/event_context_test.rb +15 -0
  875. data/vendor/sinatra/test/events_test.rb +47 -0
  876. data/vendor/sinatra/test/filter_test.rb +30 -0
  877. data/vendor/sinatra/test/haml_test.rb +233 -0
  878. data/vendor/sinatra/test/helper.rb +7 -0
  879. data/vendor/sinatra/test/mapped_error_test.rb +72 -0
  880. data/vendor/sinatra/test/pipeline_test.rb +66 -0
  881. data/vendor/sinatra/test/public/foo.xml +1 -0
  882. data/vendor/sinatra/test/sass_test.rb +57 -0
  883. data/vendor/sinatra/test/sessions_test.rb +39 -0
  884. data/vendor/sinatra/test/streaming_test.rb +118 -0
  885. data/vendor/sinatra/test/sym_params_test.rb +19 -0
  886. data/vendor/sinatra/test/template_test.rb +30 -0
  887. data/vendor/sinatra/test/use_in_file_templates_test.rb +47 -0
  888. data/vendor/sinatra/test/views/foo.builder +1 -0
  889. data/vendor/sinatra/test/views/foo.erb +1 -0
  890. data/vendor/sinatra/test/views/foo.haml +1 -0
  891. data/vendor/sinatra/test/views/foo.sass +2 -0
  892. data/vendor/sinatra/test/views/foo_layout.erb +2 -0
  893. data/vendor/sinatra/test/views/foo_layout.haml +2 -0
  894. data/vendor/sinatra/test/views/layout_test/foo.builder +1 -0
  895. data/vendor/sinatra/test/views/layout_test/foo.erb +1 -0
  896. data/vendor/sinatra/test/views/layout_test/foo.haml +1 -0
  897. data/vendor/sinatra/test/views/layout_test/foo.sass +2 -0
  898. data/vendor/sinatra/test/views/layout_test/layout.builder +3 -0
  899. data/vendor/sinatra/test/views/layout_test/layout.erb +1 -0
  900. data/vendor/sinatra/test/views/layout_test/layout.haml +1 -0
  901. data/vendor/sinatra/test/views/layout_test/layout.sass +2 -0
  902. data/vendor/sinatra/test/views/no_layout/no_layout.builder +1 -0
  903. data/vendor/sinatra/test/views/no_layout/no_layout.haml +1 -0
  904. metadata +1121 -0
@@ -0,0 +1,1997 @@
1
+ require "cases/helper"
2
+ require 'models/author'
3
+ require 'models/topic'
4
+ require 'models/reply'
5
+ require 'models/category'
6
+ require 'models/company'
7
+ require 'models/customer'
8
+ require 'models/developer'
9
+ require 'models/project'
10
+ require 'models/default'
11
+ require 'models/auto_id'
12
+ require 'models/column_name'
13
+ require 'models/subscriber'
14
+ require 'models/keyboard'
15
+ require 'models/post'
16
+ require 'models/comment'
17
+ require 'models/minimalistic'
18
+ require 'models/warehouse_thing'
19
+ require 'rexml/document'
20
+
21
+ class Category < ActiveRecord::Base; end
22
+ class Categorization < ActiveRecord::Base; end
23
+ class Smarts < ActiveRecord::Base; end
24
+ class CreditCard < ActiveRecord::Base
25
+ class PinNumber < ActiveRecord::Base
26
+ class CvvCode < ActiveRecord::Base; end
27
+ class SubCvvCode < CvvCode; end
28
+ end
29
+ class SubPinNumber < PinNumber; end
30
+ class Brand < Category; end
31
+ end
32
+ class MasterCreditCard < ActiveRecord::Base; end
33
+ class Post < ActiveRecord::Base; end
34
+ class Computer < ActiveRecord::Base; end
35
+ class NonExistentTable < ActiveRecord::Base; end
36
+ class TestOracleDefault < ActiveRecord::Base; end
37
+
38
+ class LoosePerson < ActiveRecord::Base
39
+ self.table_name = 'people'
40
+ self.abstract_class = true
41
+ attr_protected :credit_rating, :administrator
42
+ end
43
+
44
+ class LooseDescendant < LoosePerson
45
+ attr_protected :phone_number
46
+ end
47
+
48
+ class LooseDescendantSecond< LoosePerson
49
+ attr_protected :phone_number
50
+ attr_protected :name
51
+ end
52
+
53
+ class TightPerson < ActiveRecord::Base
54
+ self.table_name = 'people'
55
+ attr_accessible :name, :address
56
+ end
57
+
58
+ class TightDescendant < TightPerson
59
+ attr_accessible :phone_number
60
+ end
61
+
62
+ class ReadonlyTitlePost < Post
63
+ attr_readonly :title
64
+ end
65
+
66
+ class Booleantest < ActiveRecord::Base; end
67
+
68
+ class Task < ActiveRecord::Base
69
+ attr_protected :starting
70
+ end
71
+
72
+ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
73
+ self.table_name = 'topics'
74
+ attr_accessible :author_name
75
+ attr_protected :content
76
+ end
77
+
78
+ class BasicsTest < ActiveRecord::TestCase
79
+ fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories
80
+
81
+ def test_table_exists
82
+ assert !NonExistentTable.table_exists?
83
+ assert Topic.table_exists?
84
+ end
85
+
86
+ def test_set_attributes
87
+ topic = Topic.find(1)
88
+ topic.attributes = { "title" => "Budget", "author_name" => "Jason" }
89
+ topic.save
90
+ assert_equal("Budget", topic.title)
91
+ assert_equal("Jason", topic.author_name)
92
+ assert_equal(topics(:first).author_email_address, Topic.find(1).author_email_address)
93
+ end
94
+
95
+ def test_integers_as_nil
96
+ test = AutoId.create('value' => '')
97
+ assert_nil AutoId.find(test.id).value
98
+ end
99
+
100
+ def test_set_attributes_with_block
101
+ topic = Topic.new do |t|
102
+ t.title = "Budget"
103
+ t.author_name = "Jason"
104
+ end
105
+
106
+ assert_equal("Budget", topic.title)
107
+ assert_equal("Jason", topic.author_name)
108
+ end
109
+
110
+ def test_respond_to?
111
+ topic = Topic.find(1)
112
+ assert topic.respond_to?("title")
113
+ assert topic.respond_to?("title?")
114
+ assert topic.respond_to?("title=")
115
+ assert topic.respond_to?(:title)
116
+ assert topic.respond_to?(:title?)
117
+ assert topic.respond_to?(:title=)
118
+ assert topic.respond_to?("author_name")
119
+ assert topic.respond_to?("attribute_names")
120
+ assert !topic.respond_to?("nothingness")
121
+ assert !topic.respond_to?(:nothingness)
122
+ end
123
+
124
+ def test_array_content
125
+ topic = Topic.new
126
+ topic.content = %w( one two three )
127
+ topic.save
128
+
129
+ assert_equal(%w( one two three ), Topic.find(topic.id).content)
130
+ end
131
+
132
+ def test_read_attributes_before_type_cast
133
+ category = Category.new({:name=>"Test categoty", :type => nil})
134
+ category_attrs = {"name"=>"Test categoty", "type" => nil, "categorizations_count" => nil}
135
+ assert_equal category_attrs , category.attributes_before_type_cast
136
+ end
137
+
138
+ if current_adapter?(:MysqlAdapter)
139
+ def test_read_attributes_before_type_cast_on_boolean
140
+ bool = Booleantest.create({ "value" => false })
141
+ assert_equal 0, bool.attributes_before_type_cast["value"]
142
+ end
143
+ end
144
+
145
+ def test_read_attributes_before_type_cast_on_datetime
146
+ developer = Developer.find(:first)
147
+ assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"]
148
+ end
149
+
150
+ def test_hash_content
151
+ topic = Topic.new
152
+ topic.content = { "one" => 1, "two" => 2 }
153
+ topic.save
154
+
155
+ assert_equal 2, Topic.find(topic.id).content["two"]
156
+
157
+ topic.content_will_change!
158
+ topic.content["three"] = 3
159
+ topic.save
160
+
161
+ assert_equal 3, Topic.find(topic.id).content["three"]
162
+ end
163
+
164
+ def test_update_array_content
165
+ topic = Topic.new
166
+ topic.content = %w( one two three )
167
+
168
+ topic.content.push "four"
169
+ assert_equal(%w( one two three four ), topic.content)
170
+
171
+ topic.save
172
+
173
+ topic = Topic.find(topic.id)
174
+ topic.content << "five"
175
+ assert_equal(%w( one two three four five ), topic.content)
176
+ end
177
+
178
+ def test_case_sensitive_attributes_hash
179
+ # DB2 is not case-sensitive
180
+ return true if current_adapter?(:DB2Adapter)
181
+
182
+ assert_equal @loaded_fixtures['computers']['workstation'].to_hash, Computer.find(:first).attributes
183
+ end
184
+
185
+ def test_create
186
+ topic = Topic.new
187
+ topic.title = "New Topic"
188
+ topic.save
189
+ topic_reloaded = Topic.find(topic.id)
190
+ assert_equal("New Topic", topic_reloaded.title)
191
+ end
192
+
193
+ def test_save!
194
+ topic = Topic.new(:title => "New Topic")
195
+ assert topic.save!
196
+
197
+ reply = Reply.new
198
+ assert_raise(ActiveRecord::RecordInvalid) { reply.save! }
199
+ end
200
+
201
+ def test_save_null_string_attributes
202
+ topic = Topic.find(1)
203
+ topic.attributes = { "title" => "null", "author_name" => "null" }
204
+ topic.save!
205
+ topic.reload
206
+ assert_equal("null", topic.title)
207
+ assert_equal("null", topic.author_name)
208
+ end
209
+
210
+ def test_save_nil_string_attributes
211
+ topic = Topic.find(1)
212
+ topic.title = nil
213
+ topic.save!
214
+ topic.reload
215
+ assert_nil topic.title
216
+ end
217
+
218
+ def test_save_for_record_with_only_primary_key
219
+ minimalistic = Minimalistic.new
220
+ assert_nothing_raised { minimalistic.save }
221
+ end
222
+
223
+ def test_save_for_record_with_only_primary_key_that_is_provided
224
+ assert_nothing_raised { Minimalistic.create!(:id => 2) }
225
+ end
226
+
227
+ def test_hashes_not_mangled
228
+ new_topic = { :title => "New Topic" }
229
+ new_topic_values = { :title => "AnotherTopic" }
230
+
231
+ topic = Topic.new(new_topic)
232
+ assert_equal new_topic[:title], topic.title
233
+
234
+ topic.attributes= new_topic_values
235
+ assert_equal new_topic_values[:title], topic.title
236
+ end
237
+
238
+ def test_create_many
239
+ topics = Topic.create([ { "title" => "first" }, { "title" => "second" }])
240
+ assert_equal 2, topics.size
241
+ assert_equal "first", topics.first.title
242
+ end
243
+
244
+ def test_create_columns_not_equal_attributes
245
+ topic = Topic.new
246
+ topic.title = 'Another New Topic'
247
+ topic.send :write_attribute, 'does_not_exist', 'test'
248
+ assert_nothing_raised { topic.save }
249
+ end
250
+
251
+ def test_create_through_factory
252
+ topic = Topic.create("title" => "New Topic")
253
+ topicReloaded = Topic.find(topic.id)
254
+ assert_equal(topic, topicReloaded)
255
+ end
256
+
257
+ def test_create_through_factory_with_block
258
+ topic = Topic.create("title" => "New Topic") do |t|
259
+ t.author_name = "David"
260
+ end
261
+ topicReloaded = Topic.find(topic.id)
262
+ assert_equal("New Topic", topic.title)
263
+ assert_equal("David", topic.author_name)
264
+ end
265
+
266
+ def test_create_many_through_factory_with_block
267
+ topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) do |t|
268
+ t.author_name = "David"
269
+ end
270
+ assert_equal 2, topics.size
271
+ topic1, topic2 = Topic.find(topics[0].id), Topic.find(topics[1].id)
272
+ assert_equal "first", topic1.title
273
+ assert_equal "David", topic1.author_name
274
+ assert_equal "second", topic2.title
275
+ assert_equal "David", topic2.author_name
276
+ end
277
+
278
+ def test_update
279
+ topic = Topic.new
280
+ topic.title = "Another New Topic"
281
+ topic.written_on = "2003-12-12 23:23:00"
282
+ topic.save
283
+ topicReloaded = Topic.find(topic.id)
284
+ assert_equal("Another New Topic", topicReloaded.title)
285
+
286
+ topicReloaded.title = "Updated topic"
287
+ topicReloaded.save
288
+
289
+ topicReloadedAgain = Topic.find(topic.id)
290
+
291
+ assert_equal("Updated topic", topicReloadedAgain.title)
292
+ end
293
+
294
+ def test_update_columns_not_equal_attributes
295
+ topic = Topic.new
296
+ topic.title = "Still another topic"
297
+ topic.save
298
+
299
+ topicReloaded = Topic.find(topic.id)
300
+ topicReloaded.title = "A New Topic"
301
+ topicReloaded.send :write_attribute, 'does_not_exist', 'test'
302
+ assert_nothing_raised { topicReloaded.save }
303
+ end
304
+
305
+ def test_update_for_record_with_only_primary_key
306
+ minimalistic = minimalistics(:first)
307
+ assert_nothing_raised { minimalistic.save }
308
+ end
309
+
310
+ def test_write_attribute
311
+ topic = Topic.new
312
+ topic.send(:write_attribute, :title, "Still another topic")
313
+ assert_equal "Still another topic", topic.title
314
+
315
+ topic.send(:write_attribute, "title", "Still another topic: part 2")
316
+ assert_equal "Still another topic: part 2", topic.title
317
+ end
318
+
319
+ def test_read_attribute
320
+ topic = Topic.new
321
+ topic.title = "Don't change the topic"
322
+ assert_equal "Don't change the topic", topic.send(:read_attribute, "title")
323
+ assert_equal "Don't change the topic", topic["title"]
324
+
325
+ assert_equal "Don't change the topic", topic.send(:read_attribute, :title)
326
+ assert_equal "Don't change the topic", topic[:title]
327
+ end
328
+
329
+ def test_read_attribute_when_false
330
+ topic = topics(:first)
331
+ topic.approved = false
332
+ assert !topic.approved?, "approved should be false"
333
+ topic.approved = "false"
334
+ assert !topic.approved?, "approved should be false"
335
+ end
336
+
337
+ def test_read_attribute_when_true
338
+ topic = topics(:first)
339
+ topic.approved = true
340
+ assert topic.approved?, "approved should be true"
341
+ topic.approved = "true"
342
+ assert topic.approved?, "approved should be true"
343
+ end
344
+
345
+ def test_read_write_boolean_attribute
346
+ topic = Topic.new
347
+ # puts ""
348
+ # puts "New Topic"
349
+ # puts topic.inspect
350
+ topic.approved = "false"
351
+ # puts "Expecting false"
352
+ # puts topic.inspect
353
+ assert !topic.approved?, "approved should be false"
354
+ topic.approved = "false"
355
+ # puts "Expecting false"
356
+ # puts topic.inspect
357
+ assert !topic.approved?, "approved should be false"
358
+ topic.approved = "true"
359
+ # puts "Expecting true"
360
+ # puts topic.inspect
361
+ assert topic.approved?, "approved should be true"
362
+ topic.approved = "true"
363
+ # puts "Expecting true"
364
+ # puts topic.inspect
365
+ assert topic.approved?, "approved should be true"
366
+ # puts ""
367
+ end
368
+
369
+ def test_query_attribute_string
370
+ [nil, "", " "].each do |value|
371
+ assert_equal false, Topic.new(:author_name => value).author_name?
372
+ end
373
+
374
+ assert_equal true, Topic.new(:author_name => "Name").author_name?
375
+ end
376
+
377
+ def test_query_attribute_number
378
+ [nil, 0, "0"].each do |value|
379
+ assert_equal false, Developer.new(:salary => value).salary?
380
+ end
381
+
382
+ assert_equal true, Developer.new(:salary => 1).salary?
383
+ assert_equal true, Developer.new(:salary => "1").salary?
384
+ end
385
+
386
+ def test_query_attribute_boolean
387
+ [nil, "", false, "false", "f", 0].each do |value|
388
+ assert_equal false, Topic.new(:approved => value).approved?
389
+ end
390
+
391
+ [true, "true", "1", 1].each do |value|
392
+ assert_equal true, Topic.new(:approved => value).approved?
393
+ end
394
+ end
395
+
396
+ def test_query_attribute_with_custom_fields
397
+ object = Company.find_by_sql(<<-SQL).first
398
+ SELECT c1.*, c2.ruby_type as string_value, c2.rating as int_value
399
+ FROM companies c1, companies c2
400
+ WHERE c1.firm_id = c2.id
401
+ AND c1.id = 2
402
+ SQL
403
+
404
+ assert_equal "Firm", object.string_value
405
+ assert object.string_value?
406
+
407
+ object.string_value = " "
408
+ assert !object.string_value?
409
+
410
+ assert_equal 1, object.int_value.to_i
411
+ assert object.int_value?
412
+
413
+ object.int_value = "0"
414
+ assert !object.int_value?
415
+ end
416
+
417
+
418
+ def test_reader_for_invalid_column_names
419
+ Topic.send(:define_read_method, "mumub-jumbo".to_sym, "mumub-jumbo", nil)
420
+ assert !Topic.generated_methods.include?("mumub-jumbo")
421
+ end
422
+
423
+ def test_non_attribute_access_and_assignment
424
+ topic = Topic.new
425
+ assert !topic.respond_to?("mumbo")
426
+ assert_raises(NoMethodError) { topic.mumbo }
427
+ assert_raises(NoMethodError) { topic.mumbo = 5 }
428
+ end
429
+
430
+ def test_preserving_date_objects
431
+ # SQL Server doesn't have a separate column type just for dates, so all are returned as time
432
+ return true if current_adapter?(:SQLServerAdapter)
433
+
434
+ if current_adapter?(:SybaseAdapter, :OracleAdapter)
435
+ # Sybase ctlib does not (yet?) support the date type; use datetime instead.
436
+ # Oracle treats all dates/times as Time.
437
+ assert_kind_of(
438
+ Time, Topic.find(1).last_read,
439
+ "The last_read attribute should be of the Time class"
440
+ )
441
+ else
442
+ assert_kind_of(
443
+ Date, Topic.find(1).last_read,
444
+ "The last_read attribute should be of the Date class"
445
+ )
446
+ end
447
+ end
448
+
449
+ def test_preserving_time_objects
450
+ assert_kind_of(
451
+ Time, Topic.find(1).bonus_time,
452
+ "The bonus_time attribute should be of the Time class"
453
+ )
454
+
455
+ assert_kind_of(
456
+ Time, Topic.find(1).written_on,
457
+ "The written_on attribute should be of the Time class"
458
+ )
459
+
460
+ # For adapters which support microsecond resolution.
461
+ if current_adapter?(:PostgreSQLAdapter)
462
+ assert_equal 11, Topic.find(1).written_on.sec
463
+ assert_equal 223300, Topic.find(1).written_on.usec
464
+ assert_equal 9900, Topic.find(2).written_on.usec
465
+ end
466
+ end
467
+
468
+ def test_custom_mutator
469
+ topic = Topic.find(1)
470
+ # This mutator is protected in the class definition
471
+ topic.send(:approved=, true)
472
+ assert topic.instance_variable_get("@custom_approved")
473
+ end
474
+
475
+ def test_destroy
476
+ topic = Topic.find(1)
477
+ assert_equal topic, topic.destroy, 'topic.destroy did not return self'
478
+ assert topic.frozen?, 'topic not frozen after destroy'
479
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) }
480
+ end
481
+
482
+ def test_record_not_found_exception
483
+ assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
484
+ end
485
+
486
+ def test_initialize_with_attributes
487
+ topic = Topic.new({
488
+ "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23"
489
+ })
490
+
491
+ assert_equal("initialized from attributes", topic.title)
492
+ end
493
+
494
+ def test_initialize_with_invalid_attribute
495
+ begin
496
+ topic = Topic.new({ "title" => "test",
497
+ "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"})
498
+ rescue ActiveRecord::MultiparameterAssignmentErrors => ex
499
+ assert_equal(1, ex.errors.size)
500
+ assert_equal("last_read", ex.errors[0].attribute)
501
+ end
502
+ end
503
+
504
+ def test_load
505
+ topics = Topic.find(:all, :order => 'id')
506
+ assert_equal(4, topics.size)
507
+ assert_equal(topics(:first).title, topics.first.title)
508
+ end
509
+
510
+ def test_load_with_condition
511
+ topics = Topic.find(:all, :conditions => "author_name = 'Mary'")
512
+
513
+ assert_equal(1, topics.size)
514
+ assert_equal(topics(:second).title, topics.first.title)
515
+ end
516
+
517
+ def test_table_name_guesses
518
+ classes = [Category, Smarts, CreditCard, CreditCard::PinNumber, CreditCard::PinNumber::CvvCode, CreditCard::SubPinNumber, CreditCard::Brand, MasterCreditCard]
519
+
520
+ assert_equal "topics", Topic.table_name
521
+
522
+ assert_equal "categories", Category.table_name
523
+ assert_equal "smarts", Smarts.table_name
524
+ assert_equal "credit_cards", CreditCard.table_name
525
+ assert_equal "credit_card_pin_numbers", CreditCard::PinNumber.table_name
526
+ assert_equal "credit_card_pin_number_cvv_codes", CreditCard::PinNumber::CvvCode.table_name
527
+ assert_equal "credit_card_pin_numbers", CreditCard::SubPinNumber.table_name
528
+ assert_equal "categories", CreditCard::Brand.table_name
529
+ assert_equal "master_credit_cards", MasterCreditCard.table_name
530
+
531
+ ActiveRecord::Base.pluralize_table_names = false
532
+ classes.each(&:reset_table_name)
533
+
534
+ assert_equal "category", Category.table_name
535
+ assert_equal "smarts", Smarts.table_name
536
+ assert_equal "credit_card", CreditCard.table_name
537
+ assert_equal "credit_card_pin_number", CreditCard::PinNumber.table_name
538
+ assert_equal "credit_card_pin_number_cvv_code", CreditCard::PinNumber::CvvCode.table_name
539
+ assert_equal "credit_card_pin_number", CreditCard::SubPinNumber.table_name
540
+ assert_equal "category", CreditCard::Brand.table_name
541
+ assert_equal "master_credit_card", MasterCreditCard.table_name
542
+
543
+ ActiveRecord::Base.pluralize_table_names = true
544
+ classes.each(&:reset_table_name)
545
+
546
+ ActiveRecord::Base.table_name_prefix = "test_"
547
+ Category.reset_table_name
548
+ assert_equal "test_categories", Category.table_name
549
+ ActiveRecord::Base.table_name_suffix = "_test"
550
+ Category.reset_table_name
551
+ assert_equal "test_categories_test", Category.table_name
552
+ ActiveRecord::Base.table_name_prefix = ""
553
+ Category.reset_table_name
554
+ assert_equal "categories_test", Category.table_name
555
+ ActiveRecord::Base.table_name_suffix = ""
556
+ Category.reset_table_name
557
+ assert_equal "categories", Category.table_name
558
+
559
+ ActiveRecord::Base.pluralize_table_names = false
560
+ ActiveRecord::Base.table_name_prefix = "test_"
561
+ Category.reset_table_name
562
+ assert_equal "test_category", Category.table_name
563
+ ActiveRecord::Base.table_name_suffix = "_test"
564
+ Category.reset_table_name
565
+ assert_equal "test_category_test", Category.table_name
566
+ ActiveRecord::Base.table_name_prefix = ""
567
+ Category.reset_table_name
568
+ assert_equal "category_test", Category.table_name
569
+ ActiveRecord::Base.table_name_suffix = ""
570
+ Category.reset_table_name
571
+ assert_equal "category", Category.table_name
572
+
573
+ ActiveRecord::Base.pluralize_table_names = true
574
+ classes.each(&:reset_table_name)
575
+ end
576
+
577
+ def test_destroy_all
578
+ original_count = Topic.count
579
+ topics_by_mary = Topic.count(:conditions => mary = "author_name = 'Mary'")
580
+
581
+ Topic.destroy_all mary
582
+ assert_equal original_count - topics_by_mary, Topic.count
583
+ end
584
+
585
+ def test_destroy_many
586
+ assert_equal 3, Client.count
587
+ Client.destroy([2, 3])
588
+ assert_equal 1, Client.count
589
+ end
590
+
591
+ def test_delete_many
592
+ original_count = Topic.count
593
+ Topic.delete(deleting = [1, 2])
594
+ assert_equal original_count - deleting.size, Topic.count
595
+ end
596
+
597
+ def test_boolean_attributes
598
+ assert ! Topic.find(1).approved?
599
+ assert Topic.find(2).approved?
600
+ end
601
+
602
+ def test_increment_counter
603
+ Topic.increment_counter("replies_count", 1)
604
+ assert_equal 2, Topic.find(1).replies_count
605
+
606
+ Topic.increment_counter("replies_count", 1)
607
+ assert_equal 3, Topic.find(1).replies_count
608
+ end
609
+
610
+ def test_decrement_counter
611
+ Topic.decrement_counter("replies_count", 2)
612
+ assert_equal -1, Topic.find(2).replies_count
613
+
614
+ Topic.decrement_counter("replies_count", 2)
615
+ assert_equal -2, Topic.find(2).replies_count
616
+ end
617
+
618
+ def test_update_counter
619
+ category = categories(:general)
620
+ assert_nil category.categorizations_count
621
+ assert_equal 2, category.categorizations.count
622
+
623
+ Category.update_counters(category.id, "categorizations_count" => category.categorizations.count)
624
+ category.reload
625
+ assert_not_nil category.categorizations_count
626
+ assert_equal 2, category.categorizations_count
627
+
628
+ Category.update_counters(category.id, "categorizations_count" => category.categorizations.count)
629
+ category.reload
630
+ assert_not_nil category.categorizations_count
631
+ assert_equal 4, category.categorizations_count
632
+ end
633
+
634
+ def test_update_all
635
+ assert_equal Topic.count, Topic.update_all("content = 'bulk updated!'")
636
+ assert_equal "bulk updated!", Topic.find(1).content
637
+ assert_equal "bulk updated!", Topic.find(2).content
638
+
639
+ assert_equal Topic.count, Topic.update_all(['content = ?', 'bulk updated again!'])
640
+ assert_equal "bulk updated again!", Topic.find(1).content
641
+ assert_equal "bulk updated again!", Topic.find(2).content
642
+
643
+ assert_equal Topic.count, Topic.update_all(['content = ?', nil])
644
+ assert_nil Topic.find(1).content
645
+ end
646
+
647
+ def test_update_all_with_hash
648
+ assert_not_nil Topic.find(1).last_read
649
+ assert_equal Topic.count, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil)
650
+ assert_equal "bulk updated with hash!", Topic.find(1).content
651
+ assert_equal "bulk updated with hash!", Topic.find(2).content
652
+ assert_nil Topic.find(1).last_read
653
+ assert_nil Topic.find(2).last_read
654
+ end
655
+
656
+ def test_update_all_with_non_standard_table_name
657
+ assert_equal 1, WarehouseThing.update_all(['value = ?', 0], ['id = ?', 1])
658
+ assert_equal 0, WarehouseThing.find(1).value
659
+ end
660
+
661
+ if current_adapter?(:MysqlAdapter)
662
+ def test_update_all_with_order_and_limit
663
+ assert_equal 1, Topic.update_all("content = 'bulk updated!'", nil, :limit => 1, :order => 'id DESC')
664
+ end
665
+ end
666
+
667
+ def test_update_all_ignores_order_limit_from_association
668
+ author = Author.find(1)
669
+ assert_nothing_raised do
670
+ assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all("body = 'bulk update!'")
671
+ end
672
+ end
673
+
674
+ def test_update_many
675
+ topic_data = { 1 => { "content" => "1 updated" }, 2 => { "content" => "2 updated" } }
676
+ updated = Topic.update(topic_data.keys, topic_data.values)
677
+
678
+ assert_equal 2, updated.size
679
+ assert_equal "1 updated", Topic.find(1).content
680
+ assert_equal "2 updated", Topic.find(2).content
681
+ end
682
+
683
+ def test_delete_all
684
+ assert Topic.count > 0
685
+
686
+ assert_equal Topic.count, Topic.delete_all
687
+ end
688
+
689
+ def test_update_by_condition
690
+ Topic.update_all "content = 'bulk updated!'", ["approved = ?", true]
691
+ assert_equal "Have a nice day", Topic.find(1).content
692
+ assert_equal "bulk updated!", Topic.find(2).content
693
+ end
694
+
695
+ def test_attribute_present
696
+ t = Topic.new
697
+ t.title = "hello there!"
698
+ t.written_on = Time.now
699
+ assert t.attribute_present?("title")
700
+ assert t.attribute_present?("written_on")
701
+ assert !t.attribute_present?("content")
702
+ end
703
+
704
+ def test_attribute_keys_on_new_instance
705
+ t = Topic.new
706
+ assert_equal nil, t.title, "The topics table has a title column, so it should be nil"
707
+ assert_raise(NoMethodError) { t.title2 }
708
+ end
709
+
710
+ def test_class_name
711
+ assert_equal "Firm", ActiveRecord::Base.class_name("firms")
712
+ assert_equal "Category", ActiveRecord::Base.class_name("categories")
713
+ assert_equal "AccountHolder", ActiveRecord::Base.class_name("account_holder")
714
+
715
+ ActiveRecord::Base.pluralize_table_names = false
716
+ assert_equal "Firms", ActiveRecord::Base.class_name( "firms" )
717
+ ActiveRecord::Base.pluralize_table_names = true
718
+
719
+ ActiveRecord::Base.table_name_prefix = "test_"
720
+ assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms" )
721
+ ActiveRecord::Base.table_name_suffix = "_tests"
722
+ assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms_tests" )
723
+ ActiveRecord::Base.table_name_prefix = ""
724
+ assert_equal "Firm", ActiveRecord::Base.class_name( "firms_tests" )
725
+ ActiveRecord::Base.table_name_suffix = ""
726
+ assert_equal "Firm", ActiveRecord::Base.class_name( "firms" )
727
+ end
728
+
729
+ def test_null_fields
730
+ assert_nil Topic.find(1).parent_id
731
+ assert_nil Topic.create("title" => "Hey you").parent_id
732
+ end
733
+
734
+ def test_default_values
735
+ topic = Topic.new
736
+ assert topic.approved?
737
+ assert_nil topic.written_on
738
+ assert_nil topic.bonus_time
739
+ assert_nil topic.last_read
740
+
741
+ topic.save
742
+
743
+ topic = Topic.find(topic.id)
744
+ assert topic.approved?
745
+ assert_nil topic.last_read
746
+
747
+ # Oracle has some funky default handling, so it requires a bit of
748
+ # extra testing. See ticket #2788.
749
+ if current_adapter?(:OracleAdapter)
750
+ test = TestOracleDefault.new
751
+ assert_equal "X", test.test_char
752
+ assert_equal "hello", test.test_string
753
+ assert_equal 3, test.test_int
754
+ end
755
+ end
756
+
757
+ # Oracle, SQLServer, and Sybase do not have a TIME datatype.
758
+ unless current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
759
+ def test_utc_as_time_zone
760
+ Topic.default_timezone = :utc
761
+ attributes = { "bonus_time" => "5:42:00AM" }
762
+ topic = Topic.find(1)
763
+ topic.attributes = attributes
764
+ assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time
765
+ Topic.default_timezone = :local
766
+ end
767
+
768
+ def test_utc_as_time_zone_and_new
769
+ Topic.default_timezone = :utc
770
+ attributes = { "bonus_time(1i)"=>"2000",
771
+ "bonus_time(2i)"=>"1",
772
+ "bonus_time(3i)"=>"1",
773
+ "bonus_time(4i)"=>"10",
774
+ "bonus_time(5i)"=>"35",
775
+ "bonus_time(6i)"=>"50" }
776
+ topic = Topic.new(attributes)
777
+ assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time
778
+ Topic.default_timezone = :local
779
+ end
780
+ end
781
+
782
+ def test_default_values_on_empty_strings
783
+ topic = Topic.new
784
+ topic.approved = nil
785
+ topic.last_read = nil
786
+
787
+ topic.save
788
+
789
+ topic = Topic.find(topic.id)
790
+ assert_nil topic.last_read
791
+
792
+ # Sybase adapter does not allow nulls in boolean columns
793
+ if current_adapter?(:SybaseAdapter)
794
+ assert topic.approved == false
795
+ else
796
+ assert_nil topic.approved
797
+ end
798
+ end
799
+
800
+ def test_equality
801
+ assert_equal Topic.find(1), Topic.find(2).topic
802
+ end
803
+
804
+ def test_equality_of_new_records
805
+ assert_not_equal Topic.new, Topic.new
806
+ end
807
+
808
+ def test_hashing
809
+ assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ]
810
+ end
811
+
812
+ def test_destroy_new_record
813
+ client = Client.new
814
+ client.destroy
815
+ assert client.frozen?
816
+ end
817
+
818
+ def test_destroy_record_with_associations
819
+ client = Client.find(3)
820
+ client.destroy
821
+ assert client.frozen?
822
+ assert_kind_of Firm, client.firm
823
+ assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" }
824
+ end
825
+
826
+ def test_update_attribute
827
+ assert !Topic.find(1).approved?
828
+ Topic.find(1).update_attribute("approved", true)
829
+ assert Topic.find(1).approved?
830
+
831
+ Topic.find(1).update_attribute(:approved, false)
832
+ assert !Topic.find(1).approved?
833
+ end
834
+
835
+ def test_update_attributes
836
+ topic = Topic.find(1)
837
+ assert !topic.approved?
838
+ assert_equal "The First Topic", topic.title
839
+
840
+ topic.update_attributes("approved" => true, "title" => "The First Topic Updated")
841
+ topic.reload
842
+ assert topic.approved?
843
+ assert_equal "The First Topic Updated", topic.title
844
+
845
+ topic.update_attributes(:approved => false, :title => "The First Topic")
846
+ topic.reload
847
+ assert !topic.approved?
848
+ assert_equal "The First Topic", topic.title
849
+ end
850
+
851
+ def test_update_attributes!
852
+ reply = Reply.find(2)
853
+ assert_equal "The Second Topic of the day", reply.title
854
+ assert_equal "Have a nice day", reply.content
855
+
856
+ reply.update_attributes!("title" => "The Second Topic of the day updated", "content" => "Have a nice evening")
857
+ reply.reload
858
+ assert_equal "The Second Topic of the day updated", reply.title
859
+ assert_equal "Have a nice evening", reply.content
860
+
861
+ reply.update_attributes!(:title => "The Second Topic of the day", :content => "Have a nice day")
862
+ reply.reload
863
+ assert_equal "The Second Topic of the day", reply.title
864
+ assert_equal "Have a nice day", reply.content
865
+
866
+ assert_raise(ActiveRecord::RecordInvalid) { reply.update_attributes!(:title => nil, :content => "Have a nice evening") }
867
+ end
868
+
869
+ def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used
870
+ topic = TopicWithProtectedContentAndAccessibleAuthorName.new
871
+ assert_raises(RuntimeError) { topic.attributes = { "author_name" => "me" } }
872
+ assert_raises(RuntimeError) { topic.attributes = { "content" => "stuff" } }
873
+ end
874
+
875
+ def test_mass_assignment_protection
876
+ firm = Firm.new
877
+ firm.attributes = { "name" => "Next Angle", "rating" => 5 }
878
+ assert_equal 1, firm.rating
879
+ end
880
+
881
+ def test_mass_assignment_protection_against_class_attribute_writers
882
+ [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging,
883
+ :default_timezone, :allow_concurrency, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method|
884
+ assert Task.respond_to?(method)
885
+ assert Task.respond_to?("#{method}=")
886
+ assert Task.new.respond_to?(method)
887
+ assert !Task.new.respond_to?("#{method}=")
888
+ end
889
+ end
890
+
891
+ def test_customized_primary_key_remains_protected
892
+ subscriber = Subscriber.new(:nick => 'webster123', :name => 'nice try')
893
+ assert_nil subscriber.id
894
+
895
+ keyboard = Keyboard.new(:key_number => 9, :name => 'nice try')
896
+ assert_nil keyboard.id
897
+ end
898
+
899
+ def test_customized_primary_key_remains_protected_when_referred_to_as_id
900
+ subscriber = Subscriber.new(:id => 'webster123', :name => 'nice try')
901
+ assert_nil subscriber.id
902
+
903
+ keyboard = Keyboard.new(:id => 9, :name => 'nice try')
904
+ assert_nil keyboard.id
905
+ end
906
+
907
+ def test_mass_assignment_protection_on_defaults
908
+ firm = Firm.new
909
+ firm.attributes = { "id" => 5, "type" => "Client" }
910
+ assert_nil firm.id
911
+ assert_equal "Firm", firm[:type]
912
+ end
913
+
914
+ def test_mass_assignment_accessible
915
+ reply = Reply.new("title" => "hello", "content" => "world", "approved" => true)
916
+ reply.save
917
+
918
+ assert reply.approved?
919
+
920
+ reply.approved = false
921
+ reply.save
922
+
923
+ assert !reply.approved?
924
+ end
925
+
926
+ def test_mass_assignment_protection_inheritance
927
+ assert_nil LoosePerson.accessible_attributes
928
+ assert_equal Set.new([ 'credit_rating', 'administrator' ]), LoosePerson.protected_attributes
929
+
930
+ assert_nil LooseDescendant.accessible_attributes
931
+ assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number' ]), LooseDescendant.protected_attributes
932
+
933
+ assert_nil LooseDescendantSecond.accessible_attributes
934
+ assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number', 'name' ]), LooseDescendantSecond.protected_attributes, 'Running attr_protected twice in one class should merge the protections'
935
+
936
+ assert_nil TightPerson.protected_attributes
937
+ assert_equal Set.new([ 'name', 'address' ]), TightPerson.accessible_attributes
938
+
939
+ assert_nil TightDescendant.protected_attributes
940
+ assert_equal Set.new([ 'name', 'address', 'phone_number' ]), TightDescendant.accessible_attributes
941
+ end
942
+
943
+ def test_readonly_attributes
944
+ assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes
945
+
946
+ post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable")
947
+ post.reload
948
+ assert_equal "cannot change this", post.title
949
+
950
+ post.update_attributes(:title => "try to change", :body => "changed")
951
+ post.reload
952
+ assert_equal "cannot change this", post.title
953
+ assert_equal "changed", post.body
954
+ end
955
+
956
+ def test_multiparameter_attributes_on_date
957
+ attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "24" }
958
+ topic = Topic.find(1)
959
+ topic.attributes = attributes
960
+ # note that extra #to_date call allows test to pass for Oracle, which
961
+ # treats dates/times the same
962
+ assert_date_from_db Date.new(2004, 6, 24), topic.last_read.to_date
963
+ end
964
+
965
+ def test_multiparameter_attributes_on_date_with_empty_date
966
+ attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "" }
967
+ topic = Topic.find(1)
968
+ topic.attributes = attributes
969
+ # note that extra #to_date call allows test to pass for Oracle, which
970
+ # treats dates/times the same
971
+ assert_date_from_db Date.new(2004, 6, 1), topic.last_read.to_date
972
+ end
973
+
974
+ def test_multiparameter_attributes_on_date_with_all_empty
975
+ attributes = { "last_read(1i)" => "", "last_read(2i)" => "", "last_read(3i)" => "" }
976
+ topic = Topic.find(1)
977
+ topic.attributes = attributes
978
+ assert_nil topic.last_read
979
+ end
980
+
981
+ def test_multiparameter_attributes_on_time
982
+ attributes = {
983
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
984
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
985
+ }
986
+ topic = Topic.find(1)
987
+ topic.attributes = attributes
988
+ assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
989
+ end
990
+
991
+ def test_multiparameter_attributes_on_time_with_old_date
992
+ attributes = {
993
+ "written_on(1i)" => "1850", "written_on(2i)" => "6", "written_on(3i)" => "24",
994
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
995
+ }
996
+ topic = Topic.find(1)
997
+ topic.attributes = attributes
998
+ # testing against to_s(:db) representation because either a Time or a DateTime might be returned, depending on platform
999
+ assert_equal "1850-06-24 16:24:00", topic.written_on.to_s(:db)
1000
+ end
1001
+
1002
+ def test_multiparameter_attributes_on_time_with_utc
1003
+ ActiveRecord::Base.default_timezone = :utc
1004
+ attributes = {
1005
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
1006
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
1007
+ }
1008
+ topic = Topic.find(1)
1009
+ topic.attributes = attributes
1010
+ assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on
1011
+ ensure
1012
+ ActiveRecord::Base.default_timezone = :local
1013
+ end
1014
+
1015
+ def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes
1016
+ ActiveRecord::Base.time_zone_aware_attributes = true
1017
+ ActiveRecord::Base.default_timezone = :utc
1018
+ Time.zone = ActiveSupport::TimeZone[-28800]
1019
+ attributes = {
1020
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
1021
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
1022
+ }
1023
+ topic = Topic.find(1)
1024
+ topic.attributes = attributes
1025
+ assert_equal Time.utc(2004, 6, 24, 23, 24, 0), topic.written_on
1026
+ assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on.time
1027
+ assert_equal Time.zone, topic.written_on.time_zone
1028
+ ensure
1029
+ ActiveRecord::Base.time_zone_aware_attributes = false
1030
+ ActiveRecord::Base.default_timezone = :local
1031
+ Time.zone = nil
1032
+ end
1033
+
1034
+ def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false
1035
+ ActiveRecord::Base.time_zone_aware_attributes = false
1036
+ Time.zone = ActiveSupport::TimeZone[-28800]
1037
+ attributes = {
1038
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
1039
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
1040
+ }
1041
+ topic = Topic.find(1)
1042
+ topic.attributes = attributes
1043
+ assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
1044
+ assert_equal false, topic.written_on.respond_to?(:time_zone)
1045
+ ensure
1046
+ Time.zone = nil
1047
+ end
1048
+
1049
+ def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes
1050
+ ActiveRecord::Base.time_zone_aware_attributes = true
1051
+ ActiveRecord::Base.default_timezone = :utc
1052
+ Time.zone = ActiveSupport::TimeZone[-28800]
1053
+ Topic.skip_time_zone_conversion_for_attributes = [:written_on]
1054
+ attributes = {
1055
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
1056
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00"
1057
+ }
1058
+ topic = Topic.find(1)
1059
+ topic.attributes = attributes
1060
+ assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on
1061
+ assert_equal false, topic.written_on.respond_to?(:time_zone)
1062
+ ensure
1063
+ ActiveRecord::Base.time_zone_aware_attributes = false
1064
+ ActiveRecord::Base.default_timezone = :local
1065
+ Time.zone = nil
1066
+ Topic.skip_time_zone_conversion_for_attributes = []
1067
+ end
1068
+
1069
+ def test_multiparameter_attributes_on_time_with_empty_seconds
1070
+ attributes = {
1071
+ "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
1072
+ "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => ""
1073
+ }
1074
+ topic = Topic.find(1)
1075
+ topic.attributes = attributes
1076
+ assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
1077
+ end
1078
+
1079
+ def test_multiparameter_mass_assignment_protector
1080
+ task = Task.new
1081
+ time = Time.mktime(2000, 1, 1, 1)
1082
+ task.starting = time
1083
+ attributes = { "starting(1i)" => "2004", "starting(2i)" => "6", "starting(3i)" => "24" }
1084
+ task.attributes = attributes
1085
+ assert_equal time, task.starting
1086
+ end
1087
+
1088
+ def test_multiparameter_assignment_of_aggregation
1089
+ customer = Customer.new
1090
+ address = Address.new("The Street", "The City", "The Country")
1091
+ attributes = { "address(1)" => address.street, "address(2)" => address.city, "address(3)" => address.country }
1092
+ customer.attributes = attributes
1093
+ assert_equal address, customer.address
1094
+ end
1095
+
1096
+ def test_attributes_on_dummy_time
1097
+ # Oracle, SQL Server, and Sybase do not have a TIME datatype.
1098
+ return true if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter)
1099
+
1100
+ attributes = {
1101
+ "bonus_time" => "5:42:00AM"
1102
+ }
1103
+ topic = Topic.find(1)
1104
+ topic.attributes = attributes
1105
+ assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time
1106
+ end
1107
+
1108
+ def test_boolean
1109
+ b_false = Booleantest.create({ "value" => false })
1110
+ false_id = b_false.id
1111
+ b_true = Booleantest.create({ "value" => true })
1112
+ true_id = b_true.id
1113
+
1114
+ b_false = Booleantest.find(false_id)
1115
+ assert !b_false.value?
1116
+ b_true = Booleantest.find(true_id)
1117
+ assert b_true.value?
1118
+ end
1119
+
1120
+ def test_boolean_cast_from_string
1121
+ b_false = Booleantest.create({ "value" => "0" })
1122
+ false_id = b_false.id
1123
+ b_true = Booleantest.create({ "value" => "1" })
1124
+ true_id = b_true.id
1125
+
1126
+ b_false = Booleantest.find(false_id)
1127
+ assert !b_false.value?
1128
+ b_true = Booleantest.find(true_id)
1129
+ assert b_true.value?
1130
+ end
1131
+
1132
+ def test_clone
1133
+ topic = Topic.find(1)
1134
+ cloned_topic = nil
1135
+ assert_nothing_raised { cloned_topic = topic.clone }
1136
+ assert_equal topic.title, cloned_topic.title
1137
+ assert cloned_topic.new_record?
1138
+
1139
+ # test if the attributes have been cloned
1140
+ topic.title = "a"
1141
+ cloned_topic.title = "b"
1142
+ assert_equal "a", topic.title
1143
+ assert_equal "b", cloned_topic.title
1144
+
1145
+ # test if the attribute values have been cloned
1146
+ topic.title = {"a" => "b"}
1147
+ cloned_topic = topic.clone
1148
+ cloned_topic.title["a"] = "c"
1149
+ assert_equal "b", topic.title["a"]
1150
+
1151
+ #test if attributes set as part of after_initialize are cloned correctly
1152
+ assert_equal topic.author_email_address, cloned_topic.author_email_address
1153
+
1154
+ # test if saved clone object differs from original
1155
+ cloned_topic.save
1156
+ assert !cloned_topic.new_record?
1157
+ assert cloned_topic.id != topic.id
1158
+ end
1159
+
1160
+ def test_clone_with_aggregate_of_same_name_as_attribute
1161
+ dev = DeveloperWithAggregate.find(1)
1162
+ assert_kind_of DeveloperSalary, dev.salary
1163
+
1164
+ clone = nil
1165
+ assert_nothing_raised { clone = dev.clone }
1166
+ assert_kind_of DeveloperSalary, clone.salary
1167
+ assert_equal dev.salary.amount, clone.salary.amount
1168
+ assert clone.new_record?
1169
+
1170
+ # test if the attributes have been cloned
1171
+ original_amount = clone.salary.amount
1172
+ dev.salary.amount = 1
1173
+ assert_equal original_amount, clone.salary.amount
1174
+
1175
+ assert clone.save
1176
+ assert !clone.new_record?
1177
+ assert clone.id != dev.id
1178
+ end
1179
+
1180
+ def test_clone_preserves_subtype
1181
+ clone = nil
1182
+ assert_nothing_raised { clone = Company.find(3).clone }
1183
+ assert_kind_of Client, clone
1184
+ end
1185
+
1186
+ def test_bignum
1187
+ company = Company.find(1)
1188
+ company.rating = 2147483647
1189
+ company.save
1190
+ company = Company.find(1)
1191
+ assert_equal 2147483647, company.rating
1192
+ end
1193
+
1194
+ # TODO: extend defaults tests to other databases!
1195
+ if current_adapter?(:PostgreSQLAdapter)
1196
+ def test_default
1197
+ default = Default.new
1198
+
1199
+ # fixed dates / times
1200
+ assert_equal Date.new(2004, 1, 1), default.fixed_date
1201
+ assert_equal Time.local(2004, 1,1,0,0,0,0), default.fixed_time
1202
+
1203
+ # char types
1204
+ assert_equal 'Y', default.char1
1205
+ assert_equal 'a varchar field', default.char2
1206
+ assert_equal 'a text field', default.char3
1207
+ end
1208
+
1209
+ class Geometric < ActiveRecord::Base; end
1210
+ def test_geometric_content
1211
+
1212
+ # accepted format notes:
1213
+ # ()'s aren't required
1214
+ # values can be a mix of float or integer
1215
+
1216
+ g = Geometric.new(
1217
+ :a_point => '(5.0, 6.1)',
1218
+ #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
1219
+ :a_line_segment => '(2.0, 3), (5.5, 7.0)',
1220
+ :a_box => '2.0, 3, 5.5, 7.0',
1221
+ :a_path => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]', # [ ] is an open path
1222
+ :a_polygon => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))',
1223
+ :a_circle => '<(5.3, 10.4), 2>'
1224
+ )
1225
+
1226
+ assert g.save
1227
+
1228
+ # Reload and check that we have all the geometric attributes.
1229
+ h = Geometric.find(g.id)
1230
+
1231
+ assert_equal '(5,6.1)', h.a_point
1232
+ assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
1233
+ assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner
1234
+ assert_equal '[(2,3),(5.5,7),(8.5,11)]', h.a_path
1235
+ assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon
1236
+ assert_equal '<(5.3,10.4),2>', h.a_circle
1237
+
1238
+ # use a geometric function to test for an open path
1239
+ objs = Geometric.find_by_sql ["select isopen(a_path) from geometrics where id = ?", g.id]
1240
+ assert_equal objs[0].isopen, 't'
1241
+
1242
+ # test alternate formats when defining the geometric types
1243
+
1244
+ g = Geometric.new(
1245
+ :a_point => '5.0, 6.1',
1246
+ #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
1247
+ :a_line_segment => '((2.0, 3), (5.5, 7.0))',
1248
+ :a_box => '(2.0, 3), (5.5, 7.0)',
1249
+ :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', # ( ) is a closed path
1250
+ :a_polygon => '2.0, 3, 5.5, 7.0, 8.5, 11.0',
1251
+ :a_circle => '((5.3, 10.4), 2)'
1252
+ )
1253
+
1254
+ assert g.save
1255
+
1256
+ # Reload and check that we have all the geometric attributes.
1257
+ h = Geometric.find(g.id)
1258
+
1259
+ assert_equal '(5,6.1)', h.a_point
1260
+ assert_equal '[(2,3),(5.5,7)]', h.a_line_segment
1261
+ assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner
1262
+ assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_path
1263
+ assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon
1264
+ assert_equal '<(5.3,10.4),2>', h.a_circle
1265
+
1266
+ # use a geometric function to test for an closed path
1267
+ objs = Geometric.find_by_sql ["select isclosed(a_path) from geometrics where id = ?", g.id]
1268
+ assert_equal objs[0].isclosed, 't'
1269
+ end
1270
+ end
1271
+
1272
+ class NumericData < ActiveRecord::Base
1273
+ self.table_name = 'numeric_data'
1274
+ end
1275
+
1276
+ def test_numeric_fields
1277
+ m = NumericData.new(
1278
+ :bank_balance => 1586.43,
1279
+ :big_bank_balance => BigDecimal("1000234000567.95"),
1280
+ :world_population => 6000000000,
1281
+ :my_house_population => 3
1282
+ )
1283
+ assert m.save
1284
+
1285
+ m1 = NumericData.find(m.id)
1286
+ assert_not_nil m1
1287
+
1288
+ # As with migration_test.rb, we should make world_population >= 2**62
1289
+ # to cover 64-bit platforms and test it is a Bignum, but the main thing
1290
+ # is that it's an Integer.
1291
+ assert_kind_of Integer, m1.world_population
1292
+ assert_equal 6000000000, m1.world_population
1293
+
1294
+ assert_kind_of Fixnum, m1.my_house_population
1295
+ assert_equal 3, m1.my_house_population
1296
+
1297
+ assert_kind_of BigDecimal, m1.bank_balance
1298
+ assert_equal BigDecimal("1586.43"), m1.bank_balance
1299
+
1300
+ assert_kind_of BigDecimal, m1.big_bank_balance
1301
+ assert_equal BigDecimal("1000234000567.95"), m1.big_bank_balance
1302
+ end
1303
+
1304
+ def test_auto_id
1305
+ auto = AutoId.new
1306
+ auto.save
1307
+ assert (auto.id > 0)
1308
+ end
1309
+
1310
+ def quote_column_name(name)
1311
+ "<#{name}>"
1312
+ end
1313
+
1314
+ def test_quote_keys
1315
+ ar = AutoId.new
1316
+ source = {"foo" => "bar", "baz" => "quux"}
1317
+ actual = ar.send(:quote_columns, self, source)
1318
+ inverted = actual.invert
1319
+ assert_equal("<foo>", inverted["bar"])
1320
+ assert_equal("<baz>", inverted["quux"])
1321
+ end
1322
+
1323
+ def test_sql_injection_via_find
1324
+ assert_raises(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do
1325
+ Topic.find("123456 OR id > 0")
1326
+ end
1327
+ end
1328
+
1329
+ def test_column_name_properly_quoted
1330
+ col_record = ColumnName.new
1331
+ col_record.references = 40
1332
+ assert col_record.save
1333
+ col_record.references = 41
1334
+ assert col_record.save
1335
+ assert_not_nil c2 = ColumnName.find(col_record.id)
1336
+ assert_equal(41, c2.references)
1337
+ end
1338
+
1339
+ def test_quoting_arrays
1340
+ replies = Reply.find(:all, :conditions => [ "id IN (?)", topics(:first).replies.collect(&:id) ])
1341
+ assert_equal topics(:first).replies.size, replies.size
1342
+
1343
+ replies = Reply.find(:all, :conditions => [ "id IN (?)", [] ])
1344
+ assert_equal 0, replies.size
1345
+ end
1346
+
1347
+ MyObject = Struct.new :attribute1, :attribute2
1348
+
1349
+ def test_serialized_attribute
1350
+ myobj = MyObject.new('value1', 'value2')
1351
+ topic = Topic.create("content" => myobj)
1352
+ Topic.serialize("content", MyObject)
1353
+ assert_equal(myobj, topic.content)
1354
+ end
1355
+
1356
+ def test_serialized_time_attribute
1357
+ myobj = Time.local(2008,1,1,1,0)
1358
+ topic = Topic.create("content" => myobj).reload
1359
+ assert_equal(myobj, topic.content)
1360
+ end
1361
+
1362
+ def test_nil_serialized_attribute_with_class_constraint
1363
+ myobj = MyObject.new('value1', 'value2')
1364
+ topic = Topic.new
1365
+ assert_nil topic.content
1366
+ end
1367
+
1368
+ def test_should_raise_exception_on_serialized_attribute_with_type_mismatch
1369
+ myobj = MyObject.new('value1', 'value2')
1370
+ topic = Topic.new(:content => myobj)
1371
+ assert topic.save
1372
+ Topic.serialize(:content, Hash)
1373
+ assert_raise(ActiveRecord::SerializationTypeMismatch) { Topic.find(topic.id).content }
1374
+ ensure
1375
+ Topic.serialize(:content)
1376
+ end
1377
+
1378
+ def test_serialized_attribute_with_class_constraint
1379
+ settings = { "color" => "blue" }
1380
+ Topic.serialize(:content, Hash)
1381
+ topic = Topic.new(:content => settings)
1382
+ assert topic.save
1383
+ assert_equal(settings, Topic.find(topic.id).content)
1384
+ ensure
1385
+ Topic.serialize(:content)
1386
+ end
1387
+
1388
+ def test_quote
1389
+ author_name = "\\ \001 ' \n \\n \""
1390
+ topic = Topic.create('author_name' => author_name)
1391
+ assert_equal author_name, Topic.find(topic.id).author_name
1392
+ end
1393
+
1394
+ if RUBY_VERSION < '1.9'
1395
+ def test_quote_chars
1396
+ str = 'The Narrator'
1397
+ topic = Topic.create(:author_name => str)
1398
+ assert_equal str, topic.author_name
1399
+
1400
+ assert_kind_of ActiveSupport::Multibyte::Chars, str.chars
1401
+ topic = Topic.find_by_author_name(str.chars)
1402
+
1403
+ assert_kind_of Topic, topic
1404
+ assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars"
1405
+ end
1406
+ end
1407
+
1408
+ def test_class_level_destroy
1409
+ should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world")
1410
+ Topic.find(1).replies << should_be_destroyed_reply
1411
+
1412
+ Topic.destroy(1)
1413
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) }
1414
+ assert_raise(ActiveRecord::RecordNotFound) { Reply.find(should_be_destroyed_reply.id) }
1415
+ end
1416
+
1417
+ def test_class_level_delete
1418
+ should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world")
1419
+ Topic.find(1).replies << should_be_destroyed_reply
1420
+
1421
+ Topic.delete(1)
1422
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) }
1423
+ assert_nothing_raised { Reply.find(should_be_destroyed_reply.id) }
1424
+ end
1425
+
1426
+ def test_increment_attribute
1427
+ assert_equal 50, accounts(:signals37).credit_limit
1428
+ accounts(:signals37).increment! :credit_limit
1429
+ assert_equal 51, accounts(:signals37, :reload).credit_limit
1430
+
1431
+ accounts(:signals37).increment(:credit_limit).increment!(:credit_limit)
1432
+ assert_equal 53, accounts(:signals37, :reload).credit_limit
1433
+ end
1434
+
1435
+ def test_increment_nil_attribute
1436
+ assert_nil topics(:first).parent_id
1437
+ topics(:first).increment! :parent_id
1438
+ assert_equal 1, topics(:first).parent_id
1439
+ end
1440
+
1441
+ def test_increment_attribute_by
1442
+ assert_equal 50, accounts(:signals37).credit_limit
1443
+ accounts(:signals37).increment! :credit_limit, 5
1444
+ assert_equal 55, accounts(:signals37, :reload).credit_limit
1445
+
1446
+ accounts(:signals37).increment(:credit_limit, 1).increment!(:credit_limit, 3)
1447
+ assert_equal 59, accounts(:signals37, :reload).credit_limit
1448
+ end
1449
+
1450
+ def test_decrement_attribute
1451
+ assert_equal 50, accounts(:signals37).credit_limit
1452
+
1453
+ accounts(:signals37).decrement!(:credit_limit)
1454
+ assert_equal 49, accounts(:signals37, :reload).credit_limit
1455
+
1456
+ accounts(:signals37).decrement(:credit_limit).decrement!(:credit_limit)
1457
+ assert_equal 47, accounts(:signals37, :reload).credit_limit
1458
+ end
1459
+
1460
+ def test_decrement_attribute_by
1461
+ assert_equal 50, accounts(:signals37).credit_limit
1462
+ accounts(:signals37).decrement! :credit_limit, 5
1463
+ assert_equal 45, accounts(:signals37, :reload).credit_limit
1464
+
1465
+ accounts(:signals37).decrement(:credit_limit, 1).decrement!(:credit_limit, 3)
1466
+ assert_equal 41, accounts(:signals37, :reload).credit_limit
1467
+ end
1468
+
1469
+ def test_toggle_attribute
1470
+ assert !topics(:first).approved?
1471
+ topics(:first).toggle!(:approved)
1472
+ assert topics(:first).approved?
1473
+ topic = topics(:first)
1474
+ topic.toggle(:approved)
1475
+ assert !topic.approved?
1476
+ topic.reload
1477
+ assert topic.approved?
1478
+ end
1479
+
1480
+ def test_reload
1481
+ t1 = Topic.find(1)
1482
+ t2 = Topic.find(1)
1483
+ t1.title = "something else"
1484
+ t1.save
1485
+ t2.reload
1486
+ assert_equal t1.title, t2.title
1487
+ end
1488
+
1489
+ def test_define_attr_method_with_value
1490
+ k = Class.new( ActiveRecord::Base )
1491
+ k.send(:define_attr_method, :table_name, "foo")
1492
+ assert_equal "foo", k.table_name
1493
+ end
1494
+
1495
+ def test_define_attr_method_with_block
1496
+ k = Class.new( ActiveRecord::Base )
1497
+ k.send(:define_attr_method, :primary_key) { "sys_" + original_primary_key }
1498
+ assert_equal "sys_id", k.primary_key
1499
+ end
1500
+
1501
+ def test_set_table_name_with_value
1502
+ k = Class.new( ActiveRecord::Base )
1503
+ k.table_name = "foo"
1504
+ assert_equal "foo", k.table_name
1505
+ k.set_table_name "bar"
1506
+ assert_equal "bar", k.table_name
1507
+ end
1508
+
1509
+ def test_set_table_name_with_block
1510
+ k = Class.new( ActiveRecord::Base )
1511
+ k.set_table_name { "ks" }
1512
+ assert_equal "ks", k.table_name
1513
+ end
1514
+
1515
+ def test_set_primary_key_with_value
1516
+ k = Class.new( ActiveRecord::Base )
1517
+ k.primary_key = "foo"
1518
+ assert_equal "foo", k.primary_key
1519
+ k.set_primary_key "bar"
1520
+ assert_equal "bar", k.primary_key
1521
+ end
1522
+
1523
+ def test_set_primary_key_with_block
1524
+ k = Class.new( ActiveRecord::Base )
1525
+ k.set_primary_key { "sys_" + original_primary_key }
1526
+ assert_equal "sys_id", k.primary_key
1527
+ end
1528
+
1529
+ def test_set_inheritance_column_with_value
1530
+ k = Class.new( ActiveRecord::Base )
1531
+ k.inheritance_column = "foo"
1532
+ assert_equal "foo", k.inheritance_column
1533
+ k.set_inheritance_column "bar"
1534
+ assert_equal "bar", k.inheritance_column
1535
+ end
1536
+
1537
+ def test_set_inheritance_column_with_block
1538
+ k = Class.new( ActiveRecord::Base )
1539
+ k.set_inheritance_column { original_inheritance_column + "_id" }
1540
+ assert_equal "type_id", k.inheritance_column
1541
+ end
1542
+
1543
+ def test_count_with_join
1544
+ res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
1545
+
1546
+ res2 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", :joins => "LEFT JOIN comments ON posts.id=comments.post_id")
1547
+ assert_equal res, res2
1548
+
1549
+ res3 = nil
1550
+ assert_nothing_raised do
1551
+ res3 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'",
1552
+ :joins => "LEFT JOIN comments ON posts.id=comments.post_id")
1553
+ end
1554
+ assert_equal res, res3
1555
+
1556
+ res4 = Post.count_by_sql "SELECT COUNT(p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
1557
+ res5 = nil
1558
+ assert_nothing_raised do
1559
+ res5 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id",
1560
+ :joins => "p, comments co",
1561
+ :select => "p.id")
1562
+ end
1563
+
1564
+ assert_equal res4, res5
1565
+
1566
+ unless current_adapter?(:SQLite2Adapter, :DeprecatedSQLiteAdapter)
1567
+ res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
1568
+ res7 = nil
1569
+ assert_nothing_raised do
1570
+ res7 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id",
1571
+ :joins => "p, comments co",
1572
+ :select => "p.id",
1573
+ :distinct => true)
1574
+ end
1575
+ assert_equal res6, res7
1576
+ end
1577
+ end
1578
+
1579
+ def test_clear_association_cache_stored
1580
+ firm = Firm.find(1)
1581
+ assert_kind_of Firm, firm
1582
+
1583
+ firm.clear_association_cache
1584
+ assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort
1585
+ end
1586
+
1587
+ def test_clear_association_cache_new_record
1588
+ firm = Firm.new
1589
+ client_stored = Client.find(3)
1590
+ client_new = Client.new
1591
+ client_new.name = "The Joneses"
1592
+ clients = [ client_stored, client_new ]
1593
+
1594
+ firm.clients << clients
1595
+ assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set
1596
+
1597
+ firm.clear_association_cache
1598
+ assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set
1599
+ end
1600
+
1601
+ def test_interpolate_sql
1602
+ assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo@bar') }
1603
+ assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar) baz') }
1604
+ assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar} baz') }
1605
+ end
1606
+
1607
+ def test_scoped_find_conditions
1608
+ scoped_developers = Developer.with_scope(:find => { :conditions => 'salary > 90000' }) do
1609
+ Developer.find(:all, :conditions => 'id < 5')
1610
+ end
1611
+ assert !scoped_developers.include?(developers(:david)) # David's salary is less than 90,000
1612
+ assert_equal 3, scoped_developers.size
1613
+ end
1614
+
1615
+ def test_scoped_find_limit_offset
1616
+ scoped_developers = Developer.with_scope(:find => { :limit => 3, :offset => 2 }) do
1617
+ Developer.find(:all, :order => 'id')
1618
+ end
1619
+ assert !scoped_developers.include?(developers(:david))
1620
+ assert !scoped_developers.include?(developers(:jamis))
1621
+ assert_equal 3, scoped_developers.size
1622
+
1623
+ # Test without scoped find conditions to ensure we get the whole thing
1624
+ developers = Developer.find(:all, :order => 'id')
1625
+ assert_equal Developer.count, developers.size
1626
+ end
1627
+
1628
+ def test_scoped_find_order
1629
+ # Test order in scope
1630
+ scoped_developers = Developer.with_scope(:find => { :limit => 1, :order => 'salary DESC' }) do
1631
+ Developer.find(:all)
1632
+ end
1633
+ assert_equal 'Jamis', scoped_developers.first.name
1634
+ assert scoped_developers.include?(developers(:jamis))
1635
+ # Test scope without order and order in find
1636
+ scoped_developers = Developer.with_scope(:find => { :limit => 1 }) do
1637
+ Developer.find(:all, :order => 'salary DESC')
1638
+ end
1639
+ # Test scope order + find order, find has priority
1640
+ scoped_developers = Developer.with_scope(:find => { :limit => 3, :order => 'id DESC' }) do
1641
+ Developer.find(:all, :order => 'salary ASC')
1642
+ end
1643
+ assert scoped_developers.include?(developers(:poor_jamis))
1644
+ assert scoped_developers.include?(developers(:david))
1645
+ assert scoped_developers.include?(developers(:dev_10))
1646
+ # Test without scoped find conditions to ensure we get the right thing
1647
+ developers = Developer.find(:all, :order => 'id', :limit => 1)
1648
+ assert scoped_developers.include?(developers(:david))
1649
+ end
1650
+
1651
+ def test_scoped_find_limit_offset_including_has_many_association
1652
+ topics = Topic.with_scope(:find => {:limit => 1, :offset => 1, :include => :replies}) do
1653
+ Topic.find(:all, :order => "topics.id")
1654
+ end
1655
+ assert_equal 1, topics.size
1656
+ assert_equal 2, topics.first.id
1657
+ end
1658
+
1659
+ def test_scoped_find_order_including_has_many_association
1660
+ developers = Developer.with_scope(:find => { :order => 'developers.salary DESC', :include => :projects }) do
1661
+ Developer.find(:all)
1662
+ end
1663
+ assert developers.size >= 2
1664
+ for i in 1...developers.size
1665
+ assert developers[i-1].salary >= developers[i].salary
1666
+ end
1667
+ end
1668
+
1669
+ def test_find_last
1670
+ last = Developer.find :last
1671
+ assert_equal last, Developer.find(:first, :order => 'id desc')
1672
+ end
1673
+
1674
+ def test_last
1675
+ assert_equal Developer.find(:first, :order => 'id desc'), Developer.last
1676
+ end
1677
+
1678
+ def test_all_with_conditions
1679
+ assert_equal Developer.find(:all, :order => 'id desc'), Developer.all(:order => 'id desc')
1680
+ end
1681
+
1682
+ def test_find_ordered_last
1683
+ last = Developer.find :last, :order => 'developers.salary ASC'
1684
+ assert_equal last, Developer.find(:all, :order => 'developers.salary ASC').last
1685
+ end
1686
+
1687
+ def test_find_reverse_ordered_last
1688
+ last = Developer.find :last, :order => 'developers.salary DESC'
1689
+ assert_equal last, Developer.find(:all, :order => 'developers.salary DESC').last
1690
+ end
1691
+
1692
+ def test_find_multiple_ordered_last
1693
+ last = Developer.find :last, :order => 'developers.name, developers.salary DESC'
1694
+ assert_equal last, Developer.find(:all, :order => 'developers.name, developers.salary DESC').last
1695
+ end
1696
+
1697
+ def test_find_scoped_ordered_last
1698
+ last_developer = Developer.with_scope(:find => { :order => 'developers.salary ASC' }) do
1699
+ Developer.find(:last)
1700
+ end
1701
+ assert_equal last_developer, Developer.find(:all, :order => 'developers.salary ASC').last
1702
+ end
1703
+
1704
+ def test_abstract_class
1705
+ assert !ActiveRecord::Base.abstract_class?
1706
+ assert LoosePerson.abstract_class?
1707
+ assert !LooseDescendant.abstract_class?
1708
+ end
1709
+
1710
+ def test_base_class
1711
+ assert_equal LoosePerson, LoosePerson.base_class
1712
+ assert_equal LooseDescendant, LooseDescendant.base_class
1713
+ assert_equal TightPerson, TightPerson.base_class
1714
+ assert_equal TightPerson, TightDescendant.base_class
1715
+
1716
+ assert_equal Post, Post.base_class
1717
+ assert_equal Post, SpecialPost.base_class
1718
+ assert_equal Post, StiPost.base_class
1719
+ assert_equal SubStiPost, SubStiPost.base_class
1720
+ end
1721
+
1722
+ def test_descends_from_active_record
1723
+ # Tries to call Object.abstract_class?
1724
+ assert_raise(NoMethodError) do
1725
+ ActiveRecord::Base.descends_from_active_record?
1726
+ end
1727
+
1728
+ # Abstract subclass of AR::Base.
1729
+ assert LoosePerson.descends_from_active_record?
1730
+
1731
+ # Concrete subclass of an abstract class.
1732
+ assert LooseDescendant.descends_from_active_record?
1733
+
1734
+ # Concrete subclass of AR::Base.
1735
+ assert TightPerson.descends_from_active_record?
1736
+
1737
+ # Concrete subclass of a concrete class but has no type column.
1738
+ assert TightDescendant.descends_from_active_record?
1739
+
1740
+ # Concrete subclass of AR::Base.
1741
+ assert Post.descends_from_active_record?
1742
+
1743
+ # Abstract subclass of a concrete class which has a type column.
1744
+ # This is pathological, as you'll never have Sub < Abstract < Concrete.
1745
+ assert !StiPost.descends_from_active_record?
1746
+
1747
+ # Concrete subclasses an abstract class which has a type column.
1748
+ assert !SubStiPost.descends_from_active_record?
1749
+ end
1750
+
1751
+ def test_find_on_abstract_base_class_doesnt_use_type_condition
1752
+ old_class = LooseDescendant
1753
+ Object.send :remove_const, :LooseDescendant
1754
+
1755
+ descendant = old_class.create! :first_name => 'bob'
1756
+ assert_not_nil LoosePerson.find(descendant.id), "Should have found instance of LooseDescendant when finding abstract LoosePerson: #{descendant.inspect}"
1757
+ ensure
1758
+ unless Object.const_defined?(:LooseDescendant)
1759
+ Object.const_set :LooseDescendant, old_class
1760
+ end
1761
+ end
1762
+
1763
+ def test_assert_queries
1764
+ query = lambda { ActiveRecord::Base.connection.execute 'select count(*) from developers' }
1765
+ assert_queries(2) { 2.times { query.call } }
1766
+ assert_queries 1, &query
1767
+ assert_no_queries { assert true }
1768
+ end
1769
+
1770
+ def test_to_xml
1771
+ xml = REXML::Document.new(topics(:first).to_xml(:indent => 0))
1772
+ bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema
1773
+ written_on_in_current_timezone = topics(:first).written_on.xmlschema
1774
+ last_read_in_current_timezone = topics(:first).last_read.xmlschema
1775
+
1776
+ assert_equal "topic", xml.root.name
1777
+ assert_equal "The First Topic" , xml.elements["//title"].text
1778
+ assert_equal "David" , xml.elements["//author-name"].text
1779
+
1780
+ assert_equal "1", xml.elements["//id"].text
1781
+ assert_equal "integer" , xml.elements["//id"].attributes['type']
1782
+
1783
+ assert_equal "1", xml.elements["//replies-count"].text
1784
+ assert_equal "integer" , xml.elements["//replies-count"].attributes['type']
1785
+
1786
+ assert_equal written_on_in_current_timezone, xml.elements["//written-on"].text
1787
+ assert_equal "datetime" , xml.elements["//written-on"].attributes['type']
1788
+
1789
+ assert_equal "--- Have a nice day\n" , xml.elements["//content"].text
1790
+ assert_equal "yaml" , xml.elements["//content"].attributes['type']
1791
+
1792
+ assert_equal "david@loudthinking.com", xml.elements["//author-email-address"].text
1793
+
1794
+ assert_equal nil, xml.elements["//parent-id"].text
1795
+ assert_equal "integer", xml.elements["//parent-id"].attributes['type']
1796
+ assert_equal "true", xml.elements["//parent-id"].attributes['nil']
1797
+
1798
+ if current_adapter?(:SybaseAdapter, :SQLServerAdapter, :OracleAdapter)
1799
+ assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text
1800
+ assert_equal "datetime" , xml.elements["//last-read"].attributes['type']
1801
+ else
1802
+ assert_equal "2004-04-15", xml.elements["//last-read"].text
1803
+ assert_equal "date" , xml.elements["//last-read"].attributes['type']
1804
+ end
1805
+
1806
+ # Oracle and DB2 don't have true boolean or time-only fields
1807
+ unless current_adapter?(:OracleAdapter, :DB2Adapter)
1808
+ assert_equal "false", xml.elements["//approved"].text
1809
+ assert_equal "boolean" , xml.elements["//approved"].attributes['type']
1810
+
1811
+ assert_equal bonus_time_in_current_timezone, xml.elements["//bonus-time"].text
1812
+ assert_equal "datetime" , xml.elements["//bonus-time"].attributes['type']
1813
+ end
1814
+ end
1815
+
1816
+ def test_to_xml_skipping_attributes
1817
+ xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :replies_count])
1818
+ assert_equal "<topic>", xml.first(7)
1819
+ assert !xml.include?(%(<title>The First Topic</title>))
1820
+ assert xml.include?(%(<author-name>David</author-name>))
1821
+
1822
+ xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :author_name, :replies_count])
1823
+ assert !xml.include?(%(<title>The First Topic</title>))
1824
+ assert !xml.include?(%(<author-name>David</author-name>))
1825
+ end
1826
+
1827
+ def test_to_xml_including_has_many_association
1828
+ xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :include => :replies, :except => :replies_count)
1829
+ assert_equal "<topic>", xml.first(7)
1830
+ assert xml.include?(%(<replies type="array"><reply>))
1831
+ assert xml.include?(%(<title>The Second Topic of the day</title>))
1832
+ end
1833
+
1834
+ def test_array_to_xml_including_has_many_association
1835
+ xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :include => :replies)
1836
+ assert xml.include?(%(<replies type="array"><reply>))
1837
+ end
1838
+
1839
+ def test_array_to_xml_including_methods
1840
+ xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :methods => [ :topic_id ])
1841
+ assert xml.include?(%(<topic-id type="integer">#{topics(:first).topic_id}</topic-id>)), xml
1842
+ assert xml.include?(%(<topic-id type="integer">#{topics(:second).topic_id}</topic-id>)), xml
1843
+ end
1844
+
1845
+ def test_array_to_xml_including_has_one_association
1846
+ xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account)
1847
+ assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true))
1848
+ assert xml.include?(companies(:rails_core).account.to_xml(:indent => 0, :skip_instruct => true))
1849
+ end
1850
+
1851
+ def test_array_to_xml_including_belongs_to_association
1852
+ xml = [ companies(:first_client), companies(:second_client), companies(:another_client) ].to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
1853
+ assert xml.include?(companies(:first_client).to_xml(:indent => 0, :skip_instruct => true))
1854
+ assert xml.include?(companies(:second_client).firm.to_xml(:indent => 0, :skip_instruct => true))
1855
+ assert xml.include?(companies(:another_client).firm.to_xml(:indent => 0, :skip_instruct => true))
1856
+ end
1857
+
1858
+ def test_to_xml_including_belongs_to_association
1859
+ xml = companies(:first_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
1860
+ assert !xml.include?("<firm>")
1861
+
1862
+ xml = companies(:second_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
1863
+ assert xml.include?("<firm>")
1864
+ end
1865
+
1866
+ def test_to_xml_including_multiple_associations
1867
+ xml = companies(:first_firm).to_xml(:indent => 0, :skip_instruct => true, :include => [ :clients, :account ])
1868
+ assert_equal "<firm>", xml.first(6)
1869
+ assert xml.include?(%(<account>))
1870
+ assert xml.include?(%(<clients type="array"><client>))
1871
+ end
1872
+
1873
+ def test_to_xml_including_multiple_associations_with_options
1874
+ xml = companies(:first_firm).to_xml(
1875
+ :indent => 0, :skip_instruct => true,
1876
+ :include => { :clients => { :only => :name } }
1877
+ )
1878
+
1879
+ assert_equal "<firm>", xml.first(6)
1880
+ assert xml.include?(%(<client><name>Summit</name></client>))
1881
+ assert xml.include?(%(<clients type="array"><client>))
1882
+ end
1883
+
1884
+ def test_to_xml_including_methods
1885
+ xml = Company.new.to_xml(:methods => :arbitrary_method, :skip_instruct => true)
1886
+ assert_equal "<company>", xml.first(9)
1887
+ assert xml.include?(%(<arbitrary-method>I am Jack's profound disappointment</arbitrary-method>))
1888
+ end
1889
+
1890
+ def test_to_xml_with_block
1891
+ value = "Rockin' the block"
1892
+ xml = Company.new.to_xml(:skip_instruct => true) do |xml|
1893
+ xml.tag! "arbitrary-element", value
1894
+ end
1895
+ assert_equal "<company>", xml.first(9)
1896
+ assert xml.include?(%(<arbitrary-element>#{value}</arbitrary-element>))
1897
+ end
1898
+
1899
+ def test_type_name_with_module_should_handle_beginning
1900
+ assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person')
1901
+ assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person')
1902
+ end
1903
+
1904
+ def test_to_param_should_return_string
1905
+ assert_kind_of String, Client.find(:first).to_param
1906
+ end
1907
+
1908
+ def test_inspect_class
1909
+ assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect
1910
+ assert_equal 'LoosePerson(abstract)', LoosePerson.inspect
1911
+ assert_match(/^Topic\(id: integer, title: string/, Topic.inspect)
1912
+ end
1913
+
1914
+ def test_inspect_instance
1915
+ topic = topics(:first)
1916
+ assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", approved: false, replies_count: 1, parent_id: nil, type: nil>), topic.inspect
1917
+ end
1918
+
1919
+ def test_inspect_new_instance
1920
+ assert_match /Topic id: nil/, Topic.new.inspect
1921
+ end
1922
+
1923
+ def test_inspect_limited_select_instance
1924
+ assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect
1925
+ assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect
1926
+ end
1927
+
1928
+ def test_inspect_class_without_table
1929
+ assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect
1930
+ end
1931
+
1932
+ def test_attribute_for_inspect
1933
+ t = topics(:first)
1934
+ t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters"
1935
+
1936
+ assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on)
1937
+ assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title)
1938
+ end
1939
+
1940
+ def test_becomes
1941
+ assert_kind_of Reply, topics(:first).becomes(Reply)
1942
+ assert_equal "The First Topic", topics(:first).becomes(Reply).title
1943
+ end
1944
+
1945
+ def test_silence_sets_log_level_to_error_in_block
1946
+ original_logger = ActiveRecord::Base.logger
1947
+ log = StringIO.new
1948
+ ActiveRecord::Base.logger = Logger.new(log)
1949
+ ActiveRecord::Base.logger.level = Logger::DEBUG
1950
+ ActiveRecord::Base.silence do
1951
+ ActiveRecord::Base.logger.warn "warn"
1952
+ ActiveRecord::Base.logger.error "error"
1953
+ end
1954
+ assert_equal "error\n", log.string
1955
+ ensure
1956
+ ActiveRecord::Base.logger = original_logger
1957
+ end
1958
+
1959
+ def test_silence_sets_log_level_back_to_level_before_yield
1960
+ original_logger = ActiveRecord::Base.logger
1961
+ log = StringIO.new
1962
+ ActiveRecord::Base.logger = Logger.new(log)
1963
+ ActiveRecord::Base.logger.level = Logger::WARN
1964
+ ActiveRecord::Base.silence do
1965
+ end
1966
+ assert_equal Logger::WARN, ActiveRecord::Base.logger.level
1967
+ ensure
1968
+ ActiveRecord::Base.logger = original_logger
1969
+ end
1970
+
1971
+ def test_benchmark_with_log_level
1972
+ original_logger = ActiveRecord::Base.logger
1973
+ log = StringIO.new
1974
+ ActiveRecord::Base.logger = Logger.new(log)
1975
+ ActiveRecord::Base.logger.level = Logger::WARN
1976
+ ActiveRecord::Base.benchmark("Debug Topic Count", Logger::DEBUG) { Topic.count }
1977
+ ActiveRecord::Base.benchmark("Warn Topic Count", Logger::WARN) { Topic.count }
1978
+ ActiveRecord::Base.benchmark("Error Topic Count", Logger::ERROR) { Topic.count }
1979
+ assert_no_match /Debug Topic Count/, log.string
1980
+ assert_match /Warn Topic Count/, log.string
1981
+ assert_match /Error Topic Count/, log.string
1982
+ ensure
1983
+ ActiveRecord::Base.logger = original_logger
1984
+ end
1985
+
1986
+ def test_benchmark_with_use_silence
1987
+ original_logger = ActiveRecord::Base.logger
1988
+ log = StringIO.new
1989
+ ActiveRecord::Base.logger = Logger.new(log)
1990
+ ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, true) { ActiveRecord::Base.logger.debug "Loud" }
1991
+ ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, false) { ActiveRecord::Base.logger.debug "Quiet" }
1992
+ assert_no_match /Loud/, log.string
1993
+ assert_match /Quiet/, log.string
1994
+ ensure
1995
+ ActiveRecord::Base.logger = original_logger
1996
+ end
1997
+ end