Skip to content

Commit

Permalink
Chore: Replace NullChapter with NullChapterable
Browse files Browse the repository at this point in the history
This will replace `NullChapter` with `NullChapterable`, which will
hopefully simplify things, I don't think we need both or a `NullClub`,
`NullChapterable` should cover everything.

Refs: #5349
  • Loading branch information
shaun-technovation committed Feb 3, 2025
1 parent c62e831 commit 137f34f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/controllers/ambassador_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def current_ambassador
end

def current_chapterable
@current_chapterable ||= current_ambassador.chapterable || ::NullChapter.new
@current_chapterable ||= current_ambassador.chapterable || ::NullChapterable.new
end

def current_profile
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/chapter_ambassador_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def current_ambassador
end

def current_chapter
@current_chapter ||= current_ambassador.chapter || ::NullChapter.new
@current_chapter ||= current_ambassador.chapter || ::NullChapterable.new
end

def chapter_ambassador
Expand Down
4 changes: 2 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,11 @@ def assigned_to_chapter?
end

def current_chapterable
current_primary_chapter || current_primary_club || ::NullChapter.new
current_primary_chapter || current_primary_club || ::NullChapterable.new
end

def current_chapter
current_primary_chapter || ::NullChapter.new
current_primary_chapter || ::NullChapterable.new
end

def current_primary_chapter
Expand Down
2 changes: 1 addition & 1 deletion app/null_objects/null_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def authenticated?
end

def current_chapter
NullChapter.new
NullChapterable.new
end

class NullCertificates
Expand Down
21 changes: 0 additions & 21 deletions app/null_objects/null_chapter.rb

This file was deleted.

16 changes: 16 additions & 0 deletions app/null_objects/null_chapterable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
class NullChapterable < NullObject
def name
nil
end

def summary
nil
end

def primary_contact
nil
end

def chapter_program_information
ChapterProgramInformation.none
end

def build_chapter_program_information
ChapterProgramInformation.none
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.describe NullChapter do
let(:null_chapter) { NullChapter.new }
RSpec.describe NullChapterable do
let(:null_chapter) { NullChapterable.new }

describe "#name" do
it "returns nil" do
Expand Down

0 comments on commit 137f34f

Please sign in to comment.