From a2d4191e1568c103c0b4ee6dbe0f049c8a66d34d Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 14:05:13 -0700 Subject: [PATCH 01/42] Created new Rails app --- .ruby-gemset | 1 - .ruby-version | 1 - task_list/.gitignore | 17 ++ task_list/Gemfile | 47 +++++ task_list/Gemfile.lock | 163 ++++++++++++++++++ task_list/README.rdoc | 28 +++ task_list/Rakefile | 6 + task_list/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 16 ++ .../app/assets/stylesheets/application.css | 15 ++ .../app/controllers/application_controller.rb | 5 + task_list/app/controllers/concerns/.keep | 0 task_list/app/helpers/application_helper.rb | 2 + task_list/app/mailers/.keep | 0 task_list/app/models/.keep | 0 task_list/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 ++ task_list/bin/bundle | 3 + task_list/bin/rails | 9 + task_list/bin/rake | 9 + task_list/bin/setup | 29 ++++ task_list/bin/spring | 15 ++ task_list/config.ru | 4 + task_list/config/application.rb | 26 +++ task_list/config/boot.rb | 3 + task_list/config/database.yml | 25 +++ task_list/config/environment.rb | 5 + task_list/config/environments/development.rb | 41 +++++ task_list/config/environments/production.rb | 79 +++++++++ task_list/config/environments/test.rb | 42 +++++ task_list/config/initializers/assets.rb | 11 ++ .../initializers/backtrace_silencers.rb | 7 + .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + task_list/config/initializers/inflections.rb | 16 ++ task_list/config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 14 ++ task_list/config/locales/en.yml | 23 +++ task_list/config/routes.rb | 56 ++++++ task_list/config/secrets.yml | 22 +++ task_list/db/seeds.rb | 7 + task_list/lib/assets/.keep | 0 task_list/lib/tasks/.keep | 0 task_list/log/.keep | 0 task_list/public/404.html | 67 +++++++ task_list/public/422.html | 67 +++++++ task_list/public/500.html | 66 +++++++ task_list/public/favicon.ico | 0 task_list/public/robots.txt | 5 + task_list/test/controllers/.keep | 0 task_list/test/fixtures/.keep | 0 task_list/test/helpers/.keep | 0 task_list/test/integration/.keep | 0 task_list/test/mailers/.keep | 0 task_list/test/models/.keep | 0 task_list/test/test_helper.rb | 10 ++ task_list/vendor/assets/javascripts/.keep | 0 task_list/vendor/assets/stylesheets/.keep | 0 59 files changed, 988 insertions(+), 2 deletions(-) delete mode 100644 .ruby-gemset delete mode 100644 .ruby-version create mode 100644 task_list/.gitignore create mode 100644 task_list/Gemfile create mode 100644 task_list/Gemfile.lock create mode 100644 task_list/README.rdoc create mode 100644 task_list/Rakefile create mode 100644 task_list/app/assets/images/.keep create mode 100644 task_list/app/assets/javascripts/application.js create mode 100644 task_list/app/assets/stylesheets/application.css create mode 100644 task_list/app/controllers/application_controller.rb create mode 100644 task_list/app/controllers/concerns/.keep create mode 100644 task_list/app/helpers/application_helper.rb create mode 100644 task_list/app/mailers/.keep create mode 100644 task_list/app/models/.keep create mode 100644 task_list/app/models/concerns/.keep create mode 100644 task_list/app/views/layouts/application.html.erb create mode 100755 task_list/bin/bundle create mode 100755 task_list/bin/rails create mode 100755 task_list/bin/rake create mode 100755 task_list/bin/setup create mode 100755 task_list/bin/spring create mode 100644 task_list/config.ru create mode 100644 task_list/config/application.rb create mode 100644 task_list/config/boot.rb create mode 100644 task_list/config/database.yml create mode 100644 task_list/config/environment.rb create mode 100644 task_list/config/environments/development.rb create mode 100644 task_list/config/environments/production.rb create mode 100644 task_list/config/environments/test.rb create mode 100644 task_list/config/initializers/assets.rb create mode 100644 task_list/config/initializers/backtrace_silencers.rb create mode 100644 task_list/config/initializers/cookies_serializer.rb create mode 100644 task_list/config/initializers/filter_parameter_logging.rb create mode 100644 task_list/config/initializers/inflections.rb create mode 100644 task_list/config/initializers/mime_types.rb create mode 100644 task_list/config/initializers/session_store.rb create mode 100644 task_list/config/initializers/wrap_parameters.rb create mode 100644 task_list/config/locales/en.yml create mode 100644 task_list/config/routes.rb create mode 100644 task_list/config/secrets.yml create mode 100644 task_list/db/seeds.rb create mode 100644 task_list/lib/assets/.keep create mode 100644 task_list/lib/tasks/.keep create mode 100644 task_list/log/.keep create mode 100644 task_list/public/404.html create mode 100644 task_list/public/422.html create mode 100644 task_list/public/500.html create mode 100644 task_list/public/favicon.ico create mode 100644 task_list/public/robots.txt create mode 100644 task_list/test/controllers/.keep create mode 100644 task_list/test/fixtures/.keep create mode 100644 task_list/test/helpers/.keep create mode 100644 task_list/test/integration/.keep create mode 100644 task_list/test/mailers/.keep create mode 100644 task_list/test/models/.keep create mode 100644 task_list/test/test_helper.rb create mode 100644 task_list/vendor/assets/javascripts/.keep create mode 100644 task_list/vendor/assets/stylesheets/.keep 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/task_list/.gitignore b/task_list/.gitignore new file mode 100644 index 000000000..050c9d95c --- /dev/null +++ b/task_list/.gitignore @@ -0,0 +1,17 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +!/log/.keep +/tmp diff --git a/task_list/Gemfile b/task_list/Gemfile new file mode 100644 index 000000000..e87fad5fc --- /dev/null +++ b/task_list/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/task_list/Gemfile.lock b/task_list/Gemfile.lock new file mode 100644 index 000000000..187046034 --- /dev/null +++ b/task_list/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/task_list/README.rdoc b/task_list/README.rdoc new file mode 100644 index 000000000..dd4e97e22 --- /dev/null +++ b/task_list/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/task_list/Rakefile b/task_list/Rakefile new file mode 100644 index 000000000..ba6b733dd --- /dev/null +++ b/task_list/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/task_list/app/assets/images/.keep b/task_list/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/app/assets/javascripts/application.js b/task_list/app/assets/javascripts/application.js new file mode 100644 index 000000000..e07c5a830 --- /dev/null +++ b/task_list/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/task_list/app/assets/stylesheets/application.css b/task_list/app/assets/stylesheets/application.css new file mode 100644 index 000000000..f9cd5b348 --- /dev/null +++ b/task_list/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/task_list/app/controllers/application_controller.rb b/task_list/app/controllers/application_controller.rb new file mode 100644 index 000000000..d83690e1b --- /dev/null +++ b/task_list/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/task_list/app/controllers/concerns/.keep b/task_list/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/app/helpers/application_helper.rb b/task_list/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/task_list/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/task_list/app/mailers/.keep b/task_list/app/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/app/models/.keep b/task_list/app/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/app/models/concerns/.keep b/task_list/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/app/views/layouts/application.html.erb b/task_list/app/views/layouts/application.html.erb new file mode 100644 index 000000000..0bc12ec2d --- /dev/null +++ b/task_list/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + TaskList + <%= 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/task_list/bin/bundle b/task_list/bin/bundle new file mode 100755 index 000000000..66e9889e8 --- /dev/null +++ b/task_list/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/task_list/bin/rails b/task_list/bin/rails new file mode 100755 index 000000000..0138d79b7 --- /dev/null +++ b/task_list/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/task_list/bin/rake b/task_list/bin/rake new file mode 100755 index 000000000..d87d5f578 --- /dev/null +++ b/task_list/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/task_list/bin/setup b/task_list/bin/setup new file mode 100755 index 000000000..acdb2c138 --- /dev/null +++ b/task_list/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/task_list/bin/spring b/task_list/bin/spring new file mode 100755 index 000000000..7fe232c3a --- /dev/null +++ b/task_list/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/task_list/config.ru b/task_list/config.ru new file mode 100644 index 000000000..bd83b2541 --- /dev/null +++ b/task_list/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/task_list/config/application.rb b/task_list/config/application.rb new file mode 100644 index 000000000..fe39b94eb --- /dev/null +++ b/task_list/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 TaskList + 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/task_list/config/boot.rb b/task_list/config/boot.rb new file mode 100644 index 000000000..6b750f00b --- /dev/null +++ b/task_list/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/task_list/config/database.yml b/task_list/config/database.yml new file mode 100644 index 000000000..1c1a37ca8 --- /dev/null +++ b/task_list/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/task_list/config/environment.rb b/task_list/config/environment.rb new file mode 100644 index 000000000..ee8d90dc6 --- /dev/null +++ b/task_list/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/task_list/config/environments/development.rb b/task_list/config/environments/development.rb new file mode 100644 index 000000000..b55e2144b --- /dev/null +++ b/task_list/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/task_list/config/environments/production.rb b/task_list/config/environments/production.rb new file mode 100644 index 000000000..5c1b32e48 --- /dev/null +++ b/task_list/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/task_list/config/environments/test.rb b/task_list/config/environments/test.rb new file mode 100644 index 000000000..1c19f08b2 --- /dev/null +++ b/task_list/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/task_list/config/initializers/assets.rb b/task_list/config/initializers/assets.rb new file mode 100644 index 000000000..01ef3e663 --- /dev/null +++ b/task_list/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/task_list/config/initializers/backtrace_silencers.rb b/task_list/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /dev/null +++ b/task_list/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/task_list/config/initializers/cookies_serializer.rb b/task_list/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..7f70458de --- /dev/null +++ b/task_list/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/task_list/config/initializers/filter_parameter_logging.rb b/task_list/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /dev/null +++ b/task_list/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/task_list/config/initializers/inflections.rb b/task_list/config/initializers/inflections.rb new file mode 100644 index 000000000..ac033bf9d --- /dev/null +++ b/task_list/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/task_list/config/initializers/mime_types.rb b/task_list/config/initializers/mime_types.rb new file mode 100644 index 000000000..dc1899682 --- /dev/null +++ b/task_list/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/task_list/config/initializers/session_store.rb b/task_list/config/initializers/session_store.rb new file mode 100644 index 000000000..3998be208 --- /dev/null +++ b/task_list/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: '_task_list_session' diff --git a/task_list/config/initializers/wrap_parameters.rb b/task_list/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..33725e95f --- /dev/null +++ b/task_list/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/task_list/config/locales/en.yml b/task_list/config/locales/en.yml new file mode 100644 index 000000000..065395716 --- /dev/null +++ b/task_list/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/task_list/config/routes.rb b/task_list/config/routes.rb new file mode 100644 index 000000000..3f66539d5 --- /dev/null +++ b/task_list/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/task_list/config/secrets.yml b/task_list/config/secrets.yml new file mode 100644 index 000000000..fde7b04a1 --- /dev/null +++ b/task_list/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: 1ed2b2d635ac2038f87588fbf017330da706f43d3faaaac9e342e32cfcedac6570385bb27fcb4b2cd95ed624f8fbaa26b534f728c6c4941832b3816a0b3d9117 + +test: + secret_key_base: c5afcd2b0c40ea643652769a98586f4917ebf676a74079fc7aaa988d352a47c5777b9796cad08b9d2dcccdc0aa384451747aaab177bade650902fd5fe9a6ab61 + +# 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/task_list/db/seeds.rb b/task_list/db/seeds.rb new file mode 100644 index 000000000..4edb1e857 --- /dev/null +++ b/task_list/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/task_list/lib/assets/.keep b/task_list/lib/assets/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/lib/tasks/.keep b/task_list/lib/tasks/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/log/.keep b/task_list/log/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/public/404.html b/task_list/public/404.html new file mode 100644 index 000000000..b612547fc --- /dev/null +++ b/task_list/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/task_list/public/422.html b/task_list/public/422.html new file mode 100644 index 000000000..a21f82b3b --- /dev/null +++ b/task_list/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/task_list/public/500.html b/task_list/public/500.html new file mode 100644 index 000000000..061abc587 --- /dev/null +++ b/task_list/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/task_list/public/favicon.ico b/task_list/public/favicon.ico new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/public/robots.txt b/task_list/public/robots.txt new file mode 100644 index 000000000..3c9c7c01f --- /dev/null +++ b/task_list/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/task_list/test/controllers/.keep b/task_list/test/controllers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/fixtures/.keep b/task_list/test/fixtures/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/helpers/.keep b/task_list/test/helpers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/integration/.keep b/task_list/test/integration/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/mailers/.keep b/task_list/test/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/models/.keep b/task_list/test/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/test/test_helper.rb b/task_list/test/test_helper.rb new file mode 100644 index 000000000..92e39b2d7 --- /dev/null +++ b/task_list/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/task_list/vendor/assets/javascripts/.keep b/task_list/vendor/assets/javascripts/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/task_list/vendor/assets/stylesheets/.keep b/task_list/vendor/assets/stylesheets/.keep new file mode 100644 index 000000000..e69de29bb From 7fe48c19e61e226d12923e1a4d91c8bd27f31bab Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 14:15:25 -0700 Subject: [PATCH 02/42] Made Tasks controller --- task_list/app/assets/javascripts/tasks.coffee | 3 ++ task_list/app/assets/stylesheets/tasks.scss | 3 ++ task_list/app/controllers/tasks_controller.rb | 19 +++++++++++ task_list/app/helpers/tasks_helper.rb | 2 ++ task_list/app/views/tasks/destroy.html.erb | 2 ++ task_list/app/views/tasks/edit.html.erb | 2 ++ task_list/app/views/tasks/index.html.erb | 2 ++ task_list/app/views/tasks/new.html.erb | 2 ++ task_list/app/views/tasks/show.html.erb | 2 ++ task_list/app/views/tasks/update.html.erb | 2 ++ task_list/config/routes.rb | 12 +++++++ .../test/controllers/tasks_controller_test.rb | 34 +++++++++++++++++++ 12 files changed, 85 insertions(+) create mode 100644 task_list/app/assets/javascripts/tasks.coffee create mode 100644 task_list/app/assets/stylesheets/tasks.scss create mode 100644 task_list/app/controllers/tasks_controller.rb create mode 100644 task_list/app/helpers/tasks_helper.rb create mode 100644 task_list/app/views/tasks/destroy.html.erb create mode 100644 task_list/app/views/tasks/edit.html.erb create mode 100644 task_list/app/views/tasks/index.html.erb create mode 100644 task_list/app/views/tasks/new.html.erb create mode 100644 task_list/app/views/tasks/show.html.erb create mode 100644 task_list/app/views/tasks/update.html.erb create mode 100644 task_list/test/controllers/tasks_controller_test.rb diff --git a/task_list/app/assets/javascripts/tasks.coffee b/task_list/app/assets/javascripts/tasks.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/task_list/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/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss new file mode 100644 index 000000000..b57862ec7 --- /dev/null +++ b/task_list/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/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb new file mode 100644 index 000000000..253fb351c --- /dev/null +++ b/task_list/app/controllers/tasks_controller.rb @@ -0,0 +1,19 @@ +class TasksController < ApplicationController + def index + end + + def new + end + + def show + end + + def destroy + end + + def edit + end + + def update + end +end diff --git a/task_list/app/helpers/tasks_helper.rb b/task_list/app/helpers/tasks_helper.rb new file mode 100644 index 000000000..ce894d00c --- /dev/null +++ b/task_list/app/helpers/tasks_helper.rb @@ -0,0 +1,2 @@ +module TasksHelper +end diff --git a/task_list/app/views/tasks/destroy.html.erb b/task_list/app/views/tasks/destroy.html.erb new file mode 100644 index 000000000..a90559f9d --- /dev/null +++ b/task_list/app/views/tasks/destroy.html.erb @@ -0,0 +1,2 @@ +

Tasks#destroy

+

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

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

Tasks#edit

+

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

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

Tasks#index

+

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

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

Tasks#new

+

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

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

Tasks#show

+

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

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

Tasks#update

+

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

diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 3f66539d5..48998336d 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,4 +1,16 @@ Rails.application.routes.draw do + get 'tasks/index' + + get 'tasks/new' + + get 'tasks/show' + + get 'tasks/destroy' + + get 'tasks/edit' + + get 'tasks/update' + # 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/task_list/test/controllers/tasks_controller_test.rb b/task_list/test/controllers/tasks_controller_test.rb new file mode 100644 index 000000000..7f7526bde --- /dev/null +++ b/task_list/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 new" do + get :new + assert_response :success + end + + test "should get show" do + get :show + assert_response :success + end + + test "should get destroy" do + get :destroy + 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 + +end From 4208824d8511bee3a6bf6767781cdde69622d469 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 14:27:20 -0700 Subject: [PATCH 03/42] Created Task model --- task_list/app/models/task.rb | 2 ++ task_list/db/migrate/20160928212630_create_tasks.rb | 12 ++++++++++++ task_list/test/fixtures/tasks.yml | 13 +++++++++++++ task_list/test/models/task_test.rb | 7 +++++++ 4 files changed, 34 insertions(+) create mode 100644 task_list/app/models/task.rb create mode 100644 task_list/db/migrate/20160928212630_create_tasks.rb create mode 100644 task_list/test/fixtures/tasks.yml create mode 100644 task_list/test/models/task_test.rb diff --git a/task_list/app/models/task.rb b/task_list/app/models/task.rb new file mode 100644 index 000000000..935f76e12 --- /dev/null +++ b/task_list/app/models/task.rb @@ -0,0 +1,2 @@ +class Task < ActiveRecord::Base +end diff --git a/task_list/db/migrate/20160928212630_create_tasks.rb b/task_list/db/migrate/20160928212630_create_tasks.rb new file mode 100644 index 000000000..ab8295b77 --- /dev/null +++ b/task_list/db/migrate/20160928212630_create_tasks.rb @@ -0,0 +1,12 @@ +class CreateTasks < ActiveRecord::Migration + def change + create_table :tasks do |t| + t.string :title + t.text :description + t.boolean :completed + t.datetime :completed_at + + t.timestamps null: false + end + end +end diff --git a/task_list/test/fixtures/tasks.yml b/task_list/test/fixtures/tasks.yml new file mode 100644 index 000000000..00ff08692 --- /dev/null +++ b/task_list/test/fixtures/tasks.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + description: MyText + completed: false + completed_at: 2016-09-28 14:26:30 + +two: + title: MyString + description: MyText + completed: false + completed_at: 2016-09-28 14:26:30 diff --git a/task_list/test/models/task_test.rb b/task_list/test/models/task_test.rb new file mode 100644 index 000000000..3ca215970 --- /dev/null +++ b/task_list/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 69067307cf4f76001382379fa7786446de2be035 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 14:29:39 -0700 Subject: [PATCH 04/42] Migrate Task model to make schema --- task_list/db/schema.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 task_list/db/schema.rb diff --git a/task_list/db/schema.rb b/task_list/db/schema.rb new file mode 100644 index 000000000..a5adfec22 --- /dev/null +++ b/task_list/db/schema.rb @@ -0,0 +1,25 @@ +# 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: 20160928212630) do + + create_table "tasks", force: :cascade do |t| + t.string "title" + t.text "description" + t.boolean "completed" + t.datetime "completed_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end From 4b226deeec7f0f9c820eff1a322d490d379d54ac Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 15:29:20 -0700 Subject: [PATCH 05/42] Linked task list in index to full task descriptions via show --- task_list/app/controllers/tasks_controller.rb | 15 +++++++++++++++ task_list/app/views/tasks/index.html.erb | 9 +++++++-- task_list/app/views/tasks/show.html.erb | 18 ++++++++++++++++-- task_list/config/routes.rb | 6 +++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 253fb351c..4144856c3 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -1,11 +1,26 @@ class TasksController < ApplicationController def index + @welcome_msg = "Let's get down to business" + @tasks = Task.all end def new end def show + @tasks = Task.all + @task_of_interest = nil + + @tasks.each do |task| + number = params[:id].to_i #params gives you the url, params returns a string that we need to turn into an integer so we can use it + if task[:id] == number + @task_of_interest = task + end + end + + if @task_of_interest == nil + @task_of_interest = { id: params[:id].to_i, title: "That task was not found", description: "", completed: "", completed_at: ""} + end end def destroy diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index b16c10310..ade61f994 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,2 +1,7 @@ -

Tasks#index

-

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

+

Task List

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

<%= link_to("#{task.title}", show_path(task[:id])) %>

+<% end %> + + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 1139224db..658a0d81f 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,2 +1,16 @@ -

Tasks#show

-

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

+
+

<%= @task_of_interest[:title]%>

+ +

<%= @task_of_interest[:description] %>

+ +

+ + <% if @task_of_interest[:completed] == true %> + ✔︎ This task is complete! + <%else%> + ❏This task is NOT completed yet + <%end %> +

+ +
+ diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 48998336d..7289869ba 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,9 +1,13 @@ Rails.application.routes.draw do - get 'tasks/index' + + root to: 'tasks#index', as: 'index' + + get 'tasks/index' => "tasks#index" get 'tasks/new' get 'tasks/show' + get 'tasks/show/:id' => 'tasks#show', as: 'show' get 'tasks/destroy' From af37646045e5039523a5fe1d24b53fc523fb3471 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 15:39:22 -0700 Subject: [PATCH 06/42] Each task links to a full description of that task on show page. Wave 1 requirements --- task_list/app/views/tasks/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 658a0d81f..ac2d0c210 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -6,7 +6,8 @@

<% if @task_of_interest[:completed] == true %> - ✔︎ This task is complete! + ✔︎ This task was completed on <%=@task_of_interest[:completed_at]%> + <%else%> ❏This task is NOT completed yet <%end %> From 193129f93e2114731708f641f1b1904d9b9dfe98 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 15:51:58 -0700 Subject: [PATCH 07/42] Skeleton of Add a new Task form --- task_list/app/views/tasks/new.html.erb | 23 +++++++++++++++++++++-- task_list/app/views/tasks/show.html.erb | 1 - task_list/config/routes.rb | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index 2484008a3..f827a0551 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -1,2 +1,21 @@ -

Tasks#new

-

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

+

Add a Task

+ +
+ + + + + + + + + <%= tag(:input, :type => "hidden", + :name => request_forgery_protection_token.to_s, + :value => form_authenticity_token) %> + + + +
+ + + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index ac2d0c210..a9efd58bf 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -7,7 +7,6 @@ <% if @task_of_interest[:completed] == true %> ✔︎ This task was completed on <%=@task_of_interest[:completed_at]%> - <%else%> ❏This task is NOT completed yet <%end %> diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 7289869ba..32ad595da 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -5,6 +5,7 @@ get 'tasks/index' => "tasks#index" get 'tasks/new' + post 'tasks/create' => 'tasks#create', as: 'create' get 'tasks/show' get 'tasks/show/:id' => 'tasks#show', as: 'show' From 91bb6fc2989b4c2cbf6ebd83d1fa5eb038c03d4f Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 28 Sep 2016 16:28:03 -0700 Subject: [PATCH 08/42] Delete option included for each task listed on the homepage --- task_list/app/controllers/tasks_controller.rb | 6 ++++++ task_list/app/views/tasks/create.html.erb | 2 ++ task_list/app/views/tasks/index.html.erb | 7 +++++++ task_list/config/routes.rb | 6 ++++-- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 task_list/app/views/tasks/create.html.erb diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 4144856c3..bded310f9 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -31,4 +31,10 @@ def edit def update end + + def create + @params = params + @title = params["title"] + @description = params["description"] + end end diff --git a/task_list/app/views/tasks/create.html.erb b/task_list/app/views/tasks/create.html.erb new file mode 100644 index 000000000..fcad439c4 --- /dev/null +++ b/task_list/app/views/tasks/create.html.erb @@ -0,0 +1,2 @@ +

Tasks#create

+

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

diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index ade61f994..2ff52c108 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -2,6 +2,13 @@ <% @tasks.each do |task| %>

<%= link_to("#{task.title}", show_path(task[:id])) %>

+

+ <%=link_to("Delete", destroy_path) %> +

<% end %> +

+ <%=link_to("Add a Task", new_path) %> +

+ diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 32ad595da..ea329cd69 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,16 +1,18 @@ Rails.application.routes.draw do + get 'tasks/create' + root to: 'tasks#index', as: 'index' get 'tasks/index' => "tasks#index" - get 'tasks/new' + get 'tasks/new' => 'tasks#new', as: 'new' post 'tasks/create' => 'tasks#create', as: 'create' get 'tasks/show' get 'tasks/show/:id' => 'tasks#show', as: 'show' - get 'tasks/destroy' + get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' get 'tasks/edit' From d043808ec22016ba0a648d72f770ed3f4fbe60ec Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 09:41:52 -0700 Subject: [PATCH 09/42] Add a task successfully adds a task to the home page --- task_list/app/controllers/tasks_controller.rb | 22 ++++++++++++++++--- task_list/app/views/tasks/new.html.erb | 2 +- task_list/config/routes.rb | 1 + .../db/migrate/20160928212630_create_tasks.rb | 1 - 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index bded310f9..3f4f6c792 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -5,6 +5,7 @@ def index end def new + @task = Task.new end def show @@ -24,6 +25,7 @@ def show end def destroy + @task.destroy end def edit @@ -32,9 +34,23 @@ def edit def update end + def create - @params = params - @title = params["title"] - @description = params["description"] + @task = Task.new(title: params[:title], description: params[:description]) + @task.save + + if @task.save + redirect_to index_path, alert: "Task successfully added." + else + redirect_to new_path, alert: "Error adding task." + end end + + + private + def task_params + #Tells Rails you can accept submits from the form + params.require(:task).permit(:title, :description) + end + end diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index f827a0551..f9f76d794 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -5,7 +5,7 @@ - + diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index ea329cd69..b0643c694 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -7,6 +7,7 @@ get 'tasks/index' => "tasks#index" get 'tasks/new' => 'tasks#new', as: 'new' + post 'tasks/create' => 'tasks#create', as: 'create' get 'tasks/show' diff --git a/task_list/db/migrate/20160928212630_create_tasks.rb b/task_list/db/migrate/20160928212630_create_tasks.rb index ab8295b77..d7b7e1700 100644 --- a/task_list/db/migrate/20160928212630_create_tasks.rb +++ b/task_list/db/migrate/20160928212630_create_tasks.rb @@ -5,7 +5,6 @@ def change t.text :description t.boolean :completed t.datetime :completed_at - t.timestamps null: false end end From 0d809c4f7077584d9caf913fea2f2966bcdf7700 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 15:41:18 -0700 Subject: [PATCH 10/42] Can delete tasks from the task list --- task_list/Gemfile | 3 +-- task_list/Gemfile.lock | 2 ++ task_list/app/controllers/tasks_controller.rb | 3 ++- task_list/app/views/tasks/destroy.html.erb | 2 -- task_list/app/views/tasks/index.html.erb | 4 +++- task_list/app/views/tasks/new.html.erb | 2 +- task_list/config/routes.rb | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 task_list/app/views/tasks/destroy.html.erb diff --git a/task_list/Gemfile b/task_list/Gemfile index e87fad5fc..d7371e6c2 100644 --- a/task_list/Gemfile +++ b/task_list/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/task_list/Gemfile.lock b/task_list/Gemfile.lock index 187046034..b6d552c2c 100644 --- a/task_list/Gemfile.lock +++ b/task_list/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/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 3f4f6c792..db465893c 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -25,7 +25,8 @@ def show end def destroy - @task.destroy + Task.find(params[:id].to_i).destroy + redirect_to :index end def edit diff --git a/task_list/app/views/tasks/destroy.html.erb b/task_list/app/views/tasks/destroy.html.erb deleted file mode 100644 index a90559f9d..000000000 --- a/task_list/app/views/tasks/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Tasks#destroy

-

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

diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 2ff52c108..f73f7b17b 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,9 +1,11 @@

Task List

+

<%= @welcome_msg %>

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

<%= link_to("#{task.title}", show_path(task[:id])) %>

- <%=link_to("Delete", destroy_path) %> + <%= button_to "Delete Task", { action: "destroy", id: task.id }, + method: :delete, data: { confirm: "Are you sure?" } %>

<% end %> diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index f9f76d794..063e270d0 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -13,7 +13,7 @@ :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) %> - + diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index b0643c694..ab2cbcad2 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -7,13 +7,14 @@ get 'tasks/index' => "tasks#index" get 'tasks/new' => 'tasks#new', as: 'new' - + post 'tasks/create' => 'tasks#create', as: 'create' get 'tasks/show' get 'tasks/show/:id' => 'tasks#show', as: 'show' get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' + delete 'tasks/:id/destroy' => 'tasks#destroy' get 'tasks/edit' From 1564e89b5981a651bfa0c3332f5afdb628ff591e Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 16:47:13 -0700 Subject: [PATCH 11/42] Can now click on button to change the completion status of a task --- task_list/app/controllers/tasks_controller.rb | 13 +++++++++---- task_list/app/models/task.rb | 5 +++++ task_list/app/views/tasks/show.html.erb | 3 ++- task_list/config/routes.rb | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index db465893c..6a5163b58 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -25,17 +25,22 @@ def show end def destroy - Task.find(params[:id].to_i).destroy + task.destroy redirect_to :index end + def task + @task ||= Task.find(params[:id].to_i) + end + def edit end def update + task.update_attributes(task_params) + redirect_to action: :show, id: params[:id] end - def create @task = Task.new(title: params[:title], description: params[:description]) @task.save @@ -50,8 +55,8 @@ def create private def task_params - #Tells Rails you can accept submits from the form - params.require(:task).permit(:title, :description) + #Tells Rails which parameters can be changed + params.require(:task).permit(:title, :description, :completed) end end diff --git a/task_list/app/models/task.rb b/task_list/app/models/task.rb index 935f76e12..d153728bc 100644 --- a/task_list/app/models/task.rb +++ b/task_list/app/models/task.rb @@ -1,2 +1,7 @@ class Task < ActiveRecord::Base + + def format_datetime + attributes[:updated_at].strftime("%m/%d/%Y %H:%M") + end + end diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index a9efd58bf..85b9b2cc3 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -6,9 +6,10 @@

<% if @task_of_interest[:completed] == true %> - ✔︎ This task was completed on <%=@task_of_interest[:completed_at]%> + ✔︎ This task was completed on <%=@task_of_interest[:updated_at]%> <%else%> ❏This task is NOT completed yet + <%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %> <%end %>

diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index ab2cbcad2..1d8653c2f 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -18,7 +18,7 @@ get 'tasks/edit' - get 'tasks/update' + patch 'tasks/update' => "tasks#update", as: 'update' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From f75cc20968d7ec1a65cb4dc307c1ae7e201e9ceb Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 17:01:08 -0700 Subject: [PATCH 12/42] Formatted datetime for completion time --- task_list/app/models/task.rb | 2 +- task_list/app/views/tasks/show.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/task_list/app/models/task.rb b/task_list/app/models/task.rb index d153728bc..a64356215 100644 --- a/task_list/app/models/task.rb +++ b/task_list/app/models/task.rb @@ -1,7 +1,7 @@ class Task < ActiveRecord::Base def format_datetime - attributes[:updated_at].strftime("%m/%d/%Y %H:%M") + @updated_at.strftime("%m/%d/%Y %H:%M") end end diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 85b9b2cc3..b2d6de7b0 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -6,7 +6,7 @@

<% if @task_of_interest[:completed] == true %> - ✔︎ This task was completed on <%=@task_of_interest[:updated_at]%> + ✔︎ This task was completed on <%=@task_of_interest.updated_at.to_formatted_s(:long)%> <%else%> ❏This task is NOT completed yet <%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %> From 20a45a2b42a6bcd4039c0dbd8748b360cdc1b3df Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 20:22:18 -0700 Subject: [PATCH 13/42] Added checks or boxes on each tak based on completion for index page --- task_list/app/views/tasks/index.html.erb | 10 ++++++++-- task_list/app/views/tasks/show.html.erb | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index f73f7b17b..23afcce07 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -2,9 +2,15 @@

<%= @welcome_msg %>

<% @tasks.each do |task| %> -

<%= link_to("#{task.title}", show_path(task[:id])) %>

+ + <% if task.completed == true %> +

<%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

+ <%else%> +

<%= link_to("❏#{task.title}", show_path(task[:id])) %>

+ <%end %> +

- <%= button_to "Delete Task", { action: "destroy", id: task.id }, + <%= button_to "Delete Task", { action: "destroy", id: task.id }, method: :delete, data: { confirm: "Are you sure?" } %>

<% end %> diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index b2d6de7b0..d7b4077f3 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,10 +1,10 @@
+

<%= @task_of_interest[:title]%>

<%= @task_of_interest[:description] %>

- <% if @task_of_interest[:completed] == true %> ✔︎ This task was completed on <%=@task_of_interest.updated_at.to_formatted_s(:long)%> <%else%> From 61de31c4e93ff0722cf5e23a9f807bd1a4b93084 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 21:16:58 -0700 Subject: [PATCH 14/42] CSS format index page --- .../app/assets/stylesheets/application.css | 5 +++ task_list/app/assets/stylesheets/tasks.scss | 43 +++++++++++++++++++ task_list/app/controllers/tasks_controller.rb | 1 - task_list/app/models/task.rb | 4 -- .../app/views/layouts/application.html.erb | 1 + task_list/app/views/tasks/index.html.erb | 30 ++++++------- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/task_list/app/assets/stylesheets/application.css b/task_list/app/assets/stylesheets/application.css index f9cd5b348..25be03fd5 100644 --- a/task_list/app/assets/stylesheets/application.css +++ b/task_list/app/assets/stylesheets/application.css @@ -13,3 +13,8 @@ *= require_tree . *= require_self */ + + .list { + font-family: Permanent Marker; + + } diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index b57862ec7..a50d6a783 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -1,3 +1,46 @@ // 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/ + + +.post-it { + font-family: Permanent Marker; + background:#fefabc; + padding:15px; + font-size:1em; + color: #000; + width:40%; + margin-left: 20%; + + -moz-transform: rotate(-5deg); + -webkit-transform: rotate(-5deg); + -o-transform: rotate(-5deg); + -ms-transform: rotate(-5deg); + transform: rotate(-5deg); + + box-shadow: 0px 4px 6px #333; + -moz-box-shadow: 0px 4px 6px #333; + -webkit-box-shadow: 0px 4px 6px #333; +} + +a{ + text-decoration: none; + color: black; +} + +h1 { + font-size: 3em; + text-decoration: underline; + text-align: center; +} + +#add { + border: solid red 5px; + border-radius: 100%; + text-align: center; + width: 20%; + font-size: 1em; + float: right; + padding: 5%; + margin-top: -6%; +} diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 6a5163b58..44f1b8c7d 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -1,6 +1,5 @@ class TasksController < ApplicationController def index - @welcome_msg = "Let's get down to business" @tasks = Task.all end diff --git a/task_list/app/models/task.rb b/task_list/app/models/task.rb index a64356215..ee0282c79 100644 --- a/task_list/app/models/task.rb +++ b/task_list/app/models/task.rb @@ -1,7 +1,3 @@ class Task < ActiveRecord::Base - def format_datetime - @updated_at.strftime("%m/%d/%Y %H:%M") - end - end diff --git a/task_list/app/views/layouts/application.html.erb b/task_list/app/views/layouts/application.html.erb index 0bc12ec2d..15c3875d9 100644 --- a/task_list/app/views/layouts/application.html.erb +++ b/task_list/app/views/layouts/application.html.erb @@ -5,6 +5,7 @@ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> + diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 23afcce07..103cb1635 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,22 +1,20 @@ -

Task List

-

<%= @welcome_msg %>

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

Task List

<%=link_to("Add a Task", new_path) %>

+

+ <% @tasks.each do |task| %> - <% if task.completed == true %> -

<%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

- <%else%> -

<%= link_to("❏#{task.title}", show_path(task[:id])) %>

- <%end %> + <% if task.completed == true %> +

<%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

+ <%else%> +

<%= link_to("❏#{task.title}", show_path(task[:id])) %>

+ <%end %> +

-

- <%= button_to "Delete Task", { action: "destroy", id: task.id }, - method: :delete, data: { confirm: "Are you sure?" } %> -

-<% end %> +

<%= button_to "Delete Task", { action: "destroy", id: task.id }, + method: :delete, data: { confirm: "Are you sure?" } %>

+ <% end %> -

- <%=link_to("Add a Task", new_path) %> -

+
From bbd069996d5f60002808e6fd0f1ccf45ae80c49b Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 21:23:25 -0700 Subject: [PATCH 15/42] Notebook style background --- task_list/app/assets/stylesheets/tasks.scss | 9 ++++++++- task_list/app/views/tasks/index.html.erb | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index a50d6a783..a8c86367a 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -39,8 +39,15 @@ h1 { border-radius: 100%; text-align: center; width: 20%; - font-size: 1em; + font-size: 1.25em; float: right; padding: 5%; margin-top: -6%; } +body{ +background-color: #fff; +background-image: +linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px), +linear-gradient(#eee .1em, transparent .1em); +background-size: 100% 1.2em; +} diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 103cb1635..5912d4660 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,6 +1,6 @@
-

Task List

<%=link_to("Add a Task", new_path) %>

+

Task List

<%=link_to("Add new task", new_path) %>

<% @tasks.each do |task| %> From 508e3f3d1d931c3de51a2867a0b38861efb5308e Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 21:55:21 -0700 Subject: [PATCH 16/42] CSS format show pages for each task --- task_list/app/assets/stylesheets/tasks.scss | 47 +++++++++++++++------ task_list/app/views/tasks/show.html.erb | 6 +-- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index a8c86367a..b6a181362 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -6,17 +6,19 @@ .post-it { font-family: Permanent Marker; background:#fefabc; - padding:15px; + padding: 2%; + padding-top: .25%; font-size:1em; color: #000; - width:40%; + width:50%; margin-left: 20%; + margin-top: 3%; - -moz-transform: rotate(-5deg); - -webkit-transform: rotate(-5deg); - -o-transform: rotate(-5deg); - -ms-transform: rotate(-5deg); - transform: rotate(-5deg); + -moz-transform: rotate(-4deg); + -webkit-transform: rotate(-4deg); + -o-transform: rotate(-4deg); + -ms-transform: rotate(-4deg); + transform: rotate(-4deg); box-shadow: 0px 4px 6px #333; -moz-box-shadow: 0px 4px 6px #333; @@ -28,12 +30,24 @@ a{ color: black; } +a:hover { + color: #757575; +} + h1 { font-size: 3em; text-decoration: underline; text-align: center; } +h2{ + font-size: 2em; +} + +h3, .completion{ + font-family: courier; +} + #add { border: solid red 5px; border-radius: 100%; @@ -41,13 +55,18 @@ h1 { width: 20%; font-size: 1.25em; float: right; - padding: 5%; + padding: 3%; margin-top: -6%; } -body{ -background-color: #fff; -background-image: -linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px), -linear-gradient(#eee .1em, transparent .1em); -background-size: 100% 1.2em; + +body { + background-color: #fff; + background-image: + linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px), + linear-gradient(#eee .1em, transparent .1em); + background-size: 100% 1.2em; +} + +.delete-button{ + margin-top: -5%; } diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index d7b4077f3..75f7b3ce4 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,12 +1,12 @@ -

+

<%= @task_of_interest[:title]%>

<%= @task_of_interest[:description] %>

-

+

<% if @task_of_interest[:completed] == true %> - ✔︎ This task was completed on <%=@task_of_interest.updated_at.to_formatted_s(:long)%> + ✔︎ Task completed on: <%=@task_of_interest.updated_at.to_formatted_s(:long)%> <%else%> ❏This task is NOT completed yet <%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %> From 8539e9e002664f36e0d7f0ef0f7fbdf9b5889330 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Thu, 29 Sep 2016 22:06:28 -0700 Subject: [PATCH 17/42] Repositioned add new task link on index page --- task_list/app/assets/stylesheets/tasks.scss | 9 ++++++--- task_list/app/views/tasks/index.html.erb | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index b6a181362..b1ef2c2f3 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -31,7 +31,7 @@ a{ } a:hover { - color: #757575; + text-decoration: underline; } h1 { @@ -53,10 +53,13 @@ h3, .completion{ border-radius: 100%; text-align: center; width: 20%; + font-family: courier; font-size: 1.25em; float: right; - padding: 3%; - margin-top: -6%; + padding: 1%; + margin-top: 5%; + margin-right: 5%; + } body { diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 5912d4660..3442ddda4 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,6 +1,7 @@

-

Task List

<%=link_to("Add new task", new_path) %>

+

<%=link_to("Add new task", new_path) %>

+

Task List

<% @tasks.each do |task| %> From 119cdc9dddb85c7c0f1e167e546b3311aa8a6104 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Fri, 30 Sep 2016 10:11:32 -0700 Subject: [PATCH 18/42] Links to full task list on show and new page --- task_list/Gemfile | 2 ++ task_list/Gemfile.lock | 7 +++++++ task_list/app/assets/stylesheets/tasks.scss | 15 ++++++++++++--- task_list/app/views/tasks/new.html.erb | 1 + task_list/app/views/tasks/show.html.erb | 2 ++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/task_list/Gemfile b/task_list/Gemfile index d7371e6c2..b8edd684d 100644 --- a/task_list/Gemfile +++ b/task_list/Gemfile @@ -40,6 +40,8 @@ end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' + gem "better_errors" + gem "binding_of_caller" # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' diff --git a/task_list/Gemfile.lock b/task_list/Gemfile.lock index b6d552c2c..86a8d23f6 100644 --- a/task_list/Gemfile.lock +++ b/task_list/Gemfile.lock @@ -38,10 +38,15 @@ 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) + coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -148,6 +153,8 @@ PLATFORMS DEPENDENCIES awesome_print + better_errors + binding_of_caller byebug coffee-rails (~> 4.1.0) jbuilder (~> 2.0) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index b1ef2c2f3..cf2451f84 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -48,18 +48,27 @@ h3, .completion{ font-family: courier; } -#add { +#add, #full-list { border: solid red 5px; border-radius: 100%; text-align: center; - width: 20%; + float: right; font-family: courier; font-size: 1.25em; - float: right; padding: 1%; +} + +#add{ margin-top: 5%; margin-right: 5%; + width: 20%; +} +#full-list { + padding: 1%; + margin-top: 1%; + margin-right: 10%; + width: 10%; } body { diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index 063e270d0..b20819787 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -1,4 +1,5 @@

Add a Task

+

<%=link_to("Task List", index_path) %>

diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 75f7b3ce4..eb9afe26c 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,3 +1,5 @@ +

<%=link_to("Task List", index_path) %>

+

<%= @task_of_interest[:title]%>

From daabf7fd2c6124e63040dff5004cefb9e0de36ef Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Fri, 30 Sep 2016 10:29:17 -0700 Subject: [PATCH 19/42] Started to format page for add a task --- task_list/app/assets/stylesheets/tasks.scss | 17 ++++++++++++++++- task_list/app/views/tasks/new.html.erb | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index cf2451f84..a2da871e5 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -38,16 +38,23 @@ h1 { font-size: 3em; text-decoration: underline; text-align: center; + font-family: courier; } h2{ font-size: 2em; } -h3, .completion{ +h3, .completion, label{ font-family: courier; } +form{ + text-align: left; + font-size: 2em; + margin-left: 25%; +} + #add, #full-list { border: solid red 5px; border-radius: 100%; @@ -82,3 +89,11 @@ body { .delete-button{ margin-top: -5%; } + +input, textarea { + border: 2px solid #abced4; + border-radius: 5%; + height: 2em; + font-family: courier; + font-size: 1em; +} diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index b20819787..ad2edf4a5 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -5,8 +5,9 @@ - +

+

From 1278c33984a4dae0c421faf1320fba366eba9343 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Fri, 30 Sep 2016 11:25:58 -0700 Subject: [PATCH 20/42] Formatting of index page - remove tilt and put deletes on same line as task --- task_list/app/assets/stylesheets/tasks.scss | 34 +++++++++++++++------ task_list/app/views/tasks/index.html.erb | 2 +- task_list/app/views/tasks/new.html.erb | 4 +-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index a2da871e5..d660c23cc 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -6,7 +6,7 @@ .post-it { font-family: Permanent Marker; background:#fefabc; - padding: 2%; + padding: 5%; padding-top: .25%; font-size:1em; color: #000; @@ -14,12 +14,6 @@ margin-left: 20%; margin-top: 3%; - -moz-transform: rotate(-4deg); - -webkit-transform: rotate(-4deg); - -o-transform: rotate(-4deg); - -ms-transform: rotate(-4deg); - transform: rotate(-4deg); - box-shadow: 0px 4px 6px #333; -moz-box-shadow: 0px 4px 6px #333; -webkit-box-shadow: 0px 4px 6px #333; @@ -43,6 +37,8 @@ h1 { h2{ font-size: 2em; + width: 75%; + margin-right: 0%; } h3, .completion, label{ @@ -87,13 +83,31 @@ body { } .delete-button{ - margin-top: -5%; + margin-top: -9%; } -input, textarea { +.form-box{ border: 2px solid #abced4; border-radius: 5%; - height: 2em; + height: 1.5em; font-family: courier; font-size: 1em; } + +textarea{ + width: 56%; + margin-top: -3%; +} + +#delete-button input{ + font-size: .5em; + font-family: courier; +} + +form.button_to { + width: 10%; + margin: 0%; + padding-left: 50%; + margin-top: -12%; + +} diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 3442ddda4..00db77cfe 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -12,7 +12,7 @@ <%end %>

-

<%= button_to "Delete Task", { action: "destroy", id: task.id }, +

<%= button_to "Delete", { action: "destroy", id: task.id }, method: :delete, data: { confirm: "Are you sure?" } %>

<% end %> diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index ad2edf4a5..0cbfebaa0 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -4,11 +4,11 @@ - +

- + <%= tag(:input, :type => "hidden", From b67cfe3f88c065a0b962a332d5c2184e5b17e4a3 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Fri, 30 Sep 2016 13:56:51 -0700 Subject: [PATCH 21/42] Tweak position of complete button on show pages --- task_list/app/assets/stylesheets/tasks.scss | 19 ++++++++++++++----- task_list/app/views/tasks/new.html.erb | 2 +- task_list/app/views/tasks/show.html.erb | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index d660c23cc..345d6347a 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -51,7 +51,7 @@ form{ margin-left: 25%; } -#add, #full-list { +#add, #full-list, #full-list-show, #full-list-new { border: solid red 5px; border-radius: 100%; text-align: center; @@ -74,6 +74,15 @@ form{ width: 10%; } +#full-list-show { + margin-right: 25%; +} + +#full-list-new{ + margin-top: -5%; + margin-right: 20%; +} + body { background-color: #fff; background-image: @@ -99,10 +108,6 @@ textarea{ margin-top: -3%; } -#delete-button input{ - font-size: .5em; - font-family: courier; -} form.button_to { width: 10%; @@ -111,3 +116,7 @@ form.button_to { margin-top: -12%; } + +.complete-button { + margin-top: 5%; +} diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index 0cbfebaa0..92ed65058 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -1,5 +1,5 @@

Add a Task

-

<%=link_to("Task List", index_path) %>

+

<%=link_to("Task List", index_path) %>

diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index eb9afe26c..d4da35484 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,4 +1,4 @@ -

<%=link_to("Task List", index_path) %>

+

<%=link_to("Task List", index_path) %>

@@ -11,7 +11,7 @@ ✔︎ Task completed on: <%=@task_of_interest.updated_at.to_formatted_s(:long)%> <%else%> ❏This task is NOT completed yet - <%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %> +

<%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

<%end %>

From d7c3e155e95d491f33078d90e7891c6b6b087240 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Fri, 30 Sep 2016 15:51:33 -0700 Subject: [PATCH 22/42] Can complete tasks from index as well as show pages --- task_list/app/assets/stylesheets/tasks.scss | 58 ++++++++++++------- task_list/app/controllers/tasks_controller.rb | 3 +- task_list/app/views/tasks/index.html.erb | 15 +++-- task_list/app/views/tasks/new.html.erb | 2 +- task_list/app/views/tasks/show.html.erb | 6 +- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index 345d6347a..b66e37345 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -13,7 +13,6 @@ width:50%; margin-left: 20%; margin-top: 3%; - box-shadow: 0px 4px 6px #333; -moz-box-shadow: 0px 4px 6px #333; -webkit-box-shadow: 0px 4px 6px #333; @@ -37,15 +36,16 @@ h1 { h2{ font-size: 2em; - width: 75%; - margin-right: 0%; + width: 60%; + margin: 0%; + display: inline; } h3, .completion, label{ font-family: courier; } -form{ +.form-new{ text-align: left; font-size: 2em; margin-left: 25%; @@ -91,10 +91,6 @@ body { background-size: 100% 1.2em; } -.delete-button{ - margin-top: -9%; -} - .form-box{ border: 2px solid #abced4; border-radius: 5%; @@ -108,15 +104,37 @@ textarea{ margin-top: -3%; } - -form.button_to { - width: 10%; - margin: 0%; - padding-left: 50%; - margin-top: -12%; - -} - -.complete-button { - margin-top: 5%; -} +ul li{ + list-style-type: none; +} + +li * { + display: inline; +} +// form.button_to { +// width: 20%; +// margin: 0%; +// } +// +// // .post-it .button_to { +// // display: inline-block; +// // +// // } +// h2, .delete-button, .complete-button-index{ +// display: inline; +// // margin: 100%; +// // padding: 0%; +// } +// +// // .post-it p { +// // display: inline; +// // float: right; +// // } +// +// .post-it { +// position: relative; +// } +// // .complete-button input { +// // margin-top: 100%; +// // margin-left: 90%; +// // } diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 44f1b8c7d..296cf1101 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -37,7 +37,7 @@ def edit def update task.update_attributes(task_params) - redirect_to action: :show, id: params[:id] + redirect_to request.referrer #redirects to whatever page you came from with the updated content end def create @@ -51,7 +51,6 @@ def create end end - private def task_params #Tells Rails which parameters can be changed diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 00db77cfe..afe170a51 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -3,17 +3,22 @@

<%=link_to("Add new task", new_path) %>

Task List

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

    <% if task.completed == true %> -

    <%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

    +
  • <%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

  • <%else%> -

    <%= link_to("❏#{task.title}", show_path(task[:id])) %>

    +
  • <%= link_to("❏#{task.title}", show_path(task[:id])) %>

  • + +
  • <%= button_to "Complete", { action: "update", id: task.id, task: { completed: true} }, method: :patch %>

  • <%end %>

    -

    <%= button_to "Delete", { action: "destroy", id: task.id }, - method: :delete, data: { confirm: "Are you sure?" } %>

    +
  • <%= button_to "Delete", { action: "destroy", id: task.id }, + + method: :delete, data: { confirm: "Are you sure?" } %>

  • +
<% end %>
diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index 92ed65058..c56e53770 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -1,7 +1,7 @@

Add a Task

<%=link_to("Task List", index_path) %>

- + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index d4da35484..823190e1f 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -8,10 +8,12 @@

<% if @task_of_interest[:completed] == true %> - ✔︎ Task completed on: <%=@task_of_interest.updated_at.to_formatted_s(:long)%> + <% @task_of_interest[:completed_at] = @task_of_interest[:updated_at] %> + + ✔︎ Task completed on: <%=@task_of_interest.completed_at.to_formatted_s(:long)%> <%else%> ❏This task is NOT completed yet -

<%= button_to "Complete Task", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

+

<%= button_to "Complete", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

<%end %>

From 79604818489ff8b6f2e7127c7690e3823366d15b Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 3 Oct 2016 09:17:06 -0700 Subject: [PATCH 23/42] Added functionality to edit tasks --- task_list/app/controllers/tasks_controller.rb | 8 +++++- task_list/app/views/tasks/edit.html.erb | 26 +++++++++++++++++-- task_list/app/views/tasks/show.html.erb | 9 ++++++- task_list/config/routes.rb | 10 ++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 296cf1101..5a2f5776d 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -33,13 +33,19 @@ def task end def edit + @task = Task.find(params[:id].to_i) end def update task.update_attributes(task_params) - redirect_to request.referrer #redirects to whatever page you came from with the updated content + redirect_to index_path end + def complete + task.update_attributes(task_params) + redirect_to request.referrer #redirects to whatever page you came from with the updated c + end + def create @task = Task.new(title: params[:title], description: params[:description]) @task.save diff --git a/task_list/app/views/tasks/edit.html.erb b/task_list/app/views/tasks/edit.html.erb index 374190308..7559c7baa 100644 --- a/task_list/app/views/tasks/edit.html.erb +++ b/task_list/app/views/tasks/edit.html.erb @@ -1,2 +1,24 @@ -

Tasks#edit

-

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

+

Edit Task

+ +
+<%= form_for @task, url: update_path do |f| %> + + <%= f.label :title %> + <%= f.text_field :title, class:"form-box"%> + +

+ + <%= f.label :description%> + <%= f.text_area :description, class:"form-box"%> + +

+ + <%= f.label :completed%> + <%= f.text_area :completed, class:"form-box"%> + + <%= f.submit %> + + <%end%> +
+ + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 823190e1f..acb83af65 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -13,9 +13,16 @@ ✔︎ Task completed on: <%=@task_of_interest.completed_at.to_formatted_s(:long)%> <%else%> ❏This task is NOT completed yet -

<%= button_to "Complete", { action: "update", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

+

<%= button_to "Complete", { action: "complete", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

<%end %>

+

<%= button_to "Delete", { action: "destroy", id: @task_of_interest.id }, + + method: :delete, data: { confirm: "Are you sure?" } %>

+ +

<%= button_to "Edit", { action: "edit", id: @task_of_interest.id }, + + method: :get %>

diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 1d8653c2f..b6577aea0 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,7 +1,5 @@ Rails.application.routes.draw do - get 'tasks/create' - root to: 'tasks#index', as: 'index' get 'tasks/index' => "tasks#index" @@ -16,9 +14,13 @@ get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' delete 'tasks/:id/destroy' => 'tasks#destroy' - get 'tasks/edit' + get 'tasks/edit/:id' => "tasks#edit", as: 'edit' + + get 'tasks/update' => "tasks#update" + patch 'tasks/update/:id' => "tasks#update", as: 'update' - patch 'tasks/update' => "tasks#update", as: 'update' + get 'tasks/complete' => "tasks#complete" + patch 'tasks/complete/:id' => "tasks#complete", as: 'complete' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From b2aecd716a4972f1e8c974c0b91e51e6a887a789 Mon Sep 17 00:00:00 2001 From: Erin007 Date: Mon, 3 Oct 2016 09:31:51 -0700 Subject: [PATCH 24/42] Update README.md Reflection 10-3-16 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2b96daf9c..758b3c6b1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +# Erin's Reflection + +This was by far my least favorite project so far, and I was confused most of the time. It was so difficult to know what was default Rails automagic and how to go in to change those attributes. Troubleshooting was really tricky because sometimes the issue was with something Rails automatically did - like buttons automatically going to push methods. For example, figuring out how to target different sections of a form written in erb rather than html for formatting was frustrating. I have a little hacky solution where I stuck in empty p tags so there would be space between the different form sections, but I don't know how to achieve this in a more conventional way. I'm still not sure how to style buttons. I'm not sure how to make my "complete", "edit" and "delete" buttons line up inline with the task. I have logic in my view for whether to show the empty box or the check mark and I'm pretty sure it shouldn't be there because we're not supposed to have logic there. + +My chair pair helped me separate my update method into two methods wherein I updated the completion status separately. This was a better way than I had originally because the completion status needed to go to current page with the updates, but when editing the update needed to appear on a different page. My chair pair also used radio buttons for the completion status, which I don't know how to do. + + + # 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 9c0bdca172ef071cdcea2a32b924170923f36e21 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 3 Oct 2016 09:32:53 -0700 Subject: [PATCH 25/42] Final --- task_list/app/controllers/tasks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 5a2f5776d..bcf39b8a1 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -33,7 +33,7 @@ def task end def edit - @task = Task.find(params[:id].to_i) + task end def update @@ -45,7 +45,7 @@ def complete task.update_attributes(task_params) redirect_to request.referrer #redirects to whatever page you came from with the updated c end - + def create @task = Task.new(title: params[:title], description: params[:description]) @task.save From cae210649ef62dcd981f9a102d831b21c0f7049c Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Sat, 22 Oct 2016 12:49:27 -0700 Subject: [PATCH 26/42] Full task list style the check box and x in line and intial oAuth work from in class --- task_list/.gitignore | 3 ++ task_list/Gemfile | 8 ++++ task_list/Gemfile.lock | 38 ++++++++++++++++++- .../app/assets/javascripts/sessions.coffee | 3 ++ .../app/assets/stylesheets/application.css | 1 - .../app/assets/stylesheets/sessions.scss | 3 ++ task_list/app/assets/stylesheets/tasks.scss | 2 +- .../app/controllers/sessions_controller.rb | 4 ++ task_list/app/controllers/tasks_controller.rb | 2 +- task_list/app/helpers/sessions_helper.rb | 2 + task_list/app/models/user.rb | 2 + task_list/app/views/sessions/create.html.erb | 2 + task_list/app/views/tasks/index.html.erb | 4 +- task_list/config/initializers/omniauth.rb | 3 ++ task_list/config/routes.rb | 4 ++ .../db/migrate/20161018170856_create_users.rb | 12 ++++++ task_list/db/schema.rb | 11 +++++- .../controllers/sessions_controller_test.rb | 33 ++++++++++++++++ .../test/controllers/tasks_controller_test.rb | 14 +++++++ task_list/test/fixtures/tasks.yml | 18 ++++----- task_list/test/fixtures/users.yml | 16 ++++++++ task_list/test/models/user_test.rb | 7 ++++ task_list/test/test_helper.rb | 8 ++++ 23 files changed, 184 insertions(+), 16 deletions(-) create mode 100644 task_list/app/assets/javascripts/sessions.coffee create mode 100644 task_list/app/assets/stylesheets/sessions.scss create mode 100644 task_list/app/controllers/sessions_controller.rb create mode 100644 task_list/app/helpers/sessions_helper.rb create mode 100644 task_list/app/models/user.rb create mode 100644 task_list/app/views/sessions/create.html.erb create mode 100644 task_list/config/initializers/omniauth.rb create mode 100644 task_list/db/migrate/20161018170856_create_users.rb create mode 100644 task_list/test/controllers/sessions_controller_test.rb create mode 100644 task_list/test/fixtures/users.yml create mode 100644 task_list/test/models/user_test.rb diff --git a/task_list/.gitignore b/task_list/.gitignore index 050c9d95c..67a7c90a9 100644 --- a/task_list/.gitignore +++ b/task_list/.gitignore @@ -15,3 +15,6 @@ /log/* !/log/.keep /tmp + +/.env +.DS_Store diff --git a/task_list/Gemfile b/task_list/Gemfile index b8edd684d..5360004cf 100644 --- a/task_list/Gemfile +++ b/task_list/Gemfile @@ -1,5 +1,7 @@ source 'https://rubygems.org' +gem 'omniauth' +gem 'omniauth-github' gem 'awesome_print' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' @@ -35,6 +37,12 @@ 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' + gem 'better_errors' +end + +group :test do + gem 'minitest-reporters' end group :development do diff --git a/task_list/Gemfile.lock b/task_list/Gemfile.lock index 86a8d23f6..43bf406aa 100644 --- a/task_list/Gemfile.lock +++ b/task_list/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) @@ -56,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) @@ -69,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) @@ -78,10 +87,32 @@ 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) 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) @@ -113,6 +144,7 @@ GEM rake (11.3.0) rdoc (4.2.2) json (~> 1.4) + ruby-progressbar (1.8.1) sass (3.4.22) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -157,8 +189,12 @@ DEPENDENCIES binding_of_caller byebug coffee-rails (~> 4.1.0) + dotenv-rails jbuilder (~> 2.0) jquery-rails + minitest-reporters + omniauth + omniauth-github rails (= 4.2.7) sass-rails (~> 5.0) sdoc (~> 0.4.0) @@ -169,4 +205,4 @@ DEPENDENCIES web-console (~> 2.0) BUNDLED WITH - 1.13.1 + 1.13.5 diff --git a/task_list/app/assets/javascripts/sessions.coffee b/task_list/app/assets/javascripts/sessions.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/task_list/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/task_list/app/assets/stylesheets/application.css b/task_list/app/assets/stylesheets/application.css index 25be03fd5..25d49cfc6 100644 --- a/task_list/app/assets/stylesheets/application.css +++ b/task_list/app/assets/stylesheets/application.css @@ -16,5 +16,4 @@ .list { font-family: Permanent Marker; - } diff --git a/task_list/app/assets/stylesheets/sessions.scss b/task_list/app/assets/stylesheets/sessions.scss new file mode 100644 index 000000000..7bef9cf82 --- /dev/null +++ b/task_list/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/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index b66e37345..1c9e198bb 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -108,7 +108,7 @@ ul li{ list-style-type: none; } -li * { +ul *{ display: inline; } // form.button_to { diff --git a/task_list/app/controllers/sessions_controller.rb b/task_list/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..22ca8debf --- /dev/null +++ b/task_list/app/controllers/sessions_controller.rb @@ -0,0 +1,4 @@ +class SessionsController < ApplicationController + def create + end +end diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index bcf39b8a1..261dc8c38 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -28,7 +28,7 @@ def destroy redirect_to :index end - def task + def task @task ||= Task.find(params[:id].to_i) end diff --git a/task_list/app/helpers/sessions_helper.rb b/task_list/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..309f8b2eb --- /dev/null +++ b/task_list/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/task_list/app/models/user.rb b/task_list/app/models/user.rb new file mode 100644 index 000000000..4a57cf079 --- /dev/null +++ b/task_list/app/models/user.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end diff --git a/task_list/app/views/sessions/create.html.erb b/task_list/app/views/sessions/create.html.erb new file mode 100644 index 000000000..c251174fe --- /dev/null +++ b/task_list/app/views/sessions/create.html.erb @@ -0,0 +1,2 @@ +

Sessions#create

+

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

diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index afe170a51..97e6158d7 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -11,11 +11,11 @@ <%else%>
  • <%= link_to("❏#{task.title}", show_path(task[:id])) %>

  • -
  • <%= button_to "Complete", { action: "update", id: task.id, task: { completed: true} }, method: :patch %>

  • +
  • <%= button_to "✔︎", { action: "update", id: task.id, task: { completed: true} }, method: :patch %>

  • <%end %>

    -
  • <%= button_to "Delete", { action: "destroy", id: task.id }, +

  • <%= button_to "✗", { action: "destroy", id: task.id }, method: :delete, data: { confirm: "Are you sure?" } %>

  • diff --git a/task_list/config/initializers/omniauth.rb b/task_list/config/initializers/omniauth.rb new file mode 100644 index 000000000..fd4416122 --- /dev/null +++ b/task_list/config/initializers/omniauth.rb @@ -0,0 +1,3 @@ +Rails.application.config.middleware.use OmniAuth::Builder do + provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user:email" +end diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index b6577aea0..52f5b8a3a 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do + get 'sessions/create' + root to: 'tasks#index', as: 'index' get 'tasks/index' => "tasks#index" @@ -22,6 +24,8 @@ get 'tasks/complete' => "tasks#complete" patch 'tasks/complete/:id' => "tasks#complete", as: 'complete' + get "/auth/:provider/callback" => "sessions#create" + # 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/task_list/db/migrate/20161018170856_create_users.rb b/task_list/db/migrate/20161018170856_create_users.rb new file mode 100644 index 000000000..f85251a60 --- /dev/null +++ b/task_list/db/migrate/20161018170856_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/task_list/db/schema.rb b/task_list/db/schema.rb index a5adfec22..6385b253a 100644 --- a/task_list/db/schema.rb +++ b/task_list/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: 20160928212630) do +ActiveRecord::Schema.define(version: 20161018170856) do create_table "tasks", force: :cascade do |t| t.string "title" @@ -22,4 +22,13 @@ t.datetime "updated_at", null: false 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/task_list/test/controllers/sessions_controller_test.rb b/task_list/test/controllers/sessions_controller_test.rb new file mode 100644 index 000000000..5d32739b2 --- /dev/null +++ b/task_list/test/controllers/sessions_controller_test.rb @@ -0,0 +1,33 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + test "should get create" do + get :create + assert_response :success + 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 + 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/task_list/test/controllers/tasks_controller_test.rb b/task_list/test/controllers/tasks_controller_test.rb index 7f7526bde..44c843636 100644 --- a/task_list/test/controllers/tasks_controller_test.rb +++ b/task_list/test/controllers/tasks_controller_test.rb @@ -1,6 +1,20 @@ require 'test_helper' class TasksControllerTest < ActionController::TestCase + + test "Make sure that a user can see their tasks." do + session[:user_id] = users(:ada) + 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(:ada) + get :show, id: tasks(:babbages_task).id + assert_response :redirect + assert_equal flash[:notice], "You do not have access to that task." + end + test "should get index" do get :index assert_response :success diff --git a/task_list/test/fixtures/tasks.yml b/task_list/test/fixtures/tasks.yml index 00ff08692..b6fc88b36 100644 --- a/task_list/test/fixtures/tasks.yml +++ b/task_list/test/fixtures/tasks.yml @@ -1,13 +1,13 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - title: MyString - description: MyText - completed: false +adas_task: + title: "Write the first code!" + description: "Fortran" + user: :ada #Each task belongs to one person; Each user has many tasks. We can use fixtures that reference other fixtures + completed: true completed_at: 2016-09-28 14:26:30 -two: - title: MyString - description: MyText - completed: false - completed_at: 2016-09-28 14:26:30 +babbages_task: + title: "Make the first computer" + description: "Build it!" + user: :babbage diff --git a/task_list/test/fixtures/users.yml b/task_list/test/fixtures/users.yml new file mode 100644 index 000000000..1fd9f45da --- /dev/null +++ b/task_list/test/fixtures/users.yml @@ -0,0 +1,16 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +#These fixtures will mimic users that have already logged in the past - we assume that they can pull in their information from Github. The mock hash in the setup method in the test_helper is there to test whether we can correctly connect to Github for authentication +ada: + id: 1 + uid: 8675309 + name: "Ada Lovelace" + provider: "github" + email: ada@gmail.com + +babbage: + id: 4 + uid: 2076158907 + name: "Charlie Babbage" + provider: "github" + email: babbage@gmail.com diff --git a/task_list/test/models/user_test.rb b/task_list/test/models/user_test.rb new file mode 100644 index 000000000..82f61e010 --- /dev/null +++ b/task_list/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/task_list/test/test_helper.rb b/task_list/test/test_helper.rb index 92e39b2d7..16bbd6974 100644 --- a/task_list/test/test_helper.rb +++ b/task_list/test/test_helper.rb @@ -1,10 +1,18 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'minitest-reporters' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all + def setup + OmniAuth.config.test_mode = true + + OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({ + provider: 'github', uid: '123545', info: { email: "a@b.com", name: "Ada" } + }) + end # Add more helper methods to be used by all tests here... end From fabd15a576fbf900840d866da7b2384e3ea3f490 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Sat, 22 Oct 2016 20:09:45 -0700 Subject: [PATCH 27/42] Can now login via Github and all orignal functionality is preserved --- task_list/app/assets/stylesheets/tasks.scss | 50 +++++++------------ .../app/controllers/sessions_controller.rb | 33 ++++++++++++ task_list/app/controllers/tasks_controller.rb | 24 ++++++--- task_list/app/models/task.rb | 2 +- task_list/app/models/user.rb | 13 +++++ .../app/views/layouts/application.html.erb | 9 +++- task_list/app/views/tasks/edit.html.erb | 4 +- task_list/app/views/tasks/index.html.erb | 44 ++++++++-------- task_list/app/views/tasks/new.html.erb | 27 ++++++++-- task_list/app/views/tasks/show.html.erb | 35 ++++++++----- task_list/config/routes.rb | 43 +++++++++------- ...0161022201940_accociate_user_with_tasks.rb | 5 ++ task_list/db/schema.rb | 3 +- 13 files changed, 188 insertions(+), 104 deletions(-) create mode 100644 task_list/db/migrate/20161022201940_accociate_user_with_tasks.rb diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index 1c9e198bb..df0d99dd6 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -3,21 +3,24 @@ // You can use Sass (SCSS) here: http://sass-lang.com/ -.post-it { +.post-it, .post-it-show { font-family: Permanent Marker; background:#fefabc; padding: 5%; - padding-top: .25%; font-size:1em; color: #000; width:50%; margin-left: 20%; - margin-top: 3%; + margin-top: 8%; box-shadow: 0px 4px 6px #333; -moz-box-shadow: 0px 4px 6px #333; -webkit-box-shadow: 0px 4px 6px #333; } +.post-it { + padding-top: .25%; +} + a{ text-decoration: none; color: black; @@ -28,7 +31,7 @@ a:hover { } h1 { - font-size: 3em; + font-size: 2.5em; text-decoration: underline; text-align: center; font-family: courier; @@ -61,6 +64,16 @@ h3, .completion, label{ padding: 1%; } +#login, #logout{ + float: left; + margin-top: -5%; + margin-left: 8%; + font-size: 1.5em; + text-decoration: underline; + text-align: center; + font-family: courier; +} + #add{ margin-top: 5%; margin-right: 5%; @@ -94,7 +107,7 @@ body { .form-box{ border: 2px solid #abced4; border-radius: 5%; - height: 1.5em; + height: 1.25em; font-family: courier; font-size: 1em; } @@ -111,30 +124,3 @@ ul li{ ul *{ display: inline; } -// form.button_to { -// width: 20%; -// margin: 0%; -// } -// -// // .post-it .button_to { -// // display: inline-block; -// // -// // } -// h2, .delete-button, .complete-button-index{ -// display: inline; -// // margin: 100%; -// // padding: 0%; -// } -// -// // .post-it p { -// // display: inline; -// // float: right; -// // } -// -// .post-it { -// position: relative; -// } -// // .complete-button input { -// // margin-top: 100%; -// // margin-left: 90%; -// // } diff --git a/task_list/app/controllers/sessions_controller.rb b/task_list/app/controllers/sessions_controller.rb index 22ca8debf..0e592eef5 100644 --- a/task_list/app/controllers/sessions_controller.rb +++ b/task_list/app/controllers/sessions_controller.rb @@ -1,4 +1,37 @@ class SessionsController < ApplicationController def create + auth_hash = request.env['omniauth.auth'] + # raise + + flash[:notice] = "Login Failed!" + 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 redirect_to index_path unless @user.save + end + + # Save the user ID in the session + session[:user_id] = @user.id #This is a cookie... NOTE: we're adding the id of the user model, not the uid from github + + flash[:notice] = "Successfully logged in!" + redirect_to index_path + end + + def destroy + # reset_session + # session.clear + # session.delete(:user_id) + session[:user_id] = nil # Don't want to delete users (usually) for simplicity + + redirect_to(:back) + end + + def index + @user = User.find(session[:user_id]) # < recalls the value set in a previous request end end diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 261dc8c38..2d10a0ef5 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -1,6 +1,9 @@ class TasksController < ApplicationController def index - @tasks = Task.all + get_current_user + if @user != nil + @tasks = @user.tasks + end end def new @@ -8,11 +11,12 @@ def new end def show - @tasks = Task.all + get_current_user + @tasks = Task.where(user_id: @user.id) @task_of_interest = nil @tasks.each do |task| - number = params[:id].to_i #params gives you the url, params returns a string that we need to turn into an integer so we can use it + number = params[:id].to_i if task[:id] == number @task_of_interest = task end @@ -43,24 +47,28 @@ def update def complete task.update_attributes(task_params) - redirect_to request.referrer #redirects to whatever page you came from with the updated c + redirect_to :back #redirects to whatever page you came from with the updated c end def create - @task = Task.new(title: params[:title], description: params[:description]) + get_current_user + @task = Task.new(title: params[:task][:title], description: params[:task][:description], user_id: @user.id) @task.save if @task.save - redirect_to index_path, alert: "Task successfully added." + redirect_to tasks_path, alert: "Task successfully added." else - redirect_to new_path, alert: "Error adding task." + redirect_to new_task_path, alert: "Error adding task." end end private def task_params #Tells Rails which parameters can be changed - params.require(:task).permit(:title, :description, :completed) + params.require(:task).permit(:title, :description, :completed, :user_id) end + def get_current_user + @user = User.find_by(id: session[:user_id]) # It will figure out the integer thing and return nil if it doesn't find anything + end end diff --git a/task_list/app/models/task.rb b/task_list/app/models/task.rb index ee0282c79..8a6d8fe51 100644 --- a/task_list/app/models/task.rb +++ b/task_list/app/models/task.rb @@ -1,3 +1,3 @@ class Task < ActiveRecord::Base - + belongs_to :user end diff --git a/task_list/app/models/user.rb b/task_list/app/models/user.rb index 4a57cf079..74dd8f3a5 100644 --- a/task_list/app/models/user.rb +++ b/task_list/app/models/user.rb @@ -1,2 +1,15 @@ class User < ActiveRecord::Base + has_many :tasks, dependent: :destroy + + 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/task_list/app/views/layouts/application.html.erb b/task_list/app/views/layouts/application.html.erb index 15c3875d9..8a45cc1d7 100644 --- a/task_list/app/views/layouts/application.html.erb +++ b/task_list/app/views/layouts/application.html.erb @@ -8,7 +8,14 @@ - +
    + <%# Links to Login/Logout %> + <% 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 %> +
    <%= yield %> diff --git a/task_list/app/views/tasks/edit.html.erb b/task_list/app/views/tasks/edit.html.erb index 7559c7baa..69721a6ef 100644 --- a/task_list/app/views/tasks/edit.html.erb +++ b/task_list/app/views/tasks/edit.html.erb @@ -1,7 +1,7 @@

    Edit Task

    -<%= form_for @task, url: update_path do |f| %> +<%= form_for @task, url: task_path do |f| %> <%= f.label :title %> <%= f.text_field :title, class:"form-box"%> @@ -12,7 +12,7 @@ <%= f.text_area :description, class:"form-box"%>

    - + <%= f.label :completed%> <%= f.text_area :completed, class:"form-box"%> diff --git a/task_list/app/views/tasks/index.html.erb b/task_list/app/views/tasks/index.html.erb index 97e6158d7..d433bf194 100644 --- a/task_list/app/views/tasks/index.html.erb +++ b/task_list/app/views/tasks/index.html.erb @@ -1,26 +1,22 @@ -
    -

    <%=link_to("Add new task", new_path) %>

    -

    Task List

    -

    - - <% @tasks.each do |task| %> -

      - <% if task.completed == true %> -
    • <%= link_to("✔︎#{task.title}", show_path(task[:id])) %>

    • - <%else%> -
    • <%= link_to("❏#{task.title}", show_path(task[:id])) %>

    • - -
    • <%= button_to "✔︎", { action: "update", id: task.id, task: { completed: true} }, method: :patch %>

    • - <%end %> -

      - -
    • <%= button_to "✗", { action: "destroy", id: task.id }, - - method: :delete, data: { confirm: "Are you sure?" } %>

    • -
    - <% end %> - + <% if session[:user_id] != nil %> +

    <%=link_to("Add new task", new_task_path) %>

    +

    <%=@user.name%>'s Task List

    +

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

      + <% if task.completed == true %> +
    • <%= link_to("✔︎ #{task.title}", task_path(task[:id])) %>

    • + <%else%> +
    • <%= link_to("❏ #{task.title}", task_path(task[:id])) %>

    • +
    • <%= button_to "✔︎", { action: "update", id: task.id, task: { completed: true} }, method: :patch %>

    • + <%end %> +

      +
    • <%= button_to "✗", { action: "destroy", id: task.id }, method: :delete, data: { confirm: "Are you sure?" } %>

    • +
    + <% end %> + <%else%> +

    Task List

    +

    Login to add tasks to your list.

    + <%end%>
    - - diff --git a/task_list/app/views/tasks/new.html.erb b/task_list/app/views/tasks/new.html.erb index c56e53770..c2c5c8e3a 100644 --- a/task_list/app/views/tasks/new.html.erb +++ b/task_list/app/views/tasks/new.html.erb @@ -1,23 +1,42 @@

    Add a Task

    <%=link_to("Task List", index_path) %>

    +
    +<%= form_for @task, url: tasks_path do |f| %> - + <%= f.label :title %> + <%= f.text_field :title, class:"form-box"%> + +

    + + <%= f.label :description%> + <%= f.text_area :description, class:"form-box"%> + +

    + + + + <%= f.submit %> + + <%end%> +
    + <%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) %> - + - + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index acb83af65..833c51257 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -1,7 +1,6 @@

    <%=link_to("Task List", index_path) %>

    -
    - +

    <%= @task_of_interest[:title]%>

    <%= @task_of_interest[:description] %>

    @@ -11,18 +10,30 @@ <% @task_of_interest[:completed_at] = @task_of_interest[:updated_at] %> ✔︎ Task completed on: <%=@task_of_interest.completed_at.to_formatted_s(:long)%> +
      +
    • +

      <%= button_to "✗", { action: "destroy", id: @task_of_interest.id }, method: :delete, data: { confirm: "Are you sure?" } %>

      +
    • + +
    • +

      <%= button_to "Edit", { action: "edit", id: @task_of_interest.id }, method: :get %>

      +
    • +
    <%else%> ❏This task is NOT completed yet -

    <%= button_to "Complete", { action: "complete", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

    - <%end %> -

    - -

    <%= button_to "Delete", { action: "destroy", id: @task_of_interest.id }, +

      +
    • +

      <%= button_to "✔︎", { action: "complete", id: @task_of_interest.id, task: { completed: true} }, method: :patch %>

      +
    • +
    • +

      <%= button_to "✗", { action: "destroy", id: @task_of_interest.id }, method: :delete, data: { confirm: "Are you sure?" } %>

      +
    • +
    • +

      <%= button_to "Edit", { action: "edit", id: @task_of_interest.id }, method: :get %>

      +
    • - method: :delete, data: { confirm: "Are you sure?" } %>

      - -

      <%= button_to "Edit", { action: "edit", id: @task_of_interest.id }, - - method: :get %>

      +
    + <%end %> +

    diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index 52f5b8a3a..a188ec920 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -1,30 +1,35 @@ Rails.application.routes.draw do - get 'sessions/create' - root to: 'tasks#index', as: 'index' - get 'tasks/index' => "tasks#index" - - get 'tasks/new' => 'tasks#new', as: 'new' - - post 'tasks/create' => 'tasks#create', as: 'create' - - get 'tasks/show' - get 'tasks/show/:id' => 'tasks#show', as: 'show' + get "/auth/:provider/callback" => "sessions#create" - get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' - delete 'tasks/:id/destroy' => 'tasks#destroy' - - get 'tasks/edit/:id' => "tasks#edit", as: 'edit' - - get 'tasks/update' => "tasks#update" - patch 'tasks/update/:id' => "tasks#update", as: 'update' + delete '/sessions/destroy' => "sessions#destroy", as: 'destroy_session' + resources :tasks, :users, :session + # get 'tasks/index' => "tasks#index" + # + # get 'tasks/new' => 'tasks#new', as: 'new' + # + # post 'tasks/create' => 'tasks#create', as: 'create' + # + # get 'tasks/show' + # get 'tasks/show/:id' => 'tasks#show', as: 'show' + # + # get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' + # delete 'tasks/:id/destroy' => 'tasks#destroy' + # + # get 'tasks/edit/:id' => "tasks#edit", as: 'edit' + # + # get 'tasks/update' => "tasks#update" + # patch 'tasks/update/:id' => "tasks#update", as: 'update' + # get 'tasks/complete' => "tasks#complete" patch 'tasks/complete/:id' => "tasks#complete", as: 'complete' - - get "/auth/:provider/callback" => "sessions#create" + # + # get "/auth/:provider/callback" => "sessions#create" + # + # delete 'sessions/destroy' => "sessions#destroy" as: 'logout' # 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/task_list/db/migrate/20161022201940_accociate_user_with_tasks.rb b/task_list/db/migrate/20161022201940_accociate_user_with_tasks.rb new file mode 100644 index 000000000..98d439062 --- /dev/null +++ b/task_list/db/migrate/20161022201940_accociate_user_with_tasks.rb @@ -0,0 +1,5 @@ +class AccociateUserWithTasks < ActiveRecord::Migration + def change + add_column :tasks, :user_id, :integer + end +end diff --git a/task_list/db/schema.rb b/task_list/db/schema.rb index 6385b253a..da37e9cc4 100644 --- a/task_list/db/schema.rb +++ b/task_list/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: 20161018170856) do +ActiveRecord::Schema.define(version: 20161022201940) do create_table "tasks", force: :cascade do |t| t.string "title" @@ -20,6 +20,7 @@ t.datetime "completed_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "user_id" end create_table "users", force: :cascade do |t| From 6a0b8daf9405a8e713009a808e2dc6eadb8211df Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 24 Oct 2016 13:01:31 -0700 Subject: [PATCH 28/42] Fixtures for users --- task_list/Gemfile | 5 +-- task_list/Gemfile.lock | 2 +- task_list/app/models/user.rb | 9 +++++ task_list/config/routes.rb | 24 +----------- task_list/test/fixtures/users.yml | 59 +++++++++++++++++++++++++----- task_list/test/models/user_test.rb | 26 +++++++++++-- task_list/test/test_helper.rb | 5 +-- 7 files changed, 89 insertions(+), 41 deletions(-) diff --git a/task_list/Gemfile b/task_list/Gemfile index 5360004cf..57a77fda3 100644 --- a/task_list/Gemfile +++ b/task_list/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'omniauth' gem 'omniauth-github' -gem 'awesome_print' +gem 'awesome_print', require: 'ap' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' # Use sqlite3 as the database for Active Record @@ -42,13 +42,12 @@ group :development, :test do end group :test do - gem 'minitest-reporters' + gem 'minitest-reporters', '~> 1.1', '>= 1.1.11' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' - gem "better_errors" gem "binding_of_caller" # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring diff --git a/task_list/Gemfile.lock b/task_list/Gemfile.lock index 43bf406aa..624fc4c13 100644 --- a/task_list/Gemfile.lock +++ b/task_list/Gemfile.lock @@ -192,7 +192,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 2.0) jquery-rails - minitest-reporters + minitest-reporters (~> 1.1, >= 1.1.11) omniauth omniauth-github rails (= 4.2.7) diff --git a/task_list/app/models/user.rb b/task_list/app/models/user.rb index 74dd8f3a5..a3cec638c 100644 --- a/task_list/app/models/user.rb +++ b/task_list/app/models/user.rb @@ -2,6 +2,7 @@ class User < ActiveRecord::Base has_many :tasks, dependent: :destroy validates :email, :uid, :provider, presence: true + validate :email_at_symbol def self.build_from_github(auth_hash) user = User.new @@ -12,4 +13,12 @@ def self.build_from_github(auth_hash) return user end + def email_at_symbol + if self.email != nil + unless self.email.include?("@") + errors.add(:email, "Email address must include @") + end + end + end + end diff --git a/task_list/config/routes.rb b/task_list/config/routes.rb index a188ec920..876754ebe 100644 --- a/task_list/config/routes.rb +++ b/task_list/config/routes.rb @@ -6,30 +6,10 @@ delete '/sessions/destroy' => "sessions#destroy", as: 'destroy_session' - resources :tasks, :users, :session - # get 'tasks/index' => "tasks#index" - # - # get 'tasks/new' => 'tasks#new', as: 'new' - # - # post 'tasks/create' => 'tasks#create', as: 'create' - # - # get 'tasks/show' - # get 'tasks/show/:id' => 'tasks#show', as: 'show' - # - # get 'tasks/destroy'=> "tasks#destroy", as: 'destroy' - # delete 'tasks/:id/destroy' => 'tasks#destroy' - # - # get 'tasks/edit/:id' => "tasks#edit", as: 'edit' - # - # get 'tasks/update' => "tasks#update" - # patch 'tasks/update/:id' => "tasks#update", as: 'update' - # + resources :tasks, :users, :sessions + get 'tasks/complete' => "tasks#complete" patch 'tasks/complete/:id' => "tasks#complete", as: 'complete' - # - # get "/auth/:provider/callback" => "sessions#create" - # - # delete 'sessions/destroy' => "sessions#destroy" as: 'logout' # 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/task_list/test/fixtures/users.yml b/task_list/test/fixtures/users.yml index 1fd9f45da..27a2ecc53 100644 --- a/task_list/test/fixtures/users.yml +++ b/task_list/test/fixtures/users.yml @@ -1,16 +1,57 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -#These fixtures will mimic users that have already logged in the past - we assume that they can pull in their information from Github. The mock hash in the setup method in the test_helper is there to test whether we can correctly connect to Github for authentication -ada: +minimal_valid_user: id: 1 uid: 8675309 name: "Ada Lovelace" - provider: "github" - email: ada@gmail.com + email: ada@lovelacelearning.com + provider: github -babbage: +no_email_user: + id: 2 + uid: 8675309 + name: "Ada Lovelace" + email: + provider: github + +invalid_email_user: + id: 3 + uid: 8675309 + name: "Ada Lovelace" + email: adalovelace.gmail.com + provider: github + +no_provider_user: id: 4 - uid: 2076158907 - name: "Charlie Babbage" - provider: "github" - email: babbage@gmail.com + uid: 8675309 + name: "Ada Lovelace" + email: adalovelace.gmail.com + provider: + +valid_user_harry: + id: 5 + uid: 8675309 + name: "Harry Potter" + email: harry@hogwards.edu + provider: github + +valid_user_ron: + id: 6 + uid: 8675309 + name: "Ron Weasly" + email: ron@hogwards.edu + provider: github +# #These fixtures will mimic users that have already logged in the past - we assume that they can pull in their information from Github. The mock hash in the setup method in the test_helper is there to test whether we can correctly connect to Github for authentication +# ada: +# id: 1 +# uid: 8675309 +# name: "Ada Lovelace" +# provider: "github" +# email: ada@gmail.com +# +# babbage: +# id: 4 +# uid: 2076158907 +# name: "Charlie Babbage" +# provider: "github" +# email: babbage@gmail.com diff --git a/task_list/test/models/user_test.rb b/task_list/test/models/user_test.rb index 82f61e010..90963c288 100644 --- a/task_list/test/models/user_test.rb +++ b/task_list/test/models/user_test.rb @@ -1,7 +1,27 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + + test "User with minimal information is valid" do + users(:minimal_valid_user).valid? + assert users(:minimal_valid_user).valid? + #Check Ron and Harry's validiity too, because I will use them in the controller tests + users(:valid_user_harry).valid? + assert users(:valid_user_harry).valid? + users(:valid_user_ron).valid? + assert users(:valid_user_ron).valid? + end + + test "The user must have a valid email" do + users(:no_email_user).invalid? + assert users(:no_email_user).invalid? + users(:invalid_email_user).invalid? + assert users(:invalid_email_user).invalid? + end + + test "The user must have a provider" do + users(:no_provider_user).invalid? + assert users(:no_provider_user).invalid? + end + end diff --git a/task_list/test/test_helper.rb b/task_list/test/test_helper.rb index 16bbd6974..949802095 100644 --- a/task_list/test/test_helper.rb +++ b/task_list/test/test_helper.rb @@ -1,7 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' -require 'minitest-reporters' +require 'minitest/reporters' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. @@ -9,10 +9,9 @@ class ActiveSupport::TestCase def setup OmniAuth.config.test_mode = true - OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({ provider: 'github', uid: '123545', info: { email: "a@b.com", name: "Ada" } }) - end + end # Add more helper methods to be used by all tests here... end From fe944ddab0ca0a71668de6fca1fb2de99276c253 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 24 Oct 2016 13:49:41 -0700 Subject: [PATCH 29/42] Includes only model tests --- .../controllers/sessions_controller_test.rb | 56 ++++++------- .../test/controllers/tasks_controller_test.rb | 84 +++++++++---------- task_list/test/fixtures/tasks.yml | 18 ++-- task_list/test/fixtures/users.yml | 10 +-- task_list/test/models/user_test.rb | 10 +-- 5 files changed, 87 insertions(+), 91 deletions(-) diff --git a/task_list/test/controllers/sessions_controller_test.rb b/task_list/test/controllers/sessions_controller_test.rb index 5d32739b2..8a74468d9 100644 --- a/task_list/test/controllers/sessions_controller_test.rb +++ b/task_list/test/controllers/sessions_controller_test.rb @@ -1,33 +1,33 @@ require 'test_helper' class SessionsControllerTest < ActionController::TestCase - test "should get create" do - get :create - assert_response :success - 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 - 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 +# test "should get create" do +# get :create +# assert_response :success +# 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 +# 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/task_list/test/controllers/tasks_controller_test.rb b/task_list/test/controllers/tasks_controller_test.rb index 44c843636..f59be28d1 100644 --- a/task_list/test/controllers/tasks_controller_test.rb +++ b/task_list/test/controllers/tasks_controller_test.rb @@ -2,47 +2,47 @@ class TasksControllerTest < ActionController::TestCase - test "Make sure that a user can see their tasks." do - session[:user_id] = users(:ada) - 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(:ada) - get :show, id: tasks(:babbages_task).id - assert_response :redirect - assert_equal flash[:notice], "You do not have access to that task." - end - - test "should get index" do - get :index - assert_response :success - end - - test "should get new" do - get :new - assert_response :success - end - - test "should get show" do - get :show - assert_response :success - end - - test "should get destroy" do - get :destroy - 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 "Make sure that a user can see their tasks." do + # session[:user_id] = users(:harry).id + # get :show, id: tasks(:harrys_task).id + # assert_response :success + # end + # + # test "Make sure a user cannot see another user's tasks" do + # session[:user_id] = users(:harry).id + # get :show, id: tasks(:rons_task).id + # assert_response :redirect + # assert_equal flash[:notice], "You do not have access to that task." + # end + # # + # test "should get index" do + # get :index + # assert_response :success + # end + # + # test "should get new" do + # get :new_task + # assert_response :success + # end + # + # test "should get show" do + # get :show + # assert_response :success + # end + # + # test "should get destroy" do + # get :destroy + # 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 end diff --git a/task_list/test/fixtures/tasks.yml b/task_list/test/fixtures/tasks.yml index b6fc88b36..7b1cce2aa 100644 --- a/task_list/test/fixtures/tasks.yml +++ b/task_list/test/fixtures/tasks.yml @@ -1,13 +1,15 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -adas_task: - title: "Write the first code!" - description: "Fortran" - user: :ada #Each task belongs to one person; Each user has many tasks. We can use fixtures that reference other fixtures +harrys_task: + title: "Learn new spells" + description: "There's more than Expecto Patronum..." + user: :harry #Each task belongs to one person; Each user has many tasks. We can use fixtures that reference other fixtures completed: true completed_at: 2016-09-28 14:26:30 -babbages_task: - title: "Make the first computer" - description: "Build it!" - user: :babbage +rons_task: + title: "Enter Wizard chess tournament" + description: "It's my one real skill." + user: :ron + completed: false + completed_at: 2016-09-28 14:26:30 diff --git a/task_list/test/fixtures/users.yml b/task_list/test/fixtures/users.yml index 27a2ecc53..9a146ba17 100644 --- a/task_list/test/fixtures/users.yml +++ b/task_list/test/fixtures/users.yml @@ -1,42 +1,36 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html minimal_valid_user: - id: 1 uid: 8675309 name: "Ada Lovelace" email: ada@lovelacelearning.com provider: github no_email_user: - id: 2 uid: 8675309 name: "Ada Lovelace" email: provider: github invalid_email_user: - id: 3 uid: 8675309 name: "Ada Lovelace" email: adalovelace.gmail.com provider: github no_provider_user: - id: 4 uid: 8675309 name: "Ada Lovelace" email: adalovelace.gmail.com provider: -valid_user_harry: - id: 5 +harry: uid: 8675309 name: "Harry Potter" email: harry@hogwards.edu provider: github -valid_user_ron: - id: 6 +ron: uid: 8675309 name: "Ron Weasly" email: ron@hogwards.edu diff --git a/task_list/test/models/user_test.rb b/task_list/test/models/user_test.rb index 90963c288..ca96f8e98 100644 --- a/task_list/test/models/user_test.rb +++ b/task_list/test/models/user_test.rb @@ -5,11 +5,11 @@ class UserTest < ActiveSupport::TestCase test "User with minimal information is valid" do users(:minimal_valid_user).valid? assert users(:minimal_valid_user).valid? - #Check Ron and Harry's validiity too, because I will use them in the controller tests - users(:valid_user_harry).valid? - assert users(:valid_user_harry).valid? - users(:valid_user_ron).valid? - assert users(:valid_user_ron).valid? + #Check Ron and Harry's validiity too, because I will use them in controller tests + users(:harry).valid? + assert users(:harry).valid? + users(:ron).valid? + assert users(:ron).valid? end test "The user must have a valid email" do From 57abc6f72aff3fbceae26cdbe26ae3baaa559ca2 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 24 Oct 2016 14:13:22 -0700 Subject: [PATCH 30/42] Ensure that users can only modify their own tasks and list --- task_list/app/controllers/tasks_controller.rb | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index 2d10a0ef5..edc4c7db4 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -1,4 +1,5 @@ class TasksController < ApplicationController +#Modify the Task Controller index and show actions so that a user only sees tasks that belong to them. I do this by first getting the current user, then asking @user.tasks which gives only the tasks belonging to that particular user. def index get_current_user if @user != nil @@ -6,13 +7,9 @@ def index end end - def new - @task = Task.new - end - def show get_current_user - @tasks = Task.where(user_id: @user.id) + @tasks = @user.tasks @task_of_interest = nil @tasks.each do |task| @@ -32,37 +29,59 @@ def destroy redirect_to :index end - def task - @task ||= Task.find(params[:id].to_i) - end - +#Modify the Task Controller's edit and update method to ensure that the user cannot edit a task that does not belong to them. def edit - task + get_current_user + if @user.tasks.include?(task) #If the task they want to edit belongs to them + task + else #If the task they want to edit does NOT belong to them + flash.alert = "You can only edit your own tasks." + redirect_to root_path + end end def update - task.update_attributes(task_params) - redirect_to index_path + get_current_user + if @user.tasks.include?(task) + task.update_attributes(task_params) + redirect_to index_path + else + flash.alert = "You can only edit your own tasks." + end end - def complete - task.update_attributes(task_params) - redirect_to :back #redirects to whatever page you came from with the updated c +#Modify the new and create actions for the task controller so that the new task created will belong to the current user. In the create method I get the current user and set the user id for the task being created to the id of that user + def new + @task = Task.new end def create get_current_user - @task = Task.new(title: params[:task][:title], description: params[:task][:description], user_id: @user.id) - @task.save +#Ensure that unauthenticated users cannot create tasks and are redirected to login. + if @user != nil + @task = Task.new(title: params[:task][:title], description: params[:task][:description], user_id: @user.id) + @task.save - if @task.save - redirect_to tasks_path, alert: "Task successfully added." - else - redirect_to new_task_path, alert: "Error adding task." - end + if @task.save + redirect_to tasks_path, alert: "Task successfully added." + else + redirect_to new_task_path, alert: "Error adding task." + end + else #The user isn't logged in + flash.alert = "You must log in to add tasks to a list." + end end - private + def complete + task.update_attributes(task_params) + redirect_to :back #redirects to whatever page you came from with the updated c + end +private + + def task + @task ||= Task.find(params[:id].to_i) + end + def task_params #Tells Rails which parameters can be changed params.require(:task).permit(:title, :description, :completed, :user_id) From c40b1289208038f136f6eec8438d75247b739f2d Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Wed, 26 Oct 2016 18:24:13 -0700 Subject: [PATCH 31/42] Finished oAuth requirements --- task_list/app/controllers/tasks_controller.rb | 2 +- task_list/test/controllers/sessions_controller_test.rb | 8 ++++---- task_list/test/controllers/tasks_controller_test.rb | 10 +++++----- task_list/test/fixtures/users.yml | 2 +- task_list/test/models/user_test.rb | 1 + 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index edc4c7db4..f49c7e5dd 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -69,7 +69,7 @@ def create end else #The user isn't logged in flash.alert = "You must log in to add tasks to a list." - end + end end def complete diff --git a/task_list/test/controllers/sessions_controller_test.rb b/task_list/test/controllers/sessions_controller_test.rb index 8a74468d9..89299a25c 100644 --- a/task_list/test/controllers/sessions_controller_test.rb +++ b/task_list/test/controllers/sessions_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' class SessionsControllerTest < ActionController::TestCase -# test "should get create" do -# get :create -# assert_response :success -# end + # test "should get create" do + # get :create + # assert_response :success + # end # # def login_a_user # request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:github] diff --git a/task_list/test/controllers/tasks_controller_test.rb b/task_list/test/controllers/tasks_controller_test.rb index f59be28d1..a0e047558 100644 --- a/task_list/test/controllers/tasks_controller_test.rb +++ b/task_list/test/controllers/tasks_controller_test.rb @@ -2,11 +2,11 @@ class TasksControllerTest < ActionController::TestCase - # test "Make sure that a user can see their tasks." do - # session[:user_id] = users(:harry).id - # get :show, id: tasks(:harrys_task).id - # assert_response :success - # end + test "Make sure that a user can see their tasks." do + session[:user_id] = users(:harry).id + get :show, id: tasks(:harrys_task).id + assert_response :success + end # # test "Make sure a user cannot see another user's tasks" do # session[:user_id] = users(:harry).id diff --git a/task_list/test/fixtures/users.yml b/task_list/test/fixtures/users.yml index 9a146ba17..0c024a6eb 100644 --- a/task_list/test/fixtures/users.yml +++ b/task_list/test/fixtures/users.yml @@ -31,7 +31,7 @@ harry: provider: github ron: - uid: 8675309 + uid: 8675305 name: "Ron Weasly" email: ron@hogwards.edu provider: github diff --git a/task_list/test/models/user_test.rb b/task_list/test/models/user_test.rb index ca96f8e98..ca860acf2 100644 --- a/task_list/test/models/user_test.rb +++ b/task_list/test/models/user_test.rb @@ -6,6 +6,7 @@ class UserTest < ActiveSupport::TestCase users(:minimal_valid_user).valid? assert users(:minimal_valid_user).valid? #Check Ron and Harry's validiity too, because I will use them in controller tests + #Well, we didn't need controller tests in the assignment so I'm saving that for later... users(:harry).valid? assert users(:harry).valid? users(:ron).valid? From 0b27e0ebe698bba6bdbbca966ab9ff0d13654726 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 5 Dec 2016 10:56:16 -0800 Subject: [PATCH 32/42] no underlines on hover --- .gitignore | 3 +++ task_list/app/assets/stylesheets/tasks.scss | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 28f484983..3245b2632 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ build/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc + +# Ignore the .env file (it's full of secrets!) +.env diff --git a/task_list/app/assets/stylesheets/tasks.scss b/task_list/app/assets/stylesheets/tasks.scss index df0d99dd6..2d974b992 100644 --- a/task_list/app/assets/stylesheets/tasks.scss +++ b/task_list/app/assets/stylesheets/tasks.scss @@ -27,7 +27,7 @@ a{ } a:hover { - text-decoration: underline; + text-decoration: none; } h1 { From 5dcfd0cf2ef3347d5eb47bafb4d4fdc73ecef292 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 5 Dec 2016 11:12:40 -0800 Subject: [PATCH 33/42] prepped Gemfile for Heroku deployment --- task_list/Gemfile | 6 +++++- task_list/Gemfile.lock | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/task_list/Gemfile b/task_list/Gemfile index 57a77fda3..6b34615a2 100644 --- a/task_list/Gemfile +++ b/task_list/Gemfile @@ -1,12 +1,16 @@ source 'https://rubygems.org' +#heroku gems +gem 'pg', group: :production +gem 'rails_12factor', group: :production + gem 'omniauth' gem 'omniauth-github' gem 'awesome_print', require: 'ap' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' # Use sqlite3 as the database for Active Record -gem 'sqlite3' +gem 'sqlite3', group: [:development, :test] # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets diff --git a/task_list/Gemfile.lock b/task_list/Gemfile.lock index 624fc4c13..5e67dd8e4 100644 --- a/task_list/Gemfile.lock +++ b/task_list/Gemfile.lock @@ -113,6 +113,7 @@ GEM omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) + pg (0.19.0) pkg-config (1.1.7) rack (1.6.4) rack-test (0.6.3) @@ -136,6 +137,11 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) railties (4.2.7) actionpack (= 4.2.7) activesupport (= 4.2.7) @@ -195,7 +201,9 @@ DEPENDENCIES minitest-reporters (~> 1.1, >= 1.1.11) omniauth omniauth-github + pg rails (= 4.2.7) + rails_12factor sass-rails (~> 5.0) sdoc (~> 0.4.0) spring @@ -205,4 +213,4 @@ DEPENDENCIES web-console (~> 2.0) BUNDLED WITH - 1.13.5 + 1.13.6 From 37dfd8ecab0d0ccf059329059c906d3ac3d25e00 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 5 Dec 2016 14:52:43 -0800 Subject: [PATCH 34/42] Create index.html --- index.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 000000000..eb6fe0602 --- /dev/null +++ b/index.html @@ -0,0 +1,2 @@ +index.html + From f120db3eabe0478f5d7eaf473f0240ba2d8fd3fc Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 5 Dec 2016 15:00:31 -0800 Subject: [PATCH 35/42] Create docs --- docs | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs diff --git a/docs b/docs new file mode 100644 index 000000000..741544f7f --- /dev/null +++ b/docs @@ -0,0 +1 @@ +HEllo world! From 0226d0dde97e40dc6e5d7dc23ee2f97bbadee1a9 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 5 Dec 2016 15:01:36 -0800 Subject: [PATCH 36/42] Delete docs --- docs | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs diff --git a/docs b/docs deleted file mode 100644 index 741544f7f..000000000 --- a/docs +++ /dev/null @@ -1 +0,0 @@ -HEllo world! From ee1ee903e05d4297cb398b20ad8f3391a63fb805 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 5 Dec 2016 15:01:45 -0800 Subject: [PATCH 37/42] Delete index.html --- index.html | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index eb6fe0602..000000000 --- a/index.html +++ /dev/null @@ -1,2 +0,0 @@ -index.html - From fece9b710af16a56cfd9ff63ca7e9ee0f3bf3fea Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 5 Dec 2016 15:15:36 -0800 Subject: [PATCH 38/42] Prep for deployment --- .../app/controllers/sessions_controller.rb | 2 +- .../app/views/layouts/application.html.erb | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/task_list/app/controllers/sessions_controller.rb b/task_list/app/controllers/sessions_controller.rb index 0e592eef5..63f395aec 100644 --- a/task_list/app/controllers/sessions_controller.rb +++ b/task_list/app/controllers/sessions_controller.rb @@ -4,7 +4,7 @@ def create # raise flash[:notice] = "Login Failed!" - return redirect_to root_path unless auth_hash['uid'] # THe return makes it so nothing after this happens + 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? diff --git a/task_list/app/views/layouts/application.html.erb b/task_list/app/views/layouts/application.html.erb index 8a45cc1d7..04c6d3aee 100644 --- a/task_list/app/views/layouts/application.html.erb +++ b/task_list/app/views/layouts/application.html.erb @@ -7,16 +7,18 @@ <%= csrf_meta_tags %> + -
    - <%# Links to Login/Logout %> - <% 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 %> -
    -<%= yield %> +
    + <%# Links to Login/Logout %> + <% 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 %> +
    + + <%= yield %> From a4a8a42d2e8ba07cdaf96187330435935ede9bbf Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 5 Dec 2016 15:32:55 -0800 Subject: [PATCH 39/42] Moved Gemfile to root folder --- task_list/Gemfile | 59 ----------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 task_list/Gemfile diff --git a/task_list/Gemfile b/task_list/Gemfile deleted file mode 100644 index 6b34615a2..000000000 --- a/task_list/Gemfile +++ /dev/null @@ -1,59 +0,0 @@ -source 'https://rubygems.org' - -#heroku gems -gem 'pg', group: :production -gem 'rails_12factor', group: :production - -gem 'omniauth' -gem 'omniauth-github' -gem 'awesome_print', require: 'ap' -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.7' -# Use sqlite3 as the database for Active Record -gem 'sqlite3', group: [:development, :test] -# 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' - gem 'dotenv-rails' - gem 'better_errors' -end - -group :test do - gem 'minitest-reporters', '~> 1.1', '>= 1.1.11' -end - -group :development do - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' - gem "binding_of_caller" - - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' -end From 72cd15d7ee662b0efd1dbf2b8c60789b5151a172 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Mon, 5 Dec 2016 15:35:07 -0800 Subject: [PATCH 40/42] Moved the gemfile back --- task_list/Gemfile | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 task_list/Gemfile diff --git a/task_list/Gemfile b/task_list/Gemfile new file mode 100644 index 000000000..6b34615a2 --- /dev/null +++ b/task_list/Gemfile @@ -0,0 +1,59 @@ +source 'https://rubygems.org' + +#heroku gems +gem 'pg', group: :production +gem 'rails_12factor', group: :production + +gem 'omniauth' +gem 'omniauth-github' +gem 'awesome_print', require: 'ap' +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.2.7' +# Use sqlite3 as the database for Active Record +gem 'sqlite3', group: [:development, :test] +# 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' + gem 'dotenv-rails' + gem 'better_errors' +end + +group :test do + gem 'minitest-reporters', '~> 1.1', '>= 1.1.11' +end + +group :development do + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' + gem "binding_of_caller" + + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' +end From f98f411c8bd4d8457136f6dc4cad76915385dbc1 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Tue, 6 Dec 2016 21:55:28 -0800 Subject: [PATCH 41/42] Tweaks --- task_list/app/controllers/tasks_controller.rb | 3 ++- task_list/test/controllers/tasks_controller_test.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/task_list/app/controllers/tasks_controller.rb b/task_list/app/controllers/tasks_controller.rb index f49c7e5dd..de1a70156 100644 --- a/task_list/app/controllers/tasks_controller.rb +++ b/task_list/app/controllers/tasks_controller.rb @@ -74,8 +74,9 @@ def create def complete task.update_attributes(task_params) - redirect_to :back #redirects to whatever page you came from with the updated c + redirect_to :back end + private def task diff --git a/task_list/test/controllers/tasks_controller_test.rb b/task_list/test/controllers/tasks_controller_test.rb index a0e047558..7d4ca9f5e 100644 --- a/task_list/test/controllers/tasks_controller_test.rb +++ b/task_list/test/controllers/tasks_controller_test.rb @@ -15,6 +15,7 @@ class TasksControllerTest < ActionController::TestCase # assert_equal flash[:notice], "You do not have access to that task." # end # # + # test "should get index" do # get :index # assert_response :success From a0d74fd467e9cd89b2539db0d8aa614df74073b3 Mon Sep 17 00:00:00 2001 From: Erin Bond Date: Tue, 6 Dec 2016 22:14:48 -0800 Subject: [PATCH 42/42] Indent editing --- .../app/views/layouts/application.html.erb | 22 +++++++++---------- task_list/app/views/tasks/show.html.erb | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/task_list/app/views/layouts/application.html.erb b/task_list/app/views/layouts/application.html.erb index 04c6d3aee..61cb7addd 100644 --- a/task_list/app/views/layouts/application.html.erb +++ b/task_list/app/views/layouts/application.html.erb @@ -8,17 +8,17 @@ - -
    - <%# Links to Login/Logout %> - <% 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 %> -
    + +
    + <%# Links to Login/Logout %> + <% 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 %> +
    - <%= yield %> + <%= yield %> - + diff --git a/task_list/app/views/tasks/show.html.erb b/task_list/app/views/tasks/show.html.erb index 833c51257..af82c091b 100644 --- a/task_list/app/views/tasks/show.html.erb +++ b/task_list/app/views/tasks/show.html.erb @@ -32,7 +32,7 @@

    <%= button_to "Edit", { action: "edit", id: @task_of_interest.id }, method: :get %>

    - + <%end %>