muck-shares 0.1.8 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. data/.gitignore +2 -1
  2. data/README.rdoc +7 -6
  3. data/Rakefile +5 -13
  4. data/VERSION +1 -1
  5. data/app/controllers/muck/shares_controller.rb +0 -1
  6. data/app/models/country.rb +13 -0
  7. data/app/models/language.rb +15 -0
  8. data/app/models/state.rb +13 -0
  9. data/{locales → config/locales}/ar.yml +2 -2
  10. data/{locales → config/locales}/bg.yml +2 -2
  11. data/{locales → config/locales}/ca.yml +2 -2
  12. data/{locales → config/locales}/cs.yml +2 -2
  13. data/{locales → config/locales}/da.yml +2 -2
  14. data/{locales → config/locales}/de.yml +2 -2
  15. data/{locales → config/locales}/el.yml +2 -2
  16. data/{locales → config/locales}/en.yml +2 -2
  17. data/{locales → config/locales}/es.yml +2 -2
  18. data/{locales → config/locales}/et.yml +2 -2
  19. data/{locales → config/locales}/fa.yml +2 -2
  20. data/{locales → config/locales}/fi.yml +2 -2
  21. data/{locales → config/locales}/fr.yml +2 -2
  22. data/{locales → config/locales}/gl.yml +2 -2
  23. data/{locales → config/locales}/hi.yml +2 -2
  24. data/{locales → config/locales}/hr.yml +2 -2
  25. data/{locales → config/locales}/hu.yml +2 -2
  26. data/{locales → config/locales}/id.yml +2 -2
  27. data/{locales → config/locales}/it.yml +2 -2
  28. data/{locales → config/locales}/iw.yml +2 -2
  29. data/{locales → config/locales}/ja.yml +2 -2
  30. data/{locales → config/locales}/ko.yml +2 -2
  31. data/{locales → config/locales}/lt.yml +2 -2
  32. data/{locales → config/locales}/lv.yml +2 -2
  33. data/{locales → config/locales}/mt.yml +2 -2
  34. data/{locales → config/locales}/nl.yml +2 -2
  35. data/{locales → config/locales}/no.yml +2 -2
  36. data/{locales → config/locales}/pl.yml +2 -2
  37. data/{locales → config/locales}/pt-PT.yml +2 -2
  38. data/{locales → config/locales}/ro.yml +2 -2
  39. data/{locales → config/locales}/ru.yml +2 -2
  40. data/{locales → config/locales}/sk.yml +2 -2
  41. data/{locales → config/locales}/sl.yml +2 -2
  42. data/{locales → config/locales}/sq.yml +2 -2
  43. data/{locales → config/locales}/sr.yml +2 -2
  44. data/{locales → config/locales}/sv.yml +2 -2
  45. data/config/locales/th.yml +22 -0
  46. data/{locales → config/locales}/tl.yml +2 -2
  47. data/{locales → config/locales}/tr.yml +2 -2
  48. data/{locales → config/locales}/uk.yml +2 -2
  49. data/{locales → config/locales}/vi.yml +2 -2
  50. data/{locales → config/locales}/zh-CN.yml +2 -2
  51. data/{locales → config/locales}/zh-TW.yml +3 -3
  52. data/{locales → config/locales}/zh.yml +2 -2
  53. data/config/routes.rb +9 -0
  54. data/lib/muck_shares.rb +3 -4
  55. data/lib/muck_shares/engine.rb +18 -0
  56. data/lib/muck_shares/models/share.rb +37 -0
  57. data/lib/muck_shares/models/sharer.rb +11 -0
  58. data/lib/tasks/tasks.rb +12 -0
  59. data/test/rails_test/.gitignore +8 -0
  60. data/test/rails_test/.rake_tasks +103 -0
  61. data/test/rails_test/Gemfile +45 -0
  62. data/test/rails_test/Rakefile +10 -0
  63. data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +1 -1
  64. data/test/{rails_root → rails_test}/app/controllers/default_controller.rb +0 -0
  65. data/test/{rails_root → rails_test}/app/helpers/application_helper.rb +0 -0
  66. data/test/{rails_root → rails_test}/app/models/.keep +0 -0
  67. data/test/{rails_root → rails_test}/app/models/activity.rb +0 -0
  68. data/test/{rails_root → rails_test}/app/models/comment.rb +1 -1
  69. data/test/rails_test/app/models/profile.rb +3 -0
  70. data/test/{rails_root → rails_test}/app/models/share.rb +0 -0
  71. data/test/{rails_root → rails_test}/app/models/user.rb +5 -4
  72. data/test/{rails_root → rails_test}/app/models/user_session.rb +0 -0
  73. data/test/{rails_root → rails_test}/app/views/default/index.html.erb +0 -0
  74. data/test/{rails_root → rails_test}/app/views/layouts/default.html.erb +0 -0
  75. data/test/rails_test/config.ru +4 -0
  76. data/test/rails_test/config/application.rb +42 -0
  77. data/test/rails_test/config/boot.rb +13 -0
  78. data/test/rails_test/config/database.yml +16 -0
  79. data/test/rails_test/config/environment.rb +5 -0
  80. data/test/rails_test/config/environments/development.rb +26 -0
  81. data/test/rails_test/config/environments/production.rb +49 -0
  82. data/test/rails_test/config/environments/test.rb +35 -0
  83. data/test/rails_test/config/initializers/backtrace_silencers.rb +7 -0
  84. data/test/rails_test/config/initializers/geokit_config.rb +63 -0
  85. data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
  86. data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
  87. data/test/rails_test/config/initializers/muck.rb +60 -0
  88. data/test/rails_test/config/initializers/secret_token.rb +7 -0
  89. data/test/rails_test/config/initializers/session_store.rb +8 -0
  90. data/test/rails_test/config/routes.rb +4 -0
  91. data/test/{rails_root → rails_test}/features/shares.feature +0 -0
  92. data/test/{rails_root → rails_test}/features/step_definitions/common_steps.rb +0 -0
  93. data/test/{rails_root → rails_test}/features/step_definitions/share_steps.rb +0 -0
  94. data/test/rails_test/features/step_definitions/web_steps.rb +219 -0
  95. data/test/rails_test/features/support/custom_env.rb +19 -0
  96. data/test/rails_test/features/support/env.rb +58 -0
  97. data/test/rails_test/features/support/paths.rb +33 -0
  98. data/test/rails_test/lib/tasks/cucumber.rake +53 -0
  99. data/test/rails_test/spec/controllers/shares_controller_spec.rb +113 -0
  100. data/test/rails_test/spec/models/share_spec.rb +55 -0
  101. data/test/rails_test/spec/models/user_spec.rb +25 -0
  102. data/test/rails_test/spec/spec_helper.rb +29 -0
  103. data/test/rails_test/vendor/plugins/geokit-rails/.gitignore +2 -0
  104. data/test/rails_test/vendor/plugins/geokit-rails/CHANGELOG.rdoc +46 -0
  105. data/test/rails_test/vendor/plugins/geokit-rails/MIT-LICENSE +20 -0
  106. data/test/rails_test/vendor/plugins/geokit-rails/README.markdown +561 -0
  107. data/test/rails_test/vendor/plugins/geokit-rails/Rakefile +18 -0
  108. data/test/rails_test/vendor/plugins/geokit-rails/about.yml +9 -0
  109. data/test/rails_test/vendor/plugins/geokit-rails/assets/api_keys_template +61 -0
  110. data/test/rails_test/vendor/plugins/geokit-rails/init.rb +1 -0
  111. data/test/rails_test/vendor/plugins/geokit-rails/install.rb +14 -0
  112. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails.rb +26 -0
  113. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb +456 -0
  114. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/abstract.rb +31 -0
  115. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/mysql.rb +22 -0
  116. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/postgresql.rb +22 -0
  117. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/adapters/sqlserver.rb +43 -0
  118. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/defaults.rb +22 -0
  119. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/geocoder_control.rb +16 -0
  120. data/test/rails_test/vendor/plugins/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb +46 -0
  121. data/test/rails_test/vendor/plugins/geokit-rails/test/acts_as_mappable_test.rb +474 -0
  122. data/test/rails_test/vendor/plugins/geokit-rails/test/boot.rb +25 -0
  123. data/test/rails_test/vendor/plugins/geokit-rails/test/database.yml +20 -0
  124. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/companies.yml +7 -0
  125. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/custom_locations.yml +54 -0
  126. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/locations.yml +54 -0
  127. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_addresses.yml +17 -0
  128. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_families.yml +2 -0
  129. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_houses.yml +9 -0
  130. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_organizations.yml +5 -0
  131. data/test/rails_test/vendor/plugins/geokit-rails/test/fixtures/mock_people.yml +5 -0
  132. data/test/{rails_root/db/.keep → rails_test/vendor/plugins/geokit-rails/test/fixtures/stores.yml} +0 -0
  133. data/test/rails_test/vendor/plugins/geokit-rails/test/ip_geocode_lookup_test.rb +77 -0
  134. data/test/rails_test/vendor/plugins/geokit-rails/test/models/company.rb +3 -0
  135. data/test/rails_test/vendor/plugins/geokit-rails/test/models/custom_location.rb +12 -0
  136. data/test/rails_test/vendor/plugins/geokit-rails/test/models/location.rb +4 -0
  137. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_address.rb +4 -0
  138. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_family.rb +3 -0
  139. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_house.rb +3 -0
  140. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_organization.rb +4 -0
  141. data/test/rails_test/vendor/plugins/geokit-rails/test/models/mock_person.rb +4 -0
  142. data/test/rails_test/vendor/plugins/geokit-rails/test/models/store.rb +3 -0
  143. data/test/rails_test/vendor/plugins/geokit-rails/test/schema.rb +60 -0
  144. data/test/rails_test/vendor/plugins/geokit-rails/test/tasks.rake +31 -0
  145. data/test/rails_test/vendor/plugins/geokit-rails/test/test_helper.rb +23 -0
  146. metadata +246 -352
  147. data/config/muck_shares_routes.rb +0 -8
  148. data/install.rb +0 -1
  149. data/lib/active_record/acts/muck_share.rb +0 -59
  150. data/lib/active_record/acts/muck_sharer.rb +0 -28
  151. data/lib/muck_shares/initialize_routes.rb +0 -8
  152. data/lib/muck_shares/tasks.rb +0 -28
  153. data/locales/th.yml +0 -22
  154. data/muck-shares.gemspec +0 -401
  155. data/rails/init.rb +0 -4
  156. data/test/rails_root/Rakefile +0 -17
  157. data/test/rails_root/app/models/profile.rb +0 -3
  158. data/test/rails_root/config/amazon_s3.yml +0 -14
  159. data/test/rails_root/config/boot.rb +0 -109
  160. data/test/rails_root/config/database.yml +0 -23
  161. data/test/rails_root/config/environment.rb +0 -33
  162. data/test/rails_root/config/environments/cucumber.rb +0 -38
  163. data/test/rails_root/config/environments/development.rb +0 -19
  164. data/test/rails_root/config/environments/production.rb +0 -1
  165. data/test/rails_root/config/environments/test.rb +0 -28
  166. data/test/rails_root/config/initializers/requires.rb +0 -13
  167. data/test/rails_root/config/initializers/session_store.rb +0 -8
  168. data/test/rails_root/config/routes.rb +0 -3
  169. data/test/rails_root/db/migrate/20090320174818_create_muck_permissions_and_roles.rb +0 -16
  170. data/test/rails_root/db/migrate/20090402033319_add_muck_activities.rb +0 -36
  171. data/test/rails_root/db/migrate/20090402234137_create_languages.rb +0 -18
  172. data/test/rails_root/db/migrate/20090426041056_create_countries.rb +0 -15
  173. data/test/rails_root/db/migrate/20090426041103_create_states.rb +0 -18
  174. data/test/rails_root/db/migrate/20090512013727_create_profiles.rb +0 -21
  175. data/test/rails_root/db/migrate/20090602041838_create_users.rb +0 -39
  176. data/test/rails_root/db/migrate/20090608073052_create_friends.rb +0 -16
  177. data/test/rails_root/db/migrate/20090613173314_create_comments.rb +0 -24
  178. data/test/rails_root/db/migrate/20090704220055_create_slugs.rb +0 -18
  179. data/test/rails_root/db/migrate/20090704220120_acts_as_taggable_on_migration.rb +0 -29
  180. data/test/rails_root/db/migrate/20090730154102_allow_null_user.rb +0 -9
  181. data/test/rails_root/db/migrate/20090803185323_create_shares.rb +0 -16
  182. data/test/rails_root/db/migrate/20090804184247_add_comment_count_to_shares.rb +0 -9
  183. data/test/rails_root/db/migrate/20090804231857_add_shares_uri_index.rb +0 -9
  184. data/test/rails_root/features/step_definitions/webrat_steps.rb +0 -128
  185. data/test/rails_root/features/support/env.rb +0 -49
  186. data/test/rails_root/features/support/paths.rb +0 -33
  187. data/test/rails_root/lib/tasks/cucumber.rake +0 -20
  188. data/test/rails_root/public/.htaccess +0 -40
  189. data/test/rails_root/public/404.html +0 -30
  190. data/test/rails_root/public/422.html +0 -30
  191. data/test/rails_root/public/500.html +0 -30
  192. data/test/rails_root/public/dispatch.rb +0 -10
  193. data/test/rails_root/public/favicon.ico +0 -0
  194. data/test/rails_root/public/images/arrow_left.gif +0 -0
  195. data/test/rails_root/public/images/arrow_right.gif +0 -0
  196. data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
  197. data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
  198. data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
  199. data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
  200. data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
  201. data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
  202. data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
  203. data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
  204. data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
  205. data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
  206. data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
  207. data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
  208. data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
  209. data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
  210. data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
  211. data/test/rails_root/public/images/icons/accept.png +0 -0
  212. data/test/rails_root/public/images/icons/add.png +0 -0
  213. data/test/rails_root/public/images/icons/delete.png +0 -0
  214. data/test/rails_root/public/images/icons/vote.png +0 -0
  215. data/test/rails_root/public/images/loading.gif +0 -0
  216. data/test/rails_root/public/images/nothing.png +0 -0
  217. data/test/rails_root/public/images/profile_default.jpg +0 -0
  218. data/test/rails_root/public/images/rails.png +0 -0
  219. data/test/rails_root/public/images/spinner.gif +0 -0
  220. data/test/rails_root/public/images/sprites.png +0 -0
  221. data/test/rails_root/public/javascripts/application.js +0 -2
  222. data/test/rails_root/public/javascripts/builder.js +0 -136
  223. data/test/rails_root/public/javascripts/controls.js +0 -963
  224. data/test/rails_root/public/javascripts/dragdrop.js +0 -972
  225. data/test/rails_root/public/javascripts/effects.js +0 -1120
  226. data/test/rails_root/public/javascripts/fancyzoom.min.js +0 -1
  227. data/test/rails_root/public/javascripts/jquery/jquery-ui.js +0 -273
  228. data/test/rails_root/public/javascripts/jquery/jquery.easing.js +0 -1
  229. data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +0 -9
  230. data/test/rails_root/public/javascripts/jquery/jquery.form.js +0 -637
  231. data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +0 -2
  232. data/test/rails_root/public/javascripts/jquery/jquery.js +0 -19
  233. data/test/rails_root/public/javascripts/jquery/jquery.tips.js +0 -69
  234. data/test/rails_root/public/javascripts/muck.js +0 -80
  235. data/test/rails_root/public/javascripts/muck_activities.js +0 -108
  236. data/test/rails_root/public/javascripts/prototype.js +0 -4225
  237. data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
  238. data/test/rails_root/public/javascripts/slider.js +0 -277
  239. data/test/rails_root/public/javascripts/sound.js +0 -60
  240. data/test/rails_root/public/robots.txt +0 -1
  241. data/test/rails_root/public/stylesheets/.keep +0 -0
  242. data/test/rails_root/public/stylesheets/admin.css +0 -12
  243. data/test/rails_root/public/stylesheets/blueprint/ie.css +0 -26
  244. data/test/rails_root/public/stylesheets/blueprint/liquid_screen.css +0 -203
  245. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  246. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  247. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  248. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/readme.txt +0 -32
  249. data/test/rails_root/public/stylesheets/blueprint/plugins/buttons/screen.css +0 -97
  250. data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +0 -14
  251. data/test/rails_root/public/stylesheets/blueprint/plugins/fancy-type/screen.css +0 -71
  252. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  253. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  254. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  255. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  256. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  257. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  258. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  259. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  260. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/readme.txt +0 -18
  261. data/test/rails_root/public/stylesheets/blueprint/plugins/link-icons/screen.css +0 -40
  262. data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/liquid.css +0 -134
  263. data/test/rails_root/public/stylesheets/blueprint/plugins/liquid/src/liquid.css +0 -197
  264. data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/readme.txt +0 -10
  265. data/test/rails_root/public/stylesheets/blueprint/plugins/rtl/screen.css +0 -109
  266. data/test/rails_root/public/stylesheets/blueprint/print.css +0 -30
  267. data/test/rails_root/public/stylesheets/blueprint/screen.css +0 -251
  268. data/test/rails_root/public/stylesheets/blueprint/sprite.css +0 -1
  269. data/test/rails_root/public/stylesheets/blueprint/src/forms.css +0 -49
  270. data/test/rails_root/public/stylesheets/blueprint/src/grid.css +0 -213
  271. data/test/rails_root/public/stylesheets/blueprint/src/grid.png +0 -0
  272. data/test/rails_root/public/stylesheets/blueprint/src/ie.css +0 -59
  273. data/test/rails_root/public/stylesheets/blueprint/src/print.css +0 -85
  274. data/test/rails_root/public/stylesheets/blueprint/src/reset.css +0 -38
  275. data/test/rails_root/public/stylesheets/blueprint/src/typography.css +0 -105
  276. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
  277. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
  278. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_100_f0f0f0_1x400.png +0 -0
  279. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_50_99c2ff_1x400.png +0 -0
  280. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
  281. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_80_e6e6e6_1x400.png +0 -0
  282. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  283. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png +0 -0
  284. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-soft_100_e7eef3_1x100.png +0 -0
  285. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_222222_256x240.png +0 -0
  286. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  287. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  288. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  289. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_888888_256x240.png +0 -0
  290. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_cd0a0a_256x240.png +0 -0
  291. data/test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  292. data/test/rails_root/public/stylesheets/jquery/cupertino/jquery-ui-1.7.1.custom.css +0 -404
  293. data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +0 -44
  294. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  295. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  296. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  297. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  298. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  299. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  300. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  301. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  302. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_217bc0_256x240.png +0 -0
  303. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
  304. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_469bdd_256x240.png +0 -0
  305. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
  306. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
  307. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
  308. data/test/rails_root/public/stylesheets/jquery/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
  309. data/test/rails_root/public/stylesheets/jquery/redmond/jquery-ui-1.7.1.custom.css +0 -404
  310. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  311. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  312. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  313. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  314. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  315. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  316. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  317. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  318. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_222222_256x240.png +0 -0
  319. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  320. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_454545_256x240.png +0 -0
  321. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_888888_256x240.png +0 -0
  322. data/test/rails_root/public/stylesheets/jquery/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  323. data/test/rails_root/public/stylesheets/jquery/smoothness/jquery-ui-1.7.1.custom.css +0 -404
  324. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  325. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  326. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  327. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  328. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  329. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  330. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  331. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  332. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  333. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  334. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  335. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  336. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  337. data/test/rails_root/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  338. data/test/rails_root/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css +0 -404
  339. data/test/rails_root/public/stylesheets/reset.css +0 -0
  340. data/test/rails_root/public/stylesheets/styles.css +0 -89
  341. data/test/rails_root/public/stylesheets/themes/blue/styles.css +0 -1
  342. data/test/rails_root/public/stylesheets/themes/red/styles.css +0 -1
  343. data/test/rails_root/script/about +0 -3
  344. data/test/rails_root/script/breakpointer +0 -3
  345. data/test/rails_root/script/console +0 -3
  346. data/test/rails_root/script/create_project.rb +0 -52
  347. data/test/rails_root/script/cucumber +0 -8
  348. data/test/rails_root/script/dbconsole +0 -3
  349. data/test/rails_root/script/destroy +0 -3
  350. data/test/rails_root/script/generate +0 -3
  351. data/test/rails_root/script/performance/benchmarker +0 -3
  352. data/test/rails_root/script/performance/profiler +0 -3
  353. data/test/rails_root/script/performance/request +0 -3
  354. data/test/rails_root/script/plugin +0 -3
  355. data/test/rails_root/script/process/inspector +0 -3
  356. data/test/rails_root/script/process/reaper +0 -3
  357. data/test/rails_root/script/process/spawner +0 -3
  358. data/test/rails_root/script/runner +0 -3
  359. data/test/rails_root/script/server +0 -3
  360. data/test/rails_root/test/functional/.keep +0 -0
  361. data/test/rails_root/test/functional/shares_controller_test.rb +0 -119
  362. data/test/rails_root/test/test_helper.rb +0 -11
  363. data/test/rails_root/test/unit/.keep +0 -0
  364. data/test/rails_root/test/unit/share_test.rb +0 -59
  365. data/test/rails_root/test/unit/user_test.rb +0 -26
  366. data/test/rails_root/vendor/plugins/ssl_requirement/README +0 -43
  367. data/test/rails_root/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb +0 -62
  368. data/test/rails_root/vendor/plugins/ssl_requirement/test/ssl_requirement_test.rb +0 -132
  369. data/uninstall.rb +0 -1
@@ -0,0 +1,31 @@
1
+ module Geokit
2
+ module Adapters
3
+ class Abstract
4
+ class NotImplementedError < StandardError ; end
5
+
6
+ cattr_accessor :loaded
7
+
8
+ class << self
9
+ def load(klass) ; end
10
+ end
11
+
12
+ def initialize(klass)
13
+ @owner = klass
14
+ end
15
+
16
+ def method_missing(method, *args, &block)
17
+ return @owner.send(method, *args, &block) if @owner.respond_to?(method)
18
+ super
19
+ end
20
+
21
+ def sphere_distance_sql(lat, lng, multiplier)
22
+ raise NotImplementedError, '#sphere_distance_sql is not implemented'
23
+ end
24
+
25
+ def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
26
+ raise NotImplementedError, '#flat_distance_sql is not implemented'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ module Geokit
2
+ module Adapters
3
+ class MySQL < Abstract
4
+
5
+ def sphere_distance_sql(lat, lng, multiplier)
6
+ %|
7
+ (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
8
+ COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
9
+ SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
10
+ |
11
+ end
12
+
13
+ def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
14
+ %|
15
+ SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
16
+ POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
17
+ |
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Geokit
2
+ module Adapters
3
+ class PostgreSQL < Abstract
4
+
5
+ def sphere_distance_sql(lat, lng, multiplier)
6
+ %|
7
+ (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
8
+ COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
9
+ SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
10
+ |
11
+ end
12
+
13
+ def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
14
+ %|
15
+ SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
16
+ POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
17
+ |
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ module Geokit
2
+ module Adapters
3
+ class SQLServer < Abstract
4
+
5
+ class << self
6
+
7
+ def load(klass)
8
+ klass.connection.execute <<-EOS
9
+ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[geokit_least]') and xtype in (N'FN', N'IF', N'TF'))
10
+ drop function [dbo].[geokit_least]
11
+ EOS
12
+
13
+ klass.connection.execute <<-EOS
14
+ CREATE FUNCTION [dbo].geokit_least (@value1 float,@value2 float) RETURNS float AS BEGIN
15
+ return (SELECT CASE WHEN @value1 < @value2 THEN @value1 ELSE @value2 END) END
16
+ EOS
17
+ self.loaded = true
18
+ end
19
+
20
+ end
21
+
22
+ def initialize(*args)
23
+ super(*args)
24
+ end
25
+
26
+ def sphere_distance_sql(lat, lng, multiplier)
27
+ %|
28
+ (ACOS([dbo].geokit_least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
29
+ COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
30
+ SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
31
+ |
32
+ end
33
+
34
+ def flat_distance_sql(origin, lat_degree_units, lng_degree_units)
35
+ %|
36
+ SQRT(POWER(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
37
+ POWER(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
38
+ |
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ module Geokit
2
+ # These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
3
+ @@default_units = :miles
4
+ @@default_formula = :sphere
5
+
6
+ [:default_units, :default_formula].each do |sym|
7
+ class_eval <<-EOS, __FILE__, __LINE__
8
+ def self.#{sym}
9
+ if defined?(#{sym.to_s.upcase})
10
+ #{sym.to_s.upcase}
11
+ else
12
+ @@#{sym}
13
+ end
14
+ end
15
+
16
+ def self.#{sym}=(obj)
17
+ @@#{sym} = obj
18
+ end
19
+ EOS
20
+ end
21
+ Geokit::Geocoders.logger = ActiveRecord::Base.logger
22
+ end
@@ -0,0 +1,16 @@
1
+ module Geokit
2
+ module GeocoderControl
3
+ def set_geokit_domain
4
+ Geokit::Geocoders::domain = request.domain
5
+ logger.debug("Geokit is using the domain: #{Geokit::Geocoders::domain}")
6
+ end
7
+
8
+ def self.included(base)
9
+ if base.respond_to? :before_filter
10
+ base.send :before_filter, :set_geokit_domain
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ ActionController::Base.send(:include, Geokit::GeocoderControl) if defined?(ActionController::Base)
@@ -0,0 +1,46 @@
1
+ require 'yaml'
2
+
3
+ module Geokit
4
+ # Contains a class method geocode_ip_address which can be used to enable automatic geocoding
5
+ # for request IP addresses. The geocoded information is stored in a cookie and in the
6
+ # session to minimize web service calls. The point of the helper is to enable location-based
7
+ # websites to have a best-guess for new visitors.
8
+ module IpGeocodeLookup
9
+ # Mix below class methods into ActionController.
10
+ def self.included(base) # :nodoc:
11
+ base.extend ClassMethods
12
+ end
13
+
14
+ # Class method to mix into active record.
15
+ module ClassMethods # :nodoc:
16
+ def geocode_ip_address(filter_options = {})
17
+ before_filter :store_ip_location, filter_options
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ # Places the IP address' geocode location into the session if it
24
+ # can be found. Otherwise, looks for a geo location cookie and
25
+ # uses that value. The last resort is to call the web service to
26
+ # get the value.
27
+ def store_ip_location
28
+ session[:geo_location] ||= retrieve_location_from_cookie_or_service
29
+ cookies[:geo_location] = { :value => session[:geo_location].to_yaml, :expires => 30.days.from_now } if session[:geo_location]
30
+ end
31
+
32
+ # Uses the stored location value from the cookie if it exists. If
33
+ # no cookie exists, calls out to the web service to get the location.
34
+ def retrieve_location_from_cookie_or_service
35
+ return YAML.load(cookies[:geo_location]) if cookies[:geo_location]
36
+ location = Geocoders::MultiGeocoder.geocode(get_ip_address)
37
+ return location.success ? location : nil
38
+ end
39
+
40
+ # Returns the real ip address, though this could be the localhost ip
41
+ # address. No special handling here anymore.
42
+ def get_ip_address
43
+ request.remote_ip
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,474 @@
1
+ require 'test_helper'
2
+
3
+
4
+ Geokit::Geocoders::provider_order = [:google, :us]
5
+
6
+ class ActsAsMappableTest < GeokitTestCase
7
+
8
+ LOCATION_A_IP = "217.10.83.5"
9
+
10
+ def setup
11
+ @location_a = GeoKit::GeoLoc.new
12
+ @location_a.lat = 32.918593
13
+ @location_a.lng = -96.958444
14
+ @location_a.city = "Irving"
15
+ @location_a.state = "TX"
16
+ @location_a.country_code = "US"
17
+ @location_a.success = true
18
+
19
+ @sw = GeoKit::LatLng.new(32.91663,-96.982841)
20
+ @ne = GeoKit::LatLng.new(32.96302,-96.919495)
21
+ @bounds_center=GeoKit::LatLng.new((@sw.lat+@ne.lat)/2,(@sw.lng+@ne.lng)/2)
22
+
23
+ @starbucks = companies(:starbucks)
24
+ @loc_a = locations(:a)
25
+ @custom_loc_a = custom_locations(:a)
26
+ @loc_e = locations(:e)
27
+ @custom_loc_e = custom_locations(:e)
28
+
29
+ @barnes_and_noble = mock_organizations(:barnes_and_noble)
30
+ @address = mock_addresses(:address_barnes_and_noble)
31
+ end
32
+
33
+ def test_override_default_units_the_hard_way
34
+ Location.default_units = :kms
35
+ locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
36
+ assert_equal 5, locations.size
37
+ locations = Location.count(:origin => @loc_a, :conditions => "distance < 3.97")
38
+ assert_equal 5, locations
39
+ Location.default_units = :miles
40
+ end
41
+
42
+ def test_include
43
+ locations = Location.find(:all, :origin => @loc_a, :include => :company, :conditions => "company_id = 1")
44
+ assert !locations.empty?
45
+ assert_equal 1, locations[0].company.id
46
+ assert_equal 'Starbucks', locations[0].company.name
47
+ end
48
+
49
+ def test_distance_between_geocoded
50
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
51
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("San Francisco, CA").returns(@location_a)
52
+ assert_equal 0, Location.distance_between("Irving, TX", "San Francisco, CA")
53
+ end
54
+
55
+ def test_distance_to_geocoded
56
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
57
+ assert_equal 0, @custom_loc_a.distance_to("Irving, TX")
58
+ end
59
+
60
+ def test_distance_to_geocoded_error
61
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(GeoKit::GeoLoc.new)
62
+ assert_raise(GeoKit::Geocoders::GeocodeError) { @custom_loc_a.distance_to("Irving, TX") }
63
+ end
64
+
65
+ def test_custom_attributes_distance_calculations
66
+ assert_equal 0, @custom_loc_a.distance_to(@loc_a)
67
+ assert_equal 0, CustomLocation.distance_between(@custom_loc_a, @loc_a)
68
+ end
69
+
70
+ def test_distance_column_in_select
71
+ locations = Location.find(:all, :origin => @loc_a, :order => "distance ASC")
72
+ assert_equal 6, locations.size
73
+ assert_equal 0, @loc_a.distance_to(locations.first)
74
+ assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
75
+ end
76
+
77
+ def test_find_with_distance_condition
78
+ locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
79
+ assert_equal 5, locations.size
80
+ locations = Location.count(:origin => @loc_a, :conditions => "distance < 3.97")
81
+ assert_equal 5, locations
82
+ end
83
+
84
+ def test_find_with_distance_condition_with_units_override
85
+ locations = Location.find(:all, :origin => @loc_a, :units => :kms, :conditions => "distance < 6.387")
86
+ assert_equal 5, locations.size
87
+ locations = Location.count(:origin => @loc_a, :units => :kms, :conditions => "distance < 6.387")
88
+ assert_equal 5, locations
89
+ end
90
+
91
+ def test_find_with_distance_condition_with_formula_override
92
+ locations = Location.find(:all, :origin => @loc_a, :formula => :flat, :conditions => "distance < 6.387")
93
+ assert_equal 6, locations.size
94
+ locations = Location.count(:origin => @loc_a, :formula => :flat, :conditions => "distance < 6.387")
95
+ assert_equal 6, locations
96
+ end
97
+
98
+ def test_find_within
99
+ locations = Location.find_within(3.97, :origin => @loc_a)
100
+ assert_equal 5, locations.size
101
+ locations = Location.count_within(3.97, :origin => @loc_a)
102
+ assert_equal 5, locations
103
+ end
104
+
105
+ def test_find_within_with_token
106
+ locations = Location.find(:all, :within => 3.97, :origin => @loc_a)
107
+ assert_equal 5, locations.size
108
+ locations = Location.count(:within => 3.97, :origin => @loc_a)
109
+ assert_equal 5, locations
110
+ end
111
+
112
+ def test_find_within_with_coordinates
113
+ locations = Location.find_within(3.97, :origin =>[@loc_a.lat,@loc_a.lng])
114
+ assert_equal 5, locations.size
115
+ locations = Location.count_within(3.97, :origin =>[@loc_a.lat,@loc_a.lng])
116
+ assert_equal 5, locations
117
+ end
118
+
119
+ def test_find_with_compound_condition
120
+ locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
121
+ assert_equal 2, locations.size
122
+ locations = Location.count(:origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
123
+ assert_equal 2, locations
124
+ end
125
+
126
+ def test_find_with_secure_compound_condition
127
+ locations = Location.find(:all, :origin => @loc_a, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
128
+ assert_equal 2, locations.size
129
+ locations = Location.count(:origin => @loc_a, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
130
+ assert_equal 2, locations
131
+ end
132
+
133
+ def test_find_beyond
134
+ locations = Location.find_beyond(3.95, :origin => @loc_a)
135
+ assert_equal 1, locations.size
136
+ locations = Location.count_beyond(3.95, :origin => @loc_a)
137
+ assert_equal 1, locations
138
+ end
139
+
140
+ def test_find_beyond_with_token
141
+ locations = Location.find(:all, :beyond => 3.95, :origin => @loc_a)
142
+ assert_equal 1, locations.size
143
+ locations = Location.count(:beyond => 3.95, :origin => @loc_a)
144
+ assert_equal 1, locations
145
+ end
146
+
147
+ def test_find_beyond_with_coordinates
148
+ locations = Location.find_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
149
+ assert_equal 1, locations.size
150
+ locations = Location.count_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
151
+ assert_equal 1, locations
152
+ end
153
+
154
+ def test_find_range_with_token
155
+ locations = Location.find(:all, :range => 0..10, :origin => @loc_a)
156
+ assert_equal 6, locations.size
157
+ locations = Location.count(:range => 0..10, :origin => @loc_a)
158
+ assert_equal 6, locations
159
+ end
160
+
161
+ def test_find_range_with_token_with_conditions
162
+ locations = Location.find(:all, :origin => @loc_a, :range => 0..10, :conditions => ["city = ?", 'Coppell'])
163
+ assert_equal 2, locations.size
164
+ locations = Location.count(:origin => @loc_a, :range => 0..10, :conditions => ["city = ?", 'Coppell'])
165
+ assert_equal 2, locations
166
+ end
167
+
168
+ def test_find_range_with_token_with_hash_conditions
169
+ locations = Location.find(:all, :origin => @loc_a, :range => 0..10, :conditions => {:city => 'Coppell'})
170
+ assert_equal 2, locations.size
171
+ locations = Location.count(:origin => @loc_a, :range => 0..10, :conditions => {:city => 'Coppell'})
172
+ assert_equal 2, locations
173
+ end
174
+
175
+ def test_find_range_with_token_excluding_end
176
+ locations = Location.find(:all, :range => 0...10, :origin => @loc_a)
177
+ assert_equal 6, locations.size
178
+ locations = Location.count(:range => 0...10, :origin => @loc_a)
179
+ assert_equal 6, locations
180
+ end
181
+
182
+ def test_find_nearest
183
+ assert_equal @loc_a, Location.find_nearest(:origin => @loc_a)
184
+ end
185
+
186
+ def test_find_nearest_through_find
187
+ assert_equal @loc_a, Location.find(:nearest, :origin => @loc_a)
188
+ end
189
+
190
+ def test_find_nearest_with_coordinates
191
+ assert_equal @loc_a, Location.find_nearest(:origin =>[@loc_a.lat, @loc_a.lng])
192
+ end
193
+
194
+ def test_find_farthest
195
+ assert_equal @loc_e, Location.find_farthest(:origin => @loc_a)
196
+ end
197
+
198
+ def test_find_farthest_through_find
199
+ assert_equal @loc_e, Location.find(:farthest, :origin => @loc_a)
200
+ end
201
+
202
+ def test_find_farthest_with_coordinates
203
+ assert_equal @loc_e, Location.find_farthest(:origin =>[@loc_a.lat, @loc_a.lng])
204
+ end
205
+
206
+ def test_scoped_distance_column_in_select
207
+ locations = @starbucks.locations.find(:all, :origin => @loc_a, :order => "distance ASC")
208
+ assert_equal 5, locations.size
209
+ assert_equal 0, @loc_a.distance_to(locations.first)
210
+ assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
211
+ end
212
+
213
+ def test_scoped_find_with_distance_condition
214
+ locations = @starbucks.locations.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
215
+ assert_equal 4, locations.size
216
+ locations = @starbucks.locations.count(:origin => @loc_a, :conditions => "distance < 3.97")
217
+ assert_equal 4, locations
218
+ end
219
+
220
+ def test_scoped_find_within
221
+ locations = @starbucks.locations.find_within(3.97, :origin => @loc_a)
222
+ assert_equal 4, locations.size
223
+ locations = @starbucks.locations.count_within(3.97, :origin => @loc_a)
224
+ assert_equal 4, locations
225
+ end
226
+
227
+ def test_scoped_find_with_compound_condition
228
+ locations = @starbucks.locations.find(:all, :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
229
+ assert_equal 2, locations.size
230
+ locations = @starbucks.locations.count( :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
231
+ assert_equal 2, locations
232
+ end
233
+
234
+ def test_scoped_find_beyond
235
+ locations = @starbucks.locations.find_beyond(3.95, :origin => @loc_a)
236
+ assert_equal 1, locations.size
237
+ locations = @starbucks.locations.count_beyond(3.95, :origin => @loc_a)
238
+ assert_equal 1, locations
239
+ end
240
+
241
+ def test_scoped_find_nearest
242
+ assert_equal @loc_a, @starbucks.locations.find_nearest(:origin => @loc_a)
243
+ end
244
+
245
+ def test_scoped_find_farthest
246
+ assert_equal @loc_e, @starbucks.locations.find_farthest(:origin => @loc_a)
247
+ end
248
+
249
+ def test_ip_geocoded_distance_column_in_select
250
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
251
+ locations = Location.find(:all, :origin => LOCATION_A_IP, :order => "distance ASC")
252
+ assert_equal 6, locations.size
253
+ assert_equal 0, @loc_a.distance_to(locations.first)
254
+ assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
255
+ end
256
+
257
+ def test_ip_geocoded_find_with_distance_condition
258
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
259
+ locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => "distance < 3.97")
260
+ assert_equal 5, locations.size
261
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
262
+ locations = Location.count(:origin => LOCATION_A_IP, :conditions => "distance < 3.97")
263
+ assert_equal 5, locations
264
+ end
265
+
266
+ def test_ip_geocoded_find_within
267
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
268
+ locations = Location.find_within(3.97, :origin => LOCATION_A_IP)
269
+ assert_equal 5, locations.size
270
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
271
+ locations = Location.count_within(3.97, :origin => LOCATION_A_IP)
272
+ assert_equal 5, locations
273
+ end
274
+
275
+ def test_ip_geocoded_find_with_compound_condition
276
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
277
+ locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => "distance < 5 and city = 'Coppell'")
278
+ assert_equal 2, locations.size
279
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
280
+ locations = Location.count(:origin => LOCATION_A_IP, :conditions => "distance < 5 and city = 'Coppell'")
281
+ assert_equal 2, locations
282
+ end
283
+
284
+ def test_ip_geocoded_find_with_secure_compound_condition
285
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
286
+ locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
287
+ assert_equal 2, locations.size
288
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
289
+ locations = Location.count(:origin => LOCATION_A_IP, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
290
+ assert_equal 2, locations
291
+ end
292
+
293
+ def test_ip_geocoded_find_beyond
294
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
295
+ locations = Location.find_beyond(3.95, :origin => LOCATION_A_IP)
296
+ assert_equal 1, locations.size
297
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
298
+ locations = Location.count_beyond(3.95, :origin => LOCATION_A_IP)
299
+ assert_equal 1, locations
300
+ end
301
+
302
+ def test_ip_geocoded_find_nearest
303
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
304
+ assert_equal @loc_a, Location.find_nearest(:origin => LOCATION_A_IP)
305
+ end
306
+
307
+ def test_ip_geocoded_find_farthest
308
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
309
+ assert_equal @loc_e, Location.find_farthest(:origin => LOCATION_A_IP)
310
+ end
311
+
312
+ def test_ip_geocoder_exception
313
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with('127.0.0.1').returns(GeoKit::GeoLoc.new)
314
+ assert_raises GeoKit::Geocoders::GeocodeError do
315
+ Location.find_farthest(:origin => '127.0.0.1')
316
+ end
317
+ end
318
+
319
+ def test_address_geocode
320
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with('Irving, TX').returns(@location_a)
321
+ locations = Location.find(:all, :origin => 'Irving, TX', :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
322
+ assert_equal 2, locations.size
323
+ end
324
+
325
+ def test_find_with_custom_distance_condition
326
+ locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => "dist < 3.97")
327
+ assert_equal 5, locations.size
328
+ locations = CustomLocation.count(:origin => @loc_a, :conditions => "dist < 3.97")
329
+ assert_equal 5, locations
330
+ end
331
+
332
+ def test_find_with_custom_distance_condition_using_custom_origin
333
+ locations = CustomLocation.find(:all, :origin => @custom_loc_a, :conditions => "dist < 3.97")
334
+ assert_equal 5, locations.size
335
+ locations = CustomLocation.count(:origin => @custom_loc_a, :conditions => "dist < 3.97")
336
+ assert_equal 5, locations
337
+ end
338
+
339
+ def test_find_within_with_custom
340
+ locations = CustomLocation.find_within(3.97, :origin => @loc_a)
341
+ assert_equal 5, locations.size
342
+ locations = CustomLocation.count_within(3.97, :origin => @loc_a)
343
+ assert_equal 5, locations
344
+ end
345
+
346
+ def test_find_within_with_coordinates_with_custom
347
+ locations = CustomLocation.find_within(3.97, :origin =>[@loc_a.lat, @loc_a.lng])
348
+ assert_equal 5, locations.size
349
+ locations = CustomLocation.count_within(3.97, :origin =>[@loc_a.lat, @loc_a.lng])
350
+ assert_equal 5, locations
351
+ end
352
+
353
+ def test_find_with_compound_condition_with_custom
354
+ locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => "dist < 5 and city = 'Coppell'")
355
+ assert_equal 1, locations.size
356
+ locations = CustomLocation.count(:origin => @loc_a, :conditions => "dist < 5 and city = 'Coppell'")
357
+ assert_equal 1, locations
358
+ end
359
+
360
+ def test_find_with_secure_compound_condition_with_custom
361
+ locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => ["dist < ? and city = ?", 5, 'Coppell'])
362
+ assert_equal 1, locations.size
363
+ locations = CustomLocation.count(:origin => @loc_a, :conditions => ["dist < ? and city = ?", 5, 'Coppell'])
364
+ assert_equal 1, locations
365
+ end
366
+
367
+ def test_find_beyond_with_custom
368
+ locations = CustomLocation.find_beyond(3.95, :origin => @loc_a)
369
+ assert_equal 1, locations.size
370
+ locations = CustomLocation.count_beyond(3.95, :origin => @loc_a)
371
+ assert_equal 1, locations
372
+ end
373
+
374
+ def test_find_beyond_with_coordinates_with_custom
375
+ locations = CustomLocation.find_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
376
+ assert_equal 1, locations.size
377
+ locations = CustomLocation.count_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
378
+ assert_equal 1, locations
379
+ end
380
+
381
+ def test_find_nearest_with_custom
382
+ assert_equal @custom_loc_a, CustomLocation.find_nearest(:origin => @loc_a)
383
+ end
384
+
385
+ def test_find_nearest_with_coordinates_with_custom
386
+ assert_equal @custom_loc_a, CustomLocation.find_nearest(:origin =>[@loc_a.lat, @loc_a.lng])
387
+ end
388
+
389
+ def test_find_farthest_with_custom
390
+ assert_equal @custom_loc_e, CustomLocation.find_farthest(:origin => @loc_a)
391
+ end
392
+
393
+ def test_find_farthest_with_coordinates_with_custom
394
+ assert_equal @custom_loc_e, CustomLocation.find_farthest(:origin =>[@loc_a.lat, @loc_a.lng])
395
+ end
396
+
397
+ def test_find_with_array_origin
398
+ locations = Location.find(:all, :origin =>[@loc_a.lat,@loc_a.lng], :conditions => "distance < 3.97")
399
+ assert_equal 5, locations.size
400
+ locations = Location.count(:origin =>[@loc_a.lat,@loc_a.lng], :conditions => "distance < 3.97")
401
+ assert_equal 5, locations
402
+ end
403
+
404
+
405
+ # Bounding box tests
406
+
407
+ def test_find_within_bounds
408
+ locations = Location.find_within_bounds([@sw,@ne])
409
+ assert_equal 2, locations.size
410
+ locations = Location.count_within_bounds([@sw,@ne])
411
+ assert_equal 2, locations
412
+ end
413
+
414
+ def test_find_within_bounds_ordered_by_distance
415
+ locations = Location.find_within_bounds([@sw,@ne], :origin=>@bounds_center, :order=>'distance asc')
416
+ assert_equal locations[0], locations(:d)
417
+ assert_equal locations[1], locations(:a)
418
+ end
419
+
420
+ def test_find_within_bounds_with_token
421
+ locations = Location.find(:all, :bounds=>[@sw,@ne])
422
+ assert_equal 2, locations.size
423
+ locations = Location.count(:bounds=>[@sw,@ne])
424
+ assert_equal 2, locations
425
+ end
426
+
427
+ def test_find_within_bounds_with_string_conditions
428
+ locations = Location.find(:all, :bounds=>[@sw,@ne], :conditions=>"id !=#{locations(:a).id}")
429
+ assert_equal 1, locations.size
430
+ end
431
+
432
+ def test_find_within_bounds_with_array_conditions
433
+ locations = Location.find(:all, :bounds=>[@sw,@ne], :conditions=>["id != ?", locations(:a).id])
434
+ assert_equal 1, locations.size
435
+ end
436
+
437
+ def test_find_within_bounds_with_hash_conditions
438
+ locations = Location.find(:all, :bounds=>[@sw,@ne], :conditions=>{:id => locations(:a).id})
439
+ assert_equal 1, locations.size
440
+ end
441
+
442
+ def test_auto_geocode
443
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
444
+ store=Store.new(:address=>'Irving, TX')
445
+ store.save
446
+ assert_equal store.lat,@location_a.lat
447
+ assert_equal store.lng,@location_a.lng
448
+ assert_equal 0, store.errors.size
449
+ end
450
+
451
+ def test_auto_geocode_failure
452
+ GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("BOGUS").returns(GeoKit::GeoLoc.new)
453
+ store=Store.new(:address=>'BOGUS')
454
+ store.save
455
+ assert store.new_record?
456
+ assert_equal 1, store.errors.size
457
+ end
458
+
459
+ # Test :through
460
+
461
+ def test_find_with_through
462
+ organizations = MockOrganization.find(:all, :origin => @location_a, :order => 'distance ASC')
463
+ assert_equal 2, organizations.size
464
+ organizations = MockOrganization.count(:origin => @location_a, :conditions => "distance < 3.97")
465
+ assert_equal 1, organizations
466
+ end
467
+
468
+ def test_find_with_through_with_hash
469
+ people = MockPerson.find(:all, :origin => @location_a, :order => 'distance ASC')
470
+ assert_equal 2, people.size
471
+ people = MockPerson.count(:origin => @location_a, :conditions => "distance < 3.97")
472
+ assert_equal 2, people
473
+ end
474
+ end