Skip to content

Commit

Permalink
Make only some features visible
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlences committed Dec 5, 2024
1 parent eb98bc6 commit 9c129bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .erblint-rubocop20241205-23566-fnt2fo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
inherit_from:
- ".rubocop.yml"
Layout/InitialIndentation:
Enabled: false
Layout/LineLength:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: false
Layout/TrailingWhitespace:
Enabled: false
Naming/FileName:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Lint/UselessAssignment:
Enabled: false
Rails/OutputSafety:
Enabled: false
4 changes: 2 additions & 2 deletions app/models/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Tenant < ApplicationRecord

validates_presence_of :name

AVAILABLE_FEATURE_FLAGS = [:audit_log, :archive, :api, :message_draft_import, :fs_api, :fs_sync]
AVAILABLE_FEATURE_FLAGS = [:audit_log, :archive, :api, :fs_sync]
ALL_FEATURE_FLAGS = [:audit_log, :archive, :api, :message_draft_import, :fs_api, :fs_sync]

def draft_tag!
Expand All @@ -68,7 +68,7 @@ def user_signature_tags
end

def feature_enabled?(feature)
raise "Unknown feature #{feature}" unless feature.in? AVAILABLE_FEATURE_FLAGS
raise "Unknown feature #{feature}" unless feature.in? ALL_FEATURE_FLAGS

feature.to_s.in? feature_flags
end
Expand Down
4 changes: 2 additions & 2 deletions test/system/admin/feature_flags_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class FeatureFlagsManagementTest < ApplicationSystemTestCase

test "admin can enable and disable a feature" do
available_features = users(:admin).tenant.list_available_features
enabled = users(:admin).tenant.feature_enabled?(available_features[0].to_sym)
enabled = users(:admin).tenant.feature_enabled?(available_features[0])
click_button available_features[0]
assert_button available_features[0]
users(:admin).tenant.reload
assert_not_equal enabled, users(:admin).tenant.feature_enabled?(available_features[0].to_sym)
assert_not_equal enabled, users(:admin).tenant.feature_enabled?(available_features[0])
end
end

0 comments on commit 9c129bf

Please sign in to comment.