mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #970 from chrishunt/you-already-like-me
Improve on-boarding experience
This commit is contained in:
commit
875151f08a
24 changed files with 155 additions and 260 deletions
|
@ -228,6 +228,9 @@ Discourse.AdminUser.reopenClass({
|
|||
user.set('can_approve', false);
|
||||
return user.set('selected', false);
|
||||
});
|
||||
|
||||
bootbox.alert(Em.String.i18n("admin.user.approve_bulk_success"));
|
||||
|
||||
return Discourse.ajax("/admin/users/approve-bulk", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
|
|
|
@ -59,11 +59,15 @@
|
|||
|
||||
</div>
|
||||
<div class='controls'>
|
||||
{{#if can_approve}}
|
||||
<button class='btn' {{action approve target="content"}}>
|
||||
<i class='icon icon-ok'></i>
|
||||
{{i18n admin.user.approve}}
|
||||
</button>
|
||||
{{#if approved}}
|
||||
{{i18n admin.user.approve_success}}
|
||||
{{else}}
|
||||
{{#if can_approve}}
|
||||
<button class='btn' {{action approve target="content"}}>
|
||||
<i class='icon icon-ok'></i>
|
||||
{{i18n admin.user.approve}}
|
||||
</button>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -177,6 +177,8 @@ table {
|
|||
}
|
||||
|
||||
.display-row {
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 5px;
|
||||
&:nth-of-type(1) {
|
||||
border-top: 0;
|
||||
|
@ -190,8 +192,6 @@ table {
|
|||
clear: both;
|
||||
}
|
||||
.field {
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
font-weight: bold;
|
||||
width: 196px;
|
||||
float: left;
|
||||
|
@ -199,8 +199,6 @@ table {
|
|||
}
|
||||
.value {
|
||||
width: 250px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
float: left;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
|
|
@ -161,35 +161,27 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
if user.save
|
||||
msg = nil
|
||||
active_user = user.active?
|
||||
|
||||
if active_user
|
||||
# If the user is active (remote authorized email)
|
||||
if SiteSetting.must_approve_users?
|
||||
msg = I18n.t("login.wait_approval")
|
||||
active_user = false
|
||||
else
|
||||
log_on_user(user)
|
||||
user.enqueue_welcome_message('welcome_user')
|
||||
msg = I18n.t("login.active")
|
||||
end
|
||||
else
|
||||
msg = I18n.t("login.activate_email", email: user.email)
|
||||
Jobs.enqueue(
|
||||
:user_email, type: :signup, user_id: user.id,
|
||||
if SiteSetting.must_approve_users?
|
||||
message = I18n.t("login.wait_approval")
|
||||
elsif !user.active?
|
||||
message = I18n.t("login.activate_email", email: user.email)
|
||||
Jobs.enqueue(:user_email,
|
||||
type: :signup,
|
||||
user_id: user.id,
|
||||
email_token: user.email_tokens.first.token
|
||||
)
|
||||
else
|
||||
message = I18n.t("login.active")
|
||||
log_on_user(user)
|
||||
user.enqueue_welcome_message('welcome_user')
|
||||
end
|
||||
|
||||
# Create 3rd party auth records (Twitter, Facebook, GitHub)
|
||||
create_third_party_auth_records(user, auth) if auth.present?
|
||||
|
||||
# Clear authentication session.
|
||||
session[:authentication] = nil
|
||||
|
||||
# JSON result
|
||||
render json: { success: true, active: active_user, message: msg }
|
||||
render json: { success: true, active: user.active?, message: message }
|
||||
else
|
||||
render json: {
|
||||
success: false,
|
||||
|
|
|
@ -10,6 +10,15 @@ class UserNotifications < ActionMailer::Base
|
|||
build_email(user.email, "user_notifications.signup", email_token: opts[:email_token])
|
||||
end
|
||||
|
||||
def signup_after_approval(user, opts={})
|
||||
build_email(
|
||||
user.email,
|
||||
'user_notifications.signup_after_approval',
|
||||
email_token: opts[:email_token],
|
||||
new_user_tips: SiteContent.content_for(:usage_tips)
|
||||
)
|
||||
end
|
||||
|
||||
def authorize_email(user, opts={})
|
||||
build_email(user.email, "user_notifications.authorize_email", email_token: opts[:email_token])
|
||||
end
|
||||
|
|
|
@ -209,7 +209,8 @@ class User < ActiveRecord::Base
|
|||
self.approved = true
|
||||
self.approved_by = approved_by
|
||||
self.approved_at = Time.now
|
||||
enqueue_welcome_message('welcome_approved') if save
|
||||
|
||||
send_approval_email if save
|
||||
end
|
||||
|
||||
def self.email_hash(email)
|
||||
|
@ -615,7 +616,13 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def send_approval_email
|
||||
Jobs.enqueue(:user_email,
|
||||
type: :signup_after_approval,
|
||||
user_id: id,
|
||||
email_token: email_tokens.first.token
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
|
@ -1131,6 +1131,10 @@ en:
|
|||
flags_received_count: Flags Received
|
||||
approve: 'Approve'
|
||||
approved_by: "approved by"
|
||||
approve_success: "User approved and email sent with activation
|
||||
instructions."
|
||||
approve_bulk_success: "Success! All selected users have been approved
|
||||
and notified."
|
||||
time_read: "Read Time"
|
||||
delete: "Delete User"
|
||||
delete_forbidden: "This user can't be deleted because there are posts. Delete all this user's posts first."
|
||||
|
|
|
@ -800,19 +800,6 @@ cs:
|
|||
|
||||
- Během čtení nějakého tématu se můžete kliknutím na název tématu v horní části stránky vrátit na začátek tématu. Chcete-li naopak skočit na *konec* tématu, klikněte na šipku dolů v indikátoru pozice v dolní části stránky, nebo klikněte na odkaz 'poslední příspěvek' v souhrnu tématu u prvního příspěvku.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Byl jste schválen na %{site_name}!"
|
||||
text_body_template: |
|
||||
Gratulujeme!
|
||||
|
||||
Váš účet byl schválen a můžete se připojit na %{site_name}, vítejte na našem diskuzním fóru!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Věříme v [civilizované komunitní chování](%{base_url}/faq) za všech okolností.
|
||||
|
||||
Užijte si naše fórum!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Vítejte na %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -636,19 +636,6 @@ da:
|
|||
|
||||
- Mens du læser et emne, kan du altid springe til toppen ved at klikke på emnets titel øverst på siden. For at komme til *bunden*, klik på ned-pilen på status-viseren nederst på skærmen, eller klik på sidste indlæg-feltet på emne-opsummeringen under det første indlæg.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Du er blevet godkendt på %{site_name}!"
|
||||
text_body_template: |
|
||||
Tillykke!
|
||||
|
||||
Din brugerkonto på %{site_name} er blevet godkendt, velkommen til vores debatforum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Vi går ind for [civiliseret debatkultur](%{base_url}/faq) til enhver tid.
|
||||
|
||||
Nyd dit ophold!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Velkommen til %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -778,19 +778,6 @@ de:
|
|||
|
||||
- Um an den Anfang eines Themas zu gelangen, klicke auf den Titel am oberen Rand der Seite. Um ans *Ende* zu springen, klicke auf den Abwärtspfeil in der Fortschrittsanzeige des Themas unten auf der Seite oder auf das Feld 'Letzter Beitrag' in der Zusammenfassung des Themas unter dem ersten Beitrag.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Du wurdest auf %{site_name} zugelassen!"
|
||||
text_body_template: |
|
||||
Glückwunsch!
|
||||
|
||||
Du wurdest auf %{site_name} zugelassen, willkommen in unserem Forum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Wir stehen für [zivilisiertes Verhalten in Online-Communitys](%{base_url}/faq).
|
||||
|
||||
Viel Vergnügen!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Willkommen auf %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -797,19 +797,6 @@ en:
|
|||
|
||||
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "You've been approved on %{site_name}!"
|
||||
text_body_template: |
|
||||
Congratulations!
|
||||
|
||||
You're approved to join %{site_name}, welcome to our discussion forum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
We believe in [civilized community behavior](%{base_url}/faq) at all times.
|
||||
|
||||
Enjoy your stay!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Welcome to %{site_name}!"
|
||||
text_body_template: |
|
||||
|
@ -975,6 +962,24 @@ en:
|
|||
|
||||
%{base_url}/users/authorize-email/%{email_token}
|
||||
|
||||
signup_after_approval:
|
||||
subject_template: "You've been approved on %{site_name}!"
|
||||
text_body_template: |
|
||||
Welcome to %{site_name}!
|
||||
|
||||
You're approved to join %{site_name}, welcome to our discussion forum!
|
||||
|
||||
Click the following link to confirm and activate your new account:
|
||||
%{base_url}/users/activate-account/%{email_token}
|
||||
|
||||
If the above link is not clickable, try copying and pasting it into the address bar of your web browser.
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
We believe in [civilized community behavior](%{base_url}/faq) at all times.
|
||||
|
||||
Enjoy your stay!
|
||||
|
||||
signup:
|
||||
subject_template: "[%{site_name}] Activate your new account"
|
||||
text_body_template: |
|
||||
|
|
|
@ -618,19 +618,6 @@ es:
|
|||
|
||||
- Mientras lees un topic, vuelve a lo más alto ↑ haciendo click en su título arriba de la página. Para alcanzar el *final* ↓, haz click en la flecha hacia abajo del indicador de prograso del topic al final de la página, or click the last post field on the topic summary under the first post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "¡Has sido aprobado en %{site_name}!"
|
||||
text_body_template: |
|
||||
¡Enhorabuena!
|
||||
|
||||
Has sido aprobado para unirte a %{site_name}, ¡Bienvenido a nuestro foro de discusión!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Creemos en [civilized community behavior](%{base_url}/faq) siempre.
|
||||
|
||||
¡Disfruta tu estancia!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Bienvenido a %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -785,19 +785,6 @@ fr:
|
|||
|
||||
- Pendant que vous lisez une discussion, vous pouvez retourner au début en cliquant sur son titre situé en haut de l'écran. Pour atteindre la *fin*, cliquez sur la flèche vers le bas sur l'indiquateur de progression en bas de la page, ou cliquez sur le champ "dernier message" dans le résumé de la discussion, sous le premier message.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Vous avez été accepté sur %{site_name} !"
|
||||
text_body_template: |
|
||||
Félicitations !
|
||||
|
||||
Vous avez été accepté pour rejoindre %{site_name}, bienvenue sur notre forum de discussions.
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Nous croyons au [comportement communautaire civilisé](%{base_url}/faq) en tous temps.
|
||||
|
||||
Amusez-vous bien !
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Bienvenue sur %{site_name} !"
|
||||
text_body_template: |
|
||||
|
|
|
@ -639,19 +639,6 @@ id:
|
|||
|
||||
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "You've been approved on %{site_name}!"
|
||||
text_body_template: |
|
||||
Congratulations!
|
||||
|
||||
You're approved to join %{site_name}, welcome to our discussion forum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
We believe in [civilized community behavior](%{base_url}/faq) at all times.
|
||||
|
||||
Enjoy your stay!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Welcome to %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -765,19 +765,6 @@ it:
|
|||
|
||||
- Mentre leggi un topic, puoi tornare in cima cliccando il titolo all'inizio della pagina. Per raggiungere il *fondo* invece, clicca la freccia in basso nella progress bar situata in fondo alla pagina, o clicca il campo ultimo post nel sommario presente nel primo post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Il tuo account è stato approvato su %{site_name}!"
|
||||
text_body_template: |
|
||||
Congratulazioni!
|
||||
|
||||
Il tuo account è stato approvato per accedere su %{site_name}, benvenuto nel nostro forum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Crediamo nel [comportamento civilizzato della community](%{base_url}/faq) in ogni momento.
|
||||
|
||||
Goditi la permanenza!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Benvenuto su %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -791,19 +791,6 @@ nl:
|
|||
|
||||
- Wanneer je een topic leest, kan je naar boven scrollen (↑) door op de topictitel bovenaan de pagina te klikken. Om de *onderkant* (↓) te bereiken klik je op de pijl naar beneden aan de onderkant van de pagina of je klikt op het Laatste Post-veld in de topicsamenvatting onder het eerste bericht.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Je aanmelding voor %{site_name} is goedgekeurd!"
|
||||
text_body_template: |
|
||||
Gefeliciteerd!
|
||||
|
||||
Je aanvraag om lid te worden van %{site_name} is goedgekeurd, welkom op ons discussieforum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
We geloven altijd in [beschaafd gemeenschappelijk gedrag](%{base_url}/faq).
|
||||
|
||||
Geniet van je verblijf!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Welkom bij %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -894,19 +894,7 @@ pseudo:
|
|||
|
||||
- Ŵĥíłé řéáďíɳǧ á ťóƿíč, ɱóνé ťó ťĥé ťóƿ ↑ ƀý čłíčǩíɳǧ íťš ťíťłé áť ťĥé ťóƿ óƒ ťĥé ƿáǧé. Ťó řéáčĥ ťĥé *ƀóťťóɱ* ↓, čłíčǩ ťĥé ďóŵɳ ářřóŵ óɳ ťĥé ťóƿíč ƿřóǧřéšš íɳďíčáťóř áť ťĥé ƀóťťóɱ óƒ ťĥé ƿáǧé, óř čłíčǩ ťĥé łášť ƿóšť ƒíéłď óɳ ťĥé ťóƿíč šůɱɱářý ůɳďéř ťĥé ƒířšť ƿóšť.
|
||||
]]
|
||||
welcome_approved:
|
||||
subject_template: '[[ Ýóů''νé ƀééɳ áƿƿřóνéď óɳ %{site_name}! ]]'
|
||||
text_body_template: |-
|
||||
[[ Čóɳǧřáťůłáťíóɳš!
|
||||
|
||||
Ýóů'řé áƿƿřóνéď ťó ʲóíɳ %{site_name}, ŵéłčóɱé ťó óůř ďíščůššíóɳ ƒóřůɱ!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Ŵé ƀéłíéνé íɳ [číνíłížéď čóɱɱůɳíťý ƀéĥáνíóř](%{base_url}/ƒáƣ) áť áłł ťíɱéš.
|
||||
|
||||
Éɳʲóý ýóůř šťáý!
|
||||
]]
|
||||
welcome_user:
|
||||
subject_template: '[[ Ŵéłčóɱé ťó %{site_name}! ]]'
|
||||
text_body_template: |-
|
||||
|
|
|
@ -555,19 +555,6 @@ pt:
|
|||
|
||||
- Enquanto estiveres a ler um tópico, podes mover para o topo clicando no título no topo da página. Para chegar ao fundo clica na seta na barra de prograsso no fundo da página, ou clica no último campo sumário do tópico debaixo do primeiro post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "Foste aprovado no %{site_name}!"
|
||||
text_body_template: |
|
||||
Parabéns!
|
||||
|
||||
Estás aprovado para te juntares a %{site_name}, ben-vindo ao nosso foum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
Acreditamos num [comportamento civilizado na comunidade](%{base_url}/faq) a toda a hora.
|
||||
|
||||
Diverte-te durante a estadia!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Welcome to %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -693,19 +693,6 @@ sv:
|
|||
|
||||
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "You've been approved on %{site_name}!"
|
||||
text_body_template: |
|
||||
Congratulations!
|
||||
|
||||
You're approved to join %{site_name}, welcome to our discussion forum!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
We believe in [civilized community behavior](%{base_url}/faq) at all times.
|
||||
|
||||
Enjoy your stay!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "Welcome to %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -763,19 +763,6 @@ zh_CN:
|
|||
|
||||
- 当阅读一个主题时,你可以通过点击页面顶部的标题回到顶部;要去到 *底部*,点击页面底部的主题浏览进度指示器里的向下箭头,或者点击该主题第一帖下面的汇总信息里的最后一帖区域。
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "你已经获得了 %{site_name} 的批准!"
|
||||
text_body_template: |
|
||||
恭喜你!
|
||||
|
||||
你已经被批准加入 %{site_name},欢迎来到我们论坛参与讨论!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
我们始终相信 [文明的社会行为](%{base_url}/faq)。
|
||||
|
||||
好好享受你在论坛的时光吧!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "欢迎来到 %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -763,19 +763,6 @@ zh_TW:
|
|||
|
||||
- 當閱讀一個主題時,你可以通過點擊頁面頂部的標題回到頂部;要去到 *底部*,點擊頁面底部的主題浏覽進度指示器裏的向下箭頭,或者點擊該主題第一帖下面的彙總信息裏的最後一帖區域。
|
||||
|
||||
welcome_approved:
|
||||
subject_template: "你已經獲得了 %{site_name} 的批准!"
|
||||
text_body_template: |
|
||||
恭喜你!
|
||||
|
||||
你已經被批准加入 %{site_name},歡迎來到我們論壇參與討論!
|
||||
|
||||
%{new_user_tips}
|
||||
|
||||
我們始終相信 [文明的社會行爲](%{base_url}/faq)。
|
||||
|
||||
好好享受你在論壇的時光吧!
|
||||
|
||||
welcome_user:
|
||||
subject_template: "歡迎來到 %{site_name}!"
|
||||
text_body_template: |
|
||||
|
|
|
@ -76,21 +76,42 @@ describe SessionController do
|
|||
it "doesn't log in the user" do
|
||||
session[:current_user_id].should be_blank
|
||||
end
|
||||
|
||||
it "shows the 'not approved' error message" do
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
I18n.t('login.not_approved')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when email has not been confirmed' do
|
||||
before do
|
||||
def post_login
|
||||
xhr :post, :create, login: user.email, password: 'myawesomepassword'
|
||||
end
|
||||
|
||||
it "doesn't log in the user" do
|
||||
post_login
|
||||
session[:current_user_id].should be_blank
|
||||
end
|
||||
|
||||
it 'returns an error message' do
|
||||
::JSON.parse(response.body)['error'].should be_present
|
||||
it "shows the 'not activated' error message" do
|
||||
post_login
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
I18n.t 'login.not_activated'
|
||||
)
|
||||
end
|
||||
|
||||
context "and the 'must approve users' site setting is enabled" do
|
||||
before { SiteSetting.expects(:must_approve_users?).returns(true) }
|
||||
|
||||
it "shows the 'not approved' error message" do
|
||||
post_login
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
I18n.t 'login.not_approved'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -278,58 +278,83 @@ describe UsersController do
|
|||
DiscourseHub.stubs(:register_nickname).returns([true, nil])
|
||||
end
|
||||
|
||||
def post_user
|
||||
xhr :post, :create,
|
||||
name: @user.name,
|
||||
username: @user.username,
|
||||
password: "strongpassword",
|
||||
email: @user.email
|
||||
end
|
||||
|
||||
context 'when creating a non active user (unconfirmed email)' do
|
||||
it 'should enqueue a signup email' do
|
||||
it 'enqueues a signup email' do
|
||||
Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup))
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
end
|
||||
|
||||
it "doesn't send a welcome email" do
|
||||
it 'does not enqueue a welcome email' do
|
||||
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
end
|
||||
|
||||
it 'indicates the user is not active in the response' do
|
||||
post_user
|
||||
expect(JSON.parse(response.body)['active']).to be_false
|
||||
end
|
||||
|
||||
context "and 'must approve users' site setting is enabled" do
|
||||
before { SiteSetting.expects(:must_approve_users).returns(true) }
|
||||
|
||||
it 'does not enqueue an email' do
|
||||
Jobs.expects(:enqueue).never
|
||||
post_user
|
||||
end
|
||||
|
||||
it 'does not login the user' do
|
||||
post_user
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
|
||||
it 'indicates the user is not active in the response' do
|
||||
post_user
|
||||
expect(JSON.parse(response.body)['active']).to be_false
|
||||
end
|
||||
|
||||
it "shows the 'waiting approval' message" do
|
||||
post_user
|
||||
expect(JSON.parse(response.body)['message']).to eq(
|
||||
I18n.t 'login.wait_approval'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when creating an active user (confirmed email)' do
|
||||
before { User.any_instance.stubs(:active?).returns(true) }
|
||||
|
||||
before do
|
||||
User.any_instance.stubs(:active?).returns(true)
|
||||
it 'enqueues a welcome email' do
|
||||
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user')
|
||||
post_user
|
||||
end
|
||||
|
||||
it 'should enqueue a signup email' do
|
||||
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user')
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
it "shows the 'active' message" do
|
||||
User.any_instance.expects(:enqueue_welcome_message)
|
||||
post_user
|
||||
expect(JSON.parse(response.body)['message']).to eq(
|
||||
I18n.t 'login.active'
|
||||
)
|
||||
end
|
||||
|
||||
it "should be logged in" do
|
||||
User.any_instance.expects(:enqueue_welcome_message)
|
||||
xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
session[:current_user_id].should be_present
|
||||
end
|
||||
|
||||
it "returns true in the active part of the JSON" do
|
||||
it 'indicates the user is active in the response' do
|
||||
User.any_instance.expects(:enqueue_welcome_message)
|
||||
xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email
|
||||
::JSON.parse(response.body)['active'].should == true
|
||||
end
|
||||
|
||||
|
||||
context 'when approving of users is required' do
|
||||
before do
|
||||
SiteSetting.expects(:must_approve_users).returns(true)
|
||||
xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email
|
||||
end
|
||||
|
||||
it "doesn't log in the user" do
|
||||
session[:current_user_id].should be_blank
|
||||
end
|
||||
|
||||
it "doesn't return active in the JSON" do
|
||||
::JSON.parse(response.body)['active'].should == false
|
||||
end
|
||||
post_user
|
||||
expect(JSON.parse(response.body)['active']).to be_true
|
||||
end
|
||||
|
||||
context 'authentication records for' do
|
||||
|
@ -344,8 +369,7 @@ describe UsersController do
|
|||
TwitterUserInfo.expects(:find_by_twitter_user_id).returns(nil)
|
||||
TwitterUserInfo.expects(:create)
|
||||
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
end
|
||||
|
||||
it 'should create facebook user info if none exists' do
|
||||
|
@ -354,8 +378,7 @@ describe UsersController do
|
|||
FacebookUserInfo.expects(:find_by_facebook_user_id).returns(nil)
|
||||
FacebookUserInfo.expects(:create!)
|
||||
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
end
|
||||
|
||||
it 'should create github user info if none exists' do
|
||||
|
@ -364,18 +387,13 @@ describe UsersController do
|
|||
GithubUserInfo.expects(:find_by_github_user_id).returns(nil)
|
||||
GithubUserInfo.expects(:create)
|
||||
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
post_user
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context 'after success' do
|
||||
before do
|
||||
xhr :post, :create, name: @user.name, username: @user.username,
|
||||
password: "strongpassword", email: @user.email
|
||||
end
|
||||
before { post_user }
|
||||
|
||||
it 'should succeed' do
|
||||
should respond_with(:success)
|
||||
|
|
|
@ -94,8 +94,10 @@ describe User do
|
|||
let(:user) { Fabricate(:user) }
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
|
||||
it "generates a welcome message" do
|
||||
user.expects(:enqueue_welcome_message).with('welcome_approved')
|
||||
it "enqueues a 'signup after approval' email" do
|
||||
Jobs.expects(:enqueue).with(
|
||||
:user_email, has_entries(type: :signup_after_approval)
|
||||
)
|
||||
user.approve(admin)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue