+
\ No newline at end of file
diff --git a/app/views/layouts/_navbar-login.html.erb b/app/views/layouts/_navbar-login.html.erb
new file mode 100644
index 000000000..b05460b41
--- /dev/null
+++ b/app/views/layouts/_navbar-login.html.erb
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb
new file mode 100644
index 000000000..dd2c6b9c4
--- /dev/null
+++ b/app/views/layouts/_navbar.html.erb
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/app/views/layouts/_navlinks.html.erb b/app/views/layouts/_navlinks.html.erb
new file mode 100644
index 000000000..bc004f34a
--- /dev/null
+++ b/app/views/layouts/_navlinks.html.erb
@@ -0,0 +1,41 @@
+
+
+
\ No newline at end of file
diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb
new file mode 100644
index 000000000..03cd74a48
--- /dev/null
+++ b/app/views/profiles/show.html.erb
@@ -0,0 +1,56 @@
+<%= render partial: "layouts/navlinks", locals: {user: @user} %>
+
+
+
+
+
+
About
+
+
+
+
+
+
+
Basic Information
+
+
+
Gender:
+
Birthday:
+
Hometown:
+
Currently Lives:
+
+
+
+
<%= @user.gender.titleize if @user.gender%>
+
<%= @user.birthdate %>
+
<%= @profile.hometown %>
+
<%= @profile.current_residence %>
+
+
+
+
Contact Information
+
+
+
Email:
+
Telephone:
+
+
+
+
<%= @user.email %>
+
<%= @profile.telephone %>
+
+
+
+
+
+
Words to Live By
+
<%= @profile.words_to_live_by %>
+
About Me
+
<%= @profile.about_me %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
new file mode 100644
index 000000000..2f62cbe25
--- /dev/null
+++ b/app/views/sessions/new.html.erb
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/app/views/shared/_comment.html.erb b/app/views/shared/_comment.html.erb
new file mode 100644
index 000000000..5fd904d86
--- /dev/null
+++ b/app/views/shared/_comment.html.erb
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/views/shared/_post.html.erb b/app/views/shared/_post.html.erb
new file mode 100644
index 000000000..fb3dce4c9
--- /dev/null
+++ b/app/views/shared/_post.html.erb
@@ -0,0 +1,77 @@
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
About Me
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/static_pages/about_edit.html.erb b/app/views/static_pages/about_edit.html.erb
new file mode 100644
index 000000000..203deb3ed
--- /dev/null
+++ b/app/views/static_pages/about_edit.html.erb
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+ Welcome to Danebook
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/static_pages/index.html.erb b/app/views/static_pages/index.html.erb
new file mode 100644
index 000000000..9ac7fbfe2
--- /dev/null
+++ b/app/views/static_pages/index.html.erb
@@ -0,0 +1,77 @@
+
+
+
+
+
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
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/user_mailer/notification.html.erb b/app/views/user_mailer/notification.html.erb
new file mode 100644
index 000000000..51cd9e041
--- /dev/null
+++ b/app/views/user_mailer/notification.html.erb
@@ -0,0 +1,7 @@
+
A comment has been added.
+
+
A new comment has been posted by <%= @writer.name %> on your <%= @comment.commentable_type %>.
+
+
Comment: <%= @comment.body %>
+
+
View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %>
\ No newline at end of file
diff --git a/app/views/user_mailer/notification.text.erb b/app/views/user_mailer/notification.text.erb
new file mode 100644
index 000000000..d08b6c8ab
--- /dev/null
+++ b/app/views/user_mailer/notification.text.erb
@@ -0,0 +1,7 @@
+A comment has been added.
+
+A new comment has been posted by <%= @writer.name %> on your <%= @comment.commentable_type %>.
+
+Comment: <%= @comment.body %>
+
+View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %>
\ 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..e3a9c1346
--- /dev/null
+++ b/app/views/user_mailer/welcome.html.erb
@@ -0,0 +1,5 @@
+
Welcome to Danebook!
+
+
Thank you for signing up, <%= @user.first_name %>.
+
+
View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %>
\ 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..2527078e4
--- /dev/null
+++ b/app/views/user_mailer/welcome.text.erb
@@ -0,0 +1,5 @@
+Welcome to Danebook!
+
+Thank you for signing up, <%= @user.first_name %>.
+
+View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
new file mode 100644
index 000000000..699ce17e4
--- /dev/null
+++ b/app/views/users/index.html.erb
@@ -0,0 +1,89 @@
+
+ <% if @user %>
+ <% @user.errors.full_messages.each do |msg| %>
+
<%= msg %>
+ <% end %>
+ <% elsif @profile %>
+ <% @profile.errors.each do |msg| %>
+
<%= msg %>
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
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
+
+
+
+
+
+
+
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
new file mode 100644
index 000000000..1b08102a7
--- /dev/null
+++ b/app/views/users/new.html.erb
@@ -0,0 +1,20 @@
+
+ <% @user.posts.order(created_at: :desc)[0..-2].each do |post| %>
+ <%= render partial: "shared/post", locals: {post: post, comment: post.comments.build} %>
+ <% end %>
+
+
+
+
+
+
\ No newline at end of file
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..7fe232c3a
--- /dev/null
+++ b/bin/spring
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+
+# This file loads spring without using Bundler, in order to be fast.
+# It gets overwritten when you run the `spring binstub` command.
+
+unless defined?(Spring)
+ require 'rubygems'
+ require 'bundler'
+
+ if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
+ Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
+ gem 'spring', match[1]
+ require 'spring/binstub'
+ end
+end
diff --git a/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..e48e8a2d3
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,77 @@
+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
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
+ config.action_mailer.delivery_method = :letter_opener
+
+ # 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
+
+ config.paperclip_defaults = {
+
+ # Don't forget to make S3 your storage option!
+ :storage => :s3,
+
+ :s3_credentials => {
+
+ # put your host name here if needed
+ # see the reading below for more details
+ # NOTE: This must be the correct region for YOU
+ :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
+ }
+ }
+
+ Paperclip.options[:command_path] = "/usr/local/bin"
+ # 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
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 000000000..8a7d3de70
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,120 @@
+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.action_mailer.smtp_settings = {
+ :address => 'smtp.sendgrid.net',
+ :port => '587',
+ :authentication => :plain,
+ :user_name => ENV['SENDGRID_USERNAME'],
+ :password => ENV['SENDGRID_PASSWORD'],
+ :domain => 'heroku.com',
+ :enable_starttls_auto => true
+ }
+ config.action_mailer.delivery_method ||= :smtp
+
+ config.action_mailer.default_url_options = {
+ :host => 'morning-journey-10393.herokuapp.com',
+ }
+
+ config.paperclip_defaults = {
+
+ # Don't forget to make S3 your storage option!
+ :storage => :s3,
+
+ :s3_credentials => {
+
+ # put your host name here if needed
+ # see the reading below for more details
+ # NOTE: This must be the correct region for YOU
+ :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.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
+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..0706cafd4
--- /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 Rails 5.0 release notes 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..001bcc592
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,38 @@
+Rails.application.routes.draw do
+
+ root "users#index"
+
+ resources :users do
+ resource :profile, only: [:show]
+ resources :posts, only: [:create, :destroy]
+ get "timeline" => "users#show"
+ get "newsfeed" => "users#newsfeed"
+ resources :comments, only: [:create, :destroy]
+ resources :photos, only: [:create, :destroy, :index, :new, :show]
+ end
+
+ resource :profile, only: [:edit, :update] do
+ get "profile_photo" => "profiles#photo"
+ get "cover_photo" => "profiles#cover"
+ end
+
+ resource :session, only: [:new, :create, :destroy]
+ get "login" => "sessions#new"
+ delete "logout" => "sessions#destroy"
+
+ resource :static_pages, only: [:index, :show, :new]
+
+ resources :friendings, :only => [:create, :destroy, :show]
+
+ resources :posts, only: [] do
+ get "cfield" => "posts#cfield"
+ resources :likes, only: [:create, :destroy], :defaults => { :likeable => 'Post' }
+ end
+
+ resources :photos, only: [] do
+ resources :likes, only: [:create, :destroy], :defaults => { :likeable => 'Photo' }
+ end
+
+ get "search" => "profiles#search"
+
+end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 000000000..41b6a50fb
--- /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: 970038f03c891c92bbda30ec9ec27dbfd9c02a29f0634cbef8ff5539b496cf16dbbbbeea235427af0f387a0987ccca6a921ebf53ab1fbd007de4f727b7b5178f
+ 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: 21687109618b774f14d0aeae77a88bd7339a64659eab0ccae2d22d5e295ecb4f1b09877eebd9ff7f3f7560d6986c23f7f5d7043f136e8c244cfdcebe8c1793e3
+
+# 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/20160810204821_create_users.rb b/db/migrate/20160810204821_create_users.rb
new file mode 100644
index 000000000..3061418b4
--- /dev/null
+++ b/db/migrate/20160810204821_create_users.rb
@@ -0,0 +1,11 @@
+class CreateUsers < ActiveRecord::Migration[5.0]
+ def change
+ create_table :users do |t|
+ t.string :email
+ t.string :password_digest
+ t.string :auth_token
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160810213602_add_auth_token_index_to_users.rb b/db/migrate/20160810213602_add_auth_token_index_to_users.rb
new file mode 100644
index 000000000..bc9d74f96
--- /dev/null
+++ b/db/migrate/20160810213602_add_auth_token_index_to_users.rb
@@ -0,0 +1,5 @@
+class AddAuthTokenIndexToUsers < ActiveRecord::Migration[5.0]
+ def change
+ add_index :users, :auth_token, :unique => true
+ end
+end
diff --git a/db/migrate/20160810230851_create_profiles.rb b/db/migrate/20160810230851_create_profiles.rb
new file mode 100644
index 000000000..5da155836
--- /dev/null
+++ b/db/migrate/20160810230851_create_profiles.rb
@@ -0,0 +1,13 @@
+class CreateProfiles < ActiveRecord::Migration[5.0]
+ def change
+ create_table :profiles do |t|
+ t.string :first_name
+ t.string :last_name
+ t.string :gender
+ t.date :birthdate
+ t.integer :user_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160811180907_add_more_info_to_profile.rb b/db/migrate/20160811180907_add_more_info_to_profile.rb
new file mode 100644
index 000000000..2ab2b952f
--- /dev/null
+++ b/db/migrate/20160811180907_add_more_info_to_profile.rb
@@ -0,0 +1,11 @@
+class AddMoreInfoToProfile < ActiveRecord::Migration[5.0]
+ def change
+
+ add_column :profiles, :hometown, :string, default: ""
+ add_column :profiles, :current_residence, :string, default: ""
+ add_column :profiles, :telephone, :string, default: ""
+ add_column :profiles, :words_to_live_by, :text, default: ""
+ add_column :profiles, :about_me, :text, default: ""
+
+ end
+end
diff --git a/db/migrate/20160811221123_create_posts.rb b/db/migrate/20160811221123_create_posts.rb
new file mode 100644
index 000000000..0a150ac95
--- /dev/null
+++ b/db/migrate/20160811221123_create_posts.rb
@@ -0,0 +1,10 @@
+class CreatePosts < ActiveRecord::Migration[5.0]
+ def change
+ create_table :posts do |t|
+ t.text :body
+ t.integer :user_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160812184039_create_likes.rb b/db/migrate/20160812184039_create_likes.rb
new file mode 100644
index 000000000..02df9acb0
--- /dev/null
+++ b/db/migrate/20160812184039_create_likes.rb
@@ -0,0 +1,10 @@
+class CreateLikes < ActiveRecord::Migration[5.0]
+ def change
+ create_table :likes do |t|
+ t.integer :user_id
+ t.integer :post_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160812184326_create_comments.rb b/db/migrate/20160812184326_create_comments.rb
new file mode 100644
index 000000000..08a314e57
--- /dev/null
+++ b/db/migrate/20160812184326_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.text :body
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160816224231_create_friendings.rb b/db/migrate/20160816224231_create_friendings.rb
new file mode 100644
index 000000000..afedd67c0
--- /dev/null
+++ b/db/migrate/20160816224231_create_friendings.rb
@@ -0,0 +1,10 @@
+class CreateFriendings < ActiveRecord::Migration[5.0]
+ def change
+ create_table :friendings do |t|
+ t.integer :friender_id
+ t.integer :friended_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160818223638_create_photos.rb b/db/migrate/20160818223638_create_photos.rb
new file mode 100644
index 000000000..51f82aa04
--- /dev/null
+++ b/db/migrate/20160818223638_create_photos.rb
@@ -0,0 +1,10 @@
+class CreatePhotos < ActiveRecord::Migration[5.0]
+ def change
+ create_table :photos do |t|
+ t.has_attached_file :image
+ t.string :user_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20160819171009_add_cover_and_photo_to_profile.rb b/db/migrate/20160819171009_add_cover_and_photo_to_profile.rb
new file mode 100644
index 000000000..3684085c3
--- /dev/null
+++ b/db/migrate/20160819171009_add_cover_and_photo_to_profile.rb
@@ -0,0 +1,8 @@
+class AddCoverAndPhotoToProfile < ActiveRecord::Migration[5.0]
+ def change
+
+ add_column :profiles, :profile_photo_id, :integer
+ add_column :profiles, :cover_id, :integer
+
+ end
+end
diff --git a/db/migrate/20160819205805_add_polymorphism_to_like.rb b/db/migrate/20160819205805_add_polymorphism_to_like.rb
new file mode 100644
index 000000000..673dca416
--- /dev/null
+++ b/db/migrate/20160819205805_add_polymorphism_to_like.rb
@@ -0,0 +1,9 @@
+class AddPolymorphismToLike < ActiveRecord::Migration[5.0]
+ def change
+
+ add_column :likes, :likeable_id, :integer
+ add_column :likes, :likeable_type, :string
+ remove_column :likes, :post_id
+
+ end
+end
diff --git a/db/migrate/20160819222311_add_polymorphism_to_comment.rb b/db/migrate/20160819222311_add_polymorphism_to_comment.rb
new file mode 100644
index 000000000..92c5b0f1b
--- /dev/null
+++ b/db/migrate/20160819222311_add_polymorphism_to_comment.rb
@@ -0,0 +1,9 @@
+class AddPolymorphismToComment < ActiveRecord::Migration[5.0]
+ def change
+
+ add_column :comments, :commentable_id, :integer
+ add_column :comments, :commentable_type, :string
+ remove_column :comments, :post_id
+
+ end
+end
diff --git a/db/migrate/20160819232659_create_delayed_jobs.rb b/db/migrate/20160819232659_create_delayed_jobs.rb
new file mode 100644
index 000000000..27fdcf6cc
--- /dev/null
+++ b/db/migrate/20160819232659_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/migrate/20160921181702_add_to_user_and_remove_from_profile.rb b/db/migrate/20160921181702_add_to_user_and_remove_from_profile.rb
new file mode 100644
index 000000000..1201d2575
--- /dev/null
+++ b/db/migrate/20160921181702_add_to_user_and_remove_from_profile.rb
@@ -0,0 +1,14 @@
+class AddToUserAndRemoveFromProfile < ActiveRecord::Migration[5.0]
+ def change
+
+ remove_column :profiles, :first_name
+ remove_column :profiles, :last_name
+ remove_column :profiles, :gender
+ remove_column :profiles, :birthdate
+
+ add_column :users, :first_name, :string
+ add_column :users, :last_name, :string
+ add_column :users, :gender, :string
+ add_column :users, :birthdate, :date
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 000000000..42c7de2ac
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,100 @@
+# 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: 20160921181702) 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.text "body"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "commentable_id"
+ t.string "commentable_type"
+ 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"
+ t.integer "friended_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "likes", force: :cascade do |t|
+ t.integer "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "likeable_id"
+ t.string "likeable_type"
+ end
+
+ create_table "photos", force: :cascade do |t|
+ t.string "image_file_name"
+ t.string "image_content_type"
+ t.integer "image_file_size"
+ t.datetime "image_updated_at"
+ t.string "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "posts", force: :cascade do |t|
+ t.text "body"
+ t.integer "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "profiles", force: :cascade do |t|
+ t.integer "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "hometown", default: ""
+ t.string "current_residence", default: ""
+ t.string "telephone", default: ""
+ t.text "words_to_live_by", default: ""
+ t.text "about_me", default: ""
+ t.integer "profile_photo_id"
+ t.integer "cover_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "email"
+ t.string "password_digest"
+ t.string "auth_token"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "first_name"
+ t.string "last_name"
+ t.string "gender"
+ t.date "birthdate"
+ 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..a0cff9cd3
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,32 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
+puts "deleting everything"
+User.destroy_all
+Profile.destroy_all
+Post.destroy_all
+
+puts "creating users"
+User.create(email: "louisck@gmail.com", password: "asdfasdf", first_name: "Louis", last_name: "CK", gender: "male", birthdate: Date.parse("09/02/1977"))
+User.create(email: "chrisrock@gmail.com", password: "zxcvzxcv", first_name: "Chris", last_name: "Rock", gender: "male", birthdate: Date.parse("11/11/1976"))
+User.create(email: "johnwaters@gmail.com", password: "qwerqwer", first_name: "John", last_name: "Waters", gender: "male", birthdate: Date.parse("10/02/1937"))
+
+puts "creating profiles"
+User.first.create_profile(hometown: "Newton, MA", current_residence: "New York, New York", telephone: "555-555-5555", words_to_live_by: "I have no words to live by.", about_me: "I have no about me.")
+User.second.create_profile(hometown: "Brooklyn, NY", current_residence: "Somewhere in Jersey", telephone: "555-555-5225", words_to_live_by: "Comedy is King.", about_me: "I do comedy.")
+User.third.create_profile(hometown: "Baltimore, MD", current_residence: "Baltimore, MD", telephone: "555-555-5255", words_to_live_by: "Words? Words??", about_me: "Something orange.")
+
+puts "creating posts"
+User.first.posts.create(body: "This is a post by Louis CK, the comedian.")
+User.first.posts.create(body: "I sure do like posting things.")
+User.first.posts.create(body: "Go watch my new TV series on some channel at some time.")
+User.second.posts.create(body: "Today was a good day.")
+User.second.posts.create(body: "Today was an okay day.")
+User.second.posts.create(body: "I wrote a funny joke today.")
+User.third.posts.create(body: "Words? Words??")
+User.third.posts.create(body: "Words..")
+User.third.posts.create(body: "OK.")
\ 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/public/system/photos/images/000/000/003/medium/pootie_tang.jpg b/public/system/photos/images/000/000/003/medium/pootie_tang.jpg
new file mode 100644
index 000000000..dd40abea9
Binary files /dev/null and b/public/system/photos/images/000/000/003/medium/pootie_tang.jpg differ
diff --git a/public/system/photos/images/000/000/003/original/pootie_tang.jpg b/public/system/photos/images/000/000/003/original/pootie_tang.jpg
new file mode 100644
index 000000000..16df1908a
Binary files /dev/null and b/public/system/photos/images/000/000/003/original/pootie_tang.jpg differ
diff --git a/public/system/photos/images/000/000/003/thumb/pootie_tang.jpg b/public/system/photos/images/000/000/003/thumb/pootie_tang.jpg
new file mode 100644
index 000000000..453979c17
Binary files /dev/null and b/public/system/photos/images/000/000/003/thumb/pootie_tang.jpg differ
diff --git a/public/system/photos/images/000/000/004/medium/bull_shark.jpg b/public/system/photos/images/000/000/004/medium/bull_shark.jpg
new file mode 100644
index 000000000..9b63774a3
Binary files /dev/null and b/public/system/photos/images/000/000/004/medium/bull_shark.jpg differ
diff --git a/public/system/photos/images/000/000/004/medium/shark2.jpg b/public/system/photos/images/000/000/004/medium/shark2.jpg
new file mode 100644
index 000000000..1e347d1b5
Binary files /dev/null and b/public/system/photos/images/000/000/004/medium/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/004/original/bull_shark.jpg b/public/system/photos/images/000/000/004/original/bull_shark.jpg
new file mode 100644
index 000000000..6bfd0cd0a
Binary files /dev/null and b/public/system/photos/images/000/000/004/original/bull_shark.jpg differ
diff --git a/public/system/photos/images/000/000/004/original/shark2.jpg b/public/system/photos/images/000/000/004/original/shark2.jpg
new file mode 100644
index 000000000..74b94c30e
Binary files /dev/null and b/public/system/photos/images/000/000/004/original/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/004/thumb/bull_shark.jpg b/public/system/photos/images/000/000/004/thumb/bull_shark.jpg
new file mode 100644
index 000000000..b68329d27
Binary files /dev/null and b/public/system/photos/images/000/000/004/thumb/bull_shark.jpg differ
diff --git a/public/system/photos/images/000/000/004/thumb/shark2.jpg b/public/system/photos/images/000/000/004/thumb/shark2.jpg
new file mode 100644
index 000000000..bd4c1994e
Binary files /dev/null and b/public/system/photos/images/000/000/004/thumb/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/005/medium/shark2.jpg b/public/system/photos/images/000/000/005/medium/shark2.jpg
new file mode 100644
index 000000000..1e347d1b5
Binary files /dev/null and b/public/system/photos/images/000/000/005/medium/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/005/original/shark2.jpg b/public/system/photos/images/000/000/005/original/shark2.jpg
new file mode 100644
index 000000000..74b94c30e
Binary files /dev/null and b/public/system/photos/images/000/000/005/original/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/005/thumb/shark2.jpg b/public/system/photos/images/000/000/005/thumb/shark2.jpg
new file mode 100644
index 000000000..bd4c1994e
Binary files /dev/null and b/public/system/photos/images/000/000/005/thumb/shark2.jpg differ
diff --git a/public/system/photos/images/000/000/006/medium/surveyor_builder_3_question_types.png b/public/system/photos/images/000/000/006/medium/surveyor_builder_3_question_types.png
new file mode 100644
index 000000000..2270d6b96
Binary files /dev/null and b/public/system/photos/images/000/000/006/medium/surveyor_builder_3_question_types.png differ
diff --git a/public/system/photos/images/000/000/006/original/surveyor_builder_3_question_types.png b/public/system/photos/images/000/000/006/original/surveyor_builder_3_question_types.png
new file mode 100644
index 000000000..50e65ffca
Binary files /dev/null and b/public/system/photos/images/000/000/006/original/surveyor_builder_3_question_types.png differ
diff --git a/public/system/photos/images/000/000/006/thumb/surveyor_builder_3_question_types.png b/public/system/photos/images/000/000/006/thumb/surveyor_builder_3_question_types.png
new file mode 100644
index 000000000..f876b9722
Binary files /dev/null and b/public/system/photos/images/000/000/006/thumb/surveyor_builder_3_question_types.png differ
diff --git a/public/system/photos/images/000/000/016/medium/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg b/public/system/photos/images/000/000/016/medium/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg
new file mode 100644
index 000000000..26f721618
Binary files /dev/null and b/public/system/photos/images/000/000/016/medium/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg differ
diff --git a/public/system/photos/images/000/000/016/original/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg b/public/system/photos/images/000/000/016/original/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg
new file mode 100644
index 000000000..0e3f22498
Binary files /dev/null and b/public/system/photos/images/000/000/016/original/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg differ
diff --git a/public/system/photos/images/000/000/016/thumb/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg b/public/system/photos/images/000/000/016/thumb/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg
new file mode 100644
index 000000000..7a76dea9d
Binary files /dev/null and b/public/system/photos/images/000/000/016/thumb/635959058074383338-1169350591_louis_ck_painting-cara-and-louie.jpg differ
diff --git a/public/system/photos/images/000/000/017/medium/9-louis-show.w529.h529.jpg b/public/system/photos/images/000/000/017/medium/9-louis-show.w529.h529.jpg
new file mode 100644
index 000000000..e8880705a
Binary files /dev/null and b/public/system/photos/images/000/000/017/medium/9-louis-show.w529.h529.jpg differ
diff --git a/public/system/photos/images/000/000/017/original/9-louis-show.w529.h529.jpg b/public/system/photos/images/000/000/017/original/9-louis-show.w529.h529.jpg
new file mode 100644
index 000000000..3719dcb84
Binary files /dev/null and b/public/system/photos/images/000/000/017/original/9-louis-show.w529.h529.jpg differ
diff --git a/public/system/photos/images/000/000/017/thumb/9-louis-show.w529.h529.jpg b/public/system/photos/images/000/000/017/thumb/9-louis-show.w529.h529.jpg
new file mode 100644
index 000000000..db3eaa986
Binary files /dev/null and b/public/system/photos/images/000/000/017/thumb/9-louis-show.w529.h529.jpg differ
diff --git a/public/system/photos/images/000/000/018/medium/07-louis-ck-2.w529.h352.jpg b/public/system/photos/images/000/000/018/medium/07-louis-ck-2.w529.h352.jpg
new file mode 100644
index 000000000..11bf1efc4
Binary files /dev/null and b/public/system/photos/images/000/000/018/medium/07-louis-ck-2.w529.h352.jpg differ
diff --git a/public/system/photos/images/000/000/018/original/07-louis-ck-2.w529.h352.jpg b/public/system/photos/images/000/000/018/original/07-louis-ck-2.w529.h352.jpg
new file mode 100644
index 000000000..80b9994ad
Binary files /dev/null and b/public/system/photos/images/000/000/018/original/07-louis-ck-2.w529.h352.jpg differ
diff --git a/public/system/photos/images/000/000/018/thumb/07-louis-ck-2.w529.h352.jpg b/public/system/photos/images/000/000/018/thumb/07-louis-ck-2.w529.h352.jpg
new file mode 100644
index 000000000..9b6b97c55
Binary files /dev/null and b/public/system/photos/images/000/000/018/thumb/07-louis-ck-2.w529.h352.jpg differ
diff --git a/public/system/photos/images/000/000/019/medium/mte5ndg0mdu1mtk5mze5nty3.jpg b/public/system/photos/images/000/000/019/medium/mte5ndg0mdu1mtk5mze5nty3.jpg
new file mode 100644
index 000000000..eb642b597
Binary files /dev/null and b/public/system/photos/images/000/000/019/medium/mte5ndg0mdu1mtk5mze5nty3.jpg differ
diff --git a/public/system/photos/images/000/000/019/original/mte5ndg0mdu1mtk5mze5nty3.jpg b/public/system/photos/images/000/000/019/original/mte5ndg0mdu1mtk5mze5nty3.jpg
new file mode 100644
index 000000000..17a7c3b2e
Binary files /dev/null and b/public/system/photos/images/000/000/019/original/mte5ndg0mdu1mtk5mze5nty3.jpg differ
diff --git a/public/system/photos/images/000/000/019/thumb/mte5ndg0mdu1mtk5mze5nty3.jpg b/public/system/photos/images/000/000/019/thumb/mte5ndg0mdu1mtk5mze5nty3.jpg
new file mode 100644
index 000000000..5ce533507
Binary files /dev/null and b/public/system/photos/images/000/000/019/thumb/mte5ndg0mdu1mtk5mze5nty3.jpg differ
diff --git a/public/system/photos/images/000/000/020/medium/milk.jpg b/public/system/photos/images/000/000/020/medium/milk.jpg
new file mode 100644
index 000000000..1630c04c1
Binary files /dev/null and b/public/system/photos/images/000/000/020/medium/milk.jpg differ
diff --git a/public/system/photos/images/000/000/020/original/milk.jpg b/public/system/photos/images/000/000/020/original/milk.jpg
new file mode 100644
index 000000000..93f070b51
Binary files /dev/null and b/public/system/photos/images/000/000/020/original/milk.jpg differ
diff --git a/public/system/photos/images/000/000/020/thumb/milk.jpg b/public/system/photos/images/000/000/020/thumb/milk.jpg
new file mode 100644
index 000000000..2bf6b8ea3
Binary files /dev/null and b/public/system/photos/images/000/000/020/thumb/milk.jpg differ
diff --git a/screenshot.png b/screenshot.png
new file mode 100644
index 000000000..b744886b2
Binary files /dev/null and b/screenshot.png differ
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
new file mode 100644
index 000000000..d116504a6
--- /dev/null
+++ b/spec/controllers/comments_controller_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+describe CommentsController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:new_post){ create(:post) }
+ let(:user){ create(:user, profile: profile, posts: [new_post]) }
+
+ context "when visitor is not signed in" do
+
+ it "comments#create will not create a new Comment" do
+ expect{post :create, params: {user_id: user.id, comment: {body: "Text", post_id: new_post.id}}}.to change(Comment, :count).by(0)
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ request.cookies[:auth_token] = user.auth_token
+ end
+
+ it "comments#create will create a new Comment" do
+ expect{post :create, params: {user_id: user.id, comment: {body: "Text", post_id: new_post.id}}}.to change(Comment, :count).by(1)
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/controllers/features_controller_spec.rb b/spec/controllers/features_controller_spec.rb
new file mode 100644
index 000000000..fb6d1ed82
--- /dev/null
+++ b/spec/controllers/features_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe FeaturesController, type: :controller do
+
+end
diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb
new file mode 100644
index 000000000..1b3fc53be
--- /dev/null
+++ b/spec/controllers/likes_controller_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+describe LikesController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:new_post){ create(:post) }
+ let(:user){ create(:user, profile: profile, posts: [new_post]) }
+
+ context "when visitor is not signed in" do
+
+ it "likes#create will not create a new Like" do
+ expect{post :create, params: {user_id: user.id, format: new_post.id}}.to change(Like, :count).by(0)
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ request.cookies[:auth_token] = user.auth_token
+ end
+
+ it "likes#create will create a new Like" do
+ expect{post :create, params: {user_id: user.id, format: new_post.id}}.to change(Like, :count).by(1)
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb
new file mode 100644
index 000000000..89e503b82
--- /dev/null
+++ b/spec/controllers/photos_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe PhotosController, type: :controller do
+
+end
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
new file mode 100644
index 000000000..7453e5f65
--- /dev/null
+++ b/spec/controllers/posts_controller_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+describe PostsController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ context "when visitor is not signed in" do
+
+ it "posts#create will not create a new Post" do
+ expect{post :create, params: {user_id: user.id, post: attributes_for(:post)}}.to change(Post, :count).by(0)
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ request.cookies[:auth_token] = user.auth_token
+ end
+
+ it "posts#create will create a new Post" do
+ expect{post :create, params: {user_id: user.id, post: attributes_for(:post)}}.to change(Post, :count).by(1)
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
new file mode 100644
index 000000000..c796479fe
--- /dev/null
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -0,0 +1,62 @@
+require 'rails_helper'
+
+describe ProfilesController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ context "when visitor is not signed in" do
+
+ it "profiles#show will not render for visitor" do
+ get :show, params: {user_id: user.id}
+ expect(response).to_not render_template :show
+ end
+
+ it "profiles#edit will not render for visitor" do
+ get :edit, params: {user_id: user.id}
+ expect(response).to_not render_template :edit
+ end
+
+ it "will not update the profile" do
+ put :update, params: {user: attributes_for(:user), profile: attributes_for(:profile, hometown: "Tokyo")}
+ profile.reload
+ expect(profile.hometown).to_not eq("Tokyo")
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ request.cookies[:auth_token] = user.auth_token
+ end
+
+ it "renders the :show template" do
+ get :show, params: {user_id: user.id}
+ expect(response).to render_template :show
+ end
+
+ it "sets right variable for profiles#show" do
+ get :show, params: {user_id: user.id}
+ expect(assigns(:user)).to eq(user)
+ end
+
+ it "renders the :edit template" do
+ get :edit, params: {user: user}
+ expect(response).to render_template :edit
+ end
+
+ it "sets right variable for profiles#edit" do
+ get :edit, params: {user: user}
+ expect(assigns(:profile)).to eq(user.profile)
+ end
+
+ it "can successfully update the profile" do
+ put :update, params: {user: attributes_for(:user), profile: attributes_for(:profile, hometown: "Tokyo")}
+ profile.reload
+ expect(profile.hometown).to eq("Tokyo")
+ 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..1eb6e3522
--- /dev/null
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -0,0 +1,18 @@
+require 'rails_helper'
+
+describe SessionsController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ it "will log in for correct user credentials" do
+ post :create, params: {email: user.email, password: user.password}
+ expect(response).to redirect_to user_timeline_path(user)
+ end
+
+ it "logging in with incorrect credentials redirects to login path" do
+ post :create, params: {email: "incorrect@email.com", password: "incorrect"}
+ expect(response).to redirect_to new_session_path
+ 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..b00b3b311
--- /dev/null
+++ b/spec/controllers/users_controller_spec.rb
@@ -0,0 +1,41 @@
+require 'rails_helper'
+
+describe UsersController do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ context "when visitor is not signed in" do
+
+ it "users#create will create a new User" do
+ expect do
+ post :create, params: {user: attributes_for(:user), profile: attributes_for(:profile, :with_attributes)}
+ end.to change(User, :count).by(1)
+ end
+
+ it "users#show will not render for visitor" do
+ get :show, params: {user_id: user.id}
+ expect(response).to_not render_template :show
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ request.cookies[:auth_token] = user.auth_token
+ end
+
+ it "renders the :show template" do
+ get :show, params: {user_id: user.id}
+ expect(response).to render_template :show
+ end
+
+ it "sets right variable for users#show" do
+ get :show, params: {user_id: user.id}
+ expect(assigns(:user)).to eq(user)
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/factories.rb b/spec/factories.rb
new file mode 100644
index 000000000..57ba1d5a3
--- /dev/null
+++ b/spec/factories.rb
@@ -0,0 +1,78 @@
+FactoryGirl.define do
+ factory :feature do
+
+ end
+ factory :user_park do
+
+ end
+ factory :park do
+
+ end
+ factory :photo do
+
+ end
+ factory :friending do
+
+ end
+
+ factory :user do
+
+ sequence(:email) do |n|
+ "abcde#{n}@abcd.com"
+ end
+
+ password "asdfasdf"
+
+ trait :without_attributes do
+ email nil
+ password nil
+ end
+
+ end
+
+ factory :post do
+
+ body "Randomly generated post content."
+
+ trait :without_attributes do
+ body nil
+ end
+
+ user
+
+ end
+
+ factory :profile do
+
+ trait :with_attributes do
+ first_name "foo"
+ last_name "bar"
+ gender "male"
+ birthdate Date.parse("09/02/1977")
+ hometown "New York, NY"
+ current_residence "Boston, MA"
+ telephone "9383922933"
+ words_to_live_by "No words."
+ about_me "No about."
+ end
+
+ user
+
+ end
+
+ factory :like do
+
+ user
+ post
+
+ end
+
+ factory :comment do
+
+ user
+ post
+ body "This is a comment."
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb
new file mode 100644
index 000000000..5bf40b260
--- /dev/null
+++ b/spec/features/comments_spec.rb
@@ -0,0 +1,34 @@
+require 'rails_helper'
+
+feature 'Comment Features' do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:post){ create(:post) }
+ let(:user){ create(:user, profile: profile, posts: [post]) }
+
+
+ before do
+ sign_in(user)
+ click_link "Timeline"
+ end
+
+ scenario "entering comment on a post creates new comment" do
+ fill_in "Write a comment.", with: "This is a test comment."
+ expect{click_button "Comment"}.to change(Comment, :count).by(1)
+ expect(page).to have_content("Comment created.")
+ expect(page).to have_content("This is a test comment.")
+ end
+
+ scenario "submitting blank comment does not create new comment" do
+ expect{click_button "Comment"}.to change(Comment, :count).by(0)
+ end
+
+ scenario "removing a comment removes the comment" do
+ fill_in "Write a comment.", with: "This is a test comment."
+ click_button "Comment"
+ expect{click_link "Remove Comment"}.to change(Comment, :count).by(-1)
+ expect(page).to have_content("Comment deleted")
+ expect(page).to_not have_content("This is a test comment.")
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/likes_spec.rb b/spec/features/likes_spec.rb
new file mode 100644
index 000000000..e59e1b45f
--- /dev/null
+++ b/spec/features/likes_spec.rb
@@ -0,0 +1,27 @@
+require 'rails_helper'
+
+feature 'Like Features' do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:post){ create(:post) }
+ let(:user){ create(:user, profile: profile, posts: [post]) }
+
+
+ before do
+ sign_in(user)
+ click_link "Timeline"
+ end
+
+ scenario "like a post creates new like" do
+ expect{click_link "Like"}.to change(Like, :count).by(1)
+ expect(page).to have_content("Like added.")
+ expect(page).to have_content("likes this")
+ end
+
+ scenario "unlike a post removes like" do
+ click_link "Like"
+ expect{click_link "Unlike"}.to change(Like, :count).by(-1)
+ expect(page).to have_content("Unliked")
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/posts_spec.rb b/spec/features/posts_spec.rb
new file mode 100644
index 000000000..d915c7e81
--- /dev/null
+++ b/spec/features/posts_spec.rb
@@ -0,0 +1,32 @@
+require 'rails_helper'
+
+feature 'Post Features' do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ before do
+ sign_in(user)
+ visit user_timeline_path(user)
+ end
+
+ scenario "submitting a new post creates a post" do
+ fill_in "Tell the world something", with: "This is a test post."
+ expect{click_button "Submit"}.to change(Post, :count).by(1)
+ expect(page).to have_content("Post created")
+ expect(page).to have_content("This is a test post.")
+ end
+
+ scenario "submitting blank post does not create new post" do
+ expect{click_button "Submit"}.to change(Post, :count).by(0)
+ end
+
+ scenario "deleting a post removes the post" do
+ fill_in "Tell the world something", with: "This is a test post."
+ click_button "Submit"
+ expect{click_link "Delete"}.to change(Post, :count).by(-1)
+ expect(page).to have_content("Post deleted")
+ expect(page).to_not have_content("This is a test post.")
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/profiles_spec.rb b/spec/features/profiles_spec.rb
new file mode 100644
index 000000000..cc779098b
--- /dev/null
+++ b/spec/features/profiles_spec.rb
@@ -0,0 +1,42 @@
+require 'rails_helper'
+
+feature 'Profile Features' do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ before {sign_in(user)}
+
+ scenario "clicking on 'About' accesses user profile" do
+ click_link("About")
+ expect(page).to have_content("Basic Information")
+ end
+
+ context 'Using Edit' do
+
+ before do
+ click_link("Update Profile")
+ end
+
+ scenario "clicking on 'Update Profile' gets to 'Edit Profile' page" do
+ expect(page).to have_content("Edit Profile")
+ end
+
+ scenario "Edit changes show up on profile page" do
+ fill_in "profile[first_name]", with: "Test_Name"
+ click_button "Save Changes"
+ expect(page).to_not have_content("foo")
+ expect(page).to have_content("Test_Name")
+ end
+
+ scenario "Entering invalid changes does not update to invalid changes" do
+ new_name = "i" * 50
+ fill_in "profile[first_name]", with: new_name
+ click_button "Save Changes"
+ expect(page).to_not have_content(new_name)
+ expect(page).to have_content("foo")
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
new file mode 100644
index 000000000..42a146dce
--- /dev/null
+++ b/spec/features/users_spec.rb
@@ -0,0 +1,54 @@
+require 'rails_helper'
+
+feature 'User Features' do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ before do
+ visit root_path
+ end
+
+ scenario "add a new user" do
+ fill_in "First Name", with: "Montgomery"
+ fill_in "Last Name", with: "Burns"
+ find(".new-account").fill_in "Email", with: "montyburns@gmail.com"
+ fill_in "Your New Password", with: "moneymoney"
+ fill_in "Confirm Your Password", with: "moneymoney"
+
+ expect{ click_button "Sign Up!" }.to change(User, :count).by(1)
+ expect(page).to have_content "User created."
+ expect(page).to have_content "montyburns@gmail.com"
+ end
+
+ scenario "sign in to my account" do
+ find("#navbar").fill_in "Email", with: user.email
+ find("#navbar").fill_in "Password", with: user.password
+ click_button("Log In")
+ expect(page).to have_content "signed in"
+ expect(page).to have_content user.email
+ end
+
+ scenario "log out of my account" do
+ sign_in(user)
+ sign_out
+ expect(page).to have_content "signed out"
+ end
+
+ scenario "signing up with no attributes results in no entry" do
+ click_button "Sign Up!"
+ expect(page).to have_content "Connect with all your friends!"
+ expect(page).to have_css ".error"
+ end
+
+ scenario "signing up with invalid attributes doesn't add user" do
+ expect{ click_button "Sign Up!" }.to change(User, :count).by(0)
+ end
+
+ scenario "logging in with no attributes results in no entry" do
+ click_button "Log In"
+ expect(page).to have_content "Login"
+ expect(page).to have_content "don't match"
+ end
+
+end
\ No newline at end of file
diff --git a/spec/helpers/features_helper_spec.rb b/spec/helpers/features_helper_spec.rb
new file mode 100644
index 000000000..8a9ad795e
--- /dev/null
+++ b/spec/helpers/features_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the FeaturesHelper. For example:
+#
+# describe FeaturesHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe FeaturesHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb
new file mode 100644
index 000000000..6b5aa7d30
--- /dev/null
+++ b/spec/helpers/photos_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the PhotosHelper. For example:
+#
+# describe PhotosHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe PhotosHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb
new file mode 100644
index 000000000..957e12b64
--- /dev/null
+++ b/spec/mailers/previews/user_mailer_preview.rb
@@ -0,0 +1,4 @@
+# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
+class UserMailerPreview < ActionMailer::Preview
+
+end
diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb
new file mode 100644
index 000000000..c48d3adee
--- /dev/null
+++ b/spec/mailers/user_mailer_spec.rb
@@ -0,0 +1,5 @@
+require "rails_helper"
+
+RSpec.describe UserMailerMailer, type: :mailer do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
new file mode 100644
index 000000000..992e20443
--- /dev/null
+++ b/spec/models/comment_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+describe Comment do
+
+ let(:comment){ build(:comment) }
+
+ it "is valid with default attributes" do
+ expect(comment).to be_valid
+ end
+
+ it "checks for body presence" do
+ should validate_presence_of(:body)
+ end
+
+ #Associations
+ it { should belong_to(:user) }
+ it { should belong_to(:post) }
+
+end
\ No newline at end of file
diff --git a/spec/models/feature_spec.rb b/spec/models/feature_spec.rb
new file mode 100644
index 000000000..93ddfe904
--- /dev/null
+++ b/spec/models/feature_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Feature, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb
new file mode 100644
index 000000000..bc31128bd
--- /dev/null
+++ b/spec/models/like_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+describe Like do
+
+ let(:like){ build(:like) }
+
+ it "is valid with default attributes" do
+ expect(like).to be_valid
+ end
+
+ it "has uniqueness of user_id in conjunction with post_id" do
+ should validate_uniqueness_of(:user_id).scoped_to(:post_id)
+ end
+
+ #Associations
+ it { should belong_to(:user) }
+ it { should belong_to(:post) }
+
+end
\ No newline at end of file
diff --git a/spec/models/park_spec.rb b/spec/models/park_spec.rb
new file mode 100644
index 000000000..8bd92351c
--- /dev/null
+++ b/spec/models/park_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Park, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb
new file mode 100644
index 000000000..568cabbc1
--- /dev/null
+++ b/spec/models/photo_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Photo, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
new file mode 100644
index 000000000..854bb36be
--- /dev/null
+++ b/spec/models/post_spec.rb
@@ -0,0 +1,24 @@
+require 'rails_helper'
+
+describe Post do
+
+ let(:post) { build(:post) }
+
+ it "is valid with default attributes" do
+ expect(post).to be_valid
+ end
+
+ it "is invalid without default attributes" do
+ new_post = build(:post, :without_attributes)
+ expect(new_post).to_not be_valid
+ end
+
+ it "checks for body presence" do
+ should validate_presence_of(:body)
+ end
+
+ #Associations
+ it { should have_many(:likes) }
+ it { should have_many(:comments) }
+
+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..47636abb0
--- /dev/null
+++ b/spec/models/profile_spec.rb
@@ -0,0 +1,32 @@
+require 'rails_helper'
+
+describe Profile do
+
+ let(:profile){ build(:profile, :with_attributes) }
+
+ it "is valid with default attributes" do
+ expect(profile).to be_valid
+ end
+
+ it "is invalid without default attributes" do
+ new_profile = build_stubbed(:profile)
+ expect(new_profile).to_not be_valid
+ end
+
+ it "has first_name between 2 and 40 characters" do
+ should validate_length_of(:first_name).is_at_least(2).is_at_most(40)
+ end
+
+ it "has last_name between 2 and 40 characters" do
+ should validate_length_of(:last_name).is_at_least(2).is_at_most(40)
+ end
+
+ it "responds to user association" do
+ expect(profile).to respond_to(:user)
+ end
+
+ it "checks the method name to create the profile full name" do
+ expect(name).to eq("foo bar")
+ end
+
+end
\ No newline at end of file
diff --git a/spec/models/user_park_spec.rb b/spec/models/user_park_spec.rb
new file mode 100644
index 000000000..9ba37c0dd
--- /dev/null
+++ b/spec/models/user_park_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe UserPark, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
new file mode 100644
index 000000000..b5770fad1
--- /dev/null
+++ b/spec/models/user_spec.rb
@@ -0,0 +1,58 @@
+require 'rails_helper'
+
+describe User do
+
+ let(:user){ create(:user) }
+
+ it "is valid with default attributes" do
+ expect(user).to be_valid
+ end
+
+ it "is invalid with no attributes" do
+ new_user = build(:user, :without_attributes)
+ expect(new_user).to_not be_valid
+ end
+
+ it "has a secure password" do
+ is_expected.to have_secure_password
+ end
+
+ it "has password between 8 and 24 characters" do
+ should validate_length_of(:password).is_at_least(8).is_at_most(24)
+ end
+
+ it "has email uniqueness" do
+ should validate_uniqueness_of(:email)
+ end
+
+ it "responds to profile association" do
+ expect(user).to respond_to(:profile)
+ end
+
+ it "responds to posts association" do
+ expect(user).to respond_to(:posts)
+ end
+
+ it "responds to likes association" do
+ expect(user).to respond_to(:likes)
+ end
+
+ it "responds to comments association" do
+ expect(user).to respond_to(:comments)
+ end
+
+ it "checks to make sure regenerate_auth_token creates new token" do
+ old_token = user.auth_token
+ user.regenerate_auth_token
+ expect(old_token).to_not eq(user.auth_token)
+ end
+
+ it "runs the find_like method and receives correct output" do
+ like = create(:like)
+ post = create(:post)
+ like.post = post
+ user.likes << like
+ expect(user.find_like(post).first).to eq(like)
+ 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..000b2c3ba
--- /dev/null
+++ b/spec/rails_helper.rb
@@ -0,0 +1,71 @@
+# 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'
+# Add additional requires below this line. Rails is not loaded until this point!
+
+Shoulda::Matchers.configure do |config|
+ config.integrate do |with|
+ # Choose a test framework:
+ with.test_framework :rspec
+ # Choose one or more libraries:
+ with.library :rails
+ end
+end
+# 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 }
+
+RSpec.configure do |config|
+ config.include LoginMacros
+end
+# 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"
+ config.include FactoryGirl::Syntax::Methods
+
+ # 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")
+end
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/login_macros.rb b/spec/support/login_macros.rb
new file mode 100644
index 000000000..e3025cf47
--- /dev/null
+++ b/spec/support/login_macros.rb
@@ -0,0 +1,13 @@
+module LoginMacros
+ def sign_in(user)
+ visit root_path
+ find("#navbar").fill_in "Email", with: user.email
+ find("#navbar").fill_in "Password", with: user.password
+ click_button("Log In")
+ end
+
+ def sign_out
+ visit root_path
+ click_link("Logout")
+ end
+end
\ No newline at end of file
diff --git a/spec/views/layouts/application.rb b/spec/views/layouts/application.rb
new file mode 100644
index 000000000..8da6f9b00
--- /dev/null
+++ b/spec/views/layouts/application.rb
@@ -0,0 +1,23 @@
+require 'rails_helper'
+
+describe "layouts/application" do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ context "when a user is logged in" do
+
+ before do
+
+ @profile = profile
+ @user = user
+
+ def view.signed_in_user?
+ true
+ end
+ def view.current_user
+ @user
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/views/profiles/show_spec.rb b/spec/views/profiles/show_spec.rb
new file mode 100644
index 000000000..2baf3b18d
--- /dev/null
+++ b/spec/views/profiles/show_spec.rb
@@ -0,0 +1,32 @@
+require 'rails_helper'
+
+describe "profiles/show.html.erb" do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ before do
+ @profile = profile
+ @user = user
+ end
+
+ context "when user is signed in" do
+
+ before do
+ def view.signed_in_user?
+ true
+ end
+
+ def view.current_user
+ @user
+ end
+ end
+
+ it "shows the first name of profile" do
+ render
+ expect(rendered).to have_content(@first_name)
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/spec/views/users/index_spec.rb b/spec/views/users/index_spec.rb
new file mode 100644
index 000000000..12de2e073
--- /dev/null
+++ b/spec/views/users/index_spec.rb
@@ -0,0 +1,46 @@
+require 'rails_helper'
+
+describe "users/index.html.erb" do
+
+ let(:profile){ create(:profile, :with_attributes ) }
+ let(:user){ create(:user, :profile => profile) }
+
+ before do
+ assign(:profile, profile)
+ assign(:user, user)
+ end
+
+ context "when visitor is not signed in" do
+
+ before do
+ def view.signed_in_user?
+ false
+ end
+ end
+
+ it "will show login" do
+ render :template => 'users/index', :layout => 'layouts/application'
+ expect(rendered).to match(/Log In/)
+ end
+
+ end
+
+ context "when user is signed in" do
+
+ before do
+ def view.signed_in_user?
+ true
+ end
+
+ def view.current_user
+ @user
+ end
+ end
+
+ it "shows the logout link" do
+ render :template => 'users/index', :layout => 'layouts/application'
+ expect(rendered).to match(/Logout/)
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/test/controllers/.keep b/test/controllers/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/controllers/comments_controller_test.rb b/test/controllers/comments_controller_test.rb
new file mode 100644
index 000000000..a812ddae9
--- /dev/null
+++ b/test/controllers/comments_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/likes_controller_test.rb b/test/controllers/likes_controller_test.rb
new file mode 100644
index 000000000..78e007545
--- /dev/null
+++ b/test/controllers/likes_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LikesControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/posts_controller_test.rb b/test/controllers/posts_controller_test.rb
new file mode 100644
index 000000000..12c4a7fd0
--- /dev/null
+++ b/test/controllers/posts_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PostsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/profiles_controller_test.rb b/test/controllers/profiles_controller_test.rb
new file mode 100644
index 000000000..6c8c33d28
--- /dev/null
+++ b/test/controllers/profiles_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ProfilesControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 000000000..6135ce6af
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb
new file mode 100644
index 000000000..76b4b38eb
--- /dev/null
+++ b/test/controllers/static_pages_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class StaticPagesControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
new file mode 100644
index 000000000..6c3da770c
--- /dev/null
+++ b/test/controllers/users_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/fixtures/.keep b/test/fixtures/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml
new file mode 100644
index 000000000..80aed36e3
--- /dev/null
+++ b/test/fixtures/comments.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/fixtures/likes.yml b/test/fixtures/likes.yml
new file mode 100644
index 000000000..80aed36e3
--- /dev/null
+++ b/test/fixtures/likes.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml
new file mode 100644
index 000000000..80aed36e3
--- /dev/null
+++ b/test/fixtures/posts.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml
new file mode 100644
index 000000000..80aed36e3
--- /dev/null
+++ b/test/fixtures/profiles.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 000000000..80aed36e3
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/models/comment_test.rb b/test/models/comment_test.rb
new file mode 100644
index 000000000..b6d6131a9
--- /dev/null
+++ b/test/models/comment_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/like_test.rb b/test/models/like_test.rb
new file mode 100644
index 000000000..1eea9915b
--- /dev/null
+++ b/test/models/like_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LikeTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/post_test.rb b/test/models/post_test.rb
new file mode 100644
index 000000000..6d9d463a7
--- /dev/null
+++ b/test/models/post_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PostTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/profile_test.rb b/test/models/profile_test.rb
new file mode 100644
index 000000000..3dfa94302
--- /dev/null
+++ b/test/models/profile_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ProfileTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 000000000..82f61e010
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 000000000..92e39b2d7
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,10 @@
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/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
<%= comment.user.name %> said on <%= comment.created_at.strftime("%m/%d/%Y") %>
+<%= comment.body %>
+ <% if current_user == comment.user %> + <%= link_to "Remove Comment", user_comment_path(current_user, comment), method: :delete, class: "poster2" %> + <% end %> +