diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index a0f1e77a0..4df5ca90a 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -6,9 +6,11 @@
Welcome back
-
- Don't have an account? <%= link_to "Sign up", register_path, class: "underline" %>
-
+ <% if Feature.registration? %>
+
+ Don't have an account? <%= link_to "Sign up", register_path, class: "underline" %>
+
+ <% end %>
<%= form_with(url: login_path, method: :post, class: "flex flex-col space-y-4 w-80") do |f| %>
<%= f.email_field :email,
diff --git a/test/models/feature_test.rb b/test/models/feature_test.rb
index 76f40685c..8e73c1a28 100644
--- a/test/models/feature_test.rb
+++ b/test/models/feature_test.rb
@@ -1,6 +1,8 @@
require "test_helper"
class FeatureTest < ActiveSupport::TestCase
+ include FeatureHelpers
+
test "should return value of feature" do
stub_features(my_feature: true) do
assert Feature.enabled?(:my_feature)
@@ -65,22 +67,4 @@ class FeatureTest < ActiveSupport::TestCase
refute Feature.google_authentication?
end
end
-
- private
-
- def stub_features(hash, &block)
- Feature.features_hash = nil
- Feature.stub :features, hash do
- yield
- end
- Feature.features_hash = nil
- end
-
- def stub_raw_features(hash, &block)
- Feature.features_hash = nil
- Feature.stub :raw_features, hash do
- yield
- end
- Feature.features_hash = nil
- end
end
diff --git a/test/support/feature_helpers.rb b/test/support/feature_helpers.rb
new file mode 100644
index 000000000..92ee39f1f
--- /dev/null
+++ b/test/support/feature_helpers.rb
@@ -0,0 +1,20 @@
+module FeatureHelpers
+
+ private
+
+ def stub_features(hash, &block)
+ Feature.features_hash = nil
+ Feature.stub :features, hash do
+ yield
+ end
+ Feature.features_hash = nil
+ end
+
+ def stub_raw_features(hash, &block)
+ Feature.features_hash = nil
+ Feature.stub :raw_features, hash do
+ yield
+ end
+ Feature.features_hash = nil
+ end
+end
diff --git a/test/system/users_test.rb b/test/system/users_test.rb
index 54be73102..2f0afb6c5 100644
--- a/test/system/users_test.rb
+++ b/test/system/users_test.rb
@@ -1,6 +1,8 @@
require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
+ include FeatureHelpers
+
setup do
@user = users(:keith)
visit root_url
@@ -37,6 +39,13 @@ class UsersTest < ApplicationSystemTestCase
assert_text "can't be blank"
end
+ test "should hide the Sign Up link if the registration feature is disabled" do
+ stub_features(registration: false) do
+ visit root_url
+ assert_no_text 'Sign up'
+ end
+ end
+
test "should create a new user" do
click_text "Sign up", match: :first
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3e83876b5..19ac21112 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -4,6 +4,8 @@
require "minitest/autorun"
require "pry"
+require_relative 'support/feature_helpers'
+
class Capybara::Node::Element
def obsolete?
inspect.include?('Obsolete')
@@ -57,4 +59,4 @@ class TestCase
ActiveStorage::Current.reset
end
end
-end
\ No newline at end of file
+end