Skip to content

Commit

Permalink
Drop trigger_workflow toggle check from policies
Browse files Browse the repository at this point in the history
Simplify policy code
  • Loading branch information
saraycp committed Feb 14, 2023
1 parent 05af6e2 commit 792c53d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
7 changes: 1 addition & 6 deletions src/api/app/policies/token/rss_policy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
class Token::RssPolicy < TokenPolicy
# TODO: when trigger_workflow is rolled out, remove the create? method
def create?
user == record.executor
end
end
class Token::RssPolicy < TokenPolicy; end
6 changes: 1 addition & 5 deletions src/api/app/policies/token/workflow_policy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Token::WorkflowPolicy < TokenPolicy
# TODO: remove the second half of the condition when `trigger_workflow` feature is rolled out
def trigger?
user.is_active? && Flipper.enabled?(:trigger_workflow, user)
user.is_active?
end

def rebuild?
Expand All @@ -14,9 +13,6 @@ def trigger_service?
end

def create?
# TODO: when trigger_workflow is rolled out, remove the Flipper check
return false unless Flipper.enabled?(:trigger_workflow, user)

record.owned_by?(user)
end

Expand Down
10 changes: 2 additions & 8 deletions src/api/app/policies/token_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ def resolve
end

def new?
# TODO: when trigger_workflow is rolled out, uncomment the next line and remove the Flipper check
# true
Flipper.enabled?(:trigger_workflow, user)
true
end

def edit?
update?
end

def update?
record.executor == user && Flipper.enabled?(:trigger_workflow, user)
create?
end

def create?
# TODO: when trigger_workflow is rolled out, remove the Flipper check
return false unless Flipper.enabled?(:trigger_workflow, user)
return false unless record.type != 'Token::Rss'

record.executor == user
end

Expand Down

0 comments on commit 792c53d

Please sign in to comment.