rails_voter 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +31 -0
  4. data/app/assets/javascripts/rails_voter/application.js +13 -0
  5. data/app/assets/javascripts/rails_voter/ballot_forms.js +2 -0
  6. data/app/assets/stylesheets/rails_voter/application.css +15 -0
  7. data/app/assets/stylesheets/rails_voter/ballot_forms.css +4 -0
  8. data/app/controllers/rails_voter/application_controller.rb +5 -0
  9. data/app/controllers/rails_voter/ballot_forms_controller.rb +31 -0
  10. data/app/helpers/rails_voter/application_helper.rb +4 -0
  11. data/app/models/rails_voter/ballot_form.rb +7 -0
  12. data/app/models/rails_voter/ballot_form_detail.rb +6 -0
  13. data/app/models/rails_voter/voting_result.rb +5 -0
  14. data/app/views/layouts/rails_voter/application.html.erb +14 -0
  15. data/app/views/rails_voter/ballot_forms/_form.html.erb +4 -0
  16. data/app/views/rails_voter/ballot_forms/edit.html.erb +1 -0
  17. data/app/views/rails_voter/ballot_forms/index.html.erb +8 -0
  18. data/app/views/rails_voter/ballot_forms/new.html.erb +1 -0
  19. data/config/routes.rb +5 -0
  20. data/db/migrate/20160603071236_create_rails_voter_ballot_forms.rb +9 -0
  21. data/db/migrate/20160607180000_create_rails_voter_ballot_form_details.rb +9 -0
  22. data/db/migrate/20160607180028_add_ref_to_ballot_form_details.rb +5 -0
  23. data/db/migrate/20160608141052_create_rails_voter_voting_results.rb +7 -0
  24. data/db/migrate/20160608145149_add_ref_to_rails_voter_voting_result.rb +5 -0
  25. data/lib/generators/rails_voter/install/install_generator.rb +12 -0
  26. data/lib/generators/rails_voter/update/update_generator.rb +8 -0
  27. data/lib/rails_voter.rb +4 -0
  28. data/lib/rails_voter/engine.rb +12 -0
  29. data/lib/rails_voter/version.rb +3 -0
  30. data/lib/tasks/rails_voter_tasks.rake +4 -0
  31. data/spec/controllers/rails_voter/ballot_forms_controller_spec.rb +27 -0
  32. data/spec/dummy/README.rdoc +28 -0
  33. data/spec/dummy/Rakefile +6 -0
  34. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  35. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  36. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  37. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  38. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  39. data/spec/dummy/bin/bundle +3 -0
  40. data/spec/dummy/bin/rails +4 -0
  41. data/spec/dummy/bin/rake +4 -0
  42. data/spec/dummy/bin/setup +29 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/config/application.rb +25 -0
  45. data/spec/dummy/config/boot.rb +5 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +41 -0
  49. data/spec/dummy/config/environments/production.rb +79 -0
  50. data/spec/dummy/config/environments/test.rb +42 -0
  51. data/spec/dummy/config/initializers/assets.rb +11 -0
  52. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  54. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/spec/dummy/config/initializers/inflections.rb +16 -0
  56. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  57. data/spec/dummy/config/initializers/session_store.rb +3 -0
  58. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  59. data/spec/dummy/config/locales/en.yml +23 -0
  60. data/spec/dummy/config/routes.rb +3 -0
  61. data/spec/dummy/config/secrets.yml +22 -0
  62. data/spec/dummy/db/development.sqlite3 +0 -0
  63. data/spec/dummy/db/schema.rb +39 -0
  64. data/spec/dummy/db/test.sqlite3 +0 -0
  65. data/spec/dummy/log/development.log +4798 -0
  66. data/spec/dummy/log/test.log +379 -0
  67. data/spec/dummy/public/404.html +67 -0
  68. data/spec/dummy/public/422.html +67 -0
  69. data/spec/dummy/public/500.html +66 -0
  70. data/spec/dummy/public/favicon.ico +0 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-Y/-YLAC-0F5YWDHiu1XS3m2vMuIQxCQ74fhE284Tit664.cache +0 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0C/0CR2QUM7hDvU1BLwIUhCkwcV9VPiyGOGOzBhUa9OpZA.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0C/0Cw96FZsF6xQuLDgq6VLrg1Vv2zlIjKPz_TWpxwyS74.cache +1 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3R/3RIUD7--PHTvR_3HaH6qybgdyOdwdYaK99lGTLHE_5A.cache +2 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4Y/4YrU2Hi9VGNyZh5lDhDQhHumPB_rgWSMg0ke_IM6O9w.cache +1 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5W/5WAbJoTptshaUustVxKjBVel4bm5Bg9-F2JDOXAGA1Q.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5h/5hogIo5GrdIZabHw2PSxAgICQiGkFf0jRiO6BZcc13E.cache +1 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/74/744h7FBdJ2EJOKWF45KsbNqJgPlz-zzBMROwHu6lTuk.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7O/7OQARZoE0yV8xreh-806oNfZtdLEMnQZOCS4zUzkZlE.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8k/8k894gpcfLcx6CykkeEk_KwAftvD3eca74e4nImtgYI.cache +2 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9y/9ymJG3TiUpLSn12s4z0uv3M000P4tS8fs2E3GxlNWcE.cache +0 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/AN/ANQL7mS6tlhghQLYlvpLtiaq2lONGVjqW2fDC7aX02o.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Av/Av1PA44a6P8v1CQswpL8qLR0y_BM-rCT0vXg3xMSXPU.cache +2 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CF/CFB1yYxHb-pdICYv3qVo40WHaOBSrygEX0tAiMYbyeE.cache +1 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CX/CX1F0N1WEbvL8rbZivLzg16uXkzwzAkacejOBGgPW00.cache +1 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cx/Cx387k0mT2O4cR0wkIWaYvOZ-HypneJitQVpyJOZkVM.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/E4/E485OxatG2XIElrWCSBE08QsLzorLTflSdg0scvQDR4.cache +2 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/FD/FDIWwVpim7gvFsTUpZhCQ6UUyKL7IA8pMxhOtX6Z9Xs.cache +3 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/HX/HXpzMQAW3MDkxib5ostzQm1oHTULKBkTOzDbJ37FMqE.cache +2 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/M7/M7GVipnTzjq3ixNj2h_cMO-gDgxUZXu1sleMvXnMM88.cache +1 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/NA/NAahJpxcgSzUOfckDMmLy2y9oKakO2PVjqOMqE45p68.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Np/NpD76Bg4M5B_631XRVpVWvi2xCrttFiCnz92u72SXpc.cache +2 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/O4/O4_g6BdfpdvFlXO1rBibHeLSCHzJXLu4AjbXfOPJpX8.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Pi/Pii-m_3o_3ZAmHbs3JJa4fbT9YaPcvto7Lc9lM9ohQ0.cache +3 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qx/Qxrlr1cJgSSZunDJaXGim_fYF190YGHNNaix_JZQaSQ.cache +0 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rs/RsZh63v32E_wJdyZUzP4FnSBDggUCkE4SXpWaKhDldY.cache +1 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ry/RyIIMLa6GSaOIO2tKd9eBpont4552NT27_0HaKkGk84.cache +1 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SD/SD21X8TOBkkj237jrlOF4QYE4tiPA8kcNxsoaEKsOz4.cache +0 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/SE/SE7mLtwCvdYzfpiWuctndrvZs0YYtaL_CFacwWvYKHQ.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Sd/SdZFcfW4FMw1SadvbLZpE-eO_eul3ehs5RerVKQQjEU.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ux/UxOMbJSW2jlb-ix-4FAbIE2ilkmw79rWT7macjW_1t4.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/V6/V6C7H7bq8BEWP50S3J_ZBr4HUrZNmE5lEIjcUihjljw.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/V7/V7Bg9JYQdo4TV4veFVI82RGSBRcAYla-IH_aAafH4d4.cache +0 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VU/VU2kYIhM8iB2PHHVwg6CU6OHCuvNSGsOnZNo-THLr3Y.cache +2 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WB/WBLSRUQBk8jE9uLG696u9PGPOdd4Rga9osgkqSsaOss.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_M/_Mp4mY2713O-O7lF1nk_LiRHWBixmddNpihxju-Ls6w.cache +0 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aK/aKZM1U9yrI2t9r_bStgAIilRET97S243qghaedj8Y60.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bi/biIdBVuy8rJcSZZ8_aL3_8AUzV9lJwC90nhvSKUFTOk.cache +0 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bk/bkb16Xm43HWSVk9e3TWFlCcDBB4dAbIUIOqKs4C6D_0.cache +0 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cV/cV2t67LdBt9xTaCVHL-VpT-i9CwkVIG_pIQMY1D4mJQ.cache +0 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dW/dWORIKS-nToeuqOImlhB_7y0WaTiflDxvkwb29rauTw.cache +1 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/e5/e5N_-PJ-iEJsr5R4JbWru4rVvrdiPXCZx8BotAMMThE.cache +1 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fj/fjMNbpl_CXMtTtTRkNnF7gRQYWtVnam0ET2GO89G5U0.cache +0 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hM/hMlbv4niqg-gk3A8I0sEJ0PyiQXoI6rPRU3ST5CXNOs.cache +2 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jZ/jZHPJp8R3ZlOXlMOTyWySSkrzpnsRvUsZdVYKM5h1HY.cache +2 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jg/jgJz-siyPTomKhoAxQ1_Qvo73-SpkWfD9t07lXOcMm0.cache +1 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/k5/k5RfTLuf-XF5JQuNGfc8zZRaLSWhnUrzem8Gej4HSfs.cache +1 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kS/kSIbhOFL-LeJAs72VwJ1qqBqUvg0vnsFuspd4o9-g34.cache +1 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l5/l5FiU3km-E707EbwECNZvnpULM0XelCJb36d9Cwxty8.cache +0 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m0/m0oeAK4xi6X8EQ5kAUThDDjq5LlyfXViKa6VC7YxgBg.cache +1 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m6/m6gsyyz1B0TYl4lNappWB_RfZ25RVj-j3g2Y7MnU8hM.cache +1 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mE/mELQLduhYRBTh5jEHWJwrFW5UOB8lOzGgrWGJM21Rzg.cache +1 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ma/ma--SM6tx8wpfD31viCwbtGVD9wE6oLIsCmUFyIV70E.cache +1 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  128. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/st/stuhCYyrFDE9KRb2XcAtcO9jSpomriGAKhZ7FFfb2sQ.cache +1 -0
  129. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tF/tFAnFheXOY0PA_Dq-sgjipH8v-MxNvryYFFYN6vhuHw.cache +1 -0
  130. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tf/tfQAslwhc9VV-ZCDXY0CV4YgQfCL7h1KfnJo3TyeSdg.cache +2 -0
  131. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tk/tkMUeIGhTKJJGO5Agc4n1KEdlUYczhPIs-68R-qspSs.cache +1 -0
  132. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ws/wsa_fOy7y7X8rDvdtL6Y1OrK-jIWBA_g1XeADM5CE6Q.cache +3 -0
  133. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/z4/z4k8bxxRzi3wurRAfEIvRN-jdx9uy6MXrv5-0NpoQd0.cache +1 -0
  134. data/spec/dummy/tmp/pids/server.pid +1 -0
  135. data/spec/factories/rails_voter_ballot_form_details.rb +5 -0
  136. data/spec/factories/rails_voter_ballot_forms.rb +5 -0
  137. data/spec/factories/rails_voter_voting_results.rb +4 -0
  138. data/spec/models/rails_voter/ballot_form_detail_spec.rb +7 -0
  139. data/spec/models/rails_voter/ballot_form_spec.rb +10 -0
  140. data/spec/models/rails_voter/voting_result_spec.rb +7 -0
  141. data/spec/rails_helper.rb +1 -0
  142. data/spec/spec_helper.rb +20 -0
  143. data/spec/views/rails_voter/ballot_forms/edit.html.erb_spec.rb +5 -0
  144. data/spec/views/rails_voter/ballot_forms/index.html.erb_spec.rb +5 -0
  145. data/spec/views/rails_voter/ballot_forms/new.html.erb_spec.rb +5 -0
  146. metadata +457 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 45e40d4ad900523d35227a9d798cf25209b29ba1
4
+ data.tar.gz: 81d75d93f0fcfd7bcb3a9f716873ef518a29e4cd
5
+ SHA512:
6
+ metadata.gz: d373b7b040119776eedd5b3bb7c3c0f33596f7bcbff15ac574d1e989fea8ca699126b2afd6c444096cf45bd64df5ea9be19c2c1e1caaf93c653138e2dff0aded
7
+ data.tar.gz: 4ad9bb0490bbda345e2e105b48fdd77a5b397b5159dab26cce2d6a1fdf0f496c338359e1c37d39750f0623ebef1e210350664908c5313e92972660e25d6244f0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Fabian Kędzierski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ require "rdoc/task"
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "RailsVoter"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.rdoc")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load "rails/tasks/engine.rake"
19
+ load "rails/tasks/statistics.rake"
20
+
21
+ Bundler::GemHelper.install_tasks
22
+
23
+ Dir[File.join(File.dirname(__FILE__), "tasks/**/*.rake")].each { |f| load f }
24
+
25
+ require "rspec/core"
26
+ require "rspec/core/rake_task"
27
+
28
+ desc "Run all specs in spec directory (excluding plugin specs)"
29
+ RSpec::Core::RakeTask.new(spec: "app:db:test:prepare")
30
+
31
+ task default: :spec
@@ -0,0 +1,13 @@
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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ module RailsVoter
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require_dependency "rails_voter/application_controller"
2
+ require_dependency "decent_exposure"
3
+
4
+ module RailsVoter
5
+ class BallotFormsController < ApplicationController
6
+ expose :ballot_forms, -> { BallotForm.all }
7
+ expose :ballot_form, model: RailsVoter::BallotForm
8
+
9
+ def create
10
+ if ballot_form.save
11
+ redirect_to ballot_forms_path
12
+ else
13
+ render :new
14
+ end
15
+ end
16
+
17
+ def update
18
+ if ballot_form.update(ballot_form_params)
19
+ redirect_to ballot_forms_path
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def ballot_form_params
28
+ params.require(:ballot_form).permit(:name)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ module RailsVoter
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module RailsVoter
2
+ class BallotForm < ActiveRecord::Base
3
+ has_many :ballot_form_details
4
+
5
+ validates :name, presence: true
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module RailsVoter
2
+ class BallotFormDetail < ActiveRecord::Base
3
+ belongs_to :ballot_form
4
+ has_many :voting_results
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module RailsVoter
2
+ class VotingResult < ActiveRecord::Base
3
+ belongs_to :ballot_form_detail
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsVoter</title>
5
+ <%= stylesheet_link_tag "rails_voter/application", media: "all" %>
6
+ <%= javascript_include_tag "rails_voter/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ <%= form_for ballot_form do |f| %>
2
+ <%= f.text_field :name %>
3
+ <%= f.submit %>
4
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,8 @@
1
+ <%= link_to 'add', new_ballot_form_path %>
2
+
3
+ <% ballot_forms.each do |bf| %>
4
+ <p>
5
+ <%= bf.name %>
6
+ <%= link_to 'edit', edit_ballot_form_path(bf) %>
7
+ </p>
8
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ RailsVoter::Engine.routes.draw do
2
+ resources :ballot_forms
3
+
4
+ root to: 'ballot_forms#index'
5
+ end
@@ -0,0 +1,9 @@
1
+ class CreateRailsVoterBallotForms < ActiveRecord::Migration
2
+ def change
3
+ create_table :rails_voter_ballot_forms do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateRailsVoterBallotFormDetails < ActiveRecord::Migration
2
+ def change
3
+ create_table :rails_voter_ballot_form_details do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddRefToBallotFormDetails < ActiveRecord::Migration
2
+ def change
3
+ add_reference :rails_voter_ballot_form_details, :ballot_form, index: true, foreign_key: true
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class CreateRailsVoterVotingResults < ActiveRecord::Migration
2
+ def change
3
+ create_table :rails_voter_voting_results do |t|
4
+ t.timestamps null: false
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class AddRefToRailsVoterVotingResult < ActiveRecord::Migration
2
+ def change
3
+ add_reference :rails_voter_voting_results, :ballot_form_detail, index: true, foreign_key: true
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module RailsVoter
2
+ class InstallGenerator < Rails::Generators::Base
3
+ def add_routes
4
+ route "mount RailsVoter::Engine, at: \"/rails_voter\""
5
+ end
6
+
7
+ def add_migrations
8
+ rake("rails_voter:install:migrations")
9
+ rake("db:migrate")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module RailsVoter
2
+ class UpdateGenerator < Rails::Generators::Base
3
+ def add_migrations
4
+ rake("rails_voter:install:migrations")
5
+ rake("db:migrate")
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'rails_voter/engine'
2
+
3
+ module RailsVoter
4
+ end
@@ -0,0 +1,12 @@
1
+ module RailsVoter
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RailsVoter
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, fixture: false
7
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
8
+ g.assets true
9
+ g.helper false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module RailsVoter
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_voter do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,27 @@
1
+ require 'rails_helper'
2
+
3
+ module RailsVoter
4
+ RSpec.describe BallotFormsController, type: :controller do
5
+
6
+ # describe "GET #index" do
7
+ # it "returns http success" do
8
+ # get :index
9
+ # expect(response).to have_http_status(:success)
10
+ # end
11
+ # end
12
+
13
+ # describe "GET #new" do
14
+ # it "returns http success" do
15
+ # get :new, controller: :ballot_form
16
+ # expect(response).to have_http_status(:success)
17
+ # end
18
+ # end
19
+
20
+ # describe "GET #edit" do
21
+ # it "returns http success" do
22
+ # get :edit
23
+ # expect(response).to have_http_status(:success)
24
+ # end
25
+ # end
26
+ end
27
+ 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
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>