Rubocop autocorrections

This commit is contained in:
Bertocq
2017-09-14 13:18:37 +02:00
parent 93323cb917
commit e4e78c8f16
25 changed files with 53 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
class Admin::Poll::ShiftsController < Admin::BaseController
before_action :load_booth
before_action :load_polls
before_action :load_officer

View File

@@ -7,7 +7,7 @@ class CommunitiesController < ApplicationController
skip_authorization_check
def show
redirect_to root_path unless Setting['feature.community'].present?
redirect_to root_path if Setting['feature.community'].blank?
end
private

View File

@@ -1,8 +1,8 @@
class DocumentsController < ApplicationController
before_action :authenticate_user!
before_filter :find_documentable, except: :destroy
before_filter :prepare_new_document, only: [:new, :new_nested]
before_filter :prepare_document_for_creation, only: :create
before_action :find_documentable, except: :destroy
before_action :prepare_new_document, only: [:new, :new_nested]
before_action :prepare_document_for_creation, only: :create
load_and_authorize_resource except: :upload
skip_authorization_check only: :upload

View File

@@ -78,7 +78,7 @@ class ProposalsController < ApplicationController
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
:responsible_name, :tag_list, :terms_of_service, :geozone_id,
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id] )
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
end
def retired_params

View File

@@ -18,8 +18,8 @@ module DocumentablesHelper
def accepted_content_types_extensions(documentable_class)
documentable_class.accepted_content_types
.collect{ |content_type| ".#{content_type.split("/").last}" }
.join(",")
.collect{ |content_type| ".#{content_type.split('/').last}" }
.join(",")
end
def humanized_accepted_content_types(documentable)

View File

@@ -80,10 +80,10 @@ module DocumentsHelper
def document_direct_upload_url(document)
upload_documents_url(
documentable_type: document.documentable_type,
documentable_id: document.documentable_id,
format: :js
)
documentable_type: document.documentable_type,
documentable_id: document.documentable_id,
format: :js
)
end
end

View File

@@ -11,7 +11,7 @@ class Community < ActiveRecord::Base
end
def from_proposal?
self.proposal.present?
proposal.present?
end
private

View File

@@ -10,7 +10,7 @@ module Documentable
private
def documentable(options= {})
def documentable(options = {})
@max_documents_allowed = options[:max_documents_allowed]
@max_file_size = options[:max_file_size]
@accepted_content_types = options[:accepted_content_types]

View File

@@ -40,7 +40,7 @@ class Document < ActiveRecord::Base
attachment.instance.prefix(attachment, style)
end
def prefix(attachment, style)
def prefix(attachment, _style)
if !attachment.instance.persisted?
"cached_attachments/user/#{attachment.instance.user_id}"
else
@@ -75,7 +75,7 @@ class Document < ActiveRecord::Base
end
def remove_cached_document
File.delete(cached_attachment) if File.exists?(cached_attachment)
File.delete(cached_attachment) if File.exist?(cached_attachment)
end
end

View File

@@ -5,7 +5,7 @@ class Poll
has_many :shifts
validates :name, presence: true, uniqueness: true
def self.search(terms)
return Booth.none if terms.blank?
Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%")

View File

@@ -1,13 +1,13 @@
class Poll
class Shift < ActiveRecord::Base
belongs_to :booth
belongs_to :officer
belongs_to :booth
belongs_to :officer
validates :booth_id, presence: true
validates :officer_id, presence: true
validates :date, presence: true
validates :date, uniqueness: { scope: [:officer_id, :booth_id] }
before_create :persist_data
after_create :create_officer_assignments
@@ -20,7 +20,7 @@ class Poll
end
end
def persist_data
def persist_data
self.officer_name = officer.name
self.officer_email = officer.email
end

View File

@@ -13,6 +13,6 @@ class Topic < ActiveRecord::Base
scope :sort_by_newest, -> { order(created_at: :desc) }
scope :sort_by_oldest, -> { order(created_at: :asc) }
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }
end

View File

@@ -57,13 +57,13 @@ class User < ActiveRecord::Base
scope :officials, -> { where("official_level > 0") }
scope :newsletter, -> { where(newsletter: true) }
scope :for_render, -> { includes(:organization) }
scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) }
scope :by_document, ->(document_type, document_number) { where(document_type: document_type, document_number: document_number) }
scope :email_digest, -> { where(email_digest: true) }
scope :active, -> { where(erased_at: nil) }
scope :erased, -> { where.not(erased_at: nil) }
scope :public_for_api, -> { all }
scope :by_comments, -> (query, topics_ids) { joins(:comments).where(query, topics_ids).uniq }
scope :by_authors, -> (author_ids) { where("users.id IN (?)", author_ids) }
scope :by_comments, ->(query, topics_ids) { joins(:comments).where(query, topics_ids).uniq }
scope :by_authors, ->(author_ids) { where("users.id IN (?)", author_ids) }
before_validation :clean_document_number