8 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | APP_PATH = File.expand_path('../config/application', __dir__)
5 | require_relative '../config/boot'
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Load the Rails application.
4 | require_relative 'application'
5 |
6 | # Initialize the Rails application.
7 | Rails.application.initialize!
8 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/likes.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the likes controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/spec/factories/comments.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | FactoryBot.define do
4 | factory :comment do
5 | user
6 | post
7 |
8 | content { 'This is a test comment' }
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/spec/models/like_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe Like, type: :model do
6 | it { should belong_to(:user) }
7 | it { should belong_to(:likeable) }
8 | end
9 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/comments.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the comments controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/friendships.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the friendships controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/spec/controllers/comments_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe CommentsController, type: :controller do
6 | it { should use_before_action(:find_comment) }
7 | end
8 |
--------------------------------------------------------------------------------
/spec/controllers/users_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe UsersController, type: :controller do
6 | it { should use_before_action(:get_created_posts) }
7 | end
8 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new mime types for use in respond_to blocks:
5 | # Mime::Type.register "text/richtext", :rtf
6 |
--------------------------------------------------------------------------------
/spec/controllers/likes_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe LikesController, type: :controller do
6 | it { should use_before_action(:find_resource_to_be_liked) }
7 | end
8 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/omniauth_callbacks.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the omniauth_callbacks controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/spec/controllers/application_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe ApplicationController, type: :controller do
6 | it { should use_before_action(:authenticate_user!) }
7 | end
8 |
--------------------------------------------------------------------------------
/app/assets/javascripts/likes.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/posts.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/users.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/views/application/_flash_notice.html.erb:
--------------------------------------------------------------------------------
1 | <% if notice %>
2 |
<%= notice %>
3 | <% end %>
4 | <% if alert %>
5 |
<%= alert %>
6 | <% end %>
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10 | channel_prefix: fbreplica_production
11 |
--------------------------------------------------------------------------------
/app/assets/javascripts/comments.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/friendships.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/omniauth_callbacks.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/db/migrate/20191118172624_add_omniauth_to_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddOmniauthToUsers < ActiveRecord::Migration[5.2]
4 | def change
5 | add_column :users, :provider, :string
6 | add_column :users, :uid, :string
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/confirmation_instructions.html.erb:
--------------------------------------------------------------------------------
1 |
Welcome <%= @email %>!
2 |
3 |
You can confirm your account email through the link below:
4 |
5 |
<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
6 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
4 |
5 | require 'bundler/setup' # Set up gems listed in the Gemfile.
6 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
7 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Add your own tasks in files placed in lib/tasks ending in .rake,
4 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5 |
6 | require_relative 'config/application'
7 |
8 | Rails.application.load_tasks
9 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Configure sensitive parameters which will be filtered from the log file.
6 | Rails.application.config.filter_parameters += [:password]
7 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/db/migrate/20191027212546_create_posts.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreatePosts < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :posts do |t|
6 | t.text :content, null: false
7 | t.references :user
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/views/users/_bio.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= image_tag 'user-bio.png' %> Intro
3 |
Fullname: <%= user.fullname %>
4 |
Email Address: <%= user.email %>
5 |
DOB: <%= user.dob %>
6 |
Gender: <%= user.sex %>
7 |
8 |
--------------------------------------------------------------------------------
/db/migrate/20191102165159_create_likes.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateLikes < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :likes do |t|
6 | t.references :likeable, polymorphic: true
7 | t.references :user
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Comment < ApplicationRecord
4 | belongs_to :user
5 | belongs_to :post
6 | has_many :likes, as: :likeable, dependent: :destroy
7 |
8 | default_scope -> { order(created_at: :desc).includes(:user) }
9 |
10 | validates :content, presence: true
11 | end
12 |
--------------------------------------------------------------------------------
/app/views/application/_footer.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # ActiveSupport::Reloader.to_prepare do
5 | # ApplicationController.renderer.defaults.merge!(
6 | # http_host: 'example.org',
7 | # https: false
8 | # )
9 | # end
10 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Specify a serializer for the signed and encrypted cookie jars.
6 | # Valid options are :json, :marshal, and :hybrid.
7 | Rails.application.config.action_dispatch.cookies_serializer = :json
8 |
--------------------------------------------------------------------------------
/app/views/application/_header.html.erb:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/unlock_instructions.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @resource.email %>!
2 |
3 |
Your account has been locked due to an excessive number of unsuccessful sign in attempts.
4 |
5 |
Click the link below to unlock your account:
6 |
7 |
<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
8 |
--------------------------------------------------------------------------------
/features/user_logout.feature:
--------------------------------------------------------------------------------
1 | Feature: Log current user out
2 | In order to quit the application
3 | As a user
4 | I want to log off from all current activities
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" is logged in
8 |
9 | Scenario: End my session
10 | When I click logout
11 | Then my current session should terminate
--------------------------------------------------------------------------------
/features/user_signup.feature:
--------------------------------------------------------------------------------
1 | Feature: New User Signup
2 | In order to find friends, socialize, create posts, add comments and likes
3 | As a new user
4 | I want to create a new account
5 |
6 | Background:
7 | Given I am on the signup page
8 |
9 | Scenario: Submit valid credentials
10 | When I submit required fields
11 | Then I should see my bio
--------------------------------------------------------------------------------
/spec/controllers/posts_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe PostsController, type: :controller do
6 | it { should use_before_action(:fetch_timeline_posts) }
7 | it { should use_before_action(:initialize_new_post_editor) }
8 | it { should use_before_action(:find_post) }
9 | end
10 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/email_changed.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @email %>!
2 |
3 | <% if @resource.try(:unconfirmed_email?) %>
4 |
We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.
5 | <% else %>
6 |
We're contacting you to notify you that your email has been changed to <%= @resource.email %>.
--------------------------------------------------------------------------------
/db/migrate/20191113152429_create_friendships.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateFriendships < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :friendships do |t|
6 | t.references :user
7 | t.references :friend
8 | t.boolean :confirmed, default: false
9 |
10 | t.timestamps
11 | end
12 | add_index :friendships, %i[user_id friend_id]
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/assets/javascripts/cable.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3 | //
4 | //= require action_cable
5 | //= require_self
6 | //= require_tree ./channels
7 |
8 | (function() {
9 | this.App || (this.App = {});
10 |
11 | App.cable = ActionCable.createConsumer();
12 |
13 | }).call(this);
14 |
--------------------------------------------------------------------------------
/features/user_add_comments.feature:
--------------------------------------------------------------------------------
1 | Feature: User manage comments
2 | In order to add my reactions to posts
3 | As a user
4 | I want to add or remove comments
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" is already logged in
8 | And I can see the first post in my timeline
9 |
10 | Scenario: Add new Comment
11 | When I submit new comment using comment form
12 | Then I should see my comment for first post in timeline
--------------------------------------------------------------------------------
/features/user_remove_comments.feature:
--------------------------------------------------------------------------------
1 | Feature: User manage comments
2 | In order to add my reactions to posts
3 | As a user
4 | I want to add or remove comments
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" is already logged in
8 | And I can see the second post in my timeline
9 |
10 | Scenario: Remove my comment
11 | Given I have added a coment
12 | When I delete comment
13 | Then post comment should no longer exist
--------------------------------------------------------------------------------
/app/views/application/_post_actions.html.erb:
--------------------------------------------------------------------------------
1 |
Someone has requested a link to change your password. You can do this through the link below.
4 |
5 |
<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
6 |
7 |
If you didn't request this, please ignore this email.
8 |
Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | W3awN+RhnrUQ6qUCS+IVkWxJeIvvL1vCXzDMFbIiidx4Jf8desPDxYKVTlnKY6kHlqZEMIIRHaFiB9j4OM9X1DpwAwIh6id9x/ltAwQxO2sRKvD+kNwJajwG8ZCv0gCumyg2CNGXZ40zyCLaFBqxo83mKGs21eDdWiI20AY3Q5r/KbBlUb+4cHM9zocZgzmo0QQBJKUoF5vtU88kbktWZ3YjHj0ta3JBukXMJ8V4Il8h8kDUh7ENnXjxc0lIxc4fz7IME8JQnHyXoGnpUj5TUd+0Ktfu7v75BX5Jhfg+frGmneutJwXMrHT/vuQpvq81UtC52sYyATGObUW6Vy33Pts1Ooe00tuNzH/NKwflFEkFg33qDgM3MD1FhndzmTvJSI2SJ/5pOKukezORkU5JgqPj8f/i1mKXdFNe--W89s/O+12Bjwom8C--OV5zHDtcd5PCU33s1C2zAw==
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6 |
7 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8 | # Rails.backtrace_cleaner.remove_silencers!
9 |
--------------------------------------------------------------------------------
/spec/controllers/friendships_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe FriendshipsController, type: :controller do
6 | it {
7 | should route(:get, '/friends')
8 | .to(action: :index)
9 | }
10 |
11 | it {
12 | should route(:get, '/friend_requests')
13 | .to(action: :friend_requests)
14 | }
15 |
16 | it {
17 | should route(:get, '/mutual_friends')
18 | .to(action: :mutual_friends)
19 | }
20 | end
21 |
--------------------------------------------------------------------------------
/app/views/devise/shared/_error_messages.html.erb:
--------------------------------------------------------------------------------
1 | <% if resource.errors.any? %>
2 |
14 | <% end %>
--------------------------------------------------------------------------------
/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/show.html.erb:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/features/user_manage_posts.feature:
--------------------------------------------------------------------------------
1 | Feature: User manage posts
2 | In order to share my posts with friends
3 | As a user
4 | I want to add, edit, remove posts
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" is already logged in
8 |
9 | Scenario: Add new Post
10 | When I submit new post using post form
11 | Then I should see post in timeline
12 |
13 | Scenario: Edit my Post
14 | When I choose edit post from dropdown menu
15 | And I submit post update
16 | Then post content should be updated
17 |
18 | Scenario: Remove my Post
19 | When I choose delete post from dropdown menu
20 | Then post should no longer exist
--------------------------------------------------------------------------------
/app/views/comments/_comment.html.erb:
--------------------------------------------------------------------------------
1 |
14 | <% end %>
15 |
16 | <%= render "devise/shared/links" %>
17 |
--------------------------------------------------------------------------------
/features/step_definitions/user_add_comments_steps.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Given('I can see the first post in my timeline') do
4 | @post = FactoryBot.build(:post)
5 | within '.new-post' do
6 | fill_in 'post[content]', with: @post.content
7 | click_button 'Post'
8 | end
9 | end
10 |
11 | When('I submit new comment using comment form') do
12 | @comment = FactoryBot.build(:comment)
13 | within '.comment-editor' do
14 | fill_in 'comment[content]', with: @comment.content
15 | click_button 'Comment'
16 | end
17 | end
18 |
19 | Then('I should see my comment for first post in timeline') do
20 | expect(page).to have_content(@comment.content)
21 | end
22 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | users = [
4 | { firstname: 'Nahuel', lastname: 'Castro', email: 'nahukas@gmail.com', dob: 'Sep 26 1984', sex: 'Male' },
5 | { firstname: 'Miguel', lastname: 'Prada', email: 'mapra99@gmail.com', dob: 'Sep 26 2001', sex: 'Male' },
6 | { firstname: 'Tiago', lastname: 'Ferreira', email: 'tiferreira12@gmail.com', dob: 'Dec 12 1987', sex: 'Male' },
7 | { firstname: 'Binary', lastname: 'Shloch', email: 'shloch2007@yahoo.fr', dob: 'Sep 27 1999', sex: 'Custom' },
8 | { firstname: 'Marvelous', lastname: 'Ubani', email: 'marvellousubani@gmail.com', dob: 'Sep 30 1999', sex: 'Custom' }
9 | ]
10 |
11 | users.each do |u|
12 | User.create(u)
13 | end
14 |
--------------------------------------------------------------------------------
/app/controllers/omniauth_callbacks_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class OmniauthCallbacksController < Devise::OmniauthCallbacksController
4 | def facebook
5 | @user = User.from_omniauth(request.env['omniauth.auth'])
6 |
7 | if @user.persisted?
8 | sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
9 | set_flash_message(:notice, :success, kind: 'Facebook') if is_navigational_format?
10 | else
11 | session['devise.facebook_data'] = request.env['omniauth.auth']
12 | redirect_to new_user_registration_url
13 | end
14 | end
15 |
16 | def failure
17 | redirect_to root_path
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/features/step_definitions/user_can_view_friends_steps.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Given('the following users exist in database:') do |acc|
4 | acc.hashes.each do |a|
5 | FactoryBot.create(:user, email: a['email'])
6 | end
7 | end
8 |
9 | When('I find friends') do
10 | click_link 'Find Friends'
11 | end
12 |
13 | Then('I should see a list of users') do
14 | @user2 = User.second
15 | @user3 = User.third
16 | expect(page).to have_content("#{@user2.firstname} #{@user2.lastname}")
17 | expect(page).to have_content("#{@user3.firstname} #{@user3.lastname}")
18 | end
19 |
20 | Then('I should not see my profile') do
21 | expect(page).to_not have_content(@user.email)
22 | end
23 |
--------------------------------------------------------------------------------
/features/step_definitions/user_logout_steps.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Given('a user with email {string} is logged in') do |current_user_email|
4 | @user = FactoryBot.create(:user, email: current_user_email)
5 | visit new_user_session_path
6 | within '.default-user-login' do
7 | fill_in 'user[email]', with: @user.email
8 | fill_in 'user[password]', with: @user.password
9 | click_button 'Log In'
10 | end
11 | end
12 |
13 | When('I click logout') do
14 | within '.dropdown-menu' do
15 | click_link 'Logout'
16 | end
17 | end
18 |
19 | Then('my current session should terminate') do
20 | visit user_path @user
21 | expect(page).not_to have_current_path user_path @user
22 | end
23 |
--------------------------------------------------------------------------------
/features/user_and_friendship_request.feature:
--------------------------------------------------------------------------------
1 | Feature: User and Friendship Requests
2 | In order to make friends
3 | As a user
4 | I want to send or accept friend requests
5 |
6 | Background:
7 | Given the following users exists:
8 | | email |
9 | | "demouser1@onet.com" |
10 | | "user2demo@carry.com" |
11 |
12 | Scenario: Send a friend request
13 | Given "demouser1@onet.com" is logged in
14 | When I send request to "user2demo@carry.com"
15 | Then I should have pending request
16 |
17 | Scenario: Accept friend request
18 | Given the user "user2demo@carry.com" logs in
19 | And I have pending request from "demouser1@onet.com"
20 | When I accept request from "demouser1@onet.com"
21 | Then we should be friends
--------------------------------------------------------------------------------
/spec/models/post_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe Post, type: :model do
6 | context 'Associations' do
7 | it { should belong_to(:user) }
8 | it { should have_many(:comments).dependent(:destroy) }
9 | it { should have_many(:likes).dependent(:destroy) }
10 | end
11 |
12 | context 'validations' do
13 | before do
14 | @post = FactoryBot.create(:post)
15 | end
16 | it 'invalid when post content is null or empty' do
17 | post2 = FactoryBot.build(:post, content: nil)
18 | expect(post2).to_not be_valid
19 | end
20 |
21 | it 'is valid when post content has value' do
22 | expect(@post).to be_valid
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationController < ActionController::Base
4 | before_action :authenticate_user!
5 | before_action :configure_permitted_parameters, if: :devise_controller?
6 | include PostsHelper
7 |
8 | def set_flash_notice(type, message)
9 | flash[type.to_sym] = message
10 | end
11 |
12 | def initialize_new_post_editor
13 | @post = Post.new
14 | end
15 |
16 | def back_with_anchored_resource(anchor: '')
17 | "#{request.referrer}##{anchor}"
18 | end
19 |
20 | protected
21 |
22 | def configure_permitted_parameters
23 | devise_parameter_sanitizer
24 | .permit(:sign_up, keys: %i[firstname lastname dob sex])
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Version of your assets, change this if you want to expire all your assets.
6 | Rails.application.config.assets.version = '1.0'
7 |
8 | # Add additional assets to the asset load path.
9 | # Rails.application.config.assets.paths << Emoji.images_path
10 | # Add Yarn node_modules folder to the asset load path.
11 | Rails.application.config.assets.paths << Rails.root.join('node_modules')
12 |
13 | # Precompile additional assets.
14 | # application.js, application.css, and all non-JS/CSS in the app/assets
15 | # folder are already added.
16 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
17 |
--------------------------------------------------------------------------------
/spec/models/comment_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe Comment, type: :model do
6 | context 'Associations' do
7 | it { should belong_to(:user) }
8 | it { should belong_to(:post) }
9 | it { should have_many(:likes).dependent(:destroy) }
10 | end
11 |
12 | context 'validations' do
13 | before do
14 | @comment = FactoryBot.create(:comment)
15 | end
16 | it 'is invalid when comment content is null or empty' do
17 | comment2 = FactoryBot.build(:comment, content: nil)
18 | expect(comment2).to_not be_valid
19 | end
20 |
21 | it 'is valid when comment content has value' do
22 | expect(@comment).to be_valid
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe User, type: :model do
6 | context 'Associations' do
7 | it { should have_many(:posts).dependent(:destroy) }
8 | it { should have_many(:comments).dependent(:destroy) }
9 | it { should have_many(:likes).dependent(:destroy) }
10 | it { should have_many(:friendships).dependent(:destroy) }
11 | it {
12 | should have_many(:friends)
13 | .through(:friendships)
14 | }
15 | end
16 |
17 | it 'callbacks generate_gravatar_for_user before create' do
18 | @user = FactoryBot.build(:user)
19 | expect(@user.image_link).to be_nil
20 |
21 | @user.save
22 | expect(@user.image_link).to_not be_nil
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new inflection rules using the following format. Inflections
5 | # are locale specific, and you may define rules for as many different
6 | # locales as you wish. All of these examples are active by default:
7 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
8 | # inflect.plural /^(ox)$/i, '\1en'
9 | # inflect.singular /^(ox)en/i, '\1'
10 | # inflect.irregular 'person', 'people'
11 | # inflect.uncountable %w( fish sheep )
12 | # end
13 |
14 | # These inflection rules are supported but not enabled by default:
15 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
16 | # inflect.acronym 'RESTful'
17 | # end
18 |
--------------------------------------------------------------------------------
/goorm.manifest:
--------------------------------------------------------------------------------
1 | {"author":"101357057702460288589_d9ri5_google","name":"fbreplica","type":"ruby","detailedtype":"rubyonrails","description":" A managed container to practise, Ruby on Rails, Heroku deployment, AWS deployment, CI using Docker / Kubernetes, APIs design, hosted database (SQL, NoSQL)","date":"2019-07-02T14:46:30.000Z","plugins":{"goorm.plugin.ruby":[{"plugin.ruby.main":"index","plugin.ruby.source_path":"","plugin.ruby.run_on":"server","plugin.ruby.run_option":"s -b 0.0.0.0 -p $USER_PORT","plugin.ruby.log_path":"./server.log","name":"ruby"}]},"is_user_plugin":false,"storage":"container","project_domain":[{"id":"101357057702460288589_d9ri5_google","url":"devise-auth-saas.run.goorm.io","port":"3000"}],"author_email":"johnsonsirv@gmail.com","author_name":"Victor Okeugo","ignore_patterns":[]}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore all logfiles and tempfiles.
11 | /log/*
12 | /tmp/*
13 | !/log/.keep
14 | !/tmp/.keep
15 |
16 | # Ignore uploaded files in development
17 | /storage/*
18 | !/storage/.keep
19 |
20 | /node_modules
21 | /yarn-error.log
22 |
23 | /public/assets
24 | .byebug_history
25 |
26 | # Ignore master key for decrypting credentials and more.
27 | /config/master.key
28 |
29 | # Ignore application configuration
30 | /config/application.yml
31 |
--------------------------------------------------------------------------------
/features/user_and_likes.feature:
--------------------------------------------------------------------------------
1 | Feature: User and likes
2 | In order to add my reactions to posts and comments
3 | As a user
4 | I want to like and unlike posts or comments
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" is already logged in
8 | And I can see a post in my timeline
9 | And I can see a comment for this post
10 |
11 | Scenario: Like a Post
12 | When I like post
13 | Then post likes should contain user
14 |
15 | Scenario: Unlike a Post
16 | Given I have liked post
17 | When I unlike post
18 | Then post likes should not contain user
19 |
20 | Scenario: Like a Comment
21 | When I like post comment
22 | Then comment likes should contain user
23 |
24 | Scenario: Unlike a Comment
25 | Given I have liked comment
26 | When I unlike comment
27 | Then comment likes should not contain user
--------------------------------------------------------------------------------
/app/views/users/_user_timeline_banner.html.erb:
--------------------------------------------------------------------------------
1 |
23 | <% end %>
24 |
25 | <%= render "devise/shared/links" %>
26 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | require 'fileutils'
5 | include FileUtils
6 |
7 | # path to your application root.
8 | APP_ROOT = File.expand_path('..', __dir__)
9 |
10 | def system!(*args)
11 | system(*args) || abort("\n== Command #{args} failed ==")
12 | end
13 |
14 | chdir APP_ROOT do
15 | # This script is a way to update your development environment automatically.
16 | # Add necessary update steps to this file.
17 |
18 | puts '== Installing dependencies =='
19 | system! 'gem install bundler --conservative'
20 | system('bundle check') || system!('bundle install')
21 |
22 | # Install JavaScript dependencies if using Yarn
23 | # system('bin/yarn')
24 |
25 | puts "\n== Updating database =="
26 | system! 'bin/rails db:migrate'
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! 'bin/rails log:clear tmp:clear'
30 |
31 | puts "\n== Restarting application server =="
32 | system! 'bin/rails restart'
33 | end
34 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/features/user_login.feature:
--------------------------------------------------------------------------------
1 | Feature: Login as an existing User
2 | In order to view, add posts, comments and likes
3 | As a user
4 | I want to log in with my email
5 |
6 | Background:
7 | Given a user with email "demouser@onet.com" exists in database
8 | And I access the login form
9 |
10 | Scenario: Valid Login Credentials
11 | When I submit correct login credentials
12 | Then I should see my timeline
13 |
14 | Scenario: Incorrect Login Credentials
15 | When I submit incorrect login credentials
16 | Then I should see login error
17 |
18 | Scenario: Login through the navigation form
19 | When I access navbar login form
20 | And I submit correct credentials through the navbar form
21 | Then I should also see my timeline
22 |
23 | Scenario: Access Restricted pages
24 | When I access post timeline
25 | Then I should be redirected to login
26 |
27 | @omniauth_test
28 | Scenario: Sign in with facebook
29 | Given I am signed in with facebook
30 | Then I should see user firstname "omniauthfirstname"
31 |
32 |
--------------------------------------------------------------------------------
/app/controllers/comments_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CommentsController < ApplicationController
4 | before_action :find_comment, only: [:destroy]
5 |
6 | def create
7 | save_comment comment_params
8 | end
9 |
10 | def destroy
11 | @comment.destroy
12 | set_flash_notice 'notice', 'Comment deleted'
13 | redirect_to back_with_anchored_resource anchor: @comment.id
14 | end
15 |
16 | private
17 |
18 | def save_comment(comment_params)
19 | @comment = current_user.add_new_comment(comment_params)
20 | if @comment.errors.any?
21 | set_flash_notice 'alert', 'Comment could not be saved. Did you forget to write something?'
22 | else
23 | set_flash_notice 'notice', 'Comment added successfully'
24 | end
25 |
26 | redirect_back fallback_location: root_path
27 | end
28 |
29 | def comment_params
30 | params.require(:comment).permit(:content, :post_id)
31 | end
32 |
33 | def find_comment
34 | @comment = Comment.find(params[:id])
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/views/devise/sessions/_login_form.html.erb:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/db/migrate/20191027154938_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class DeviseCreateUsers < ActiveRecord::Migration[5.2]
4 | def change
5 | create_table :users do |t|
6 | ## Database authenticatable
7 | t.string :email, null: false, default: ''
8 | t.string :encrypted_password, null: false, default: ''
9 |
10 | # Registrable
11 | t.string :firstname
12 | t.string :lastname
13 | t.string :sex
14 | t.date :dob
15 | t.string :image_link, null: false
16 |
17 | ## Recoverable
18 | t.string :reset_password_token
19 | t.datetime :reset_password_sent_at
20 |
21 | ## Rememberable
22 | t.datetime :remember_created_at
23 |
24 | ## Trackable
25 | # t.integer :sign_in_count, default: 0, null: false
26 | # t.datetime :current_sign_in_at
27 | # t.datetime :last_sign_in_at
28 | # t.inet :current_sign_in_ip
29 | # t.inet :last_sign_in_ip
30 |
31 | ## Confirmable
32 | # t.string :confirmation_token
33 | # t.datetime :confirmed_at
34 | # t.datetime :confirmation_sent_at
35 | # t.string :unconfirmed_email # Only if using reconfirmable
36 |
37 | ## Lockable
38 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
39 | # t.string :unlock_token # Only if unlock strategy is :email or :both
40 | # t.datetime :locked_at
41 |
42 | t.timestamps null: false
43 | end
44 |
45 | add_index :users, :email, unique: true
46 | add_index :users, :reset_password_token, unique: true
47 | # add_index :users, :confirmation_token, unique: true
48 | # add_index :users, :unlock_token, unique: true
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/features/step_definitions/user_and_likes_steps.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Given('I can see a post in my timeline') do
4 | @post = FactoryBot.create(:post)
5 | within '.new-post' do
6 | fill_in 'post[content]', with: @post.content
7 | click_button 'Post'
8 | end
9 | end
10 |
11 | Given('I can see a comment for this post') do
12 | @comment = FactoryBot.build(:comment)
13 | within '.comment-editor' do
14 | fill_in 'comment[content]', with: @comment.content
15 | click_button 'Comment'
16 | end
17 | end
18 |
19 | When('I like post') do
20 | within '.post-social-actions' do
21 | click_link 'Like'
22 | end
23 | end
24 |
25 | Then('post likes should contain user') do
26 | liker = Post.last.likes.find_by(user_id: @user)
27 | expect(liker).to be_valid
28 | end
29 |
30 | Given('I have liked post') do
31 | within '.post-social-actions' do
32 | click_link 'Like'
33 | end
34 | end
35 |
36 | When('I unlike post') do
37 | within '.post-social-actions' do
38 | click_link 'Unlike'
39 | end
40 | end
41 |
42 | Then('post likes should not contain user') do
43 | liker = Post.last.likes.find_by(user_id: @user)
44 | expect(liker).to be_nil
45 | end
46 |
47 | When('I like post comment') do
48 | within '.comment-actions' do
49 | click_link 'Like'
50 | end
51 | end
52 |
53 | Then('comment likes should contain user') do
54 | liker = Comment.last.likes.find_by(user_id: @user)
55 | expect(liker).to be_valid
56 | end
57 |
58 | Given('I have liked comment') do
59 | within '.comment-actions' do
60 | click_link 'Like'
61 | end
62 | end
63 |
64 | When('I unlike comment') do
65 | within '.comment-actions' do
66 | click_link 'Unlike'
67 | end
68 | end
69 |
70 | Then('comment likes should not contain user') do
71 | liker = Comment.last.likes.find_by(user_id: @user)
72 | expect(liker).to be_nil
73 | end
74 |
--------------------------------------------------------------------------------
/app/models/friendship.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Friendship < ApplicationRecord
4 | belongs_to :user
5 | belongs_to :friend, class_name: 'User'
6 |
7 | scope :pending_requests, -> { where(confirmed: false) }
8 | scope :confirmed, -> { where(confirmed: true) }
9 |
10 | default_scope -> { includes(:user) }
11 |
12 | validate :self_irreflexive
13 | validates :user, presence: true
14 | validates :friend, presence: true, uniqueness: { scope: :user }
15 |
16 | def self.confirm_friend_request_for(user, friend)
17 | friendship = where(user: user, friend: friend)
18 | .or(where(user: friend, friend: user))
19 |
20 | transaction do
21 | friendship.update(confirmed: true)
22 | user.friendships.create(friend: friendship.first.user, confirmed: true)
23 | end
24 | end
25 |
26 | def self.remove_friendship_between(user, friend)
27 | friendship = where(user: user, friend: friend)
28 | .or(where(user: friend, friend: user))
29 |
30 | friendship.destroy_all
31 | end
32 |
33 | def self.unconfirmed_friends_for(user)
34 | pending_requests.where(friend: user).map(&:user)
35 | end
36 |
37 | def self.confirmed_friends_for(user)
38 | confirmed.where(user: user).map(&:friend)
39 | end
40 |
41 | def self.mutual_friends_between(user, other_user)
42 | find_by_sql(["SELECT friendships.*
43 | FROM friendships
44 | WHERE friendships.user_id = ?
45 | AND friendships.friend_id
46 | IN ( SELECT friendships.friend_id
47 | FROM friendships
48 | WHERE friendships.user_id = ?
49 | AND confirmed = ?
50 | );", user.id, other_user.id, true]).map(&:friend)
51 | end
52 |
53 | private
54 |
55 | def self_irreflexive
56 | msg = "can't be friends with self"
57 | errors.add(:friendship_is_irreflexive!, msg) if user == friend
58 | end
59 | end
60 |
--------------------------------------------------------------------------------
/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.4.0'
7 |
8 | gem 'rails', '~> 5.2.3'
9 | gem 'pg', '>= 0.18', '< 2.0'
10 | gem 'puma', '~> 3.12'
11 |
12 | # UI
13 | gem 'bootstrap', '~> 4.3.1'
14 | gem 'font-awesome-rails'
15 | gem 'jquery-rails'
16 | gem 'sass-rails', '~> 5.0'
17 | gem 'uglifier', '>= 1.3.0'
18 |
19 | gem 'mini_racer', platforms: :ruby
20 | gem 'coffee-rails', '~> 4.2'
21 |
22 | gem 'turbolinks', '~> 5'
23 |
24 | gem 'jbuilder', '~> 2.5'
25 | # Use Redis adapter to run Action Cable in production
26 | # gem 'redis', '~> 4.0'
27 | # Use ActiveModel has_secure_password
28 | # gem 'bcrypt', '~> 3.1.7'
29 |
30 | # Use ActiveStorage variant
31 | # gem 'mini_magick', '~> 4.8'
32 |
33 | # Use Capistrano for deployment
34 | # gem 'capistrano-rails', group: :development
35 |
36 | gem 'bootsnap', '>= 1.1.0', require: false
37 |
38 | # Authenticaion and Configuration
39 | gem 'devise'
40 | gem 'figaro'
41 | gem 'omniauth-facebook'
42 |
43 | # util
44 | gem 'faker'
45 | gem 'hirb'
46 |
47 | group :development, :test do
48 | gem 'byebug', platforms: %i[mri mingw x64_mingw]
49 | gem 'factory_bot_rails'
50 | gem 'rspec-rails'
51 | end
52 |
53 | group :development do
54 | gem 'listen', '>= 3.0.5', '< 3.2'
55 | gem 'web-console', '>= 3.3.0'
56 | gem 'bullet', '~> 5.7', '>= 5.7.5'
57 | gem 'guard'
58 | gem 'guard-cucumber'
59 | gem 'guard-rspec', require: false
60 | gem 'spring'
61 | gem 'spring-watcher-listen', '~> 2.0.0'
62 | end
63 |
64 | group :test do
65 | gem 'cucumber-rails', require: false
66 | gem 'capybara', '>= 2.15'
67 | gem 'database_cleaner'
68 | gem 'selenium-webdriver'
69 | gem 'shoulda-callback-matchers', '~> 1.1.1'
70 | gem 'shoulda-matchers'
71 | gem 'webdrivers', '~> 4.0'
72 | end
73 |
74 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
75 |
--------------------------------------------------------------------------------
/app/views/application/_homepage_shortcuts_right.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Friend Requests
4 |
5 |
6 | <% if request?(current_user) %>
7 | <% friend_requests_for(current_user).each do |friend| %>
8 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/features/step_definitions/user_login_steps.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Given('a user with email {string} exists in database') do |valid_email|
4 | @user = FactoryBot.create(:user, email: valid_email)
5 | end
6 |
7 | Given('I access the login form') do
8 | visit new_user_session_path
9 | end
10 |
11 | When('I submit correct login credentials') do
12 | within '.default-user-login' do
13 | fill_in 'user[email]', with: @user.email
14 | fill_in 'user[password]', with: @user.password
15 | click_button 'Log In'
16 | end
17 | end
18 |
19 | Then('I should see my timeline') do
20 | expect(page).to have_current_path root_path
21 | end
22 |
23 | When('I submit incorrect login credentials') do
24 | within '.default-user-login' do
25 | fill_in 'user[email]', with: 'incorrect@email.com'
26 | fill_in 'user[password]', with: 'incorrectpassword'
27 | click_button 'Log In'
28 | end
29 | end
30 |
31 | Then('I should see login error') do
32 | expect(page).to have_current_path new_user_session_path
33 | end
34 |
35 | When('I access navbar login form') do
36 | visit new_user_registration_path
37 | end
38 |
39 | When('I submit correct credentials through the navbar form') do
40 | within '.navbar' do
41 | fill_in 'user[email]', with: @user.email
42 | fill_in 'user[password]', with: @user.password
43 | click_button 'Log In'
44 | end
45 | end
46 |
47 | Then('I should also see my timeline') do
48 | expect(page).to have_current_path root_path
49 | end
50 |
51 | When('I access post timeline') do
52 | visit posts_path
53 | end
54 |
55 | Then('I should be redirected to login') do
56 | expect(page).to have_current_path new_user_session_path
57 | end
58 |
59 | Given('I am signed in with facebook') do
60 | visit user_facebook_omniauth_authorize_path
61 | end
62 |
63 | Then('I should see user firstname {string}') do |firstname|
64 | expect(page).to have_text(firstname.titlecase)
65 | end
66 |
--------------------------------------------------------------------------------
/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/environments/test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | Rails.application.configure do
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 |
31 | # Store uploaded files on the local file system in a temporary directory
32 | config.active_storage.service = :test
33 |
34 | config.action_mailer.perform_caching = false
35 |
36 | # Tell Action Mailer not to deliver emails to the real world.
37 | # The :test delivery method accumulates sent emails in the
38 | # ActionMailer::Base.deliveries array.
39 | config.action_mailer.delivery_method = :test
40 |
41 | # Print deprecation notices to the stderr.
42 | config.active_support.deprecation = :stderr
43 |
44 | # Raises error for missing translations
45 | # config.action_view.raise_on_missing_translations = true
46 | end
47 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/_signup_form.html.erb:
--------------------------------------------------------------------------------
1 |
50 | By clicking Sign Up, you agree to our fictious Terms and Conditions.
51 | We understand about Data or Cookie Policy, but this is just a demo app.
52 |
21 | This project is a minimal implementation of a social networking app that clones the core features of facebook. The word Nzuko is a local name meaning gathering. Visit the Live Url .
22 |
23 | It explores functionalities like:
24 |
25 | - Create new account
26 | - Writing posts and comments (text only)
27 | - Liking posts and comments
28 | - Sending / accepting / canceling friend requests
29 | - Notifications for new friend request.
30 | - User authentication using `Devise` and OAuth (omniauth-facebook)
31 | - User authorization for posts and comments
32 |
43 |
44 | ### Future implementations:
45 |
46 | - Profile management is minimal but will be extended
47 | - Real-time news feed
48 | - Real-time notifications - from new posts, friend request and ads
49 | - Instant Messaging
50 | - Sharing and Tagging of posts
51 | - Support for multimedia content - videos, images and more
52 | - Additional social login - google, instagram
53 |
54 | ### Built with:
55 |
56 | - Ruby 2.4.0
57 | - Rails 5.2.3
58 | - PostgreSQL
59 | - Cucumber & Capybara (Integration tests)
60 | - RSpec (Unit test)
61 | - Devise / Omniauth-facebook (authentication)
62 | - Bootstrap (UI)
63 | - Guard / Figaro
64 | - FactoryBot (FactoryGirl) / Faker
65 |
66 | ### Installation
67 |
68 | ##### Clone this repository from your terminal
69 |
70 | > `git clone https://github.com/johnsonsirv/facebook-clone.git`
71 |
72 | ###### Database setup
73 |
74 | in your terminal run
75 |
76 | > `rake db:setup`
77 | >
78 | > `rake db:migrate db:test:prepare`
79 |
80 | ###### Run test suite
81 |
82 | ###### run integration level tests (user stories located in `features/`)
83 |
84 | in your terminal run
85 |
86 | > `cucumber features`
87 |
88 | ###### run unit level tests (specs location `spec/`)
89 |
90 | in your terminal run
91 |
92 | > `rspec spec`
93 |
94 | ### Usage
95 |
96 | on your terminal run
97 |
98 | > `rails server`
99 |
100 | Visit `localhost://3000`
101 |
102 | ### Contributor(s)
103 |
104 | [Victor Okeugo](https://angel.co/u/victorokeugo/)
105 |
106 | - Github: [@johnsonsirv](https://github.com/johnsonsirv)
107 | - Twitter: [@vokeugo](https://twitter.com/@vokeugo/)
108 | - Email: [okeugo.victor.c@gmail.com]()
109 |
110 | ### Contributing
111 |
112 | 1. Fork it (https://github.com/johnsonsirv/facebook-clone/fork)
113 | 2. Create your feature branch (git checkout -b feature/[choose-a-name])
114 | 3. Commit your changes (git commit -m 'What this commit will fix/add')
115 | 4. Push to the branch (git push origin feature/[chosen name])
116 | 5. Create a new Pull Request
117 | > You can also create [issues](https://github.com/johnsonsirv/facebook-clone/issues)
118 |
--------------------------------------------------------------------------------
/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 = "fbreplica_#{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 |
--------------------------------------------------------------------------------
/.rubocop_todo.yml:
--------------------------------------------------------------------------------
1 | # This configuration was generated by
2 | # `rubocop --auto-gen-config`
3 | # on 2019-11-20 15:42:57 +0000 using RuboCop version 0.76.0.
4 | # The point is for the user to remove these configuration records
5 | # one by one as the offenses are removed from the code base.
6 | # Note that changes in the inspected code, or installation of new
7 | # versions of RuboCop, may require this file to be generated again.
8 |
9 | # Offense count: 4
10 | # Cop supports --auto-correct.
11 | # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
12 | # Include: **/*.gemfile, **/Gemfile, **/gems.rb
13 | Bundler/OrderedGems:
14 | Exclude:
15 | - 'Gemfile'
16 |
17 | # Offense count: 8
18 | # Cop supports --auto-correct.
19 | # Configuration parameters: EnforcedStyle, IndentationWidth.
20 | # SupportedStyles: with_first_argument, with_fixed_indentation
21 | Layout/AlignArguments:
22 | Exclude:
23 | - 'app/helpers/comments_helper.rb'
24 | - 'app/helpers/posts_helper.rb'
25 | - 'app/helpers/users_helper.rb'
26 |
27 | # Offense count: 1
28 | # Cop supports --auto-correct.
29 | Layout/EmptyLineAfterGuardClause:
30 | Exclude:
31 | - 'app/controllers/likes_controller.rb'
32 |
33 | # Offense count: 5
34 | # Cop supports --auto-correct.
35 | # Configuration parameters: EnforcedStyle.
36 | # SupportedStyles: normal, indented_internal_methods
37 | Layout/IndentationConsistency:
38 | Exclude:
39 | - 'app/controllers/likes_controller.rb'
40 | - 'app/controllers/posts_controller.rb'
41 |
42 | # Offense count: 12
43 | # Cop supports --auto-correct.
44 | # Configuration parameters: Width, IgnoredPatterns.
45 | Layout/IndentationWidth:
46 | Exclude:
47 | - 'app/controllers/likes_controller.rb'
48 |
49 | # Offense count: 1
50 | # Cop supports --auto-correct.
51 | # Configuration parameters: AllowDoxygenCommentStyle.
52 | Layout/LeadingCommentSpace:
53 | Exclude:
54 | - 'config/environments/development.rb'
55 |
56 | # Offense count: 5
57 | # Cop supports --auto-correct.
58 | # Configuration parameters: EnforcedStyle, IndentationWidth.
59 | # SupportedStyles: aligned, indented, indented_relative_to_receiver
60 | Layout/MultilineMethodCallIndentation:
61 | Exclude:
62 | - 'app/models/post.rb'
63 |
64 | # Offense count: 28
65 | # Cop supports --auto-correct.
66 | # Configuration parameters: IndentationWidth.
67 | Layout/Tab:
68 | Exclude:
69 | - 'app/controllers/likes_controller.rb'
70 |
71 | # Offense count: 21
72 | # Cop supports --auto-correct.
73 | # Configuration parameters: AllowInHeredoc.
74 | Layout/TrailingWhitespace:
75 | Exclude:
76 | - 'app/controllers/likes_controller.rb'
77 | - 'app/helpers/posts_helper.rb'
78 | - 'app/helpers/users_helper.rb'
79 | - 'config/environments/development.rb'
80 |
81 | # Offense count: 1
82 | # Configuration parameters: AllowSafeAssignment.
83 | Lint/AssignmentInCondition:
84 | Exclude:
85 | - 'app/models/user.rb'
86 |
87 | # Offense count: 1
88 | Lint/UselessAssignment:
89 | Exclude:
90 | - 'features/step_definitions/user_signup_steps.rb'
91 |
92 | # Offense count: 1
93 | Metrics/AbcSize:
94 | Max: 17
95 |
96 | # Offense count: 4
97 | # Configuration parameters: CountComments, ExcludedMethods.
98 | # ExcludedMethods: refine
99 | Metrics/BlockLength:
100 | Max: 56
101 |
102 | # Offense count: 1
103 | # Configuration parameters: CountComments, ExcludedMethods.
104 | Metrics/MethodLength:
105 | Max: 15
106 |
107 | # Offense count: 1
108 | Naming/AccessorMethodName:
109 | Exclude:
110 | - 'app/controllers/users_controller.rb'
111 |
112 | # Offense count: 28
113 | Style/Documentation:
114 | Enabled: false
115 |
116 | # Offense count: 4
117 | # Cop supports --auto-correct.
118 | Style/IfUnlessModifier:
119 | Exclude:
120 | - 'lib/tasks/cucumber.rake'
121 | - 'spec/rails_helper.rb'
122 |
123 | # Offense count: 2
124 | Style/MixinUsage:
125 | Exclude:
126 | - 'bin/setup'
127 | - 'bin/update'
128 |
129 | # Offense count: 3
130 | # Cop supports --auto-correct.
131 | Style/MultilineIfModifier:
132 | Exclude:
133 | - 'app/helpers/comments_helper.rb'
134 | - 'app/helpers/posts_helper.rb'
135 |
136 | # Offense count: 101
137 | # Cop supports --auto-correct.
138 | # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
139 | # URISchemes: http, https
140 | Metrics/LineLength:
141 | Max: 158
142 |
--------------------------------------------------------------------------------
/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 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5 | # The generated `.rspec` file contains `--require spec_helper` which will cause
6 | # this file to always be loaded, without a need to explicitly require it in any
7 | # files.
8 | #
9 | # Given that it is always loaded, you are encouraged to keep this file as
10 | # light-weight as possible. Requiring heavyweight dependencies from this file
11 | # will add to the boot time of your test suite on EVERY test run, even for an
12 | # individual file that may not need all of that loaded. Instead, consider making
13 | # a separate helper file that requires the additional dependencies and performs
14 | # the additional setup, and require it from the spec files that actually need
15 | # it.
16 | #
17 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18 | RSpec.configure do |config|
19 | # rspec-expectations config goes here. You can use an alternate
20 | # assertion/expectation library such as wrong or the stdlib/minitest
21 | # assertions if you prefer.
22 | config.expect_with :rspec do |expectations|
23 | # This option will default to `true` in RSpec 4. It makes the `description`
24 | # and `failure_message` of custom matchers include text for helper methods
25 | # defined using `chain`, e.g.:
26 | # be_bigger_than(2).and_smaller_than(4).description
27 | # # => "be bigger than 2 and smaller than 4"
28 | # ...rather than:
29 | # # => "be bigger than 2"
30 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31 | end
32 |
33 | # rspec-mocks config goes here. You can use an alternate test double
34 | # library (such as bogus or mocha) by changing the `mock_with` option here.
35 | config.mock_with :rspec do |mocks|
36 | # Prevents you from mocking or stubbing a method that does not exist on
37 | # a real object. This is generally recommended, and will default to
38 | # `true` in RSpec 4.
39 | mocks.verify_partial_doubles = true
40 | end
41 |
42 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43 | # have no way to turn it off -- the option exists only for backwards
44 | # compatibility in RSpec 3). It causes shared context metadata to be
45 | # inherited by the metadata hash of host groups and examples, rather than
46 | # triggering implicit auto-inclusion in groups with matching metadata.
47 | config.shared_context_metadata_behavior = :apply_to_host_groups
48 |
49 | # The settings below are suggested to provide a good initial experience
50 | # with RSpec, but feel free to customize to your heart's content.
51 | # # This allows you to limit a spec run to individual examples or groups
52 | # # you care about by tagging them with `:focus` metadata. When nothing
53 | # # is tagged with `:focus`, all examples get run. RSpec also provides
54 | # # aliases for `it`, `describe`, and `context` that include `:focus`
55 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56 | # config.filter_run_when_matching :focus
57 | #
58 | # # Allows RSpec to persist some state between runs in order to support
59 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
60 | # # you configure your source control system to ignore this file.
61 | # config.example_status_persistence_file_path = "spec/examples.txt"
62 | #
63 | # # Limits the available syntax to the non-monkey patched syntax that is
64 | # # recommended. For more details, see:
65 | # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66 | # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67 | # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68 | # config.disable_monkey_patching!
69 | #
70 | # # Many RSpec users commonly either run the entire suite or an individual
71 | # # file, and it's useful to allow more verbose output when running an
72 | # # individual spec file.
73 | # if config.files_to_run.one?
74 | # # Use the documentation formatter for detailed output,
75 | # # unless a formatter has already been configured
76 | # # (e.g. via a command-line flag).
77 | # config.default_formatter = "doc"
78 | # end
79 | #
80 | # # Print the 10 slowest examples and example groups at the
81 | # # end of the spec run, to help surface which specs are running
82 | # # particularly slow.
83 | # config.profile_examples = 10
84 | #
85 | # # Run specs in random order to surface order dependencies. If you find an
86 | # # order dependency and want to debug it, you can fix the order by providing
87 | # # the seed, which is printed after each run.
88 | # # --seed 1234
89 | # config.order = :random
90 | #
91 | # # Seed global randomization in this process using the `--seed` CLI option.
92 | # # Setting this allows you to use `--seed` to deterministically reproduce
93 | # # test failures related to randomization by passing the same `--seed` value
94 | # # as the one that triggered the failure.
95 | # Kernel.srand config.seed
96 | end
97 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (5.2.3)
5 | actionpack (= 5.2.3)
6 | nio4r (~> 2.0)
7 | websocket-driver (>= 0.6.1)
8 | actionmailer (5.2.3)
9 | actionpack (= 5.2.3)
10 | actionview (= 5.2.3)
11 | activejob (= 5.2.3)
12 | mail (~> 2.5, >= 2.5.4)
13 | rails-dom-testing (~> 2.0)
14 | actionpack (5.2.3)
15 | actionview (= 5.2.3)
16 | activesupport (= 5.2.3)
17 | rack (~> 2.0)
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.3)
22 | activesupport (= 5.2.3)
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.3)
28 | activesupport (= 5.2.3)
29 | globalid (>= 0.3.6)
30 | activemodel (5.2.3)
31 | activesupport (= 5.2.3)
32 | activerecord (5.2.3)
33 | activemodel (= 5.2.3)
34 | activesupport (= 5.2.3)
35 | arel (>= 9.0)
36 | activestorage (5.2.3)
37 | actionpack (= 5.2.3)
38 | activerecord (= 5.2.3)
39 | marcel (~> 0.3.1)
40 | activesupport (5.2.3)
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.0)
49 | execjs
50 | backports (3.15.0)
51 | bcrypt (3.1.13)
52 | bindex (0.8.1)
53 | bootsnap (1.4.5)
54 | msgpack (~> 1.0)
55 | bootstrap (4.3.1)
56 | autoprefixer-rails (>= 9.1.0)
57 | popper_js (>= 1.14.3, < 2)
58 | sassc-rails (>= 2.0.0)
59 | builder (3.2.3)
60 | bullet (5.9.0)
61 | activesupport (>= 3.0.0)
62 | uniform_notifier (~> 1.11)
63 | byebug (11.0.1)
64 | capybara (3.29.0)
65 | addressable
66 | mini_mime (>= 0.1.3)
67 | nokogiri (~> 1.8)
68 | rack (>= 1.6.0)
69 | rack-test (>= 0.6.3)
70 | regexp_parser (~> 1.5)
71 | xpath (~> 3.2)
72 | childprocess (3.0.0)
73 | coderay (1.1.2)
74 | coffee-rails (4.2.2)
75 | coffee-script (>= 2.2.0)
76 | railties (>= 4.0.0)
77 | coffee-script (2.4.1)
78 | coffee-script-source
79 | execjs
80 | coffee-script-source (1.12.2)
81 | concurrent-ruby (1.1.5)
82 | crass (1.0.5)
83 | cucumber (3.1.2)
84 | builder (>= 2.1.2)
85 | cucumber-core (~> 3.2.0)
86 | cucumber-expressions (~> 6.0.1)
87 | cucumber-wire (~> 0.0.1)
88 | diff-lcs (~> 1.3)
89 | gherkin (~> 5.1.0)
90 | multi_json (>= 1.7.5, < 2.0)
91 | multi_test (>= 0.1.2)
92 | cucumber-core (3.2.1)
93 | backports (>= 3.8.0)
94 | cucumber-tag_expressions (~> 1.1.0)
95 | gherkin (~> 5.0)
96 | cucumber-expressions (6.0.1)
97 | cucumber-rails (1.8.0)
98 | capybara (>= 2.12, < 4)
99 | cucumber (>= 3.0.2, < 4)
100 | mime-types (>= 2.0, < 4)
101 | nokogiri (~> 1.8)
102 | railties (>= 4.2, < 7)
103 | cucumber-tag_expressions (1.1.1)
104 | cucumber-wire (0.0.1)
105 | database_cleaner (1.7.0)
106 | devise (4.7.1)
107 | bcrypt (~> 3.0)
108 | orm_adapter (~> 0.1)
109 | railties (>= 4.1.0)
110 | responders
111 | warden (~> 1.2.3)
112 | diff-lcs (1.3)
113 | erubi (1.9.0)
114 | execjs (2.7.0)
115 | factory_bot (5.1.1)
116 | activesupport (>= 4.2.0)
117 | factory_bot_rails (5.1.1)
118 | factory_bot (~> 5.1.0)
119 | railties (>= 4.2.0)
120 | faker (2.6.0)
121 | i18n (>= 1.6, < 1.8)
122 | faraday (0.17.0)
123 | multipart-post (>= 1.2, < 3)
124 | ffi (1.11.1)
125 | figaro (1.1.1)
126 | thor (~> 0.14)
127 | font-awesome-rails (4.7.0.5)
128 | railties (>= 3.2, < 6.1)
129 | formatador (0.2.5)
130 | gherkin (5.1.0)
131 | globalid (0.4.2)
132 | activesupport (>= 4.2.0)
133 | guard (2.15.1)
134 | formatador (>= 0.2.4)
135 | listen (>= 2.7, < 4.0)
136 | lumberjack (>= 1.0.12, < 2.0)
137 | nenv (~> 0.1)
138 | notiffany (~> 0.0)
139 | pry (>= 0.9.12)
140 | shellany (~> 0.0)
141 | thor (>= 0.18.1)
142 | guard-compat (1.2.1)
143 | guard-cucumber (1.5.4)
144 | cucumber (>= 1.3.0)
145 | guard-compat (~> 1.0)
146 | nenv (~> 0.1)
147 | guard-rspec (4.7.3)
148 | guard (~> 2.1)
149 | guard-compat (~> 1.1)
150 | rspec (>= 2.99.0, < 4.0)
151 | hashie (3.6.0)
152 | hirb (0.7.3)
153 | i18n (1.7.0)
154 | concurrent-ruby (~> 1.0)
155 | jbuilder (2.9.1)
156 | activesupport (>= 4.2.0)
157 | jquery-rails (4.3.5)
158 | rails-dom-testing (>= 1, < 3)
159 | railties (>= 4.2.0)
160 | thor (>= 0.14, < 2.0)
161 | jwt (2.2.1)
162 | libv8 (7.3.492.27.1)
163 | listen (3.1.5)
164 | rb-fsevent (~> 0.9, >= 0.9.4)
165 | rb-inotify (~> 0.9, >= 0.9.7)
166 | ruby_dep (~> 1.2)
167 | loofah (2.3.1)
168 | crass (~> 1.0.2)
169 | nokogiri (>= 1.5.9)
170 | lumberjack (1.0.13)
171 | mail (2.7.1)
172 | mini_mime (>= 0.1.1)
173 | marcel (0.3.3)
174 | mimemagic (~> 0.3.2)
175 | method_source (0.9.2)
176 | mime-types (3.3)
177 | mime-types-data (~> 3.2015)
178 | mime-types-data (3.2019.1009)
179 | mimemagic (0.3.3)
180 | mini_mime (1.0.2)
181 | mini_portile2 (2.4.0)
182 | mini_racer (0.2.6)
183 | libv8 (>= 6.9.411)
184 | minitest (5.12.2)
185 | msgpack (1.3.1)
186 | multi_json (1.14.1)
187 | multi_test (0.1.2)
188 | multi_xml (0.6.0)
189 | multipart-post (2.1.1)
190 | nenv (0.3.0)
191 | nio4r (2.5.2)
192 | nokogiri (1.10.8)
193 | mini_portile2 (~> 2.4.0)
194 | notiffany (0.1.3)
195 | nenv (~> 0.1)
196 | shellany (~> 0.0)
197 | oauth2 (1.4.2)
198 | faraday (>= 0.8, < 2.0)
199 | jwt (>= 1.0, < 3.0)
200 | multi_json (~> 1.3)
201 | multi_xml (~> 0.5)
202 | rack (>= 1.2, < 3)
203 | omniauth (1.9.0)
204 | hashie (>= 3.4.6, < 3.7.0)
205 | rack (>= 1.6.2, < 3)
206 | omniauth-facebook (5.0.0)
207 | omniauth-oauth2 (~> 1.2)
208 | omniauth-oauth2 (1.6.0)
209 | oauth2 (~> 1.1)
210 | omniauth (~> 1.9)
211 | orm_adapter (0.5.0)
212 | pg (1.1.4)
213 | popper_js (1.14.5)
214 | pry (0.12.2)
215 | coderay (~> 1.1.0)
216 | method_source (~> 0.9.0)
217 | public_suffix (4.0.1)
218 | puma (3.12.6)
219 | rack (2.0.8)
220 | rack-test (1.1.0)
221 | rack (>= 1.0, < 3)
222 | rails (5.2.3)
223 | actioncable (= 5.2.3)
224 | actionmailer (= 5.2.3)
225 | actionpack (= 5.2.3)
226 | actionview (= 5.2.3)
227 | activejob (= 5.2.3)
228 | activemodel (= 5.2.3)
229 | activerecord (= 5.2.3)
230 | activestorage (= 5.2.3)
231 | activesupport (= 5.2.3)
232 | bundler (>= 1.3.0)
233 | railties (= 5.2.3)
234 | sprockets-rails (>= 2.0.0)
235 | rails-dom-testing (2.0.3)
236 | activesupport (>= 4.2.0)
237 | nokogiri (>= 1.6)
238 | rails-html-sanitizer (1.3.0)
239 | loofah (~> 2.3)
240 | railties (5.2.3)
241 | actionpack (= 5.2.3)
242 | activesupport (= 5.2.3)
243 | method_source
244 | rake (>= 0.8.7)
245 | thor (>= 0.19.0, < 2.0)
246 | rake (13.0.0)
247 | rb-fsevent (0.10.3)
248 | rb-inotify (0.10.0)
249 | ffi (~> 1.0)
250 | regexp_parser (1.6.0)
251 | responders (3.0.0)
252 | actionpack (>= 5.0)
253 | railties (>= 5.0)
254 | rspec (3.9.0)
255 | rspec-core (~> 3.9.0)
256 | rspec-expectations (~> 3.9.0)
257 | rspec-mocks (~> 3.9.0)
258 | rspec-core (3.9.0)
259 | rspec-support (~> 3.9.0)
260 | rspec-expectations (3.9.0)
261 | diff-lcs (>= 1.2.0, < 2.0)
262 | rspec-support (~> 3.9.0)
263 | rspec-mocks (3.9.0)
264 | diff-lcs (>= 1.2.0, < 2.0)
265 | rspec-support (~> 3.9.0)
266 | rspec-rails (3.9.0)
267 | actionpack (>= 3.0)
268 | activesupport (>= 3.0)
269 | railties (>= 3.0)
270 | rspec-core (~> 3.9.0)
271 | rspec-expectations (~> 3.9.0)
272 | rspec-mocks (~> 3.9.0)
273 | rspec-support (~> 3.9.0)
274 | rspec-support (3.9.0)
275 | ruby_dep (1.5.0)
276 | rubyzip (2.0.0)
277 | sass (3.7.4)
278 | sass-listen (~> 4.0.0)
279 | sass-listen (4.0.0)
280 | rb-fsevent (~> 0.9, >= 0.9.4)
281 | rb-inotify (~> 0.9, >= 0.9.7)
282 | sass-rails (5.1.0)
283 | railties (>= 5.2.0)
284 | sass (~> 3.1)
285 | sprockets (>= 2.8, < 4.0)
286 | sprockets-rails (>= 2.0, < 4.0)
287 | tilt (>= 1.1, < 3)
288 | sassc (2.2.1)
289 | ffi (~> 1.9)
290 | sassc-rails (2.1.2)
291 | railties (>= 4.0.0)
292 | sassc (>= 2.0)
293 | sprockets (> 3.0)
294 | sprockets-rails
295 | tilt
296 | selenium-webdriver (3.142.6)
297 | childprocess (>= 0.5, < 4.0)
298 | rubyzip (>= 1.2.2)
299 | shellany (0.0.1)
300 | shoulda-callback-matchers (1.1.4)
301 | activesupport (>= 3)
302 | shoulda-matchers (4.1.2)
303 | activesupport (>= 4.2.0)
304 | spring (2.1.0)
305 | spring-watcher-listen (2.0.1)
306 | listen (>= 2.7, < 4.0)
307 | spring (>= 1.2, < 3.0)
308 | sprockets (3.7.2)
309 | concurrent-ruby (~> 1.0)
310 | rack (> 1, < 3)
311 | sprockets-rails (3.2.1)
312 | actionpack (>= 4.0)
313 | activesupport (>= 4.0)
314 | sprockets (>= 3.0.0)
315 | thor (0.20.3)
316 | thread_safe (0.3.6)
317 | tilt (2.0.10)
318 | turbolinks (5.2.1)
319 | turbolinks-source (~> 5.2)
320 | turbolinks-source (5.2.0)
321 | tzinfo (1.2.5)
322 | thread_safe (~> 0.1)
323 | uglifier (4.2.0)
324 | execjs (>= 0.3.0, < 3)
325 | uniform_notifier (1.13.0)
326 | warden (1.2.8)
327 | rack (>= 2.0.6)
328 | web-console (3.7.0)
329 | actionview (>= 5.0)
330 | activemodel (>= 5.0)
331 | bindex (>= 0.4.0)
332 | railties (>= 5.0)
333 | webdrivers (4.1.3)
334 | nokogiri (~> 1.6)
335 | rubyzip (>= 1.3.0)
336 | selenium-webdriver (>= 3.0, < 4.0)
337 | websocket-driver (0.7.1)
338 | websocket-extensions (>= 0.1.0)
339 | websocket-extensions (0.1.5)
340 | xpath (3.2.0)
341 | nokogiri (~> 1.8)
342 |
343 | PLATFORMS
344 | ruby
345 |
346 | DEPENDENCIES
347 | bootsnap (>= 1.1.0)
348 | bootstrap (~> 4.3.1)
349 | bullet (~> 5.7, >= 5.7.5)
350 | byebug
351 | capybara (>= 2.15)
352 | coffee-rails (~> 4.2)
353 | cucumber-rails
354 | database_cleaner
355 | devise
356 | factory_bot_rails
357 | faker
358 | figaro
359 | font-awesome-rails
360 | guard
361 | guard-cucumber
362 | guard-rspec
363 | hirb
364 | jbuilder (~> 2.5)
365 | jquery-rails
366 | listen (>= 3.0.5, < 3.2)
367 | mini_racer
368 | omniauth-facebook
369 | pg (>= 0.18, < 2.0)
370 | puma (~> 3.12)
371 | rails (~> 5.2.3)
372 | rspec-rails
373 | sass-rails (~> 5.0)
374 | selenium-webdriver
375 | shoulda-callback-matchers (~> 1.1.1)
376 | shoulda-matchers
377 | spring
378 | spring-watcher-listen (~> 2.0.0)
379 | turbolinks (~> 5)
380 | tzinfo-data
381 | uglifier (>= 1.3.0)
382 | web-console (>= 3.3.0)
383 | webdrivers (~> 4.0)
384 |
385 | RUBY VERSION
386 | ruby 2.4.0p0
387 |
388 | BUNDLED WITH
389 | 1.14.6
390 |
--------------------------------------------------------------------------------
/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 = '0acbb63a91a70e1e4feac2fa83379c4279b67e5ee38d8559ad0f0040faf1a1c2c57c6eaa6bb5c85c28800047f6895e0d43c9f3d0c124a4481da1dbab0b9f60c4'
12 |
13 | # ==> Controller configuration
14 | # Configure the parent class to the devise controllers.
15 | # config.parent_controller = 'DeviseController'
16 |
17 | # ==> Mailer Configuration
18 | # Configure the e-mail address which will be shown in Devise::Mailer,
19 | # note that it will be overwritten if you use your own mailer class
20 | # with default "from" parameter.
21 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
22 |
23 | # Configure the class responsible to send e-mails.
24 | # config.mailer = 'Devise::Mailer'
25 |
26 | # Configure the parent class responsible to send e-mails.
27 | # config.parent_mailer = 'ActionMailer::Base'
28 |
29 | # ==> ORM configuration
30 | # Load and configure the ORM. Supports :active_record (default) and
31 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
32 | # available as additional gems.
33 | require 'devise/orm/active_record'
34 |
35 | # ==> Configuration for any authentication mechanism
36 | # Configure which keys are used when authenticating a user. The default is
37 | # just :email. You can configure it to use [:username, :subdomain], so for
38 | # authenticating a user, both parameters are required. Remember that those
39 | # parameters are used only when authenticating and not when retrieving from
40 | # session. If you need permissions, you should implement that in a before filter.
41 | # You can also supply a hash where the value is a boolean determining whether
42 | # or not authentication should be aborted when the value is not present.
43 | # config.authentication_keys = [:email]
44 |
45 | # Configure parameters from the request object used for authentication. Each entry
46 | # given should be a request method and it will automatically be passed to the
47 | # find_for_authentication method and considered in your model lookup. For instance,
48 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
49 | # The same considerations mentioned for authentication_keys also apply to request_keys.
50 | # config.request_keys = []
51 |
52 | # Configure which authentication keys should be case-insensitive.
53 | # These keys will be downcased upon creating or modifying a user and when used
54 | # to authenticate or find a user. Default is :email.
55 | config.case_insensitive_keys = [:email]
56 |
57 | # Configure which authentication keys should have whitespace stripped.
58 | # These keys will have whitespace before and after removed upon creating or
59 | # modifying a user and when used to authenticate or find a user. Default is :email.
60 | config.strip_whitespace_keys = [:email]
61 |
62 | # Tell if authentication through request.params is enabled. True by default.
63 | # It can be set to an array that will enable params authentication only for the
64 | # given strategies, for example, `config.params_authenticatable = [:database]` will
65 | # enable it only for database (email + password) authentication.
66 | # config.params_authenticatable = true
67 |
68 | # Tell if authentication through HTTP Auth is enabled. False by default.
69 | # It can be set to an array that will enable http authentication only for the
70 | # given strategies, for example, `config.http_authenticatable = [:database]` will
71 | # enable it only for database authentication. The supported strategies are:
72 | # :database = Support basic authentication with authentication key + password
73 | # config.http_authenticatable = false
74 |
75 | # If 401 status code should be returned for AJAX requests. True by default.
76 | # config.http_authenticatable_on_xhr = true
77 |
78 | # The realm used in Http Basic Authentication. 'Application' by default.
79 | # config.http_authentication_realm = 'Application'
80 |
81 | # It will change confirmation, password recovery and other workflows
82 | # to behave the same regardless if the e-mail provided was right or wrong.
83 | # Does not affect registerable.
84 | # config.paranoid = true
85 |
86 | # By default Devise will store the user in session. You can skip storage for
87 | # particular strategies by setting this option.
88 | # Notice that if you are skipping storage for all authentication paths, you
89 | # may want to disable generating routes to Devise's sessions controller by
90 | # passing skip: :sessions to `devise_for` in your config/routes.rb
91 | config.skip_session_storage = [:http_auth]
92 |
93 | # By default, Devise cleans up the CSRF token on authentication to
94 | # avoid CSRF token fixation attacks. This means that, when using AJAX
95 | # requests for sign in and sign up, you need to get a new CSRF token
96 | # from the server. You can disable this option at your own risk.
97 | # config.clean_up_csrf_token_on_authentication = true
98 |
99 | # When false, Devise will not attempt to reload routes on eager load.
100 | # This can reduce the time taken to boot the app but if your application
101 | # requires the Devise mappings to be loaded during boot time the application
102 | # won't boot properly.
103 | # config.reload_routes = true
104 |
105 | # ==> Configuration for :database_authenticatable
106 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If
107 | # using other algorithms, it sets how many times you want the password to be hashed.
108 | #
109 | # Limiting the stretches to just one in testing will increase the performance of
110 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
111 | # a value less than 10 in other environments. Note that, for bcrypt (the default
112 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
113 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
114 | config.stretches = Rails.env.test? ? 1 : 11
115 |
116 | # Set up a pepper to generate the hashed password.
117 | # config.pepper = 'e411b71134a512aaa64186569a88c42365633ecfe24ea09662ee0269ca7473c83089412d1e0aa19f554c0f2ce3fb933c66c808a08a1aad68ee16e3b865745ede'
118 |
119 | # Send a notification to the original email when the user's email is changed.
120 | # config.send_email_changed_notification = false
121 |
122 | # Send a notification email when the user's password is changed.
123 | # config.send_password_change_notification = false
124 |
125 | # ==> Configuration for :confirmable
126 | # A period that the user is allowed to access the website even without
127 | # confirming their account. For instance, if set to 2.days, the user will be
128 | # able to access the website for two days without confirming their account,
129 | # access will be blocked just in the third day.
130 | # You can also set it to nil, which will allow the user to access the website
131 | # without confirming their account.
132 | # Default is 0.days, meaning the user cannot access the website without
133 | # confirming their account.
134 | # config.allow_unconfirmed_access_for = 2.days
135 |
136 | # A period that the user is allowed to confirm their account before their
137 | # token becomes invalid. For example, if set to 3.days, the user can confirm
138 | # their account within 3 days after the mail was sent, but on the fourth day
139 | # their account can't be confirmed with the token any more.
140 | # Default is nil, meaning there is no restriction on how long a user can take
141 | # before confirming their account.
142 | # config.confirm_within = 3.days
143 |
144 | # If true, requires any email changes to be confirmed (exactly the same way as
145 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
146 | # db field (see migrations). Until confirmed, new email is stored in
147 | # unconfirmed_email column, and copied to email column on successful confirmation.
148 | config.reconfirmable = true
149 |
150 | # Defines which key will be used when confirming an account
151 | # config.confirmation_keys = [:email]
152 |
153 | # ==> Configuration for :rememberable
154 | # The time the user will be remembered without asking for credentials again.
155 | # config.remember_for = 2.weeks
156 |
157 | # Invalidates all the remember me tokens when the user signs out.
158 | config.expire_all_remember_me_on_sign_out = true
159 |
160 | # If true, extends the user's remember period when remembered via cookie.
161 | # config.extend_remember_period = false
162 |
163 | # Options to be passed to the created cookie. For instance, you can set
164 | # secure: true in order to force SSL only cookies.
165 | # config.rememberable_options = {}
166 |
167 | # ==> Configuration for :validatable
168 | # Range for password length.
169 | config.password_length = 6..128
170 |
171 | # Email regex used to validate email formats. It simply asserts that
172 | # one (and only one) @ exists in the given string. This is mainly
173 | # to give user feedback and not to assert the e-mail validity.
174 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
175 |
176 | # ==> Configuration for :timeoutable
177 | # The time you want to timeout the user session without activity. After this
178 | # time the user will be asked for credentials again. Default is 30 minutes.
179 | # config.timeout_in = 30.minutes
180 |
181 | # ==> Configuration for :lockable
182 | # Defines which strategy will be used to lock an account.
183 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
184 | # :none = No lock strategy. You should handle locking by yourself.
185 | # config.lock_strategy = :failed_attempts
186 |
187 | # Defines which key will be used when locking and unlocking an account
188 | # config.unlock_keys = [:email]
189 |
190 | # Defines which strategy will be used to unlock an account.
191 | # :email = Sends an unlock link to the user email
192 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
193 | # :both = Enables both strategies
194 | # :none = No unlock strategy. You should handle unlocking by yourself.
195 | # config.unlock_strategy = :both
196 |
197 | # Number of authentication tries before locking an account if lock_strategy
198 | # is failed attempts.
199 | # config.maximum_attempts = 20
200 |
201 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
202 | # config.unlock_in = 1.hour
203 |
204 | # Warn on the last attempt before the account is locked.
205 | # config.last_attempt_warning = true
206 |
207 | # ==> Configuration for :recoverable
208 | #
209 | # Defines which key will be used when recovering the password for an account
210 | # config.reset_password_keys = [:email]
211 |
212 | # Time interval you can reset your password with a reset password key.
213 | # Don't put a too small interval or your users won't have the time to
214 | # change their passwords.
215 | config.reset_password_within = 6.hours
216 |
217 | # When set to false, does not sign a user in automatically after their password is
218 | # reset. Defaults to true, so a user is signed in automatically after a reset.
219 | # config.sign_in_after_reset_password = true
220 |
221 | # ==> Configuration for :encryptable
222 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
223 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
224 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
225 | # for default behavior) and :restful_authentication_sha1 (then you should set
226 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
227 | #
228 | # Require the `devise-encryptable` gem when using anything other than bcrypt
229 | # config.encryptor = :sha512
230 |
231 | # ==> Scopes configuration
232 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
233 | # "users/sessions/new". It's turned off by default because it's slower if you
234 | # are using only default views.
235 | # config.scoped_views = false
236 |
237 | # Configure the default scope given to Warden. By default it's the first
238 | # devise role declared in your routes (usually :user).
239 | # config.default_scope = :user
240 |
241 | # Set this configuration to false if you want /users/sign_out to sign out
242 | # only the current scope. By default, Devise signs out all scopes.
243 | # config.sign_out_all_scopes = true
244 |
245 | # ==> Navigation configuration
246 | # Lists the formats that should be treated as navigational. Formats like
247 | # :html, should redirect to the sign in page when the user does not have
248 | # access, but formats like :xml or :json, should return 401.
249 | #
250 | # If you have any extra navigational formats, like :iphone or :mobile, you
251 | # should add them to the navigational formats lists.
252 | #
253 | # The "*/*" below is required to match Internet Explorer requests.
254 | # config.navigational_formats = ['*/*', :html]
255 |
256 | # The default HTTP method used to sign out a resource. Default is :delete.
257 | config.sign_out_via = :delete
258 |
259 | # ==> OmniAuth
260 | # Add a new OmniAuth provider. Check the wiki for more information on setting
261 | # up on your models and hooks.
262 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
263 | config.omniauth :facebook, Figaro.env.facebook_app_id, Figaro.env.facebook_app_secret
264 | # ==> Warden configuration
265 | # If you want to use other strategies, that are not supported by Devise, or
266 | # change the failure app, you can configure them inside the config.warden block.
267 | #
268 | # config.warden do |manager|
269 | # manager.intercept_401 = false
270 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
271 | # end
272 |
273 | # ==> Mountable engine configurations
274 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
275 | # is mountable, there are some extra configurations to be taken into account.
276 | # The following options are available, assuming the engine is mounted as:
277 | #
278 | # mount MyEngine, at: '/my_engine'
279 | #
280 | # The router that invoked `devise_for`, in the example above, would be:
281 | # config.router_name = :my_engine
282 | #
283 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
284 | # so you need to do it manually. For the users scope, it would be:
285 | # config.omniauth_path_prefix = '/my_engine/users/auth'
286 |
287 | # ==> Turbolinks configuration
288 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
289 | #
290 | # ActiveSupport.on_load(:devise_failure_app) do
291 | # include Turbolinks::Controller
292 | # end
293 |
294 | # ==> Configuration for :registerable
295 |
296 | # When set to false, does not sign a user in automatically after their password is
297 | # changed. Defaults to true, so a user is signed in automatically after changing a password.
298 | # config.sign_in_after_change_password = true
299 | end
300 |
--------------------------------------------------------------------------------