mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 10:03:44 +08:00
89ad2b5900
This updates tests to use latest rails 5 practice and updates ALL dependencies that could be updated Performance testing shows that performance has not regressed if anything it is marginally faster now.
119 lines
2.8 KiB
Ruby
119 lines
2.8 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe FinishInstallationController do
|
|
|
|
describe '.index' do
|
|
context "has_login_hint is false" do
|
|
before do
|
|
SiteSetting.has_login_hint = false
|
|
end
|
|
|
|
it "doesn't allow access" do
|
|
get :index
|
|
expect(response).not_to be_successful
|
|
end
|
|
end
|
|
|
|
context "has_login_hint is true" do
|
|
before do
|
|
SiteSetting.has_login_hint = true
|
|
end
|
|
|
|
it "allows access" do
|
|
get :index
|
|
expect(response).to be_successful
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '.register' do
|
|
context "has_login_hint is false" do
|
|
before do
|
|
SiteSetting.has_login_hint = false
|
|
end
|
|
|
|
it "doesn't allow access" do
|
|
get :register
|
|
expect(response).not_to be_successful
|
|
end
|
|
end
|
|
|
|
context "has_login_hint is true" do
|
|
before do
|
|
SiteSetting.has_login_hint = true
|
|
GlobalSetting.stubs(:developer_emails).returns("robin@example.com")
|
|
end
|
|
|
|
it "allows access" do
|
|
get :register
|
|
expect(response).to be_successful
|
|
end
|
|
|
|
it "raises an error when the email is not in the allowed list" do
|
|
post :register, params: {
|
|
email: 'notrobin@example.com',
|
|
username: 'eviltrout',
|
|
password: 'disismypasswordokay'
|
|
}, format: :json
|
|
expect(response.status).to eq(400)
|
|
end
|
|
|
|
it "doesn't redirect when fields are wrong" do
|
|
post :register, params: {
|
|
email: 'robin@example.com',
|
|
username: '',
|
|
password: 'disismypasswordokay'
|
|
}
|
|
|
|
expect(response).not_to be_redirect
|
|
end
|
|
|
|
it "registers the admin when the email is in the list" do
|
|
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
|
|
|
post :register, params: {
|
|
email: 'robin@example.com',
|
|
username: 'eviltrout',
|
|
password: 'disismypasswordokay'
|
|
}, format: :json
|
|
|
|
expect(response).to be_redirect
|
|
expect(User.where(username: 'eviltrout').exists?).to eq(true)
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
describe '.confirm_email' do
|
|
context "has_login_hint is false" do
|
|
before do
|
|
SiteSetting.has_login_hint = false
|
|
end
|
|
|
|
it "shows the page" do
|
|
get :confirm_email
|
|
expect(response).to be_successful
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '.resend_email' do
|
|
before do
|
|
SiteSetting.has_login_hint = true
|
|
GlobalSetting.stubs(:developer_emails).returns("robin@example.com")
|
|
|
|
post :register, params: {
|
|
email: 'robin@example.com',
|
|
username: 'eviltrout',
|
|
password: 'disismypasswordokay'
|
|
}
|
|
end
|
|
|
|
it "resends the email" do
|
|
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
|
get :resend_email
|
|
expect(response).to be_successful
|
|
end
|
|
end
|
|
end
|