Skip to content

Commit b90febb

Browse files
dadachiclaude
andcommitted
Revert PermissionsController nil-version guard
Per review: a missing current PrivacyVersion/TermsVersion is a server-side data integrity problem (no row published as current). Crashing loud is preferable to silently telling the client "you're up to date" — the latter would mask the data issue and mislead clients. Keeps the SessionsController fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2e93213 commit b90febb

2 files changed

Lines changed: 2 additions & 22 deletions

File tree

app/controllers/api/v1/shopkeeper/permissions_controller.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def index
88
current_privacy_version = PrivacyVersion.current_version
99
current_terms_version = TermsVersion.current_version
1010

11-
should_update_privacy = version_outdated?(current_shopkeeper.confirmed_privacy_version, current_privacy_version)
12-
should_update_terms = version_outdated?(current_shopkeeper.confirmed_terms_version, current_terms_version)
11+
should_update_privacy = current_shopkeeper.confirmed_privacy_version < current_privacy_version
12+
should_update_terms = current_shopkeeper.confirmed_terms_version < current_terms_version
1313

1414
options = {}
1515
options[:meta] = {
@@ -25,13 +25,4 @@ def index
2525
permissions = current_accounts_shopkeeper.permissions
2626
render json: PermissionSerializer.new(permissions, options).serializable_hash
2727
end
28-
29-
private
30-
31-
# nil current → nothing published yet, nothing to update.
32-
def version_outdated?(confirmed, current)
33-
return false if current.nil?
34-
35-
confirmed < current
36-
end
3728
end

test/controllers/api/v1/shopkeeper/permissions_controller_test.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,4 @@ class Api::V1::Shopkeeper::PermissionsControllerTest < ActionDispatch::Integrati
6464

6565
assert_response :unauthorized
6666
end
67-
68-
test "index does not crash when there is no current published privacy or terms version" do
69-
PrivacyVersion.update_all(current_type: PrivacyVersion.current_types[:uncurrent])
70-
TermsVersion.update_all(current_type: TermsVersion.current_types[:uncurrent])
71-
72-
get api_v1_shopkeeper_permissions_url, headers: @shopkeeper.create_new_auth_token
73-
74-
assert_response :success
75-
assert_equal false, response.parsed_body["meta"]["should_update_privacy"]
76-
assert_equal false, response.parsed_body["meta"]["should_update_terms"]
77-
end
7867
end

0 commit comments

Comments
 (0)