diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..344f4d7 --- /dev/null +++ b/.env-example @@ -0,0 +1,4 @@ +S3_KEY=INSERT_YOUR_S3_KEY_HERE +S3_SECRET=INSERT_YOUR_S3_SECRET_KEY_HERE + +REDIS_URL=redis://localhost:6379 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e159582 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp + +/config/database.yml +/public/uploads +.env +dump.rdb + +.DS_Store +.ruby-version +.rbenv-version +redis_state.rdb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..83e16f8 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/.ruby-version-example b/.ruby-version-example new file mode 100644 index 0000000..3e3c2f1 --- /dev/null +++ b/.ruby-version-example @@ -0,0 +1 @@ +2.1.1 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..7f53d08 --- /dev/null +++ b/Gemfile @@ -0,0 +1,79 @@ +source 'https://rubygems.org' + +ruby '2.1.6' + +gem 'rails', '~> 4.2' + +# Web +# gem 'unicorn' +# gem 'puma' +# gem 'rails_12factor' # required for heroku applications +gem 'thin' + +# Databases +gem 'pg' +gem 'redis' +gem 'redis-objects' + +# Assets +gem "reimagine2", git: "git@github.com:challengepost/reimagine.git", branch: "master" + +gem 'coffee-rails', '~> 4.0.0' +gem 'compass-rails' +gem 'rack-cors', require: 'rack/cors' +gem 'sass-rails', '~> 4.0.0' +gem 'smusher', require: false +gem 'uglifier', '>= 1.3.0' + +# Authentication +gem 'cancan' +gem 'devise' + +# Views +gem 'kaminari' +gem 'simple_form' + +# Attachments +gem 'carrierwave' +gem 'carrierwave_backgrounder' +gem 'fog', '>= 1.3.1' +gem 'mini_magick' + +# Background +gem 'sidekiq' +gem 'sinatra' # for sidekiq ui + +# Use jQuery as the JavaScript library +gem 'jquery-rails' + +# Monitoring/System +gem 'figleaf' + +# Tracking +gem 'mixpanel' + +# Models +gem 'email_validator' + +group :development, :test do + gem 'factory_girl_rails', '~> 4.0' + gem 'launchy' + gem 'rspec-rails' + gem 'shoulda-matchers' + gem 'steak' + gem 'timecop' + + gem 'pry' + gem 'pry-byebug' + gem 'pry-rails' + gem 'pry-remote' +end + +group :development do + # gem 'rack-livereload' + gem 'foreman' + gem 'guard-livereload' + gem 'rename' # renames your app you can remove after use +end + +gem 'whenever', require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..cef92c1 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,460 @@ +GIT + remote: git@github.com:challengepost/reimagine.git + revision: 6ecfb0c6a238eae145b3bf09a5e7895fa1db6723 + branch: master + specs: + reimagine2 (2.0.55) + coffee-rails + compass-rails + rails + sass-rails + zurb-foundation (~> 4) + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.1) + actionmailer (4.2.3) + actionpack (= 4.2.3) + actionview (= 4.2.3) + activejob (= 4.2.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.3) + actionview (= 4.2.3) + activesupport (= 4.2.3) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.3) + activesupport (= 4.2.3) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.3) + activesupport (= 4.2.3) + globalid (>= 0.3.0) + activemodel (4.2.3) + activesupport (= 4.2.3) + builder (~> 3.1) + activerecord (4.2.3) + activemodel (= 4.2.3) + activesupport (= 4.2.3) + arel (~> 6.0) + activesupport (4.2.3) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.3.8) + arel (6.0.2) + bcrypt (3.1.10) + builder (3.2.2) + byebug (4.0.5) + columnize (= 0.9.0) + cancan (1.6.10) + capybara (2.4.4) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + carrierwave (0.10.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + json (>= 1.7) + mime-types (>= 1.16) + carrierwave_backgrounder (0.4.1) + carrierwave (~> 0.5) + celluloid (0.16.0) + timers (~> 4.0.0) + chronic (0.10.2) + chunky_png (1.3.4) + coderay (1.1.0) + coffee-rails (4.0.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.9.1.1) + columnize (0.9.0) + compass (0.12.7) + chunky_png (~> 1.2) + fssm (>= 0.2.7) + sass (~> 3.2.19) + compass-rails (2.0.0) + compass (>= 0.12.2) + connection_pool (2.2.0) + daemons (1.2.3) + devise (3.5.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) + diff-lcs (1.2.5) + em-websocket (0.5.1) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0.6.0) + email_validator (1.6.0) + activemodel + erubis (2.7.0) + escape (0.0.4) + eventmachine (1.0.7) + excon (0.45.4) + execjs (2.5.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) + ffi (1.9.10) + figleaf (0.0.7) + activesupport + hashie + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.32.0) + fog-atmos + fog-aws (>= 0.6.0) + fog-brightbox (~> 0.4) + fog-core (~> 1.32) + fog-ecloud (= 0.1.1) + fog-google (>= 0.0.2) + fog-json + fog-local + fog-powerdns (>= 0.1.1) + fog-profitbricks + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + nokogiri (~> 1.5, >= 1.5.11) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (0.7.3) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.7.2) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-core (1.32.0) + builder + excon (~> 0.45) + formatador (~> 0.2) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + fog-ecloud (0.1.1) + fog-core + fog-xml + fog-google (0.0.7) + fog-core + fog-json + fog-xml + fog-json (1.0.2) + fog-core (~> 1.0) + multi_json (~> 1.10) + fog-local (0.2.1) + fog-core (~> 1.27) + fog-powerdns (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + fog-profitbricks (0.0.3) + fog-core + fog-xml + nokogiri + fog-radosgw (0.0.4) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.0.1) + fog-core + fog-json + fog-serverlove (0.1.2) + fog-core + fog-json + fog-softlayer (0.4.7) + fog-core + fog-json + fog-storm_on_demand (0.1.1) + fog-core + fog-json + fog-terremark (0.1.0) + fog-core + fog-xml + fog-vmfusion (0.1.0) + fission + fog-core + fog-voxel (0.1.0) + fog-core + fog-xml + fog-xml (0.1.2) + fog-core + nokogiri (~> 1.5, >= 1.5.11) + foreman (0.78.0) + thor (~> 0.19.1) + formatador (0.2.5) + fssm (0.2.10) + globalid (0.3.5) + activesupport (>= 4.1.0) + guard (2.12.8) + formatador (>= 0.2.4) + listen (>= 2.7, <= 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-livereload (2.4.0) + em-websocket (~> 0.5) + guard (~> 2.8) + multi_json (~> 1.8) + hashie (3.4.2) + hike (1.2.3) + hitimes (1.2.2) + http_parser.rb (0.6.0) + httpclient (2.6.0.1) + i18n (0.7.0) + inflecto (0.0.2) + ipaddress (0.8.0) + jquery-rails (4.0.4) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json (1.8.3) + kaminari (0.16.3) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + launchy (2.4.3) + addressable (~> 2.3) + listen (3.0.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + loofah (2.0.2) + nokogiri (>= 1.5.9) + lumberjack (1.0.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + method_source (0.8.2) + mime-types (2.6.1) + mini_magick (4.2.7) + mini_portile (0.6.2) + minitest (5.7.0) + mixpanel (4.1.1) + escape + json + rack + multi_json (1.11.2) + nenv (0.2.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.2) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + notiffany (0.0.6) + nenv (~> 0.1) + shellany (~> 0.0) + orm_adapter (0.5.0) + pg (0.18.2) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.1.0) + byebug (~> 4.0) + pry (~> 0.10) + pry-rails (0.3.4) + pry (>= 0.9.10) + pry-remote (0.1.8) + pry (~> 0.9) + slop (~> 3.0) + rack (1.6.4) + rack-cors (0.4.0) + rack-protection (1.5.3) + rack + rack-test (0.6.3) + rack (>= 1.0) + rails (4.2.3) + actionmailer (= 4.2.3) + actionpack (= 4.2.3) + actionview (= 4.2.3) + activejob (= 4.2.3) + activemodel (= 4.2.3) + activerecord (= 4.2.3) + activesupport (= 4.2.3) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.3) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.6) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.3) + actionpack (= 4.2.3) + activesupport (= 4.2.3) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.4.2) + rb-fsevent (0.9.5) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + redis (3.2.1) + redis-namespace (1.5.2) + redis (~> 3.0, >= 3.0.4) + redis-objects (1.2.0) + redis (>= 3.0.2) + rename (1.0.2) + rails (>= 3.0.0) + responders (2.1.0) + railties (>= 4.2.0, < 5) + rspec-core (3.3.1) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-mocks (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-rails (3.3.2) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) + sass (3.2.19) + sass-rails (4.0.5) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.2) + sprockets (~> 2.8, < 3.0) + sprockets-rails (~> 2.0) + shellany (0.0.1) + shoulda-matchers (2.8.0) + activesupport (>= 3.0.0) + sidekiq (3.4.1) + celluloid (~> 0.16.0) + connection_pool (>= 2.1.1) + json + redis (>= 3.0.6) + redis-namespace (>= 1.3.1) + simple_form (3.1.0) + actionpack (~> 4.0) + activemodel (~> 4.0) + sinatra (1.4.6) + rack (~> 1.4) + rack-protection (~> 1.4) + tilt (>= 1.3, < 3) + slop (3.6.0) + smusher (0.4.9) + httpclient (>= 2.2) + json + rake + sprockets (2.12.4) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.3.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + steak (2.0.0) + capybara (>= 1.0.0) + rspec-rails (>= 2.5.0) + thin (1.6.3) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0) + rack (~> 1.0) + thor (0.19.1) + thread_safe (0.3.5) + tilt (1.4.1) + timecop (0.7.4) + timers (4.0.1) + hitimes + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.7.1) + execjs (>= 0.3.0) + json (>= 1.8.0) + warden (1.2.3) + rack (>= 1.0) + whenever (0.9.4) + chronic (>= 0.6.3) + xpath (2.0.0) + nokogiri (~> 1.3) + zurb-foundation (4.3.2) + sass (>= 3.2.0) + +PLATFORMS + ruby + +DEPENDENCIES + cancan + carrierwave + carrierwave_backgrounder + coffee-rails (~> 4.0.0) + compass-rails + devise + email_validator + factory_girl_rails (~> 4.0) + figleaf + fog (>= 1.3.1) + foreman + guard-livereload + jquery-rails + kaminari + launchy + mini_magick + mixpanel + pg + pry + pry-byebug + pry-rails + pry-remote + rack-cors + rails (~> 4.2) + redis + redis-objects + reimagine2! + rename + rspec-rails + sass-rails (~> 4.0.0) + shoulda-matchers + sidekiq + simple_form + sinatra + smusher + steak + thin + timecop + uglifier (>= 1.3.0) + whenever diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..cbbb723 --- /dev/null +++ b/Guardfile @@ -0,0 +1,8 @@ +guard 'livereload' do + watch(%r{app/views/.+\.(erb|haml|slim)$}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{public/.+\.(css|js|html)}) + watch(%r{config/locales/.+\.yml}) + # Rails Assets Pipeline + watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" } +end diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ebaa25f --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec thin start -R config.ru -p $PORT diff --git a/README.md b/README.md new file mode 100644 index 0000000..796fd66 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +## Description + +Todo Rails Sample App + +## Dependencies + +By default, the dependencies and conventions are: + +- ruby 2.1.6 +- bundler +- postgresql +- redis (for background jobs) +- having "./bin" in your $PATH + +You do not have to use them all but will need to update the project yourself. + +## Instructions + +### Clone the project + + git clone git@github.com:challengepost/todo-rails.git your_project /path/to/new/project + cd /path/to/new/project/ + +### Update dependencies + +If you know right away that you won't need certain gems, update Gemfile + +### Install dependencies + + gem install bundler + bundle install + bundle install --binstubs + +### Setup default database + +- `cp config/database-example.yml config/database.yml` +- update database name and user +- `createuser [new_user] --createdb` # if necessary +- `rake db:create db:migrate` +- `rake db:migrate` +- `rake db:seed` + +### Run tests faster + +Spring will make running your tests faster, but to take advantage of it you need to run it independently (i.e. without `bundle exec`). Install spring gem the old fashioned way + + gem install spring + +### Update configurations + + rake secret + +And place result into config/initializers/secret_token.rb + +**prerequisite:** + +`brew install postgres` or [install and launch Postgres app](http://postgresapp.com/) + +You will probably run into some errors, use these resources to fix them: + +- [`initdb` fatal shared memory error](http://willbryant.net/software/mac_os_x/postgres_initdb_fatal_shared_memory_error_on_leopard) +- [[...] Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?](http://stackoverflow.com/questions/6770649/repairing-postgresql-after-upgrading-to-osx-10-7-lion) +- [[...] Setting SHMMAX etc values on MAC OS X 10.6 for PostgreSQL](http://stackoverflow.com/questions/2017004/setting-shmmax-etc-values-on-mac-os-x-10-6-for-postgresql) + +# Workflow + +1. checkout a feature branch +2. write failing tests +3. write just enough code to make the tests pass +4. push to github (git push origin [branch_name]]) +5. create a pull request +6. get your code reviewed +7. deploy to staging (rake deploy:staging) +8. get your feature reviewed +9. deploy to production + +# Other info + +TODO diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..574ab7a --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +TodoRails::Application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/images/layout/ChallengePost_logo.png b/app/assets/images/layout/ChallengePost_logo.png new file mode 100644 index 0000000..2c0f2f6 Binary files /dev/null and b/app/assets/images/layout/ChallengePost_logo.png differ diff --git a/app/assets/images/layout/ChallengePost_logo@2x.png b/app/assets/images/layout/ChallengePost_logo@2x.png new file mode 100644 index 0000000..373c3b2 Binary files /dev/null and b/app/assets/images/layout/ChallengePost_logo@2x.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..77b1de9 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,19 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require global_nav/update_user +//= require reimagine2 + +new window.Reimagine2() + diff --git a/app/assets/javascripts/apps.js.coffee b/app/assets/javascripts/apps.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/apps.js.coffee @@ -0,0 +1,3 @@ +# 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://coffeescript.org/ diff --git a/app/assets/javascripts/foos.js.coffee b/app/assets/javascripts/foos.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/foos.js.coffee @@ -0,0 +1,3 @@ +# 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://coffeescript.org/ diff --git a/app/assets/javascripts/global_nav/update_user.js b/app/assets/javascripts/global_nav/update_user.js new file mode 100644 index 0000000..5d52538 --- /dev/null +++ b/app/assets/javascripts/global_nav/update_user.js @@ -0,0 +1,9 @@ +$.ajax({ + url: "http://staging.challengepost.com/accounts/current_user.json", + success: function(data) { + $("#global-nav-screen-name").text(data.screen_name); + }, + xhrFields: { + withCredentials: true + } +}); diff --git a/app/assets/javascripts/home.js.coffee b/app/assets/javascripts/home.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/home.js.coffee @@ -0,0 +1,3 @@ +# 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://coffeescript.org/ diff --git a/app/assets/stylesheets/_layout.sass b/app/assets/stylesheets/_layout.sass new file mode 100644 index 0000000..7b66850 --- /dev/null +++ b/app/assets/stylesheets/_layout.sass @@ -0,0 +1,4 @@ +@import 'reimagine2/export' +@import 'layout/global_nav' +@import 'layout/flashes' +@import 'layout/header' diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass new file mode 100644 index 0000000..f0992a5 --- /dev/null +++ b/app/assets/stylesheets/application.sass @@ -0,0 +1,2 @@ +@import 'layout' +@import 'apps' diff --git a/app/assets/stylesheets/apps.css.scss b/app/assets/stylesheets/apps.css.scss new file mode 100644 index 0000000..4345966 --- /dev/null +++ b/app/assets/stylesheets/apps.css.scss @@ -0,0 +1,3 @@ +@import 'home/apps/labels'; +@import 'home/apps/details'; +@import 'home/apps/actions'; diff --git a/app/assets/stylesheets/home.css.scss b/app/assets/stylesheets/home.css.scss new file mode 100644 index 0000000..f0ddc68 --- /dev/null +++ b/app/assets/stylesheets/home.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the home controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/home/apps/actions.sass b/app/assets/stylesheets/home/apps/actions.sass new file mode 100644 index 0000000..872ba8a --- /dev/null +++ b/app/assets/stylesheets/home/apps/actions.sass @@ -0,0 +1,13 @@ +@import "foundation/components/buttons" + +.app-image + margin-bottom: 1em + + img + width: 100% + +.app-links + .app-links-video + background: none + +button-style(#bfbfbf) + diff --git a/app/assets/stylesheets/home/apps/details.sass b/app/assets/stylesheets/home/apps/details.sass new file mode 100644 index 0000000..11164b3 --- /dev/null +++ b/app/assets/stylesheets/home/apps/details.sass @@ -0,0 +1,7 @@ +#app-title + margin-top: 0 + margin-bottom: 0 + +#app-tagline + font-style: italic + diff --git a/app/assets/stylesheets/home/apps/labels.sass b/app/assets/stylesheets/home/apps/labels.sass new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/layout/_flashes.sass b/app/assets/stylesheets/layout/_flashes.sass new file mode 100644 index 0000000..288ca3f --- /dev/null +++ b/app/assets/stylesheets/layout/_flashes.sass @@ -0,0 +1,3 @@ +#flash-messages + .alert-box + margin-bottom: 0 diff --git a/app/assets/stylesheets/layout/_global_nav.sass b/app/assets/stylesheets/layout/_global_nav.sass new file mode 100644 index 0000000..5607d5f --- /dev/null +++ b/app/assets/stylesheets/layout/_global_nav.sass @@ -0,0 +1,3 @@ +#global-nav + position: relative + box-shadow: 0px 1px 3px rgba(0,0,0,0.3) diff --git a/app/assets/stylesheets/layout/_header.sass b/app/assets/stylesheets/layout/_header.sass new file mode 100644 index 0000000..7d970a1 --- /dev/null +++ b/app/assets/stylesheets/layout/_header.sass @@ -0,0 +1,6 @@ +#header + background: $challengepost-dark-grey-background + padding: 2em 0 + + h1 + color: white diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..6ec6a8f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..f6e5155 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,33 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception + + # Send raw event to mixpanel from frontend via javascript + # Allows us to take advantage of mixpanel cookies such as + # google analytics utm tracking + # + def mixpanel_append_track_event(event_title, event_properties = {}) + mixpanel_js_client.append_track(event_title, event_properties) + end + + private + + def mixpanel_js_client + @mixpanel_js_client ||= Mixpanel::Tracker.new( + Figleaf::Settings.mixpanel.api_key, { + persist: true, env: mixpanel_env }) + end + + def mixpanel_env + @mixpanel_env ||= { + 'REMOTE_ADDR' => request.env['REMOTE_ADDR'], + 'HTTP_X_FORWARDED_FOR' => request.env['HTTP_X_FORWARDED_FOR'], + 'rack.session' => request.env['rack.session'], + 'mixpanel_events' => request.env['mixpanel_events'] + } + end + + + +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..cf4a0ea --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def hello + end +end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb new file mode 100644 index 0000000..0031b28 --- /dev/null +++ b/app/controllers/todos_controller.rb @@ -0,0 +1,59 @@ +class TodosController < ApplicationController + before_action :set_todo, only: [:show, :edit, :update, :destroy] + + # GET /todos + def index + @todos = Todo.all + end + + # GET /todos/1 + def show + end + + # GET /todos/new + def new + @todo = Todo.new + end + + # GET /todos/1/edit + def edit + end + + # POST /todos + def create + @todo = Todo.new(todo_params) + + if @todo.save + redirect_to @todo, notice: 'Todo was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /todos/1 + def update + if @todo.update(todo_params) + redirect_to @todo, notice: 'Todo was successfully updated.' + else + render action: 'edit' + end + end + + # DELETE /todos/1 + def destroy + @todo.destroy + redirect_to todos_url, notice: 'Todo was successfully destroyed.' + end + + private + + # Use callbacks to share common setup or constraints between actions. + def set_todo + @todo = Todo.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def todo_params + params.require(:todo).permit(:title) + end +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..23de56a --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb new file mode 100644 index 0000000..cbeb2c4 --- /dev/null +++ b/app/helpers/layout_helper.rb @@ -0,0 +1,28 @@ +# Copied from platform +module LayoutHelper + # Use foundation's data-interchange way of serving responsive images + def responsive_image_tag(image, options = {}) + options[:data] ||= {} + options[:data].merge!(responsive_options(image, options)) + image_tag image, options + end + + def double_density_file_name(file_name, options = {}) + double_density_label = options.delete(:double_density_label) || "@2x" + + extension = File.extname(file_name) + filename = file_name.chomp(extension) + [filename, double_density_label, extension].join + end + + private + + def responsive_options(image, options = {}) + { + interchange: [ + "[#{image_path(image)}, (default)]", + "[#{image_path(double_density_file_name(image, options))}, (retina)]" + ].join(", ") + } + end +end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb new file mode 100644 index 0000000..65ab195 --- /dev/null +++ b/app/helpers/todos_helper.rb @@ -0,0 +1,2 @@ +module TodosHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 0000000..e03bf9b --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,32 @@ +class Ability + include CanCan::Ability + + def initialize(user) + # Define abilities for the passed in user here. For example: + # + # user ||= User.new # guest user (not logged in) + # if user.admin? + # can :manage, :all + # else + # can :read, :all + # end + # + # The first argument to `can` is the action you are giving the user + # permission to do. + # If you pass :manage it will apply to every action. Other common actions + # here are :read, :create, :update and :destroy. + # + # The second argument is the resource the user can perform the action on. + # If you pass :all it will apply to every resource. Otherwise pass a Ruby + # class of the resource. + # + # The third argument is an optional hash of conditions to further filter the + # objects. + # For example, here the user can only update published articles. + # + # can :update, Article, :published => true + # + # See the wiki for details: + # https://github.com/ryanb/cancan/wiki/Defining-Abilities + end +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/todo.rb b/app/models/todo.rb new file mode 100644 index 0000000..8886e9b --- /dev/null +++ b/app/models/todo.rb @@ -0,0 +1,2 @@ +class Todo < ActiveRecord::Base +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..c822027 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable +end diff --git a/app/uploaders/example_photo_uploader.rb b/app/uploaders/example_photo_uploader.rb new file mode 100644 index 0000000..4f4e25a --- /dev/null +++ b/app/uploaders/example_photo_uploader.rb @@ -0,0 +1,52 @@ +# encoding: utf-8 + +class ExamplePhotoUploader < CarrierWave::Uploader::Base + include ::CarrierWave::Backgrounder::Delay + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + # storage :file + storage :fog + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + def scale(width, height) + resize_to_fill width, height + end + + # Create different versions of your uploaded files: + version :thumb do + process :scale => [50, 50] + end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end diff --git a/app/views/home/hello.html.erb b/app/views/home/hello.html.erb new file mode 100644 index 0000000..09a008a --- /dev/null +++ b/app/views/home/hello.html.erb @@ -0,0 +1 @@ +<%= link_to 'go check your todos', todos_path %> diff --git a/app/views/layouts/_default_header.html.erb b/app/views/layouts/_default_header.html.erb new file mode 100644 index 0000000..9cecaf1 --- /dev/null +++ b/app/views/layouts/_default_header.html.erb @@ -0,0 +1 @@ +

Todo Rails

diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb new file mode 100644 index 0000000..8cd566f --- /dev/null +++ b/app/views/layouts/_header.html.erb @@ -0,0 +1,11 @@ + diff --git a/app/views/layouts/_top_bar.html.erb b/app/views/layouts/_top_bar.html.erb new file mode 100644 index 0000000..209c93e --- /dev/null +++ b/app/views/layouts/_top_bar.html.erb @@ -0,0 +1,31 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..82bdfd7 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,52 @@ + + + + + + + <%= favicon_link_tag 'reimagine2/favicon.ico' %> + + + + Todo Rails + + <%= csrf_meta_tags %> + <%= yield :head %> + + <%# + IE7 and old get 0 styles. + #%> + + + <%= stylesheet_link_tag 'reimagine2' %> + <%= stylesheet_link_tag 'application' %> + + + <%# + For now we only use modernizr to add html5 shim to the page (for IE) + If needed, move modernizr to the block above + #%> + + + + + <%= content_tag :body, { id: "body-#{controller_name}", class: 'foundation-grid' } do %> + <%= render "nav/global_nav/global_nav" %> + +
+ <%= render "layouts/header" %> + +
+
+ <%= yield %> +
+
+
+ + <%= render 'reimagine2/challengepost/footer' %> + <%= javascript_include_tag "application" %> + <%= render "layouts/tracking/google" %> + <% end %> + diff --git a/app/views/layouts/tracking/_google.html.erb b/app/views/layouts/tracking/_google.html.erb new file mode 100644 index 0000000..b61823f --- /dev/null +++ b/app/views/layouts/tracking/_google.html.erb @@ -0,0 +1,15 @@ + diff --git a/app/views/nav/global_nav/_account_links.html.erb b/app/views/nav/global_nav/_account_links.html.erb new file mode 100644 index 0000000..0bc5231 --- /dev/null +++ b/app/views/nav/global_nav/_account_links.html.erb @@ -0,0 +1,2 @@ + diff --git a/app/views/nav/global_nav/_drop_down_menus.html.erb b/app/views/nav/global_nav/_drop_down_menus.html.erb new file mode 100644 index 0000000..733374e --- /dev/null +++ b/app/views/nav/global_nav/_drop_down_menus.html.erb @@ -0,0 +1,30 @@ + diff --git a/app/views/nav/global_nav/_global_nav.html.erb b/app/views/nav/global_nav/_global_nav.html.erb new file mode 100644 index 0000000..7402d67 --- /dev/null +++ b/app/views/nav/global_nav/_global_nav.html.erb @@ -0,0 +1,19 @@ + diff --git a/app/views/nav/global_nav/_group_logo.html.erb b/app/views/nav/global_nav/_group_logo.html.erb new file mode 100644 index 0000000..f4b94eb --- /dev/null +++ b/app/views/nav/global_nav/_group_logo.html.erb @@ -0,0 +1,3 @@ + diff --git a/app/views/todos/_form.html.erb b/app/views/todos/_form.html.erb new file mode 100644 index 0000000..27448b3 --- /dev/null +++ b/app/views/todos/_form.html.erb @@ -0,0 +1,5 @@ +<%= simple_form_for @todo do |f| %> + <%= f.input :name %> + + <%= f.submit %> +<% end %> diff --git a/app/views/todos/edit.html.erb b/app/views/todos/edit.html.erb new file mode 100644 index 0000000..032ee08 --- /dev/null +++ b/app/views/todos/edit.html.erb @@ -0,0 +1,6 @@ +

