From e7a1472a1c7a0a025cba10032549e891402485cc Mon Sep 17 00:00:00 2001 From: angus Date: Fri, 12 Mar 2021 21:02:42 +1100 Subject: [PATCH] Handle when permitted is set as "everyone" --- lib/custom_wizard/wizard.rb | 1 + spec/components/custom_wizard/wizard_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/custom_wizard/wizard.rb b/lib/custom_wizard/wizard.rb index bf3478ca..3e12c31d 100644 --- a/lib/custom_wizard/wizard.rb +++ b/lib/custom_wizard/wizard.rb @@ -166,6 +166,7 @@ class CustomWizard::Wizard mapper.all? do |m| if m[:type] === 'assignment' + [*m[:result]].include?(Group::AUTO_GROUPS[:everyone]) || GroupUser.exists?(group_id: m[:result], user_id: user.id) elsif m[:type] === 'validation' m[:result] diff --git a/spec/components/custom_wizard/wizard_spec.rb b/spec/components/custom_wizard/wizard_spec.rb index c348fc6b..e613ddf9 100644 --- a/spec/components/custom_wizard/wizard_spec.rb +++ b/spec/components/custom_wizard/wizard_spec.rb @@ -98,6 +98,13 @@ describe CustomWizard::Wizard do CustomWizard::Wizard.new(@permitted_template, trusted_user).permitted? ).to eq(true) end + + it "permits everyone if everyone is permitted" do + @permitted_template['permitted'][0]['output'] = Group::AUTO_GROUPS[:everyone] + expect( + CustomWizard::Wizard.new(@permitted_template, user).permitted? + ).to eq(true) + end it "does not permit unpermitted users" do expect(