Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit a1782bde3f72927829652c6a15ae6c6469be5662 Sven Fuchs committed Dec 28, 2011
Showing with 2,073 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +30 −0 Gemfile
  3. +207 −0 Gemfile.lock
  4. +7 −0 README
  5. +7 −0 Rakefile
  6. BIN app/assets/images/llama.jpg
  7. BIN app/assets/images/rails.png
  8. +9 −0 app/assets/javascripts/application.js
  9. +34 −0 app/assets/javascripts/subscriptions.js.coffee
  10. +86 −0 app/assets/stylesheets/application.css.scss
  11. +4 −0 app/controllers/application_controller.rb
  12. +2 −0 app/controllers/home_controller.rb
  13. +12 −0 app/controllers/profile_controller.rb
  14. +20 −0 app/controllers/sessions_controller.rb
  15. +50 −0 app/controllers/subscriptions_controller.rb
  16. +2 −0 app/helpers/application_helper.rb
  17. +2 −0 app/helpers/plans_helper.rb
  18. +2 −0 app/helpers/subscriptions_helper.rb
  19. 0 app/mailers/.gitkeep
  20. 0 app/models/.gitkeep
  21. +2 −0 app/models/address.rb
  22. +3 −0 app/models/payment.rb
  23. +23 −0 app/models/subscription.rb
  24. +44 −0 app/models/user.rb
  25. +2 −0 app/views/home/index.html.haml
  26. +16 −0 app/views/layouts/application.html.erb
  27. +5 −0 app/views/payments/_payments.html.haml
  28. +26 −0 app/views/profile/show.html.haml
  29. +4 −0 app/views/subscriptions/_subscription.html.haml
  30. +69 −0 app/views/subscriptions/new.html.haml
  31. +35 −0 app/views/subscriptions/show.html.haml
  32. +4 −0 config.ru
  33. +48 −0 config/application.rb
  34. +6 −0 config/boot.rb
  35. +8 −0 config/cucumber.yml
  36. +5 −0 config/environment.rb
  37. +32 −0 config/environments/development.rb
  38. +60 −0 config/environments/production.rb
  39. +39 −0 config/environments/test.rb
  40. +7 −0 config/initializers/backtrace_silencers.rb
  41. +10 −0 config/initializers/devise.rb
  42. +10 −0 config/initializers/inflections.rb
  43. +5 −0 config/initializers/mime_types.rb
  44. +7 −0 config/initializers/secret_token.rb
  45. +8 −0 config/initializers/session_store.rb
  46. +111 −0 config/initializers/simple_form.rb
  47. +2 −0 config/initializers/stripe.rb
  48. +14 −0 config/initializers/wrap_parameters.rb
  49. +10 −0 config/locales/en.yml
  50. +23 −0 config/locales/simple_form.yml
  51. +12 −0 config/routes.rb
  52. +7 −0 config/settings.example.yml
  53. +9 −0 db/migrate/20111008164003_create_subscriptions.rb
  54. +16 −0 db/migrate/20111227224127_create_users.rb
  55. +14 −0 db/migrate/20111228000327_create_addresses.rb
  56. +10 −0 db/migrate/20111228175101_create_payments.rb
  57. +57 −0 db/schema.rb
  58. +2 −0 doc/README_FOR_APP
  59. +44 −0 features/ordering_subscriptions.feature
  60. +8 −0 features/step_definitions/authentication_steps.rb
  61. +7 −0 features/step_definitions/common_steps.rb
  62. +3 −0 features/step_definitions/debug_steps.rb
  63. +9 −0 features/step_definitions/ordering_steps.rb
  64. +239 −0 features/step_definitions/web_steps.rb
  65. +56 −0 features/support/env.rb
  66. +28 −0 features/support/oauth.rb
  67. +10 −0 features/support/paths.rb
  68. 0 features/support/selectors.rb
  69. 0 lib/assets/.gitkeep
  70. 0 lib/tasks/.gitkeep
  71. +65 −0 lib/tasks/cucumber.rake
  72. +26 −0 public/404.html
  73. +26 −0 public/422.html
  74. +26 −0 public/500.html
  75. 0 public/favicon.ico
  76. +5 −0 public/robots.txt
  77. +10 −0 script/cucumber
  78. +6 −0 script/rails
  79. +51 −0 spec/fixtures/oauth/github.rb
  80. +82 −0 spec/fixtures/oauth/twitter.rb
  81. 0 vendor/assets/stylesheets/.gitkeep
  82. 0 vendor/plugins/.gitkeep
  83. +20 −0 vendor/plugins/country_select/MIT-LICENSE
  84. +14 −0 vendor/plugins/country_select/README
  85. +1 −0 vendor/plugins/country_select/init.rb
  86. +2 −0 vendor/plugins/country_select/install.rb
  87. +88 −0 vendor/plugins/country_select/lib/country_select.rb
  88. +1 −0 vendor/plugins/country_select/uninstall.rb
@@ -0,0 +1,7 @@
+.bundle
+config/database.yml
+config/settings.yml
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
30 Gemfile
@@ -0,0 +1,30 @@
+source 'http://rubygems.org'
+
+gem 'rails', '~> 3.1.3'
+gem 'rack', '~> 1.3.3'
+gem 'sqlite3'
+
+gem 'jquery-rails'
+
+gem 'stripe'
+gem 'devise', '~> 1.5.0'
+gem 'omniauth-github', '~> 1.0.0'
+gem 'omniauth-twitter'
+gem 'simple_form'
+gem 'haml'
+gem 'hashr'
+
+group :assets do
+ gem 'sass-rails', '~> 3.1.4'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+group :test do
+ gem 'capybara'
+ gem 'database_cleaner'
+ gem 'cucumber-rails'
+ gem 'cucumber'
+ gem 'spork'
+ gem 'launchy'
+end
@@ -0,0 +1,207 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ addressable (2.2.6)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.1)
+ builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.2.4)
+ ffi (~> 1.0.6)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ cucumber (1.1.4)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.7.1)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ cucumber-rails (1.2.1)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.1.3)
+ nokogiri (>= 1.5.0)
+ database_cleaner (0.7.0)
+ devise (1.5.2)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.1)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ execjs (1.2.13)
+ multi_json (~> 1.0)
+ faraday (0.7.5)
+ addressable (~> 2.2.6)
+ multipart-post (~> 1.1.3)
+ rack (< 2, >= 1.1.0)
+ ffi (1.0.11)
+ gherkin (2.7.1)
+ json (>= 1.4.6)
+ haml (3.1.4)
+ hashie (1.2.0)
+ hashr (0.0.19)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.4)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ multipart-post (1.1.4)
+ nokogiri (1.5.0)
+ oauth (0.4.5)
+ oauth2 (0.5.1)
+ faraday (~> 0.7.4)
+ multi_json (~> 1.0.3)
+ omniauth (1.0.1)
+ hashie (~> 1.2)
+ rack
+ omniauth-github (1.0.1)
+ omniauth (~> 1.0)
+ omniauth-oauth2 (~> 1.0)
+ omniauth-oauth (1.0.0)
+ oauth
+ omniauth (~> 1.0)
+ omniauth-oauth2 (1.0.0)
+ oauth2 (~> 0.5.0)
+ omniauth (~> 1.0)
+ omniauth-twitter (0.0.7)
+ omniauth-oauth (~> 1.0)
+ orm_adapter (0.0.5)
+ polyglot (0.3.3)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rubyzip (0.9.5)
+ sass (3.1.12)
+ sass-rails (3.1.5)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (~> 3.1.10)
+ tilt (~> 1.3.2)
+ selenium-webdriver (2.15.0)
+ childprocess (>= 0.2.1)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
+ simple_form (1.5.2)
+ actionpack (~> 3.0)
+ activemodel (~> 3.0)
+ spork (0.8.5)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.5)
+ stripe (1.5.25)
+ rest-client (~> 1.4)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ uglifier (1.2.1)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ warden (1.1.0)
+ rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara
+ coffee-rails (~> 3.1.1)
+ cucumber
+ cucumber-rails
+ database_cleaner
+ devise (~> 1.5.0)
+ haml
+ hashr
+ jquery-rails
+ launchy
+ omniauth-github (~> 1.0.0)
+ omniauth-twitter
+ rack (~> 1.3.3)
+ rails (~> 3.1.3)
+ sass-rails (~> 3.1.4)
+ simple_form
+ spork
+ sqlite3
+ stripe
+ uglifier (>= 1.0.3)
7 README
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Saas::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -0,0 +1,34 @@
+$ ->
+ Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
+ subscription.setupForm()
+
+subscription =
+ setupForm: ->
+ $('#toggle_shipping_address').change(subscription.toggleShippingAddress)
+ $('#new_subscription').submit ->
+ $('input[type=submit]').attr('disabled', true)
+ if $('#card_number').length
+ subscription.processCard()
+ false
+ else
+ true
+
+ toggleShippingAddress: ->
+ element = $('#shipping_address')
+ if element.is(':visible') then element.hide() else element.show()
+
+ processCard: ->
+ card =
+ number: $('#card_number').val()
+ cvc: $('#card_code').val()
+ expMonth: $('#card_month').val()
+ expYear: $('#card_year').val()
+ Stripe.createToken(card, subscription.handleStripeResponse)
+
+ handleStripeResponse: (status, response) ->
+ if status == 200
+ $('#subscription_stripe_card_token').val(response.id)
+ $('#new_subscription')[0].submit()
+ else
+ $('#stripe_error').text(response.error.message)
+ $('input[type=submit]').attr('disabled', false)
@@ -0,0 +1,86 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
+
+html, body {
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 75%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+form label {
+ display: block;
+ margin-bottom: 2px;
+}
+
+form .input, form .actions {
+ margin: 12px 0;
+}
+form .error {
+ color: red;
+}
+
+#subscription {
+ width: 400px;
+ h1 {
+ font-size: 24px;
+ }
+}
+
+#stripe_error {
+ color: #D00;
+}
+
+#new_subscription {
+ #shipping_address {
+ display: none;
+ }
+}
+
+
@@ -0,0 +1,4 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
+
Oops, something went wrong.

0 comments on commit a1782bd

Please sign in to comment.