Remove old user sign up code
This commit is contained in:
parent
0cd4559f5a
commit
7397e14a57
@ -4,10 +4,6 @@ class UsersController < ApplicationController
|
||||
|
||||
attr_reader :user
|
||||
|
||||
def new
|
||||
@user = build_user
|
||||
end
|
||||
|
||||
def show
|
||||
if params[:username]
|
||||
user = User.for_username!(params[:username])
|
||||
@ -18,18 +14,6 @@ class UsersController < ApplicationController
|
||||
render locals: { page: UserPagePresenter.build(user, current_user, params[:page]) }
|
||||
end
|
||||
|
||||
def create
|
||||
@user = build_user
|
||||
|
||||
if @user.save
|
||||
store.delete(:new_user_email)
|
||||
self.current_user = @user
|
||||
redirect_to docs_path('getting-started'), notice: "Welcome to Asciinema!"
|
||||
else
|
||||
render :new, :status => 422
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = current_user
|
||||
authorize @user
|
||||
@ -48,21 +32,6 @@ class UsersController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def store
|
||||
session
|
||||
end
|
||||
|
||||
def build_user
|
||||
user = User.new(create_params)
|
||||
user.email = store[:new_user_email]
|
||||
|
||||
user
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.fetch(:user, {}).permit(:username, :name)
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:user).permit(:username, :name, :email, :theme_name)
|
||||
end
|
||||
|
@ -1,38 +0,0 @@
|
||||
.container
|
||||
.row
|
||||
.col-md-6.new-user
|
||||
h1 New user?
|
||||
|
||||
p
|
||||
' Every Asciinema user gets a profile page at
|
||||
br
|
||||
a href="#"
|
||||
| #{root_url}~
|
||||
strong username
|
||||
' . Pick a desired username below.
|
||||
|
||||
= form_for @user, url: user_path do |f|
|
||||
.form-group
|
||||
= f.label :username, 'Pick a username:'
|
||||
= f.text_field :username, required: true, 'class' => 'form-control', 'data-behavior' => 'focus'
|
||||
.form-group
|
||||
= f.submit 'Start recording', class: 'btn btn-primary'
|
||||
|
||||
.col-md-6.returning-user
|
||||
h1 Returning user?
|
||||
|
||||
p
|
||||
' There is no account associated with the email
|
||||
strong = @user.email
|
||||
' .
|
||||
|
||||
p
|
||||
' However, if you have been previously signing in to Asciinema via
|
||||
' Github or Twitter then click a proper button below so we can locate
|
||||
' your existing account:
|
||||
|
||||
ul.login
|
||||
li = link_to "Sign in via Github", github_auth_path, :class => 'btn-auth btn-github'
|
||||
li = link_to "Sign in via Twitter", twitter_auth_path, :class => 'btn-auth btn-twitter'
|
||||
|
||||
p Note: this is one-time task. You won't be asked to do it again.
|
@ -2,89 +2,6 @@ require 'rails_helper'
|
||||
|
||||
describe UsersController do
|
||||
|
||||
let(:store) { {} }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:store) { store }
|
||||
end
|
||||
|
||||
describe '#new' do
|
||||
before do
|
||||
store[:new_user_email] = 'foo@bar.com'
|
||||
|
||||
get :new
|
||||
end
|
||||
|
||||
it 'assigns user with a stored email' do
|
||||
expect(assigns(:user).email).to eq('foo@bar.com')
|
||||
end
|
||||
|
||||
it 'renders new template' do
|
||||
should render_template('new')
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
let!(:user) { stub_model(User) }
|
||||
|
||||
subject { post :create, user: { username: 'jola' } }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:current_user=)
|
||||
allow(User).to receive(:new).with('username' => 'jola') { user }
|
||||
store[:new_user_email] = 'foo@bar.com'
|
||||
end
|
||||
|
||||
context "when user is persisted" do
|
||||
before do
|
||||
allow(user).to receive(:save) { true }
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
it 'removes the email from the store' do
|
||||
expect(store.key?(:new_user_email)).to be(false)
|
||||
end
|
||||
|
||||
it 'assigns the stored email to the user' do
|
||||
expect(user.email).to eq('foo@bar.com')
|
||||
end
|
||||
|
||||
it 'sets the current_user' do
|
||||
expect(controller).to have_received(:current_user=).with(user)
|
||||
end
|
||||
|
||||
it 'redirects to the "getting started" page with a notice' do
|
||||
expect(flash[:notice]).to_not be_blank
|
||||
should redirect_to(docs_path('getting-started'))
|
||||
end
|
||||
end
|
||||
|
||||
context "when user isn't persisted" do
|
||||
before do
|
||||
allow(user).to receive(:save) { false }
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
it "doesn't remove the email from the store" do
|
||||
expect(store.key?(:new_user_email)).to be(true)
|
||||
end
|
||||
|
||||
it "doesn't set the current_user" do
|
||||
expect(controller).to_not have_received(:current_user=)
|
||||
end
|
||||
|
||||
it 'assigns user with a stored email' do
|
||||
expect(assigns(:user).email).to eq('foo@bar.com')
|
||||
end
|
||||
|
||||
it 'renders "new" template' do
|
||||
should render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
subject { get :show, username: username }
|
||||
|
||||
|
@ -5,8 +5,6 @@ FactoryGirl.define do
|
||||
sequence(:username) { |n| "user#{n}" }
|
||||
|
||||
factory :user do
|
||||
provider "twitter"
|
||||
uid
|
||||
sequence(:username) { generate(:username) }
|
||||
sequence(:email) { |n| "foo#{n}@bar.com" }
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user