Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to overwrite the correspondence-language with a filter-chain #238

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading