diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..10f5eb295 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history + +# Ignore application configuration +/config/application.yml diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..7e3eb5c7c --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format doc diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..f61d162c4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,72 @@ +source 'https://rubygems.org' + + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.0.0' +# Use postgresql as the database for Active Record +gem 'pg', '~> 0.18' +# Use Puma as the app server +gem 'puma', '~> 3.0' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby +gem 'pry-byebug' + +gem 'delayed_job_active_record' +# Use jquery as the JavaScript library +gem 'jquery-rails' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 3.0' +# Use ActiveModel has_secure_password +gem 'bcrypt', '~> 3.1.7' +gem 'paperclip' +gem 'aws-sdk' +gem 'figaro' +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platform: :mri +end + +group :development do + # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. + gem 'web-console' + gem 'listen', '~> 3.0.5' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'better_errors' + gem 'binding_of_caller' + gem 'hirb' + gem 'letter_opener' +end + +group :development, :test do + gem 'factory_girl_rails', '~> 4.0' + gem 'shoulda-matchers' + gem 'rspec-rails' + gem 'rails-controller-testing' +end + +group :test do + gem 'capybara' + gem 'launchy' +end + +group :production do + gem 'rails_12factor' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..4ed307fef --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,282 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.0.0.1) + actionpack (= 5.0.0.1) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.0.1) + actionpack (= 5.0.0.1) + actionview (= 5.0.0.1) + activejob (= 5.0.0.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.0.1) + actionview (= 5.0.0.1) + activesupport (= 5.0.0.1) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.0.1) + activesupport (= 5.0.0.1) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (5.0.0.1) + activesupport (= 5.0.0.1) + globalid (>= 0.3.6) + activemodel (5.0.0.1) + activesupport (= 5.0.0.1) + activerecord (5.0.0.1) + activemodel (= 5.0.0.1) + activesupport (= 5.0.0.1) + arel (~> 7.0) + activesupport (5.0.0.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.4.0) + arel (7.1.1) + aws-sdk (2.5.5) + aws-sdk-resources (= 2.5.5) + aws-sdk-core (2.5.5) + jmespath (~> 1.0) + aws-sdk-resources (2.5.5) + aws-sdk-core (= 2.5.5) + bcrypt (3.1.11) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + builder (3.2.2) + byebug (9.0.5) + capybara (2.8.0) + addressable + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.8) + climate_control (>= 0.0.3, < 1.0) + coderay (1.1.1) + coffee-rails (4.2.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.2.x) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.10.0) + concurrent-ruby (1.0.2) + debug_inspector (0.0.2) + delayed_job (4.1.2) + activesupport (>= 3.0, < 5.1) + delayed_job_active_record (4.1.1) + activerecord (>= 3.0, < 5.1) + delayed_job (>= 3.0, < 5) + diff-lcs (1.2.5) + erubis (2.7.0) + execjs (2.7.0) + factory_girl (4.7.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.7.0) + factory_girl (~> 4.7.0) + railties (>= 3.0.0) + ffi (1.9.14) + figaro (1.1.1) + thor (~> 0.14) + globalid (0.3.7) + activesupport (>= 4.1.0) + hirb (0.7.3) + i18n (0.7.0) + jbuilder (2.6.0) + activesupport (>= 3.0.0, < 5.1) + multi_json (~> 1.2) + jmespath (1.3.1) + jquery-rails (4.2.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + launchy (2.4.3) + addressable (~> 2.3) + letter_opener (1.4.1) + launchy (~> 2.2) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mimemagic (0.3.2) + mini_portile2 (2.1.0) + minitest (5.9.0) + multi_json (1.12.1) + nio4r (1.2.1) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) + paperclip (5.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) + cocaine (~> 0.5.5) + mime-types + mimemagic (~> 0.3.0) + pg (0.18.4) + pkg-config (1.1.7) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.0) + byebug (~> 9.0) + pry (~> 0.10) + puma (3.6.0) + rack (2.0.1) + rack-test (0.6.3) + rack (>= 1.0) + rails (5.0.0.1) + actioncable (= 5.0.0.1) + actionmailer (= 5.0.0.1) + actionpack (= 5.0.0.1) + actionview (= 5.0.0.1) + activejob (= 5.0.0.1) + activemodel (= 5.0.0.1) + activerecord (= 5.0.0.1) + activesupport (= 5.0.0.1) + bundler (>= 1.3.0, < 2.0) + railties (= 5.0.0.1) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) + rails-dom-testing (2.0.1) + activesupport (>= 4.2.0, < 6.0) + nokogiri (~> 1.6.0) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) + railties (5.0.0.1) + actionpack (= 5.0.0.1) + activesupport (= 5.0.0.1) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (11.2.2) + rb-fsevent (0.9.7) + rb-inotify (0.9.7) + ffi (>= 0.5.0) + rspec-core (3.5.2) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-rails (3.5.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + sass (3.4.22) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + shoulda-matchers (3.1.1) + activesupport (>= 4.0.0) + slop (3.6.0) + spring (1.7.2) + spring-watcher-listen (2.0.0) + listen (>= 2.7, < 4.0) + spring (~> 1.2) + sprockets (3.7.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.1.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.5) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (3.0.2) + execjs (>= 0.3.0, < 3) + web-console (3.3.1) + actionview (>= 5.0) + activemodel (>= 5.0) + debug_inspector + railties (>= 5.0) + websocket-driver (0.6.4) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + aws-sdk + bcrypt (~> 3.1.7) + better_errors + binding_of_caller + byebug + capybara + coffee-rails (~> 4.2) + delayed_job_active_record + factory_girl_rails (~> 4.0) + figaro + hirb + jbuilder (~> 2.5) + jquery-rails + launchy + letter_opener + listen (~> 3.0.5) + paperclip + pg (~> 0.18) + pry-byebug + puma (~> 3.0) + rails (~> 5.0.0) + rails-controller-testing + rails_12factor + rspec-rails + sass-rails (~> 5.0) + shoulda-matchers + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console + +BUNDLED WITH + 1.12.5 diff --git a/README.md b/README.md index 24602872a..1397e4823 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,21 @@ -danebook -======== +# Danebook -This is the Real Dane Deal. +![Home Page](screenshot.png "Home page") + +Check it out [here!](https://mikedanebook.herokuapp.com) + +## Overview + +Danebook is a social networking platform built with full functionality. Users are able to create posts, like and comment on posts, upload photos, and friend other users. + +### Features + +Users can: +* Write posts and upload photos +* Comment on posts from other users +* Friend other users +* Keep track of recent activity + +## Developer + +Created by [Mike Lee](https://github.com/asackofwheat) \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..e85f91391 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..b16e53d6d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/images/danish_flag.gif b/app/assets/images/danish_flag.gif new file mode 100644 index 000000000..132d8cff8 Binary files /dev/null and b/app/assets/images/danish_flag.gif differ diff --git a/app/assets/images/flag.png b/app/assets/images/flag.png new file mode 100644 index 000000000..96b4c60dd Binary files /dev/null and b/app/assets/images/flag.png differ diff --git a/app/assets/images/harry_potter_small.jpg b/app/assets/images/harry_potter_small.jpg new file mode 100644 index 000000000..3d660d77d Binary files /dev/null and b/app/assets/images/harry_potter_small.jpg differ diff --git a/app/assets/images/hogwarts_small.jpg b/app/assets/images/hogwarts_small.jpg new file mode 100644 index 000000000..94a8abeff Binary files /dev/null and b/app/assets/images/hogwarts_small.jpg differ diff --git a/app/assets/images/user_silhouette_generic.gif b/app/assets/images/user_silhouette_generic.gif new file mode 100644 index 000000000..e52535f55 Binary files /dev/null and b/app/assets/images/user_silhouette_generic.gif differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..b12018d09 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 000000000..71ee1e66d --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the rails generate channel command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/comments.coffee b/app/assets/javascripts/comments.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/comments.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/features.coffee b/app/assets/javascripts/features.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/features.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/friendings.coffee b/app/assets/javascripts/friendings.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/friendings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/likes.coffee b/app/assets/javascripts/likes.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/likes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/photos.coffee b/app/assets/javascripts/photos.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/photos.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/posts.coffee b/app/assets/javascripts/posts.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/posts.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/profiles.coffee b/app/assets/javascripts/profiles.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/profiles.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/sessions.coffee b/app/assets/javascripts/sessions.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/sessions.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/static_pages.coffee b/app/assets/javascripts/static_pages.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/static_pages.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/users.coffee b/app/assets/javascripts/users.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/users.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 000000000..0ebd7fe82 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/assets/stylesheets/comments.scss b/app/assets/stylesheets/comments.scss new file mode 100644 index 000000000..3722c124e --- /dev/null +++ b/app/assets/stylesheets/comments.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/features.scss b/app/assets/stylesheets/features.scss new file mode 100644 index 000000000..6c091d968 --- /dev/null +++ b/app/assets/stylesheets/features.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the features controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/friendings.scss b/app/assets/stylesheets/friendings.scss new file mode 100644 index 000000000..25e6461f0 --- /dev/null +++ b/app/assets/stylesheets/friendings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the friendings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/likes.scss b/app/assets/stylesheets/likes.scss new file mode 100644 index 000000000..1f08d329f --- /dev/null +++ b/app/assets/stylesheets/likes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the likes controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/photos.scss new file mode 100644 index 000000000..1a3e082cd --- /dev/null +++ b/app/assets/stylesheets/photos.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the photos controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/posts.scss b/app/assets/stylesheets/posts.scss new file mode 100644 index 000000000..1a7e15390 --- /dev/null +++ b/app/assets/stylesheets/posts.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the posts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/profiles.scss b/app/assets/stylesheets/profiles.scss new file mode 100644 index 000000000..287733f3e --- /dev/null +++ b/app/assets/stylesheets/profiles.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the profiles controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 000000000..7bef9cf82 --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/static_pages.scss b/app/assets/stylesheets/static_pages.scss new file mode 100644 index 000000000..8172ca847 --- /dev/null +++ b/app/assets/stylesheets/static_pages.scss @@ -0,0 +1,288 @@ +// Place all the styles related to the static_pages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +main { + margin-top: 100px; +} + +.navbar-brand{ + font-size: 48px; + color: white; +} + +.navbar { + background-color: #2B78E4; +} + +.welcome { + margin-top: 70px; +} + +li { + margin: 20px; +} + +.form { + margin-bottom: 10px; +} + +.sign-up { + margin-top: 5px; +} + +#topnav{ + + .logo-container{ + img{ + width: 40px; + height: 40px; + margin-top: 4px; + margin-right: 10px; + vertical-align: middle; + } + + a{ + color: white; + font-size: 28px; + } + } + + .search-container{ + margin-top: 8px; + } + + .name-container{ + font-size: 16px; + margin-top: 14px; + .pull-right{ + a{ + color: black; + } + } + } + +} + +.poster-pic2{ + margin: 3px -6px; + width: 60px; + height: 60px; +} + +.main-header{ + img{ + width: 100%; + height: 350px; + border: solid black 1px; + } + .profile{ + position: absolute; + top: 210px; + left: 0; + width: 130px; + height: 130px; + } + .title-name{ + position: absolute; + font-size: 24px; + color: white; + top: 290px; + left: 138px; + } +} + +.nav-link-row{ + border: solid black 1px; + + .nav-links{ + border: solid black 1px; + p{ + text-align: center; + margin-top: 10px; + } + } +} + +.content{ + margin-top: 10px; + border: solid black 1px; + .title-header{ + border: solid black 1px; + background-color: #ccc; + } + .title{ + text-align: center; + font-size: 28px; + margin-top: 6px; + } + .edit-button{ + margin-top: 13px; + margin-left: 186px; + } + + h1{ + font-size:24px; + } + .data-points{ + margin-left: 36px; + } + .content-space{ + border: solid black 1px; + } + input{ + margin-top: 1px; + width: 190px; + } + .save-button{ + margin-top: 46px; + margin-bottom: 120px; + width: 400px; + margin-left: 282px; + } + .friend-row{ + border: solid black 1px; + margin: 10px 1px; + } + .friend-profile{ + width: 100px; + height:100px; + margin: 8px -6px; + } + .friend-name{ + font-size: 16px; + } + .unfriend-button{ + border: solid black 1px; + margin-top: 40px; + margin-left: 20px; + } + .photo-preview{ + margin: 5px; + } +} + +.tl-content{ + margin-top: 10px; + .tl-about{ + background-color: #ccc; + border-top: solid black 1px; + border-left: solid black 1px; + border-right: solid black 1px; + p{ + text-align: center; + margin-bottom: 3px; + } + } + .section-about{ + border: solid black 1px; + .col-xs-12{ + margin-top: 10px; + } + .ph-preview{ + margin: 5px; + width: 96px; + height: 96px; + } + } + .post-title{ + margin-left: 10px; + width: 555px; + .tl-posts{ + background-color: #ccc; + border-top: solid black 1px; + border-left: solid black 1px; + border-right: solid black 1px; + p{ + text-align: center; + margin-bottom: 3px; + } + } + .section-posts{ + border: solid black 1px; + .col-xs-12{ + margin-top: 10px; + } + } + .section-submit{ + background-color: #ccc; + border-bottom: solid black 1px; + border-left: solid black 1px; + border-right: solid black 1px; + .submit-button{ + margin: 6px 470px; + } + } + .old-post{ + margin-top: 10px; + border-top: solid black 1px; + border-right: solid black 1px; + border-left: solid black 1px; + } + .poster-pic{ + margin: 3px -10px; + width: 50px; + height: 50px; + } + .post-content{ + padding-top: 10px; + border-left: solid black 1px; + border-right: solid black 1px; + } + .post-comment{ + border: solid black 1px; + background-color: #ccc; + } + .post-comment2{ + border-top: solid black 1px; + border-right: solid black 1px; + border-left: solid black 1px; + background-color: #ccc; + } + .post-like{ + padding-top: 10px; + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + border-bottom: solid black 1px; + } + .post-like2{ + padding-top: 10px; + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + border-bottom: solid gray 1px; + } + .poster-pic2{ + margin: 3px -6px; + width: 50px; + height: 50px; + } + .poster2{ + margin-left: 12px; + } + .comment-post{ + padding-top: 10px; + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + } + .comment-like{ + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + } + .comment-next{ + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + } + .next-submit{ + background-color: #ccc; + border-right: solid black 1px; + border-left: solid black 1px; + border-bottom: solid black 1px; + padding-bottom: 20px; + } + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 000000000..1efc835cc --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 000000000..0ff5442f4 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 000000000..fcd8aa1d4 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,54 @@ +class ApplicationController < ActionController::Base + protect_from_forgery with: :exception + + before_action :require_login + + private + + def sign_in(user) + user.regenerate_auth_token + cookies[:auth_token] = user.auth_token + @current_user = user + end + + def permanent_sign_in(user) + user.regenerate_auth_token + cookies.permanent[:auth_token] = user.auth_token + @current_user = user + end + + def sign_out + @current_user = nil + cookies.delete(:auth_token) + end + + def current_user + @current_user ||= User.find_by_auth_token(cookies[:auth_token]) if cookies[:auth_token] + end + helper_method :current_user + + def signed_in_user? + !!current_user + end + helper_method :signed_in_user? + + def full_name(user) + "#{user.first_name} #{user.last_name}" + end + helper_method :full_name + + def require_login + unless signed_in_user? + flash.notice = "Not authorized, please sign in!" + redirect_to login_path + end + end + + def require_current_user + unless params[:user_id].to_i == current_user.id + flash[:error] = "You're not authorized to perform that action." + redirect_to user_path(current_user) + end + end + +end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 000000000..dc30e6807 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,45 @@ +class CommentsController < ApplicationController + + def create + @comment = current_user.comments.build(comment_params) + if @comment.save + @user = @comment.commentable.user + Comment.delay(run_at: 5.seconds.from_now).send_notification(@user.id, @comment.id) + flash.notice = "Comment created." + respond_to do |format| + format.html {redirect_back(fallback_location: current_user)} + format.js + end + else + flash.notice = "Error. Comment not created." + respond_to do |format| + format.html {redirect_back(fallback_location: current_user)} + format.js {redirect_back(fallback_location: current_user)} + end + end + end + + def destroy + @comment = current_user.comments.find(params[:id]) + if @comment.destroy + flash.notice = "Comment deleted." + respond_to do |format| + format.html {redirect_back(fallback_location: current_user)} + format.js + end + else + flash.notice = "Error. Comment not deleted." + respond_to do |format| + format.html {redirect_back(fallback_location: current_user)} + format.js + end + end + end + + private + + def comment_params + params.require(:comment).permit(:body, :commentable_id, :commentable_type) + end + +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/friendings_controller.rb b/app/controllers/friendings_controller.rb new file mode 100644 index 000000000..8568c25de --- /dev/null +++ b/app/controllers/friendings_controller.rb @@ -0,0 +1,25 @@ +class FriendingsController < ApplicationController + + def create + new_friend = User.find(params[:format]) + if current_user.friendeds << new_friend + flash.notice = "Successfully friended #{new_friend.name}" + redirect_back(fallback_location: current_user) + else + flash.notice = "Failed to friend! Sad :(" + redirect_back(fallback_location: current_user) + end + end + + def destroy + unfriend = User.find(params[:id]) + current_user.friendeds.delete(unfriend) + flash.notice = "Successfully unfriended" + redirect_back(fallback_location: current_user) + end + + def show + @user = User.find(params[:id]) + end + +end \ No newline at end of file diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb new file mode 100644 index 000000000..466138c3c --- /dev/null +++ b/app/controllers/likes_controller.rb @@ -0,0 +1,32 @@ +class LikesController < ApplicationController + + def create + @user = current_user + @like = @user.likes.build(likeable_id: param_type_id, likeable_type: params[:likeable]) + if @like.save + flash.notice = "Like added." + redirect_back(fallback_location: current_user) + else + flash.notice = "Error. You've already liked this post." + redirect_back(fallback_location: current_user) + end + end + + def destroy + @like = Like.find(param_type_id) + if @like.destroy + flash.notice = "Unliked." + redirect_back(fallback_location: current_user) + else + flash.notice = "Error. Still liking post." + redirect_back(fallback_location: current_user) + end + end + + private + + def param_type_id + params[:post_id] || params[:photo_id] + end + +end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb new file mode 100644 index 000000000..9c40238fc --- /dev/null +++ b/app/controllers/photos_controller.rb @@ -0,0 +1,45 @@ +class PhotosController < ApplicationController + + def index + @user = User.find(params[:user_id]) + end + + def new + @user = User.find(params[:user_id]) + @photo = Photo.new + end + + def create + @photo = current_user.photos.build(photo_params) + if @photo.save + flash.notice = "Photo saved." + redirect_to user_photos_path(current_user) + else + flash.notice = "Photo not saved." + redirect_back(fallback_location: current_user) + end + end + + def destroy + @profile = current_user.profile + @profile.profile_photo_id = nil if @profile.profile_photo_id == params[:id].to_i + @profile.cover_id = nil if @profile.cover_id == params[:id].to_i + @profile.save + @photo = Photo.find(params[:id]) + @photo.destroy + redirect_to user_photos_path(current_user) + end + + def show + @user = User.find(params[:user_id]) + @photo = Photo.find(params[:id]) + @comment = Comment.new + end + + private + + def photo_params + params.require(:photo).permit(:image) + end + +end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb new file mode 100644 index 000000000..2d87be403 --- /dev/null +++ b/app/controllers/posts_controller.rb @@ -0,0 +1,53 @@ +class PostsController < ApplicationController + + def create + @user = current_user + @post = @user.posts.build(post_params) + if @user.save + flash.notice = "Post created." + respond_to do |format| + format.html { redirect_back(fallback_location: current_user) } + format.js + end + else + flash.notice = "Error. Post not created." + respond_to do |format| + format.html { redirect_back(fallback_location: current_user) } + format.js + end + end + end + + def destroy + @user = current_user + @post = @user.posts.find(params[:id]) + if @post.destroy + flash.notice = "Post deleted." + respond_to do |format| + format.html {redirect_to user_path(@user)} + format.js + end + else + flash.notice = "Error. Post not deleted." + respond_to do |format| + format.html {redirect_to user_path(@user)} + format.js + end + end + end + + def cfield + @post = Post.find(params[:post_id]) + respond_to do |format| + format.html {} + format.js + end + end + + private + + def post_params + params.require(:post).permit(:body) + end + +end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb new file mode 100644 index 000000000..10787a044 --- /dev/null +++ b/app/controllers/profiles_controller.rb @@ -0,0 +1,55 @@ +class ProfilesController < ApplicationController + + + # before_action :require_current_user, :only => [:update] + + def show + @user = User.find(params[:user_id]) + @profile = @user.profile + end + + def edit + @user = current_user + @profile = current_user.profile + end + + def update + @user = current_user + @profile = current_user.profile + @user.update(user_params) + @profile.update(profile_params) + redirect_to user_profile_path(@user) + end + + def photo + current_user.profile.profile_photo_id = params[:format].to_i + current_user.profile.save + redirect_to user_path(current_user) + end + + def cover + current_user.profile.cover_id = params[:format].to_i + current_user.profile.save + redirect_to user_path(current_user) + end + + def search + @user = current_user + @users = User.search(query_params[:query]) + end + + private + + def profile_params + params.require(:profile).permit(:birthdate, :hometown, :current_residence, :telephone, :words_to_live_by, :about_me) + end + + def user_params + params.require(:user).permit(:email, :gender, :first_name, :last_name) + end + + def query_params + params.permit(query: [:first_name, :last_name]) + end + +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..c2c8d21be --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,26 @@ +class SessionsController < ApplicationController + + skip_before_action :require_login, :only => [:create, :new, :destroy] + + def new + end + + def create + @user = User.find_by_email(params[:email]) + if @user && @user.authenticate(params[:password]) + sign_in(@user) + flash.notice = "You've signed in." + redirect_to user_newsfeed_path(@user) + else + flash.notice = "The email and password you entered don't match. Please try again." + redirect_to new_session_path + end + end + + def destroy + sign_out + flash.notice = "You've signed out." + redirect_to root_url + end + +end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb new file mode 100644 index 000000000..c5ca6b19f --- /dev/null +++ b/app/controllers/static_pages_controller.rb @@ -0,0 +1,12 @@ +class StaticPagesController < ApplicationController + + def index + end + + def show + end + + def new + end + +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 000000000..ea4e7bd5b --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,55 @@ +class UsersController < ApplicationController + + skip_before_action :require_login, :only => [:index, :new, :create] + + before_action :require_current_user, :only => [:newsfeed] + + def index + end + + def new + @user = User.new + end + + def create + @user = User.new(user_params) + @user.build_profile + if @user.save + sign_in(@user) + UserMailer.welcome(@user).deliver! + flash.notice = "User created." + redirect_to user_profile_path(@user) + else + render :index + end + end + + def destroy + end + + def show + @user = User.find(params[:id]) + @profile = @user.profile + @post = @user.posts.build + @comment = Comment.new + end + + def edit + end + + def update + end + + def newsfeed + @user = current_user + @profile = @user.profile + @post = @user.posts.build + @comment = Comment.new + end + + private + + def user_params + params.require(:user).permit(:email, :password, :password_confirmation, :first_name, :last_name, :birthdate, :gender) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..3e42a1cb5 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,27 @@ +module ApplicationHelper + + def errors(obj) + if obj + obj.errors.full_messages.each do |msg| + msg + end + end + end + +def profile_image(user) + if user.profile.profile_photo_id + image_tag User.get_profile_photo(user).image.url, class:"profile" + else + image_tag 'user_silhouette_generic.gif', class:"profile" + end +end + +def cover_image(user) + if user.profile.cover_id + image_tag User.get_cover_photo(user).image.url + else + image_tag 'hogwarts_small.jpg' + end +end + +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 000000000..0ec9ca5f2 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/app/helpers/friendings_helper.rb b/app/helpers/friendings_helper.rb new file mode 100644 index 000000000..3cbb54dae --- /dev/null +++ b/app/helpers/friendings_helper.rb @@ -0,0 +1,11 @@ +module FriendingsHelper + + def friend_buttons(user) + if current_user.friendeds.include?(user) + link_to "Unfriend Me", friending_path(user), method: :delete, class: "btn btn-secondary unfriend-button" + else + link_to "Friend Me", friendings_path(user), method: :post, class: "btn btn-primary unfriend-button" + end + end + +end diff --git a/app/helpers/likes_helper.rb b/app/helpers/likes_helper.rb new file mode 100644 index 000000000..a78a75964 --- /dev/null +++ b/app/helpers/likes_helper.rb @@ -0,0 +1,2 @@ +module LikesHelper +end diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb new file mode 100644 index 000000000..0a10d472b --- /dev/null +++ b/app/helpers/photos_helper.rb @@ -0,0 +1,2 @@ +module PhotosHelper +end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb new file mode 100644 index 000000000..a7b8cec89 --- /dev/null +++ b/app/helpers/posts_helper.rb @@ -0,0 +1,2 @@ +module PostsHelper +end diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb new file mode 100644 index 000000000..4e430508f --- /dev/null +++ b/app/helpers/profiles_helper.rb @@ -0,0 +1,2 @@ +module ProfilesHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..309f8b2eb --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/helpers/static_pages_helper.rb b/app/helpers/static_pages_helper.rb new file mode 100644 index 000000000..2d63e79e6 --- /dev/null +++ b/app/helpers/static_pages_helper.rb @@ -0,0 +1,2 @@ +module StaticPagesHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 000000000..15ced314c --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,11 @@ +module UsersHelper + + def friend_link(user) + (unless current_user == user + link_to "Add Friend", friendings_path(user), method: :post + else + "

test

" + end).html_safe + end + +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 000000000..a009ace51 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 000000000..286b2239d --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 000000000..d9804aa26 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,16 @@ +class UserMailer < ApplicationMailer + default from: "mrdane@danebook.com" + + def welcome(user) + @user = user + mail(to: @user.email, subject: 'Welcome to Danebook!') + end + + def notification(user, comment) + @writer = User.find(comment.user_id) + @user = user + @comment = comment + mail(to: @user.email, subject: 'A comment has been added.') + end + +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 000000000..27560da86 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,15 @@ +class Comment < ApplicationRecord + + validates :body, + :presence => true + + belongs_to :user + belongs_to :commentable, polymorphic: true + + def self.send_notification(id, comment_id) + user = User.find(id) + comment = Comment.find(comment_id) + UserMailer.notification(user, comment).deliver + end + +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/friending.rb b/app/models/friending.rb new file mode 100644 index 000000000..b5e5aed53 --- /dev/null +++ b/app/models/friending.rb @@ -0,0 +1,6 @@ +class Friending < ApplicationRecord + + belongs_to :friend_initiator, foreign_key: :friender_id, class_name: "User" + belongs_to :friend_recipient, foreign_key: :friended_id, class_name: "User" + +end diff --git a/app/models/like.rb b/app/models/like.rb new file mode 100644 index 000000000..5446c197e --- /dev/null +++ b/app/models/like.rb @@ -0,0 +1,8 @@ +class Like < ApplicationRecord + + belongs_to :user + belongs_to :likeable, polymorphic: true + + validates_uniqueness_of :user_id, :scope => [:likeable_id, :likeable_type] + +end diff --git a/app/models/photo.rb b/app/models/photo.rb new file mode 100644 index 000000000..9e0dfd7a7 --- /dev/null +++ b/app/models/photo.rb @@ -0,0 +1,14 @@ +class Photo < ApplicationRecord + + belongs_to :user + has_many :likes, as: :likeable, dependent: :destroy + has_many :comments, as: :commentable, dependent: :destroy + + has_attached_file :image, :styles => { :medium => "300x300#", :thumb => "130x130#" } + validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ + + def like_list + likes.map {|like| like.user.name}.join(", ") + end + +end diff --git a/app/models/post.rb b/app/models/post.rb new file mode 100644 index 000000000..d4e644484 --- /dev/null +++ b/app/models/post.rb @@ -0,0 +1,19 @@ +class Post < ApplicationRecord + + validates :body, presence: true + + belongs_to :user + has_many :likes, as: :likeable, dependent: :destroy + has_many :comments, as: :commentable, dependent: :destroy + + def like_list + likes.map {|like| like.user.name}.join(", ") + end + + def self.friend_posts(user) + nil + friend_ids = "(#{user.friended_ids.join(",")})" + self.where("user_id IN #{friend_ids}").order("created_at DESC") + end + +end diff --git a/app/models/profile.rb b/app/models/profile.rb new file mode 100644 index 000000000..d716a0a8b --- /dev/null +++ b/app/models/profile.rb @@ -0,0 +1,19 @@ +class Profile < ApplicationRecord + + # validates :first_name, + # :length => { :in => 1..40 } + + # validates :last_name, + # :length => { :in => 1..40 } + + belongs_to :user + + def remove_photo(id) + if profile_photo_id == id + profile_photo_id = nil + elsif cover_id == id + cover_id = nil + end + end + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..50b56aca4 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,69 @@ +class User < ApplicationRecord + + before_create :generate_token + + has_secure_password + + validates :password, + :length => { :in => 8..24 }, + :allow_nil => true + + validates :email, + :presence => true, + :uniqueness => true + + has_one :profile + has_many :posts + has_many :likes + has_many :comments + has_many :photos + + has_many :initiated_friends, foreign_key: :friender_id, class_name: "Friending" + has_many :friendeds, through: :initiated_friends, source: :friend_recipient + + has_many :received_friends, foreign_key: :friended_id, class_name: "Friending" + has_many :frienders, through: :received_friends, source: :friend_initiator + + def generate_token + begin + self[:auth_token] = SecureRandom.urlsafe_base64 + end while User.exists?(:auth_token => self[:auth_token]) + end + + def regenerate_auth_token + self.auth_token = nil + generate_token + save! + end + + def find_like(obj, type) + likes.where("likeable_id = ? AND likeable_type = ?", obj.id, type) + end + + def like_exist?(obj, type) + !find_like(obj, type).empty? + end + + def self.get_profile_photo(user) + Photo.find(user.profile.profile_photo_id) + end + + def self.get_cover_photo(user) + Photo.find(user.profile.cover_id) + end + + def self.search(query) + results = self.where("") + if query + query.each do |col, name| + results = results.where("#{col} ILIKE ?", "%#{name}%") if name.present? + end + end + results + end + + def name + first_name + " " + last_name + end + +end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 000000000..5c3327f7d --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,7 @@ +var commentRow = "<%= j( render partial: "shared/comment", locals: { comment: @comment } ) %>" +var $commentRow = $(commentRow); +var id = <%= @comment.commentable.id %>; +var $container = $('#' + id); +$container.find('.info-box').after($commentRow); +$commentRow.hide().slideDown(1000); +$container.find('#comment-form')[0].reset(); \ No newline at end of file diff --git a/app/views/comments/destroy.js.erb b/app/views/comments/destroy.js.erb new file mode 100644 index 000000000..25f285452 --- /dev/null +++ b/app/views/comments/destroy.js.erb @@ -0,0 +1,3 @@ +var id = <%= @comment.id %>; +var $comment = $('#' + id); +$comment.slideUp(1000); \ No newline at end of file diff --git a/app/views/friendings/show.html.erb b/app/views/friendings/show.html.erb new file mode 100644 index 000000000..891383d61 --- /dev/null +++ b/app/views/friendings/show.html.erb @@ -0,0 +1,30 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + +
+
+
+

Friends

+
+
+
+ + <% @user.friendeds.each do |friend| %> + +
+
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"friend-profile" %> +
+
+ <%= link_to friend.name, user_path(friend), class: "friend-name" %> +
+
+ <%= link_to "Unfriend Me", friending_path(friend), method: :delete, class: "btn btn-secondary unfriend-button" %> +
+
+
+ + <% end %> + +
+ \ 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 @@ +
+
+
+ <%= cover_image(@user) %> + <%= profile_image(@user) %> + <%= @user.first_name %> <%= @user.last_name %> +
+
+ + + +
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 000000000..ae347115b --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,34 @@ + + + + ProjectDanebook + <%= csrf_meta_tags %> + + + + + + + + + + + + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + <% if signed_in_user? %> + <%= render partial: "layouts/navbar-login", locals: {current_user: current_user} %> + <% else %> + <%= render "layouts/navbar" %> + <% end %> +


+ <%= flash.notice %> + <% errors(@user) %> + <% errors(@profile) %> + <%= yield %> + + diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 000000000..cbd34d2e9 --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 000000000..37f0bddbd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/photos/index.html.erb b/app/views/photos/index.html.erb new file mode 100644 index 000000000..a7a4801f4 --- /dev/null +++ b/app/views/photos/index.html.erb @@ -0,0 +1,17 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + +
+
+
+

