Skip to content

Commit

Permalink
Also check people_managers feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-illi committed Dec 4, 2023
1 parent 563bdf6 commit d99ae6d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def privacy_policy_param
end

def assert_feature_enabled
FeatureGate.assert!('people.people_managers.self_service_managed_creation')
FeatureGate.assert!('people.people_managers') &&
FeatureGate.assert!('people.people_managers.self_service_managed_creation')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

# Copyright (c) 2023, Schweizer Alpen-Club. This file is part of
# hitobito_youth and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_youth

require 'spec_helper'

describe Event::ParticipationContactData::ManagedController do

let(:params) { { group_id: groups(:top_layer), event_id: events(:top_event) } }

def request(method, action)
send(method, action, params: params)
end

{ get: :edit, post: :update }.each do |method, action|
context 'with people_manager feature enabled' do
before do
allow(FeatureGate).to receive(:enabled?).
with('people.people_managers').
and_return(true)
end

it "with self_service_managed_creation enabled does not raise FeatureGate error" do
expect { request(method, action) }.not_to raise_error
end

it "with self_service_managed_creation disabled raises FeatureGate error" do
expect { request(method, action) }.to raise_error(FeatureGate::FeatureDisabled)
end
end

context 'with people_manager feature disabled' do
before do
allow(FeatureGate).to receive(:enabled?).
with('people.people_managers').
and_return(false)
end

it "with self_service_managed_creation enabled raises FeatureGate error" do
expect { request(method, action) }.to raise_error(FeatureGate::FeatureDisabled)
end

it "with self_service_managed_creation disabled raises FeatureGate error" do
expect { request(method, action) }.to raise_error(FeatureGate::FeatureDisabled)
end
end
end

end

0 comments on commit d99ae6d

Please sign in to comment.