Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: No Registration links when Disable Signups is set #717

Merged
merged 2 commits into from Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 deletions app/views/file_pushes/new_anonymous.html.erb
Expand Up @@ -9,13 +9,16 @@
<%= _('Securely Send Files That Delete Automatically') %>
</div>
<div class="card-body">
<h5 class="card-title">
<%= _('Please login or sign up to use this feature.') %>
</h5>
<p class="card-text">
</p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<a href="<%= new_user_registration_path %>" class="btn btn-success">Sign Up</a>
<% if Settings.disable_signups %>
<h5 class="card-title"><%= _('Please login to use this feature.') %></h5>
<p class="card-text"></p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<% else %>
<h5 class="card-title"><%= _('Please login or sign up to use this feature.') %></h5>
<p class="card-text"></p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<a href="<%= new_user_registration_path %>" class="btn btn-success">Sign Up</a>
<% end %>
</div>
</div>
</div>
17 changes: 10 additions & 7 deletions app/views/urls/new_anonymous.html.erb
Expand Up @@ -9,13 +9,16 @@
<%= _('Securely Send URLs That Expire Automatically') %>
</div>
<div class="card-body">
<h5 class="card-title">
<%= _('Please login or sign up to use this feature.') %>
</h5>
<p class="card-text">
</p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<a href="<%= new_user_registration_path %>" class="btn btn-success">Sign Up</a>
<% if Settings.disable_signups %>
<h5 class="card-title"><%= _('Please login to use this feature.') %></h5>
<p class="card-text"></p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<% else %>
<h5 class="card-title"><%= _('Please login or sign up to use this feature.') %></h5>
<p class="card-text"></p>
<a href="<%= new_user_session_path %>" class="btn btn-primary">Log In</a>
<a href="<%= new_user_registration_path %>" class="btn btn-success">Sign Up</a>
<% end %>
</div>
</div>
</div>
45 changes: 0 additions & 45 deletions test/integration/create_account_test.rb

This file was deleted.

44 changes: 44 additions & 0 deletions test/integration/file_push/file_push_anonymous_access.rb
@@ -0,0 +1,44 @@
require 'test_helper'

class PasswordCreationTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

setup do
Settings.enable_logins = true
Settings.enable_file_pushes = true

Rails.application.reload_routes!
end

teardown do
Settings.disable_signups = false
end

def test_anonymous_disabled_signups_no_signup_link
Settings.disable_signups = true

get new_file_push_path
assert_response :success
assert response.body.include?('Please login to use this feature.')
end

def test_anonymous_enabled_signups_with_signup_link
get new_file_push_path
assert_response :success
assert response.body.include?('Please login or sign up to use this feature.')
end

def test_no_access_for_anonymous
get active_file_pushes_path
assert_response :redirect

get expired_file_pushes_path
assert_response :redirect

post file_pushes_path, params: { :blah => 'blah' }
assert_response :redirect

get new_file_push_path
assert_response :success
end
end
44 changes: 44 additions & 0 deletions test/integration/url/url_anonymous_access.rb
@@ -0,0 +1,44 @@
require 'test_helper'

class PasswordCreationTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

setup do
Settings.enable_logins = true
Settings.enable_urls = true

Rails.application.reload_routes!
end

teardown do
Settings.disable_signups = false
end

def test_anonymous_disabled_signups_no_signup_link
Settings.disable_signups = true

get new_url_path
assert_response :success
assert response.body.include?('Please login to use this feature.')
end

def test_anonymous_enabled_signups_with_signup_link
get new_url_path
assert_response :success
assert response.body.include?('Please login or sign up to use this feature.')
end

def test_no_access_for_anonymous
get active_urls_path
assert_response :redirect

get expired_urls_path
assert_response :redirect

post urls_path, params: { :blah => 'blah' }
assert_response :redirect

get new_url_path
assert_response :success
end
end