Photos <%= link_to "Add Photo", new_user_photo_path(current_user), class: "btn btn-primary btn-sm submit-button" %>

+
+
+ +
+ <% @user.photos.each do |photo| %> +
+ <%= link_to (image_tag photo.image.url(:medium), class: "photo-preview"), user_photo_path(@user, photo) %> +
+ <% end %> +
+ \ No newline at end of file diff --git a/app/views/photos/new.html.erb b/app/views/photos/new.html.erb new file mode 100644 index 000000000..0a6831cc3 --- /dev/null +++ b/app/views/photos/new.html.erb @@ -0,0 +1,22 @@ +<%= render partial: "layouts/navlinks", locals: {user: current_user} %> + +
+
+
+

Add Photo

+
+
+ +
+ +
+
+

Choose a file to upload.


+ <%= form_for [current_user, @photo] do |f| %> + <%= f.file_field :image %>
+ <%= f.submit %> + <% end %>

+
+ +
+ \ No newline at end of file diff --git a/app/views/photos/show.html.erb b/app/views/photos/show.html.erb new file mode 100644 index 000000000..8abc9a1d9 --- /dev/null +++ b/app/views/photos/show.html.erb @@ -0,0 +1,72 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + +
+
+
+

Photos <%= link_to "Add Photo", new_user_photo_path(current_user), class: "btn btn-primary btn-sm submit-button" %>

+
+
+ +
+
+
+ <% if current_user == @user %> +

<%= link_to "Set as Profile Photo", profile_photo_profile_path(@photo) %> | + <%= link_to "Set as Cover Photo", cover_photo_profile_path(@photo)%> | + <%= link_to "Remove Photo", user_photo_path(@photo), method: :delete %>

+ <% end %> + <%= image_tag @photo.image.url %>
+ <% unless current_user.like_exist?(@photo, "Photo") %> + <%= link_to "#{@photo.likes.count} Like(s)", photo_likes_path(@photo), method: :post %> + <% else %> + <%= link_to "Unlike", photo_like_path(current_user.find_like(@photo, "Photo").first), method: :delete %> + <% end %> + + <% unless @photo.likes.empty? %> +
+
+

<%= @photo.like_list %> likes this

+
+
+ <% end %> + +
+ + <% @photo.comments.order(created_at: :desc).each do |comment| %> + +
+
+ <%= image_tag 'user_silhouette_generic.gif', class: "poster-pic2" %> +
+
+

<%= 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 %> +
+
+ + <% end %> + + <%= form_for [current_user, @comment], remote: true, html: { id: 'comment-form' } do |f| %> + <%= f.hidden_field :commentable_id, :value => @photo.id %> + <%= f.hidden_field :commentable_type, :value => "Photo" %> + +
+
+ <%= f.text_area :body, size: "72x4", placeholder: "Write a comment.", style: "margin-top: 5px" %> +
+
+ +
+
+ <%= f.submit "Comment", class: "btn btn-primary btn-sm submit-button" %> +
+
+ + <% end %> + +
+
+ \ No newline at end of file diff --git a/app/views/posts/cfield.js.erb b/app/views/posts/cfield.js.erb new file mode 100644 index 000000000..f964fbbb3 --- /dev/null +++ b/app/views/posts/cfield.js.erb @@ -0,0 +1,5 @@ +var id = <%= @post.id %>; +var $commentButton = $('#' + id + ' > .post-comment') +var $commentField = $('#' + id + ' > .comment-form') +$commentButton.hide(); +$commentField.show(); \ No newline at end of file diff --git a/app/views/posts/create.js.erb b/app/views/posts/create.js.erb new file mode 100644 index 000000000..4a1afcaf5 --- /dev/null +++ b/app/views/posts/create.js.erb @@ -0,0 +1,6 @@ +var postRow = "<%= j( render partial: "shared/post", locals: { post: @post, comment: @post.comments.build } ) %>" +var $postRow = $(postRow); +var $userPosts = $('.recent-posts'); +$userPosts.prepend($postRow); +$postRow.hide().slideDown(1000); +$('#post-form')[0].reset(); \ No newline at end of file diff --git a/app/views/posts/destroy.js.erb b/app/views/posts/destroy.js.erb new file mode 100644 index 000000000..29ca0a6a9 --- /dev/null +++ b/app/views/posts/destroy.js.erb @@ -0,0 +1,3 @@ +var id = <%= @post.id %>; +var $post = $('#' + id); +$post.slideUp(1000); \ No newline at end of file diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb new file mode 100644 index 000000000..79ed5ed3f --- /dev/null +++ b/app/views/profiles/edit.html.erb @@ -0,0 +1,98 @@ +
+
+
+ <%= image_tag 'hogwarts_small.jpg' %> + <%= image_tag 'user_silhouette_generic.gif', class:"profile" %> + <%= current_user.first_name %> <%= current_user.last_name %> +
+
+ + + +
+ + +
+
+
+

