Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce visibility of event when creating participation for oneself, …
…refs #1967
- Loading branch information
1 parent
7ac4e32
commit 749d00f
Showing
2 changed files
with
48 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) 2023, Pfadibewegung Schweiz. This file is part of | ||
# hitobito 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. | ||
|
||
require 'spec_helper' | ||
|
||
describe Event::ParticipationAbility do | ||
|
||
let(:user) { role.person } | ||
subject { Ability.new(user) } | ||
|
||
context 'creating participation for herself' do | ||
let(:participation) { Event::Participation.new(event: course, person: user) } | ||
let(:role) { Fabricate(Group::BottomLayer::Leader.name, group: groups(:bottom_layer_one)) } | ||
|
||
context 'in event which can be shown' do | ||
let(:course) { Event::Course.new(groups: [groups(:bottom_layer_one)], globally_visible: false) } | ||
|
||
it 'may create participation for herself' do | ||
is_expected.to be_able_to(:create, participation) | ||
end | ||
end | ||
|
||
context 'in globally visible event' do | ||
let(:course) { Event::Course.new(groups: [groups(:bottom_layer_two)], globally_visible: true) } | ||
|
||
it 'may create participation for herself' do | ||
is_expected.to be_able_to(:create, participation) | ||
end | ||
end | ||
|
||
context 'in event which cannot be shown' do | ||
let(:course) { Event::Course.new(groups: [groups(:bottom_layer_two)], globally_visible: false) } | ||
|
||
it 'may not create participation for herself' do | ||
is_expected.not_to be_able_to(:create, participation) | ||
end | ||
end | ||
end | ||
end |