From aa3ed3d43b3602cff0bf2d6e7cd781749fda7074 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Tue, 4 Dec 2012 00:46:15 -0500 Subject: [PATCH] git init --- .gitignore | 7 + .rspec | 2 + .rvmrc | 55 ++++ Gemfile | 43 ++++ Gemfile.lock | 236 ++++++++++++++++++ Guardfile | 37 +++ README.md | 14 ++ Rakefile | 27 ++ app/assets/images/rails.png | Bin 0 -> 6647 bytes app/assets/javascripts/application.js | 16 ++ app/assets/javascripts/bootstrap.js.coffee | 4 + .../javascripts/examples.js.coffee.sample | 15 ++ app/assets/stylesheets/application.css | 13 + .../bootstrap_and_overrides.css.less | 17 ++ app/controllers/application_controller.rb | 3 + app/controllers/authenticated_controller.rb | 3 + app/controllers/site_controller.rb | 9 + app/controllers/team_controller.example | 36 +++ app/helpers/application_helper.rb | 10 + app/mailers/.gitkeep | 0 app/models/.gitkeep | 0 app/models/team.example | 17 ++ app/models/team_membership.example | 18 ++ app/models/user.rb | 17 ++ app/views/devise/_links.erb | 25 ++ app/views/devise/confirmations/new.html.erb | 12 + .../mailer/confirmation_instructions.html.erb | 5 + .../reset_password_instructions.html.erb | 8 + .../mailer/unlock_instructions.html.erb | 7 + app/views/devise/passwords/edit.html.erb | 16 ++ app/views/devise/passwords/new.html.erb | 12 + app/views/devise/registrations/edit.html.erb | 25 ++ app/views/devise/registrations/new.html.haml | 29 +++ app/views/devise/sessions/new.html.erb | 28 +++ app/views/devise/unlocks/new.html.erb | 12 + app/views/layouts/application.html.haml | 49 ++++ app/views/site/index.html.haml | 1 + app/views/teams_examples/index.html.haml | 9 + app/views/teams_examples/new.html.haml | 21 ++ app/views/teams_examples/show.html.haml | 11 + config.ru | 4 + config/application.rb | 66 +++++ config/boot.rb | 6 + config/database.yml | 25 ++ config/environment.rb | 5 + config/environments/development.rb | 44 ++++ config/environments/production.rb | 68 +++++ config/environments/test.rb | 37 +++ config/initializers/backtrace_silencers.rb | 7 + config/initializers/devise.rb | 223 +++++++++++++++++ config/initializers/inflections.rb | 15 ++ config/initializers/mime_types.rb | 5 + config/initializers/secret_token.rb | 7 + config/initializers/session_store.rb | 8 + config/initializers/setup_mail.rb | 9 + config/initializers/wrap_parameters.rb | 14 ++ config/locales/devise.en.yml | 57 +++++ config/locales/en.yml | 5 + config/routes.rb | 71 ++++++ .../20120227024410_devise_create_users.rb | 49 ++++ .../20120227040841_add_lockable_to_user.rb | 9 + .../20120301124238_add_names_to_user.rb | 7 + .../20120308031328_create_teams.example | 17 ++ ...325023452_add_private_team_to_team.example | 5 + ...0325031259_create_team_memberships.example | 17 ++ db/schema.rb | 61 +++++ db/seeds.rb | 11 + doc/README_FOR_APP | 1 + lib/assets/.gitkeep | 0 lib/tasks/.gitkeep | 0 log/.gitkeep | 0 public/404.html | 26 ++ public/422.html | 26 ++ public/500.html | 25 ++ public/favicon.ico | 0 public/robots.txt | 5 + script/rails | 6 + spec/acceptance/create_a_team.feature.example | 30 +++ spec/acceptance/list_teams.feature.example | 34 +++ spec/acceptance/steps/common_steps.rb | 15 ++ spec/acceptance/steps/factory_girl_steps.rb | 40 +++ spec/acceptance/steps/login_steps.rb | 7 + spec/acceptance/steps/pagination_steps.rb | 3 + spec/acceptance/steps/team_steps.example | 72 ++++++ spec/acceptance/steps/user_steps.rb | 3 + spec/controllers/maps_controller_spec.example | 5 + spec/factories.rb | 14 ++ spec/factories/maps.example | 10 + spec/models/team_membership_spec.example | 24 ++ spec/models/team_spec.example | 45 ++++ spec/models/user_spec.rb | 29 +++ spec/requests/devise/registrations_spec.rb | 45 ++++ spec/spec_helper.rb | 119 +++++++++ spec/support/factory_girl_step_helpers.rb | 93 +++++++ vendor/assets/javascripts/.gitkeep | 0 vendor/assets/stylesheets/.gitkeep | 0 vendor/plugins/.gitkeep | 0 97 files changed, 2398 insertions(+) create mode 100644 .gitignore create mode 100644 .rspec create mode 100644 .rvmrc create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Guardfile create mode 100644 README.md create mode 100644 Rakefile create mode 100644 app/assets/images/rails.png create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/bootstrap.js.coffee create mode 100644 app/assets/javascripts/examples.js.coffee.sample create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/bootstrap_and_overrides.css.less create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/authenticated_controller.rb create mode 100644 app/controllers/site_controller.rb create mode 100644 app/controllers/team_controller.example create mode 100644 app/helpers/application_helper.rb create mode 100644 app/mailers/.gitkeep create mode 100644 app/models/.gitkeep create mode 100644 app/models/team.example create mode 100644 app/models/team_membership.example create mode 100644 app/models/user.rb create mode 100644 app/views/devise/_links.erb create mode 100644 app/views/devise/confirmations/new.html.erb create mode 100644 app/views/devise/mailer/confirmation_instructions.html.erb create mode 100644 app/views/devise/mailer/reset_password_instructions.html.erb create mode 100644 app/views/devise/mailer/unlock_instructions.html.erb create mode 100644 app/views/devise/passwords/edit.html.erb create mode 100644 app/views/devise/passwords/new.html.erb create mode 100644 app/views/devise/registrations/edit.html.erb create mode 100644 app/views/devise/registrations/new.html.haml create mode 100644 app/views/devise/sessions/new.html.erb create mode 100644 app/views/devise/unlocks/new.html.erb create mode 100644 app/views/layouts/application.html.haml create mode 100644 app/views/site/index.html.haml create mode 100644 app/views/teams_examples/index.html.haml create mode 100644 app/views/teams_examples/new.html.haml create mode 100644 app/views/teams_examples/show.html.haml create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/devise.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/secret_token.rb create mode 100644 config/initializers/session_store.rb create mode 100644 config/initializers/setup_mail.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/devise.en.yml create mode 100644 config/locales/en.yml create mode 100644 config/routes.rb create mode 100644 db/migrate/20120227024410_devise_create_users.rb create mode 100644 db/migrate/20120227040841_add_lockable_to_user.rb create mode 100644 db/migrate/20120301124238_add_names_to_user.rb create mode 100644 db/migrate/20120308031328_create_teams.example create mode 100644 db/migrate/20120325023452_add_private_team_to_team.example create mode 100644 db/migrate/20120325031259_create_team_memberships.example create mode 100644 db/schema.rb create mode 100644 db/seeds.rb create mode 100644 doc/README_FOR_APP create mode 100644 lib/assets/.gitkeep create mode 100644 lib/tasks/.gitkeep create mode 100644 log/.gitkeep create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/favicon.ico create mode 100644 public/robots.txt create mode 100755 script/rails create mode 100644 spec/acceptance/create_a_team.feature.example create mode 100644 spec/acceptance/list_teams.feature.example create mode 100644 spec/acceptance/steps/common_steps.rb create mode 100644 spec/acceptance/steps/factory_girl_steps.rb create mode 100644 spec/acceptance/steps/login_steps.rb create mode 100644 spec/acceptance/steps/pagination_steps.rb create mode 100644 spec/acceptance/steps/team_steps.example create mode 100644 spec/acceptance/steps/user_steps.rb create mode 100644 spec/controllers/maps_controller_spec.example create mode 100644 spec/factories.rb create mode 100644 spec/factories/maps.example create mode 100644 spec/models/team_membership_spec.example create mode 100644 spec/models/team_spec.example create mode 100644 spec/models/user_spec.rb create mode 100644 spec/requests/devise/registrations_spec.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/support/factory_girl_step_helpers.rb create mode 100644 vendor/assets/javascripts/.gitkeep create mode 100644 vendor/assets/stylesheets/.gitkeep create mode 100644 vendor/plugins/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d31f67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.bundle +db/*.sqlite3 +log/*.log +tmp/ +*.swp +.powrc +.rbenv-version diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..fe31725 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +-rturnip diff --git a/.rvmrc b/.rvmrc new file mode 100644 index 0000000..a8e41f3 --- /dev/null +++ b/.rvmrc @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# This is an RVM Project .rvmrc file, used to automatically load the ruby +# development environment upon cd'ing into the directory + +# First we specify our desired [@], the @gemset name is optional. +environment_id="ruby-1.9.3-p0@velocipede" + +# +# Uncomment following line if you want options to be set only for given project. +# +# PROJECT_JRUBY_OPTS=( --1.9 ) + +# +# First we attempt to load the desired environment directly from the environment +# file. This is very fast and efficient compared to running through the entire +# CLI and selector. If you want feedback on which environment was used then +# insert the word 'use' after --create as this triggers verbose mode. +# +if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ + && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] +then + \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" + + if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] + then + . "${rvm_path:-$HOME/.rvm}/hooks/after_use" + fi +else + # If the environment file has not yet been created, use the RVM CLI to select. + if ! rvm --create use "$environment_id" + then + echo "Failed to create RVM environment '${environment_id}'." + return 1 + fi +fi + +# +# If you use an RVM gemset file to install a list of gems (*.gems), you can have +# it be automatically loaded. Uncomment the following and adjust the filename if +# necessary. +# +# filename=".gems" +# if [[ -s "$filename" ]] +# then +# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d' +# fi + +# If you use bundler, this might be useful to you: +# if command -v bundle && [[ -s Gemfile ]] +# then +# bundle install +# fi + + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0892222 --- /dev/null +++ b/Gemfile @@ -0,0 +1,43 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.1' + +gem 'sqlite3', '~> 1.3.5' +gem 'devise', '~> 2.0.4' +gem 'haml-rails', '~> 0.3.4' +gem 'jquery-rails', '~> 2.0' +gem 'decent_exposure', '~> 1.0.1' +gem 'will_paginate', '~> 3.0.3' +gem 'bootstrap-will_paginate', '~> 0.0.6' + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + gem "twitter-bootstrap-rails", "~> 2.0.3" + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer' + + gem 'uglifier', '>= 1.0.3' +end + +group :development, :test do + gem 'rspec-rails', '~> 2.8.1' + gem 'factory_girl_rails', '~> 1.2' + gem 'pry', '~> 0.9.8' +end + +group :test do + gem 'shoulda-matchers', '~> 1.0.0' + gem 'capybara', '~> 1.1.2' + gem 'turnip', '~> 0.3.0' + gem 'database_cleaner' + gem 'launchy' + gem 'spork' + #guard dependency for Mac OS 10 + gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i + gem 'guard-spork' + gem 'guard-rspec' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e3cb180 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,236 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.1) + actionpack (= 3.2.1) + mail (~> 2.4.0) + actionpack (3.2.1) + activemodel (= 3.2.1) + activesupport (= 3.2.1) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.1) + rack (~> 1.4.0) + rack-cache (~> 1.1) + rack-test (~> 0.6.1) + sprockets (~> 2.1.2) + activemodel (3.2.1) + activesupport (= 3.2.1) + builder (~> 3.0.0) + activerecord (3.2.1) + activemodel (= 3.2.1) + activesupport (= 3.2.1) + arel (~> 3.0.0) + tzinfo (~> 0.3.29) + activeresource (3.2.1) + activemodel (= 3.2.1) + activesupport (= 3.2.1) + activesupport (3.2.1) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.3.2) + arel (3.0.2) + bcrypt-ruby (3.0.1) + bootstrap-will_paginate (0.0.9) + will_paginate + builder (3.0.4) + capybara (1.1.3) + 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.3.6) + ffi (~> 1.0, >= 1.0.6) + coderay (1.0.8) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.4.0) + commonjs (0.2.6) + database_cleaner (0.9.1) + decent_exposure (1.0.2) + devise (2.0.4) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + railties (~> 3.1) + warden (~> 1.1.1) + diff-lcs (1.1.3) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) + railties (>= 3.0.0) + ffi (1.1.5) + gherkin (2.11.5) + json (>= 1.4.6) + guard (1.5.4) + listen (>= 0.4.2) + lumberjack (>= 1.0.2) + pry (>= 0.9.10) + thor (>= 0.14.6) + guard-rspec (1.2.1) + guard (>= 1.1) + guard-spork (1.2.3) + childprocess (>= 0.2.3) + guard (>= 1.1) + spork (>= 0.8.4) + sys-proctable + haml (3.1.7) + haml-rails (0.3.5) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (~> 3.1) + railties (>= 3.1, < 4.1) + hike (1.2.1) + i18n (0.6.1) + journey (1.0.4) + jquery-rails (2.1.3) + railties (>= 3.1.0, < 5.0) + thor (~> 0.14) + json (1.7.5) + launchy (2.1.2) + addressable (~> 2.3) + less (2.2.2) + commonjs (~> 0.2.6) + less-rails (2.2.6) + actionpack (>= 3.1) + less (~> 2.2.0) + libv8 (3.3.10.4) + libwebsocket (0.1.5) + addressable + listen (0.5.3) + lumberjack (1.0.2) + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + method_source (0.8.1) + mime-types (1.19) + multi_json (1.3.7) + nokogiri (1.5.5) + orm_adapter (0.0.7) + polyglot (0.3.3) + pry (0.9.10) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.3.1) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.1) + actionmailer (= 3.2.1) + actionpack (= 3.2.1) + activerecord (= 3.2.1) + activeresource (= 3.2.1) + activesupport (= 3.2.1) + bundler (~> 1.0) + railties (= 3.2.1) + railties (3.2.1) + actionpack (= 3.2.1) + activesupport (= 3.2.1) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rb-fsevent (0.9.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + rspec-rails (2.8.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec (~> 2.8.0) + rubyzip (0.9.9) + sass (3.2.3) + sass-rails (3.2.5) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + selenium-webdriver (2.26.0) + childprocess (>= 0.2.5) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + shoulda-matchers (1.0.0) + slop (3.3.3) + spork (0.9.2) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.6) + sys-proctable (0.9.2) + therubyracer (0.10.2) + libv8 (~> 3.3.10) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + turnip (0.3.1) + gherkin (>= 2.5) + rspec (~> 2.0) + twitter-bootstrap-rails (2.0.9) + actionpack (>= 3.1) + less-rails (~> 2.2.2) + railties (>= 3.1) + therubyracer (~> 0.10.1) + tzinfo (0.3.35) + uglifier (1.3.0) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + warden (1.1.1) + rack (>= 1.0) + will_paginate (3.0.3) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + bootstrap-will_paginate (~> 0.0.6) + capybara (~> 1.1.2) + coffee-rails (~> 3.2.1) + database_cleaner + decent_exposure (~> 1.0.1) + devise (~> 2.0.4) + factory_girl_rails (~> 1.2) + guard-rspec + guard-spork + haml-rails (~> 0.3.4) + jquery-rails (~> 2.0) + launchy + pry (~> 0.9.8) + rails (= 3.2.1) + rb-fsevent + rspec-rails (~> 2.8.1) + sass-rails (~> 3.2.3) + shoulda-matchers (~> 1.0.0) + spork + sqlite3 (~> 1.3.5) + turnip (~> 0.3.0) + twitter-bootstrap-rails (~> 2.0.3) + uglifier (>= 1.0.3) + will_paginate (~> 3.0.3) diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..34e4840 --- /dev/null +++ b/Guardfile @@ -0,0 +1,37 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do + watch('config/application.rb') + watch('config/environment.rb') + watch('config/environments/test.rb') + watch(%r{^config/initializers/.+\.rb$}) + watch('Gemfile') + watch('Gemfile.lock') + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } + watch(%r{features/support/}) { :cucumber } + watch(%r{^spec/support/.+\.rb$}) +end + +guard 'rspec', :version => 2, :cli => "--drb", :all_on_start => false, :all_after_pass => false do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + + # Capybara request specs + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } +end + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5952f3 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Developer Setup + +1. use rvm +1. allow the .rvmrc file +1. `gem install bundler` +1. `bundle` +1. `rake db:create db:migrate db:seed` +1. `rake` +1. `rails s` + +## Mailcatcher + +Use mailcatcher to see what emails look like in development. +Follow the instructions from http://mailcatcher.me/ to create an rvm wrapper so you don't install it all over your gemsets diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5164c52 --- /dev/null +++ b/Rakefile @@ -0,0 +1,27 @@ +#!/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. + +Rake::TaskManager.class_eval do + def remove_task(task_name) + @tasks.delete(task_name.to_s) + end +end + +require File.expand_path('../config/application', __FILE__) + +Velocipede::Application.load_tasks + +namespace :spec do + desc 'Run all acceptance specs' + RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t| + t.pattern = '**/*.feature' + end +end + +Rake.application.remove_task 'spec' + +desc 'Run all specs' +RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t| + t.pattern = '**/*{_spec.rb,.feature}' +end diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 0000000000000000000000000000000000000000..e794828740a3d0c43cdf412972df3aa633f45060 GIT binary patch literal 6647 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 + $("a[rel=popover]").popover() + $(".tooltip").tooltip() + $("a[rel=tooltip]").tooltip() diff --git a/app/assets/javascripts/examples.js.coffee.sample b/app/assets/javascripts/examples.js.coffee.sample new file mode 100644 index 0000000..5187716 --- /dev/null +++ b/app/assets/javascripts/examples.js.coffee.sample @@ -0,0 +1,15 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ +jQuery -> + $('form').on 'click', '.remove_fields', (event) -> + $(this).prev('input[type=hidden]').val('1') + $(this).closest('fieldset').hide() + event.preventDefault() + + $('form').on 'click', '.add_fields', (event) -> + time = new Date().getTime() + regexp = new RegExp($(this).data('id'), 'g') + $(this).before($(this).data('fields').replace(regexp, time)) + event.preventDefault() + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..3b5cc66 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * 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 . +*/ diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less new file mode 100644 index 0000000..4210c11 --- /dev/null +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -0,0 +1,17 @@ +@import "twitter/bootstrap/bootstrap"; +@import "twitter/bootstrap/responsive"; + +// Set the correct sprite paths +@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png'); +@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png'); + +// Your custom LESS stylesheets goes here +// +// Since bootstrap was imported above you have access to its mixins which +// you may use and inherit here +// +// If you'd like to override bootstrap's own variables, you can do so here as well +// See http://twitter.github.com/bootstrap/less.html for their names and documentation +// +// Example: +// @linkColor: #ff0000; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..e8065d9 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/authenticated_controller.rb b/app/controllers/authenticated_controller.rb new file mode 100644 index 0000000..29a8599 --- /dev/null +++ b/app/controllers/authenticated_controller.rb @@ -0,0 +1,3 @@ +class AuthenticatedController < ApplicationController + before_filter :authenticate_user! +end diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb new file mode 100644 index 0000000..1dca589 --- /dev/null +++ b/app/controllers/site_controller.rb @@ -0,0 +1,9 @@ +class SiteController < ApplicationController + + def index + respond_to do |format| + format.html + end + end + +end diff --git a/app/controllers/team_controller.example b/app/controllers/team_controller.example new file mode 100644 index 0000000..3361f2f --- /dev/null +++ b/app/controllers/team_controller.example @@ -0,0 +1,36 @@ +class TeamsController < AuthenticatedController + expose(:team) do + if params[:id] + Team.find(params[:id]) + elsif params[:team] + Team.new(params[:team]) + else + Team.new(:max_members => 16) + end + end + + expose(:teams) { Team.order('lower(name)').paginate(:page => params[:page]) } + + def index + end + + def show + end + + def new + end + + def create + team.captain = current_user + if team.save + redirect_to teams_url + else + render :new + end + end + + def join + current_user.teams << team + redirect_to team + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..45c6beb --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,10 @@ +module ApplicationHelper + def link_to_add_fields(name, f, association) + new_object = f.object.send(association).klass.new + id = new_object.object_id + fields = f.fields_for(association, new_object, child_index: id) do |builder| + render(association.to_s.singularize + "_fields", f: builder) + end + link_to(name, '#', id: "add_#{association.to_s.singularize}" , class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")}) + end +end diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/team.example b/app/models/team.example new file mode 100644 index 0000000..e7c080e --- /dev/null +++ b/app/models/team.example @@ -0,0 +1,17 @@ +class Team < ActiveRecord::Base + attr_accessible :name, :max_members, :private_team + + belongs_to :captain, :class_name => 'User' + has_many :team_memberships + has_many :members, :through => :team_memberships, :source => :user + + validates :name, :presence => true, :uniqueness => true, :length => { :minimum => 3 } + validates :max_members, :presence => true, :numericality => { :only_integer => true, :greater_than => 0 } + validates :captain, :presence => true + + self.per_page = 15 + + def to_s + "#{name}#{private_team? ? '*' : ''}" + end +end diff --git a/app/models/team_membership.example b/app/models/team_membership.example new file mode 100644 index 0000000..bd3edcb --- /dev/null +++ b/app/models/team_membership.example @@ -0,0 +1,18 @@ +class TeamMembership < ActiveRecord::Base + belongs_to :team + belongs_to :user + + validates :user, :presence => true + validates :team, :presence => true + validates :user_id, :uniqueness => { :scope => :team_id } + validate :no_captains_allowed + + + private + + def no_captains_allowed + if user.present? && team.present? && team.captain == user + errors.add(:user, "Captain is already a member.") + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..64f217a --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,17 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable, :lockable #TODO ,:confirmable + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me, + :first_name, :last_name, :nickname + + validates :first_name, :presence => true + validates :last_name, :presence => true + + def to_s + "#{first_name} #{last_name}" + end +end diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb new file mode 100644 index 0000000..33b1120 --- /dev/null +++ b/app/views/devise/_links.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Sign in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..f998e05 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,12 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend confirmation instructions" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..a5c4585 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @resource.email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..ae9e888 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password, and you can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..2263c21 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive amount of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..9272916 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +

Change your password

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + <%= f.hidden_field :reset_password_token %> + +
<%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Change my password" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..b9b59d4 --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,12 @@ +

Forgot your password?

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Send me reset password instructions" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..bb66fbf --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,25 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+ +
<%= f.submit "Update" %>
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml new file mode 100644 index 0000000..ef1ec0b --- /dev/null +++ b/app/views/devise/registrations/new.html.haml @@ -0,0 +1,29 @@ +%h2 Sign up += form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| + = devise_error_messages! + %div + = f.label :first_name + %br/ + = f.text_field :first_name + %div + = f.label :last_name + %br/ + = f.text_field :last_name + %div + = f.label :nickname + %br/ + = f.text_field :nickname + %div + = f.label :email + %br/ + = f.email_field :email + %div + = f.label :password + %br/ + = f.password_field :password + %div + = f.label :password_confirmation + %br/ + = f.password_field :password_confirmation + %div= f.submit "Sign up" += render "links" diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..fcf2fd8 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,28 @@ +

Sign in

+ +<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ + <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in" %>
+<% end %> + +<%= render "links" %> + +<% if Rails.env.development? %> + <% User.all.each do |user| %> + <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> + <%= f.hidden_field :email, :value => user.email %> + <%= f.hidden_field :password, :value => 'password' %> +
<%= f.submit "Sign in as #{user.email}" %>
+ <% end %> + <% end %> +<% end %> + diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..8ab26cc --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,12 @@ +

Resend unlock instructions

+ +<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend unlock instructions" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..3b33b03 --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,49 @@ +!!! 5 +%html{:lang => "en"} + %head + %meta{:charset => "utf-8"}/ + %title= content_for?(:title) ? yield(:title) : "Mash" + = csrf_meta_tags + /[if lt IE 9] + = javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js" + :css + body { + padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ + } + = stylesheet_link_tag "application", :media => "all" + + %body + .navbar.navbar-fixed-top + .navbar-inner + .container + = link_to 'Mash', root_path, :class => 'brand' + .container.nav-collapse + %ul.nav + %li= link_to "Home", root_path + %ul.nav.pull-right + - if user_signed_in? + %li#logged_in_as + = link_to "Hello #{current_user.first_name} #{current_user.last_name}", edit_user_registration_path + %li#logout + = link_to 'Logout', destroy_user_session_path, :method => :delete + - else + %li#login + = link_to 'Login', new_user_session_path + %li#register + = link_to 'Register', new_user_registration_path + + .container + + .content + - if flash[:notice] + %p{:class => 'notice'}= flash[:notice] + - if flash[:alert] + %p{:class => 'alert'}= flash[:alert] + .row + .span13 + = yield + + %footer + %p © Rails App Template 2012 + + = javascript_include_tag "application" diff --git a/app/views/site/index.html.haml b/app/views/site/index.html.haml new file mode 100644 index 0000000..6994a00 --- /dev/null +++ b/app/views/site/index.html.haml @@ -0,0 +1 @@ +Do the monster mash! diff --git a/app/views/teams_examples/index.html.haml b/app/views/teams_examples/index.html.haml new file mode 100644 index 0000000..47505d6 --- /dev/null +++ b/app/views/teams_examples/index.html.haml @@ -0,0 +1,9 @@ +%p + = link_to 'Create a Team', new_team_path, :class => 'btn btn-large btn-primary' + +.teams + - teams.each do |team| + %h3.team= link_to team, team + += will_paginate teams + diff --git a/app/views/teams_examples/new.html.haml b/app/views/teams_examples/new.html.haml new file mode 100644 index 0000000..c582934 --- /dev/null +++ b/app/views/teams_examples/new.html.haml @@ -0,0 +1,21 @@ += form_for team, :html => { :class => 'form-horizontal' } do |f| + .control-group{:class => team.errors[:name].present? ? 'error' : ''} + = f.label :name, 'Name', :class => 'control-label' + .controls + = f.text_field :name + - if team.errors[:name].present? + .help-inline= team.errors[:name].join(', ') + .control-group{:class => team.errors[:max_members].present? ? 'error' : ''} + = f.label :max_members, 'Max members', :class => 'control-label' + .controls + = f.text_field :max_members + - if team.errors[:max_members].present? + .help-inline= team.errors[:max_members].join(', ') + .control-group{:class => team.errors[:private_team].present? ? 'error' : ''} + = f.label :private_team, 'Private team?', :class => 'control-label' + .controls + = f.check_box :private_team + - if team.errors[:private_team].present? + .help-inline= team.errors[:private_team].join(', ') + .form-actions + = f.submit 'Create Team', :class => 'btn btn-primary' diff --git a/app/views/teams_examples/show.html.haml b/app/views/teams_examples/show.html.haml new file mode 100644 index 0000000..505ccd3 --- /dev/null +++ b/app/views/teams_examples/show.html.haml @@ -0,0 +1,11 @@ +%h3= team + +%ul.members + %li= team.captain + - team.members.each do |member| + %li= member + +- unless current_user.is_a_member_of?(team) + = form_tag join_team_path(team) do + = submit_tag 'Join team', :class => 'btn' + diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..a494079 --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Velocipede::Application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..7d74bda --- /dev/null +++ b/config/application.rb @@ -0,0 +1,66 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + +module Velocipede + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + config.generators do |g| + g.helper false + g.test_framework :rspec, + :view_specs => false, + :routing_specs => false + end + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + # config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..4489e58 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,6 @@ +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..51a4dd4 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..4d66573 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +Velocipede::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..f5594e3 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,44 @@ +Velocipede::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true + + #Devise gem uses mailer + config.action_mailer.default_url_options = { :host => 'localhost:3000' } + + # use mailcatcher (http://mailcatcher.me/) to test emails in development + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..4680ca9 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,68 @@ +Velocipede::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # TODO set to host + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..e859f52 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,37 @@ +Velocipede::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..e0d6120 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,223 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class with default "from" parameter. + config.mailer_sender = "velocipede@gmail.com" + + # Configure the class responsible to send e-mails. + # config.mailer = "Devise::Mailer" + + # Automatically apply schema changes in tableless databases + config.apply_schema = false + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [ :email ] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:token]` will + # enable it only for token authentication. + # config.http_authenticatable = false + + # If http headers should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. "Application" by default. + # config.http_authentication_realm = "Application" + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # :http_auth and :token_auth by adding those symbols to the array below. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing :skip => :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. + config.stretches = Rails.env.test? ? 1 : 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = "bb93785f2f4fa5d751943024b63e63ec239e2de6b975d14c919083a3ef922f0c5eced07e17291ca08225c212a9fbd4738dfe4bc76daa1bc70bc950e526d2fea5" + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming his account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming his account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming his account. + # config.allow_unconfirmed_access_for = 2.days + + # If true, requires any email changes to be confirmed (exctly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed new email is stored in + # unconfirmed email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # If true, uses the password salt as remember token. This should be turned + # to false if you are not using database authenticatable. + config.use_salt_as_remember_token = true + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.cookie_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 6..128. + # config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # an one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper) + # config.encryptor = :sha512 + + # ==> Configuration for :token_authenticatable + # Defines name of the authentication token params key + # config.token_authentication_key = :auth_token + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Configure sign_out behavior. + # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). + # The default is true, which means any logout action will sign out all active scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ["*/*", :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # end +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..5d8d9be --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,15 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end +# +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 0000000..6cf1f00 --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Velocipede::Application.config.secret_token = 'cd4ae1e008bba64bfe79f64167e769534386892a48163ecfb114ee65ef7e5d2548ba1194b5ee08f52998622b6aad39390db2029fdf3143bdea3bb59bf23f97be' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..48d0891 --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Velocipede::Application.config.session_store :cookie_store, key: '_mash_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Velocipede::Application.config.session_store :active_record_store diff --git a/config/initializers/setup_mail.rb b/config/initializers/setup_mail.rb new file mode 100644 index 0000000..fe0f488 --- /dev/null +++ b/config/initializers/setup_mail.rb @@ -0,0 +1,9 @@ +ActionMailer::Base.smtp_settings = { + :address => "smtp.gmail.com", + :port => 587, + :domain => "gmail.com", + :user_name => "velocipede", + :password => "password", + :authentication => "plain", + :enable_starttls_auto => true +} diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..999df20 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..73df488 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,57 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + errors: + messages: + expired: "has expired, please request a new one" + not_found: "not found" + already_confirmed: "was already confirmed, please try signing in" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" + + devise: + failure: + already_authenticated: 'You are already signed in.' + unauthenticated: 'You need to sign in or sign up before continuing.' + unconfirmed: 'You have to confirm your account before continuing.' + locked: 'Your account is locked.' + invalid: 'Invalid email or password.' + invalid_token: 'Invalid authentication token.' + timeout: 'Your session expired, please sign in again to continue.' + inactive: 'Your account was not activated yet.' + sessions: + signed_in: 'Signed in successfully.' + signed_out: 'Signed out successfully.' + passwords: + send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' + updated: 'Your password was changed successfully. You are now signed in.' + updated_not_active: 'Your password was changed successfully.' + send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail" + confirmations: + send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' + send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' + confirmed: 'Your account was successfully confirmed. You are now signed in.' + registrations: + signed_up: 'Welcome! You have signed up successfully.' + signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' + signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' + signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' + updated: 'You updated your account successfully.' + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + unlocks: + send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' + unlocked: 'Your account has been unlocked successfully. Please sign in to continue.' + send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.' + omniauth_callbacks: + success: 'Successfully authorized from %{kind} account.' + failure: 'Could not authorize you from %{kind} because "%{reason}".' + mailer: + confirmation_instructions: + subject: 'Confirmation instructions' + reset_password_instructions: + subject: 'Reset password instructions' + unlock_instructions: + subject: 'Unlock Instructions' diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..179c14c --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..58a4d7a --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,71 @@ +Velocipede::Application.routes.draw do + + devise_for :users + + # The priority is based upon order of creation: + # first created -> highest priority. + + match 'site/index' => 'site#index' + + resources :teams, :except => [:edit, :delete] do + member do + post :join + end + end + + resources :clues + resources :maps + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => 'site#index' + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id))(.:format)' +end diff --git a/db/migrate/20120227024410_devise_create_users.rb b/db/migrate/20120227024410_devise_create_users.rb new file mode 100644 index 0000000..540333c --- /dev/null +++ b/db/migrate/20120227024410_devise_create_users.rb @@ -0,0 +1,49 @@ +class DeviseCreateUsers < ActiveRecord::Migration + def change + create_table(:users) do |t| + ## Database authenticatable + t.string :email, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, :default => 0 + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Encryptable + # t.string :password_salt + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + ## Token authenticatable + # t.string :authentication_token + + + t.timestamps + end + + add_index :users, :email, :unique => true + add_index :users, :reset_password_token, :unique => true + # add_index :users, :confirmation_token, :unique => true + # add_index :users, :unlock_token, :unique => true + # add_index :users, :authentication_token, :unique => true + end +end diff --git a/db/migrate/20120227040841_add_lockable_to_user.rb b/db/migrate/20120227040841_add_lockable_to_user.rb new file mode 100644 index 0000000..377e214 --- /dev/null +++ b/db/migrate/20120227040841_add_lockable_to_user.rb @@ -0,0 +1,9 @@ +class AddLockableToUser < ActiveRecord::Migration + def change + change_table :users do |t| + t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + t.string :unlock_token # Only if unlock strategy is :email or :both + t.datetime :locked_at + end + end +end diff --git a/db/migrate/20120301124238_add_names_to_user.rb b/db/migrate/20120301124238_add_names_to_user.rb new file mode 100644 index 0000000..c8ed060 --- /dev/null +++ b/db/migrate/20120301124238_add_names_to_user.rb @@ -0,0 +1,7 @@ +class AddNamesToUser < ActiveRecord::Migration + def change + add_column :users, :first_name, :string, :null => false, :default => '' + add_column :users, :last_name, :string, :null => false, :default => '' + add_column :users, :nickname, :string + end +end diff --git a/db/migrate/20120308031328_create_teams.example b/db/migrate/20120308031328_create_teams.example new file mode 100644 index 0000000..ccbaa14 --- /dev/null +++ b/db/migrate/20120308031328_create_teams.example @@ -0,0 +1,17 @@ +class CreateTeams < ActiveRecord::Migration + def up + create_table :teams do |t| + t.string :name, :null => false, :default => '' + t.integer :max_members, :null => false, :default => 16 + t.integer :captain_id, :null => false + end + add_index :teams, :name, :unique => true + add_index :teams, :captain_id + end + + def down + remove_index :teams, :column => :captain_id + remove_index :teams, :column => :name + drop_table :teams + end +end diff --git a/db/migrate/20120325023452_add_private_team_to_team.example b/db/migrate/20120325023452_add_private_team_to_team.example new file mode 100644 index 0000000..56bca23 --- /dev/null +++ b/db/migrate/20120325023452_add_private_team_to_team.example @@ -0,0 +1,5 @@ +class AddPrivateTeamToTeam < ActiveRecord::Migration + def change + add_column :teams, :private_team, :boolean, :default => false, :null => false + end +end diff --git a/db/migrate/20120325031259_create_team_memberships.example b/db/migrate/20120325031259_create_team_memberships.example new file mode 100644 index 0000000..753696e --- /dev/null +++ b/db/migrate/20120325031259_create_team_memberships.example @@ -0,0 +1,17 @@ +class CreateTeamMemberships < ActiveRecord::Migration + def up + create_table :team_memberships do |t| + t.references :user, :null => false + t.references :team, :null => false + t.timestamps + end + add_index :team_memberships, :user_id + add_index :team_memberships, :team_id + end + + def down + remove_index :team_memberships, :column => :team_id + remove_index :team_memberships, :column => :user_id + drop_table :team_memberships + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..8b1025d --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,61 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20121104211300) do + + +# create_table "team_memberships", :force => true do |t| +# t.integer "user_id", :null => false +# t.integer "team_id", :null => false +# t.datetime "created_at", :null => false +# t.datetime "updated_at", :null => false +# end + +# add_index "team_memberships", ["team_id"], :name => "index_team_memberships_on_team_id" +# add_index "team_memberships", ["user_id"], :name => "index_team_memberships_on_user_id" + +# create_table "teams", :force => true do |t| +# t.string "name", :default => "", :null => false +# t.integer "max_members", :default => 16, :null => false +# t.integer "captain_id", :null => false +# t.boolean "private_team", :default => false, :null => false +# end + +# add_index "teams", ["captain_id"], :name => "index_teams_on_captain_id" +# add_index "teams", ["name"], :name => "index_teams_on_name", :unique => true + + create_table "users", :force => true do |t| + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", :default => 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "failed_attempts", :default => 0 + t.string "unlock_token" + t.datetime "locked_at" + t.string "first_name", :default => "", :null => false + t.string "last_name", :default => "", :null => false + t.string "nickname" + end + + add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..e605943 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,11 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) + +if Rails.env.development? + FactoryGirl.create(:user) +end diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP new file mode 100644 index 0000000..379f521 --- /dev/null +++ b/doc/README_FOR_APP @@ -0,0 +1 @@ +# No API yet diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..9a48320 --- /dev/null +++ b/public/404.html @@ -0,0 +1,26 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..83660ab --- /dev/null +++ b/public/422.html @@ -0,0 +1,26 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000..f3648a0 --- /dev/null +++ b/public/500.html @@ -0,0 +1,25 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+ + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..085187f --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/script/rails b/script/rails new file mode 100755 index 0000000..f8da2cf --- /dev/null +++ b/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/spec/acceptance/create_a_team.feature.example b/spec/acceptance/create_a_team.feature.example new file mode 100644 index 0000000..dad1f41 --- /dev/null +++ b/spec/acceptance/create_a_team.feature.example @@ -0,0 +1,30 @@ +Feature: Create a team + In order to gather my friends to participate in a hunt + As a user + I want to create a team + + Background: + Given a user "test@example.com" with password "password" + When I login with email "test@example.com" and password "password" + And I go to create a new team + + Scenario: View the create a team form + Then I should see the create a team form + + Scenario: Errors on form are displayed + When I submit the new team form + Then I should see an error message about the team name + + Scenario: Created team is in list + When I fill out the team form with team name "Happy Trackers" + And I submit the new team form + And I go to the team list + Then I should see "Happy Trackers" in the team list + + Scenario: Create a private team + When I fill out the team form with team name "Happy Trackers" + And I check the box to make my team private + And I submit the new team form + And I go to the team list + Then the team list should be: + | Happy Trackers* | diff --git a/spec/acceptance/list_teams.feature.example b/spec/acceptance/list_teams.feature.example new file mode 100644 index 0000000..87ec5b7 --- /dev/null +++ b/spec/acceptance/list_teams.feature.example @@ -0,0 +1,34 @@ +Feature: List teams + In order to see the teams + As a user + I want to see them sorted by name and paginated + + Background: + Given a user "test@example.com" with password "password" + When I login with email "test@example.com" and password "password" + + Scenario: Team list paginated to 15 + Given 20 teams exist + And I go to the team list + Then I should see 15 teams in the team list + When I go to the next page + Then I should see 5 teams in the team list + + Scenario: Team list should be alphabetical by name + Given the following teams exist: + | name | + | Bad | + | Car | + | Art | + | Door | + | ear | + | apple | + And I go to the team list + Then the team list should be: + | apple | + | Art | + | Bad | + | Car | + | Door | + | ear | + diff --git a/spec/acceptance/steps/common_steps.rb b/spec/acceptance/steps/common_steps.rb new file mode 100644 index 0000000..8cc7162 --- /dev/null +++ b/spec/acceptance/steps/common_steps.rb @@ -0,0 +1,15 @@ +step "show me the page" do + save_and_open_page +end + +step "I click the link :link_text" do |link_text| + page.click_link link_text +end + +step "I click the button :button_text" do |button_text| + page.click_button button_text +end + +step "I fill out the form with :model :field_name :field_value" do |model, field_name, field_value| + page.fill_in "#{model}_#{field_name}", :with => field_value +end diff --git a/spec/acceptance/steps/factory_girl_steps.rb b/spec/acceptance/steps/factory_girl_steps.rb new file mode 100644 index 0000000..dce651c --- /dev/null +++ b/spec/acceptance/steps/factory_girl_steps.rb @@ -0,0 +1,40 @@ +FactoryGirl.factories.each do |factory| + factory.compile + factory.human_names.each do |human_name| + step "the following #{human_name} exists:" do |table| + table.hashes.each do |human_hash| + attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations) + FactoryGirl.create(factory.name, attributes) + end + end + + step "the following #{human_name.pluralize} exist:" do |table| + table.hashes.each do |human_hash| + attributes = convert_human_hash_to_attribute_hash(human_hash, factory.associations) + FactoryGirl.create(factory.name, attributes) + end + end + + step "a(n) #{human_name} exists" do + FactoryGirl.create(factory.name) + end + + step ":count #{human_name.pluralize} exist" do |count| + FactoryGirl.create_list(factory.name, count.to_i) + end + + if factory.build_class.respond_to?(:columns) + factory.build_class.columns.each do |column| + name = column.respond_to?(:name) ? column.name : column.to_s + human_column_name = name.downcase.gsub('_', ' ') + step "a(n) #{human_name} exists with a(n) #{human_column_name} of :value" do |value| + FactoryGirl.create(factory.name, name => value) + end + + step ":count #{human_name.pluralize} exist with a(n) #{human_column_name} of :value" do |count, value| + FactoryGirl.create_list(factory.name, count.to_i, name => value) + end + end + end + end +end diff --git a/spec/acceptance/steps/login_steps.rb b/spec/acceptance/steps/login_steps.rb new file mode 100644 index 0000000..10c417e --- /dev/null +++ b/spec/acceptance/steps/login_steps.rb @@ -0,0 +1,7 @@ +step "I login with email :email and password :password" do |email, password| + visit new_user_session_path + fill_in 'Email', :with => email + fill_in 'Password', :with => password + click_button 'Sign in' + page.should have_content("Signed in successfully.") +end diff --git a/spec/acceptance/steps/pagination_steps.rb b/spec/acceptance/steps/pagination_steps.rb new file mode 100644 index 0000000..244a06b --- /dev/null +++ b/spec/acceptance/steps/pagination_steps.rb @@ -0,0 +1,3 @@ +step "I go to the next page" do + page.find('.pagination li.next a').click +end diff --git a/spec/acceptance/steps/team_steps.example b/spec/acceptance/steps/team_steps.example new file mode 100644 index 0000000..6acc129 --- /dev/null +++ b/spec/acceptance/steps/team_steps.example @@ -0,0 +1,72 @@ +step "I go to create a new team" do + visit new_team_path +end + +step 'I go to the team list' do + visit teams_path +end + +step "I should see the create a team form" do + page.should have_field 'Name' + page.should have_field 'Max members', :with => '16' +end + +step "I submit the new team form" do + page.find('form#new_team').find('input[type=submit]').click +end + +step "I fill out the team form with team name :team_name" do |team_name| + page.fill_in 'Name', :with => team_name +end + +step "I check the box to make my team private" do + page.check "Private team?" +end + +step 'I should see an error message about the team name' do + within 'form#new_team' do + page.should have_content "can't be blank" + end +end + +step 'I should see :team_name in the team list' do |team_name| + within '.teams' do + page.should have_content(team_name) + end +end + +step 'I should see :count teams in the team list' do |count| + within '.teams' do + page.all('h3.team').count.should == count.to_i + end +end + +step 'the team list should be:' do |table| + within '.teams' do + actual = page.all('h3.team').collect { |h3| [h3.text] } + table.raw.should == actual + end +end + +step 'I should have the option of joining the team' do + page.should have_button 'Join team' +end + +step 'I should not have the option of joining the team' do + page.should have_no_button 'Join team' +end + +step ':user_email should be in the team member list' do |user_email| + user = User.find_by_email(user_email) + assert user, "Could not find user by email: #{user_email}" + within '.members' do + page.should have_content user.to_s + end +end + +step ':user_email captains the team :team_name' do |user_email, team_name| + user = User.find_by_email(user_email) + assert user, "Could not find user by email: #{user_email}" + FactoryGirl.create(:team, :name => team_name, :captain => user) +end + diff --git a/spec/acceptance/steps/user_steps.rb b/spec/acceptance/steps/user_steps.rb new file mode 100644 index 0000000..34788fe --- /dev/null +++ b/spec/acceptance/steps/user_steps.rb @@ -0,0 +1,3 @@ +step "a user :email with password :password" do |email, password| + FactoryGirl.create(:user, :email => email, :password => password) +end diff --git a/spec/controllers/maps_controller_spec.example b/spec/controllers/maps_controller_spec.example new file mode 100644 index 0000000..1bcb2bf --- /dev/null +++ b/spec/controllers/maps_controller_spec.example @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe MapsController do + +end diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 0000000..99daa56 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,14 @@ +FactoryGirl.define do + factory :user do + sequence(:email) { |n| "user_#{n}@example.com" } + password 'password' + password_confirmation { password } + first_name 'Michael' + last_name 'Scott' + end + +# factory :team do +# sequence(:name) { |n| "mash it #{n} times" } +# association :captain, :factory => :user +# end +end diff --git a/spec/factories/maps.example b/spec/factories/maps.example new file mode 100644 index 0000000..a7ae7a7 --- /dev/null +++ b/spec/factories/maps.example @@ -0,0 +1,10 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :map do + name "MyString" + creator_id "" + max_teams "" + max_members "" + end +end diff --git a/spec/models/team_membership_spec.example b/spec/models/team_membership_spec.example new file mode 100644 index 0000000..4247fe2 --- /dev/null +++ b/spec/models/team_membership_spec.example @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe TeamMembership do + describe 'membership validations' do + let(:team) { create(:team) } + let(:user) { create(:user) } + + describe 'should require user and team' do + it { should have(1).error_on(:user) } + it { should have(1).error_on(:team) } + end + + it 'should only allow a user to be a member once' do + TeamMembership.create(:user => user, :team => team) + second = TeamMembership.create(:user => user, :team => team) + second.should be_invalid + end + + it 'should not allow a captain to become a member' do + membership = TeamMembership.create(:user => team.captain, :team => team) + membership.should be_invalid + end + end +end diff --git a/spec/models/team_spec.example b/spec/models/team_spec.example new file mode 100644 index 0000000..a780923 --- /dev/null +++ b/spec/models/team_spec.example @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Team do + it 'should have a size of 16 by default' do + subject.max_members.should == 16 + end + + describe 'validations' do + it { should have(2).error_on(:name) } + + context 'name' do + it 'should require atleast 3 characters' do + subject.name = 'hi' + subject.should have(1).error_on(:name) + end + it 'should not allow blank' do + subject.name = '' + subject.should have(2).error_on(:name) + end + it 'should not allow duplicated' do + team = FactoryGirl.create(:team) + subject.name = team.name + subject.should have(1).error_on(:name) + end + end + + context 'max_members' do + it 'should not let it be 0' do + subject.max_members = 0 + subject.should have(1).error_on(:max_members) + end + + it 'should not let it be left empty' do + subject.max_members = '' + subject.should have(2).error_on(:max_members) + end + end + + context 'captain' do + it 'should require a captain' do + subject.should have(1).error_on(:captain) + end + end + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..bf76a41 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe User do + describe 'validations' do + it { should have(1).error_on(:first_name) } + it { should have(1).error_on(:last_name) } + end + +# describe 'is a member of team' do +# let(:user) { create(:user) } +# let(:team) { create(:team) } +# subject { user.is_a_member_of?(team) } + +# context 'it not a member of the team' do +# it { should be_false } +# end + +# context 'is a member of the team already' do +# before { user.teams << team } +# it { should be_true } +# end + +# context 'is the captain of the team' do +# let(:team) { create(:team, :captain => user) } +# it { should be_true } +# end +# end + +end diff --git a/spec/requests/devise/registrations_spec.rb b/spec/requests/devise/registrations_spec.rb new file mode 100644 index 0000000..7ed6a7c --- /dev/null +++ b/spec/requests/devise/registrations_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe "New User Registrations" do + it 'should have a link to sign up on the homepage' do + visit root_path + page.should have_link 'Register' + click_link 'Register' + current_path.should == new_user_registration_path + end + + context 'registration page' do + before do + visit new_user_registration_path + end + it 'should have the additional user fields on the registration page' do + page.should have_field 'First name' + page.should have_field 'Last name' + page.should have_field 'Nickname' + page.should have_field 'Email' + page.should have_field 'Password' + page.should have_field 'Password confirmation' + page.should have_button 'Sign up' + end + + context 'required non-devise fields' do + before do + fill_in 'Email', :with => 'FF@example.com' + fill_in 'Password', :with => 'password' + fill_in 'Password confirmation', :with => 'password' + end + + it 'should require first name' do + fill_in 'Last name', :with => 'Footer' + click_button 'Sign up' + page.should have_content "First name can't be blank" + end + + it 'should require last name' do + fill_in 'First name', :with => 'Frank' + click_button 'Sign up' + page.should have_content "Last name can't be blank" + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..b434b1b --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,119 @@ +require 'rubygems' +require 'spork' +require 'rails' +#uncomment the following line to use spork with the debugger +#require 'spork/ext/ruby-debug' + +Spork.prefork do + # Loading more in this block will cause your tests to run faster. However, + # if you change any configuration or code from libraries loaded here, you'll + # need to restart spork for it take effect. + + #Needed for Devise gem. Delay loading of loading of User model in routes.rb + Spork.trap_method(Rails::Application::RoutesReloader, :reload!) + + + # This file is copied to spec/ when you run 'rails generate rspec:install' + ENV["RAILS_ENV"] ||= 'test' + require File.expand_path("../../config/environment", __FILE__) + require 'rspec/rails' + require 'rspec/autorun' + require 'capybara/rspec' + require 'turnip/capybara' + + # Requires supporting ruby files with custom matchers and macros, etc, + # in spec/support/ and its subdirectories. + Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + + RSpec.configure do |config| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = false + + config.before(:suite) do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with :truncation + end + + config.before(:each) do + if Capybara.current_driver == Capybara.javascript_driver + DatabaseCleaner.strategy = :truncation + else + DatabaseCleaner.strategy = :transaction + end + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + config.include FactoryGirlStepHelpers + config.include FactoryGirl::Syntax::Methods + + #allows :focus tag to only run specific tests + config.treat_symbols_as_metadata_keys_with_true_values = true + config.filter_run :focus => true + config.run_all_when_everything_filtered = true + + end + +end + +Spork.each_run do + # This code will be run each time you run your specs. + + #Reload Factories + #FYI make sure that Factories use strings instead of class constants + FactoryGirl.reload +end + +# --- Instructions --- +# Sort the contents of this file into a Spork.prefork and a Spork.each_run +# block. +# +# The Spork.prefork block is run only once when the spork server is started. +# You typically want to place most of your (slow) initializer code in here, in +# particular, require'ing any 3rd-party gems that you don't normally modify +# during development. +# +# The Spork.each_run block is run each time you run your specs. In case you +# need to load files that tend to change during development, require them here. +# With Rails, your application modules are loaded automatically, so sometimes +# this block can remain empty. +# +# Note: You can modify files loaded *from* the Spork.each_run block without +# restarting the spork server. However, this file itself will not be reloaded, +# so if you change any of the code inside the each_run block, you still need to +# restart the server. In general, if you have non-trivial code in this file, +# it's advisable to move it into a separate file so you can easily edit it +# without restarting spork. (For example, with RSpec, you could move +# non-trivial code into a file spec/support/my_helper.rb, making sure that the +# spec/support/* files are require'd from inside the each_run block.) +# +# Any code that is left outside the two blocks will be run during preforking +# *and* during each_run -- that's probably not what you want. +# +# These instructions should self-destruct in 10 seconds. If they don't, feel +# free to delete them. + + + + + diff --git a/spec/support/factory_girl_step_helpers.rb b/spec/support/factory_girl_step_helpers.rb new file mode 100644 index 0000000..1dd8b70 --- /dev/null +++ b/spec/support/factory_girl_step_helpers.rb @@ -0,0 +1,93 @@ +module FactoryGirlStepHelpers + def convert_human_hash_to_attribute_hash(human_hash, associations = []) + HumanHashToAttributeHash.new(human_hash, associations).attributes + end + + class HumanHashToAttributeHash + attr_reader :associations + + def initialize(human_hash, associations) + @human_hash = human_hash + @associations = associations + end + + def attributes(strategy = CreateAttributes) + @human_hash.inject({}) do |attribute_hash, (human_key, value)| + attributes = strategy.new(self, *process_key_value(human_key, value)) + attribute_hash.merge({ attributes.key => attributes.value }) + end + end + + private + + def process_key_value(key, value) + value = value.strip if value.is_a?(String) + [key.downcase.gsub(' ', '_').to_sym, value] + end + + class AssociationManager + def initialize(human_hash_to_attributes_hash, key, value) + @human_hash_to_attributes_hash = human_hash_to_attributes_hash + @key = key + @value = value + end + + def association + @human_hash_to_attributes_hash.associations.detect {|association| association.name == @key } + end + + def association_instance + return unless association + + if attributes_hash = nested_attribute_hash + factory.build_class.first(:conditions => attributes_hash.attributes(FindAttributes)) or + FactoryGirl.create(association.factory, attributes_hash.attributes) + end + end + + private + + def factory + FactoryGirl.factory_by_name(association.factory) + end + + def nested_attribute_hash + attribute, value = @value.split(':', 2) + return if value.blank? + + HumanHashToAttributeHash.new({ attribute => value }, factory.associations) + end + end + + class AttributeStrategy + attr_reader :key, :value, :association_manager + + def initialize(human_hash_to_attributes_hash, key, value) + @association_manager = AssociationManager.new(human_hash_to_attributes_hash, key, value) + @key = key + @value = value + end + end + + class FindAttributes < AttributeStrategy + def initialize(human_hash_to_attributes_hash, key, value) + super + + if association_manager.association + @key = "#{@key}_id" + @value = association_manager.association_instance.try(:id) + end + end + end + + class CreateAttributes < AttributeStrategy + def initialize(human_hash_to_attributes_hash, key, value) + super + + if association_manager.association + @value = association_manager.association_instance + end + end + end + end +end diff --git a/vendor/assets/javascripts/.gitkeep b/vendor/assets/javascripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/assets/stylesheets/.gitkeep b/vendor/assets/stylesheets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/plugins/.gitkeep b/vendor/plugins/.gitkeep new file mode 100644 index 0000000..e69de29