Rename nickname to username
This commit is contained in:
parent
81c8340bc1
commit
94817be1b3
@ -2,7 +2,7 @@
|
|||||||
.new_user
|
.new_user
|
||||||
margin-top: 30px
|
margin-top: 30px
|
||||||
|
|
||||||
#user_nickname
|
#user_username
|
||||||
width: 200px
|
width: 200px
|
||||||
|
|
||||||
.returning-user
|
.returning-user
|
||||||
|
@ -9,7 +9,7 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
user = User.real_for_nickname!(params[:nickname])
|
user = User.real_for_username!(params[:username])
|
||||||
render locals: { page: UserPagePresenter.build(user, current_user) }
|
render locals: { page: UserPagePresenter.build(user, current_user) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_params
|
def create_params
|
||||||
params.fetch(:user, {}).permit(:nickname, :name)
|
params.fetch(:user, {}).permit(:username, :name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_params
|
def update_params
|
||||||
params.require(:user).permit(:nickname, :name, :email)
|
params.require(:user).permit(:username, :name, :email)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module AvatarHelper
|
module AvatarHelper
|
||||||
|
|
||||||
def avatar_image_tag
|
def avatar_image_tag
|
||||||
h.image_tag avatar_url, alt: model.nickname, class: 'avatar'
|
h.image_tag avatar_url, alt: model.username, class: 'avatar'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -2,7 +2,7 @@ class UserDecorator < ApplicationDecorator
|
|||||||
include AvatarHelper
|
include AvatarHelper
|
||||||
|
|
||||||
def link
|
def link
|
||||||
wrap_with_link(nickname)
|
wrap_with_link(username)
|
||||||
end
|
end
|
||||||
|
|
||||||
def img_link
|
def img_link
|
||||||
@ -11,9 +11,9 @@ class UserDecorator < ApplicationDecorator
|
|||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
if model.name.present?
|
if model.name.present?
|
||||||
"#{model.name} (#{model.nickname})"
|
"#{model.name} (#{model.username})"
|
||||||
else
|
else
|
||||||
model.nickname
|
model.username
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class UserDecorator < ApplicationDecorator
|
|||||||
if dummy
|
if dummy
|
||||||
html
|
html
|
||||||
else
|
else
|
||||||
h.link_to html, h.profile_path(model), title: nickname
|
h.link_to html, h.profile_path(model), title: username
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class Asciicast < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def user
|
def user
|
||||||
super || self.user = User.new(nickname: 'anonymous').tap { |u| u.dummy = true }
|
super || self.user = User.new(username: 'anonymous').tap { |u| u.dummy = true }
|
||||||
end
|
end
|
||||||
|
|
||||||
def stdout
|
def stdout
|
||||||
|
@ -8,8 +8,8 @@ class User < ActiveRecord::Base
|
|||||||
has_many :asciicasts, :dependent => :destroy
|
has_many :asciicasts, :dependent => :destroy
|
||||||
has_many :comments, :dependent => :destroy
|
has_many :comments, :dependent => :destroy
|
||||||
|
|
||||||
validates :nickname, presence: true
|
validates :username, presence: true
|
||||||
validates :nickname, uniqueness: { scope: :dummy }, unless: :dummy
|
validates :username, uniqueness: { scope: :dummy }, unless: :dummy
|
||||||
validates :email, presence: true, uniqueness: true, unless: :dummy
|
validates :email, presence: true, uniqueness: true, unless: :dummy
|
||||||
|
|
||||||
scope :real, -> { where(dummy: false) }
|
scope :real, -> { where(dummy: false) }
|
||||||
@ -24,8 +24,8 @@ class User < ActiveRecord::Base
|
|||||||
where(email: email).first
|
where(email: email).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.real_for_nickname!(nickname)
|
def self.real_for_username!(username)
|
||||||
real.where(nickname: nickname).first!
|
real.where(username: username).first!
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.for_api_token(token, username)
|
def self.for_api_token(token, username)
|
||||||
@ -41,7 +41,7 @@ class User < ActiveRecord::Base
|
|||||||
transaction do |tx|
|
transaction do |tx|
|
||||||
user = User.new
|
user = User.new
|
||||||
user.dummy = true
|
user.dummy = true
|
||||||
user.nickname = username
|
user.username = username
|
||||||
user.save!
|
user.save!
|
||||||
user.api_tokens.create!(token: token)
|
user.api_tokens.create!(token: token)
|
||||||
user
|
user
|
||||||
@ -52,7 +52,7 @@ class User < ActiveRecord::Base
|
|||||||
SecureRandom.urlsafe_base64
|
SecureRandom.urlsafe_base64
|
||||||
end
|
end
|
||||||
|
|
||||||
def nickname=(value)
|
def username=(value)
|
||||||
value ? super(value.strip) : super
|
value ? super(value.strip) : super
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
nickname
|
username
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_api_token(token)
|
def assign_api_token(token)
|
||||||
|
@ -16,7 +16,7 @@ class UserPagePresenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
"#{user.nickname}'s profile".html_safe
|
"#{user.username}'s profile".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_full_name
|
def user_full_name
|
||||||
@ -37,11 +37,11 @@ class UserPagePresenter
|
|||||||
|
|
||||||
def asciicast_count_text(h)
|
def asciicast_count_text(h)
|
||||||
count = h.pluralize(user.asciicast_count, 'asciicast')
|
count = h.pluralize(user.asciicast_count, 'asciicast')
|
||||||
"#{count} by #{user.nickname}"
|
"#{count} by #{user.username}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_nickname
|
def user_username
|
||||||
user.nickname
|
user.username
|
||||||
end
|
end
|
||||||
|
|
||||||
def asciicasts
|
def asciicasts
|
||||||
|
@ -22,7 +22,7 @@ header.navbar.navbar-default[role="navigation"]
|
|||||||
li.dropdown
|
li.dropdown
|
||||||
a.dropdown-toggle[href="#" data-toggle="dropdown"]
|
a.dropdown-toggle[href="#" data-toggle="dropdown"]
|
||||||
= current_user.avatar_image_tag
|
= current_user.avatar_image_tag
|
||||||
= current_user.nickname
|
= current_user.username
|
||||||
b.caret
|
b.caret
|
||||||
ul.dropdown-menu
|
ul.dropdown-menu
|
||||||
li
|
li
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
legend Your account
|
legend Your account
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :nickname, 'Username *', class: 'col-sm-2 control-label'
|
= f.label :username, 'Username *', class: 'col-sm-2 control-label'
|
||||||
.col-sm-4 = f.text_field :nickname, class: 'form-control'
|
.col-sm-4 = f.text_field :username, class: 'form-control'
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :email, 'E-mail *', class: 'col-sm-2 control-label'
|
= f.label :email, 'E-mail *', class: 'col-sm-2 control-label'
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
= form_for @user, url: user_path do |f|
|
= form_for @user, url: user_path do |f|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :nickname, 'Pick a username:'
|
= f.label :username, 'Pick a username:'
|
||||||
= f.text_field :nickname, required: true, 'class' => 'form-control', 'data-behavior' => 'focus'
|
= f.text_field :username, required: true, 'class' => 'form-control', 'data-behavior' => 'focus'
|
||||||
.form-group
|
.form-group
|
||||||
= f.submit 'Start recording', class: 'btn btn-primary'
|
= f.submit 'Start recording', class: 'btn btn-primary'
|
||||||
|
|
||||||
|
@ -30,4 +30,4 @@
|
|||||||
code asciinema auth
|
code asciinema auth
|
||||||
' in your terminal.
|
' in your terminal.
|
||||||
- else
|
- else
|
||||||
' #{page.user_nickname} hasn't recorded anything yet.
|
' #{page.user_username} hasn't recorded anything yet.
|
||||||
|
@ -11,7 +11,7 @@ Asciinema::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/~:nickname" => "users#show", :as => :profile
|
get "/~:username" => "users#show", :as => :profile
|
||||||
|
|
||||||
get "/docs" => "docs#show", :page => 'getting-started', :as => :docs_index
|
get "/docs" => "docs#show", :page => 'getting-started', :as => :docs_index
|
||||||
get "/docs/:page" => "docs#show", :as => :docs
|
get "/docs/:page" => "docs#show", :as => :docs
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class RenameUsersNicknameToUsername < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :users, :nickname, :username
|
||||||
|
end
|
||||||
|
end
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140212193024) do
|
ActiveRecord::Schema.define(version: 20140212194017) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -90,7 +90,7 @@ ActiveRecord::Schema.define(version: 20140212193024) do
|
|||||||
t.string "avatar_url"
|
t.string "avatar_url"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "nickname", null: false
|
t.string "username", null: false
|
||||||
t.string "auth_token"
|
t.string "auth_token"
|
||||||
t.boolean "dummy", default: false, null: false
|
t.boolean "dummy", default: false, null: false
|
||||||
end
|
end
|
||||||
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(version: 20140212193024) do
|
|||||||
add_index "users", ["auth_token"], name: "index_users_on_auth_token", using: :btree
|
add_index "users", ["auth_token"], name: "index_users_on_auth_token", using: :btree
|
||||||
add_index "users", ["dummy"], name: "index_users_on_dummy", using: :btree
|
add_index "users", ["dummy"], name: "index_users_on_dummy", using: :btree
|
||||||
add_index "users", ["email"], name: "index_users_on_email", using: :btree
|
add_index "users", ["email"], name: "index_users_on_email", using: :btree
|
||||||
add_index "users", ["nickname"], name: "index_users_on_nickname", using: :btree
|
|
||||||
add_index "users", ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true, using: :btree
|
add_index "users", ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true, using: :btree
|
||||||
|
add_index "users", ["username"], name: "index_users_on_username", using: :btree
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ end
|
|||||||
|
|
||||||
describe AsciicastsController do
|
describe AsciicastsController do
|
||||||
|
|
||||||
let(:user) { stub_model(User, :nickname => 'nick') }
|
let(:user) { stub_model(User, username: 'nick') }
|
||||||
let(:asciicast) { stub_model(Asciicast, :id => 666) }
|
let(:asciicast) { stub_model(Asciicast, :id => 666) }
|
||||||
|
|
||||||
subject { response }
|
subject { response }
|
||||||
|
@ -27,11 +27,11 @@ describe UsersController do
|
|||||||
describe "#create" do
|
describe "#create" do
|
||||||
let!(:user) { stub_model(User) }
|
let!(:user) { stub_model(User) }
|
||||||
|
|
||||||
subject { post :create, user: { nickname: 'jola' } }
|
subject { post :create, user: { username: 'jola' } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:current_user=)
|
allow(controller).to receive(:current_user=)
|
||||||
allow(User).to receive(:new).with('nickname' => 'jola') { user }
|
allow(User).to receive(:new).with('username' => 'jola') { user }
|
||||||
store[:new_user_email] = 'foo@bar.com'
|
store[:new_user_email] = 'foo@bar.com'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,15 +86,15 @@ describe UsersController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
subject { get :show, nickname: nickname }
|
subject { get :show, username: username }
|
||||||
|
|
||||||
let(:nickname) { user.nickname }
|
let(:username) { user.username }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when real user nickname given" do
|
context "when real user username given" do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
it 'renders "show" template with HomePagePresenter as page' do
|
it 'renders "show" template with HomePagePresenter as page' do
|
||||||
@ -102,7 +102,7 @@ describe UsersController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when dummy user nickname given" do
|
context "when dummy user username given" do
|
||||||
let(:user) { create(:dummy_user) }
|
let(:user) { create(:dummy_user) }
|
||||||
|
|
||||||
it "responds with 404" do
|
it "responds with 404" do
|
||||||
@ -110,8 +110,8 @@ describe UsersController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when fictional nickname given" do
|
context "when fictional username given" do
|
||||||
let(:nickname) { 'nononono-no' }
|
let(:username) { 'nononono-no' }
|
||||||
|
|
||||||
it "responds with 404" do
|
it "responds with 404" do
|
||||||
expect(subject).to be_not_found
|
expect(subject).to be_not_found
|
||||||
|
@ -8,7 +8,7 @@ describe AvatarHelper do
|
|||||||
|
|
||||||
let(:decorator) { double('decorator', h: h, model: model).
|
let(:decorator) { double('decorator', h: h, model: model).
|
||||||
extend(described_class) }
|
extend(described_class) }
|
||||||
let(:model) { double('model', nickname: 'satyr', avatar_url: avatar_url,
|
let(:model) { double('model', username: 'satyr', avatar_url: avatar_url,
|
||||||
email: email) }
|
email: email) }
|
||||||
|
|
||||||
describe '#avatar_image_tag' do
|
describe '#avatar_image_tag' do
|
||||||
|
@ -7,7 +7,7 @@ describe UserDecorator do
|
|||||||
describe '#link' do
|
describe '#link' do
|
||||||
subject { decorator.link }
|
subject { decorator.link }
|
||||||
|
|
||||||
let(:user) { User.new(nickname: 'satyr') }
|
let(:user) { User.new(username: 'satyr') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(h).to receive(:profile_path).with(user) { '/path' }
|
allow(h).to receive(:profile_path).with(user) { '/path' }
|
||||||
@ -18,7 +18,7 @@ describe UserDecorator do
|
|||||||
user.dummy = false
|
user.dummy = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is a nickname link to user's profile" do
|
it "is a username link to user's profile" do
|
||||||
expect(subject).to eq('<a href="/path" title="satyr">satyr</a>')
|
expect(subject).to eq('<a href="/path" title="satyr">satyr</a>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -28,7 +28,7 @@ describe UserDecorator do
|
|||||||
user.dummy = true
|
user.dummy = true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is user's nickname" do
|
it "is user's username" do
|
||||||
expect(subject).to eq('satyr')
|
expect(subject).to eq('satyr')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -37,7 +37,7 @@ describe UserDecorator do
|
|||||||
describe '#img_link' do
|
describe '#img_link' do
|
||||||
subject { decorator.img_link }
|
subject { decorator.img_link }
|
||||||
|
|
||||||
let(:user) { User.new(nickname: 'satyr') }
|
let(:user) { User.new(username: 'satyr') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(h).to receive(:profile_path).with(user) { '/path' }
|
allow(h).to receive(:profile_path).with(user) { '/path' }
|
||||||
@ -68,7 +68,7 @@ describe UserDecorator do
|
|||||||
describe '#full_name' do
|
describe '#full_name' do
|
||||||
subject { decorator.full_name }
|
subject { decorator.full_name }
|
||||||
|
|
||||||
let(:user) { double('user', nickname: 'sickill', name: name) }
|
let(:user) { double('user', username: 'sickill', name: name) }
|
||||||
|
|
||||||
context "when full name is present" do
|
context "when full name is present" do
|
||||||
let(:name) { 'Marcin Kulik' }
|
let(:name) { 'Marcin Kulik' }
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
sequence(:uid) { |n| n }
|
sequence(:uid) { |n| n }
|
||||||
sequence(:nickname) { |n| "user#{n}" }
|
sequence(:username) { |n| "user#{n}" }
|
||||||
|
|
||||||
factory :user do
|
factory :user do
|
||||||
provider "twitter"
|
provider "twitter"
|
||||||
uid
|
uid
|
||||||
sequence(:nickname) { generate(:nickname) }
|
sequence(:username) { generate(:username) }
|
||||||
sequence(:email) { |n| "foo#{n}@bar.com" }
|
sequence(:email) { |n| "foo#{n}@bar.com" }
|
||||||
name nil
|
name nil
|
||||||
avatar_url nil
|
avatar_url nil
|
||||||
@ -15,6 +15,6 @@ FactoryGirl.define do
|
|||||||
|
|
||||||
factory :dummy_user, class: User do
|
factory :dummy_user, class: User do
|
||||||
dummy true
|
dummy true
|
||||||
sequence(:nickname) { generate(:nickname) }
|
sequence(:username) { generate(:username) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
feature "Asciicast page", :js => true do
|
feature "Asciicast page", :js => true do
|
||||||
|
|
||||||
let!(:user) { create(:user, nickname: 'aaron') }
|
let!(:user) { create(:user, username: 'aaron') }
|
||||||
let!(:asciicast) { create(:asciicast, user: user, title: 'the title') }
|
let!(:asciicast) { create(:asciicast, user: user, title: 'the title') }
|
||||||
let!(:other_asciicast) { create(:asciicast, user: user) }
|
let!(:other_asciicast) { create(:asciicast, user: user) }
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ feature "User's profile" do
|
|||||||
scenario 'Visiting' do
|
scenario 'Visiting' do
|
||||||
visit profile_path(user)
|
visit profile_path(user)
|
||||||
|
|
||||||
expect(page).to have_content(/1 asciicast by #{user.nickname}/i)
|
expect(page).to have_content(/1 asciicast by #{user.username}/i)
|
||||||
expect(page).to have_link('Tricks!')
|
expect(page).to have_link('Tricks!')
|
||||||
expect(page).to have_selector('.asciicast-list .play-button')
|
expect(page).to have_selector('.asciicast-list .play-button')
|
||||||
end
|
end
|
||||||
|
@ -72,8 +72,8 @@ describe Asciicast do
|
|||||||
expect(asciicast.user).to be_dummy
|
expect(asciicast.user).to be_dummy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is a user with "anonymous" as nickname' do
|
it 'is a user with "anonymous" as username' do
|
||||||
expect(asciicast.user.nickname).to eq('anonymous')
|
expect(asciicast.user.username).to eq('anonymous')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,17 +18,17 @@ describe User do
|
|||||||
let!(:existing_user) { create(:user) }
|
let!(:existing_user) { create(:user) }
|
||||||
let(:user) { described_class.new }
|
let(:user) { described_class.new }
|
||||||
|
|
||||||
it { should validate_presence_of(:nickname) }
|
it { should validate_presence_of(:username) }
|
||||||
|
|
||||||
context "when user is dummy" do
|
context "when user is dummy" do
|
||||||
before do
|
before do
|
||||||
user.dummy = true
|
user.dummy = true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't check for nickname uniqueness" do
|
it "doesn't check for username uniqueness" do
|
||||||
user.nickname = existing_user.nickname
|
user.username = existing_user.username
|
||||||
user.valid?
|
user.valid?
|
||||||
expect(user.errors[:nickname]).to be_empty
|
expect(user.errors[:username]).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't check for email presence" do
|
it "doesn't check for email presence" do
|
||||||
@ -49,10 +49,10 @@ describe User do
|
|||||||
user.dummy = false
|
user.dummy = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "checks for nickname uniqueness" do
|
it "checks for username uniqueness" do
|
||||||
user.nickname = existing_user.nickname
|
user.username = existing_user.username
|
||||||
user.valid?
|
user.valid?
|
||||||
expect(user.errors[:nickname]).to_not be_empty
|
expect(user.errors[:username]).to_not be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "checks for email presence" do
|
it "checks for email presence" do
|
||||||
@ -132,7 +132,7 @@ describe User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "assigns given username to the user" do
|
it "assigns given username to the user" do
|
||||||
expect(subject.nickname).to eq(username)
|
expect(subject.username).to eq(username)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns given api token to the user" do
|
it "assigns given api token to the user" do
|
||||||
@ -147,7 +147,7 @@ describe User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "assigns 'anonymous' as username to the user" do
|
it "assigns 'anonymous' as username to the user" do
|
||||||
expect(subject.nickname).to eq('anonymous')
|
expect(subject.username).to eq('anonymous')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ describe User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "assigns 'anonymous' as username to the user" do
|
it "assigns 'anonymous' as username to the user" do
|
||||||
expect(subject.nickname).to eq('anonymous')
|
expect(subject.username).to eq('anonymous')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -185,11 +185,11 @@ describe User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#nickname=' do
|
describe '#username=' do
|
||||||
it 'strips the whitespace' do
|
it 'strips the whitespace' do
|
||||||
user = described_class.new(nickname: ' sickill ')
|
user = described_class.new(username: ' sickill ')
|
||||||
|
|
||||||
expect(user.nickname).to eq('sickill')
|
expect(user.username).to eq('sickill')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ describe UserPagePresenter do
|
|||||||
end
|
end
|
||||||
|
|
||||||
let(:presenter) { described_class.new(user, current_user, page, per_page) }
|
let(:presenter) { described_class.new(user, current_user, page, per_page) }
|
||||||
let(:user) { double('user', nickname: 'cartman') }
|
let(:user) { double('user', username: 'cartman') }
|
||||||
let(:current_user) { double('current_user') }
|
let(:current_user) { double('current_user') }
|
||||||
let(:page) { 2 }
|
let(:page) { 2 }
|
||||||
let(:per_page) { 5 }
|
let(:per_page) { 5 }
|
||||||
@ -112,8 +112,8 @@ describe UserPagePresenter do
|
|||||||
it { should eq('3 asciicasts by cartman') }
|
it { should eq('3 asciicasts by cartman') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#user_nickname' do
|
describe '#user_username' do
|
||||||
subject { presenter.user_nickname }
|
subject { presenter.user_username }
|
||||||
|
|
||||||
it { should eq('cartman') }
|
it { should eq('cartman') }
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Asciinema
|
|||||||
OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({
|
OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({
|
||||||
:provider => provider.to_s,
|
:provider => provider.to_s,
|
||||||
:uid => '123456',
|
:uid => '123456',
|
||||||
:info => { :nickname => opts[:nickname] },
|
:info => { :username => opts[:username] },
|
||||||
:extra => {
|
:extra => {
|
||||||
:raw_info => {
|
:raw_info => {
|
||||||
:avatar_url =>
|
:avatar_url =>
|
||||||
|
Loading…
Reference in New Issue
Block a user