Editing todo

+ +<%= render 'form' %> + +<%= link_to 'Show', @todo %> | +<%= link_to 'Back', todos_path %> diff --git a/app/views/todos/index.html.erb b/app/views/todos/index.html.erb new file mode 100644 index 0000000..59ae3fd --- /dev/null +++ b/app/views/todos/index.html.erb @@ -0,0 +1,27 @@ +

Listing todos

+ + + + + + + + + + + + + <% @todos.each do |todo| %> + + + + + + + <% end %> + +
Name
<%= todo.title %><%= link_to 'Show', todo %><%= link_to 'Edit', edit_todo_path(todo) %><%= link_to 'Destroy', todo, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Todo', new_todo_path %> diff --git a/app/views/todos/new.html.erb b/app/views/todos/new.html.erb new file mode 100644 index 0000000..213bdae --- /dev/null +++ b/app/views/todos/new.html.erb @@ -0,0 +1,5 @@ +

New todo

+ +<%= render 'form' %> + +<%= link_to 'Back', todos_path %> diff --git a/app/views/todos/show.html.erb b/app/views/todos/show.html.erb new file mode 100644 index 0000000..d3a64d7 --- /dev/null +++ b/app/views/todos/show.html.erb @@ -0,0 +1 @@ +<%= @todo.title %> diff --git a/app/workers/example_worker.rb b/app/workers/example_worker.rb new file mode 100644 index 0000000..ccc99bc --- /dev/null +++ b/app/workers/example_worker.rb @@ -0,0 +1,7 @@ +class ExampleWorker + include Sidekiq::Worker + + def perform + # do stuff + end +end diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..5bc2a61 --- /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 Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..04249a9 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,37 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(:default, Rails.env) + +module TodoRails + 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. + config.assets.precompile += %w( reimagine2.css ) + config.assets.precompile += %w( reimagine2.js ) + + # 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 + Figleaf::Settings.configure_with_auto_define do |s| + s.env = Rails.env + s.some_awesome_flag = true + s.load_settings + end + config.middleware.use Mixpanel::Middleware, Figleaf::Settings.mixpanel.api_key, { + insert_mixpanel_scripts: true, + insert_js_last: true, + persist: true, + debug: Figleaf::Settings.mixpanel.debug + } + + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..3596736 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +# 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-example.yml b/config/database-example.yml new file mode 100644 index 0000000..6acd3b9 --- /dev/null +++ b/config/database-example.yml @@ -0,0 +1,31 @@ +development: + adapter: postgresql + encoding: unicode + database: rails_template_development + pool: 5 + username: + password: + +staging: + adapter: postgresql + encoding: unicode + database: rails_template_development + pool: 5 + username: + password: + +test: + adapter: postgresql + encoding: unicode + database: rails_template_test + pool: 5 + username: + password: + +production: + adapter: postgresql + encoding: unicode + database: rails_template_production + pool: 5 + username: + password: diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..0aa9f9b --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +TodoRails::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..9941819 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,36 @@ +TodoRails::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # config.middleware.use Rack::LiveReload + + # 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 + + # Do not eager load code on boot. + config.eager_load = false + + # 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 + config.action_mailer.default_url_options = { :host => 'localhost:3000' } + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.compress = false + config.assets.debug = false + config.sass.style = :debug_info + config.sass.trace_selectors = true + config.sass.debug_info = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..a610ffa --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,80 @@ +TodoRails::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 + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_files = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # 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 = false + + # Set to :debug to see everything in the log. + config.log_level = :info + + # 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 in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # 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 + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..4e12b43 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,36 @@ +TodoRails::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 + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = "public, max-age=3600" + + # 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 + + # 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/carrierwave_backgrounder.rb b/config/initializers/carrierwave_backgrounder.rb new file mode 100644 index 0000000..56591e6 --- /dev/null +++ b/config/initializers/carrierwave_backgrounder.rb @@ -0,0 +1,9 @@ +CarrierWave::Backgrounder.configure do |c| + # c.backend :delayed_job, queue: :carrierwave + # c.backend :resque, queue: :carrierwave + c.backend :sidekiq, queue: :carrierwave + # c.backend :girl_friday, queue: :carrierwave + # c.backend :sucker_punch, queue: :carrierwave + # c.backend :qu, queue: :carrierwave + # c.backend :qc +end diff --git a/config/initializers/carrierwave_fog.rb b/config/initializers/carrierwave_fog.rb new file mode 100644 index 0000000..10db6b8 --- /dev/null +++ b/config/initializers/carrierwave_fog.rb @@ -0,0 +1,16 @@ +CarrierWave.configure do |config| + # config.fog_credentials = { + # :provider => 'AWS', + # :aws_access_key_id => ENV['S3_KEY'], + # :aws_secret_access_key => ENV['S3_SECRET'], + # :region => ENV['S3_REGION'], + # # :host => 'pb.pb.lc', # optional, defaults to nil + # } + # config.fog_directory = "pb.pb.lc" #/#{Rails.application.class.parent_name}" + # config.asset_host = '//pb.pb.lc' # optional, defaults to nilĂ· + # config.fog_public = true + # config.fog_attributes = { # optional, defaults to {} + # 'Cache-Control' => 'max-age=315576000', + # 'Expires' => 10.year.from_now.httpdate + # } +end diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb new file mode 100644 index 0000000..2f828b4 --- /dev/null +++ b/config/initializers/cors.rb @@ -0,0 +1,7 @@ +Rails.application.config.middleware.insert 0, Rack::Cors do + allow do + origins '*.challengepost.com' + resource '/assets/*' + end +end + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..7a75942 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,258 @@ +# 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| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + config.secret_key = 'ec0d96a5976af71fc12e9fdd0bb4d6e17c26ba1e5d43e885b1f2e211e8ccca61f619ede62261a969f9d96a593ea73371d2860dcd83606174d4c1341fdae114e0' + + # ==> 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 = 'please-change-me-at-config-initializers-devise@example.com' + + # Configure the class responsible to send e-mails. + # config.mailer = 'Devise::Mailer' + + # ==> 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 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. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # :token = Support basic authentication with token authentication key + # :token_options = Support token authentication with options as defined in + # http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html + # 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] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # ==> 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 = '62855ddd5ac61fb833a7b3f586b42be6ae43edf61ea79924f5e43f122e10b7cce16906bbd2d7c971d6db2e951017c6255882e3681eb3f0f508a24752a2231abb' + + # ==> 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 + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly 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 + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 8..128. + config.password_length = 8..128 + + # Email regex used to validate email formats. It simply asserts that + # 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 + + # If true, expires auth token on session timeout. + # config.expire_auth_token_on_timeout = false + + # ==> 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). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # 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 + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all 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 + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using omniauth, Devise cannot automatically set Omniauth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' +end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) 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(:en) 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/mixpanel.rb b/config/initializers/mixpanel.rb new file mode 100644 index 0000000..ea9057e --- /dev/null +++ b/config/initializers/mixpanel.rb @@ -0,0 +1 @@ +@mixpanel = Mixpanel::Tracker.new Figleaf::Settings.mixpanel.api_key diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 0000000..500c2aa --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used 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. +# You can use `rake secret` to generate a secure secret key. + +# Make sure your secret_key_base is kept private +# if you're sharing your code publicly. +TodoRails::Application.config.secret_key_base = 'b4d1626dfffbc82d7f982e7083984c4eec66e1bd9a14f2eb4ee97282dd16d7a0d5261e1d9bf26c27cca8b4b9e6ac20fccc55f61e006adc2ecf56dedeb7e7a0b9' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..be779bd --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +TodoRails::Application.config.session_store :cookie_store, key: '_gallery_session' diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 0000000..1a13f4d --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,13 @@ +Sidekiq.configure_server do |config| + config.redis = { + url: ENV['REDIS_URL'], + namespace: 'example_app:sidekiq' + } +end + +Sidekiq.configure_client do |config| + config.redis = { + url: ENV['REDIS_URL'], + namespace: 'example_app:sidekiq' + } +end diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 0000000..d5492e5 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,166 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => true` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + + ## full_messages_for + # If you want to display the full error message for the attribute, you can + # use the component :full_error, like: + # + # b.use :full_error, wrap_with: { tag: :span, class: :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'error_notification' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. Please note that when using :boolean_style = :nested, + # SimpleForm will force this option to be a label. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + # config.label_class = nil + + # You can define the default class to be used on forms. Can be overriden + # with `html: { :class }`. Defaulting to none. + # config.default_form_class = nil + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { string: :prepend } + + # Namespaces where SimpleForm should look for custom input classes that + # override default inputs. + # config.custom_inputs_namespaces << "CustomInputs" + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil + + # Define the default class of the input wrapper of the boolean input. + config.boolean_label_class = 'checkbox' + + # Defines if the default input wrapper class should be included in radio + # collection wrappers. + # config.include_default_input_wrapper_class = true + + # Defines which i18n scope will be used in Simple Form. + # config.i18n_scope = 'simple_form' +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /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] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..d5b4520 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,60 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your account was successfully confirmed." + confirmed_and_signed_in: "Your account was successfully confirmed. You are now signed in." + send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account is not activated yet." + invalid: "Invalid email or password." + invalid_token: "Invalid authentication token." + locked: "Your account is locked." + not_found_in_database: "Invalid email or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your account before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock Instructions" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password was changed successfully. You are now signed in." + updated_not_active: "Your password was changed successfully." + registrations: + destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + 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." + 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." + 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." + updated: "You updated your account successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + 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:" diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml new file mode 100644 index 0000000..2374383 --- /dev/null +++ b/config/locales/simple_form.en.yml @@ -0,0 +1,31 @@ +en: + simple_form: + "yes": 'Yes' + "no": 'No' + required: + text: 'required' + mark: '*' + # You can uncomment the line below if you need to overwrite the whole required html. + # When using html, text and mark won't be used. + # html: '*' + error_notification: + default_message: "Please review the problems below:" + # Examples + # labels: + # defaults: + # password: 'Password' + # user: + # new: + # email: 'E-mail to sign in.' + # edit: + # email: 'E-mail.' + # hints: + # defaults: + # username: 'User name to sign in.' + # password: 'No special characters, please.' + # include_blanks: + # defaults: + # age: 'Rather not say' + # prompts: + # defaults: + # age: 'Select your age' diff --git a/config/redis/redis.conf b/config/redis/redis.conf new file mode 100644 index 0000000..b95210b --- /dev/null +++ b/config/redis/redis.conf @@ -0,0 +1,2 @@ +daemonize no +save 10 10 diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..a2a2583 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,11 @@ +require 'sidekiq/web' + +TodoRails::Application.routes.draw do + resources :foos + resources :todos + + devise_for :users + + mount Sidekiq::Web => '/sidekiq' + root to: 'home#hello' +end diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 0000000..de75cf9 --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,20 @@ +# Use this file to easily define all of your cron jobs. +# +# It's helpful, but not entirely necessary to understand cron before proceeding. +# http://en.wikipedia.org/wiki/Cron + +# Example: +# +# set :output, "/path/to/my/cron_log.log" +# +# every 2.hours do +# command "/usr/bin/some_great_command" +# runner "MyModel.some_method" +# rake "some:great:rake:task" +# end +# +# every 4.days do +# runner "AnotherModel.prune_old_records" +# end + +# Learn more: http://github.com/javan/whenever diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000..00e86c7 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,11 @@ +development: + secret_key_base: 9ac2d0ad8ebcc312090e99d745006d3cf8 + +test: + secret_key_base: a1580ad61ccb6ac60f9f256948cf63d6e20 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + pusher_url: <%= ENV["PUSHER_URL"] %> diff --git a/config/settings/domain.yml b/config/settings/domain.yml new file mode 100644 index 0000000..d1e1a57 --- /dev/null +++ b/config/settings/domain.yml @@ -0,0 +1,66 @@ +development: &LOCAL + root: platform.dev + secure: secure.platform.dev + manage: manage.platform.dev + gov: challengegov.dev + email: challengepost.com + api: api.platform.dev + editor: editor.platform.dev + post: post.platform.dev + clients: + - editor.platform.dev + - editor.dummy.dev + - platform.dev + +test: + <<: *LOCAL + +profile: + <<: *LOCAL + +staging: + root: staging.challengepost.com + secure: secure.staging.challengepost.com + manage: manage.staging.challengepost.com + gov: staging.challenge.gov + email: challengepost.com + api: stagingapi.challengepost.com + editor: editor.staging.challengepost.com + post: post.staging.challengepost.com + clients: + - editor.staging.challengepost.com + - editor.starship.challengepost.com + - editor.staging.challengepost.com.s3-website-us-east-1.amazonaws.com + - editor.platform.dev + - editor.dummy.dev + - staging.challengepost.com + +princess: + root: princess.challengepost.com + secure: secure.princess.challengepost.com + manage: manage.princess.challengepost.com + gov: princess.challenge.gov + email: challengepost.com + api: princessapi.challengepost.com + editor: editor.princess.challengepost.com + post: post.staging.challengepost.com + clients: + - editor.platform.dev + - editor.dummy.dev + - princess.challengepost.com + +production: + root: challengepost.com + secure: secure.challengepost.com + manage: manage.challengepost.com + gov: challenge.gov + email: challengepost.com + api: api.challengepost.com + editor: editor.challengepost.com + post: post.challengepost.com + clients: + - editor.challengepost.com + - editor.challengepost.com.s3-website-us-east-1.amazonaws.com + - editor.platform.dev + - editor.dummy.dev + - challengepost.com diff --git a/config/settings/google_analytics.yml b/config/settings/google_analytics.yml new file mode 100644 index 0000000..2c809aa --- /dev/null +++ b/config/settings/google_analytics.yml @@ -0,0 +1,23 @@ +disabled: &disabled + ua_code: UA-global + +default: &default + ua_code: UA-2233558-21 + +development: + <<: *default + +staging: + <<: *default + +princess: + <<: *default + +test: + <<: *disabled + +profile: + <<: *default + +production: + <<: *default diff --git a/config/settings/mixpanel.yml b/config/settings/mixpanel.yml new file mode 100644 index 0000000..a1a9fda --- /dev/null +++ b/config/settings/mixpanel.yml @@ -0,0 +1,29 @@ +test: + api_key: 'testing' + enabled: false + debug: false + +# Enable in development.local.rb to send events to +# send events to the development project in mixpanel +development: &development + api_key: '3b2796f70555eccef4053f3048f1ec50' + debug: true + enabled: false + +profile: + <<: *development + +staging: &staging + api_key: 'f0f3b6adaf6919bee2b8b638bc7db39b' + debug: true + enabled: true + +princess: + api_key: '2ccea32b28ca3f90d6f60ded9e491ad1' + debug: true + enabled: true + +production: + api_key: '1c828346e9fae00dbc3a117657f65895' + debug: false + enabled: true diff --git a/config/sidekiq.yml b/config/sidekiq.yml new file mode 100644 index 0000000..2d4ee72 --- /dev/null +++ b/config/sidekiq.yml @@ -0,0 +1,10 @@ +# Sample configuration file for Sidekiq. +# Options here can still be overridden by cmd line args. +# sidekiq -C config.yml +--- +:verbose: true +:pidfile: ./tmp/pids/sidekiq.pid +:concurrency: 25 +:queues: + - [default, 5] + - [carrierwave, 3] diff --git a/db/migrate/20131006230600_devise_create_users.rb b/db/migrate/20131006230600_devise_create_users.rb new file mode 100644 index 0000000..ab71c3d --- /dev/null +++ b/db/migrate/20131006230600_devise_create_users.rb @@ -0,0 +1,42 @@ +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, :null => false + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## 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, :null => false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + 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 + end +end diff --git a/db/migrate/20150714225535_create_todos.rb b/db/migrate/20150714225535_create_todos.rb new file mode 100644 index 0000000..faf9336 --- /dev/null +++ b/db/migrate/20150714225535_create_todos.rb @@ -0,0 +1,7 @@ +class CreateTodos < ActiveRecord::Migration + def change + create_table :todos do |t| + t.string :title + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..9c2bdb6 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,41 @@ +# 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 that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20150714225535) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "todos", force: :cascade do |t| + t.string "title" + end + + create_table "users", force: :cascade 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, null: false + 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" + t.datetime "updated_at" + end + + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..44a6a52 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,32 @@ +# 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) + +users = [ + { email: 'matthew@exmple.com', password: 'password', password_confirmation: 'password' }, + { email: 'robin@exmple.com', password: 'password', password_confirmation: 'password' }, + { email: 'ross@exmple.com', password: 'password', password_confirmation: 'password' }, +] + +users.each do |attrs| + user = User.find_or_create_by(email: attrs[:email]) do |u| + u.attributes = attrs + end + + user.save +end + +todos = [ + { title: "Build a todo app" }, + { title: "Write blog post" }, + { title: "Send email to boss" }, + { title: "Attend Ruby meetup" } +] + +todos.each do |attrs| + Todo.find_or_create_by(title: attrs[:title]) +end diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/deploy.rake b/lib/tasks/deploy.rake new file mode 100644 index 0000000..f9ae73a --- /dev/null +++ b/lib/tasks/deploy.rake @@ -0,0 +1,15 @@ +namespace :deploy do + def makefile_path + File.expand_path("../../../scripts/deploy.make", __FILE__) + end + + desc "deploys current branch to staging" + task :staging do + system "make -f #{makefile_path} staging" + end + + desc "deploys local master to production" + task :production do + system "make -f #{makefile_path} production" + end +end diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb new file mode 100644 index 0000000..201a069 --- /dev/null +++ b/lib/templates/erb/scaffold/_form.html.erb @@ -0,0 +1,13 @@ +<%%= simple_form_for(@<%= singular_table_name %>) do |f| %> + <%%= f.error_notification %> + +
+ <%- attributes.each do |attribute| -%> + <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> + <%- end -%> +
+ +
+ <%%= f.button :submit %> +
+<%% end %> diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..a0daa0c --- /dev/null +++ b/public/404.html @@ -0,0 +1,58 @@ + + + + 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.

+
+

If you are the application owner check the logs for more information.

+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..fbb4b84 --- /dev/null +++ b/public/422.html @@ -0,0 +1,58 @@ + + + + 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.

+
+

If you are the application owner check the logs for more information.

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

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+ + 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..1a3a5e4 --- /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/scripts/deploy.make b/scripts/deploy.make new file mode 100644 index 0000000..b666c3a --- /dev/null +++ b/scripts/deploy.make @@ -0,0 +1,34 @@ +STAGING_REMOTE_NAME := heroku_staging +PRODUCTION_REMOTE_NAME := heroku_production +CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) + +all: + echo 'nope' + +staging: merge_current_branch_to_staging deploy_staging + +production: checkout_master pull_master deploy_production + +deploy_staging: back_to_branch + git push --force $(STAGING_REMOTE_NAME) staging:master + +deploy_production: + git push $(PRODUCTION_REMOTE_NAME) master + +merge_current_branch_to_staging: ensure_staging_branch_exists + git checkout staging + git pull origin staging + git merge $(CURRENT_BRANCH) --no-edit + git push origin staging + +ensure_staging_branch_exists: + -git branch staging + +back_to_branch: + git checkout $(CURRENT_BRANCH) + +checkout_master: + git checkout master + +pull_master: + git pull --rebase origin master diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb new file mode 100644 index 0000000..71946ad --- /dev/null +++ b/spec/acceptance/acceptance_helper.rb @@ -0,0 +1,4 @@ +require 'spec_helper' + +# Put your acceptance spec helpers inside spec/acceptance/support +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} \ No newline at end of file diff --git a/spec/acceptance/support/helpers.rb b/spec/acceptance/support/helpers.rb new file mode 100644 index 0000000..ed4c0e0 --- /dev/null +++ b/spec/acceptance/support/helpers.rb @@ -0,0 +1,6 @@ +module HelperMethods + # Put helper methods you need to be available in all acceptance specs here. + +end + +RSpec.configuration.include HelperMethods, :type => :acceptance \ No newline at end of file diff --git a/spec/acceptance/support/paths.rb b/spec/acceptance/support/paths.rb new file mode 100644 index 0000000..e3b8307 --- /dev/null +++ b/spec/acceptance/support/paths.rb @@ -0,0 +1,9 @@ +module NavigationHelpers + # Put helper methods related to the paths in your application here. + + def homepage + "/" + end +end + +RSpec.configuration.include NavigationHelpers, :type => :acceptance \ No newline at end of file diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb new file mode 100644 index 0000000..386a314 --- /dev/null +++ b/spec/controllers/home_controller_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +RSpec.describe HomeController, type: :controller do + + describe "GET 'hello'" do + it "returns http success" do + get 'hello' + expect(response).to be_success + end + end +end diff --git a/spec/controllers/todos_controller_spec.rb b/spec/controllers/todos_controller_spec.rb new file mode 100644 index 0000000..55de39b --- /dev/null +++ b/spec/controllers/todos_controller_spec.rb @@ -0,0 +1,142 @@ +require 'rails_helper' + +RSpec.describe TodosController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Todo. As you add validations to Todo, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { { "title" => "Build a working Todo app" } } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # TodosController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET index" do + it "assigns all todos as @todos" do + todo = Todo.create! valid_attributes + get :index, {}, valid_session + expect(assigns(:todos)).to eq([todo]) + end + end + + describe "GET show" do + it "assigns the requested todo as @todo" do + todo = Todo.create! valid_attributes + get :show, {:id => todo.to_param}, valid_session + expect(assigns(:todo)).to eq(todo) + end + end + + describe "GET new" do + it "assigns a new todo as @todo" do + get :new, {}, valid_session + expect(assigns(:todo)).to be_a_new(Todo) + end + end + + describe "GET edit" do + it "assigns the requested todo as @todo" do + todo = Todo.create! valid_attributes + get :edit, {:id => todo.to_param}, valid_session + expect(assigns(:todo)).to eq(todo) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Todo" do + expect { + post :create, {:todo => valid_attributes}, valid_session + }.to change(Todo, :count).by(1) + end + + it "assigns a newly created todo as @todo" do + post :create, {:todo => valid_attributes}, valid_session + expect(assigns(:todo)).to be_a(Todo) + expect(assigns(:todo)).to be_persisted + end + + it "redirects to the created todo" do + post :create, {:todo => valid_attributes}, valid_session + expect(response).to redirect_to(Todo.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved todo as @todo" do + # Trigger the behavior that occurs when invalid params are submitted + allow_any_instance_of(Todo).to receive(:save).and_return(false) + post :create, {:todo => { "title" => "invalid value" }}, valid_session + expect(assigns(:todo)).to be_a_new(Todo) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + allow_any_instance_of(Todo).to receive(:save).and_return(false) + post :create, {:todo => { "title" => "invalid value" }}, valid_session + expect(response).to render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested todo" do + todo = Todo.create! valid_attributes + # Assuming there are no other todos in the database, this + # specifies that the Todo created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + allow_any_instance_of(Todo).to receive(:update).with({ "title" => "MyString" }) + put :update, {:id => todo.to_param, :todo => { "title" => "MyString" }}, valid_session + end + + it "assigns the requested todo as @todo" do + todo = Todo.create! valid_attributes + put :update, {:id => todo.to_param, :todo => valid_attributes}, valid_session + expect(assigns(:todo)).to eq(todo) + end + + it "redirects to the todo" do + todo = Todo.create! valid_attributes + put :update, {:id => todo.to_param, :todo => valid_attributes}, valid_session + expect(response).to redirect_to(todo) + end + end + + describe "with invalid params" do + it "assigns the todo as @todo" do + todo = Todo.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + allow_any_instance_of(Todo).to receive(:save).and_return(false) + put :update, {:id => todo.to_param, :todo => { "title" => "invalid value" }}, valid_session + expect(assigns(:todo)).to eq(todo) + end + + it "re-renders the 'edit' template" do + todo = Todo.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + allow_any_instance_of(Todo).to receive(:save).and_return(false) + put :update, {:id => todo.to_param, :todo => { "title" => "invalid value" }}, valid_session + expect(response).to render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested todo" do + todo = Todo.create! valid_attributes + expect { + delete :destroy, {:id => todo.to_param}, valid_session + }.to change(Todo, :count).by(-1) + end + + it "redirects to the todos list" do + todo = Todo.create! valid_attributes + delete :destroy, {:id => todo.to_param}, valid_session + expect(response).to redirect_to(todos_url) + end + end + +end diff --git a/spec/factories/todos.rb b/spec/factories/todos.rb new file mode 100644 index 0000000..47d2471 --- /dev/null +++ b/spec/factories/todos.rb @@ -0,0 +1,7 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :todo do + title "Finish writing OKRs" + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 0000000..26b30ef --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :user do + end +end diff --git a/spec/helpers/home_helper_spec.rb b/spec/helpers/home_helper_spec.rb new file mode 100644 index 0000000..e8629a1 --- /dev/null +++ b/spec/helpers/home_helper_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe HomeHelper, type: :helper do +# pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb new file mode 100644 index 0000000..b36cf20 --- /dev/null +++ b/spec/helpers/todos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TodosHelper. For example: +# +# describe TodosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe TodosHelper, type: :helper do + # pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb new file mode 100644 index 0000000..d0d67b4 --- /dev/null +++ b/spec/models/todo_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe Todo, type: :model do +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..4c00bde --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,4 @@ +require 'spec_helper' + +RSpec.describe User, type: :model do +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..88ff2d0 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,52 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'spec_helper' +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migrations before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # 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 = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! +end diff --git a/spec/requests/todos_spec.rb b/spec/requests/todos_spec.rb new file mode 100644 index 0000000..e6c6c18 --- /dev/null +++ b/spec/requests/todos_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "Todos", type: :request do + describe "GET /todos" do + it "is a success" do + get todos_path + expect(response.status).to be(200) + end + end +end diff --git a/spec/routing/todos_routing_spec.rb b/spec/routing/todos_routing_spec.rb new file mode 100644 index 0000000..8e5d12c --- /dev/null +++ b/spec/routing/todos_routing_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe TodosController, type: :routing do + describe "routing" do + + it "routes to #index" do + expect(get("/todos")).to route_to("todos#index") + end + + it "routes to #new" do + expect(get("/todos/new")).to route_to("todos#new") + end + + it "routes to #show" do + expect(get("/todos/1")).to route_to("todos#show", :id => "1") + end + + it "routes to #edit" do + expect(get("/todos/1/edit")).to route_to("todos#edit", :id => "1") + end + + it "routes to #create" do + expect(post("/todos")).to route_to("todos#create") + end + + it "routes to #update" do + expect(put("/todos/1")).to route_to("todos#update", :id => "1") + end + + it "routes to #destroy" do + expect(delete("/todos/1")).to route_to("todos#destroy", :id => "1") + end + + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..913e28a --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,92 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29