Merge pull request #1642 from basecamp/flavorjones/join-code-exhaustion

Display a helpful error message when join code is exhausted
This commit is contained in:
Mike Dalessio
2025-11-19 15:54:30 -05:00
committed by GitHub
3 changed files with 23 additions and 3 deletions
+6 -2
View File
@@ -29,10 +29,14 @@ class JoinCodesController < ApplicationController
private
def set_join_code
@join_code ||= Account::JoinCode.active.find_by(code: params.expect(:code), account: Current.account)
@join_code ||= Account::JoinCode.find_by(code: params.expect(:code), account: Current.account)
end
def ensure_join_code_is_valid
head :not_found unless @join_code&.active?
if @join_code.nil?
head :not_found
elsif !@join_code.active?
render :inactive, status: :gone
end
end
end
+15
View File
@@ -0,0 +1,15 @@
<% @page_title = "You can't join #{@join_code.account.name} right now." %>
<div class="panel panel--centered flex flex-column gap-half">
<h1 class="txt-x-large font-weight-black margin-none"><%= @page_title %></h1>
<p class="txt-medium">This join code has no invitations left on it.</p>
<p class="txt-medium">
<%= link_to "Check out Fizzy", "https://www.fizzy.do" %>.
</p>
</div>
<% content_for :footer do %>
<%= render "sessions/footer" %>
<% end %>
@@ -24,7 +24,8 @@ class JoinCodesControllerTest < ActionDispatch::IntegrationTest
get join_path(code: @join_code.code, script_name: @account.slug)
assert_response :not_found
assert_response :gone
assert_in_body "This join code has no invitations left on it"
end
test "create" do