Rebuild rubocop TODOs after auto-correcting

This commit is contained in:
James Mason 2018-04-04 10:18:51 -07:00
parent 31c50255e9
commit 84dbb52d11
No known key found for this signature in database
GPG key ID: 1B3951886C449023
580 changed files with 3689 additions and 3133 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Commercial < ApplicationRecord
require 'oembed'
@ -6,7 +8,7 @@ class Commercial < ApplicationRecord
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
validates :url, presence: true, uniqueness: { scope: :commercialable }
validates :url, format: URI::regexp(%w(http https))
validates :url, format: URI.regexp(%w[http https])
validate :valid_url
@ -36,9 +38,7 @@ class Commercial < ApplicationRecord
errors[:no_event] << id && next unless event
commercial = event.commercials.new(url: url)
unless commercial.save
errors[:validation_errors] << "Could not create commercial for event with ID #{event.id} (" + commercial.errors.full_messages.to_sentence + ')'
end
errors[:validation_errors] << "Could not create commercial for event with ID #{event.id} (" + commercial.errors.full_messages.to_sentence + ')' unless commercial.save
end
errors
end
@ -47,9 +47,7 @@ class Commercial < ApplicationRecord
def valid_url
result = Commercial.render_from_url(url)
if result[:error]
errors.add(:base, result[:error])
end
errors.add(:base, result[:error]) if result[:error]
end
def self.register_provider
@ -58,12 +56,12 @@ class Commercial < ApplicationRecord
speakerdeck << 'http://speakerdeck.com/*'
OEmbed::Providers.register(
OEmbed::Providers::Youtube,
OEmbed::Providers::Vimeo,
OEmbed::Providers::Slideshare,
OEmbed::Providers::Flickr,
OEmbed::Providers::Instagram,
speakerdeck
OEmbed::Providers::Youtube,
OEmbed::Providers::Vimeo,
OEmbed::Providers::Slideshare,
OEmbed::Providers::Flickr,
OEmbed::Providers::Instagram,
speakerdeck
)
end