Skip to content

Commit

Permalink
Comply with Standard Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
jonallured committed Dec 4, 2024
1 parent 2a40c5f commit bf91df4
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 58 deletions.
2 changes: 1 addition & 1 deletion app/graphql/resolvers/concerns/resolvers/submissionable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def external_submission_id
end

def compute_error
return IdsNotPassed unless ids_passed?
IdsNotPassed unless ids_passed?
end

def ids_passed?
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/resolvers/offer_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run
private

def compute_error
return BadArgumentError unless admin? || partner? || user?
BadArgumentError unless admin? || partner? || user?
end

def validate_user(offer)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/submissions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def formatted_minimum_price_for_email(submission)

def artist_supply_priority(is_p1: false, target_supply: false, **)
return "P1" if is_p1
return "P2" if target_supply
"P2" if target_supply
end

def assignable_admin?(user)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/utm_params_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module UtmParamsHelper
def utm_params(source:, campaign:, **args)
initial = {utm_campaign: campaign, utm_medium: "email", utm_source: source}
transformed_args = args.each_with_object({}) { |(key, value), obj| obj["utm_#{key}".to_sym] = value }
transformed_args = args.each_with_object({}) { |(key, value), obj| obj[:"utm_#{key}"] = value }
initial.merge(transformed_args)
end

Expand Down
24 changes: 12 additions & 12 deletions app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def submission(submission:, user:, artist:)
)

smtpapi category: %w[submission],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(
to: Convection.config.admin_email_address,
subject: "Submission ##{@submission.id}"
Expand All @@ -33,9 +33,9 @@ def submission_approved(submission:, artist:)
assigned_admin = AdminUser.find_by(gravity_user_id: submission.assigned_to)

smtpapi category: %w[submission],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}

mail(
to: assigned_admin.email,
Expand All @@ -51,9 +51,9 @@ def submission_resubmitted(submission:, artist:)
assigned_admin = AdminUser.find_by(gravity_user_id: submission.assigned_to)

smtpapi category: %w[submission],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}

mail(
to: assigned_admin.email,
Expand All @@ -72,9 +72,9 @@ def artwork_updated(submission:, artwork_data:, changes: nil, image_added: nil)
@image_added = image_added

smtpapi category: %w[submission],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}

mail(
to: assigned_admin.email,
Expand Down
6 changes: 3 additions & 3 deletions app/mailers/partner_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def submission_digest(
content: "sub-digest-auction"
)
smtpapi category: %w[submission_digest],
unique_args: {
partner_name: partner_name
}
unique_args: {
partner_name: partner_name
}

current_date = Time.now.utc.strftime("%B %-d")
mail(
Expand Down
56 changes: 28 additions & 28 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def submission_receipt(submission:, artist:)
)

smtpapi category: %w[submission_receipt],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(
to: submission.email,
subject: "Thank you for submitting your artwork to Artsy",
Expand All @@ -35,9 +35,9 @@ def first_upload_reminder(submission:)
)

smtpapi category: %w[first_upload_reminder],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail to: submission.email, subject: "You're Almost Done"
end

Expand All @@ -50,11 +50,11 @@ def second_upload_reminder(submission:)
)

smtpapi category: %w[second_upload_reminder],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail to: submission.email,
subject: "Artsy Consignments - complete your submission"
subject: "Artsy Consignments - complete your submission"
end

def submission_approved(submission:, artist:)
Expand All @@ -69,9 +69,9 @@ def submission_approved(submission:, artist:)
)

smtpapi category: %w[submission_approved],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(
to: submission.email,
subject: "Artsy Approved Submission | Next Steps"
Expand All @@ -90,9 +90,9 @@ def artist_submission_rejected(submission:, artist:)
)

smtpapi category: %w[artist_submission_rejected],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(to: submission.email, subject: "An update about your submission")
end

Expand All @@ -108,9 +108,9 @@ def fake_submission_rejected(submission:, artist:)
)

smtpapi category: %w[fake_submission_rejected],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(to: submission.email, subject: "Artsy Submission")
end

Expand All @@ -128,9 +128,9 @@ def nsv_bsv_submission_rejected(submission:, artist:, logged_in:)
)

smtpapi category: %w[nsv_bsv_submission_rejected],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
title = submission.title || "Unknown"
artist_name = artist&.name
subject = "Update on \"#{title}\" #{artist_name ? "by #{artist_name}" : ""}"
Expand All @@ -150,9 +150,9 @@ def non_target_supply_artist_rejected(submission:, artist:)
)

smtpapi category: %w[non_target_supply_artist_rejected],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(to: submission.email, subject: "An update about your submission")
end

Expand All @@ -168,9 +168,9 @@ def other_submission_rejected(submission:, artist:)
)

smtpapi category: %w[other_submission_rejected],
unique_args: {
submission_id: submission.id
}
unique_args: {
submission_id: submission.id
}
mail(to: submission.email, subject: "An update about your submission")
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/concerns/percentize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ module Percentize
class_methods do
def percentize(*method_names)
method_names.each do |method_name|
attribute "#{method_name}_whole".to_sym
attribute :"#{method_name}_whole"

define_method "#{method_name}_whole" do
define_method :"#{method_name}_whole" do
return if self[method_name].blank?

(self[method_name] * 100).round(2)
end

define_method "#{method_name}_whole=" do |percent_whole|
define_method :"#{method_name}_whole=" do |percent_whole|
if percent_whole.blank?
self[method_name] = nil
else
Expand Down
2 changes: 1 addition & 1 deletion app/models/offer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def set_state

# defines methods sent?, accepted?, etc. for each possible offer state
STATES.each do |method|
define_method "#{method}?".to_sym do
define_method :"#{method}?" do
state == method
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def sale_state
end

def sorted_images
images.sort_by.with_index { |a, i| a == primary_image ? -1 : i }
images.sort_by.with_index { |a, i| (a == primary_image) ? -1 : i }
end

def as_json(options = {})
Expand Down Expand Up @@ -170,7 +170,7 @@ def thumbnail

# defines methods submitted?, approved?, etc. for each possible submission state
STATES.each do |method|
define_method "#{method}?".to_sym do
define_method :"#{method}?" do
state == method
end
end
Expand Down
1 change: 1 addition & 0 deletions config/initializers/application_controller_renderer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# ActiveSupport::Reloader.to_prepare do
Expand Down
1 change: 1 addition & 0 deletions config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
1 change: 1 addition & 0 deletions config/initializers/mime_types.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
Expand Down
1 change: 1 addition & 0 deletions config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

mutation = <<-GRAPHQL
mutation {
addUserToSubmission(input: { id: \"#{submission.uuid}\" }) {
addUserToSubmission(input: { id: "#{submission.uuid}" }) {
clientMutationId
consignmentSubmission {
externalId
Expand All @@ -46,7 +46,7 @@

mutation = <<-GRAPHQL
mutation {
addUserToSubmission(input: { id: \"#{submission.uuid}\" }) {
addUserToSubmission(input: { id: "#{submission.uuid}" }) {
clientMutationId
consignmentSubmission {
externalId
Expand All @@ -68,7 +68,7 @@

mutation = <<-GRAPHQL
mutation {
addUserToSubmission(input: { id: \"#{submission.uuid}\" }) {
addUserToSubmission(input: { id: "#{submission.uuid}" }) {
clientMutationId
consignmentSubmission {
externalId
Expand All @@ -94,7 +94,7 @@

mutation = <<-GRAPHQL
mutation {
addUserToSubmission(input: { id: \"#{submission.uuid}\" }) {
addUserToSubmission(input: { id: "#{submission.uuid}" }) {
clientMutationId
consignmentSubmission {
externalId
Expand All @@ -120,7 +120,7 @@

mutation = <<-GRAPHQL
mutation {
addUserToSubmission(input: { id: \"#{submission.id}\" }) {
addUserToSubmission(input: { id: "#{submission.id}" }) {
clientMutationId
consignmentSubmission {
externalId
Expand Down

0 comments on commit bf91df4

Please sign in to comment.