14 | <% end %>
15 |
16 | <%= render "devise/shared/links" %>
17 |
--------------------------------------------------------------------------------
/app/views/layouts/_bootstrap.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # This file contains settings for ActionController::ParamsWrapper which
6 | # is enabled by default.
7 |
8 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9 | ActiveSupport.on_load(:action_controller) do
10 | wrap_parameters format: [:json]
11 | end
12 |
13 | # To enable root element in JSON for ActiveRecord objects.
14 | # ActiveSupport.on_load(:active_record) do
15 | # self.include_root_in_json = true
16 | # end
17 |
--------------------------------------------------------------------------------
/app/views/users/friends.html.erb:
--------------------------------------------------------------------------------
1 |
Friends
2 |
3 |
4 |
5 | <% if all_friends > 0 %>
6 | <% current_user.friends.each do |user| %>
7 |
30 | <%= f.label :current_password %> (we need your current password to confirm your changes)
31 | <%= f.password_field :current_password, autocomplete: "current-password" %>
32 |
33 |
34 |
35 | <%= f.submit "Update" %>
36 |
37 | <% end %>
38 |
39 |
Cancel my account
40 |
41 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
42 |
43 | <%= link_to "Back", :back %>
44 |
--------------------------------------------------------------------------------
/app/controllers/users/registrations_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Users::RegistrationsController < Devise::RegistrationsController
4 | # before_action :configure_sign_up_params, only: [:create]
5 | # before_action :configure_account_update_params, only: [:update]
6 |
7 | # GET /resource/sign_up
8 | # def new
9 | # super
10 | # end
11 |
12 | # POST /resource
13 | # def create
14 | # super
15 | # end
16 |
17 | # GET /resource/edit
18 | # def edit
19 | # super
20 | # end
21 |
22 | # PUT /resource
23 | # def update
24 | # super
25 | # end
26 |
27 | # DELETE /resource
28 | # def destroy
29 | # super
30 | # end
31 |
32 | # GET /resource/cancel
33 | # Forces the session data which is usually expired after sign
34 | # in to be expired now. This is useful if the user wants to
35 | # cancel oauth signing in/up in the middle of the process,
36 | # removing all OAuth session data.
37 | # def cancel
38 | # super
39 | # end
40 |
41 | # protected
42 |
43 | # If you have extra params to permit, append them to the sanitizer.
44 | # def configure_sign_up_params
45 | # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
46 | # end
47 |
48 | # If you have extra params to permit, append them to the sanitizer.
49 | # def configure_account_update_params
50 | # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
51 | # end
52 |
53 | # The path used after sign up.
54 | # def after_sign_up_path_for(resource)
55 | # super(resource)
56 | # end
57 |
58 | # The path used after sign up for inactive accounts.
59 | # def after_inactive_sign_up_path_for(resource)
60 | # super(resource)
61 | # end
62 | end
63 |
--------------------------------------------------------------------------------
/app/views/layouts/_header.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | source 'https://rubygems.org'
4 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5 |
6 | ruby '2.6.4'
7 | gem 'activesupport', '~> 5.2.4.1'
8 | gem 'bootsnap', '>= 1.1.0', require: false
9 | gem 'bootstrap', '~> 4.3.1'
10 | gem 'bootstrap-will_paginate', '1.0.0'
11 | gem 'coffee-rails', '~> 4.2'
12 | gem 'devise', '~> 4.7', '>= 4.7.1'
13 | gem 'faker', '~> 1.6', '>= 1.6.6'
14 | gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.5'
15 | gem 'font-awesome-sass', '~> 5.11.2'
16 | gem 'hirb'
17 | gem 'jbuilder', '~> 2.5'
18 | gem 'omniauth-facebook', '~> 5.0'
19 | gem 'pg', '>= 0.18', '< 2.0'
20 | gem 'puma', '~> 3.11'
21 | gem 'rack', '~> 2.0', '>= 2.0.8'
22 | gem 'rails', '~> 5.2.3'
23 | gem 'sass-rails', '~> 5.0'
24 | gem 'turbolinks', '~> 5'
25 | gem 'uglifier', '>= 1.3.0'
26 |
27 | # Use Redis adapter to run Action Cable in production
28 | # gem 'redis', '~> 4.0'
29 | # Use ActiveModel has_secure_password
30 | # gem 'bcrypt', '~> 3.1.7'
31 | # Use ActiveStorage variant
32 | # gem 'mini_magick', '~> 4.8'
33 |
34 | # Use Capistrano for deployment
35 | # gem 'capistrano-rails', group: :development
36 |
37 | group :development, :test do
38 | gem 'byebug', platforms: %i[mri mingw x64_mingw]
39 | gem 'rspec-rails'
40 | end
41 |
42 | group :development do
43 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
44 | gem 'listen', '>= 3.0.5', '< 3.2'
45 | gem 'spring'
46 | gem 'spring-watcher-listen', '~> 2.0.0'
47 | gem 'web-console', '>= 3.3.0'
48 | end
49 |
50 | group :test do
51 | gem 'capybara', '>= 3.30.0'
52 | gem 'selenium-webdriver'
53 | # Easy installation and use of chromedriver to run system tests with Chrome
54 | # gem 'chromedriver-helper'
55 | gem 'webdrivers', '~> 4.0'
56 | end
57 |
58 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
59 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
60 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | workers Integer(ENV['WEB_CONCURRENCY'] || 2)
8 | threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
9 | threads threads_count, threads_count
10 |
11 | preload_app!
12 |
13 | rackup DefaultRackup
14 | port ENV['PORT'] || 3000
15 | environment ENV['RACK_ENV'] || 'development'
16 |
17 | on_worker_boot do
18 | # Worker specific setup for Rails 4.1+
19 | # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
20 | ActiveRecord::Base.establish_connection
21 | end
22 |
23 | # threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
24 | # threads threads_count, threads_count
25 |
26 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
27 | #
28 | # port ENV.fetch("PORT") { 3000 }
29 |
30 | # Specifies the `environment` that Puma will run in.
31 | #
32 | # environment ENV.fetch("RAILS_ENV") { "development" }
33 |
34 | # Specifies the number of `workers` to boot in clustered mode.
35 | # Workers are forked webserver processes. If using threads and workers together
36 | # the concurrency of the application would be max `threads` * `workers`.
37 | # Workers do not work on JRuby or Windows (both of which do not support
38 | # processes).
39 | #
40 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
41 |
42 | # Use the `preload_app!` method when specifying a `workers` number.
43 | # This directive tells Puma to first boot the application and load code
44 | # before forking the application. This takes advantage of Copy On Write
45 | # process behavior so workers use less memory.
46 | #
47 | # preload_app!
48 |
49 | # Allow puma to be restarted by `rails restart` command.
50 | plugin :tmp_restart
51 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # The test environment is used exclusively to run your application's
7 | # test suite. You never need to work with it otherwise. Remember that
8 | # your test database is "scratch space" for the test suite and is wiped
9 | # and recreated between test runs. Don't rely on the data there!
10 | config.cache_classes = true
11 |
12 | # Do not eager load code on boot. This avoids loading your whole application
13 | # just for the purpose of running a single test. If you are using a tool that
14 | # preloads Rails for running tests, you may have to set it to true.
15 | config.eager_load = false
16 |
17 | # Configure public file server for tests with Cache-Control for performance.
18 | config.public_file_server.enabled = true
19 | config.public_file_server.headers = {
20 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
21 | }
22 |
23 | # Show full error reports and disable caching.
24 | config.consider_all_requests_local = true
25 | config.action_controller.perform_caching = false
26 |
27 | # Raise exceptions instead of rendering exception templates.
28 | config.action_dispatch.show_exceptions = false
29 |
30 | # Disable request forgery protection in test environment.
31 | config.action_controller.allow_forgery_protection = false
32 |
33 | # Store uploaded files on the local file system in a temporary directory
34 | config.active_storage.service = :test
35 |
36 | config.action_mailer.perform_caching = false
37 |
38 | # Tell Action Mailer not to deliver emails to the real world.
39 | # The :test delivery method accumulates sent emails in the
40 | # ActionMailer::Base.deliveries array.
41 | config.action_mailer.delivery_method = :test
42 |
43 | # Print deprecation notices to the stderr.
44 | config.active_support.deprecation = :stderr
45 |
46 | # Raises error for missing translations
47 | # config.action_view.raise_on_missing_translations = true
48 | end
49 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class User < ApplicationRecord
4 | has_many :posts, dependent: :destroy
5 | has_many :comments, dependent: :destroy
6 | has_many :likes, dependent: :destroy
7 | has_many :friendships
8 | has_many :inverse_friendships, class_name: 'Friendship', foreign_key: 'friend_id'
9 | validates :first_name, presence: true
10 | validates :last_name, presence: true
11 | # Include default devise modules. Others available are:
12 | # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
13 | devise :database_authenticatable, :registerable,
14 | :recoverable, :rememberable, :validatable, :omniauthable, omniauth_providers: %i[facebook]
15 |
16 | def self.from_omniauth(auth)
17 | where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
18 | user.email = auth.info.email
19 | user.password = Devise.friendly_token[0, 20]
20 | user.first_name = auth.info.name.split(' ')[0] # assuming the user model has a name
21 | user.last_name = auth.info.name.split(' ')[1]
22 | # user.image = auth.info.image # assuming the user model has an image
23 | # If you are using confirmable and the provider(s) you use validate emails,
24 | # uncomment the line below to skip the confirmation emails.
25 | # user.skip_confirmation!
26 | end
27 | end
28 |
29 | # called by the devise registrations controller
30 | def self.new_with_session(params, session)
31 | super.tap do |user|
32 | if (data = session['devise.facebook_data'] && session['devise.facebook_data']['extra']['raw_info'])
33 | user.email = data['email'] if user.email.blank?
34 | end
35 | end
36 | end
37 |
38 | def friends
39 | friends_array = friendships.map { |f| f.friend if f.confirmed }
40 | friends_array.concat(inverse_friendships.map { |f| f.user if f.confirmed })
41 | friends_array.compact.uniq!
42 | end
43 |
44 | def pending_friends
45 | friendships.map { |f| f.friend unless f.confirmed }.compact
46 | end
47 |
48 | def confirm_friend(user)
49 | friendship = inverse_friendships.find { |f| f.user == user }
50 | friendship.confirmed = true
51 | friendship.save
52 | end
53 |
54 | def friend?(user)
55 | friendship.include? user
56 | end
57 |
58 | def unfriend(user)
59 | table = friendships.where(requested_id: user.id).or(inverse_friendships.where(requestor_id: user.id)).ids
60 | Friendship.delete(table.first)
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # In the development environment your application's code is reloaded on
7 | # every request. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports.
15 | config.consider_all_requests_local = true
16 |
17 | # Enable/disable caching. By default caching is disabled.
18 | # Run rails dev:cache to toggle caching.
19 | if Rails.root.join('tmp', 'caching-dev.txt').exist?
20 | config.action_controller.perform_caching = true
21 |
22 | config.cache_store = :memory_store
23 | config.public_file_server.headers = {
24 | 'Cache-Control' => "public, max-age=#{2.days.to_i}"
25 | }
26 | else
27 | config.action_controller.perform_caching = false
28 |
29 | config.cache_store = :null_store
30 | end
31 |
32 | # Store uploaded files on the local file system (see config/storage.yml for options)
33 | config.active_storage.service = :local
34 |
35 | # Devise setup
36 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
37 | # Don't care if the mailer can't send.
38 | config.action_mailer.raise_delivery_errors = false
39 |
40 | config.action_mailer.perform_caching = false
41 |
42 | # Print deprecation notices to the Rails logger.
43 | config.active_support.deprecation = :log
44 |
45 | # Raise an error on page load if there are pending migrations.
46 | config.active_record.migration_error = :page_load
47 |
48 | # Highlight code that triggered database queries in logs.
49 | config.active_record.verbose_query_logs = true
50 |
51 | # Debug mode disables concatenation and preprocessing of assets.
52 | # This option may cause significant delays in view rendering with a large
53 | # number of complex assets.
54 | config.assets.debug = true
55 |
56 | # Suppress logger output for asset requests.
57 | config.assets.quiet = true
58 |
59 | # Raises error for missing translations
60 | # config.action_view.raise_on_missing_translations = true
61 |
62 | # Use an evented file watcher to asynchronously detect changes in source code,
63 | # routes, locales, etc. This feature depends on the listen gem.
64 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
65 | end
66 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 2020_01_24_103907) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "comments", force: :cascade do |t|
19 | t.bigint "user_id"
20 | t.bigint "post_id"
21 | t.text "comment_text"
22 | t.datetime "created_at", null: false
23 | t.datetime "updated_at", null: false
24 | t.index ["post_id"], name: "index_comments_on_post_id"
25 | t.index ["user_id"], name: "index_comments_on_user_id"
26 | end
27 |
28 | create_table "friendships", force: :cascade do |t|
29 | t.bigint "user_id"
30 | t.bigint "friend_id"
31 | t.boolean "confirmed"
32 | t.datetime "created_at", null: false
33 | t.datetime "updated_at", null: false
34 | t.index ["friend_id"], name: "index_friendships_on_friend_id"
35 | t.index ["user_id"], name: "index_friendships_on_user_id"
36 | end
37 |
38 | create_table "likes", force: :cascade do |t|
39 | t.bigint "user_id"
40 | t.bigint "post_id"
41 | t.datetime "created_at", null: false
42 | t.datetime "updated_at", null: false
43 | t.index ["post_id"], name: "index_likes_on_post_id"
44 | t.index ["user_id"], name: "index_likes_on_user_id"
45 | end
46 |
47 | create_table "posts", force: :cascade do |t|
48 | t.text "post_text"
49 | t.integer "user_id"
50 | end
51 |
52 | create_table "users", force: :cascade do |t|
53 | t.string "email", default: "", null: false
54 | t.string "encrypted_password", default: "", null: false
55 | t.string "reset_password_token"
56 | t.datetime "reset_password_sent_at"
57 | t.datetime "remember_created_at"
58 | t.datetime "created_at", null: false
59 | t.datetime "updated_at", null: false
60 | t.string "first_name"
61 | t.string "last_name"
62 | t.string "provider"
63 | t.string "uid"
64 | t.index ["email"], name: "index_users_on_email", unique: true
65 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
66 | end
67 |
68 | add_foreign_key "friendships", "users"
69 | add_foreign_key "friendships", "users", column: "friend_id"
70 | add_foreign_key "likes", "posts"
71 | add_foreign_key "likes", "users"
72 | end
73 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # This file is copied to spec/ when you run 'rails generate rspec:install'
4 | require 'spec_helper'
5 | require 'capybara/rspec'
6 | require 'database_cleaner'
7 | ENV['RAILS_ENV'] ||= 'test'
8 |
9 | require File.expand_path('../config/environment', __dir__)
10 |
11 | # Prevent database truncation if the environment is production
12 | abort('The Rails environment is running in production mode!') if Rails.env.production?
13 | require 'rspec/rails'
14 | # Add additional requires below this line. Rails is not loaded until this point!
15 |
16 | # Requires supporting ruby files with custom matchers and macros, etc, in
17 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
18 | # run as spec files by default. This means that files in spec/support that end
19 | # in _spec.rb will both be required and run as specs, causing the specs to be
20 | # run twice. It is recommended that you do not name files matching this glob to
21 | # end with _spec.rb. You can configure this pattern with the --pattern
22 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
23 | #
24 | # The following line is provided for convenience purposes. It has the downside
25 | # of increasing the boot-up time by auto-requiring all files in the support
26 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
27 | # require only the support files necessary.
28 | #
29 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
30 |
31 | # Checks for pending migrations and applies them before tests are run.
32 | # If you are not using ActiveRecord, you can remove these lines.
33 | begin
34 | ActiveRecord::Migration.maintain_test_schema!
35 | rescue ActiveRecord::PendingMigrationError => e
36 | puts e.to_s.strip
37 | exit 1
38 | end
39 | RSpec.configure do |config|
40 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
41 |
42 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
43 |
44 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
45 | # examples within a transaction, remove the following line or assign false
46 | # instead of true.
47 | config.use_transactional_fixtures = true
48 |
49 | # RSpec Rails can automatically mix in different behaviours to your tests
50 | # based on their file location, for example enabling you to call `get` and
51 | # `post` in specs under `spec/controllers`.
52 | #
53 | # You can disable this behaviour by removing the line below, and instead
54 | # explicitly tag your specs with their type, e.g.:
55 | #
56 | # RSpec.describe UsersController, :type => :controller do
57 | # # ...
58 | # end
59 | #
60 | # The different available types are documented in the features, such as in
61 | # https://relishapp.com/rspec/rspec-rails/docs
62 | config.infer_spec_type_from_file_location!
63 |
64 | # Filter lines from Rails gems in backtraces.
65 | config.filter_rails_from_backtrace!
66 | # arbitrary gems may also be filtered via:
67 | # config.filter_gems_from_backtrace("gem name")
68 | end
69 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # http://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: fb_clone_development
27 | username: fb-clone
28 | password: foobar12345
29 |
30 | # The specified database role being used to connect to postgres.
31 | # To create additional roles in postgres see `$ createuser --help`.
32 | # When left blank, postgres will use the default role. This is
33 | # the same name as the operating system user that initialized the database.
34 | #username: facebook-clone
35 | # The password associated with the postgres role (username).
36 | #password:
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 | # The TCP port the server listens on. Defaults to 5432.
42 | # If your server runs on a different port number, change accordingly.
43 | #port: 5432
44 | # Schema search path. The server defaults to $user,public
45 | #schema_search_path: myapp,sharedapp,public
46 | # Minimum log levels, in increasing order:
47 | # debug5, debug4, debug3, debug2, debug1,
48 | # log, notice, warning, error, fatal, and panic
49 | # Defaults to warning.
50 | #min_messages: notice
51 |
52 | # Warning: The database defined as "test" will be erased and
53 | # re-generated from your development database when you run "rake".
54 | # Do not set this db to the same as development or production.
55 | test:
56 | <<: *default
57 | database: fb_clone_test
58 | username: fb-clone
59 | password: foobar12345
60 |
61 | # As with config/secrets.yml, you never want to store sensitive information,
62 | # like your database password, in your source code. If your source code is
63 | # ever seen by anyone, they now have access to your database.
64 | #
65 | # Instead, provide the password as a unix environment variable when you boot
66 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
67 | # for a full rundown on how to provide these environment variables in a
68 | # production deployment.
69 | #
70 | # On Heroku and other platform providers, you may have a full connection URL
71 | # available as an environment variable. For example:
72 | #
73 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
74 | #
75 | # You can use this database configuration with:
76 | #
77 | # production:
78 | # url: <%= ENV['DATABASE_URL'] %>
79 | #
80 | # production:
81 | # <<: *default
82 | # database: fb_clone_production
83 | # username: fb-clone
84 | # password: foobar12345
85 | production:
86 | <<: *default
87 | database: fb_production
88 | username: fb
89 | password: <%= ENV['FB_DATABASE_PASSWORD'] %>
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Project Facebook Clone
2 |
3 | Welcome to Friendbook. In this project, we recreated the basic functionality of facebook. This is the last project of Microverse's Rails curriculum.
4 |
5 | ### Features
6 |
7 | - Users
8 |
9 | - Sign up using their # Project Facebook Clone
10 |
11 | Welcome to Friendbook. In this project, we recreated the basic functionality of Facebook. This is the last project of the Microverse's Rails curriculum.
12 |
13 | ### Features
14 |
15 | - Users
16 |
17 | - Sign up using their real facebook account
18 | - Create/delete posts
19 | - Like posts
20 | - Comment on posts
21 | - Send and accept friendship requests
22 | - Remove friends
23 |
24 | ### Future features
25 | - Create a post with images
26 | - Add emojis to comments
27 | - Upload profile photo
28 | - Chat with a friend
29 |
30 | ### Screenshot
31 |
32 | 
33 |
34 | ### Live link
35 |
36 | Follow the link to access [Friendbook](https://secret-sea-76381.herokuapp.com/)
37 |
38 | ### Requirements
39 |
40 | ```
41 | - A Cloud Server running Linux (Ubuntu 18.04) or (Mac OS)
42 | - PostgreSQL installed and running.
43 | - Ruby 2.6.4
44 | - Rails 5.2.3
45 | - A basic familiarity with Ruby on Rails
46 |
47 | ```
48 |
49 | ### Gems
50 |
51 | - gem 'devise', '~> 4.7', '>= 4.7.1'
52 | - gem 'faker', '~> 1.6', '>= 1.6.6'
53 | - gem 'font-awesome-sass'
54 | - gem 'omniauth-facebook', '~> 5.0'
55 | - gem 'pg', '>= 0.18', '< 2.0'
56 | - gem 'rails', '~> 5.2.3'
57 |
58 | ### To run on windows system we have to install the following gems
59 |
60 | - gem 'wdm', '>= 0.1.0' if Gem.win_platform?
61 | - gem 'autoprefixer-rails'
62 |
63 | Add this to ```ENV['EXECJS_RUNTIME'] = 'Node'``` ```boot.rb``` file
64 |
65 | Uncomment ``` #workers Integer(ENV['WEB_CONCURRENCY'] || 2) ``` in ```puma.rb``` file
66 |
67 | #### Optional
68 |
69 | - gem hirb
70 |
71 | ### Installation
72 |
73 | Clone or download this repository to your local machine. After cloning open your terminal on the repository folder and run :
74 |
75 | ```
76 | bundle install
77 | rails db:create
78 | rails db:migrate
79 | rails db:seed
80 | ```
81 |
82 | ## How to run the test
83 |
84 | For unit testing run
85 | ``` rspec spec/models ```
86 |
87 | For a feature test run
88 | ``` rspec spec/features ```
89 |
90 | Or run
91 | ``` rspec -fd ``` for all test
92 |
93 |
94 | 👤 **Nick Haralampopoulos**
95 |
96 | - Github: [@macnick](https://github.com/macnick)
97 | - Twitter: [@mac_experts](https://twitter.com/mac_experts)
98 | - Linkedin: [Nick Haralampopoulos](https://www.linkedin.com/in/nick-haralampopoulos-26a55412a/)
99 | - Email: [Nick Haralampopoulos](mac.expert.nick@gmail.com)
100 |
101 | 👤 **Daniel Larbi Addo**
102 |
103 | - Github: [@addod19](https://github.com/addod19)
104 | - Twitter: [@DanielLarbiAdd1](https://twitter.com/DanielLarbiAdd1)
105 | - Linkedin: [Daniel Larbi Addo](https://linkedin.com/in/daniel-larbi-addo-9738b0128/)
106 | - Email: (addodaniellarbi@gmail.com)
107 |
108 | ## Appreciation
109 | [Microverse](microverse.org)
110 |
111 | ## 🤝 Contributing
112 |
113 | Contributions, issues, and feature requests are welcome!
114 |
115 | Feel free to check the [issues page](https://github.com/macnick/facebook-clone/issues).
116 |
117 | 1. Fork it ( https://github.com/macnick/facebook-clone/fork )
118 | 2. Create your feature branch (git checkout -b my-new-feature)
119 | 3. Commit your changes (git commit -am 'Add some feature')
120 | 4. Push to the branch (git push origin my-new-feature)
121 | 5. Create a new Pull Request
122 |
123 | ## Show your support
124 |
125 | Give us ⭐️ if you like this project!
126 |
127 | ## 📝 License
128 |
129 | This project is [MiT](LICENSE) licensed.
130 |
131 | ```
132 |
133 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # Code is not reloaded between requests.
7 | config.cache_classes = true
8 |
9 | # Eager load code on boot. This eager loads most of Rails and
10 | # your application in memory, allowing both threaded web servers
11 | # and those relying on copy on write to perform better.
12 | # Rake tasks automatically ignore this option for performance.
13 | config.eager_load = true
14 |
15 | # Full error reports are disabled and caching is turned on.
16 | config.consider_all_requests_local = false
17 | config.action_controller.perform_caching = true
18 |
19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21 | # config.require_master_key = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
35 |
36 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
37 | # config.action_controller.asset_host = 'http://assets.example.com'
38 |
39 | # Specifies the header that your server uses for sending files.
40 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
41 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
42 |
43 | # Store uploaded files on the local file system (see config/storage.yml for options)
44 | config.active_storage.service = :local
45 |
46 | # Mount Action Cable outside main process or domain
47 | # config.action_cable.mount_path = nil
48 | # config.action_cable.url = 'wss://example.com/cable'
49 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
50 |
51 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
52 | # config.force_ssl = true
53 |
54 | # Use the lowest log level to ensure availability of diagnostic information
55 | # when problems arise.
56 | config.log_level = :debug
57 |
58 | # Prepend all log lines with the following tags.
59 | config.log_tags = [:request_id]
60 |
61 | # Use a different cache store in production.
62 | # config.cache_store = :mem_cache_store
63 |
64 | # Use a real queuing backend for Active Job (and separate queues per environment)
65 | # config.active_job.queue_adapter = :resque
66 | # config.active_job.queue_name_prefix = "facebook-clone_#{Rails.env}"
67 |
68 | config.action_mailer.perform_caching = false
69 |
70 | # Ignore bad email addresses and do not raise email delivery errors.
71 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
72 | # config.action_mailer.raise_delivery_errors = false
73 |
74 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
75 | # the I18n.default_locale when a translation cannot be found).
76 | config.i18n.fallbacks = true
77 |
78 | # Send deprecation notices to registered listeners.
79 | config.active_support.deprecation = :notify
80 |
81 | # Use default logging formatter so that PID and timestamp are not suppressed.
82 | config.log_formatter = ::Logger::Formatter.new
83 |
84 | # Use a different logger for distributed setups.
85 | # require 'syslog/logger'
86 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
87 |
88 | if ENV['RAILS_LOG_TO_STDOUT'].present?
89 | logger = ActiveSupport::Logger.new(STDOUT)
90 | logger.formatter = config.log_formatter
91 | config.logger = ActiveSupport::TaggedLogging.new(logger)
92 | end
93 |
94 | # Do not dump schema after migrations.
95 | config.active_record.dump_schema_after_migration = false
96 | end
97 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your email address before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock instructions"
26 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
48 | sessions:
49 | signed_in: "Signed in successfully."
50 | signed_out: "Signed out successfully."
51 | already_signed_out: "Signed out successfully."
52 | unlocks:
53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56 | errors:
57 | messages:
58 | already_confirmed: "was already confirmed, please try signing in"
59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60 | expired: "has expired, please request a new one"
61 | not_found: "not found"
62 | not_locked: "was not locked"
63 | not_saved:
64 | one: "1 error prohibited this %{resource} from being saved:"
65 | other: "%{count} errors prohibited this %{resource} from being saved:"
66 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'capybara/rspec'
4 | require 'selenium/webdriver'
5 |
6 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
7 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8 | # The generated `.rspec` file contains `--require spec_helper` which will cause
9 | # this file to always be loaded, without a need to explicitly require it in any
10 | # files.
11 |
12 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
13 | RSpec.configure do |config|
14 | # rspec-expectations config goes here. You can use an alternate
15 | # assertion/expectation library such as wrong or the stdlib/minitest
16 | # assertions if you prefer.
17 | config.expect_with :rspec do |expectations|
18 | # This option will default to `true` in RSpec 4. It makes the `description`
19 | # and `failure_message` of custom matchers include text for helper methods
20 | # defined using `chain`, e.g.:
21 | # be_bigger_than(2).and_smaller_than(4).description
22 | # # => "be bigger than 2 and smaller than 4"
23 | # ...rather than:
24 | # # => "be bigger than 2"
25 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
26 | end
27 |
28 | # rspec-mocks config goes here. You can use an alternate test double
29 | # library (such as bogus or mocha) by changing the `mock_with` option here.
30 | config.mock_with :rspec do |mocks|
31 | # Prevents you from mocking or stubbing a method that does not exist on
32 | # a real object. This is generally recommended, and will default to
33 | # `true` in RSpec 4.
34 | mocks.verify_partial_doubles = true
35 | end
36 |
37 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
38 | # have no way to turn it off -- the option exists only for backwards
39 | # compatibility in RSpec 3). It causes shared context metadata to be
40 | # inherited by the metadata hash of host groups and examples, rather than
41 | # triggering implicit auto-inclusion in groups with matching metadata.
42 | config.shared_context_metadata_behavior = :apply_to_host_groups
43 | config.disable_monkey_patching = false
44 | # The settings below are suggested to provide a good initial experience
45 | # with RSpec, but feel free to customize to your heart's content.
46 | # # This allows you to limit a spec run to individual examples or groups
47 | # # you care about by tagging them with `:focus` metadata. When nothing
48 | # # is tagged with `:focus`, all examples get run. RSpec also provides
49 | # # aliases for `it`, `describe`, and `context` that include `:focus`
50 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
51 | # config.filter_run_when_matching :focus
52 | #
53 | # # Allows RSpec to persist some state between runs in order to support
54 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
55 | # # you configure your source control system to ignore this file.
56 | # config.example_status_persistence_file_path = "spec/examples.txt"
57 | #
58 | # # Limits the available syntax to the non-monkey patched syntax that is
59 | # # recommended. For more details, see:
60 | # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
61 | # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62 | # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
63 | # config.disable_monkey_patching!
64 | #
65 | # # Many RSpec users commonly either run the entire suite or an individual
66 | # # file, and it's useful to allow more verbose output when running an
67 | # # individual spec file.
68 | # if config.files_to_run.one?
69 | # # Use the documentation formatter for detailed output,
70 | # # unless a formatter has already been configured
71 | # # (e.g. via a command-line flag).
72 | # config.default_formatter = "doc"
73 | # end
74 | #
75 | # # Print the 10 slowest examples and example groups at the
76 | # # end of the spec run, to help surface which specs are running
77 | # # particularly slow.
78 | # config.profile_examples = 10
79 | #
80 | # # Run specs in random order to surface order dependencies. If you find an
81 | # # order dependency and want to debug it, you can fix the order by providing
82 | # # the seed, which is printed after each run.
83 | # # --seed 1234
84 | # config.order = :random
85 | #
86 | # # Seed global randomization in this process using the `--seed` CLI option.
87 | # # Setting this allows you to use `--seed` to deterministically reproduce
88 | # # test failures related to randomization by passing the same `--seed` value
89 | # # as the one that triggered the failure.
90 | # Kernel.srand config.seed
91 | end
92 |
93 | Capybara.register_driver :selenium do |app|
94 | Capybara::Selenium::Driver.new(app, browser: :chrome)
95 | end
96 |
97 | Capybara.configure do |config|
98 | config.run_server = false
99 | config.default_driver = :selenium
100 | config.app_host = 'localhost:3000' # change url
101 | end
102 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (5.2.4.1)
5 | actionpack (= 5.2.4.1)
6 | nio4r (~> 2.0)
7 | websocket-driver (>= 0.6.1)
8 | actionmailer (5.2.4.1)
9 | actionpack (= 5.2.4.1)
10 | actionview (= 5.2.4.1)
11 | activejob (= 5.2.4.1)
12 | mail (~> 2.5, >= 2.5.4)
13 | rails-dom-testing (~> 2.0)
14 | actionpack (5.2.4.1)
15 | actionview (= 5.2.4.1)
16 | activesupport (= 5.2.4.1)
17 | rack (~> 2.0, >= 2.0.8)
18 | rack-test (>= 0.6.3)
19 | rails-dom-testing (~> 2.0)
20 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
21 | actionview (5.2.4.1)
22 | activesupport (= 5.2.4.1)
23 | builder (~> 3.1)
24 | erubi (~> 1.4)
25 | rails-dom-testing (~> 2.0)
26 | rails-html-sanitizer (~> 1.0, >= 1.0.3)
27 | activejob (5.2.4.1)
28 | activesupport (= 5.2.4.1)
29 | globalid (>= 0.3.6)
30 | activemodel (5.2.4.1)
31 | activesupport (= 5.2.4.1)
32 | activerecord (5.2.4.1)
33 | activemodel (= 5.2.4.1)
34 | activesupport (= 5.2.4.1)
35 | arel (>= 9.0)
36 | activestorage (5.2.4.1)
37 | actionpack (= 5.2.4.1)
38 | activerecord (= 5.2.4.1)
39 | marcel (~> 0.3.1)
40 | activesupport (5.2.4.1)
41 | concurrent-ruby (~> 1.0, >= 1.0.2)
42 | i18n (>= 0.7, < 2)
43 | minitest (~> 5.1)
44 | tzinfo (~> 1.1)
45 | addressable (2.7.0)
46 | public_suffix (>= 2.0.2, < 5.0)
47 | arel (9.0.0)
48 | autoprefixer-rails (9.7.4)
49 | execjs
50 | bcrypt (3.1.13)
51 | bindex (0.8.1)
52 | bootsnap (1.4.5)
53 | msgpack (~> 1.0)
54 | bootstrap (4.3.1)
55 | autoprefixer-rails (>= 9.1.0)
56 | popper_js (>= 1.14.3, < 2)
57 | sassc-rails (>= 2.0.0)
58 | bootstrap-will_paginate (1.0.0)
59 | will_paginate
60 | builder (3.2.4)
61 | byebug (11.1.1)
62 | capybara (3.31.0)
63 | addressable
64 | mini_mime (>= 0.1.3)
65 | nokogiri (~> 1.8)
66 | rack (>= 1.6.0)
67 | rack-test (>= 0.6.3)
68 | regexp_parser (~> 1.5)
69 | xpath (~> 3.2)
70 | childprocess (3.0.0)
71 | coffee-rails (4.2.2)
72 | coffee-script (>= 2.2.0)
73 | railties (>= 4.0.0)
74 | coffee-script (2.4.1)
75 | coffee-script-source
76 | execjs
77 | coffee-script-source (1.12.2)
78 | concurrent-ruby (1.1.5)
79 | crass (1.0.6)
80 | devise (4.7.1)
81 | bcrypt (~> 3.0)
82 | orm_adapter (~> 0.1)
83 | railties (>= 4.1.0)
84 | responders
85 | warden (~> 1.2.3)
86 | diff-lcs (1.3)
87 | erubi (1.9.0)
88 | execjs (2.7.0)
89 | faker (1.9.6)
90 | i18n (>= 0.7)
91 | faraday (1.0.0)
92 | multipart-post (>= 1.2, < 3)
93 | ffi (1.12.1)
94 | font-awesome-rails (4.7.0.5)
95 | railties (>= 3.2, < 6.1)
96 | font-awesome-sass (5.11.2)
97 | sassc (>= 1.11)
98 | globalid (0.4.2)
99 | activesupport (>= 4.2.0)
100 | hashie (3.6.0)
101 | hirb (0.7.3)
102 | i18n (1.8.2)
103 | concurrent-ruby (~> 1.0)
104 | jbuilder (2.9.1)
105 | activesupport (>= 4.2.0)
106 | jwt (2.2.1)
107 | listen (3.1.5)
108 | rb-fsevent (~> 0.9, >= 0.9.4)
109 | rb-inotify (~> 0.9, >= 0.9.7)
110 | ruby_dep (~> 1.2)
111 | loofah (2.4.0)
112 | crass (~> 1.0.2)
113 | nokogiri (>= 1.5.9)
114 | mail (2.7.1)
115 | mini_mime (>= 0.1.1)
116 | marcel (0.3.3)
117 | mimemagic (~> 0.3.2)
118 | method_source (0.9.2)
119 | mimemagic (0.3.4)
120 | mini_mime (1.0.2)
121 | mini_portile2 (2.4.0)
122 | minitest (5.14.0)
123 | msgpack (1.3.1)
124 | multi_json (1.14.1)
125 | multi_xml (0.6.0)
126 | multipart-post (2.1.1)
127 | nio4r (2.5.2)
128 | nokogiri (1.10.7)
129 | mini_portile2 (~> 2.4.0)
130 | oauth2 (1.4.3)
131 | faraday (>= 0.8, < 2.0)
132 | jwt (>= 1.0, < 3.0)
133 | multi_json (~> 1.3)
134 | multi_xml (~> 0.5)
135 | rack (>= 1.2, < 3)
136 | omniauth (1.9.0)
137 | hashie (>= 3.4.6, < 3.7.0)
138 | rack (>= 1.6.2, < 3)
139 | omniauth-facebook (5.0.0)
140 | omniauth-oauth2 (~> 1.2)
141 | omniauth-oauth2 (1.6.0)
142 | oauth2 (~> 1.1)
143 | omniauth (~> 1.9)
144 | orm_adapter (0.5.0)
145 | pg (1.2.2)
146 | popper_js (1.16.0)
147 | public_suffix (4.0.3)
148 | puma (3.12.2)
149 | rack (2.1.2)
150 | rack-test (1.1.0)
151 | rack (>= 1.0, < 3)
152 | rails (5.2.4.1)
153 | actioncable (= 5.2.4.1)
154 | actionmailer (= 5.2.4.1)
155 | actionpack (= 5.2.4.1)
156 | actionview (= 5.2.4.1)
157 | activejob (= 5.2.4.1)
158 | activemodel (= 5.2.4.1)
159 | activerecord (= 5.2.4.1)
160 | activestorage (= 5.2.4.1)
161 | activesupport (= 5.2.4.1)
162 | bundler (>= 1.3.0)
163 | railties (= 5.2.4.1)
164 | sprockets-rails (>= 2.0.0)
165 | rails-dom-testing (2.0.3)
166 | activesupport (>= 4.2.0)
167 | nokogiri (>= 1.6)
168 | rails-html-sanitizer (1.3.0)
169 | loofah (~> 2.3)
170 | railties (5.2.4.1)
171 | actionpack (= 5.2.4.1)
172 | activesupport (= 5.2.4.1)
173 | method_source
174 | rake (>= 0.8.7)
175 | thor (>= 0.19.0, < 2.0)
176 | rake (13.0.1)
177 | rb-fsevent (0.10.3)
178 | rb-inotify (0.10.1)
179 | ffi (~> 1.0)
180 | regexp_parser (1.6.0)
181 | responders (3.0.0)
182 | actionpack (>= 5.0)
183 | railties (>= 5.0)
184 | rspec-core (3.9.1)
185 | rspec-support (~> 3.9.1)
186 | rspec-expectations (3.9.0)
187 | diff-lcs (>= 1.2.0, < 2.0)
188 | rspec-support (~> 3.9.0)
189 | rspec-mocks (3.9.1)
190 | diff-lcs (>= 1.2.0, < 2.0)
191 | rspec-support (~> 3.9.0)
192 | rspec-rails (3.9.0)
193 | actionpack (>= 3.0)
194 | activesupport (>= 3.0)
195 | railties (>= 3.0)
196 | rspec-core (~> 3.9.0)
197 | rspec-expectations (~> 3.9.0)
198 | rspec-mocks (~> 3.9.0)
199 | rspec-support (~> 3.9.0)
200 | rspec-support (3.9.2)
201 | ruby_dep (1.5.0)
202 | rubyzip (2.1.0)
203 | sass (3.7.4)
204 | sass-listen (~> 4.0.0)
205 | sass-listen (4.0.0)
206 | rb-fsevent (~> 0.9, >= 0.9.4)
207 | rb-inotify (~> 0.9, >= 0.9.7)
208 | sass-rails (5.1.0)
209 | railties (>= 5.2.0)
210 | sass (~> 3.1)
211 | sprockets (>= 2.8, < 4.0)
212 | sprockets-rails (>= 2.0, < 4.0)
213 | tilt (>= 1.1, < 3)
214 | sassc (2.2.1)
215 | ffi (~> 1.9)
216 | sassc-rails (2.1.2)
217 | railties (>= 4.0.0)
218 | sassc (>= 2.0)
219 | sprockets (> 3.0)
220 | sprockets-rails
221 | tilt
222 | selenium-webdriver (3.142.7)
223 | childprocess (>= 0.5, < 4.0)
224 | rubyzip (>= 1.2.2)
225 | spring (2.1.0)
226 | spring-watcher-listen (2.0.1)
227 | listen (>= 2.7, < 4.0)
228 | spring (>= 1.2, < 3.0)
229 | sprockets (3.7.2)
230 | concurrent-ruby (~> 1.0)
231 | rack (> 1, < 3)
232 | sprockets-rails (3.2.1)
233 | actionpack (>= 4.0)
234 | activesupport (>= 4.0)
235 | sprockets (>= 3.0.0)
236 | thor (1.0.1)
237 | thread_safe (0.3.6)
238 | tilt (2.0.10)
239 | turbolinks (5.2.1)
240 | turbolinks-source (~> 5.2)
241 | turbolinks-source (5.2.0)
242 | tzinfo (1.2.6)
243 | thread_safe (~> 0.1)
244 | uglifier (4.2.0)
245 | execjs (>= 0.3.0, < 3)
246 | warden (1.2.8)
247 | rack (>= 2.0.6)
248 | web-console (3.7.0)
249 | actionview (>= 5.0)
250 | activemodel (>= 5.0)
251 | bindex (>= 0.4.0)
252 | railties (>= 5.0)
253 | webdrivers (4.2.0)
254 | nokogiri (~> 1.6)
255 | rubyzip (>= 1.3.0)
256 | selenium-webdriver (>= 3.0, < 4.0)
257 | websocket-driver (0.7.1)
258 | websocket-extensions (>= 0.1.0)
259 | websocket-extensions (0.1.4)
260 | will_paginate (3.2.1)
261 | xpath (3.2.0)
262 | nokogiri (~> 1.8)
263 |
264 | PLATFORMS
265 | ruby
266 |
267 | DEPENDENCIES
268 | activesupport (~> 5.2.4.1)
269 | bootsnap (>= 1.1.0)
270 | bootstrap (~> 4.3.1)
271 | bootstrap-will_paginate (= 1.0.0)
272 | byebug
273 | capybara (>= 3.30.0)
274 | coffee-rails (~> 4.2)
275 | devise (~> 4.7, >= 4.7.1)
276 | faker (~> 1.6, >= 1.6.6)
277 | font-awesome-rails (~> 4.7, >= 4.7.0.5)
278 | font-awesome-sass (~> 5.11.2)
279 | hirb
280 | jbuilder (~> 2.5)
281 | listen (>= 3.0.5, < 3.2)
282 | omniauth-facebook (~> 5.0)
283 | pg (>= 0.18, < 2.0)
284 | puma (~> 3.11)
285 | rack (~> 2.0, >= 2.0.8)
286 | rails (~> 5.2.3)
287 | rspec-rails
288 | sass-rails (~> 5.0)
289 | selenium-webdriver
290 | spring
291 | spring-watcher-listen (~> 2.0.0)
292 | turbolinks (~> 5)
293 | tzinfo-data
294 | uglifier (>= 1.3.0)
295 | web-console (>= 3.3.0)
296 | webdrivers (~> 4.0)
297 |
298 | RUBY VERSION
299 | ruby 2.6.4p104
300 |
301 | BUNDLED WITH
302 | 2.0.2
303 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Use this hook to configure devise mailer, warden hooks and so forth.
4 | # Many of these configuration options can be set straight in your model.
5 | Devise.setup do |config|
6 | # The secret key used by Devise. Devise uses this key to generate
7 | # random tokens. Changing this key will render invalid all existing
8 | # confirmation, reset password and unlock tokens in the database.
9 | # Devise will use the `secret_key_base` as its `secret_key`
10 | # by default. You can change it below and use your own secret key.
11 | # config.secret_key = 'a665e0b8559c28a3cd793e0d6aa36822780b941169d2d46a95d79bc76
12 | # c4d38b003c307dd601b679d8ae60510449e265244af73fd01202c69d8cb75692a60fedc'
13 |
14 | # ==> Controller configuration
15 | # Configure the parent class to the devise controllers.
16 | # config.parent_controller = 'DeviseController'
17 |
18 | # ==> Mailer Configuration
19 | # Configure the e-mail address which will be shown in Devise::Mailer,
20 | # note that it will be overwritten if you use your own mailer class
21 | # with default "from" parameter.
22 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
23 |
24 | # Configure the class responsible to send e-mails.
25 | # config.mailer = 'Devise::Mailer'
26 |
27 | # Configure the parent class responsible to send e-mails.
28 | # config.parent_mailer = 'ActionMailer::Base'
29 |
30 | # ==> ORM configuration
31 | # Load and configure the ORM. Supports :active_record (default) and
32 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
33 | # available as additional gems.
34 | require 'devise/orm/active_record'
35 |
36 | # ==> Configuration for any authentication mechanism
37 | # Configure which keys are used when authenticating a user. The default is
38 | # just :email. You can configure it to use [:username, :subdomain], so for
39 | # authenticating a user, both parameters are required. Remember that those
40 | # parameters are used only when authenticating and not when retrieving from
41 | # session. If you need permissions, you should implement that in a before filter.
42 | # You can also supply a hash where the value is a boolean determining whether
43 | # or not authentication should be aborted when the value is not present.
44 | # config.authentication_keys = [:email]
45 |
46 | # Configure parameters from the request object used for authentication. Each entry
47 | # given should be a request method and it will automatically be passed to the
48 | # find_for_authentication method and considered in your model lookup. For instance,
49 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
50 | # The same considerations mentioned for authentication_keys also apply to request_keys.
51 | # config.request_keys = []
52 |
53 | # Configure which authentication keys should be case-insensitive.
54 | # These keys will be downcased upon creating or modifying a user and when used
55 | # to authenticate or find a user. Default is :email.
56 | config.case_insensitive_keys = [:email]
57 |
58 | # Configure which authentication keys should have whitespace stripped.
59 | # These keys will have whitespace before and after removed upon creating or
60 | # modifying a user and when used to authenticate or find a user. Default is :email.
61 | config.strip_whitespace_keys = [:email]
62 |
63 | # Tell if authentication through request.params is enabled. True by default.
64 | # It can be set to an array that will enable params authentication only for the
65 | # given strategies, for example, `config.params_authenticatable = [:database]` will
66 | # enable it only for database (email + password) authentication.
67 | # config.params_authenticatable = true
68 |
69 | # Tell if authentication through HTTP Auth is enabled. False by default.
70 | # It can be set to an array that will enable http authentication only for the
71 | # given strategies, for example, `config.http_authenticatable = [:database]` will
72 | # enable it only for database authentication. The supported strategies are:
73 | # :database = Support basic authentication with authentication key + password
74 | # config.http_authenticatable = true
75 | # config.http_authenticatable = [:database]
76 | # If 401 status code should be returned for AJAX requests. True by default.
77 | # config.http_authenticatable_on_xhr = true
78 |
79 | # The realm used in Http Basic Authentication. 'Application' by default.
80 | # config.http_authentication_realm = 'Application'
81 |
82 | # It will change confirmation, password recovery and other workflows
83 | # to behave the same regardless if the e-mail provided was right or wrong.
84 | # Does not affect registerable.
85 | # config.paranoid = true
86 |
87 | # By default Devise will store the user in session. You can skip storage for
88 | # particular strategies by setting this option.
89 | # Notice that if you are skipping storage for all authentication paths, you
90 | # may want to disable generating routes to Devise's sessions controller by
91 | # passing skip: :sessions to `devise_for` in your config/routes.rb
92 | config.skip_session_storage = [:http_auth]
93 |
94 | # By default, Devise cleans up the CSRF token on authentication to
95 | # avoid CSRF token fixation attacks. This means that, when using AJAX
96 | # requests for sign in and sign up, you need to get a new CSRF token
97 | # from the server. You can disable this option at your own risk.
98 | # config.clean_up_csrf_token_on_authentication = true
99 |
100 | # When false, Devise will not attempt to reload routes on eager load.
101 | # This can reduce the time taken to boot the app but if your application
102 | # requires the Devise mappings to be loaded during boot time the application
103 | # won't boot properly.
104 | # config.reload_routes = true
105 |
106 | # ==> Configuration for :database_authenticatable
107 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If
108 | # using other algorithms, it sets how many times you want the password to be hashed.
109 | #
110 | # Limiting the stretches to just one in testing will increase the performance of
111 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
112 | # a value less than 10 in other environments. Note that, for bcrypt (the default
113 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
114 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
115 | config.stretches = Rails.env.test? ? 1 : 11
116 |
117 | # Set up a pepper to generate the hashed password.
118 | # config.pepper = 'ff4e3002573751ecb6f5362cfc272d895a4c71d12e68f9f1333a987f542d598c36416ac86ee2c
119 | # a6d8fe3132bbcd2509de4e3a445880e250b3584eac39573ce54'
120 |
121 | # Send a notification to the original email when the user's email is changed.
122 | # config.send_email_changed_notification = false
123 |
124 | # Send a notification email when the user's password is changed.
125 | # config.send_password_change_notification = false
126 |
127 | # ==> Configuration for :confirmable
128 | # A period that the user is allowed to access the website even without
129 | # confirming their account. For instance, if set to 2.days, the user will be
130 | # able to access the website for two days without confirming their account,
131 | # access will be blocked just in the third day.
132 | # You can also set it to nil, which will allow the user to access the website
133 | # without confirming their account.
134 | # Default is 0.days, meaning the user cannot access the website without
135 | # confirming their account.
136 | # config.allow_unconfirmed_access_for = 2.days
137 |
138 | # A period that the user is allowed to confirm their account before their
139 | # token becomes invalid. For example, if set to 3.days, the user can confirm
140 | # their account within 3 days after the mail was sent, but on the fourth day
141 | # their account can't be confirmed with the token any more.
142 | # Default is nil, meaning there is no restriction on how long a user can take
143 | # before confirming their account.
144 | # config.confirm_within = 3.days
145 |
146 | # If true, requires any email changes to be confirmed (exactly the same way as
147 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
148 | # db field (see migrations). Until confirmed, new email is stored in
149 | # unconfirmed_email column, and copied to email column on successful confirmation.
150 | config.reconfirmable = true
151 |
152 | # Defines which key will be used when confirming an account
153 | # config.confirmation_keys = [:email]
154 |
155 | # ==> Configuration for :rememberable
156 | # The time the user will be remembered without asking for credentials again.
157 | # config.remember_for = 2.weeks
158 |
159 | # Invalidates all the remember me tokens when the user signs out.
160 | config.expire_all_remember_me_on_sign_out = true
161 |
162 | # If true, extends the user's remember period when remembered via cookie.
163 | # config.extend_remember_period = false
164 |
165 | # Options to be passed to the created cookie. For instance, you can set
166 | # secure: true in order to force SSL only cookies.
167 | # config.rememberable_options = {}
168 |
169 | # ==> Configuration for :validatable
170 | # Range for password length.
171 | config.password_length = 6..128
172 |
173 | # Email regex used to validate email formats. It simply asserts that
174 | # one (and only one) @ exists in the given string. This is mainly
175 | # to give user feedback and not to assert the e-mail validity.
176 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
177 |
178 | # ==> Configuration for :timeoutable
179 | # The time you want to timeout the user session without activity. After this
180 | # time the user will be asked for credentials again. Default is 30 minutes.
181 | # config.timeout_in = 30.minutes
182 |
183 | # ==> Configuration for :lockable
184 | # Defines which strategy will be used to lock an account.
185 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
186 | # :none = No lock strategy. You should handle locking by yourself.
187 | # config.lock_strategy = :failed_attempts
188 |
189 | # Defines which key will be used when locking and unlocking an account
190 | # config.unlock_keys = [:email]
191 |
192 | # Defines which strategy will be used to unlock an account.
193 | # :email = Sends an unlock link to the user email
194 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
195 | # :both = Enables both strategies
196 | # :none = No unlock strategy. You should handle unlocking by yourself.
197 | # config.unlock_strategy = :both
198 |
199 | # Number of authentication tries before locking an account if lock_strategy
200 | # is failed attempts.
201 | # config.maximum_attempts = 20
202 |
203 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
204 | # config.unlock_in = 1.hour
205 |
206 | # Warn on the last attempt before the account is locked.
207 | # config.last_attempt_warning = true
208 |
209 | # ==> Configuration for :recoverable
210 | #
211 | # Defines which key will be used when recovering the password for an account
212 | # config.reset_password_keys = [:email]
213 |
214 | # Time interval you can reset your password with a reset password key.
215 | # Don't put a too small interval or your users won't have the time to
216 | # change their passwords.
217 | config.reset_password_within = 6.hours
218 |
219 | # When set to false, does not sign a user in automatically after their password is
220 | # reset. Defaults to true, so a user is signed in automatically after a reset.
221 | # config.sign_in_after_reset_password = true
222 |
223 | # ==> Configuration for :encryptable
224 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
225 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
226 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
227 | # for default behavior) and :restful_authentication_sha1 (then you should set
228 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
229 | #
230 | # Require the `devise-encryptable` gem when using anything other than bcrypt
231 | # config.encryptor = :sha512
232 |
233 | # ==> Scopes configuration
234 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
235 | # "users/sessions/new". It's turned off by default because it's slower if you
236 | # are using only default views.
237 | # config.scoped_views = false
238 |
239 | # Configure the default scope given to Warden. By default it's the first
240 | # devise role declared in your routes (usually :user).
241 | # config.default_scope = :user
242 |
243 | # Set this configuration to false if you want /users/sign_out to sign out
244 | # only the current scope. By default, Devise signs out all scopes.
245 | # config.sign_out_all_scopes = true
246 |
247 | # ==> Navigation configuration
248 | # Lists the formats that should be treated as navigational. Formats like
249 | # :html, should redirect to the sign in page when the user does not have
250 | # access, but formats like :xml or :json, should return 401.
251 | #
252 | # If you have any extra navigational formats, like :iphone or :mobile, you
253 | # should add them to the navigational formats lists.
254 | #
255 | # The "*/*" below is required to match Internet Explorer requests.
256 | # config.navigational_formats = ['*/*', :html]
257 |
258 | # The default HTTP method used to sign out a resource. Default is :delete.
259 | config.sign_out_via = :delete
260 |
261 | # ==> OmniAuth
262 | # Add a new OmniAuth provider. Check the wiki for more information on setting
263 | # up on your models and hooks.
264 | <<<<<<< HEAD
265 | config.omniauth :facebook, '3451859098219919', 'a640e7cb82ee1f48b88775ad4686525c', callback_url: 'https://secret-sea-76381.herokuapp.com/auth/facebook/callback'
266 |
267 | # ==> Warden configuration
268 | =======
269 | # config.omniauth :facebook, '3451859098219919', 'a640e7cb82ee1f48b88775ad4686525c', callback_url: 'https://secret-sea-76381.herokuapp.com/auth/facebook/callback'
270 | config.omniauth :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'], callback_url: 'https://secret-sea-76381.herokuapp.com/users/auth/facebook/callback'
271 | # ==> Warden configuration
272 | >>>>>>> master
273 | # If you want to use other strategies, that are not supported by Devise, or
274 | # change the failure app, you can configure them inside the config.warden block.
275 | #
276 | # config.warden do |manager|
277 | # manager.intercept_401 = false
278 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
279 | # end
280 |
281 | # ==> Mountable engine configurations
282 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
283 | # is mountable, there are some extra configurations to be taken into account.
284 | # The following options are available, assuming the engine is mounted as:
285 | #
286 | # mount MyEngine, at: '/my_engine'
287 | #
288 | # The router that invoked `devise_for`, in the example above, would be:
289 | # config.router_name = :my_engine
290 | #
291 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
292 | # so you need to do it manually. For the users scope, it would be:
293 | # config.omniauth_path_prefix = '/my_engine/users/auth'
294 |
295 | # ==> Turbolinks configuration
296 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
297 | #
298 | # ActiveSupport.on_load(:devise_failure_app) do
299 | # include Turbolinks::Controller
300 | # end
301 |
302 | # ==> Configuration for :registerable
303 |
304 | # When set to false, does not sign a user in automatically after their password is
305 | # changed. Defaults to true, so a user is signed in automatically after changing a password.
306 | # config.sign_in_after_change_password = true
307 | end
308 |
--------------------------------------------------------------------------------