From 71907016fbdf81323c35d15e0b83524efcf80e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Wed, 28 Sep 2016 14:01:44 -0700 Subject: [PATCH 01/16] set up rails app --- .gitignore | 46 ++--- .ruby-gemset | 1 - .ruby-version | 1 - Gemfile | 47 +++++ Gemfile.lock | 163 ++++++++++++++++++ README.rdoc | 28 +++ Rakefile | 6 + app/assets/images/.keep | 0 app/assets/javascripts/application.js | 16 ++ app/assets/stylesheets/application.css | 15 ++ app/controllers/application_controller.rb | 5 + app/controllers/concerns/.keep | 0 app/helpers/application_helper.rb | 2 + app/mailers/.keep | 0 app/models/.keep | 0 app/models/concerns/.keep | 0 app/views/layouts/application.html.erb | 14 ++ bin/bundle | 3 + bin/rails | 9 + bin/rake | 9 + bin/setup | 29 ++++ bin/spring | 15 ++ config.ru | 4 + config/application.rb | 26 +++ config/boot.rb | 3 + config/database.yml | 25 +++ config/environment.rb | 5 + config/environments/development.rb | 41 +++++ config/environments/production.rb | 79 +++++++++ config/environments/test.rb | 42 +++++ config/initializers/assets.rb | 11 ++ config/initializers/backtrace_silencers.rb | 7 + config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + config/initializers/inflections.rb | 16 ++ config/initializers/mime_types.rb | 4 + config/initializers/session_store.rb | 3 + config/initializers/wrap_parameters.rb | 14 ++ config/locales/en.yml | 23 +++ config/routes.rb | 56 ++++++ config/secrets.yml | 22 +++ db/seeds.rb | 7 + lib/assets/.keep | 0 lib/tasks/.keep | 0 log/.keep | 0 public/404.html | 67 +++++++ public/422.html | 67 +++++++ public/500.html | 66 +++++++ public/favicon.ico | 0 public/robots.txt | 5 + test/controllers/.keep | 0 test/fixtures/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/test_helper.rb | 10 ++ vendor/assets/javascripts/.keep | 0 vendor/assets/stylesheets/.keep | 0 59 files changed, 985 insertions(+), 34 deletions(-) delete mode 100644 .ruby-gemset delete mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/assets/images/.keep create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/helpers/application_helper.rb create mode 100644 app/mailers/.keep create mode 100644 app/models/.keep create mode 100644 app/models/concerns/.keep create mode 100644 app/views/layouts/application.html.erb create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/setup create mode 100755 bin/spring create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/session_store.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/en.yml create mode 100644 config/routes.rb create mode 100644 config/secrets.yml create mode 100644 db/seeds.rb create mode 100644 lib/assets/.keep create mode 100644 lib/tasks/.keep create mode 100644 log/.keep create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/favicon.ico create mode 100644 public/robots.txt create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/test_helper.rb create mode 100644 vendor/assets/javascripts/.keep create mode 100644 vendor/assets/stylesheets/.keep diff --git a/.gitignore b/.gitignore index 28f484983..050c9d95c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,17 @@ -*.gem -*.rbc -/.config -/coverage/ -/InstalledFiles -/pkg/ -/spec/reports/ -/test/tmp/ -/test/version_tmp/ -/tmp/ +# 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' -## Specific to RubyMotion: -.dat* -.repl_history -build/ +# Ignore bundler config. +/.bundle -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal -## Environment normalisation: -/.bundle/ -/vendor/bundle -/lib/bundler/man/ - -# for a library or gem, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# Gemfile.lock -# .ruby-version -# .ruby-gemset - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -.rvmrc +# Ignore all logfiles and tempfiles. +/log/* +!/log/.keep +/tmp diff --git a/.ruby-gemset b/.ruby-gemset deleted file mode 100644 index 5d2410e51..000000000 --- a/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -TaskListRails diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 276cbf9e2..000000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.3.0 diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..e87fad5fc --- /dev/null +++ b/Gemfile @@ -0,0 +1,47 @@ +source 'https://rubygems.org' + + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.2.7' +# Use sqlite3 as the database for Active Record +gem 'sqlite3' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.1.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.0' +# bundle exec rake doc:rails generates the API under doc/api. +gem 'sdoc', '~> 0.4.0', group: :doc + +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Unicorn as the app server +# gem 'unicorn' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug' +end + +group :development do + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' + + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' +end + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..187046034 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,163 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.2.7) + actionpack (= 4.2.7) + actionview (= 4.2.7) + activejob (= 4.2.7) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.7) + actionview (= 4.2.7) + activesupport (= 4.2.7) + 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.7) + activesupport (= 4.2.7) + 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.7) + activesupport (= 4.2.7) + globalid (>= 0.3.0) + activemodel (4.2.7) + activesupport (= 4.2.7) + builder (~> 3.1) + activerecord (4.2.7) + activemodel (= 4.2.7) + activesupport (= 4.2.7) + arel (~> 6.0) + activesupport (4.2.7) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + arel (6.0.3) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + builder (3.2.2) + byebug (9.0.5) + coffee-rails (4.1.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.1.x) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.10.0) + concurrent-ruby (1.0.2) + debug_inspector (0.0.2) + erubis (2.7.0) + execjs (2.7.0) + globalid (0.3.7) + activesupport (>= 4.1.0) + i18n (0.7.0) + jbuilder (2.6.0) + activesupport (>= 3.0.0, < 5.1) + multi_json (~> 1.2) + jquery-rails (4.2.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json (1.8.3) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.1.0) + minitest (5.9.1) + multi_json (1.12.1) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) + pkg-config (1.1.7) + rack (1.6.4) + rack-test (0.6.3) + rack (>= 1.0) + rails (4.2.7) + actionmailer (= 4.2.7) + actionpack (= 4.2.7) + actionview (= 4.2.7) + activejob (= 4.2.7) + activemodel (= 4.2.7) + activerecord (= 4.2.7) + activesupport (= 4.2.7) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.7) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (4.2.7) + actionpack (= 4.2.7) + activesupport (= 4.2.7) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (11.3.0) + rdoc (4.2.2) + json (~> 1.4) + sass (3.4.22) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) + spring (1.7.2) + sprockets (3.7.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.11) + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.5) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (3.0.2) + execjs (>= 0.3.0, < 3) + web-console (2.3.0) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) + +PLATFORMS + ruby + +DEPENDENCIES + byebug + coffee-rails (~> 4.1.0) + jbuilder (~> 2.0) + jquery-rails + rails (= 4.2.7) + sass-rails (~> 5.0) + sdoc (~> 0.4.0) + spring + sqlite3 + turbolinks + uglifier (>= 1.3.0) + web-console (~> 2.0) + +BUNDLED WITH + 1.13.1 diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 000000000..dd4e97e22 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..ba6b733dd --- /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__) + +Rails.application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..e07c5a830 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// 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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 000000000..f9cd5b348 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 000000000..d83690e1b --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +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 +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 000000000..46eeb110b --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + TaskListRails + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 000000000..66e9889e8 --- /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 000000000..0138d79b7 --- /dev/null +++ b/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +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 000000000..d87d5f578 --- /dev/null +++ b/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000..acdb2c138 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/bin/spring b/bin/spring new file mode 100755 index 000000000..7fe232c3a --- /dev/null +++ b/bin/spring @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) + Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } + gem 'spring', match[1] + require 'spring/binstub' + end +end diff --git a/config.ru b/config.ru new file mode 100644 index 000000000..bd83b2541 --- /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 000000000..902432bad --- /dev/null +++ b/config/application.rb @@ -0,0 +1,26 @@ +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(*Rails.groups) + +module TaskListRails + 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. + + # 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 + + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 000000000..6b750f00b --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 000000000..1c1a37ca8 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 000000000..ee8d90dc6 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 000000000..b55e2144b --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,41 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # 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 + + # 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.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 000000000..5c1b32e48 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,79 @@ +Rails.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 threaded 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 serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # 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 + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # 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 cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 000000000..1c19f08b2 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.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 file 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 + + # Randomize the order test cases are executed. + config.active_support.test_order = :random + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 000000000..01ef3e663 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /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/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..7f70458de --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /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 000000000..ac033bf9d --- /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 000000000..dc1899682 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# 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 diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 000000000..15d065a84 --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_TaskListRails_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..33725e95f --- /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/en.yml b/config/locales/en.yml new file mode 100644 index 000000000..065395716 --- /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/routes.rb b/config/routes.rb new file mode 100644 index 000000000..3f66539d5 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 000000000..6acbbfdaf --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# 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 the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 9eb881ffb80af2dbbfe6938e7a06db62d2158361c314a4840abfa48c8639ac879b1d5921f4af7cb13cd0410801dc5de78effc6611521338938a76144b133275f + +test: + secret_key_base: 1f0ac7f1b8144fbdc483add5b844ea6a9f5905727033e4c1da9bbda146a45d813d9042d5d380f6471165829d08ddd2b4a64aa37d830648a219e85e58961088d4 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 000000000..4edb1e857 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# 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) diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/log/.keep b/log/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/public/404.html b/public/404.html new file mode 100644 index 000000000..b612547fc --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + 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 000000000..a21f82b3b --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + 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 000000000..061abc587 --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + 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 000000000..e69de29bb diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 000000000..3c9c7c01f --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.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/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 000000000..92e39b2d7 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 000000000..e69de29bb From c6ada195186a3c5eccdebc226a416fc5f79a0854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Wed, 28 Sep 2016 14:21:49 -0700 Subject: [PATCH 02/16] Created Tasts controller --- app/assets/javascripts/tasks.coffee | 3 ++ app/assets/stylesheets/tasks.scss | 3 ++ app/controllers/tasks_controller.rb | 19 +++++++++++++ app/helpers/tasks_helper.rb | 2 ++ app/views/tasks/destroy.html.erb | 2 ++ app/views/tasks/edit.html.erb | 2 ++ app/views/tasks/index.html.erb | 2 ++ app/views/tasks/new.html.erb | 2 ++ app/views/tasks/show.html.erb | 2 ++ app/views/tasks/update.html.erb | 2 ++ config/routes.rb | 12 ++++++++ test/controllers/tasks_controller_test.rb | 34 +++++++++++++++++++++++ 12 files changed, 85 insertions(+) create mode 100644 app/assets/javascripts/tasks.coffee create mode 100644 app/assets/stylesheets/tasks.scss create mode 100644 app/controllers/tasks_controller.rb create mode 100644 app/helpers/tasks_helper.rb create mode 100644 app/views/tasks/destroy.html.erb create mode 100644 app/views/tasks/edit.html.erb create mode 100644 app/views/tasks/index.html.erb create mode 100644 app/views/tasks/new.html.erb create mode 100644 app/views/tasks/show.html.erb create mode 100644 app/views/tasks/update.html.erb create mode 100644 test/controllers/tasks_controller_test.rb diff --git a/app/assets/javascripts/tasks.coffee b/app/assets/javascripts/tasks.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/tasks.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/tasks.scss b/app/assets/stylesheets/tasks.scss new file mode 100644 index 000000000..c5e7712d4 --- /dev/null +++ b/app/assets/stylesheets/tasks.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Tasks controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb new file mode 100644 index 000000000..4e0a3c5df --- /dev/null +++ b/app/controllers/tasks_controller.rb @@ -0,0 +1,19 @@ +class TasksController < ApplicationController + def index + end + + def show + end + + def new + end + + def edit + end + + def update + end + + def destroy + end +end diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb new file mode 100644 index 000000000..ce894d00c --- /dev/null +++ b/app/helpers/tasks_helper.rb @@ -0,0 +1,2 @@ +module TasksHelper +end diff --git a/app/views/tasks/destroy.html.erb b/app/views/tasks/destroy.html.erb new file mode 100644 index 000000000..a90559f9d --- /dev/null +++ b/app/views/tasks/destroy.html.erb @@ -0,0 +1,2 @@ +

Tasks#destroy

+

Find me in app/views/tasks/destroy.html.erb

diff --git a/app/views/tasks/edit.html.erb b/app/views/tasks/edit.html.erb new file mode 100644 index 000000000..374190308 --- /dev/null +++ b/app/views/tasks/edit.html.erb @@ -0,0 +1,2 @@ +

Tasks#edit

+

Find me in app/views/tasks/edit.html.erb

diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb new file mode 100644 index 000000000..b16c10310 --- /dev/null +++ b/app/views/tasks/index.html.erb @@ -0,0 +1,2 @@ +

Tasks#index

+

Find me in app/views/tasks/index.html.erb

diff --git a/app/views/tasks/new.html.erb b/app/views/tasks/new.html.erb new file mode 100644 index 000000000..2484008a3 --- /dev/null +++ b/app/views/tasks/new.html.erb @@ -0,0 +1,2 @@ +

Tasks#new

+

Find me in app/views/tasks/new.html.erb

diff --git a/app/views/tasks/show.html.erb b/app/views/tasks/show.html.erb new file mode 100644 index 000000000..1139224db --- /dev/null +++ b/app/views/tasks/show.html.erb @@ -0,0 +1,2 @@ +

Tasks#show

+

Find me in app/views/tasks/show.html.erb

diff --git a/app/views/tasks/update.html.erb b/app/views/tasks/update.html.erb new file mode 100644 index 000000000..fdb1ea609 --- /dev/null +++ b/app/views/tasks/update.html.erb @@ -0,0 +1,2 @@ +

Tasks#update

+

Find me in app/views/tasks/update.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 3f66539d5..f79f59cbd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,16 @@ Rails.application.routes.draw do + get 'tasks/index' + + get 'tasks/show' + + get 'tasks/new' + + get 'tasks/edit' + + get 'tasks/update' + + get 'tasks/destroy' + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb new file mode 100644 index 000000000..b37059769 --- /dev/null +++ b/test/controllers/tasks_controller_test.rb @@ -0,0 +1,34 @@ +require 'test_helper' + +class TasksControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get show" do + get :show + assert_response :success + end + + test "should get new" do + get :new + assert_response :success + end + + test "should get edit" do + get :edit + assert_response :success + end + + test "should get update" do + get :update + assert_response :success + end + + test "should get destroy" do + get :destroy + assert_response :success + end + +end From 7affdc8b3422083f8ce7bc0366f35efb63f55adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Fri, 30 Sep 2016 10:29:13 -0700 Subject: [PATCH 03/16] lost trying to get a checkbox to update the database --- Gemfile | 3 +- Gemfile.lock | 2 + .../stylesheets/_reset_and_normalize.css | 465 ++++++++++++++++++ app/assets/stylesheets/application.css | 109 ++++ app/controllers/tasks_controller.rb | 26 + app/models/task.rb | 17 + app/views/layouts/application.html.erb | 23 +- app/views/tasks/create.html.erb | 1 + app/views/tasks/destroy.html.erb | 11 +- app/views/tasks/edit.html.erb | 17 +- app/views/tasks/index.html.erb | 18 +- app/views/tasks/new.html.erb | 18 +- app/views/tasks/show.html.erb | 47 +- config/routes.rb | 17 +- db/migrate/20160928215231_create_tasks.rb | 12 + .../20160928220505_remove_name_from_tasks.rb | 5 + .../20160928220804_add_title_to_tasks.rb | 5 + .../20160930000203_add_complete_to_tasks.rb | 5 + .../20160930172148_add_completed_to_tasks.rb | 5 + db/schema.rb | 26 + test/fixtures/tasks.yml | 13 + test/models/task_test.rb | 7 + 22 files changed, 835 insertions(+), 17 deletions(-) create mode 100644 app/assets/stylesheets/_reset_and_normalize.css create mode 100644 app/models/task.rb create mode 100644 app/views/tasks/create.html.erb create mode 100644 db/migrate/20160928215231_create_tasks.rb create mode 100644 db/migrate/20160928220505_remove_name_from_tasks.rb create mode 100644 db/migrate/20160928220804_add_title_to_tasks.rb create mode 100644 db/migrate/20160930000203_add_complete_to_tasks.rb create mode 100644 db/migrate/20160930172148_add_completed_to_tasks.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/tasks.yml create mode 100644 test/models/task_test.rb diff --git a/Gemfile b/Gemfile index e87fad5fc..d7371e6c2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' - +gem 'awesome_print' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' # Use sqlite3 as the database for Active Record @@ -44,4 +44,3 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end - diff --git a/Gemfile.lock b/Gemfile.lock index 187046034..b6d552c2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,7 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) + awesome_print (1.7.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) @@ -146,6 +147,7 @@ PLATFORMS ruby DEPENDENCIES + awesome_print byebug coffee-rails (~> 4.1.0) jbuilder (~> 2.0) diff --git a/app/assets/stylesheets/_reset_and_normalize.css b/app/assets/stylesheets/_reset_and_normalize.css new file mode 100644 index 000000000..f8c695f57 --- /dev/null +++ b/app/assets/stylesheets/_reset_and_normalize.css @@ -0,0 +1,465 @@ +/*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */ + +/** + * 1. Change the default font family in all browsers (opinionated). + * 2. Prevent adjustments of font size after orientation changes in IE and iOS. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove the margin in all browsers (opinionated). + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Add the correct display in IE 9-. + * 1. Add the correct display in Edge, IE, and Firefox. + * 2. Add the correct display in IE. + */ + +article, +aside, +details, /* 1 */ +figcaption, +figure, +footer, +header, +main, /* 2 */ +menu, +nav, +section, +summary { /* 1 */ + display: block; +} + +/** + * Add the correct display in IE 9-. + */ + +audio, +canvas, +progress, +video { + display: inline-block; +} + +/** + * Add the correct display in iOS 4-7. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Add the correct display in IE 10-. + * 1. Add the correct display in IE. + */ + +template, /* 1 */ +[hidden] { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * 1. Remove the gray background on active links in IE 10. + * 2. Remove gaps in links underline in iOS 8+ and Safari 8+. + */ + +a { + background-color: transparent; /* 1 */ + -webkit-text-decoration-skip: objects; /* 2 */ +} + +/** + * Remove the outline on focused links when they are also active or hovered + * in all browsers (opinionated). + */ + +a:active, +a:hover { + outline-width: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * 1. Remove the bottom border in Firefox 39-. + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Prevent the duplicate application of `bolder` by the next rule in Safari 6. + */ + +b, +strong { + font-weight: inherit; +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * Add the correct font style in Android 4.3-. + */ + +dfn { + font-style: italic; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Add the correct background and color in IE 9-. + */ + +mark { + background-color: #ff0; + color: #000; +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10-. + */ + +img { + border-style: none; +} + +/** + * Hide the overflow in IE. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct margin in IE 8. + */ + +figure { + margin: 1em 40px; +} + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change font properties to `inherit` in all browsers (opinionated). + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +select, +textarea { + font: inherit; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Restore the font weight unset by the previous rule. + */ + +optgroup { + font-weight: bold; +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` + * controls in Android 4. + * 2. Correct the inability to style clickable types in iOS and Safari. + */ + +button, +html [type="button"], /* 1 */ +[type="reset"], +[type="submit"] { + -webkit-appearance: button; /* 2 */ +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Change the border, margin, and padding in all browsers (opinionated). + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Remove the default vertical scrollbar in IE. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10-. + * 2. Remove the padding in IE 10-. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding and cancel buttons in Chrome and Safari on OS X. + */ + +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Correct the text style of placeholders in Chrome, Edge, and Safari. + */ + +::-webkit-input-placeholder { + color: inherit; + opacity: 0.54; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + + + + + + +/* --------- reset styles : May be slightly redundant with above ----------- */ + +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, b, u, i, center, +dl, dt, dd, ol, ul, li, fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; + vertical-align: baseline; background: transparent; +} +body { line-height: 1; } +ol, ul { list-style: none; } +blockquote, q { quotes: none; } +blockquote:before, blockquote:after, q:before, q:after { content: ''; } +:focus { outline: 0; } +ins { text-decoration: none; } +del { text-decoration: line-through; } +table { border-collapse: collapse; border-spacing: 0; } + +body { + font-size: 100%; + text-align: left; + color: #000000; +} + +/* container - place inside each section or around the entire page depending on your layout */ +.container { + width: 960px; + margin: 0 auto; + text-align: left; + position: relative; +} + +/* for clearing any floats
*/ +.clearfloat { + clear:both; + height:0; + font-size: 1px; + line-height: 0px; +} diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9cd5b348..5fddb1bed 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -13,3 +13,112 @@ *= require_tree . *= require_self */ + + /* Semantic Tags */ + header { + background-color: rgb(205, 170, 46); + position: fixed; + width: 100%; + height: 47px; + top: 0; + } + + body { + font-family: garamond; + } + + main { + background-color: rgb(218, 218, 218); + /*margin-top: 47px; + margin-bottom: 47px;*/ + padding: 47px 5vw 50px 5vw; + height: 100vh; + box-sizing: border-box; /*So 100vh includes the padding!!! (i.e. no scroll for no reason)*/ + overflow: scroll; /*So it will make the main area scrollable if too small!!*/ + } + + article { + padding: 0 0 0 2vw; + font-size: 1.2em; + } + + nav { + background-color: black; + display: inline-block; + width: auto; + height: 100%; + position: absolute; + right: 0; + } + + footer { + background-color: rgb(205, 170, 46); + display: inline-block; + width: 100%; + height: 47px; + /*position: relative; + bottom: 0;*/ + position: fixed; /* fixed makes a sticky footer, relative puts it at the bottom*/ + bottom: 0vh; + overflow: scroll; + } + + + h1 { + font-size: 2em; + line-height: 2; + text-shadow: 1px 1px 7px #717171; + } + + h2 { + font-size: 1.5em; + line-height: 2; + } + + ol { + list-style-type:upper-roman; + line-height: 1.5; + padding: 0 0 0 2vw; + + } + + p { + text-indent: 10px; + } + + + + /* ---- Header specific / Horizontal navigation bar ---- */ + #siteName { + font-size: 3em; + line-height: 1; + font-variant-caps: all-small-caps; + padding-left: 2vw; + display: inline-block; + } + + header ul, header ul { + list-style-type: none; + margin: 0; + padding: 0; + overflow: hidden; + /*height: 100%;*/ + } + + header li, footer li { + float: right; + } + + header li a, footer li a { + display: block; + padding: 15px; + text-align: center; + color: white; + text-decoration: none; + } + + /* Change the link color to #111 (black) on hover */ + header li a:hover, footer li a:hover { + background-color: rgb(91, 91, 91); + } + /* ---- Horizontal navigation bar ---- */ diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 4e0a3c5df..3a8cfa3f7 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -1,19 +1,45 @@ class TasksController < ApplicationController def index + @tasks = Task.all end def show + tasks = Task.all + # Get the current task + @task = tasks.find(params[:id]) + end def new + @newtask = Task.new + + end + + def create + @params = params + @task = Task.new + @task.title = params[:task][:title] + @task.description = params[:task][:description] + # @newtask.complete = false + @task.save + + redirect_to action: "show", id: @task.id + # render "show", id: @task.id end def edit end def update + + @task.update_attribute(@task.completed_at, Time.now) end def destroy + @task = Task.find(params[:id]) + @task.destroy + redirect_to action: "index" end + + end diff --git a/app/models/task.rb b/app/models/task.rb new file mode 100644 index 000000000..e905b9033 --- /dev/null +++ b/app/models/task.rb @@ -0,0 +1,17 @@ +class Task < ActiveRecord::Base + + def complete_time + complete = completed_at ? "Completed at: #{completed_at.to_s}" : "Incomplete..." + return complete + end + + def complete? + complete = completed_at != nil + return complete + end + + def test_check + + end + +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 46eeb110b..bd06d98e6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,9 +6,30 @@ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> + +
+

Task Tracker

+ +
+ +
+ <%= yield %> +
+ +
+ +
-<%= yield %> diff --git a/app/views/tasks/create.html.erb b/app/views/tasks/create.html.erb new file mode 100644 index 000000000..1f7a8b360 --- /dev/null +++ b/app/views/tasks/create.html.erb @@ -0,0 +1 @@ + diff --git a/app/views/tasks/destroy.html.erb b/app/views/tasks/destroy.html.erb index a90559f9d..4c9a9f300 100644 --- a/app/views/tasks/destroy.html.erb +++ b/app/views/tasks/destroy.html.erb @@ -1,2 +1,9 @@ -

Tasks#destroy

-

Find me in app/views/tasks/destroy.html.erb

+

Deleting a task from the model

+<%= params %> +
+ +

+ <%= "#{@task.title.upcase} has been deleted from your to-do list." %> +

+ +
diff --git a/app/views/tasks/edit.html.erb b/app/views/tasks/edit.html.erb index 374190308..5e8b8cea1 100644 --- a/app/views/tasks/edit.html.erb +++ b/app/views/tasks/edit.html.erb @@ -1,2 +1,17 @@

Tasks#edit

-

Find me in app/views/tasks/edit.html.erb

+ +
+ + + + + + + + + +
+ + + + diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index b16c10310..fe279718e 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -1,2 +1,16 @@ -

Tasks#index

-

Find me in app/views/tasks/index.html.erb

+

Your To Do List...

+ +
+ +
    + <% @tasks.each do |task| %> +
  1. +

    + <%= link_to( task.title , show_path(task.id)) %> + <%= button_to("Delete", {action: "destroy", id: task[:id]}, method: :delete, data: { confirm: "Are you sure you want to delete this task from your to-do list???" }) %> +

    +
  2. + <% end %> +
+ +
diff --git a/app/views/tasks/new.html.erb b/app/views/tasks/new.html.erb index 2484008a3..0966ca72e 100644 --- a/app/views/tasks/new.html.erb +++ b/app/views/tasks/new.html.erb @@ -1,2 +1,16 @@ -

Tasks#new

-

Find me in app/views/tasks/new.html.erb

+

Create A New Task

+ +
+ +<%= form_for @newtask, url: create_path do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> + + <%= f.label :description %> + <%= f.text_field :description %> + + <%= f.submit %> +<% end %> + + +
diff --git a/app/views/tasks/show.html.erb b/app/views/tasks/show.html.erb index 1139224db..7df40c6a3 100644 --- a/app/views/tasks/show.html.erb +++ b/app/views/tasks/show.html.erb @@ -1,2 +1,45 @@ -

Tasks#show

-

Find me in app/views/tasks/show.html.erb

+ + +

<%= @task.title %>

+ +
+

Description:

+ +

+ <%= @task.description %> +

+ +

Status:

+ +

+ <%= @task.complete_time %> + + <%= check_box("task", "complete?", { class: 'Task' }, true, false)%> + <%= " #{@task.completed}" %> + + + + + <%= check_box_tag(:complete)%> + <%= label_tag(@task.complete?, "Done") %> + <% if @task[:complete] %> + <% "Test sdfjkjfslkajfkld" %> + <% end %> + +

+ +

Options:

+

+ + <%# link_to("Home", root_path) %> + <%# link_to("Edit", edit_path(@task) ) %> + + <%= button_to("Edit This Task", {action: "edit", id: @task[:id]}, method: :get) %> + + <%= button_to("Delete This Task", {action: "destroy", id: @task[:id]}, method: :delete, data: { confirm: "Are you sure you want to delete this task from your to-do list???" }) %> + +

+ + <%= params %> + +
diff --git a/config/routes.rb b/config/routes.rb index f79f59cbd..9abe0a10e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,15 +1,22 @@ Rails.application.routes.draw do - get 'tasks/index' - get 'tasks/show' + root to: 'tasks#index' - get 'tasks/new' + get 'tasks/index' => 'tasks#index', as: 'index' - get 'tasks/edit' + get 'tasks/show/:id' => 'tasks#show', as: 'show' + + get 'tasks/new' => 'tasks#new', as: 'new' + + get 'tasks/create' + + post 'tasks/create' => 'tasks#create', as: "create" + + get 'tasks/:id/edit' => 'tasks#edit', as: 'edit' get 'tasks/update' - get 'tasks/destroy' + delete 'tasks/:id/destroy' => "tasks#destroy", as: "destroy" # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/db/migrate/20160928215231_create_tasks.rb b/db/migrate/20160928215231_create_tasks.rb new file mode 100644 index 000000000..f06f512f1 --- /dev/null +++ b/db/migrate/20160928215231_create_tasks.rb @@ -0,0 +1,12 @@ +class CreateTasks < ActiveRecord::Migration + def change + create_table :tasks do |t| + t.string :name + t.text :description + t.string :category + t.datetime :completed_at + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160928220505_remove_name_from_tasks.rb b/db/migrate/20160928220505_remove_name_from_tasks.rb new file mode 100644 index 000000000..8579a977c --- /dev/null +++ b/db/migrate/20160928220505_remove_name_from_tasks.rb @@ -0,0 +1,5 @@ +class RemoveNameFromTasks < ActiveRecord::Migration + def change + remove_column :tasks, :name, :string + end +end diff --git a/db/migrate/20160928220804_add_title_to_tasks.rb b/db/migrate/20160928220804_add_title_to_tasks.rb new file mode 100644 index 000000000..77a70cca2 --- /dev/null +++ b/db/migrate/20160928220804_add_title_to_tasks.rb @@ -0,0 +1,5 @@ +class AddTitleToTasks < ActiveRecord::Migration + def change + add_column :tasks, :title, :string + end +end diff --git a/db/migrate/20160930000203_add_complete_to_tasks.rb b/db/migrate/20160930000203_add_complete_to_tasks.rb new file mode 100644 index 000000000..aa0bc12b3 --- /dev/null +++ b/db/migrate/20160930000203_add_complete_to_tasks.rb @@ -0,0 +1,5 @@ +class AddCompleteToTasks < ActiveRecord::Migration + def change + add_column :tasks, :complete, :boolean + end +end diff --git a/db/migrate/20160930172148_add_completed_to_tasks.rb b/db/migrate/20160930172148_add_completed_to_tasks.rb new file mode 100644 index 000000000..46f18df0b --- /dev/null +++ b/db/migrate/20160930172148_add_completed_to_tasks.rb @@ -0,0 +1,5 @@ +class AddCompletedToTasks < ActiveRecord::Migration + def change + add_column :tasks, :completed, :string + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..9b428d0ca --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,26 @@ +# 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: 20160930172148) do + + create_table "tasks", force: :cascade do |t| + t.text "description" + t.string "category" + t.datetime "completed_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "title" + t.string "completed" + end + +end diff --git a/test/fixtures/tasks.yml b/test/fixtures/tasks.yml new file mode 100644 index 000000000..66ae2c606 --- /dev/null +++ b/test/fixtures/tasks.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + description: MyText + category: MyString + completed_at: 2016-09-28 14:52:31 + +two: + name: MyString + description: MyText + category: MyString + completed_at: 2016-09-28 14:52:31 diff --git a/test/models/task_test.rb b/test/models/task_test.rb new file mode 100644 index 000000000..3ca215970 --- /dev/null +++ b/test/models/task_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class TaskTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 0f354f2381376da58716a8e5c70080d4f3bdb72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Fri, 30 Sep 2016 15:24:54 -0700 Subject: [PATCH 04/16] Finished wave 3... but not pretty --- app/controllers/tasks_controller.rb | 24 ++++++++++++++++++- app/helpers/tasks_helper.rb | 5 ++++ app/models/task.rb | 7 +++--- app/views/tasks/index.html.erb | 7 ++++++ app/views/tasks/show.html.erb | 22 ++++++++--------- config/routes.rb | 7 +++++- ...60930205138_remove_completed_from_tasks.rb | 5 ++++ ...05312_remove_completedstring_from_tasks.rb | 5 ++++ ...930205400_add_completedboolean_to_tasks.rb | 5 ++++ db/schema.rb | 4 ++-- 10 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20160930205138_remove_completed_from_tasks.rb create mode 100644 db/migrate/20160930205312_remove_completedstring_from_tasks.rb create mode 100644 db/migrate/20160930205400_add_completedboolean_to_tasks.rb diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 3a8cfa3f7..466e0d866 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -1,6 +1,10 @@ class TasksController < ApplicationController def index @tasks = Task.all + # @tasks.each do |task| + # task.completed = task.completed_at != nil + # task.save + # end end def show @@ -31,10 +35,28 @@ def edit end def update + @task = Task.find(params[:id]) + @task.toggle!(:completed) + + if @task.completed + @task.completed_at = Time.now + else + @task.completed_at = nil + end + + @task.save + + redirect_to(:back) - @task.update_attribute(@task.completed_at, Time.now) end + # This was for toggle... revisit later + # def toggle_approve + # @a = Tasks.find(params[:id]) + # @a.toggle!(:completed) + # render :nothing => true + # end + def destroy @task = Task.find(params[:id]) @task.destroy diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb index ce894d00c..451bb0f00 100644 --- a/app/helpers/tasks_helper.rb +++ b/app/helpers/tasks_helper.rb @@ -1,2 +1,7 @@ module TasksHelper + + # This was for toggle... revisit later + # def approve_link_text(approvable) + # approvable.completed ? 'Un-approve' : 'Approve' + # end end diff --git a/app/models/task.rb b/app/models/task.rb index e905b9033..72f94f44e 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,7 +1,7 @@ class Task < ActiveRecord::Base def complete_time - complete = completed_at ? "Completed at: #{completed_at.to_s}" : "Incomplete..." + complete = completed_at ? "Completed at: #{completed_at.to_s}" : "Currently Incomplete..." return complete end @@ -10,8 +10,9 @@ def complete? return complete end - def test_check - + def complete_question + completed ? 'Mark Incomplete...' : 'Mark Complete!' end + end diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index fe279718e..87d739fed 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -4,9 +4,16 @@
    <% @tasks.each do |task| %> + <% @task = task %> <%# I know this is silly, but I need it as a class variable for my checkbox %>
  1. <%= link_to( task.title , show_path(task.id)) %> + + + <%= check_box("task", "complete?", { class: 'Task' }, true, false)%> + <%= "Complete?" %> + <%= button_to("#{@task.complete_question} ", update_path(@task), method: "patch") %> + <%= button_to("Delete", {action: "destroy", id: task[:id]}, method: :delete, data: { confirm: "Are you sure you want to delete this task from your to-do list???" }) %>

  2. diff --git a/app/views/tasks/show.html.erb b/app/views/tasks/show.html.erb index 7df40c6a3..a38cc1155 100644 --- a/app/views/tasks/show.html.erb +++ b/app/views/tasks/show.html.erb @@ -10,24 +10,23 @@

    Status:

    +

    - <%= @task.complete_time %> <%= check_box("task", "complete?", { class: 'Task' }, true, false)%> - <%= " #{@task.completed}" %> - - - - - <%= check_box_tag(:complete)%> - <%= label_tag(@task.complete?, "Done") %> - <% if @task[:complete] %> - <% "Test sdfjkjfslkajfkld" %> - <% end %> + <%= @task.complete_time %> + <%= button_to("#{@task.complete_question} ", update_path(@task), method: "patch") %> +

    +

    + + <%# link_to approve_link_text(@task), + toggle_approve_task_path(@task), + :remote => true %>

    +

    Options:

    @@ -40,6 +39,5 @@

    - <%= params %> diff --git a/config/routes.rb b/config/routes.rb index 9abe0a10e..6821bff45 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,10 +14,15 @@ get 'tasks/:id/edit' => 'tasks#edit', as: 'edit' - get 'tasks/update' + patch 'tasks/:id/update'=> 'tasks#update', as: 'update' delete 'tasks/:id/destroy' => "tasks#destroy", as: "destroy" + # This was for toggle... revisit later + # resources :tasks do + # get 'toggle_approve', :on => :member + # end + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/db/migrate/20160930205138_remove_completed_from_tasks.rb b/db/migrate/20160930205138_remove_completed_from_tasks.rb new file mode 100644 index 000000000..0e554f20f --- /dev/null +++ b/db/migrate/20160930205138_remove_completed_from_tasks.rb @@ -0,0 +1,5 @@ +class RemoveCompletedFromTasks < ActiveRecord::Migration + def change + remove_column :tasks, :completed, :string + end +end diff --git a/db/migrate/20160930205312_remove_completedstring_from_tasks.rb b/db/migrate/20160930205312_remove_completedstring_from_tasks.rb new file mode 100644 index 000000000..58e2fad46 --- /dev/null +++ b/db/migrate/20160930205312_remove_completedstring_from_tasks.rb @@ -0,0 +1,5 @@ +class RemoveCompletedstringFromTasks < ActiveRecord::Migration + def change + remove_column :tasks, :completed, :string + end +end diff --git a/db/migrate/20160930205400_add_completedboolean_to_tasks.rb b/db/migrate/20160930205400_add_completedboolean_to_tasks.rb new file mode 100644 index 000000000..92f05584b --- /dev/null +++ b/db/migrate/20160930205400_add_completedboolean_to_tasks.rb @@ -0,0 +1,5 @@ +class AddCompletedbooleanToTasks < ActiveRecord::Migration + def change + add_column :tasks, :completed, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 9b428d0ca..d80fb02fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160930172148) do +ActiveRecord::Schema.define(version: 20160930205400) do create_table "tasks", force: :cascade do |t| t.text "description" @@ -20,7 +20,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "title" - t.string "completed" + t.boolean "completed" end end From 3197bfe40314d54514d37cda744eca8123edefbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Fri, 30 Sep 2016 16:07:50 -0700 Subject: [PATCH 05/16] Added the edit function i forgot... --- app/controllers/tasks_controller.rb | 14 ++++++++++++++ app/views/tasks/edit.html.erb | 19 +++++++++---------- app/views/tasks/index.html.erb | 2 +- app/views/tasks/show.html.erb | 3 ++- config/routes.rb | 4 +++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 466e0d866..fc82586c9 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -32,10 +32,23 @@ def create end def edit + @task = Task.find(params[:id]) end def update @task = Task.find(params[:id]) + + @task.title = params[:task][:title] + @task.description= params[:task][:description] + + @task.save + + redirect_to action: "show" + + end + + def button + @task = Task.find(params[:id]) @task.toggle!(:completed) if @task.completed @@ -50,6 +63,7 @@ def update end + # This was for toggle... revisit later # def toggle_approve # @a = Tasks.find(params[:id]) diff --git a/app/views/tasks/edit.html.erb b/app/views/tasks/edit.html.erb index 5e8b8cea1..a8ef34bf8 100644 --- a/app/views/tasks/edit.html.erb +++ b/app/views/tasks/edit.html.erb @@ -1,16 +1,15 @@ -

    Tasks#edit

    +

    Update your Task

    -
    - - - - - +<%= form_for @task, method: :put, url: update_path do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> - - + <%= f.label :description %> + <%= f.text_field :description %> + + <%= f.submit %> +<% end %> -
    diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index 87d739fed..e38e45ef5 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -12,7 +12,7 @@ <%= check_box("task", "complete?", { class: 'Task' }, true, false)%> <%= "Complete?" %> - <%= button_to("#{@task.complete_question} ", update_path(@task), method: "patch") %> + <%= button_to("#{@task.complete_question} ", button_path(@task), method: "patch") %> <%= button_to("Delete", {action: "destroy", id: task[:id]}, method: :delete, data: { confirm: "Are you sure you want to delete this task from your to-do list???" }) %>

    diff --git a/app/views/tasks/show.html.erb b/app/views/tasks/show.html.erb index a38cc1155..34d3491c6 100644 --- a/app/views/tasks/show.html.erb +++ b/app/views/tasks/show.html.erb @@ -16,7 +16,7 @@ <%= check_box("task", "complete?", { class: 'Task' }, true, false)%> <%= @task.complete_time %> - <%= button_to("#{@task.complete_question} ", update_path(@task), method: "patch") %> + <%= button_to("#{@task.complete_question} ", button_path(@task), method: "patch") %>

    @@ -24,6 +24,7 @@ <%# link_to approve_link_text(@task), toggle_approve_task_path(@task), :remote => true %> + <%= params %>

    diff --git a/config/routes.rb b/config/routes.rb index 6821bff45..3ba3d3a73 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,9 @@ get 'tasks/:id/edit' => 'tasks#edit', as: 'edit' - patch 'tasks/:id/update'=> 'tasks#update', as: 'update' + put 'tasks/:id/update'=> 'tasks#update', as: 'update' + + patch 'tasks/:id/button'=> 'tasks#button', as: 'button' delete 'tasks/:id/destroy' => "tasks#destroy", as: "destroy" From 9f833a351f37aa1aa584e18e64fa201132599dc5 Mon Sep 17 00:00:00 2001 From: BJHunnicutt Date: Mon, 3 Oct 2016 09:21:38 -0700 Subject: [PATCH 06/16] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2b96daf9c..f2b9140f2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ +## Reflection +### What went well: + Creating all the pages and forms was pretty straighforward. I definitely feel more comfortable with routing (but not completely). + +### What I'm still working on understanding better: + I tried for a long time to have the checkbox control an attribute, but I only managed to get it to display an attribute. + +### What did chair pair do differently: + + # Task List Rails ✅ We are going to build a Task List in Rails. This web application will enable us to keep track of list of tasks with the functionality to add, edit and remove tasks from a list. From 165a82b8b8443f417f45e1ed3df30af4419fc88f Mon Sep 17 00:00:00 2001 From: BJHunnicutt Date: Mon, 3 Oct 2016 09:23:26 -0700 Subject: [PATCH 07/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2b9140f2..83d273cde 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ I tried for a long time to have the checkbox control an attribute, but I only managed to get it to display an attribute. ### What did chair pair do differently: - + Both of my chair-pairs did more formatting than I did on the display of the list, buttons, etc. I need to be better about doing that, I tend to stop once it's functional. # Task List Rails ✅ We are going to build a Task List in Rails. This web application will enable us to keep track of list of tasks with the functionality to add, edit and remove tasks from a list. From eadda31d5aaf1728c8898bcffd2f0f9e72359d8c Mon Sep 17 00:00:00 2001 From: BJHunnicutt Date: Mon, 3 Oct 2016 09:23:46 -0700 Subject: [PATCH 08/16] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83d273cde..8d357c32f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -## Reflection -### What went well: +### Reflection +#### What went well: Creating all the pages and forms was pretty straighforward. I definitely feel more comfortable with routing (but not completely). -### What I'm still working on understanding better: +#### What I'm still working on understanding better: I tried for a long time to have the checkbox control an attribute, but I only managed to get it to display an attribute. -### What did chair pair do differently: +#### What did chair pair do differently: Both of my chair-pairs did more formatting than I did on the display of the list, buttons, etc. I need to be better about doing that, I tend to stop once it's functional. # Task List Rails ✅ From 9b09ed30ec6b5eaea8f7df4a3db3214594bd8aec Mon Sep 17 00:00:00 2001 From: BJHunnicutt Date: Mon, 3 Oct 2016 09:24:32 -0700 Subject: [PATCH 09/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d357c32f..1035f66c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### Reflection #### What went well: - Creating all the pages and forms was pretty straighforward. I definitely feel more comfortable with routing (but not completely). + Creating all the pages and forms was pretty straighforward. I definitely feel more comfortable with routing (but not completely). Having the buttons update the attributes took me a while to figure out, but made sence in the end. #### What I'm still working on understanding better: I tried for a long time to have the checkbox control an attribute, but I only managed to get it to display an attribute. From 2d57369ad0add7d3032debf5efc256619f8d717a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Tue, 4 Oct 2016 13:00:34 -0700 Subject: [PATCH 10/16] Added parial render for forms --- Gemfile | 1 + Gemfile.lock | 8 ++++++++ app/controllers/tasks_controller.rb | 7 +++++-- app/views/tasks/_form.html.erb | 11 +++++++++++ app/views/tasks/edit.html.erb | 10 +--------- app/views/tasks/new.html.erb | 10 +--------- erd.pdf | Bin 0 -> 22415 bytes 7 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 app/views/tasks/_form.html.erb create mode 100644 erd.pdf diff --git a/Gemfile b/Gemfile index d7371e6c2..d4d02e88f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem 'rails-erd' gem 'awesome_print' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' diff --git a/Gemfile.lock b/Gemfile.lock index b6d552c2c..5e1a8b9fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,6 +42,7 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.5) + choice (0.2.0) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -98,6 +99,11 @@ GEM activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) + rails-erd (1.5.0) + activerecord (>= 3.2) + activesupport (>= 3.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) rails-html-sanitizer (1.0.3) loofah (~> 2.0) railties (4.2.7) @@ -108,6 +114,7 @@ GEM rake (11.3.0) rdoc (4.2.2) json (~> 1.4) + ruby-graphviz (1.2.2) sass (3.4.22) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -153,6 +160,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails rails (= 4.2.7) + rails-erd sass-rails (~> 5.0) sdoc (~> 0.4.0) spring diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index fc82586c9..edd5a9323 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -15,8 +15,9 @@ def show end def new - @newtask = Task.new - + @task = Task.new + # @path = "create" + @method = :get end def create @@ -33,6 +34,8 @@ def create def edit @task = Task.find(params[:id]) + # @path = "update" + @method = :put end def update diff --git a/app/views/tasks/_form.html.erb b/app/views/tasks/_form.html.erb new file mode 100644 index 000000000..aa1b9eb3f --- /dev/null +++ b/app/views/tasks/_form.html.erb @@ -0,0 +1,11 @@ +

    Form Helper

    + +<%= form_for @task, method: @method, url: action_name do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> + + <%= f.label :description %> + <%= f.text_field :description %> + + <%= f.submit action_name %> +<% end %> diff --git a/app/views/tasks/edit.html.erb b/app/views/tasks/edit.html.erb index a8ef34bf8..33fe5c7e9 100644 --- a/app/views/tasks/edit.html.erb +++ b/app/views/tasks/edit.html.erb @@ -1,15 +1,7 @@

    Update your Task

    -<%= form_for @task, method: :put, url: update_path do |f| %> - <%= f.label :title %> - <%= f.text_field :title %> - - <%= f.label :description %> - <%= f.text_field :description %> - - <%= f.submit %> -<% end %> +<%= render partial: "form", locals: {action_name: "update"} %> diff --git a/app/views/tasks/new.html.erb b/app/views/tasks/new.html.erb index 0966ca72e..4ddd83004 100644 --- a/app/views/tasks/new.html.erb +++ b/app/views/tasks/new.html.erb @@ -2,15 +2,7 @@
    -<%= form_for @newtask, url: create_path do |f| %> - <%= f.label :title %> - <%= f.text_field :title %> - - <%= f.label :description %> - <%= f.text_field :description %> - - <%= f.submit %> -<% end %> +<%= render partial: "form", locals: {action_name: "create"}%>
    diff --git a/erd.pdf b/erd.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f61efa3e606c9afa5857cda69649628ccae21fc2 GIT binary patch literal 22415 zcmce-1yEf}mo|)sV1Wb;dT@6qxckA~{ow8n!QI{62^!ozxVyW%hL7C)-g#$gX6mc2 z>aV}{K6`hsUhS(-J*%JIB(g#xGz_#%a3sCESG&hW*Vz-j{cy|xdVsaQ85|cEfKJND z%EZAG!16AV2hfRtEF6sN-rp8_4n{&o2G)i~03IGVdj~rsJxe$j@QMU!>t%X`!1E_G zF3O;vi8~M5OS(yV-y9|_$phykgPbmZ%yC$}c~$X<71=J)@O>sG6j~(K;nBxC48=Rt zXTdrWrQ9|-sWHk04K@g;c|G~ka(_+2i8NDDthA(dl$MLbpZR|OVf^vilfV+)Ag17x zG5`5+cPyT_hv9W*gl$Lm!OQ5k$EGPe$}lYvNBOVZUD|X{QL$qSrDj z+LJ2VoP0+Xk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q4Wl^VdsY}L;8TofKy!BO#$ax)HB3= zGT5G7?T(DGTMmigC9B+|h<9s-Xq@9h4}?G5*5H^n|4eD?O#%PY&Y)tsEF0>NWskdK znSFmF3hMFn%*)LeXFaezHjZ@^NxX-xvtJklKcXd^1B@vr=c3F!gj8d4aTR~wZ%-`U z(#GB8Lu)XPl=5Eap)`8`-Q(s3Tt9@ZT6!7UrqKu)mV?$!^U17QmvK|(qn2X&fzs6E ztsmhgLG@!iP~RF?v~T@pK#+aE99f|>2SPijCSWuyE&?Vp*i)AhB9#9R0M<^b?lzu-E9jQU8KN>FOO{G$n z4O3A^`ov@E`hq7Iv?gh&ACK;l3v^! z9S7*Zq*q@z^;UiC8h zm|mq?blQQU27&riD8caYrKq6t0%{Nda;1*zecIJdJIvF_%bd`FP3T;i5s zV8_7bq4FWE#gi0S%xN*b#Z$%lDB@Xs%Tq)=BGu-BhOA=_dv31-0Tp86bPiL$kp9YV zp)M^=ekdif(rtTajm9lFwgo#E?}g$Pe#ZO!1`lycxZIQaieHQ}J0shMyN8#_WMSGl zJVrnM;;v$;9HqK{zP|94kqf2KMjP@46qqIpkbQs@Iwm_$HxCArlWZT&?%z|Ucz7$8 zy@UU*ulM(T0^_}#o>a9HIGKvP&0?%#x5EeJ@*+SO$c~)0*{b^pN-V=He!6U95|n_i@2XbTocg z(ZCInfX1Edz_WU4wo=Ww5&>wBNC3UJ1lK2-fUTNS7Bm3jt-Gwn_u8Q{gP3(jNcQ

    yg>=Z+2~s1&he>m4+)X~!}<9S5e11vg8yT?`^Wkzq-W*jtd92b*0Dmn zcnSY=A7GaJWy=!++?yaxUC?d7O(+Tmi^4(LK31OI{vd#g_!F>r*Zbc=C;Y+_KdF#| zr Date: Mon, 24 Oct 2016 22:29:26 -0700 Subject: [PATCH 11/16] Old changes uncommited --- .gitignore | 6 +++ Gemfile | 6 +++ Gemfile.lock | 34 +++++++++++++++ app/assets/javascripts/sessions.coffee | 3 ++ app/assets/stylesheets/sessions.scss | 3 ++ app/controllers/sessions_controller.rb | 7 +++ app/helpers/sessions_helper.rb | 2 + app/models/user.rb | 2 + app/views/sessions/create.html.erb | 2 + app/views/sessions/destroy.html.erb | 2 + app/views/tasks/new.html.erb | 1 - app/views/tasks/update.html.erb | 2 + config/initializers/omniauth.rb | 7 +++ config/routes.rb | 8 ++++ db/migrate/20161018170108_create_users.rb | 12 ++++++ db/schema.rb | 11 ++++- test/controllers/sessions_controller_test.rb | 45 ++++++++++++++++++++ test/controllers/tasks_controller_test.rb | 17 ++++++++ test/fixtures/tasks.yml | 17 ++++---- test/fixtures/users.yml | 17 ++++++++ test/models/user_test.rb | 7 +++ test/test_helper.rb | 13 ++++++ 22 files changed, 213 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/sessions.coffee create mode 100644 app/assets/stylesheets/sessions.scss create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 app/models/user.rb create mode 100644 app/views/sessions/create.html.erb create mode 100644 app/views/sessions/destroy.html.erb create mode 100644 config/initializers/omniauth.rb create mode 100644 db/migrate/20161018170108_create_users.rb create mode 100644 test/controllers/sessions_controller_test.rb create mode 100644 test/fixtures/users.yml create mode 100644 test/models/user_test.rb diff --git a/.gitignore b/.gitignore index 050c9d95c..9e676a0c8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,12 @@ # Ignore bundler config. /.bundle +# Hide the .env - It's full of secrets! - # slash makes it only the one in the root directory and only that one, could use without the slash +/.env + +# Ignore this finder browser record cashe +.DS_Store + # Ignore the default SQLite database. /db/*.sqlite3 /db/*.sqlite3-journal diff --git a/Gemfile b/Gemfile index d4d02e88f..28a67cda5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,9 @@ source 'https://rubygems.org' +# for OAuth github authentication +gem "omniauth" +gem "omniauth-github" + gem 'rails-erd' gem 'awesome_print' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' @@ -36,6 +40,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' + gem 'dotenv-rails' end group :development do @@ -44,4 +49,5 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' + gem 'better_errors' end diff --git a/Gemfile.lock b/Gemfile.lock index 5e1a8b9fc..a27190227 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,11 +38,16 @@ GEM tzinfo (~> 1.1) arel (6.0.3) awesome_print (1.7.0) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.5) choice (0.2.0) + coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -52,10 +57,17 @@ GEM coffee-script-source (1.10.0) concurrent-ruby (1.0.2) debug_inspector (0.0.2) + dotenv (2.1.1) + dotenv-rails (2.1.1) + dotenv (= 2.1.1) + railties (>= 4.0, < 5.1) erubis (2.7.0) execjs (2.7.0) + faraday (0.9.2) + multipart-post (>= 1.2, < 3) globalid (0.3.7) activesupport (>= 4.1.0) + hashie (3.4.6) i18n (0.7.0) jbuilder (2.6.0) activesupport (>= 3.0.0, < 5.1) @@ -65,6 +77,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) + jwt (1.5.6) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.4) @@ -75,9 +88,26 @@ GEM mini_portile2 (2.1.0) minitest (5.9.1) multi_json (1.12.1) + multi_xml (0.5.5) + multipart-post (2.0.0) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) + oauth2 (1.2.0) + faraday (>= 0.8, < 0.10) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + omniauth (1.3.1) + hashie (>= 1.2, < 4) + rack (>= 1.0, < 3) + omniauth-github (1.1.2) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.1) + omniauth-oauth2 (1.4.0) + oauth2 (~> 1.0) + omniauth (~> 1.2) pkg-config (1.1.7) rack (1.6.4) rack-test (0.6.3) @@ -155,10 +185,14 @@ PLATFORMS DEPENDENCIES awesome_print + better_errors byebug coffee-rails (~> 4.1.0) + dotenv-rails jbuilder (~> 2.0) jquery-rails + omniauth + omniauth-github rails (= 4.2.7) rails-erd sass-rails (~> 5.0) diff --git a/app/assets/javascripts/sessions.coffee b/app/assets/javascripts/sessions.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/sessions.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/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 000000000..7bef9cf82 --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..ca48c61a6 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,7 @@ +class SessionsController < ApplicationController + def create + end + + def destroy + end +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..309f8b2eb --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..4a57cf079 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end diff --git a/app/views/sessions/create.html.erb b/app/views/sessions/create.html.erb new file mode 100644 index 000000000..c251174fe --- /dev/null +++ b/app/views/sessions/create.html.erb @@ -0,0 +1,2 @@ +

    Sessions#create

    +

    Find me in app/views/sessions/create.html.erb

    diff --git a/app/views/sessions/destroy.html.erb b/app/views/sessions/destroy.html.erb new file mode 100644 index 000000000..d75237d98 --- /dev/null +++ b/app/views/sessions/destroy.html.erb @@ -0,0 +1,2 @@ +

    Sessions#destroy

    +

    Find me in app/views/sessions/destroy.html.erb

    diff --git a/app/views/tasks/new.html.erb b/app/views/tasks/new.html.erb index 4ddd83004..a91804999 100644 --- a/app/views/tasks/new.html.erb +++ b/app/views/tasks/new.html.erb @@ -4,5 +4,4 @@ <%= render partial: "form", locals: {action_name: "create"}%> - diff --git a/app/views/tasks/update.html.erb b/app/views/tasks/update.html.erb index fdb1ea609..d2941267d 100644 --- a/app/views/tasks/update.html.erb +++ b/app/views/tasks/update.html.erb @@ -1,2 +1,4 @@

    Tasks#update

    Find me in app/views/tasks/update.html.erb

    + +<%= params %> diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 000000000..69a9caff8 --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,7 @@ + +Rails.application.config.middleware.use OmniAuth::Builder do + provider :github, + ENV["GITHUB_CLIENT_ID"], + ENV["GITHUB_CLIENT_SECRET"], + scope: "user:email" # Make sure You set the Authorization callback URL: http://localhost:3000/auth/github/callback when you +end diff --git a/config/routes.rb b/config/routes.rb index 3ba3d3a73..1726eccdf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Rails.application.routes.draw do + get 'sessions/create' + + get 'sessions/destroy' + root to: 'tasks#index' get 'tasks/index' => 'tasks#index', as: 'index' @@ -20,6 +24,10 @@ delete 'tasks/:id/destroy' => "tasks#destroy", as: "destroy" + + get "/auth/:provider/callback" => "sessions#create" + + # This was for toggle... revisit later # resources :tasks do # get 'toggle_approve', :on => :member diff --git a/db/migrate/20161018170108_create_users.rb b/db/migrate/20161018170108_create_users.rb new file mode 100644 index 000000000..f85251a60 --- /dev/null +++ b/db/migrate/20161018170108_create_users.rb @@ -0,0 +1,12 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :uid + t.string :name + t.string :provider + t.string :email + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d80fb02fb..8453f8b86 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160930205400) do +ActiveRecord::Schema.define(version: 20161018170108) do create_table "tasks", force: :cascade do |t| t.text "description" @@ -23,4 +23,13 @@ t.boolean "completed" end + create_table "users", force: :cascade do |t| + t.string "uid" + t.string "name" + t.string "provider" + t.string "email" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 000000000..d4cf0e090 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,45 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + test "should get create" do + get :create + assert_response :success + end + + test "should get destroy" do + get :destroy + assert_response :success + end + + ################ ADDED ################## + test "The truth" do + assert true + end + + def login_a_user + request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:github] + get :create, {provider: "github"} + end + + test "Can Create a user" do + assert_difference('User.count', 1) do + login_a_user + assert_response :redirect + assert_redirected_to root_path + assert_equal session[:user_id] = User.find_by(uid: OmniAuth.config_mock_provider: "githib").id + + end + end + + test "If a user logs in twice it doesn't create a 2nd user" do + assert_difference('User.count', 1) do + login_a_user + end + assert_no_difference('User.count') do + login_a_user + assert_response :redirect + assert_redirected_to root_path + end + end + +end diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb index b37059769..786f0c91c 100644 --- a/test/controllers/tasks_controller_test.rb +++ b/test/controllers/tasks_controller_test.rb @@ -31,4 +31,21 @@ class TasksControllerTest < ActionController::TestCase assert_response :success end + ########## Added new below ########### + + test "Make sure a user can see their tasks" do + session[:user_id] = users(:ada).id + get :show, id: tasks(:adas_task).id + + assert_response :success + end + + test "Make sure a user cannot see another user's tasks" do + session[:user_id] = users(:babbage).id + get :show, id: tasks(:adas_task).id + + assert_response :redirect + assert_equal flash[:notice], "You do not have access to that task" + end + end diff --git a/test/fixtures/tasks.yml b/test/fixtures/tasks.yml index 66ae2c606..9c9ac0d17 100644 --- a/test/fixtures/tasks.yml +++ b/test/fixtures/tasks.yml @@ -1,13 +1,12 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - name: MyString - description: MyText - category: MyString +adas_task: + title: "Write the 1st code!" + description: "Fortran" + user: :ada completed_at: 2016-09-28 14:52:31 -two: - name: MyString - description: MyText - category: MyString - completed_at: 2016-09-28 14:52:31 +babbages_task: + title: "Make the first computer" + description: "Build it" + user: :babbage diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 000000000..cb5b9d42e --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +ada: + id: 1 + uid: 11234 + name: "Ada Lovelace" + provider: github + email: ada@adadevelopersacademy.org + completed_at: 2016-09-28 14:52:31 + +babbage: + id: 2 + uid: 11235 + name: "Babbage" + provider: github + email: babbage@adadevelopersacademy.org + completed_at: 2016-09-28 14:52:30 diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 000000000..82f61e010 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 92e39b2d7..0b374f79e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,4 +7,17 @@ class ActiveSupport::TestCase fixtures :all # Add more helper methods to be used by all tests here... + + def setup + # Once you have enabled test mode, all requests + # to OmniAuth will be short circuited to use the mock authentication hash. + # A request to /auth/provider will redirect immediately to /auth/provider/callback. + OmniAuth.config.test_mode = true + + # The mock_auth configuration allows you to set per-provider (or default) authentication + # hashes to return during testing. + OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({ + provider: 'github', uid: '123545', info: { email: "a@b.com", name: "Ada" } + }) + end end From 2b38d8d2c5b557a44052799f9ebc193706583870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Tue, 25 Oct 2016 20:51:13 -0700 Subject: [PATCH 12/16] Phase 1 complete --- app/assets/javascripts/homepages.coffee | 3 +++ app/assets/stylesheets/homepages.scss | 3 +++ app/controllers/homepages_controller.rb | 4 ++++ app/controllers/sessions_controller.rb | 23 +++++++++++++++++++ app/helpers/homepages_helper.rb | 2 ++ app/models/user.rb | 13 +++++++++++ app/views/homepages/index.html.erb | 2 ++ app/views/layouts/application.html.erb | 5 ++++ config/routes.rb | 2 ++ test/controllers/homepages_controller_test.rb | 9 ++++++++ 10 files changed, 66 insertions(+) create mode 100644 app/assets/javascripts/homepages.coffee create mode 100644 app/assets/stylesheets/homepages.scss create mode 100644 app/controllers/homepages_controller.rb create mode 100644 app/helpers/homepages_helper.rb create mode 100644 app/views/homepages/index.html.erb create mode 100644 test/controllers/homepages_controller_test.rb diff --git a/app/assets/javascripts/homepages.coffee b/app/assets/javascripts/homepages.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/homepages.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/homepages.scss b/app/assets/stylesheets/homepages.scss new file mode 100644 index 000000000..e42583ae8 --- /dev/null +++ b/app/assets/stylesheets/homepages.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the homepages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/homepages_controller.rb b/app/controllers/homepages_controller.rb new file mode 100644 index 000000000..f200c8ac2 --- /dev/null +++ b/app/controllers/homepages_controller.rb @@ -0,0 +1,4 @@ +class HomepagesController < ApplicationController + def index + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ca48c61a6..cbc0df29b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,7 +1,30 @@ class SessionsController < ApplicationController def create + auth_hash = request.env['omniauth.auth'] + # raise + flash[:notice] = "Login Failed!" #This is kind of like a cookie or param, it's saved in the background + return redirect_to root_path unless auth_hash['uid'] # THe return makes it so nothing after this happens + + @user = User.find_by(uid: auth_hash[:uid], provider: 'github') #specifying both because you could log someone in with the same user id on facebook + if @user.nil? + # User doesn't match anything in the DB. + # Attempt to create a new user. + @user = User.build_from_github(auth_hash) + flash[:notice] = "Unable to save the user" + return render :root_path unless @user.save + end + + # Save the user ID in the session + session[:user_id] = @user.id + + flash[:notice] = "Successfully logged in!" + redirect_to root_path + end def destroy + session[:user_id] = nil # Don't want to delete users (usually) for simplicity + + redirect_to root_path end end diff --git a/app/helpers/homepages_helper.rb b/app/helpers/homepages_helper.rb new file mode 100644 index 000000000..4bd8098f3 --- /dev/null +++ b/app/helpers/homepages_helper.rb @@ -0,0 +1,2 @@ +module HomepagesHelper +end diff --git a/app/models/user.rb b/app/models/user.rb index 4a57cf079..9ca6b2b24 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,15 @@ class User < ActiveRecord::Base + + validates :email, :uid, :provider, presence: true + + def self.build_from_github(auth_hash) + user = User.new + user.uid = auth_hash[:uid] + user.provider = 'github' + user.name = auth_hash['info']['name'] + user.email = auth_hash['info']['email'] + + return user + end + end diff --git a/app/views/homepages/index.html.erb b/app/views/homepages/index.html.erb new file mode 100644 index 000000000..37d3ce709 --- /dev/null +++ b/app/views/homepages/index.html.erb @@ -0,0 +1,2 @@ +

    Homepages#index

    +

    Find me in app/views/homepages/index.html.erb

    diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bd06d98e6..e49f391fa 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,6 +14,11 @@
    • <%= link_to("Home", index_path) %>
    • <%= link_to("New Task", new_path) %>
    • + <% if session[:user_id] == nil %> +
    • <%= link_to("Login via Github", "auth/github") %>
    • <%# i.e. "/auth/:provider" %> + <% else %> +
    • <%= link_to("Logout", "/sessions/destroy", method: "delete") %>
    • + <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index 1726eccdf..0fc5e0c77 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do + get 'homepages/index' + get 'sessions/create' get 'sessions/destroy' diff --git a/test/controllers/homepages_controller_test.rb b/test/controllers/homepages_controller_test.rb new file mode 100644 index 000000000..46828ab12 --- /dev/null +++ b/test/controllers/homepages_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class HomepagesControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end From 14db2c1f2dbcdb031d6ee1baad853da2dc0f8dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBJHunnicutt=E2=80=9D?= Date: Tue, 25 Oct 2016 22:41:24 -0700 Subject: [PATCH 13/16] Finished phase 2 --- Gemfile | 4 +++ Gemfile.lock | 8 +++++ app/controllers/homepages_controller.rb | 3 ++ app/controllers/sessions_controller.rb | 2 +- app/controllers/tasks_controller.rb | 4 +++ app/views/homepages/index.html.erb | 8 +++-- app/views/layouts/application.html.erb | 6 ++-- config/routes.rb | 6 ++-- test/controllers/sessions_controller_test.rb | 13 +++++--- test/controllers/tasks_controller_test.rb | 14 +++++---- test/fixtures/tasks.yml | 4 +-- test/fixtures/users.yml | 11 +++++-- test/models/user_test.rb | 32 ++++++++++++++++++-- test/test_helper.rb | 9 +++--- 14 files changed, 94 insertions(+), 30 deletions(-) diff --git a/Gemfile b/Gemfile index 28a67cda5..34d1ab999 100644 --- a/Gemfile +++ b/Gemfile @@ -51,3 +51,7 @@ group :development do gem 'spring' gem 'better_errors' end + +group :test do + gem 'minitest-reporters' +end diff --git a/Gemfile.lock b/Gemfile.lock index a27190227..0480275d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,6 +36,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + ansi (1.5.0) arel (6.0.3) awesome_print (1.7.0) better_errors (2.1.1) @@ -87,6 +88,11 @@ GEM mime-types-data (3.2016.0521) mini_portile2 (2.1.0) minitest (5.9.1) + minitest-reporters (1.1.11) + ansi + builder + minitest (>= 5.0) + ruby-progressbar multi_json (1.12.1) multi_xml (0.5.5) multipart-post (2.0.0) @@ -145,6 +151,7 @@ GEM rdoc (4.2.2) json (~> 1.4) ruby-graphviz (1.2.2) + ruby-progressbar (1.8.1) sass (3.4.22) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -191,6 +198,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 2.0) jquery-rails + minitest-reporters omniauth omniauth-github rails (= 4.2.7) diff --git a/app/controllers/homepages_controller.rb b/app/controllers/homepages_controller.rb index f200c8ac2..2891ab57a 100644 --- a/app/controllers/homepages_controller.rb +++ b/app/controllers/homepages_controller.rb @@ -1,4 +1,7 @@ class HomepagesController < ApplicationController def index + if session[:user_id] != nil + redirect_to index_path + end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index cbc0df29b..85dc89ac0 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -16,7 +16,7 @@ def create # Save the user ID in the session session[:user_id] = @user.id - + flash[:notice] = "Successfully logged in!" redirect_to root_path diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index edd5a9323..efb1f7047 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -8,6 +8,10 @@ def index end def show + # if session[:user_id] != nil + # redirect_to index_path + # end + tasks = Task.all # Get the current task @task = tasks.find(params[:id]) diff --git a/app/views/homepages/index.html.erb b/app/views/homepages/index.html.erb index 37d3ce709..ca5f334b9 100644 --- a/app/views/homepages/index.html.erb +++ b/app/views/homepages/index.html.erb @@ -1,2 +1,6 @@ -

    Homepages#index

    -

    Find me in app/views/homepages/index.html.erb

    + +<% if @user %> +

    Welcome, <%= @user.name %>!

    +<% else %> +

    Please log in

    +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e49f391fa..09bf18aae 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,11 +12,11 @@

    Task Tracker