-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from hitobito/feature/jubla-131-avoid-previou…
…s-alumnus-logic-in-nejb-part Avoid previous Alumnus-Logic in NEJB-Tree
- Loading branch information
Showing
13 changed files
with
127 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024-2024, Jungwacht Blauring Schweiz. This file is part of | ||
# hitobito_jubla 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_jubla. | ||
|
||
# Implementation of the NullObject-Pattern | ||
# | ||
# Mimics an AlumnusManager, but does nothing. Intended as a temporary drop-in | ||
# to gradually phase out the previous alumnus-logic | ||
module Jubla::Role | ||
class NullAlumnusManager | ||
def create = true | ||
|
||
def destroy = true | ||
end | ||
end |
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
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
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024-2024, Jungwacht Blauring Schweiz. This file is part of | ||
# hitobito_jubla 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_jubla. | ||
|
||
class NejbRole < Role | ||
module AlumnusFreeRole | ||
def skip_alumnus_callback | ||
true | ||
end | ||
|
||
def alumnus_manager | ||
@alumnus_manager ||= Jubla::Role::NullAlumnusManager.new | ||
end | ||
end | ||
include AlumnusFreeRole | ||
end |
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024-2024, Jungwacht Blauring Schweiz. This file is part of | ||
# hitobito_jubla 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_jubla. | ||
|
||
require "spec_helper" | ||
|
||
describe Jubla::Role::NullAlumnusManager do | ||
it "has a create-method" do | ||
expect(subject.create).to be_truthy | ||
end | ||
|
||
it "has a destroy-method" do | ||
expect(subject.destroy).to be_truthy | ||
end | ||
end |
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,34 @@ | ||
# Copyright (c) 2012-2024, Jungwacht Blauring Schweiz. This file is part of | ||
# hitobito_jubla 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_jubla. | ||
|
||
require "spec_helper" | ||
|
||
describe NejbRole do | ||
it "is a Role" do | ||
expect(subject).to be_a Role | ||
end | ||
|
||
it "is a Jubla::Role" do | ||
expect(subject).to be_a Jubla::Role | ||
end | ||
|
||
it "disables the alumnus-callback" do | ||
expect(subject.skip_alumnus_callback).to be_truthy | ||
end | ||
|
||
it "uses the NullAlumnusManager" do | ||
expect(subject.alumnus_manager).to be_a Jubla::Role::NullAlumnusManager | ||
end | ||
|
||
%w[ | ||
Group::NejbSchar::GroupAdmin | ||
].each do |role| | ||
context role do | ||
it "is a NeJbRole" do | ||
expect(role.safe_constantize.new).to be_a NejbRole | ||
end | ||
end | ||
end | ||
end |