Add specs to check for dis/enabled registrations
This commit is contained in:
parent
6cc8ebcba3
commit
4e5b0a8562
|
@ -15,14 +15,15 @@ describe User::RegistrationsController, type: :controller do
|
|||
justask_admin retrospring_admin admin justask retrospring
|
||||
moderation moderator mod administrator siteadmin site_admin
|
||||
help retro_spring retroospring retrosprlng
|
||||
]
|
||||
})
|
||||
],
|
||||
},)
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
context "valid user sign up" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(true)
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true)
|
||||
allow(controller).to receive(:verify_hcaptcha).and_return(captcha_successful)
|
||||
end
|
||||
|
||||
|
@ -32,8 +33,8 @@ describe User::RegistrationsController, type: :controller do
|
|||
screen_name: "dio",
|
||||
email: "the-world-21@somewhere.everywhere.now",
|
||||
password: "AReallySecurePassword456!",
|
||||
password_confirmation: "AReallySecurePassword456!"
|
||||
}
|
||||
password_confirmation: "AReallySecurePassword456!",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -59,6 +60,7 @@ describe User::RegistrationsController, type: :controller do
|
|||
context "invalid user sign up" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false)
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true)
|
||||
end
|
||||
|
||||
subject { post :create, params: registration_params }
|
||||
|
@ -70,8 +72,8 @@ describe User::RegistrationsController, type: :controller do
|
|||
screen_name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
password_confirmation: ""
|
||||
}
|
||||
password_confirmation: "",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -87,8 +89,8 @@ describe User::RegistrationsController, type: :controller do
|
|||
screen_name: "Dio Brando",
|
||||
email: "the-world-21@somewhere.everywhere.now",
|
||||
password: "AReallySecurePassword456!",
|
||||
password_confirmation: "AReallySecurePassword456!"
|
||||
}
|
||||
password_confirmation: "AReallySecurePassword456!",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -104,8 +106,8 @@ describe User::RegistrationsController, type: :controller do
|
|||
screen_name: "moderator",
|
||||
email: "the-world-21@somewhere.everywhere.now",
|
||||
password: "AReallySecurePassword456!",
|
||||
password_confirmation: "AReallySecurePassword456!"
|
||||
}
|
||||
password_confirmation: "AReallySecurePassword456!",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -114,5 +116,33 @@ describe User::RegistrationsController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when registrations are disabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false)
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false)
|
||||
end
|
||||
|
||||
it "redirects to the root page" do
|
||||
subject
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
subject { get :new }
|
||||
|
||||
context "when registrations are disabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:hcaptcha, :enabled).and_return(false)
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false)
|
||||
end
|
||||
|
||||
it "redirects to the root page" do
|
||||
subject
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe "about/index.html.haml", type: :view do
|
||||
before do
|
||||
stub_const("APP_CONFIG", {
|
||||
"hostname" => "example.com",
|
||||
"https" => true,
|
||||
"sitename" => "yastask",
|
||||
},)
|
||||
end
|
||||
|
||||
subject(:rendered) { render }
|
||||
|
||||
context "registrations are enabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true)
|
||||
end
|
||||
|
||||
it "has references to registering now" do
|
||||
expect(rendered).to match(/Register now/)
|
||||
end
|
||||
end
|
||||
|
||||
context "registrations are disabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false)
|
||||
end
|
||||
|
||||
it "has no references to registering now" do
|
||||
expect(rendered).to_not match(/Register now/)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe "navigation/_guest.html.haml", type: :view do
|
||||
subject(:rendered) do
|
||||
render partial: "navigation/guest"
|
||||
end
|
||||
|
||||
context "registrations are enabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(true)
|
||||
end
|
||||
|
||||
it "has a sign up link" do
|
||||
expect(rendered).to match(/Sign up/)
|
||||
end
|
||||
end
|
||||
|
||||
context "registrations are disabled" do
|
||||
before do
|
||||
allow(APP_CONFIG).to receive(:dig).with(:features, :registration, :enabled).and_return(false)
|
||||
end
|
||||
|
||||
it "has no sign up link" do
|
||||
expect(rendered).to_not match(/Sign up/)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue