Skip to content

Commit

Permalink
Allow to overwrite the correspondence-language with a filter-chain
Browse files Browse the repository at this point in the history
  • Loading branch information
kronn committed Feb 13, 2025
1 parent 782bd5f commit 15a171d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/domain/die_mitte/mailing_lists/subscribers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def people

def correspondence_language_condition
return {} if @list.correspondence_language.blank?
return {} if @list.filter_chain.filters.any? { |filter| filter.attr == "language" }

{correspondence_language: @list.correspondence_language}
end
Expand Down
8 changes: 8 additions & 0 deletions spec/domain/mailing_list/subscribers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
expect(list.people).to have(2).items
end

it "includes two people if set but with a more specific filter-chain" do
list.update(correspondence_language: :fr)
list.update(filter_chain: {language: {allowed_values: [:fr, :de]}})

expect(list.people).to have(2).items
end


it "includes single perosn when set" do
list.update(correspondence_language: :de)
expect(list.people).to eq [other]
Expand Down

0 comments on commit 15a171d

Please sign in to comment.