\ No newline at end of file
diff --git a/app/views/newsfeeds/_newsfeed_user.html.erb b/app/views/newsfeeds/_newsfeed_user.html.erb
new file mode 100644
index 000000000..f9afe7ddf
--- /dev/null
+++ b/app/views/newsfeeds/_newsfeed_user.html.erb
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/views/newsfeeds/_recently_active_friend.html.erb b/app/views/newsfeeds/_recently_active_friend.html.erb
new file mode 100644
index 000000000..b968cebda
--- /dev/null
+++ b/app/views/newsfeeds/_recently_active_friend.html.erb
@@ -0,0 +1,21 @@
+
+
\ No newline at end of file
diff --git a/app/views/newsfeeds/index.html.erb b/app/views/newsfeeds/index.html.erb
new file mode 100644
index 000000000..8e05d66cc
--- /dev/null
+++ b/app/views/newsfeeds/index.html.erb
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/views/photos/_photo_actions.html.erb b/app/views/photos/_photo_actions.html.erb
new file mode 100644
index 000000000..7458f0813
--- /dev/null
+++ b/app/views/photos/_photo_actions.html.erb
@@ -0,0 +1,18 @@
+
+
\ No newline at end of file
diff --git a/app/views/photos/_photo_on_show.html.erb b/app/views/photos/_photo_on_show.html.erb
new file mode 100644
index 000000000..5b4411e1b
--- /dev/null
+++ b/app/views/photos/_photo_on_show.html.erb
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/app/views/photos/_photo_poster.html.erb b/app/views/photos/_photo_poster.html.erb
new file mode 100644
index 000000000..38002760e
--- /dev/null
+++ b/app/views/photos/_photo_poster.html.erb
@@ -0,0 +1,23 @@
+
\ No newline at end of file
diff --git a/app/views/posts/_new_post.html.erb b/app/views/posts/_new_post.html.erb
new file mode 100644
index 000000000..895dd79b1
--- /dev/null
+++ b/app/views/posts/_new_post.html.erb
@@ -0,0 +1,16 @@
+
+
+
+ Post
+
+ <%= form_for [@user, @post] do |post_fields| %>
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/posts/_post.html.erb b/app/views/posts/_post.html.erb
new file mode 100644
index 000000000..4d53422f8
--- /dev/null
+++ b/app/views/posts/_post.html.erb
@@ -0,0 +1,43 @@
+
\ No newline at end of file
diff --git a/app/views/posts/_post_actions.html.erb b/app/views/posts/_post_actions.html.erb
new file mode 100644
index 000000000..22e166343
--- /dev/null
+++ b/app/views/posts/_post_actions.html.erb
@@ -0,0 +1,12 @@
+
+
+ <%= like_or_unlike(post) %>
+
+ <% if user == current_user %>
+ <%= link_to 'Delete', user_post_path(user, post), method: :delete, data: { confirm: 'Are you sure?' }, class: 'pull-right' %>
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/posts/_timeline_friends.html.erb b/app/views/posts/_timeline_friends.html.erb
new file mode 100644
index 000000000..ed8b2f50e
--- /dev/null
+++ b/app/views/posts/_timeline_friends.html.erb
@@ -0,0 +1,20 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/views/posts/_timeline_photos.html.erb b/app/views/posts/_timeline_photos.html.erb
new file mode 100644
index 000000000..cd6ed69db
--- /dev/null
+++ b/app/views/posts/_timeline_photos.html.erb
@@ -0,0 +1,14 @@
+
+
Photos
+
+ <% user.photos.each do |photo| %>
+ <%= image_tag photo.image.url('thumb') %>
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/posts/_timeline_sidebar.html.erb b/app/views/posts/_timeline_sidebar.html.erb
new file mode 100644
index 000000000..625fbb433
--- /dev/null
+++ b/app/views/posts/_timeline_sidebar.html.erb
@@ -0,0 +1,7 @@
+
diff --git a/app/views/sessions/destroy.html.erb b/app/views/sessions/destroy.html.erb
new file mode 100644
index 000000000..d75237d98
--- /dev/null
+++ b/app/views/sessions/destroy.html.erb
@@ -0,0 +1,2 @@
+
Sessions#destroy
+
Find me in app/views/sessions/destroy.html.erb
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
new file mode 100644
index 000000000..b39a3bc95
--- /dev/null
+++ b/app/views/sessions/new.html.erb
@@ -0,0 +1,2 @@
+
Sessions#new
+
Find me in app/views/sessions/new.html.erb
diff --git a/app/views/shared/_flash.html.erb b/app/views/shared/_flash.html.erb
new file mode 100644
index 000000000..1da61b232
--- /dev/null
+++ b/app/views/shared/_flash.html.erb
@@ -0,0 +1,5 @@
+<% flash.each do |message_type, message| %>
+
+ <%= message %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb
new file mode 100644
index 000000000..8d549d635
--- /dev/null
+++ b/app/views/shared/_header.html.erb
@@ -0,0 +1,48 @@
+
+
+
+
+ <%= cover_photo(user) %>
+
+
+
+
+ <%= profile_photo(user, 'thumb') %>
+
+
+
+
+
<%= full_name(user) %>
+
+
+
+ <% if user != current_user %>
+ <%= friend_button(user) %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb
new file mode 100644
index 000000000..96bc7c118
--- /dev/null
+++ b/app/views/shared/_nav.html.erb
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/app/views/shared/_user_description.html.erb b/app/views/shared/_user_description.html.erb
new file mode 100644
index 000000000..dd7174392
--- /dev/null
+++ b/app/views/shared/_user_description.html.erb
@@ -0,0 +1,23 @@
+
\ No newline at end of file
diff --git a/app/views/shared/untitled b/app/views/shared/untitled
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/user_mailer/new_comment.html.erb b/app/views/user_mailer/new_comment.html.erb
new file mode 100644
index 000000000..4e8845271
--- /dev/null
+++ b/app/views/user_mailer/new_comment.html.erb
@@ -0,0 +1 @@
+
You have a new comment!
\ No newline at end of file
diff --git a/app/views/user_mailer/new_comment.text.erb b/app/views/user_mailer/new_comment.text.erb
new file mode 100644
index 000000000..c3506ae28
--- /dev/null
+++ b/app/views/user_mailer/new_comment.text.erb
@@ -0,0 +1 @@
+You have a new comment!
\ No newline at end of file
diff --git a/app/views/user_mailer/welcome.html.erb b/app/views/user_mailer/welcome.html.erb
new file mode 100644
index 000000000..fded268c4
--- /dev/null
+++ b/app/views/user_mailer/welcome.html.erb
@@ -0,0 +1 @@
+
Welcome to Danebook, <%= @user.first_name %>
\ No newline at end of file
diff --git a/app/views/user_mailer/welcome.text.erb b/app/views/user_mailer/welcome.text.erb
new file mode 100644
index 000000000..76ef81ab8
--- /dev/null
+++ b/app/views/user_mailer/welcome.text.erb
@@ -0,0 +1 @@
+Welcome to Danebook, <%= @user.first_name %>
\ No newline at end of file
diff --git a/app/views/users/_sign_up_form.html.erb b/app/views/users/_sign_up_form.html.erb
new file mode 100644
index 000000000..605b6be5d
--- /dev/null
+++ b/app/views/users/_sign_up_form.html.erb
@@ -0,0 +1,49 @@
+<%= form_for @user, html: { class: 'signup' } do |user_fields| %>
+
+
\ No newline at end of file
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
new file mode 100644
index 000000000..b0fa4590b
--- /dev/null
+++ b/app/views/users/new.html.erb
@@ -0,0 +1,36 @@
+
+
+
+
+
+ Connect with all your friends!
+
+
+
+ See photos and updates in your news feed
+
+
+ Post your status for the world to see from your profile
+
+
+ Get in touch with your friends by "friending" them
+
+
+ Like things because you're a positive person!
+
+
+
+
+
+
+
+
+
Sign Up
+ <%= render 'sign_up_form' %>
+
+
+
+
+
+
+
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 000000000..66e9889e8
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/delayed_job b/bin/delayed_job
new file mode 100755
index 000000000..edf195985
--- /dev/null
+++ b/bin/delayed_job
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 000000000..5badb2fde
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 000000000..d87d5f578
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+begin
+ load File.expand_path('../spring', __FILE__)
+rescue LoadError => e
+ raise unless e.message.include?('spring')
+end
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 000000000..e620b4dad
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+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') || system!('bundle install')
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/bin/spring b/bin/spring
new file mode 100755
index 000000000..fb2ec2ebb
--- /dev/null
+++ b/bin/spring
@@ -0,0 +1,17 @@
+#!/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'
+
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
+ if spring
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
+ gem 'spring', spring.version
+ require 'spring/binstub'
+ end
+end
diff --git a/bin/update b/bin/update
new file mode 100755
index 000000000..a8e4462f2
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/config.ru b/config.ru
new file mode 100644
index 000000000..f7ba0b527
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 000000000..af54ad3ac
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,15 @@
+require_relative 'boot'
+
+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 ProjectDanebook
+ 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.
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 000000000..30f5120df
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 000000000..0bbde6f74
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,9 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: redis://localhost:6379/1
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 000000000..e7c6a08cf
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,85 @@
+# PostgreSQL. Versions 9.1 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On OS X with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On OS X with MacPorts:
+# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem 'pg'
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see rails configuration guide
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: project_danebook_development
+
+ # The specified database role being used to connect to postgres.
+ # To create additional roles in postgres see `$ createuser --help`.
+ # When left blank, postgres will use the default role. This is
+ # the same name as the operating system user that initialized the database.
+ #username: project_danebook
+
+ # The password associated with the postgres role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# 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: project_danebook_test
+
+# As with config/secrets.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password as a unix environment variable when you boot
+# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full rundown on how to provide these environment variables in a
+# production deployment.
+#
+# On Heroku and other platform providers, you may have a full connection URL
+# available as an environment variable. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# You can use this database configuration with:
+#
+# production:
+# url: <%= ENV['DATABASE_URL'] %>
+#
+production:
+ <<: *default
+ database: project_danebook_production
+ username: project_danebook
+ password: <%= ENV['PROJECT_DANEBOOK_DATABASE_PASSWORD'] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 000000000..426333bb4
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 000000000..f14f9262f
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,75 @@
+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.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => 'public, max-age=172800'
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = 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
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+
+ Paperclip.options[:command_path] = "/usr/local/bin"
+
+ config.paperclip_defaults = {
+ :storage => :s3,
+
+
+ :s3_credentials => {
+ :s3_host_name => "s3.amazonaws.com",
+ :s3_region => "us-east-1",
+
+ # NOTE: these lines are changed to use secrets.yml
+ # from the examples (which use ENV vars instead)
+ :bucket => Rails.application.secrets.s3_bucket_name,
+ :access_key_id => Rails.application.secrets.aws_access_key_id,
+ :secret_access_key => Rails.application.secrets.aws_secret_access_key
+ }
+ }
+
+ config.action_mailer.delivery_method = :letter_opener
+
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 000000000..2fc610822
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,102 @@
+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
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = 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
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # 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
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # 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 = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "project_danebook_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # 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
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+
+ config.paperclip_defaults = {
+ :storage => :s3,
+
+
+ :s3_credentials => {
+ :s3_host_name => "s3.amazonaws.com",
+ :s3_region => "us-east-1",
+
+ # NOTE: these lines are changed to use secrets.yml
+ # from the examples (which use ENV vars instead)
+ :bucket => Rails.application.secrets.s3_bucket_name,
+ :access_key_id => Rails.application.secrets.aws_access_key_id,
+ :secret_access_key => Rails.application.secrets.aws_secret_access_key
+ }
+ }
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 000000000..30587ef6d
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ '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
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
new file mode 100644
index 000000000..51639b67a
--- /dev/null
+++ b/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,6 @@
+# Be sure to restart your server when you modify this file.
+
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644
index 000000000..01ef3e663
--- /dev/null
+++ b/config/initializers/assets.rb
@@ -0,0 +1,11 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path
+# Rails.application.config.assets.paths << Emoji.images_path
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
+# Rails.application.config.assets.precompile += %w( search.js )
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 000000000..59385cdf3
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644
index 000000000..5a6a32d37
--- /dev/null
+++ b/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 000000000..4a994e1e7
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 000000000..ac033bf9d
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
new file mode 100644
index 000000000..dc1899682
--- /dev/null
+++ b/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb
new file mode 100644
index 000000000..671abb69a
--- /dev/null
+++ b/config/initializers/new_framework_defaults.rb
@@ -0,0 +1,24 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.0 upgrade.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+
+# Enable per-form CSRF tokens. Previous versions had false.
+Rails.application.config.action_controller.per_form_csrf_tokens = true
+
+# Enable origin-checking CSRF mitigation. Previous versions had false.
+Rails.application.config.action_controller.forgery_protection_origin_check = true
+
+# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
+# Previous versions had false.
+ActiveSupport.to_time_preserves_timezone = true
+
+# Require `belongs_to` associations by default. Previous versions had false.
+Rails.application.config.active_record.belongs_to_required_by_default = true
+
+# Do not halt callback chains when a callback returns false. Previous versions had true.
+ActiveSupport.halt_callback_chains_on_return_false = false
+
+# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
+Rails.application.config.ssl_options = { hsts: { subdomains: true } }
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
new file mode 100644
index 000000000..f2d118131
--- /dev/null
+++ b/config/initializers/session_store.rb
@@ -0,0 +1,3 @@
+# Be sure to restart your server when you modify this file.
+
+Rails.application.config.session_store :cookie_store, key: '_project_danebook_session'
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 000000000..bbfc3961b
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 000000000..065395716
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,23 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 000000000..c7f311f81
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,47 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum, this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted this block will be run, if you are using `preload_app!`
+# option you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 000000000..a891c4830
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,31 @@
+Rails.application.routes.draw do
+
+ root 'users#new'
+
+ get 'login' => 'users#new'
+ delete 'logout' => 'sessions#destroy'
+ get 'newsfeed' => 'newsfeeds#index'
+
+ resources :users, :only => [:new,
+ :create,
+ :edit,
+ :update] do
+
+ resources :posts, :only => [:create, :destroy]
+ get '/timeline' => 'posts#index'
+ resources :friends, :only => [:create,
+ :destroy,
+ :index]
+ resources :photos, :only => [:index, :show]
+ end
+
+ get '/users/:id/about',
+ to: 'users#about',
+ as: 'about_user'
+
+ resource :session, :only => [:new, :create, :destroy]
+ resources :friend_requests, only: [:index]
+ resources :comments, :likes, :only => [:create, :destroy]
+ resources :photos, :only => [:new, :create, :destroy, :update]
+
+end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 000000000..3956ce43a
--- /dev/null
+++ b/config/secrets.yml
@@ -0,0 +1,28 @@
+# 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 `rails 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: 5e51a3983bb3c59aeeabdbf1ac968af6498bb65f5ed0b2c075c19b774677253622e1f6c9c298617b662449149935157bce77101fef7f6375bec55e7f0438b5d7
+ s3_bucket_name: <%= ENV["S3_BUCKET_NAME"] %>
+ aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
+ aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
+
+test:
+ secret_key_base: c487eedefa25793bdbe3effee0c097d54d38f1b12a050ac124d2e0addd41efbacc9e864ced8f68db241765f59d9dc697a60edd5d269c61a3328ff067d2352eb8
+
+# Do not keep production secrets in the repository,
+# instead read values from the environment.
+production:
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
+ s3_bucket_name: <%= ENV["S3_BUCKET_NAME"] %>
+ aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
+ aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
diff --git a/config/spring.rb b/config/spring.rb
new file mode 100644
index 000000000..c9119b40c
--- /dev/null
+++ b/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/db/migrate/20170122230258_create_users.rb b/db/migrate/20170122230258_create_users.rb
new file mode 100644
index 000000000..91a2a95c6
--- /dev/null
+++ b/db/migrate/20170122230258_create_users.rb
@@ -0,0 +1,10 @@
+class CreateUsers < ActiveRecord::Migration[5.0]
+ def change
+ create_table :users do |t|
+ t.string :email
+ t.string :password_digest
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20170123010349_add_columns_to_user.rb b/db/migrate/20170123010349_add_columns_to_user.rb
new file mode 100644
index 000000000..bc89bb8e5
--- /dev/null
+++ b/db/migrate/20170123010349_add_columns_to_user.rb
@@ -0,0 +1,10 @@
+class AddColumnsToUser < ActiveRecord::Migration[5.0]
+ def change
+ add_column :users, :first_name, :string
+ add_column :users, :last_name, :string
+ add_column :users, :birth_date, :integer
+ add_column :users, :birth_month, :integer
+ add_column :users, :birth_year, :integer
+ add_column :users, :gender, :boolean
+ end
+end
diff --git a/db/migrate/20170123023620_add_auth_token_to_users.rb b/db/migrate/20170123023620_add_auth_token_to_users.rb
new file mode 100644
index 000000000..350799bed
--- /dev/null
+++ b/db/migrate/20170123023620_add_auth_token_to_users.rb
@@ -0,0 +1,6 @@
+class AddAuthTokenToUsers < ActiveRecord::Migration[5.0]
+ def change
+ add_column :users, :auth_token, :string
+ add_index :users, :auth_token, :unique => true
+ end
+end
diff --git a/db/migrate/20170123043822_create_profiles.rb b/db/migrate/20170123043822_create_profiles.rb
new file mode 100644
index 000000000..40170df37
--- /dev/null
+++ b/db/migrate/20170123043822_create_profiles.rb
@@ -0,0 +1,15 @@
+class CreateProfiles < ActiveRecord::Migration[5.0]
+ def change
+ create_table :profiles do |t|
+ t.integer :user_id
+ t.string :college
+ t.string :hometown
+ t.string :current_location
+ t.string :telephone
+ t.text :words
+ t.text :about_me
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20170124032831_create_posts.rb b/db/migrate/20170124032831_create_posts.rb
new file mode 100644
index 000000000..e91ce6b80
--- /dev/null
+++ b/db/migrate/20170124032831_create_posts.rb
@@ -0,0 +1,9 @@
+class CreatePosts < ActiveRecord::Migration[5.0]
+ def change
+ create_table :posts do |t|
+ t.string :content
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20170124033017_create_comments.rb b/db/migrate/20170124033017_create_comments.rb
new file mode 100644
index 000000000..447734ac2
--- /dev/null
+++ b/db/migrate/20170124033017_create_comments.rb
@@ -0,0 +1,11 @@
+class CreateComments < ActiveRecord::Migration[5.0]
+ def change
+ create_table :comments do |t|
+ t.integer :user_id
+ t.integer :post_id
+ t.string :content
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20170124033110_add_user_id_to_posts.rb b/db/migrate/20170124033110_add_user_id_to_posts.rb
new file mode 100644
index 000000000..e161cab0c
--- /dev/null
+++ b/db/migrate/20170124033110_add_user_id_to_posts.rb
@@ -0,0 +1,5 @@
+class AddUserIdToPosts < ActiveRecord::Migration[5.0]
+ def change
+ add_column :posts, :user_id, :integer
+ end
+end
diff --git a/db/migrate/20170125063928_create_likes.rb b/db/migrate/20170125063928_create_likes.rb
new file mode 100644
index 000000000..148b26716
--- /dev/null
+++ b/db/migrate/20170125063928_create_likes.rb
@@ -0,0 +1,13 @@
+class CreateLikes < ActiveRecord::Migration[5.0]
+ def change
+ create_table :likes do |t|
+ t.integer :user_id
+ t.integer :likable_id
+ t.string :likable_type
+
+ t.timestamps
+ end
+
+ add_index :likes, [:likable_type, :likable_id]
+ end
+end
diff --git a/db/migrate/20170205040239_create_friendings.rb b/db/migrate/20170205040239_create_friendings.rb
new file mode 100644
index 000000000..f5c2e8902
--- /dev/null
+++ b/db/migrate/20170205040239_create_friendings.rb
@@ -0,0 +1,10 @@
+class CreateFriendings < ActiveRecord::Migration[5.0]
+ def change
+ create_table :friendings do |t|
+ t.integer :friender_id, null: false
+ t.integer :friendee_id, null: false
+ t.timestamps
+ end
+ add_index :friendings, [:friender_id, :friendee_id], unique: true
+ end
+end
diff --git a/db/migrate/20170206031837_change_comments_to_polymorphic.rb b/db/migrate/20170206031837_change_comments_to_polymorphic.rb
new file mode 100644
index 000000000..a54675ea0
--- /dev/null
+++ b/db/migrate/20170206031837_change_comments_to_polymorphic.rb
@@ -0,0 +1,7 @@
+class ChangeCommentsToPolymorphic < ActiveRecord::Migration[5.0]
+ def change
+ remove_column :comments, :post_id
+ add_column :comments, :commentable_id, :integer
+ add_column :comments, :commentable_type, :string
+ end
+end
diff --git a/db/migrate/20170206061846_add_index_to_comments.rb b/db/migrate/20170206061846_add_index_to_comments.rb
new file mode 100644
index 000000000..09f2cd612
--- /dev/null
+++ b/db/migrate/20170206061846_add_index_to_comments.rb
@@ -0,0 +1,5 @@
+class AddIndexToComments < ActiveRecord::Migration[5.0]
+ def change
+ add_index :comments, [:commentable_type, :commentable_id]
+ end
+end
diff --git a/db/migrate/20170207022634_create_photos.rb b/db/migrate/20170207022634_create_photos.rb
new file mode 100644
index 000000000..82dc25e74
--- /dev/null
+++ b/db/migrate/20170207022634_create_photos.rb
@@ -0,0 +1,9 @@
+class CreatePhotos < ActiveRecord::Migration[5.0]
+ def change
+ create_table :photos do |t|
+ t.integer :user_id
+ t.timestamps
+ end
+ add_attachment :photos, :photo
+ end
+end
diff --git a/db/migrate/20170207041303_rename_paperclip_attachment_on_photos.rb b/db/migrate/20170207041303_rename_paperclip_attachment_on_photos.rb
new file mode 100644
index 000000000..e803bb258
--- /dev/null
+++ b/db/migrate/20170207041303_rename_paperclip_attachment_on_photos.rb
@@ -0,0 +1,6 @@
+class RenamePaperclipAttachmentOnPhotos < ActiveRecord::Migration[5.0]
+ def change
+ remove_attachment :photos, :photo
+ add_attachment :photos, :image
+ end
+end
diff --git a/db/migrate/20170209011759_add_photo_columns_to_user.rb b/db/migrate/20170209011759_add_photo_columns_to_user.rb
new file mode 100644
index 000000000..e80c8b9c4
--- /dev/null
+++ b/db/migrate/20170209011759_add_photo_columns_to_user.rb
@@ -0,0 +1,6 @@
+class AddPhotoColumnsToUser < ActiveRecord::Migration[5.0]
+ def change
+ add_column :users, :profile_photo, :integer
+ add_column :users, :cover_photo, :integer
+ end
+end
diff --git a/db/migrate/20170209012011_change_photo_column_names_on_users.rb b/db/migrate/20170209012011_change_photo_column_names_on_users.rb
new file mode 100644
index 000000000..86e4c3af7
--- /dev/null
+++ b/db/migrate/20170209012011_change_photo_column_names_on_users.rb
@@ -0,0 +1,6 @@
+class ChangePhotoColumnNamesOnUsers < ActiveRecord::Migration[5.0]
+ def change
+ rename_column :users, :profile_photo, :profile_photo_id
+ rename_column :users, :cover_photo, :cover_photo_id
+ end
+end
diff --git a/db/migrate/20170210021348_create_delayed_jobs.rb b/db/migrate/20170210021348_create_delayed_jobs.rb
new file mode 100644
index 000000000..27fdcf6cc
--- /dev/null
+++ b/db/migrate/20170210021348_create_delayed_jobs.rb
@@ -0,0 +1,22 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, force: true do |table|
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.string :queue # The name of the queue this job is in
+ table.timestamps null: true
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 000000000..7222bcf20
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,106 @@
+# 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: 20170210021348) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "comments", force: :cascade do |t|
+ t.integer "user_id"
+ t.string "content"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "commentable_id"
+ t.string "commentable_type"
+ t.index ["commentable_type", "commentable_id"], name: "index_comments_on_commentable_type_and_commentable_id", using: :btree
+ end
+
+ create_table "delayed_jobs", force: :cascade do |t|
+ t.integer "priority", default: 0, null: false
+ t.integer "attempts", default: 0, null: false
+ t.text "handler", null: false
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by"
+ t.string "queue"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.index ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
+ end
+
+ create_table "friendings", force: :cascade do |t|
+ t.integer "friender_id", null: false
+ t.integer "friendee_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["friender_id", "friendee_id"], name: "index_friendings_on_friender_id_and_friendee_id", unique: true, using: :btree
+ end
+
+ create_table "likes", force: :cascade do |t|
+ t.integer "user_id"
+ t.integer "likable_id"
+ t.string "likable_type"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["likable_type", "likable_id"], name: "index_likes_on_likable_type_and_likable_id", using: :btree
+ end
+
+ create_table "photos", force: :cascade do |t|
+ t.integer "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "image_file_name"
+ t.string "image_content_type"
+ t.integer "image_file_size"
+ t.datetime "image_updated_at"
+ end
+
+ create_table "posts", force: :cascade do |t|
+ t.string "content"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "user_id"
+ end
+
+ create_table "profiles", force: :cascade do |t|
+ t.integer "user_id"
+ t.string "college"
+ t.string "hometown"
+ t.string "current_location"
+ t.string "telephone"
+ t.text "words"
+ t.text "about_me"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "email"
+ t.string "password_digest"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "first_name"
+ t.string "last_name"
+ t.integer "birth_date"
+ t.integer "birth_month"
+ t.integer "birth_year"
+ t.boolean "gender"
+ t.string "auth_token"
+ t.integer "profile_photo_id"
+ t.integer "cover_photo_id"
+ t.index ["auth_token"], name: "index_users_on_auth_token", unique: true, using: :btree
+ end
+
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 000000000..1323950bb
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,43 @@
+puts "clearing db..."
+Like.destroy_all
+Comment.destroy_all
+Post.destroy_all
+Photo.destroy_all
+Profile.destroy_all
+Friending.destroy_all
+User.destroy_all
+puts "DONE"
+
+puts "creating users..."
+20.times do |i|
+ User.create(
+ email: "foo#{i}@bar.com",
+ password: "foobar",
+ first_name: Faker::Name.first_name,
+ last_name: Faker::Name.last_name,
+ birth_month: rand(1..12),
+ birth_date: rand(1..28),
+ birth_year: rand(1980..2000)
+ )
+end
+puts "DONE"
+
+puts "creating posts..."
+User.all.each do |user|
+ user.posts.create(
+ content: Faker::Lorem.paragraph,
+ created_at: Faker::Date.between(2.years.ago, Time.now)
+ )
+end
+puts "DONE"
+
+puts "creating comments..."
+Post.all.each do |post|
+ post.comments.create(
+ user_id: User.pluck(:id).sample,
+ content: Faker::Lorem.paragraph
+ )
+end
+puts "DONE"
+
+puts "SEEDING COMPLETE"
\ No newline at end of file
diff --git a/lib/assets/.keep b/lib/assets/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/404.html b/public/404.html
new file mode 100644
index 000000000..b612547fc
--- /dev/null
+++ b/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/422.html b/public/422.html
new file mode 100644
index 000000000..a21f82b3b
--- /dev/null
+++ b/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/500.html b/public/500.html
new file mode 100644
index 000000000..061abc587
--- /dev/null
+++ b/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 000000000..3c9c7c01f
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-agent: *
+# Disallow: /
diff --git a/screenshots/about-edit.png b/screenshots/about-edit.png
new file mode 100644
index 000000000..2fbe7ffc1
Binary files /dev/null and b/screenshots/about-edit.png differ
diff --git a/screenshots/about.png b/screenshots/about.png
new file mode 100644
index 000000000..0d0a12fba
Binary files /dev/null and b/screenshots/about.png differ
diff --git a/screenshots/friends-index.png b/screenshots/friends-index.png
new file mode 100644
index 000000000..17b9c2233
Binary files /dev/null and b/screenshots/friends-index.png differ
diff --git a/screenshots/newsfeed.png b/screenshots/newsfeed.png
new file mode 100644
index 000000000..8c2dccd0c
Binary files /dev/null and b/screenshots/newsfeed.png differ
diff --git a/screenshots/photos-index.png b/screenshots/photos-index.png
new file mode 100644
index 000000000..a8ac72b4b
Binary files /dev/null and b/screenshots/photos-index.png differ
diff --git a/screenshots/photos-show.png b/screenshots/photos-show.png
new file mode 100644
index 000000000..b937c2de3
Binary files /dev/null and b/screenshots/photos-show.png differ
diff --git a/screenshots/signup.png b/screenshots/signup.png
new file mode 100644
index 000000000..ef5b6a4d7
Binary files /dev/null and b/screenshots/signup.png differ
diff --git a/screenshots/timeline.png b/screenshots/timeline.png
new file mode 100644
index 000000000..74407ff75
Binary files /dev/null and b/screenshots/timeline.png differ
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
new file mode 100644
index 000000000..e20f0b78e
--- /dev/null
+++ b/spec/controllers/posts_controller_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+describe PostsController do
+ let(:author){ create(:user) }
+ let(:created_post){ create(:post) }
+
+ context 'user not logged in' do
+ it 'redirects to login path' do
+ post :create, params: { user_id: author.id, post: attributes_for(:post) }
+ expect(response).to redirect_to login_path
+ end
+ end
+
+ context 'user logged in' do
+ before do
+ cookies[:auth_token] = author.auth_token
+ post :create, params: { user_id: author.id, post: attributes_for(:post) }
+ end
+
+ it 'redirects to user timeline' do
+ expect(response).to redirect_to user_timeline_path(author)
+ end
+
+ it 'displays flash messages' do
+ expect(flash[:success]).not_to be_nil
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
new file mode 100644
index 000000000..31f1da6f2
--- /dev/null
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -0,0 +1,49 @@
+require 'rails_helper'
+
+describe SessionsController do
+ let(:user){ create(:user) }
+
+ context '#create' do
+ it 'sets an auth token cookie' do
+ post :create, params: { email: user.email, password: user.password }
+ user.reload
+ expect(cookies[:auth_token]).to eq(user.auth_token)
+ end
+
+ it 'redirects to user timeline when successful' do
+ post :create, params: { email: user.email, password: user.password }
+ expect(response).to redirect_to user_timeline_path(user)
+ end
+
+ it 'redirects to root path when unsuccessful' do
+ post :create, params: { email: user.email, password: '' }
+ expect(response).to redirect_to root_path
+ end
+ end
+
+ context '#destroy' do
+ before do
+ post :create, params: { email: user.email, password: user.password }
+ delete :destroy
+ end
+
+ it 'redirects to root path when successful' do
+ expect(response).to redirect_to root_path
+ end
+
+ it 'displays flash' do
+ expect(flash[:success]).not_to be_nil
+ end
+
+ it 'deletes auth token cookie' do
+ user.reload
+ puts user.auth_token
+ puts cookies[:auth_token]
+ expect(request.cookies[:auth_token]).to be_nil
+ end
+ end
+
+
+
+
+end
\ No newline at end of file
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
new file mode 100644
index 000000000..ec7672b7e
--- /dev/null
+++ b/spec/controllers/users_controller_spec.rb
@@ -0,0 +1,45 @@
+require 'rails_helper'
+
+describe UsersController do
+ let(:existing_user){ create(:user) }
+ let(:other_user){ create(:user) }
+
+ context 'new user' do
+ it 'about page renders new user form' do
+ get :about, { id: existing_user.id }
+ expect(response).to redirect_to login_path
+ end
+
+ it 'create user object' do
+ expect{
+ post :create, params: { user: attributes_for(:user) }
+ }.to change(User, :count).by(1)
+ end
+ end
+
+ context 'signed in user' do
+ before do
+ cookies[:auth_token] = existing_user.auth_token
+ end
+
+ it 'redirects to newsfeed if already signed in' do
+ get :new
+ expect(response).to redirect_to newsfeed_path
+ end
+
+ it 'cannot access edit form if unauthorized' do
+ get :edit, { id: other_user.id }
+ expect(response).to redirect_to root_path
+ end
+
+ it "can access their own edit form" do
+ get :edit, { id: existing_user.id }
+ expect(response).to be_success
+ end
+
+ end
+
+
+
+
+end
\ No newline at end of file
diff --git a/spec/factories/comment_factory.rb b/spec/factories/comment_factory.rb
new file mode 100644
index 000000000..4bb172563
--- /dev/null
+++ b/spec/factories/comment_factory.rb
@@ -0,0 +1,9 @@
+FactoryGirl.define do
+
+ factory :comment do
+ content 'asdskdjf sdfsdf'
+ user
+ post
+ end
+
+end
\ No newline at end of file
diff --git a/spec/factories/like_factory.rb b/spec/factories/like_factory.rb
new file mode 100644
index 000000000..a2d1edc0e
--- /dev/null
+++ b/spec/factories/like_factory.rb
@@ -0,0 +1,15 @@
+FactoryGirl.define do
+
+ factory :like do
+ user
+
+ factory :post_like do
+ association :likable, :factory => :post
+ end
+
+ factory :comment_like do
+ association :likable, :factory => :comment
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/factories/post_factory.rb b/spec/factories/post_factory.rb
new file mode 100644
index 000000000..a4138edca
--- /dev/null
+++ b/spec/factories/post_factory.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+
+ factory :post do
+ content 'asdfa sadf asdf as dfa asdf as df sdfasd ffdsf'
+ association :user
+ end
+
+end
\ No newline at end of file
diff --git a/spec/factories/profile_factory.rb b/spec/factories/profile_factory.rb
new file mode 100644
index 000000000..044ad62b0
--- /dev/null
+++ b/spec/factories/profile_factory.rb
@@ -0,0 +1,18 @@
+FactoryGirl.define do
+
+ factory :profile do
+ college 'UCLA'
+ hometown 'LA'
+ current_location 'LA'
+ telephone '6666666666'
+ words "i'm very cool"
+ about_me "super cool"
+
+ after(:build) do |profile|
+ profile.user ||= build(:user, :profile => profile)
+ end
+
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb
new file mode 100644
index 000000000..1b70fd921
--- /dev/null
+++ b/spec/factories/user_factory.rb
@@ -0,0 +1,14 @@
+FactoryGirl.define do
+
+ factory :user do
+ sequence(:first_name) { |n| "aubrey#{n}"}
+ sequence(:last_name) { |n| "graham#{n}"}
+ sequence(:email) { |n| "aubrey#{n}@graham.com" }
+ birth_date 24
+ birth_month 10
+ birth_year 1986
+ gender true
+ password 'legend'
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/authentication_spec.rb b/spec/features/authentication_spec.rb
new file mode 100644
index 000000000..e6ff39a19
--- /dev/null
+++ b/spec/features/authentication_spec.rb
@@ -0,0 +1,51 @@
+require 'rails_helper'
+
+feature 'authentication' do
+
+ let(:existing_user){ create(:user) }
+ let(:new_user){ build(:user) }
+
+ before do
+ visit root_path
+ end
+
+ context 'when signing in' do
+ scenario 'errors if incorrect params' do
+ sign_in(new_user)
+ expect(current_path).to eq(root_path)
+ end
+
+ scenario 'log in successfully' do
+ sign_in(existing_user)
+ expect(current_path).to eq(user_timeline_path(existing_user))
+ end
+
+ scenario 'errors if log in form fields empty' do
+ click_button('Log In')
+ expect(page).to have_content("We couldn't sign you in!")
+ end
+ end
+
+ context 'when signing up' do
+ scenario 'cannot access timeline/about pages yet' do
+ visit(about_user_path(existing_user))
+ expect(current_path).to eq(login_path)
+ end
+
+ scenario 'creates new user when sign up successful' do
+ expect{ sign_up(new_user) }.to change(User, :count).by(1)
+ end
+
+ scenario 'displays errors when sign up unsuccessful' do
+ unsuccessful_new_user = build(:user, :first_name => '')
+ sign_up(unsuccessful_new_user)
+ expect(page).to have_content('Sign Up')
+ end
+
+ scenario 'existing user cannot sign up' do
+ sign_up(existing_user)
+ expect(page).to have_content('Email has already been taken')
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/edit_profile_spec.rb b/spec/features/edit_profile_spec.rb
new file mode 100644
index 000000000..bf2f7255b
--- /dev/null
+++ b/spec/features/edit_profile_spec.rb
@@ -0,0 +1,43 @@
+require 'rails_helper'
+
+feature 'Edit Profile' do
+ let(:user){ create(:user) }
+ let(:other_user){ create(:user) }
+
+ context 'edit own profile' do
+
+ before do
+ visit root_path
+ sign_in(user)
+ visit(edit_user_path(user))
+ end
+
+ specify "edit profile link on user's own about page" do
+ expect(page).to have_link('Edit Profile')
+ end
+
+ specify 'access own edit form' do
+ expect(current_path).to eq(edit_user_path(user))
+ end
+
+ specify "not permitted to access other user's edit form" do
+ visit(edit_user_path(other_user))
+ expect(current_path).not_to eq(edit_user_path(other_user))
+ end
+
+ specify 'prevented from submitting invalid params' do
+ fill_in 'user[profile_attributes][telephone]', with: "asdjfklajsdklfjklaskdfljalsdfasdf"
+ click_button('Save Changes')
+ expect(page).to have_content("Profile telephone is too long")
+ end
+
+ specify 'successfully edits own profile' do
+ fill_in 'user[profile_attributes][words]', with: 'hello hello'
+ click_button('Save Changes')
+ expect(page).to have_content('Profile updated!')
+ end
+ end
+
+
+
+end
\ No newline at end of file
diff --git a/spec/features/friend_user_spec.rb b/spec/features/friend_user_spec.rb
new file mode 100644
index 000000000..49af60253
--- /dev/null
+++ b/spec/features/friend_user_spec.rb
@@ -0,0 +1,9 @@
+require 'rails_helper'
+
+describe 'create friendship' do
+ let(:friender){ create(:user) }
+ let(:friendee){ create(:user) }
+
+ context ''
+
+end
\ No newline at end of file
diff --git a/spec/features/timeline_spec.rb b/spec/features/timeline_spec.rb
new file mode 100644
index 000000000..dfecc7c81
--- /dev/null
+++ b/spec/features/timeline_spec.rb
@@ -0,0 +1,55 @@
+require 'rails_helper'
+
+feature 'Timeline' do
+ let(:user){ create(:user) }
+ let(:other_user){ create(:user) }
+
+ context 'own timeline' do
+ before do
+ visit root_path
+ sign_in(user)
+ visit user_timeline_path(user)
+ end
+
+ specify 'successfully add post through new post form' do
+ # correct elements visible
+ expect(page).to have_link('Edit Profile')
+ expect(page).not_to have_button('Add as Friend')
+
+ # post form visible
+ expect(page).to have_field('post[content]')
+
+ # add post
+ fill_in 'post[content]', with: 'this is a post'
+
+ #check to see post count goes up
+ expect{ click_button('Post') }.to change(Post, :count).by(1)
+ end
+
+ specify 'cannot create empty post' do
+ fill_in 'post[content]', with: ''
+ click_button('Post')
+ expect(page).to have_content("Content can't be blank")
+ end
+
+ end
+
+ context "viewing other users' timelines" do
+ before do
+ visit root_path
+ sign_in(user)
+ visit user_timeline_path(other_user)
+ end
+
+ specify 'links to authorized ' do
+ expect(page).not_to have_link('Edit Profile')
+ expect(page).not_to have_field('post[content]')
+ end
+
+ specify 'add friend button visible' do
+ expect(page).to have_link('Add as Friend')
+ end
+ end
+
+
+end
\ No newline at end of file
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
new file mode 100644
index 000000000..58e97c84b
--- /dev/null
+++ b/spec/models/comment_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+describe Comment do
+ let(:comment){ build(:comment) }
+
+ describe 'validations' do
+ it { should validate_presence_of(:user) }
+ it { should validate_presence_of(:content) }
+ it { should validate_length_of(:content).is_at_least(1).is_at_most(300) }
+ end
+
+ describe 'associations' do
+ it { should belong_to(:user) }
+ it { should have_many(:likes).dependent(:destroy) }
+ end
+
+end
\ No newline at end of file
diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb
new file mode 100644
index 000000000..a01f64ab7
--- /dev/null
+++ b/spec/models/like_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+describe Like do
+ let(:post_like){ build(:post_like) }
+
+ describe 'polymorphic liking associations' do
+
+ it { should belong_to(:user) }
+ it { should belong_to(:likable) }
+ it { should validate_presence_of(:user) }
+ it { should validate_presence_of(:likable) }
+
+ it 'likes respond to parent likable association' do
+ expect(post_like).to respond_to(:likable)
+ end
+
+ it 'parents respond to child associations' do
+ expect(post_like.likable).to respond_to(:likes)
+ end
+
+ it 'likes do not allow invalid types' do
+ invalid_like = build(:like, :likable_type => 'User')
+ expect(invalid_like).not_to be_valid
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
new file mode 100644
index 000000000..b560475be
--- /dev/null
+++ b/spec/models/post_spec.rb
@@ -0,0 +1,32 @@
+require 'rails_helper'
+
+describe Post do
+ # let(:user){ create(:user) }
+ let(:post){ build(:post) }
+
+ describe 'validations' do
+
+ it 'should save with default attributes' do
+ post.save
+ expect(post).to be_valid
+ end
+
+ it 'should not be valid if user is nil' do
+ invalid_post = build(:post, :user_id => nil)
+ expect(invalid_post).not_to be_valid
+ end
+
+ it { should validate_presence_of(:content) }
+ it { should validate_presence_of(:user) }
+
+ end
+
+ describe 'associations' do
+
+ it { should belong_to(:user) }
+ it { should have_many(:comments).dependent(:destroy) }
+ it { should have_many(:likes).dependent(:destroy) }
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb
new file mode 100644
index 000000000..2a090d5b5
--- /dev/null
+++ b/spec/models/profile_spec.rb
@@ -0,0 +1,47 @@
+require 'rails_helper'
+
+describe Profile do
+ let(:user){ create(:user) }
+ let(:profile){ build(:profile, :user_id => user.id) }
+
+ describe 'validations' do
+ it 'default profile is valid' do
+ profile.save
+ expect(profile).to be_valid
+ end
+
+ it 'user should be unique' do
+ should validate_uniqueness_of(:user_id)
+ end
+
+ it 'user is present' do
+ should validate_presence_of(:user_id)
+ end
+
+ it 'invalid when user not present' do
+ invalid_profile = build(:profile, :user_id => nil)
+ expect(invalid_profile).not_to be_valid
+ end
+
+ it { should validate_length_of(:college).is_at_most(50) }
+ it { should validate_length_of(:hometown).is_at_most(50) }
+ it { should validate_length_of(:current_location).is_at_most(50) }
+ it { should validate_length_of(:telephone).is_at_most(11) }
+ it {should validate_length_of(:words).is_at_most(300) }
+ it {should validate_length_of(:about_me).is_at_most(300) }
+
+ end
+
+ describe 'associations' do
+ before do
+ profile.save
+ end
+
+ it { should belong_to(:user) }
+
+ it 'dependent on user' do
+ expect{ user.destroy }.to change{ Profile.count }.by(-1)
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
new file mode 100644
index 000000000..79db16fda
--- /dev/null
+++ b/spec/models/user_spec.rb
@@ -0,0 +1,59 @@
+require 'rails_helper'
+
+describe User do
+ let(:user){ build(:user) }
+
+ describe 'attributes' do
+ it 'email should be unique' do
+ should validate_uniqueness_of(:email)
+ end
+
+ it 'has secure password' do
+ should have_secure_password
+ end
+
+ it 'name is acceptable length' do
+ should validate_length_of(:first_name).is_at_least(1).is_at_most(50)
+ should validate_length_of(:last_name).is_at_least(1).is_at_most(50)
+ end
+
+ # it 'password is acceptable length' do
+ # should validate_length_of(:password).is_at_least(1).is_at_most(30)
+ # end
+
+ it 'birthday values should only accept integer values' do
+ should validate_numericality_of(:birth_date).only_integer
+ should validate_numericality_of(:birth_month).only_integer
+ should validate_numericality_of(:birth_year).only_integer
+ end
+
+ it 'user with non-integer birthday values is invalid' do
+ non_valid_user = build(:user, :birth_date => 1.2)
+ expect(non_valid_user).not_to be_valid
+ end
+ end
+
+ describe 'associations' do
+ it 'responds to posts association' do
+ expect(user).to respond_to(:posts)
+ end
+
+ it 'responds to profile association' do
+ expect(user).to respond_to(:profile)
+ end
+
+ it 'responds to comments association' do
+ expect(user).to respond_to(:comments)
+ end
+
+ it 'responds to likes association' do
+ expect(user).to respond_to(:likes)
+ end
+
+ it 'accepts nested attributes for profile' do
+ should accept_nested_attributes_for(:profile)
+ end
+ end
+
+
+end
\ No newline at end of file
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
new file mode 100644
index 000000000..77235936a
--- /dev/null
+++ b/spec/rails_helper.rb
@@ -0,0 +1,74 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+# Prevent database truncation if the environment is production
+abort("The Rails environment is running in production mode!") if Rails.env.production?
+require 'spec_helper'
+require 'rspec/rails'
+require 'factory_girl_rails'
+require 'capybara/rails'
+require 'shoulda/matchers'
+# Add additional requires below this line. Rails is not loaded until this point!
+
+# Requires supporting ruby files with custom matchers and macros, etc, in
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
+# run as spec files by default. This means that files in spec/support that end
+# in _spec.rb will both be required and run as specs, causing the specs to be
+# run twice. It is recommended that you do not name files matching this glob to
+# end with _spec.rb. You can configure this pattern with the --pattern
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
+#
+# The following line is provided for convenience purposes. It has the downside
+# of increasing the boot-up time by auto-requiring all files in the support
+# directory. Alternatively, in the individual `*_spec.rb` files, manually
+# require only the support files necessary.
+#
+Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
+
+# Checks for pending migration and applies them before tests are run.
+# If you are not using ActiveRecord, you can remove this line.
+ActiveRecord::Migration.maintain_test_schema!
+
+RSpec.configure do |config|
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # RSpec Rails can automatically mix in different behaviours to your tests
+ # based on their file location, for example enabling you to call `get` and
+ # `post` in specs under `spec/controllers`.
+ #
+ # You can disable this behaviour by removing the line below, and instead
+ # explicitly tag your specs with their type, e.g.:
+ #
+ # RSpec.describe UsersController, :type => :controller do
+ # # ...
+ # end
+ #
+ # The different available types are documented in the features, such as in
+ # https://relishapp.com/rspec/rspec-rails/docs
+ config.infer_spec_type_from_file_location!
+
+ # Filter lines from Rails gems in backtraces.
+ config.filter_rails_from_backtrace!
+ # arbitrary gems may also be filtered via:
+ # config.filter_gems_from_backtrace("gem name")
+
+ # Avoid prefacing FactoryGirl methods with 'Factory Girl'
+ config.include FactoryGirl::Syntax::Methods
+ # Include macros
+ config.include Macros
+ config.include Capybara::DSL
+end
+
+
+Shoulda::Matchers.configure do |config|
+ config.integrate do |with|
+ with.test_framework :rspec
+ with.library :rails
+ end
+end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 000000000..8f698be46
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,99 @@
+# This file was generated by the `rails generate rspec:install` command. Conventionally, all
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
+# The generated `.rspec` file contains `--require spec_helper` which will cause
+# this file to always be loaded, without a need to explicitly require it in any
+# files.
+#
+# Given that it is always loaded, you are encouraged to keep this file as
+# light-weight as possible. Requiring heavyweight dependencies from this file
+# will add to the boot time of your test suite on EVERY test run, even for an
+# individual file that may not need all of that loaded. Instead, consider making
+# a separate helper file that requires the additional dependencies and performs
+# the additional setup, and require it from the spec files that actually need
+# it.
+#
+# The `.rspec` file also contains a few flags that are not defaults but that
+# users commonly want.
+#
+# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+RSpec.configure do |config|
+ # rspec-expectations config goes here. You can use an alternate
+ # assertion/expectation library such as wrong or the stdlib/minitest
+ # assertions if you prefer.
+ config.expect_with :rspec do |expectations|
+ # This option will default to `true` in RSpec 4. It makes the `description`
+ # and `failure_message` of custom matchers include text for helper methods
+ # defined using `chain`, e.g.:
+ # be_bigger_than(2).and_smaller_than(4).description
+ # # => "be bigger than 2 and smaller than 4"
+ # ...rather than:
+ # # => "be bigger than 2"
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end
+
+ # rspec-mocks config goes here. You can use an alternate test double
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
+ config.mock_with :rspec do |mocks|
+ # Prevents you from mocking or stubbing a method that does not exist on
+ # a real object. This is generally recommended, and will default to
+ # `true` in RSpec 4.
+ mocks.verify_partial_doubles = true
+ end
+
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
+ # have no way to turn it off -- the option exists only for backwards
+ # compatibility in RSpec 3). It causes shared context metadata to be
+ # inherited by the metadata hash of host groups and examples, rather than
+ # triggering implicit auto-inclusion in groups with matching metadata.
+ config.shared_context_metadata_behavior = :apply_to_host_groups
+
+# The settings below are suggested to provide a good initial experience
+# with RSpec, but feel free to customize to your heart's content.
+=begin
+ # This allows you to limit a spec run to individual examples or groups
+ # you care about by tagging them with `:focus` metadata. When nothing
+ # is tagged with `:focus`, all examples get run. RSpec also provides
+ # aliases for `it`, `describe`, and `context` that include `:focus`
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
+ config.filter_run_when_matching :focus
+
+ # Allows RSpec to persist some state between runs in order to support
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
+ # you configure your source control system to ignore this file.
+ config.example_status_persistence_file_path = "spec/examples.txt"
+
+ # Limits the available syntax to the non-monkey patched syntax that is
+ # recommended. For more details, see:
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
+ config.disable_monkey_patching!
+
+ # Many RSpec users commonly either run the entire suite or an individual
+ # file, and it's useful to allow more verbose output when running an
+ # individual spec file.
+ if config.files_to_run.one?
+ # Use the documentation formatter for detailed output,
+ # unless a formatter has already been configured
+ # (e.g. via a command-line flag).
+ config.default_formatter = 'doc'
+ end
+
+ # Print the 10 slowest examples and example groups at the
+ # end of the spec run, to help surface which specs are running
+ # particularly slow.
+ config.profile_examples = 10
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = :random
+
+ # Seed global randomization in this process using the `--seed` CLI option.
+ # Setting this allows you to use `--seed` to deterministically reproduce
+ # test failures related to randomization by passing the same `--seed` value
+ # as the one that triggered the failure.
+ Kernel.srand config.seed
+=end
+end
diff --git a/spec/support/macros.rb b/spec/support/macros.rb
new file mode 100644
index 000000000..575cd453a
--- /dev/null
+++ b/spec/support/macros.rb
@@ -0,0 +1,22 @@
+module Macros
+
+ def sign_in(user)
+ fill_in :email, with: "#{user.email}"
+ fill_in :password, with: "#{user.password}"
+ click_button('Log In')
+ end
+
+ def sign_up(user)
+ fill_in 'First Name', with: "#{user.first_name}"
+ fill_in 'Last Name', with: "#{user.last_name}"
+ fill_in 'Your Email', with: "#{user.email}"
+ fill_in 'Your New Password', with: "#{user.password}"
+ fill_in 'Confirm Your Password', with: "#{user.password}"
+ select("#{user.birth_month}", :from => 'user[birth_month]')
+ select("#{user.birth_date}", :from => 'user[birth_date]')
+ select("#{user.birth_year}", :from => 'user[birth_year]')
+ choose('user_gender_true')
+ click_button('Sign Up!')
+ end
+
+end
\ No newline at end of file
diff --git a/spec/views/layout_views_spec.rb b/spec/views/layout_views_spec.rb
new file mode 100644
index 000000000..e12c4c38c
--- /dev/null
+++ b/spec/views/layout_views_spec.rb
@@ -0,0 +1,51 @@
+require 'rails_helper'
+
+describe 'shared/_nav.html.erb' do
+ let(:user){ create(:user) }
+
+ context 'when signed in' do
+ before do
+ cookies[:auth_token] = user.auth_token
+ @user = user
+ def view.signed_in_user?
+ true
+ end
+
+ def view.current_user
+ @user
+ end
+
+ render
+ end
+
+ it 'nav search bar is present' do
+ expect(rendered).to have_selector("input", class: 'search')
+ end
+
+ it 'name is displayed on nav' do
+ expect(rendered).to have_content("#{user.first_name}")
+ end
+
+ it 'logout link on nav' do
+ expect(rendered).to have_link('Log Out')
+ end
+ end
+
+ context 'not signed in' do
+ before do
+ def view.signed_in_user?
+ false
+ end
+
+ render
+
+ end
+
+ it 'log in form is present' do
+ expect(rendered).to have_selector("input", id: 'email')
+ end
+ end
+
+
+
+end
\ No newline at end of file
diff --git a/tmp/.keep b/tmp/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep
new file mode 100644
index 000000000..e69de29bb
<%= like_count(@photo) %>
+ +