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

replace !persisted with new_record? and !empty? with any? #3091

Merged
merged 1 commit into from
Aug 20, 2022
Merged
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
2 changes: 1 addition & 1 deletion app/controllers/admin/base_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def show

def destroy
@base_item = BaseItem.includes(:items).find(params[:id])
if !@base_item.items.empty? && @base_item.destroy
if @base_item.items.any? && @base_item.destroy
redirect_to admin_base_items_path, notice: "Base Item deleted!"
else
redirect_to admin_base_items_path, alert: "Failed to delete Base Item. Are there still items attached?"
Expand Down
2 changes: 1 addition & 1 deletion app/services/distribution_content_change_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call
end

def any_change?
!updates.empty? || !removed.empty?
updates.any? || removed.any?
end

def changes
Expand Down
2 changes: 1 addition & 1 deletion app/services/sync_ndbn_members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def sync
next
elsif ndbn_member.persisted? && ndbn_member.changed?
Rails.logger.info("#{ndbn_member.id} changed their account name from #{ndbn_member.account_name_was} to #{ndbn_member.account_name}.")
elsif !ndbn_member.persisted?
elsif ndbn_member.new_record?
Rails.logger.info("New record found! #{ndbn_member.id} - #{ndbn_member.account_name} has been added!")
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/distribution_mailer/_distribution_changes.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p>Here are some Items that we need change based on Human Essentials</p>
<ul style="list-style-type:none">
<% if !@distribution_changes[:updates].empty? %>
<% if @distribution_changes[:updates].any? %>
<li>Items Updated</li>
<ol style="list-style-type:none">
<% @distribution_changes[:updates].each do |item| %>
Expand All @@ -11,7 +11,7 @@
</ol>
</li>
<% end %>
<% if !@distribution_changes[:removed].empty? %>
<% if @distribution_changes[:removed].any? %>
<li>Items Removed</li>
<ol style="list-style-type:none">
<% @distribution_changes[:removed].each do |item| %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/distribution_mailer/partner_mailer.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ From: <%= @from_email %>
<%= @default_email_text_interpolated %>
<% if @distribution_changes.present? %>
Here are some Items that we need change based on Human Essentials
<% if !@distribution_changes[:updates].empty? %>
<% if @distribution_changes[:updates].any? %>
Items Updated:
<% @distribution_changes[:updates].each do |item| %>
* <%= "#{item[:name]} from #{item[:old_quantity]} to #{item[:new_quantity]}" %>
<% end %>
<% end %>
<% if !@distribution_changes[:removed].empty? %>
<% if @distribution_changes[:removed].any? %>
Items Removed:
<% @distribution_changes[:removed].each do |item| %>
* <%= item[:name] %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/distributions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</li>
<li class="breadcrumb-item"><%= link_to "Distributions", (distributions_path) %></li>
<li class="breadcrumb-item"><a href="#"><%= @distribution.partner.name %>
<% if !@distribution.new_record? %>
<% if @distribution.persisted? %>
<%= "(#{@distribution.created_at.strftime("%m/%d/%Y")})" %></li>
<% end %></a></li>
</ol>
Expand Down