Test correct login behavior when pending approval
This commit is contained in:
parent
41b0692543
commit
93fc0e74bc
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue