Skip to content

Commit

Permalink
Reverse Rubocop’s misunderstanding.
Browse files Browse the repository at this point in the history
MailingList is not an ActiveRecord model.
  • Loading branch information
pat committed Dec 17, 2023
1 parent c5ef3b5 commit bf193a0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions app/lib/mailing_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def self.all
@all ||= LISTS.collect { |name| new name }
end

def self.each(...)
all.each(...)
end

def initialize(name)
@name = name
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/mailing_list/create_webhooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MailingList::CreateWebhooks
def self.call
MailingList.all.find do |list|
MailingList.each do |list|
new(list).call
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/mailing_list/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MailingList::Setup
def self.call(user)
MailingList.all.find do |list|
MailingList.each do |list|
new(user, list).call
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/mailing_list/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MailingList::Sync
def self.call
MailingList.all.find do |list|
MailingList.each do |list|
new(list).call
end
end
Expand Down
8 changes: 2 additions & 6 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,18 @@ def set_up_mailing_list_flags
def subscribe_to_lists
return if skip_subscriptions

# rubocop:disable Rails/FindEach
MailingList.all.each do |list|
MailingList.each do |list|
next unless mailing_lists[list.name] == "true"

MailingList::Subscribe.call self, list
end
# rubocop:enable Rails/FindEach
end

def update_mailing_list_email_addresses
# rubocop:disable Rails/FindEach
MailingList.all.each do |list|
MailingList.each do |list|
next unless mailing_lists[list.name] == "true"

MailingList::Update.call self, list
end
# rubocop:enable Rails/FindEach
end
end
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

<div class="hint">You can choose to subscribe to news about each of our major events. If you are already subscribed to any of these lists, those subscriptions will be honoured.</div>

<% MailingList.all.each do |list| %>
<% MailingList.each do |list| %>
<div class="field flipped">
<div class="input">
<%= hidden_field_tag "user[mailing_lists][#{list.name}]", "false" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/my/details/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<fieldset>
<legend>Mailing Lists</legend>

<% MailingList.all.each do |list| %>
<% MailingList.each do |list| %>
<div class="field flipped">
<div class="input">
<%= hidden_field_tag "user[mailing_lists][#{list.name}]", "false" %>
Expand Down
4 changes: 2 additions & 2 deletions spec/features/committee_manages_list_webhooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

RSpec.feature "Committee manages list webhooks", type: :request do
scenario "registering webhooks" do
MailingList.all.find do |list|
MailingList.each do |list|
stub_request(:post, "https://api.createsend.com/api/v3.3/lists/#{list.api_id}/webhooks.json")
end

MailingList::CreateWebhooks.call

MailingList.all.find_each do |list|
MailingList.each do |list|
expect(
a_request(:post, "https://api.createsend.com/api/v3.3/lists/#{list.api_id}/webhooks.json")
).to have_been_made
Expand Down

0 comments on commit bf193a0

Please sign in to comment.