REFACTOR: finish installation controller specs to requests
This commit is contained in:
parent
5ecaa55e50
commit
7f21892ad0
|
@ -2,15 +2,15 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe FinishInstallationController do
|
describe FinishInstallationController do
|
||||||
|
|
||||||
describe '.index' do
|
describe '#index' do
|
||||||
context "has_login_hint is false" do
|
context "has_login_hint is false" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.has_login_hint = false
|
SiteSetting.has_login_hint = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't allow access" do
|
it "doesn't allow access" do
|
||||||
get :index
|
get "/finish-installation"
|
||||||
expect(response).not_to be_successful
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,21 +20,21 @@ describe FinishInstallationController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows access" do
|
it "allows access" do
|
||||||
get :index
|
get "/finish-installation"
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.register' do
|
describe '#register' do
|
||||||
context "has_login_hint is false" do
|
context "has_login_hint is false" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.has_login_hint = false
|
SiteSetting.has_login_hint = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't allow access" do
|
it "doesn't allow access" do
|
||||||
get :register
|
get "/finish-installation/register"
|
||||||
expect(response).not_to be_successful
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,21 +45,21 @@ describe FinishInstallationController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows access" do
|
it "allows access" do
|
||||||
get :register
|
get "/finish-installation/register"
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error when the email is not in the allowed list" do
|
it "raises an error when the email is not in the allowed list" do
|
||||||
post :register, params: {
|
post "/finish-installation/register.json", params: {
|
||||||
email: 'notrobin@example.com',
|
email: 'notrobin@example.com',
|
||||||
username: 'eviltrout',
|
username: 'eviltrout',
|
||||||
password: 'disismypasswordokay'
|
password: 'disismypasswordokay'
|
||||||
}, format: :json
|
}
|
||||||
expect(response.status).to eq(400)
|
expect(response.status).to eq(400)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't redirect when fields are wrong" do
|
it "doesn't redirect when fields are wrong" do
|
||||||
post :register, params: {
|
post "/finish-installation/register", params: {
|
||||||
email: 'robin@example.com',
|
email: 'robin@example.com',
|
||||||
username: '',
|
username: '',
|
||||||
password: 'disismypasswordokay'
|
password: 'disismypasswordokay'
|
||||||
|
@ -69,40 +69,39 @@ describe FinishInstallationController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "registers the admin when the email is in the list" do
|
it "registers the admin when the email is in the list" do
|
||||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
expect do
|
||||||
|
post "/finish-installation/register.json", params: {
|
||||||
post :register, params: {
|
|
||||||
email: 'robin@example.com',
|
email: 'robin@example.com',
|
||||||
username: 'eviltrout',
|
username: 'eviltrout',
|
||||||
password: 'disismypasswordokay'
|
password: 'disismypasswordokay'
|
||||||
}, format: :json
|
}
|
||||||
|
end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)
|
||||||
|
|
||||||
expect(response).to be_redirect
|
expect(response).to be_redirect
|
||||||
expect(User.where(username: 'eviltrout').exists?).to eq(true)
|
expect(User.where(username: 'eviltrout').exists?).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.confirm_email' do
|
describe '#confirm_email' do
|
||||||
context "has_login_hint is false" do
|
context "has_login_hint is false" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.has_login_hint = false
|
SiteSetting.has_login_hint = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows the page" do
|
it "shows the page" do
|
||||||
get :confirm_email
|
get "/finish-installation/confirm-email"
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.resend_email' do
|
describe '#resend_email' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.has_login_hint = true
|
SiteSetting.has_login_hint = true
|
||||||
GlobalSetting.stubs(:developer_emails).returns("robin@example.com")
|
GlobalSetting.stubs(:developer_emails).returns("robin@example.com")
|
||||||
|
|
||||||
post :register, params: {
|
post "/finish-installation/register", params: {
|
||||||
email: 'robin@example.com',
|
email: 'robin@example.com',
|
||||||
username: 'eviltrout',
|
username: 'eviltrout',
|
||||||
password: 'disismypasswordokay'
|
password: 'disismypasswordokay'
|
||||||
|
@ -110,9 +109,11 @@ describe FinishInstallationController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "resends the email" do
|
it "resends the email" do
|
||||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))
|
expect do
|
||||||
get :resend_email
|
put "/finish-installation/resend-email"
|
||||||
expect(response).to be_successful
|
end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue