handcart 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +247 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/handcart/application.js +16 -0
  6. data/app/assets/stylesheets/handcart/application.css +15 -0
  7. data/app/assets/stylesheets/handcart/layout.css.scss +21 -0
  8. data/app/controllers/handcart/application_controller.rb +4 -0
  9. data/app/controllers/handcart/ip_addresses_controller.rb +56 -0
  10. data/app/controllers/handcart/subdomains_controller.rb +55 -0
  11. data/app/helpers/handcart/application_helper.rb +14 -0
  12. data/app/helpers/handcart/url_helper.rb +16 -0
  13. data/app/models/handcart/concerns/handcarts.rb +30 -0
  14. data/app/models/handcart/domain_constraint.rb +20 -0
  15. data/app/models/handcart/ip_address.rb +18 -0
  16. data/app/models/handcart/setting_constraint.rb +26 -0
  17. data/app/models/handcart/subdomain.rb +36 -0
  18. data/app/views/handcart/ip_addresses/_form.html.haml +12 -0
  19. data/app/views/handcart/ip_addresses/edit.html.haml +3 -0
  20. data/app/views/handcart/ip_addresses/index.html.haml +36 -0
  21. data/app/views/handcart/ip_addresses/new.html.haml +3 -0
  22. data/app/views/handcart/ip_addresses/show.html.haml +20 -0
  23. data/app/views/handcart/subdomains/_form.html.haml +9 -0
  24. data/app/views/handcart/subdomains/edit.html.haml +3 -0
  25. data/app/views/handcart/subdomains/index.html.haml +31 -0
  26. data/app/views/handcart/subdomains/new.html.haml +3 -0
  27. data/app/views/handcart/subdomains/show.html.haml +20 -0
  28. data/app/views/layouts/handcart/_navbar.html.haml +15 -0
  29. data/app/views/layouts/handcart/application.html.haml +60 -0
  30. data/config/handcart.json +6 -0
  31. data/config/locales/en.yml +61 -0
  32. data/config/routes.rb +5 -0
  33. data/db/migrate/20131009165427_create_handcart_subdomains.rb +9 -0
  34. data/db/migrate/20131203000934_create_handcart_ip_addresses.rb +12 -0
  35. data/lib/handcart.rb +67 -0
  36. data/lib/handcart/acts_as_handcart.rb +16 -0
  37. data/lib/handcart/controller_additions.rb +152 -0
  38. data/lib/handcart/engine.rb +27 -0
  39. data/lib/handcart/ip_authorization.rb +27 -0
  40. data/lib/handcart/simple_form.rb +179 -0
  41. data/lib/handcart/strategies/base_ip_strategy.rb +21 -0
  42. data/lib/handcart/strategies/containment_strategy.rb +16 -0
  43. data/lib/handcart/strategies/inclusion_strategy.rb +17 -0
  44. data/lib/handcart/templates/rspec/controller/controller_spec.rb +17 -0
  45. data/lib/handcart/templates/rspec/scaffold/routing_spec.rb +40 -0
  46. data/lib/handcart/version.rb +3 -0
  47. data/spec/controllers/handcart/ip_addresses_controller_spec.rb +134 -0
  48. data/spec/controllers/handcart/subdomains_controller_spec.rb +138 -0
  49. data/spec/dummy/README.rdoc +28 -0
  50. data/spec/dummy/Rakefile +6 -0
  51. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  52. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  53. data/spec/dummy/app/assets/stylesheets/layout.css.scss +4 -0
  54. data/spec/dummy/app/controllers/application_controller.rb +7 -0
  55. data/spec/dummy/app/controllers/custom_constraints_controller.rb +2 -0
  56. data/spec/dummy/app/controllers/ip_addresses_controller.rb +7 -0
  57. data/spec/dummy/app/controllers/master/companies_controller.rb +51 -0
  58. data/spec/dummy/app/controllers/master/dashboard_controller.rb +4 -0
  59. data/spec/dummy/app/controllers/master_controller.rb +2 -0
  60. data/spec/dummy/app/controllers/public_controller.rb +12 -0
  61. data/spec/dummy/app/controllers/subdomain_controller.rb +8 -0
  62. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  63. data/spec/dummy/app/models/company.rb +7 -0
  64. data/spec/dummy/app/views/ip_addresses/index.html.haml +12 -0
  65. data/spec/dummy/app/views/ip_addresses/show.html.haml +1 -0
  66. data/spec/dummy/app/views/layouts/_navbar.html.haml +11 -0
  67. data/spec/dummy/app/views/layouts/application.html.haml +53 -0
  68. data/spec/dummy/app/views/layouts/public.html.haml +41 -0
  69. data/spec/dummy/app/views/master/companies/_form.html.haml +19 -0
  70. data/spec/dummy/app/views/master/companies/edit.html.haml +7 -0
  71. data/spec/dummy/app/views/master/companies/index.html.haml +25 -0
  72. data/spec/dummy/app/views/master/companies/new.html.haml +5 -0
  73. data/spec/dummy/app/views/master/companies/show.html.haml +12 -0
  74. data/spec/dummy/app/views/master/dashboard/index.html.haml +2 -0
  75. data/spec/dummy/app/views/public/forbidden.html.haml +3 -0
  76. data/spec/dummy/app/views/public/index.html.haml +2 -0
  77. data/spec/dummy/app/views/subdomain/index.html.haml +2 -0
  78. data/spec/dummy/bin/bundle +3 -0
  79. data/spec/dummy/bin/rails +4 -0
  80. data/spec/dummy/bin/rake +4 -0
  81. data/spec/dummy/config.ru +4 -0
  82. data/spec/dummy/config/application.rb +40 -0
  83. data/spec/dummy/config/boot.rb +5 -0
  84. data/spec/dummy/config/database.yml +26 -0
  85. data/spec/dummy/config/environment.rb +5 -0
  86. data/spec/dummy/config/environments/development.rb +29 -0
  87. data/spec/dummy/config/environments/production.rb +80 -0
  88. data/spec/dummy/config/environments/test.rb +36 -0
  89. data/spec/dummy/config/handcart.json +6 -0
  90. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  91. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  92. data/spec/dummy/config/initializers/handcart.rb +16 -0
  93. data/spec/dummy/config/initializers/inflections.rb +16 -0
  94. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  95. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  96. data/spec/dummy/config/initializers/session_store.rb +3 -0
  97. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy/config/locales/en.yml +12 -0
  99. data/spec/dummy/config/routes.rb +23 -0
  100. data/spec/dummy/db/migrate/20131010194534_create_companies.rb +10 -0
  101. data/spec/dummy/db/migrate/20131016183624_add_active_to_companies.rb +5 -0
  102. data/spec/dummy/db/schema.rb +41 -0
  103. data/spec/dummy/log/development.log +14 -0
  104. data/spec/dummy/log/test.log +786 -0
  105. data/spec/dummy/public/404.html +58 -0
  106. data/spec/dummy/public/422.html +58 -0
  107. data/spec/dummy/public/500.html +57 -0
  108. data/spec/dummy/spec/models/company_spec.rb +36 -0
  109. data/spec/dummy/spec/routing/custom_constraints_routing_spec.rb +37 -0
  110. data/spec/dummy/tmp/cache/assets/development/sass/27d34b7cbcb5b92ab03220c4d4b91379cc64c2c0/layout.css.scssc +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sass/dc98e44780f42e6521ebbf14c4db22f6a78c41ef/layout.css.scssc +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sprockets/05974a1f812cf4a61bb242d48722fd19 +0 -0
  113. data/spec/dummy/tmp/cache/assets/development/sprockets/063a74a7c73c9501ee373ef00111f159 +0 -0
  114. data/spec/dummy/tmp/cache/assets/development/sprockets/073d2b13ed9366ce539940749eb3844d +0 -0
  115. data/spec/dummy/tmp/cache/assets/development/sprockets/0d76367ded60510a66afc3dea891e76a +0 -0
  116. data/spec/dummy/tmp/cache/assets/development/sprockets/106c3f4e1fc71e9dc70abae55d432886 +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/13ae4613233656a42188d4d3ddbb7fc1 +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/18c826ba1d6dac1633cae2da25c0402a +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/247df6a90ce931f763db1ade5227d4b1 +0 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/2860df473a6cf4c483cd6f251fea3ae0 +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/2a99072e783dcef4637b38221531ea61 +0 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/2ab4b3177ab6c9d837c0905b61eedad5 +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/2b84c9cc30f71e24310dd1a4381caae8 +0 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/2bebf0981bc585e24939ca8ffe10081c +0 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/2c45a1517014fd239c930e48a71a93f0 +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/2d5147f4ea70131b4e330cab38aeb1a1 +0 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/3124588878c79981009129f32d5fe408 +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/33325c558d8db2071bf8a938517e5af2 +0 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/350c8c72b1dbd7a84f85424b5cd4def1 +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/3a3d69c38e3b3d20e94420ebebd05a69 +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/3b1656b46a35a6120c3407b930d468ba +0 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/3c0fc39d9b84afb4937545b620cd2d72 +0 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/3fa878a57cb0b42be266336564609b18 +0 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/40f26b5e75d0f747e691c0b38529fb59 +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/42aa8e53e39d8f5247f1b3e89cb00adc +0 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/42e1f4c72bf58cf112dd11eae8ee768b +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/433be3db83a4d9f93f5d1fa2ae3bde4e +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/4b6f9f46d7a2e230321d7f8df06ea470 +0 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/4c17c77b444339bb3ab293047da0ff0d +0 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/4ee93c096bb850d38032eb457afebf69 +0 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/4f25edc4354919ba67721f488ba10e12 +0 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/58fb821d4a4a44fdb2a89d4f487a8390 +0 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/5f97a76ac644497413f4c8dc547ddea6 +0 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/6076ab56e9c62fd04155d6f6c43e575e +0 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/60b75d9635ed84e08a0b9a245d8a3202 +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/64ad9f343408809fdfb1df851186853d +0 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/6e79870e51ea835a6847f8c65e23e14b +0 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/6e9d2e7aafa45c939731291fa453b8c2 +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/78f915513059378e161ceb6f2d14fbd9 +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/8102cf6724f489a310fe3a6b764bb2e9 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/81108a1123b15b10c7f7f2e0d1207267 +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/81b3dcc0aa61577b08de13ba5633dbc4 +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/83e686634b5ac6d4b183677ed2edda8b +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/8581aae276f167a9b7b2158641b0bf87 +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/94cb3819408e525700729fbd473432c8 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/99eb5e50b6d0e5d0d6b6c37cbde33864 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/a7c86e9a777f7789dd1c78d26a662a87 +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/a9e19eb45005fa24bc8b90b6a374089f +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/ac4492393938e58cede2b6277afb0bc6 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/ad1d96635f4dae7eb22d1984947d7440 +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/af718c632887ccb6c1c35c4b65c61293 +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/b2f45720a78d375468b99bb25f121c4e +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/b559f2694561fc6c44e3319f507de1e7 +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/b6e8c6ba59755a8fe132457f81065f96 +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/b796b57f310287a7a619afa9d5b99952 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/b7c36a1c00d7804d9e827d704c0dd811 +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/bc28a210f3df576c74059aff8233eae3 +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/bc414fbd5123e40c4f5e69f4c294f489 +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/c0181c32e0ed10ec8fa3049f9a80f551 +0 -0
  173. data/spec/dummy/tmp/cache/assets/development/sprockets/c17130f66131c854d6f8c2196902b596 +0 -0
  174. data/spec/dummy/tmp/cache/assets/development/sprockets/c4c0e10aa5c21ece42c0bfe998a5d8c0 +0 -0
  175. data/spec/dummy/tmp/cache/assets/development/sprockets/c63bcc000975adbdf423db3ad43eb93f +0 -0
  176. data/spec/dummy/tmp/cache/assets/development/sprockets/c962f9220062a6407dfc7d9447565273 +0 -0
  177. data/spec/dummy/tmp/cache/assets/development/sprockets/cb8b538b6fce61b500edebe63156bf62 +0 -0
  178. data/spec/dummy/tmp/cache/assets/development/sprockets/cfcef2015b7df990ed90006632877389 +0 -0
  179. data/spec/dummy/tmp/cache/assets/development/sprockets/cff56d2d0a8b8a25d4b0388d242be9c8 +0 -0
  180. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  181. data/spec/dummy/tmp/cache/assets/development/sprockets/d32fc7356f764b22ecbcebbcb9b47ee1 +0 -0
  182. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  183. data/spec/dummy/tmp/cache/assets/development/sprockets/d776667bae72eb3d582da5803fc931ca +0 -0
  184. data/spec/dummy/tmp/cache/assets/development/sprockets/dfc307d14a0cf64cf8c3a4e94fdbcfb9 +0 -0
  185. data/spec/dummy/tmp/cache/assets/development/sprockets/e4b6570b82329477bc7043183b64b105 +0 -0
  186. data/spec/dummy/tmp/cache/assets/development/sprockets/eff1316ad12dd5b8f4cbf0ba9e448229 +0 -0
  187. data/spec/dummy/tmp/cache/assets/development/sprockets/f2348b747b81ca6e3a24d5bd0b7023c4 +0 -0
  188. data/spec/dummy/tmp/cache/assets/development/sprockets/f6f921309fcc78b6850abcf2418279fe +0 -0
  189. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  190. data/spec/dummy/tmp/cache/assets/development/sprockets/f7e1dbf50c19c9d439de52caa4296164 +0 -0
  191. data/spec/dummy/tmp/cache/assets/development/sprockets/ff2adfc3ed446b68ac2d0077e8af34e2 +0 -0
  192. data/spec/factories/companies.rb +7 -0
  193. data/spec/factories/handcart_ip_addresses.rb +8 -0
  194. data/spec/factories/handcart_subdomains.rb +5 -0
  195. data/spec/models/handcart/base_ip_strategy_spec.rb +23 -0
  196. data/spec/models/handcart/containment_strategy_spec.rb +23 -0
  197. data/spec/models/handcart/domain_constraint_spec.rb +38 -0
  198. data/spec/models/handcart/engine_spec.rb +14 -0
  199. data/spec/models/handcart/handcart_spec.rb +38 -0
  200. data/spec/models/handcart/inclusion_strategy_spec.rb +29 -0
  201. data/spec/models/handcart/ip_address_spec.rb +51 -0
  202. data/spec/models/handcart/ip_authorization_spec.rb +17 -0
  203. data/spec/models/handcart/subdomain_spec.rb +153 -0
  204. data/spec/routing/handcart/ip_addresses_routing_spec.rb +38 -0
  205. data/spec/routing/handcart/subdomains_routing_spec.rb +38 -0
  206. data/spec/spec_helper.rb +65 -0
  207. data/spec/support/subdomains.rb +26 -0
  208. metadata +565 -0
@@ -0,0 +1,21 @@
1
+ module Handcart
2
+ module Strategies
3
+ # This is the parent of all IP Authorization strategies. It should only be used
4
+ # in cases where no IP authorization is desired.
5
+ class BaseIpStrategy
6
+ attr_accessor :strategy
7
+
8
+ def initialize
9
+ @strategy = :none
10
+ end
11
+
12
+ def self.available_strategies
13
+ [:containment, :inclusion, :none]
14
+ end
15
+
16
+ def is_in_range?(foreign_ip_address, handcart)
17
+ raise NotImplementedError, 'Invalid IP Authorization Strategy'
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module Handcart
2
+ module Strategies
3
+ class ContainmentStrategy < BaseIpStrategy
4
+ # This strategy simply checks to see if the permitted list of IP Addresses
5
+ # for the current handcart has an entry for the foreign IP Address
6
+
7
+ def initialize
8
+ @strategy = :containment
9
+ end
10
+
11
+ def is_in_range?(foreign_ip_address, handcart)
12
+ handcart.ip_addresses.permitted.include?(foreign_ip_address)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Handcart
2
+ module Strategies
3
+ class InclusionStrategy < BaseIpStrategy
4
+ # This strategy checks the permitted list of IP Addresses for the current handcart
5
+ # to insure not only that the list contains the foreign IP address, but that it is
6
+ # also within the same subnet group.
7
+
8
+ def initialize
9
+ @strategy = :inclusion
10
+ end
11
+
12
+ def is_in_range?(foreign_ip_address, handcart)
13
+ handcart.ip_addresses.permitted.any? { |handcart_ip_address| IPAddr.new("#{handcart_ip_address.address}/#{handcart_ip_address.subnet_mask}").include?(foreign_ip_address) }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ <% module_namespacing do -%>
4
+ describe <%= class_name %>Controller do
5
+ routes { Handcart::Engine.routes }
6
+
7
+ <% for action in actions -%>
8
+ describe "GET '<%= action %>'" do
9
+ it "returns http success" do
10
+ get '<%= action %>', use_routes: :handcart
11
+ response.should be_success
12
+ end
13
+ end
14
+
15
+ <% end -%>
16
+ end
17
+ <% end -%>
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ describe <%= controller_class_name %>Controller do
5
+ describe "routing" do
6
+ routes { Handcart::Engine.routes }
7
+
8
+ <% unless options[:singleton] -%>
9
+ it "routes to #index" do
10
+ expect(get: <%= ns_table_name %>").to route_to("handcart/<%= ns_table_name %>#index")
11
+ end
12
+
13
+ <% end -%>
14
+ it "routes to #new" do
15
+ expect(get: <%= ns_table_name %>/new").to route_to("handcart/<%= ns_table_name %>#new")
16
+ end
17
+
18
+ it "routes to #show" do
19
+ expect(get: <%= ns_table_name %>/1").to route_to("handcart/<%= ns_table_name %>#show", id: "1")
20
+ end
21
+
22
+ it "routes to #edit" do
23
+ expect(get: <%= ns_table_name %>/1/edit").to route_to("handcart/<%= ns_table_name %>#edit", id: "1")
24
+ end
25
+
26
+ it "routes to #create" do
27
+ expect(post: <%= ns_table_name %>").to route_to("handcart/<%= ns_table_name %>#create")
28
+ end
29
+
30
+ it "routes to #update" do
31
+ expect(put: <%= ns_table_name %>/1").to route_to("handcart/<%= ns_table_name %>#update", id: "1")
32
+ end
33
+
34
+ it "routes to #destroy" do
35
+ expect(delete: <%= ns_table_name %>/1").to route_to("handcart/<%= ns_table_name %>#destroy", id: "1")
36
+ end
37
+
38
+ end
39
+ end
40
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ module Handcart
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,134 @@
1
+ require 'spec_helper'
2
+
3
+ module Handcart
4
+ describe IpAddressesController do
5
+ routes { Handcart::Engine.routes }
6
+
7
+ let(:valid_attributes) { attributes_for(:handcart_ip_address) }
8
+ let(:valid_session) { {} }
9
+
10
+ describe "GET index" do
11
+ it "assigns all ip_addresses as @ip_addresses" do
12
+ ip_address = IpAddress.create! valid_attributes
13
+ get :index, {}, valid_session
14
+ assigns(:ip_addresses).should eq([ip_address])
15
+ end
16
+ end
17
+
18
+ describe "GET show" do
19
+ it "assigns the requested ip_address as @ip_address" do
20
+ ip_address = IpAddress.create! valid_attributes
21
+ get :show, {id: ip_address.to_param}, valid_session
22
+ assigns(:ip_address).should eq(ip_address)
23
+ end
24
+ end
25
+
26
+ describe "GET new" do
27
+ it "assigns a new ip_address as @ip_address" do
28
+ get :new, {}, valid_session
29
+ assigns(:ip_address).should be_a_new(IpAddress)
30
+ end
31
+ end
32
+
33
+ describe "GET edit" do
34
+ it "assigns the requested ip_address as @ip_address" do
35
+ ip_address = IpAddress.create! valid_attributes
36
+ get :edit, {id: ip_address.to_param}, valid_session
37
+ assigns(:ip_address).should eq(ip_address)
38
+ end
39
+ end
40
+
41
+ describe "POST create" do
42
+ describe "with valid params" do
43
+ it "creates a new IpAddress" do
44
+ expect {
45
+ post :create, {ip_address: valid_attributes}, valid_session
46
+ }.to change(IpAddress, :count).by(1)
47
+ end
48
+
49
+ it "assigns a newly created ip_address as @ip_address" do
50
+ post :create, {ip_address: valid_attributes}, valid_session
51
+ assigns(:ip_address).should be_a(IpAddress)
52
+ assigns(:ip_address).should be_persisted
53
+ end
54
+
55
+ it "redirects to the created ip_address" do
56
+ post :create, {ip_address: valid_attributes}, valid_session
57
+ response.should redirect_to(IpAddress.last)
58
+ end
59
+ end
60
+
61
+ describe "with invalid params" do
62
+ it "assigns a newly created but unsaved ip_address as @ip_address" do
63
+ # Trigger the behavior that occurs when invalid params are submitted
64
+ IpAddress.any_instance.stub(:save).and_return(false)
65
+ post :create, {ip_address: { "address" => "invalid value" }}, valid_session
66
+ assigns(:ip_address).should be_a_new(IpAddress)
67
+ end
68
+
69
+ it "re-renders the 'new' template" do
70
+ # Trigger the behavior that occurs when invalid params are submitted
71
+ IpAddress.any_instance.stub(:save).and_return(false)
72
+ post :create, {ip_address: { "address" => "invalid value" }}, valid_session
73
+ response.should render_template("new")
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "PUT update" do
79
+ describe "with valid params" do
80
+ it "updates the requested ip_address" do
81
+ ip_address = IpAddress.create! valid_attributes
82
+ IpAddress.any_instance.should_receive(:update).with({ "address" => "MyString" })
83
+ put :update, {id: ip_address.to_param, ip_address: { "address" => "MyString" }}, valid_session
84
+ end
85
+
86
+ it "assigns the requested ip_address as @ip_address" do
87
+ ip_address = IpAddress.create! valid_attributes
88
+ put :update, {id: ip_address.to_param, ip_address: valid_attributes}, valid_session
89
+ assigns(:ip_address).should eq(ip_address)
90
+ end
91
+
92
+ it "redirects to the ip_address" do
93
+ ip_address = IpAddress.create! valid_attributes
94
+ put :update, {id: ip_address.to_param, ip_address: valid_attributes}, valid_session
95
+ response.should redirect_to(ip_address)
96
+ end
97
+ end
98
+
99
+ describe "with invalid params" do
100
+ it "assigns the ip_address as @ip_address" do
101
+ ip_address = IpAddress.create! valid_attributes
102
+ # Trigger the behavior that occurs when invalid params are submitted
103
+ IpAddress.any_instance.stub(:save).and_return(false)
104
+ put :update, {id: ip_address.to_param, ip_address: { "address" => "invalid value" }}, valid_session
105
+ assigns(:ip_address).should eq(ip_address)
106
+ end
107
+
108
+ it "re-renders the 'edit' template" do
109
+ ip_address = IpAddress.create! valid_attributes
110
+ # Trigger the behavior that occurs when invalid params are submitted
111
+ IpAddress.any_instance.stub(:save).and_return(false)
112
+ put :update, {id: ip_address.to_param, ip_address: { "address" => "invalid value" }}, valid_session
113
+ response.should render_template("edit")
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "DELETE destroy" do
119
+ it "destroys the requested ip_address" do
120
+ ip_address = IpAddress.create! valid_attributes
121
+ expect {
122
+ delete :destroy, {id: ip_address.to_param}, valid_session
123
+ }.to change(IpAddress, :count).by(-1)
124
+ end
125
+
126
+ it "redirects to the ip_addresses list" do
127
+ ip_address = IpAddress.create! valid_attributes
128
+ delete :destroy, {id: ip_address.to_param}, valid_session
129
+ response.should redirect_to(ip_addresses_url)
130
+ end
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+
3
+ module Handcart
4
+ describe SubdomainsController do
5
+ routes { Handcart::Engine.routes }
6
+
7
+ let(:valid_attributes) { attributes_for(:handcart_subdomain) }
8
+ let(:valid_session) { {} }
9
+
10
+ describe "GET index" do
11
+ it "assigns all subdomains as @subdomains" do
12
+ subdomain = Subdomain.create! valid_attributes
13
+ get :index, {}, valid_session
14
+ assigns(:subdomains).should eq([subdomain])
15
+ end
16
+ end
17
+
18
+ describe "GET show" do
19
+ it "assigns the requested subdomain as @subdomain" do
20
+ subdomain = Subdomain.create! valid_attributes
21
+ get :show, {id: subdomain.to_param}, valid_session
22
+ assigns(:subdomain).should eq(subdomain)
23
+ end
24
+ end
25
+
26
+ describe "GET new" do
27
+ it "assigns a new subdomain as @subdomain" do
28
+ get :new, {}, valid_session
29
+ assigns(:subdomain).should be_a_new(Subdomain)
30
+ end
31
+ end
32
+
33
+ describe "GET edit" do
34
+ it "assigns the requested subdomain as @subdomain" do
35
+ subdomain = Subdomain.create! valid_attributes
36
+ get :edit, {id: subdomain.to_param}, valid_session
37
+ assigns(:subdomain).should eq(subdomain)
38
+ end
39
+ end
40
+
41
+ describe "POST create" do
42
+ describe "with valid params" do
43
+ it "creates a new Subdomain" do
44
+ expect {
45
+ post :create, {subdomain: valid_attributes}, valid_session
46
+ }.to change(Subdomain, :count).by(1)
47
+ end
48
+
49
+ it "assigns a newly created subdomain as @subdomain" do
50
+ post :create, {subdomain: valid_attributes}, valid_session
51
+ assigns(:subdomain).should be_a(Subdomain)
52
+ assigns(:subdomain).should be_persisted
53
+ end
54
+
55
+ it "redirects to the subdomains index" do
56
+ post :create, {subdomain: valid_attributes}, valid_session
57
+ response.should redirect_to(subdomains_url)
58
+ end
59
+ end
60
+
61
+ describe "with invalid params" do
62
+ it "assigns a newly created but unsaved subdomain as @subdomain" do
63
+ # Trigger the behavior that occurs when invalid params are submitted
64
+ Subdomain.any_instance.stub(:save).and_return(false)
65
+ post :create, {subdomain: { "name" => "invalid value" }}, valid_session
66
+ assigns(:subdomain).should be_a_new(Subdomain)
67
+ end
68
+
69
+ it "re-renders the 'new' template" do
70
+ # Trigger the behavior that occurs when invalid params are submitted
71
+ Subdomain.any_instance.stub(:save).and_return(false)
72
+ post :create, {subdomain: { "name" => "invalid value" }}, valid_session
73
+ response.should render_template("new")
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "PUT update" do
79
+ describe "with valid params" do
80
+ it "updates the requested subdomain" do
81
+ subdomain = Subdomain.create! valid_attributes
82
+ # Assuming there are no other subdomains in the database, this
83
+ # specifies that the Subdomain created on the previous line
84
+ # receives the :update_attributes message with whatever params are
85
+ # submitted in the request.
86
+ Subdomain.any_instance.should_receive(:update).with({ "name" => "MyString" })
87
+ put :update, {id: subdomain.to_param, subdomain: { "name" => "MyString" }}, valid_session
88
+ end
89
+
90
+ it "assigns the requested subdomain as @subdomain" do
91
+ subdomain = Subdomain.create! valid_attributes
92
+ put :update, {id: subdomain.to_param, subdomain: valid_attributes}, valid_session
93
+ assigns(:subdomain).should eq(subdomain)
94
+ end
95
+
96
+ it "redirects to the subdomains index" do
97
+ subdomain = Subdomain.create! valid_attributes
98
+ put :update, {id: subdomain.to_param, subdomain: valid_attributes}, valid_session
99
+ response.should redirect_to(subdomains_url)
100
+ end
101
+ end
102
+
103
+ describe "with invalid params" do
104
+ it "assigns the subdomain as @subdomain" do
105
+ subdomain = Subdomain.create! valid_attributes
106
+ # Trigger the behavior that occurs when invalid params are submitted
107
+ Subdomain.any_instance.stub(:save).and_return(false)
108
+ put :update, {id: subdomain.to_param, subdomain: { "name" => "invalid value" }}, valid_session
109
+ assigns(:subdomain).should eq(subdomain)
110
+ end
111
+
112
+ it "re-renders the 'edit' template" do
113
+ subdomain = Subdomain.create! valid_attributes
114
+ # Trigger the behavior that occurs when invalid params are submitted
115
+ Subdomain.any_instance.stub(:save).and_return(false)
116
+ put :update, {id: subdomain.to_param, subdomain: { "name" => "invalid value" }}, valid_session
117
+ response.should render_template("edit")
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "DELETE destroy" do
123
+ it "destroys the requested subdomain" do
124
+ subdomain = Subdomain.create! valid_attributes
125
+ expect {
126
+ delete :destroy, {id: subdomain.to_param}, valid_session
127
+ }.to change(Subdomain, :count).by(-1)
128
+ end
129
+
130
+ it "redirects to the subdomains list" do
131
+ subdomain = Subdomain.create! valid_attributes
132
+ delete :destroy, {id: subdomain.to_param}, valid_session
133
+ response.should redirect_to(subdomains_url)
134
+ end
135
+ end
136
+
137
+ end
138
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require twitter/bootstrap
16
+ //= require_tree .