-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use helper method, also check people_managers feature gate
- Loading branch information
1 parent
681f49b
commit f9dc675
Showing
5 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
spec/controllers/event/participation_contact_data/managed_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |