-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
175 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
language: ruby | ||
|
||
rvm: | ||
- 2.3.0 | ||
|
||
- 2.3.0 | ||
services: | ||
- postgresql | ||
|
||
- postgresql | ||
before_script: | ||
- psql -c 'create database pict_test;' -U postgres | ||
|
||
- psql -c 'create database pict_test;' -U postgres | ||
after_success: | ||
- coveralls | ||
- coveralls | ||
env: | ||
matrix: | ||
- secure: lrZjuraTZ5i1TlNw0mFdNiApUkpDwapz/2iTyz67p7ZDjYseCe5iS2Cwp9zffNrtmareoIQKg4KcWwKczalBGD6J6PX2mwxx6uMCEgoymi/f5F2fgO4eFsOUkAg+ESGo1sp5WKXRhdFbVCEiKn0V3QWMxyKudvKuI+JkvquKKDkDe9BQxRrBPcf0w4yl2zK5wV3in/O7Byp/fRJTDf+z2KFDXLHo6+ADxBVvq9hJYR59Za/IIl0WpI8rSF2Ocuw/WgAB3bKEnsx0UsEEqeqPXIchfnV7nXEaN5OXHtxGCwYeSc+srttmrmGbFV5wfdKHKzcBm165doTh89TWB484EKXd6LoKkM8WJ1DzE3W6TD4Clrj/TD/3cTRpCcov5qTUBIfmSZd2dmigY4QrlqysPLQf8uJ0KJSdsbXQPM58AEDCxfFpiTG3kYhPpmQtMptZIqjbFm28K/uKBs4a1RWnTcOSS5qQS9PQRnseMykE1VbuCxrRLVaMj0ioIW2YOj3D5uNogw52TOw6ZHLlGqkKpKMbXXlpJd8nKSiRdUPzNNn2y7EWf0baz7e9PduTsu+tziMXGOxTQyI/PzuuqcggASd5ZtLTf78S5agfkBblJqKeN/cqeWgeHpVpv/mqpOSzacAZ7edL0Y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Bd3w5uEb7aZLCCnGC3h5es9HWSP2PMQ2L6miDO3lkwuvkagCSHmR1vMwi+MoeIWmTlOUEsPZWFqgX9MYezostUn1eoadSgY8qarFwIKkM6/l4tZhBF1vI/qxGEx7uHC/M2Y69eHN7fcHozm2GmyScGl9ObX74F3ahpcTSaB0+M7V/May03QAYvOT9pKitcJn9XI5wodSskqxuAcxQfo1tclqk+dVF8INS5yAekROCoEyxrIK21/nlFZ4fSbVMIKWzCu3ToWIN1e8+n5x6NnY+7ZrcKLXVcNaykFMYy6oXOzGq1GRIg/yWF5aHtNKxPjQwOwl9CC11uhq/De30OoMKt4QmOOk= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
def facebook | ||
|
||
@user = User.from_omniauth(request.env["omniauth.auth"]) | ||
|
||
if @user.persisted? | ||
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated | ||
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? | ||
else | ||
session["devise.facebook_data"] = request.env["omniauth.auth"] | ||
redirect_to new_user_registration_url | ||
end | ||
end | ||
|
||
def failure | ||
redirect_to root_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
class User < ApplicationRecord | ||
# Include default devise modules. Others available are: | ||
# :confirmable, :lockable, :timeoutable and :omniauthable | ||
|
||
devise :omniauthable, :omniauth_providers => [:facebook] | ||
|
||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :trackable, :validatable | ||
def self.from_omniauth(auth) | ||
where(provider: auth.provider, uid: auth.uid).first_or_create do |user| | ||
user.email = auth.info.email | ||
user.password = Devise.friendly_token[0,20] | ||
user.name = auth.info.name # assuming the user model has a name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddOmniauthToUsers < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :users, :provider, :string | ||
add_column :users, :uid, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUsernameToUserModel < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :users, :name, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "rails_helper" | ||
|
||
feature "user login" do | ||
|
||
context "user not signed in" do | ||
scenario "login and logout links are present" do | ||
visit "/" | ||
expect(page).to have_content("Sign up") | ||
expect(page).to have_content("Sign in") | ||
end | ||
end | ||
|
||
scenario "should not see 'sign out' link" do | ||
visit('/') | ||
expect(page).not_to have_link('Sign out') | ||
end | ||
end | ||
|
||
context "user signed in on the homepage" do | ||
before do | ||
sign_up(email: 'test@example.com', password: '123456') | ||
visit('/') | ||
end | ||
|
||
scenario "should see 'sign out' link and user email in nav bar" do | ||
expect(page).to have_link('Sign out') | ||
expect(page).to have_content("Signed in as: test@example.com") | ||
end | ||
|
||
scenario "should not see a 'sign in' link and a 'sign up' link" do | ||
expect(page).not_to have_link('Sign in') | ||
expect(page).not_to have_link('Sign up') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters