A platform for community discussion. Free, open, simple.
REFACTOR: finish installation controller specs to requests
OsamaSayegh7f21892ad061
diff --git a/spec/controllers/finish_installation_controller_spec.rb b/spec/requests/finish_installation_controller_spec.rbsimilarity index 62%rename from spec/controllers/finish_installation_controller_spec.rbrename to spec/requests/finish_installation_controller_spec.rbindex a7ee627ebe1..0703a2d9c0c 100644--- a/spec/controllers/finish_installation_controller_spec.rb+++ b/spec/requests/finish_installation_controller_spec.rb@@ -2,15 +2,15 @@ require 'rails_helper'describe FinishInstallationController do- describe '.index' do+ describe '#index' docontext "has_login_hint is false" dobefore doSiteSetting.has_login_hint = falseendit "doesn't allow access" do- get :index- expect(response).not_to be_successful+ get "/finish-installation"+ expect(response).to be_forbiddenendend@@ -20,21 +20,21 @@ describe FinishInstallationController doendit "allows access" do- get :index- expect(response).to be_successful+ get "/finish-installation"+ expect(response.status).to eq(200)endendend- describe '.register' do+ describe '#register' docontext "has_login_hint is false" dobefore doSiteSetting.has_login_hint = falseendit "doesn't allow access" do- get :register- expect(response).not_to be_successful+ get "/finish-installation/register"+ expect(response).to be_forbiddenendend@@ -45,21 +45,21 @@ describe FinishInstallationController doendit "allows access" do- get :register- expect(response).to be_successful+ get "/finish-installation/register"+ expect(response.status).to eq(200)endit "raises an error when the email is not in the allowed list" do- post :register, params: {+ post "/finish-installation/register.json", params: {email: '[email protected]',username: 'eviltrout',password: 'disismypasswordokay'- }, format: :json+ }expect(response.status).to eq(400)endit "doesn't redirect when fields are wrong" do- post :register, params: {+ post "/finish-installation/register", params: {email: '[email protected]',username: '',password: 'disismypasswordokay'@@ -69,40 +69,39 @@ describe FinishInstallationController doendit "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: '[email protected]',- username: 'eviltrout',- password: 'disismypasswordokay'- }, format: :json+ expect do+ post "/finish-installation/register.json", params: {+ email: '[email protected]',+ username: 'eviltrout',+ password: 'disismypasswordokay'+ }+ end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)expect(response).to be_redirectexpect(User.where(username: 'eviltrout').exists?).to eq(true)end-endend- describe '.confirm_email' do+ describe '#confirm_email' docontext "has_login_hint is false" dobefore doSiteSetting.has_login_hint = falseendit "shows the page" do- get :confirm_email- expect(response).to be_successful+ get "/finish-installation/confirm-email"+ expect(response.status).to eq(200)endendend- describe '.resend_email' do+ describe '#resend_email' dobefore doSiteSetting.has_login_hint = trueGlobalSetting.stubs(:developer_emails).returns("[email protected]")- post :register, params: {+ post "/finish-installation/register", params: {email: '[email protected]',username: 'eviltrout',password: 'disismypasswordokay'@@ -110,9 +109,11 @@ describe FinishInstallationController doendit "resends the email" do- Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :signup))- get :resend_email- expect(response).to be_successful+ expect do+ put "/finish-installation/resend-email"+ end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)++ expect(response.status).to eq(200)endendend