Edit Profile

+
+
+ +
+ +
+ +
+

Basic Information

+
+
+

Gender:

+

Birthday:

+

Hometown:

+

Currently Lives:

+
+ +
+ + + + + + + +
+
+ +

Contact Information

+
+
+

First Name:

+

Last Name:

+

Email:

+

Telephone:

+
+ +
+ + + + +
+
+
+ +
+

Words to Live By

+ +

About Me

+ +
+ +
+
+ + + +
+
+ +
+
+
\ No newline at end of file diff --git a/app/views/profiles/search.html.erb b/app/views/profiles/search.html.erb new file mode 100644 index 000000000..f176abf7f --- /dev/null +++ b/app/views/profiles/search.html.erb @@ -0,0 +1,30 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + +
+
+
+

Search Results

+
+
+
+ + <% @users.each do |friend| %> + +
+
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"friend-profile" %> +
+
+ <%= link_to friend.name, user_path(friend), class: "friend-name" %> +
+
+ <%= friend_buttons(friend) %> +
+
+
+ + <% end %> + +
+ \ 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 @@ +
+
+




+

Login

+ + <%= form_tag session_path do %> + <%= label_tag :email %> + <%= text_field_tag :email %> +
+ <%= label_tag :password %> + <%= password_field_tag :password %> +
+ <%= submit_tag "Log in" %> + <% end %> + +
+
\ 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 @@ +
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"poster-pic2" %> +
+
+

<%= 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", remote: true %> + <% end %> +
+
\ 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 @@ +
+
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"poster-pic2" %> +
+
+ <%= link_to full_name(post.user), user_profile_path(post.user), class:"poster" %> +

Posted on <%= post.created_at.strftime("%m/%d/%Y") %>

+
+
+
+
+

<%= post.body %>

+
+
+ +
+
+
+ <% unless current_user.like_exist?(post, "Post") %> + <%= link_to "#{post.likes.count} Like(s)", post_likes_path(post), method: :post %> + <% else %> + <%= link_to "Unlike", post_like_path(current_user.find_like(post, "Post").first), method: :delete %> + <% end %> +
+ + <% if current_user == @user %> +
+ <%= link_to "Delete", user_post_path(@user, post), method: :delete, style: "margin-left: 10px", remote: true %> +
+ <% end %> + +
+ + <% unless post.likes.empty? %> +
+
+

<%= post.like_list %> likes this

+
+
+ <% end %> +
+ + <% post.comments.order(created_at: :desc).each do |comment| %> + <% next if comment.new_record? %> + + <%= render partial: "shared/comment", locals: {comment: comment} %> + + <% end %> + +
+
+ <%= link_to "Add Comment", post_cfield_path(post), style: "margin: 4px", remote: true %> +
+
+ + +
\ No newline at end of file diff --git a/app/views/static_pages/about.html.erb b/app/views/static_pages/about.html.erb new file mode 100644 index 000000000..15df8e029 --- /dev/null +++ b/app/views/static_pages/about.html.erb @@ -0,0 +1,149 @@ + + + + + + + + Welcome to Danebook + + + + + + + + + + + + + + + + + + + + +
+
+ + + Harry Potter +
+ + + +
+ + +
+
+
+

About

+
+
+ +
+
+
+ +
+

Basic Information

+
+
+

Birthday:

+

College:

+

Hometown:

+

Currently Lives:

+
+ +
+

July 31st, 1980

+

Hogwarts College

+

Godrick's Hollow, England

+

Godrick's Hollow, England

+
+
+ +

Contact Information

+
+
+

Email:

+

Telephone:

+
+ +
+

harry_potter@hogwarts.edu

+

555-123-4567

+
+
+
+ +
+

Words to Live By

+

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 + + + + + + + + + + + + + + + + + + + + +
+
+ + + Harry Potter +
+ + + +
+ + +
+
+
+

Edit Profile

+
+
+
+ +
+

Basic Information

+
+
+

Birthday:

+

College:

+

Hometown:

+

Currently Lives:

+
+ +
+

July 31st, 1980

+
+ + + +
+
+
+ +

Contact Information

+
+
+

Email:

+

Telephone:

+
+ +
+

harry_potter@hogwarts.edu

+
+ +
+
+
+
+ +
+

Words to Live By

+ +

About Me

+ +
+ +
+ + + +
+ +
+ +
+ + + \ No newline at end of file diff --git a/app/views/static_pages/friends.html.erb b/app/views/static_pages/friends.html.erb new file mode 100644 index 000000000..ab6f38268 --- /dev/null +++ b/app/views/static_pages/friends.html.erb @@ -0,0 +1,190 @@ + + + + + + + + Welcome to Danebook + + + + + + + + + + + + + + + + + + + + +
+
+ + + Harry Potter +
+ + + +
+ + +
+
+
+

Friends

+
+
+
+ +
+
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+ +
+ + + \ 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
  • +
  • Like things because you're a positive person!
  • +
+
+ + + +
+
diff --git a/app/views/static_pages/new.html.erb b/app/views/static_pages/new.html.erb new file mode 100644 index 000000000..b475f4e9e --- /dev/null +++ b/app/views/static_pages/new.html.erb @@ -0,0 +1,103 @@ +
+
+
+ <%= image_tag 'hogwarts_small.jpg' %> + <%= image_tag 'user_silhouette_generic.gif', class:"profile" %> +
+
+ + +
+
+
+

Friends

+
+
+
+ +
+
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+
+ +
+
+ Hermione Granger +

432 Friends

+
+
+ +
+
+ +
+ +
\ No newline at end of file diff --git a/app/views/static_pages/photos.html.erb b/app/views/static_pages/photos.html.erb new file mode 100644 index 000000000..80fbe7b83 --- /dev/null +++ b/app/views/static_pages/photos.html.erb @@ -0,0 +1,140 @@ + + + + + + + + Welcome to Danebook + + + + + + + + + + + + + + + + + + + + +
+
+ + + Harry Potter +
+ + + +
+ + +
+
+
+

Photos

+
+
+ +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/static_pages/show.html.erb b/app/views/static_pages/show.html.erb new file mode 100644 index 000000000..534efff79 --- /dev/null +++ b/app/views/static_pages/show.html.erb @@ -0,0 +1,45 @@ +
+
+
+ <%= image_tag 'hogwarts_small.jpg' %> + <%= image_tag 'user_silhouette_generic.gif', class:"profile" %> +
+
+ + + + + +
+
+
+

Photos

+
+
+ +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
\ No newline at end of file diff --git a/app/views/static_pages/timeline.html.erb b/app/views/static_pages/timeline.html.erb new file mode 100644 index 000000000..acf3c7a06 --- /dev/null +++ b/app/views/static_pages/timeline.html.erb @@ -0,0 +1,327 @@ + + + + + + + + Welcome to Danebook + + + + + + + + + + + + + + + + + + + + +
+
+ + + Harry Potter +
+ + + +
+ + +
+
+
+
+

About (Test Area)

+
+
+
+

Born on: July 31st, 1980

+

Went to school at: Hogwarts

+

Hometown: Godrick's Hollow, England

+

Currently Lives: Godrick's Hollow

+
+
+ +
+

Photos (123)

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+ See More Photos +
+ +
+

Friends (542)

+
+ +
+ +
+ +
+
+

Post

+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ Harry Potter +

Posted on Thursday 6/1/2014

+
+
+
+
+

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

+
+
+
+
+ Like +
+
+ Comment +
+
+ Delete +
+
+ +
+
+ +
+
+ Harry Potter +

Posted on Thursday 5/21/2014

+
+
+
+
+

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

+
+
+
+
+ Like +
+
+ Comment +
+
+ Delete +
+
+
+
+

Hermione Granger likes this

+
+
+ +
+
+ +
+
+ Harry Potter +

Posted on Thursday 5/21/2014

+
+
+
+
+

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

+
+
+
+
+ Unlike +
+
+ Delete +
+
+
+
+

You and Hermione Granger and 3 others like this

+
+
+ +
+
+ +
+
+

Ron Weasley said on Thursday 5/21/2014

+

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

+
+
+
+
+ Like +
+
+

3 other people like this

+
+
+ +
+
+ +
+
+

Harry Potter said on Friday 5/22/2014

+

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

+
+
+
+
+ Like +
+
+

3 other people like this

+
+
+ Delete +
+
+ +
+
+ +
+
+ +
+
+ Cancel +
+
+ +
+
+ +
+ + +
+
+ + + + + + + + + \ 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!
  • +
+
+ + + +
+
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 @@ +
+
+




+

Create a New User

+ + <%= form_for @user do |f| %> + <%= f.label :email %> + <%= f.text_field :email %> +
+ <%= f.label :password %> + <%= f.password_field :password %> +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation %> +
+ <%= f.submit %> + <% end %> + +
+
\ No newline at end of file diff --git a/app/views/users/newsfeed.html.erb b/app/views/users/newsfeed.html.erb new file mode 100644 index 000000000..18b922264 --- /dev/null +++ b/app/views/users/newsfeed.html.erb @@ -0,0 +1,41 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + +
+
+
+

Newsfeed

+
+
+ + <%= form_for [@user, @post], remote: true, html: { id: 'post-form' } do |f| %> + +
+
+ <%= f.text_area :body, size: "72x6", placeholder: "Tell the world something" %> +
+
+
+
+ <%= f.submit "Submit", class: "btn btn-primary btn-sm submit-button" %> +
+
+ + <% end %> +
+ +
+
+
+

Recent Friend Posts

+
+ <% unless current_user.friendeds.empty? %> + <% Post.friend_posts(current_user).each do |post| %> + + <%= render partial: "shared/post", locals: {post: post, comment: post.comments.build} %> + + <% end %> + <% end %> +
+
+
+
\ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 000000000..261e2ed07 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,92 @@ +<%= render partial: "layouts/navlinks", locals: {user: @user} %> + + +
+
+
+
+

About

+
+
+
+

Born on: <%= @user.birthdate %>

+

Email: <%= @user.email %>

+

Hometown: <%= @profile.hometown %>

+

Currently Lives: <%= @profile.current_residence %>

+
+
+ +
+

Photos

+
+
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> +
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> +
+
+ <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> +
+ See More Photos +
+ +
+

Friends (<%= @user.friendeds.count %>)

+
+
+ <% @user.friendeds.each do |friend| %> + +
+ <%= image_tag 'user_silhouette_generic.gif', class:"ph-preview" %> + <%= link_to friend.name, user_path(friend), style: "margin-left: 12px" %> +
+ + <% end %> +
+
+ +
+ +
+
+

Posts

+
+
+ + <% if current_user == @user %> + + <%= form_for [@user, @post], remote: true, html: { id: 'post-form' } do |f| %> + +
+
+ <%= f.text_area :body, size: "72x6", placeholder: "Tell the world something" %> +
+
+
+
+ <%= f.submit "Submit", class: "btn btn-primary btn-sm submit-button" %> +
+
+ + <% end %> + + <% end %> + +
+ <% @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