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 IChainRecordNotFound < StandardError
end
@ -17,8 +19,8 @@ class User < ApplicationRecord
has_many :users_roles
has_many :roles, through: :users_roles, dependent: :destroy
has_paper_trail on: [:create, :update], ignore: [:sign_in_count, :remember_created_at, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip, :unconfirmed_email,
:avatar_content_type, :avatar_file_size, :avatar_updated_at, :updated_at, :confirmation_sent_at, :confirmation_token, :reset_password_token]
has_paper_trail on: %i[create update], ignore: %i[sign_in_countremember_created_atcurrent_sign_in_atlast_sign_in_atcurrent_sign_in_iplast_sign_in_ipunconfirmed_email
avatar_content_type avatar_file_size avatar_updated_at updated_at confirmation_sent_at confirmation_token reset_password_token]
include Gravtastic
gravtastic size: 32
@ -28,7 +30,7 @@ class User < ApplicationRecord
after_save :touch_events
# add scope
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
scope :comment_notifiable, ->(conference) { joins(:roles).where('roles.name IN (?)', %i[organizer cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id) }
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
@ -40,7 +42,7 @@ class User < ApplicationRecord
else
[:database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable, omniauth_providers: [:suse, :google, :facebook, :github]]
:omniauthable, omniauth_providers: %i[suse google facebook github]]
end
devise(*devise_modules)
@ -51,9 +53,9 @@ class User < ApplicationRecord
has_many :event_users, dependent: :destroy
has_many :events, -> { distinct }, through: :event_users
has_many :presented_events, -> { joins(:event_users).where(event_users: {event_role: 'speaker'}).distinct }, through: :event_users, source: :event
has_many :presented_events, -> { joins(:event_users).where(event_users: { event_role: 'speaker' }).distinct }, through: :event_users, source: :event
has_many :registrations, dependent: :destroy do
def for_conference conference
def for_conference(conference)
where(conference: conference).first
end
end
@ -61,7 +63,7 @@ class User < ApplicationRecord
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :tickets, through: :ticket_purchases, source: :ticket do
def for_registration conference
def for_registration(conference)
where(conference: conference, registration_ticket: true).first
end
end
@ -81,7 +83,7 @@ class User < ApplicationRecord
validates :username,
uniqueness: {
case_sensitive: false
case_sensitive: false
},
presence: true
@ -95,48 +97,48 @@ class User < ApplicationRecord
# === Returns
# * +true+ if the user attended the event
# * +false+ if the user did not attend the event
def attended_event? event
def attended_event?(event)
event_registration = event.events_registrations.find_by(registration: registrations)
return false unless event_registration.present?
return false if event_registration.blank?
event_registration.attended
end
def mark_attendance_for_conference conference
def mark_attendance_for_conference(conference)
registration = registrations.for_conference(conference)
registration.attended = true
registration.save
end
def name
self[:name].blank? ? username : self[:name]
self[:name].presence || username
end
##
# Checks if a user has registered to an event
# ====Returns
# * +true+ or +false+
def registered_to_event? event
def registered_to_event?(event)
event.registrations.include? registrations.find_by(conference: event.program.conference)
end
def subscribed? conference
def subscribed?(conference)
subscriptions.find_by(conference_id: conference.id).present?
end
def supports? conference
def supports?(conference)
ticket_purchases.find_by(conference_id: conference.id).present?
end
def self.for_ichain_username(username, attributes)
user = find_by(username: username)
raise UserDisabled if user && user.is_disabled
raise UserDisabled if user&.is_disabled
if user
user.update_attributes(email: attributes[:email],
last_sign_in_at: user.current_sign_in_at,
current_sign_in_at: Time.current)
user.update(email: attributes[:email],
last_sign_in_at: user.current_sign_in_at,
current_sign_in_at: Time.current)
else
begin
user = create!(username: username, email: attributes[:email])
@ -163,9 +165,7 @@ class User < ApplicationRecord
def self.find_for_auth(auth, current_user = nil)
user = current_user
if user.nil? # No current user available, user is not already logged in
user = User.where(email: auth.info.email).first_or_initialize
end
user = User.where(email: auth.info.email).first_or_initialize if user.nil? # No current user available, user is not already logged in
if user.new_record?
user.email = auth.info.email
@ -231,9 +231,7 @@ class User < ApplicationRecord
private
def setup_role
if User.count == 1 && User.first.email == 'deleted@localhost.osem'
self.is_admin = true
end
self.is_admin = true if User.count == 1 && User.first.email == 'deleted@localhost.osem'
end
def touch_events