[deploy] Update top-header for logged-out user (#9874)
* Create first start at desktop top header updates * Update mobile styling of top header * Stylize sign in widget card * Update nav menu and top bar * Changes based on user being logged-in or not * Uses user_signed_in? on top nav bar * Fix lingering old cloudinary helper method * Trigger CI * Fixes specs * Adds redirect_using_referer_spec, fixes other specs & cleanup * Adds nav-menu.scss to layouts/_styles.html.erb for inline & small edit in referer check * Remove logged-out styles to make it more uniform with logged in * Remove nav-menu.scss file * cleanup markup and JS a little * Fixes FB auth specs to new login links * Makes sure unauthenticated /new redirects back to editor * CI fix Sing in with -> Continue with * Update db/schema.rb * Update db/schema.rb * Update db/schema.rb Co-authored-by: Fernando Valverde <fdov88@gmail.com> Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com> Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
This commit is contained in:
parent
da27a1a41c
commit
54c071856e
19 changed files with 492 additions and 151 deletions
|
|
@ -125,11 +125,14 @@ function initReactions() {
|
|||
}
|
||||
|
||||
function listenForNotificationsBellClick() {
|
||||
setTimeout(function () {
|
||||
document.getElementById('notifications-link').onclick = function () {
|
||||
document.getElementById('notifications-number').classList.add('hidden');
|
||||
};
|
||||
}, 180);
|
||||
var notificationsLink = document.getElementById('notifications-link');
|
||||
if (notificationsLink) {
|
||||
setTimeout(function () {
|
||||
notificationsLink.onclick = function () {
|
||||
document.getElementById('notifications-number').classList.add('hidden');
|
||||
};
|
||||
}, 180);
|
||||
}
|
||||
}
|
||||
|
||||
function initFilter() {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
function initializeSpecialNavigationFunctionality() {
|
||||
var connectLink = document.getElementById('connect-link');
|
||||
var notificationsLink = document.getElementById('notifications-link');
|
||||
var moderationLink = document.getElementById('moderation-link')
|
||||
if (document.getElementById('notifications-container')) {
|
||||
notificationsLink.blur();
|
||||
notificationsLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
notificationsLink.classList.remove('top-bar__link--current');
|
||||
}
|
||||
if (document.getElementById('chat')) {
|
||||
connectLink.blur();
|
||||
connectLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
connectLink.classList.remove('top-bar__link--current');
|
||||
}
|
||||
if (document.getElementById('moderation-page')) {
|
||||
moderationLink.blur();
|
||||
moderationLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
moderationLink.classList.remove('top-bar__link--current');
|
||||
var moderationLink = document.getElementById('moderation-link');
|
||||
|
||||
if (connectLink) {
|
||||
if (document.getElementById('notifications-container')) {
|
||||
notificationsLink.blur();
|
||||
notificationsLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
notificationsLink.classList.remove('top-bar__link--current');
|
||||
}
|
||||
if (document.getElementById('chat')) {
|
||||
connectLink.blur();
|
||||
connectLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
connectLink.classList.remove('top-bar__link--current');
|
||||
}
|
||||
if (document.getElementById('moderation-page')) {
|
||||
moderationLink.blur();
|
||||
moderationLink.classList.add('top-bar__link--current');
|
||||
} else {
|
||||
moderationLink.classList.remove('top-bar__link--current');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
160
app/assets/stylesheets/signin.scss
Normal file
160
app/assets/stylesheets/signin.scss
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
@import 'variables';
|
||||
@import 'config/import';
|
||||
|
||||
.authentication-feed {
|
||||
&__card {
|
||||
display: grid;
|
||||
grid-gap: var(--su-6);
|
||||
padding: var(--su-6);
|
||||
margin: var(--su-3);
|
||||
|
||||
@include generate-box(
|
||||
$level: 1,
|
||||
$bg: #f5f6fe,
|
||||
$border: var(--accent-brand),
|
||||
$color: var(--card-color)
|
||||
);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
padding: var(--su-7);
|
||||
margin: 0 0 var(--su-3) 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__container {
|
||||
@media (min-width: $breakpoint-s) {
|
||||
display: flex;
|
||||
grid-gap: var(--su-7);
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__image-container {
|
||||
width: var(--su-8);
|
||||
height: var(--su-8);
|
||||
margin-bottom: var(--su-2);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
&__image {
|
||||
border-radius: var(--radius);
|
||||
transform: rotate(-10deg);
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__title {
|
||||
color: var(--card-color);
|
||||
font-size: var(--fs-2xl);
|
||||
line-height: var(--lh-tight);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
font-size: var(--fs-3xl);
|
||||
}
|
||||
}
|
||||
|
||||
&__description {
|
||||
color: var(--card-color-secondary);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: grid;
|
||||
grid-gap: var(--su-1);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: max-content;
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.authentication-widget {
|
||||
&__container {
|
||||
padding: var(--su-4);
|
||||
}
|
||||
|
||||
&__image-container {
|
||||
width: var(--su-8);
|
||||
height: var(--su-8);
|
||||
margin-bottom: var(--su-2);
|
||||
}
|
||||
|
||||
&__image {
|
||||
border-radius: var(--radius);
|
||||
transform: rotate(-10deg);
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__title {
|
||||
color: var(--card-color);
|
||||
font-size: var(--fs-xl);
|
||||
line-height: var(--lh-tight);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
font-size: var(--fs-2xl);
|
||||
}
|
||||
}
|
||||
|
||||
&__description {
|
||||
color: var(--card-color-secondary);
|
||||
margin-bottom: var(--su-4);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: grid;
|
||||
grid-gap: var(--su-1);
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
#page-content.registrations {
|
||||
.devise-container {
|
||||
min-height: 480px;
|
||||
padding-top: calc(10vw + 35px);
|
||||
h1 {
|
||||
font-weight: 300;
|
||||
text-align: center;
|
||||
font-family: var(--ff-sans-serif);
|
||||
font-size: 30px;
|
||||
@media screen and (min-width: 520px) {
|
||||
font-size: 50px;
|
||||
}
|
||||
}
|
||||
a.sign-up-link {
|
||||
display: block;
|
||||
margin: 50px auto;
|
||||
width: 280px;
|
||||
max-width: 92%;
|
||||
text-align: center;
|
||||
padding: 20px 0px;
|
||||
border: 1px solid rgb(245, 245, 245);
|
||||
font-family: var(--ff-sans-serif);
|
||||
color: rgb(86, 98, 103);
|
||||
border-radius: 3px;
|
||||
font-size: 22px;
|
||||
img {
|
||||
opacity: 0.7;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 3px;
|
||||
vertical-align: -3px;
|
||||
}
|
||||
&:hover {
|
||||
border: 1px solid rgb(0, 231, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -179,3 +179,49 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.authentication-header {
|
||||
&__container {
|
||||
padding: var(--su-6);
|
||||
}
|
||||
|
||||
&__image-container {
|
||||
width: var(--su-8);
|
||||
height: var(--su-8);
|
||||
margin-bottom: var(--su-2);
|
||||
}
|
||||
|
||||
&__image {
|
||||
border-radius: var(--radius);
|
||||
transform: rotate(-10deg);
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__title {
|
||||
color: var(--card-color);
|
||||
font-size: var(--fs-2xl);
|
||||
line-height: var(--lh-tight);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
font-size: var(--fs-3xl);
|
||||
}
|
||||
}
|
||||
|
||||
&__description {
|
||||
color: var(--card-color-secondary);
|
||||
margin-bottom: var(--su-4);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: grid;
|
||||
grid-gap: var(--su-1);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: max-content;
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,52 @@
|
|||
}
|
||||
}
|
||||
|
||||
.authentication-widget {
|
||||
&__container {
|
||||
padding: var(--su-4);
|
||||
}
|
||||
|
||||
&__image-container {
|
||||
width: var(--su-8);
|
||||
height: var(--su-8);
|
||||
margin-bottom: var(--su-2);
|
||||
}
|
||||
|
||||
&__image {
|
||||
border-radius: var(--radius);
|
||||
transform: rotate(-10deg);
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__title {
|
||||
color: var(--card-color);
|
||||
font-size: var(--fs-xl);
|
||||
line-height: var(--lh-tight);
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
font-size: var(--fs-2xl);
|
||||
}
|
||||
}
|
||||
|
||||
&__description {
|
||||
color: var(--card-color-secondary);
|
||||
margin-bottom: var(--su-4);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: grid;
|
||||
grid-gap: var(--su-1);
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: $breakpoint-s) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-self: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Registration View
|
||||
.registration {
|
||||
border-radius: unset;
|
||||
|
|
|
|||
|
|
@ -66,36 +66,7 @@
|
|||
h4 {
|
||||
margin: 0;
|
||||
}
|
||||
&.signin-cta-widget {
|
||||
border: 1px solid darken($bold-blue, 5%);
|
||||
box-shadow: 5px 6px 0px darken($bold-blue, 15%);
|
||||
padding: 0px 0px;
|
||||
border-radius: 3px;
|
||||
|
||||
header {
|
||||
background: darken($bold-blue, 5%);
|
||||
color: white;
|
||||
padding: 16px 0px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.widget-body {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
padding: 8px 0;
|
||||
|
||||
.login-cta-button {
|
||||
margin: 8px;
|
||||
background-color: $bold-blue;
|
||||
padding: 16px 0;
|
||||
border-radius: 50px;
|
||||
color: $white;
|
||||
text-align: center;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.showing {
|
||||
display: block;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ApplicationController < ActionController::Base
|
|||
# the user to after a successful log in
|
||||
def after_sign_in_path_for(resource)
|
||||
if current_user.saw_onboarding
|
||||
path = request.env["omniauth.origin"] || stored_location_for(resource) || dashboard_path
|
||||
path = stored_location_for(resource) || request.env["omniauth.origin"] || root_path(signin: "true")
|
||||
signin_param = { "signin" => "true" } # the "signin" param is used by the service worker
|
||||
|
||||
uri = Addressable::URI.parse(path)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,12 @@ class ArticlesController < ApplicationController
|
|||
|
||||
@article, needs_authorization = Articles::Builder.call(@user, @tag, @prefill)
|
||||
|
||||
needs_authorization ? authorize(Article) : skip_authorization
|
||||
if needs_authorization
|
||||
authorize(Article)
|
||||
else
|
||||
skip_authorization
|
||||
store_location_for(:user, request.path)
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ class RegistrationsController < Devise::RegistrationsController
|
|||
@registered_users_count = User.registered.estimated_count
|
||||
|
||||
if user_signed_in?
|
||||
redirect_to dashboard_path
|
||||
redirect_to root_path(signin: "true")
|
||||
else
|
||||
if URI(request.referer || "").host == URI(request.base_url).host
|
||||
store_location_for(:user, request.referer)
|
||||
end
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,11 +3,31 @@
|
|||
<aside class="side-bar sidebar-additional showing grid gap-4" id="sidebar-additional">
|
||||
<% unless user_signed_in? || !any_selfserve_auth? %>
|
||||
<section class="crayons-card crayons-card--secondary signin-cta-widget">
|
||||
<header class="crayons-card__header">
|
||||
<h3 class="crayons-card__header__headline">Join <%= community_name %></h3>
|
||||
</header>
|
||||
<div class="p-4 grid gap-2">
|
||||
<%= render partial: "shared/authentication/providers_sidebar" %>
|
||||
<div class="authentication-widget__container">
|
||||
<figure class="authentication-widget__image-container">
|
||||
<img class="authentication-widget__image" src="<%= optimized_image_url(safe_logo_url(SiteConfig.secondary_logo_url), width: 190) %>"
|
||||
alt="Secondary <%= community_name %> logo" />
|
||||
</figure>
|
||||
<div class="authentication-widget__content">
|
||||
<h3 class="authentication-widget__title">
|
||||
<a href="/"><%= community_name %></a> is a community of <%= number_with_delimiter User.registered.estimated_count %> amazing <%= community_members_label %>
|
||||
</h3>
|
||||
<p class="authentication-widget__description">
|
||||
<% if SiteConfig.tagline.present? %>
|
||||
<%= SiteConfig.tagline %>
|
||||
<% else %>
|
||||
Log in to customize your experience and get involved.
|
||||
<% end %>
|
||||
</p>
|
||||
<div class="authentication-widget__actions">
|
||||
<a href="/enter" class="crayons-btn" aria-label="Create new account">
|
||||
Create new account
|
||||
</a>
|
||||
<a href="/enter" class="crayons-btn crayons-btn--ghost-brand" aria-label="Log in">
|
||||
Log in
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -19,25 +19,41 @@
|
|||
<div class="p-1">
|
||||
<a href="<%= signout_confirm_path %>" class="crayons-link crayons-link--block" id="last-nav-link">Sign Out</a>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<div class="border-0 border-b-1 border-solid border-base-20 p-2 grid gap-2">
|
||||
<% if any_selfserve_auth? %>
|
||||
<%= render partial: "shared/authentication/providers_nav_menu" %>
|
||||
<a
|
||||
href="/enter"
|
||||
class="crayons-btn crayons-btn--secondary">
|
||||
More Sign In Options
|
||||
</a>
|
||||
<% else %>
|
||||
<a
|
||||
href="/enter"
|
||||
class="crayons-btn crayons-btn--secondary">
|
||||
Sign In
|
||||
</a>
|
||||
<% end %>
|
||||
<div class="authentication-header__container border-0 border-b-1 border-solid border-base-20">
|
||||
<figure class="authentication-header__image-container">
|
||||
<img class="authentication-header__image" src="<%= optimized_image_url(safe_logo_url(SiteConfig.secondary_logo_url), width: 190) %>"
|
||||
alt="Secondary <%= community_name %> logo" />
|
||||
</figure>
|
||||
<div class="authentication-header__content">
|
||||
<h2 class="authentication-header__title">
|
||||
<a href="/"><%= community_name %></a> is a community of <%= number_with_delimiter User.registered.estimated_count %> amazing <%= community_members_label %>
|
||||
</h2>
|
||||
<p class="authentication-header__description">
|
||||
<% if SiteConfig.tagline.present? %>
|
||||
<%= SiteConfig.tagline %>
|
||||
<% else %>
|
||||
Log in to customize your experience and get involved.
|
||||
<% end %>
|
||||
</p>
|
||||
<div class="authentication-header__actions">
|
||||
<a href="/enter" class="crayons-btn" aria-label="Create new account">
|
||||
Create new account
|
||||
</a>
|
||||
<a href="/enter" class="crayons-btn crayons-btn--ghost-brand" aria-label="Log in">
|
||||
Log in
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-1">
|
||||
<a href="<%= information_path %>" class="crayons-link crayons-link--block" id="last-nav-link">All about <%= community_name %></a>
|
||||
<div class="border-0 border-b-1 border-solid border-base-20 p-1">
|
||||
<a href="<%= about_path %>" class="crayons-link crayons-link--block" id="last-nav-link">
|
||||
About <%= community_name %>
|
||||
</a>
|
||||
<a href="<%= information_path %>" class="crayons-link crayons-link--block" id="last-nav-link">
|
||||
Learn more
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -24,22 +24,32 @@
|
|||
</div>
|
||||
|
||||
<div class="top-bar__links">
|
||||
<a href="/new" class="crayons-btn hidden mr-2 whitespace-nowrap s:block">Write a post</a>
|
||||
<% if user_signed_in? %>
|
||||
<a href="/new" class="crayons-btn hidden mr-2 whitespace-nowrap s:block">Write a post</a>
|
||||
|
||||
<a id="moderation-link" class="top-bar__link trusted-visible-block" aria-label="Moderation" href="<%= mod_path %>">
|
||||
<%= inline_svg_tag("mod.svg", aria: true, class: "crayons-icon", title: "Moderation") %>
|
||||
</a>
|
||||
<a id="moderation-link" class="top-bar__link trusted-visible-block" aria-label="Moderation" href="<%= mod_path %>">
|
||||
<%= inline_svg_tag("mod.svg", aria: true, class: "crayons-icon", title: "Moderation") %>
|
||||
</a>
|
||||
|
||||
<a href="/connect" id="connect-link" class="top-bar__link" aria-label="Connect">
|
||||
<%= inline_svg_tag("connect.svg", aria: true, class: "crayons-icon", title: "Connect") %>
|
||||
<span class="crayons-indicator crayons-indicator--accent hidden" id="connect-number"></span>
|
||||
</a>
|
||||
<a href="/notifications" id="notifications-link" class="top-bar__link" aria-label="Notifications">
|
||||
<%= inline_svg_tag("bell.svg", aria: true, class: "crayons-icon", title: "Notifications") %>
|
||||
<span class="crayons-indicator crayons-indicator--critical hidden" id="notifications-number"></span>
|
||||
</a>
|
||||
<a href="/connect" id="connect-link" class="top-bar__link" aria-label="Connect">
|
||||
<%= inline_svg_tag("connect.svg", aria: true, class: "crayons-icon", title: "Connect") %>
|
||||
<span class="crayons-indicator crayons-indicator--accent hidden" id="connect-number"></span>
|
||||
</a>
|
||||
|
||||
<div class="top-bar__menu" id="top-bar__menu">
|
||||
<a href="/notifications" id="notifications-link" class="top-bar__link" aria-label="Notifications">
|
||||
<%= inline_svg_tag("bell.svg", aria: true, class: "crayons-icon", title: "Notifications") %>
|
||||
<span class="crayons-indicator crayons-indicator--critical hidden" id="notifications-number"></span>
|
||||
</a>
|
||||
<% else %>
|
||||
<a href="/enter" class="crayons-btn crayons-btn--ghost-brand hidden mr-2 whitespace-nowrap s:block" data-no-instant>
|
||||
Log in
|
||||
</a>
|
||||
|
||||
<a href="/enter" class="crayons-btn hidden mr-2 whitespace-nowrap s:block" data-no-instant>
|
||||
Create account
|
||||
</a>
|
||||
<% end %>
|
||||
<div class="top-bar__menu <% unless user_signed_in? %>s:hidden<% end %>" id="top-bar__menu">
|
||||
<button type="button" class="top-bar__menu__trigger" id="navigation-butt" aria-label="Navigation menu">
|
||||
<% if user_signed_in? %>
|
||||
<span class="crayons-avatar crayons-avatar--l"><img class="crayons-avatar__image" alt="" id="nav-profile-image" /></span>
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ RSpec.describe "Registrations", type: :request do
|
|||
end
|
||||
|
||||
context "when logged in" do
|
||||
it "redirects to /dashboard" do
|
||||
it "redirects to main feed" do
|
||||
sign_in user
|
||||
|
||||
get sign_up_path
|
||||
expect(response).to redirect_to(dashboard_path)
|
||||
expect(response).to redirect_to("/?signin=true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
58
spec/system/authentication/redirects_using_referer_spec.rb
Normal file
58
spec/system/authentication/redirects_using_referer_spec.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Redirects authentication using Referer", type: :system do
|
||||
let(:article) { build(:article) }
|
||||
let(:user) do
|
||||
create(:user, :with_identity, identities: [:twitter], saw_onboarding: true)
|
||||
end
|
||||
|
||||
let(:login_link) { "Log in" }
|
||||
let(:sign_in_link) { "Continue with Twitter" }
|
||||
|
||||
before do
|
||||
omniauth_mock_twitter_payload
|
||||
OmniAuth.config.mock_auth[:twitter].info.email = user.email
|
||||
end
|
||||
|
||||
after do
|
||||
sign_out user
|
||||
end
|
||||
|
||||
context "when a valid referer is available" do
|
||||
it "redirects back to the main feed (root path)" do
|
||||
visit root_path
|
||||
click_link(login_link, match: :first)
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/", ignore_query: true)
|
||||
end
|
||||
|
||||
it "redirects back to an article page" do
|
||||
visit "/#{article.slug}"
|
||||
click_link(login_link, match: :first)
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/#{article.slug}", ignore_query: true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when no referer is available" do
|
||||
it "redirects back to the main feed as default" do
|
||||
Capybara.current_session.driver.header "Referer", ""
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/", ignore_query: true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the referer is from an external host" do
|
||||
it "redirects back to the main feed as default" do
|
||||
Capybara.current_session.driver.header "Referer", "https://example.com"
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/", ignore_query: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Authenticating with Facebook" do
|
||||
let(:sign_in_link) { "Sign In with Facebook" }
|
||||
let(:sign_in_link) { "Continue with Facebook" }
|
||||
|
||||
before { omniauth_mock_facebook_payload }
|
||||
|
||||
|
|
@ -9,13 +9,13 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
context "when using valid credentials" do
|
||||
it "creates a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it "logs in and redirects to the onboarding" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/onboarding", ignore_query: true)
|
||||
|
|
@ -23,7 +23,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
end
|
||||
|
||||
it "remembers the user" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
user = User.last
|
||||
|
|
@ -41,13 +41,13 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
it "creates a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it "logs in and redirects to the onboarding" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/onboarding", ignore_query: true)
|
||||
|
|
@ -55,7 +55,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
end
|
||||
|
||||
it "remembers the user" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
user = User.last
|
||||
|
|
@ -72,7 +72,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
user = create(:user, username: username)
|
||||
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
|
||||
|
|
@ -98,18 +98,18 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "does not log in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_in")
|
||||
expect(page).to have_link(sign_in_link)
|
||||
expect(page).to have_link("All about #{ApplicationConfig['COMMUNITY_NAME']}")
|
||||
expect(page).to have_link("About #{ApplicationConfig['COMMUNITY_NAME']}")
|
||||
end
|
||||
|
||||
it "notifies Datadog about a callback error" do
|
||||
|
|
@ -119,7 +119,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "facebook", params)
|
||||
|
|
@ -135,7 +135,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
error = OAuth::Unauthorized.new(request)
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "facebook", params)
|
||||
|
|
@ -148,7 +148,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
error = nil
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "facebook", params)
|
||||
|
|
@ -166,13 +166,13 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "redirects to the registration page" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_up")
|
||||
|
|
@ -181,7 +181,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
it "logs errors" do
|
||||
allow(Honeybadger).to receive(:notify)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(Honeybadger).to have_received(:notify).once
|
||||
|
|
@ -204,7 +204,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
context "when using valid credentials" do
|
||||
it "logs in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
|
|
@ -216,7 +216,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
sign_in user
|
||||
visit user_facebook_omniauth_authorize_path
|
||||
|
||||
expect(page).to have_current_path("/dashboard?signin=true")
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Authenticating with GitHub" do
|
||||
let(:sign_in_link) { "Sign In with GitHub" }
|
||||
let(:sign_in_link) { "Continue with GitHub" }
|
||||
|
||||
before { omniauth_mock_github_payload }
|
||||
|
||||
|
|
@ -9,13 +9,13 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
context "when using valid credentials" do
|
||||
it "creates a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it "logs in and redirects to the onboarding" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/onboarding", ignore_query: true)
|
||||
|
|
@ -23,7 +23,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
end
|
||||
|
||||
it "remembers the user" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
user = User.last
|
||||
|
|
@ -39,7 +39,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
user = create(:user, username: username.delete("."))
|
||||
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
|
||||
|
|
@ -65,18 +65,18 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "does not log in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_in")
|
||||
expect(page).to have_link(sign_in_link)
|
||||
expect(page).to have_link("All about #{SiteConfig.community_name}")
|
||||
expect(page).to have_link("About #{SiteConfig.community_name}")
|
||||
end
|
||||
|
||||
it "notifies Datadog about a callback error" do
|
||||
|
|
@ -86,7 +86,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "github", params)
|
||||
|
|
@ -102,7 +102,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
error = OAuth::Unauthorized.new(request)
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "github", params)
|
||||
|
|
@ -115,7 +115,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
error = nil
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "github", params)
|
||||
|
|
@ -133,13 +133,13 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "redirects to the registration page" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_up")
|
||||
|
|
@ -148,7 +148,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
it "reports errors" do
|
||||
allow(Honeybadger).to receive(:notify)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(Honeybadger).to have_received(:notify)
|
||||
|
|
@ -170,7 +170,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
|
||||
context "when using valid credentials" do
|
||||
it "logs in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
|
|
@ -178,11 +178,11 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
end
|
||||
|
||||
context "when already signed in" do
|
||||
it "redirects to the dashboard" do
|
||||
it "redirects to the feed" do
|
||||
sign_in user
|
||||
visit user_github_omniauth_authorize_path
|
||||
|
||||
expect(page).to have_current_path("/dashboard?signin=true")
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Authenticating with Twitter" do
|
||||
let(:sign_in_link) { "Sign In with Twitter" }
|
||||
let(:sign_in_link) { "Continue with Twitter" }
|
||||
|
||||
before { omniauth_mock_twitter_payload }
|
||||
|
||||
|
|
@ -9,13 +9,13 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
context "when using valid credentials" do
|
||||
it "creates a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
end
|
||||
|
||||
it "logs in and redirects to the onboarding" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/onboarding?referrer=none")
|
||||
|
|
@ -23,7 +23,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
end
|
||||
|
||||
it "remembers the user" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
user = User.last
|
||||
|
|
@ -39,7 +39,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
user = create(:user, username: username.delete("."))
|
||||
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.to change(User, :count).by(1)
|
||||
|
||||
|
|
@ -61,18 +61,18 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "does not log in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_in")
|
||||
expect(page).to have_link(sign_in_link)
|
||||
expect(page).to have_link("All about #{SiteConfig.community_name}")
|
||||
expect(page).to have_link("About #{SiteConfig.community_name}")
|
||||
end
|
||||
|
||||
it "notifies Datadog about a callback error" do
|
||||
|
|
@ -82,7 +82,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "twitter", "{}")
|
||||
|
|
@ -98,7 +98,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
error = OAuth::Unauthorized.new(request)
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "twitter", "{}")
|
||||
|
|
@ -111,7 +111,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
error = nil
|
||||
omniauth_setup_authentication_error(error)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
args = omniauth_failure_args(error, "twitter", "{}")
|
||||
|
|
@ -129,13 +129,13 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
|
||||
it "does not create a new user" do
|
||||
expect do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
end.not_to change(User, :count)
|
||||
end
|
||||
|
||||
it "redirects to the registration page" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/users/sign_up")
|
||||
|
|
@ -144,7 +144,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
it "reports errors" do
|
||||
allow(Honeybadger).to receive(:notify)
|
||||
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(Honeybadger).to have_received(:notify)
|
||||
|
|
@ -162,19 +162,19 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
|
||||
context "when using valid credentials" do
|
||||
it "logs in" do
|
||||
visit root_path
|
||||
visit sign_up_path
|
||||
click_link(sign_in_link, match: :first)
|
||||
|
||||
expect(page).to have_current_path("/dashboard?signin=true")
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
end
|
||||
end
|
||||
|
||||
context "when already signed in" do
|
||||
it "redirects to the dashboard" do
|
||||
it "redirects to the feed" do
|
||||
sign_in user
|
||||
visit user_twitter_omniauth_authorize_path
|
||||
|
||||
expect(page).to have_current_path("/dashboard?signin=true")
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ RSpec.describe "User visits a homepage", type: :system do
|
|||
it "shows the sign-in block" do
|
||||
visit "/"
|
||||
within ".signin-cta-widget" do
|
||||
expect(page).to have_text("Sign In with Twitter")
|
||||
expect(page).to have_text("Sign In with GitHub")
|
||||
expect(page).to have_text("Log in")
|
||||
expect(page).to have_text("Create new account")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ RSpec.describe "Authenticating with a password" do
|
|||
auth_payload.info.email = user.email
|
||||
user.lock_access!
|
||||
|
||||
visit root_path
|
||||
click_link("Sign In with GitHub", match: :first)
|
||||
visit sign_up_path
|
||||
click_link("Continue with GitHub", match: :first)
|
||||
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
expect(page).not_to have_text("Your account is locked.")
|
||||
|
|
@ -68,7 +68,7 @@ RSpec.describe "Authenticating with a password" do
|
|||
context "when logging in with the correct credentials" do
|
||||
it "allows the user to sign in with the correct password" do
|
||||
submit_login_form(user.email, password)
|
||||
expect(page).to have_current_path("/dashboard?signin=true")
|
||||
expect(page).to have_current_path("/?signin=true")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue