Rubocop autocorrections
This commit is contained in:
@@ -33,10 +33,10 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @video.destroy
|
||||
notice = t("flash.actions.destroy.poll_question_answer_video")
|
||||
notice = if @video.destroy
|
||||
t("flash.actions.destroy.poll_question_answer_video")
|
||||
else
|
||||
notice = t("flash.actions.destroy.error")
|
||||
t("flash.actions.destroy.error")
|
||||
end
|
||||
redirect_to :back, notice: notice
|
||||
end
|
||||
|
||||
@@ -18,8 +18,7 @@ class DirectUploadsController < ApplicationController
|
||||
render json: { cached_attachment: @direct_upload.relation.cached_attachment,
|
||||
filename: @direct_upload.relation.attachment.original_filename,
|
||||
destroy_link: render_destroy_upload_link(@direct_upload).html_safe,
|
||||
attachment_url: @direct_upload.relation.attachment.url
|
||||
}
|
||||
attachment_url: @direct_upload.relation.attachment.url}
|
||||
else
|
||||
@direct_upload.destroy_attachment
|
||||
render json: { errors: @direct_upload.errors[:attachment].join(", ") },
|
||||
|
||||
@@ -22,7 +22,7 @@ module ImageablesHelper
|
||||
|
||||
def imageable_accepted_content_types_extensions
|
||||
Image::ACCEPTED_CONTENT_TYPE
|
||||
.collect{ |content_type| ".#{content_type.split("/").last}" }
|
||||
.collect{ |content_type| ".#{content_type.split('/').last}" }
|
||||
.join(",")
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ module ImageablesHelper
|
||||
.join(", ")
|
||||
end
|
||||
|
||||
def imageables_note(imageable)
|
||||
def imageables_note(_imageable)
|
||||
t "images.form.note", accepted_content_types: imageable_humanized_accepted_content_types,
|
||||
max_file_size: imageable_max_file_size
|
||||
end
|
||||
|
||||
@@ -46,11 +46,11 @@ module WelcomeHelper
|
||||
end
|
||||
|
||||
def calculate_offset(debates, proposals, apply_offset)
|
||||
if (debates.any? && proposals.any?)
|
||||
if apply_offset
|
||||
offset = "medium-offset-2 large-offset-2"
|
||||
if debates.any? && proposals.any?
|
||||
offset = if apply_offset
|
||||
"medium-offset-2 large-offset-2"
|
||||
else
|
||||
offset = "end"
|
||||
"end"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,8 +48,8 @@ class Debate < ActiveRecord::Base
|
||||
attr_accessor :link_required
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true).
|
||||
where("author_id != ?", user.id)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
|
||||
@@ -7,7 +7,7 @@ class DirectUpload
|
||||
:relation, :resource_relation,
|
||||
:attachment, :cached_attachment, :user
|
||||
|
||||
validates_presence_of :attachment, :resource_type, :resource_relation, :user
|
||||
validates :attachment, :resource_type, :resource_relation, :user, presence: true
|
||||
validate :parent_resource_attachment_validations,
|
||||
if: -> { attachment.present? && resource_type.present? && resource_relation.present? && user.present? }
|
||||
|
||||
@@ -20,13 +20,13 @@ class DirectUpload
|
||||
@resource = @resource_type.constantize.find_or_initialize_by(id: @resource_id)
|
||||
|
||||
# Refactor
|
||||
if @resource.respond_to?(:images) &&
|
||||
@relation = if @resource.respond_to?(:images) &&
|
||||
((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?)
|
||||
@relation = @resource.images.send("build", relation_attributtes)
|
||||
@resource.images.send("build", relation_attributtes)
|
||||
elsif @resource.class.reflections[@resource_relation].macro == :has_one
|
||||
@relation = @resource.send("build_#{resource_relation}", relation_attributtes)
|
||||
@resource.send("build_#{resource_relation}", relation_attributtes)
|
||||
else
|
||||
@relation = @resource.send(@resource_relation).build(relation_attributtes)
|
||||
@resource.send(@resource_relation).build(relation_attributtes)
|
||||
end
|
||||
|
||||
@relation.user = user
|
||||
@@ -50,7 +50,7 @@ class DirectUpload
|
||||
def parent_resource_attachment_validations
|
||||
@relation.valid?
|
||||
|
||||
if @relation.errors.has_key? :attachment
|
||||
if @relation.errors.key? :attachment
|
||||
errors[:attachment] = @relation.errors[:attachment]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,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
|
||||
|
||||
@@ -5,7 +5,7 @@ class Image < ActiveRecord::Base
|
||||
TITLE_LEGHT_RANGE = 4..80
|
||||
MIN_SIZE = 475
|
||||
MAX_IMAGE_SIZE = 1.megabyte
|
||||
ACCEPTED_CONTENT_TYPE = %w(image/jpeg image/jpg)
|
||||
ACCEPTED_CONTENT_TYPE = %w(image/jpeg image/jpg).freeze
|
||||
|
||||
has_attached_file :attachment, styles: { large: "x#{MIN_SIZE}", medium: "300x300#", thumb: "140x245#" },
|
||||
url: "/system/:class/:prefix/:style/:hash.:extension",
|
||||
@@ -52,7 +52,7 @@ class Image < 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Poll
|
||||
class Voter < ActiveRecord::Base
|
||||
|
||||
VALID_ORIGINS = %w{ web booth }
|
||||
VALID_ORIGINS = %w{web booth}.freeze
|
||||
|
||||
belongs_to :poll
|
||||
belongs_to :user
|
||||
|
||||
@@ -69,10 +69,10 @@ class Proposal < ActiveRecord::Base
|
||||
scope :public_for_api, -> { all }
|
||||
|
||||
def self.recommendations(user)
|
||||
tagged_with(user.interests, any: true).
|
||||
where("author_id != ?", user.id).
|
||||
unsuccessful.
|
||||
not_followed_by_user(user)
|
||||
tagged_with(user.interests, any: true)
|
||||
.where("author_id != ?", user.id)
|
||||
.unsuccessful
|
||||
.not_followed_by_user(user)
|
||||
end
|
||||
|
||||
def self.not_followed_by_user(user)
|
||||
|
||||
@@ -64,5 +64,4 @@ feature 'Officer Assignments' do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -87,7 +87,6 @@ feature 'Admin settings' do
|
||||
expect(page).to have_content "Map configuration updated succesfully"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -408,7 +408,6 @@ feature 'Emails' do
|
||||
end
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has responded to your comment')
|
||||
expect(email).to deliver_to(user1)
|
||||
|
||||
@@ -42,7 +42,7 @@ describe DirectUpload do
|
||||
|
||||
proposal_document_direct_upload.save_attachment
|
||||
|
||||
expect(File.exists?(proposal_document_direct_upload.relation.attachment.path)).to eq(true)
|
||||
expect(File.exist?(proposal_document_direct_upload.relation.attachment.path)).to eq(true)
|
||||
expect(proposal_document_direct_upload.relation.attachment.path).to include('cached_attachments')
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ describe DirectUpload do
|
||||
uploaded_path = proposal_document_direct_upload.relation.attachment.path
|
||||
proposal_document_direct_upload.destroy_attachment
|
||||
|
||||
expect(File.exists?(uploaded_path)).to eq(false)
|
||||
expect(File.exist?(uploaded_path)).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
describe "At #{mappable_new_path}" do
|
||||
|
||||
let!(:arguments) { {} }
|
||||
let!(:mappable) { create("#{mappable_factory_name}".to_sym) }
|
||||
let!(:mappable) { create(mappable_factory_name.to_s.to_sym) }
|
||||
let!(:map_location) { create(:map_location, "#{mappable_factory_name}_map_location".to_sym, "#{mappable_association_name}": mappable) }
|
||||
|
||||
before { set_arguments(arguments, mappable, mappable_path_arguments) }
|
||||
@@ -77,10 +77,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
|
||||
describe "At #{mappable_edit_path}" do
|
||||
|
||||
let!(:mappable) { create("#{mappable_factory_name}".to_sym) }
|
||||
let!(:mappable) { create(mappable_factory_name.to_s.to_sym) }
|
||||
let!(:map_location) { create(:map_location, "#{mappable_factory_name}_map_location".to_sym, "#{mappable_association_name}": mappable) }
|
||||
|
||||
before { skip } unless mappable_edit_path.present?
|
||||
before { skip } if mappable_edit_path.blank?
|
||||
|
||||
scenario "Should edit map on #{mappable_factory_name} and contain default values", :js do
|
||||
login_as mappable.author
|
||||
@@ -143,13 +143,13 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
describe "At #{mappable_show_path}" do
|
||||
|
||||
let!(:arguments) { {} }
|
||||
let!(:mappable) { create("#{mappable_factory_name}".to_sym) }
|
||||
let!(:mappable) { create(mappable_factory_name.to_s.to_sym) }
|
||||
let!(:map_location) { create(:map_location, "#{mappable_factory_name}_map_location".to_sym, "#{mappable_association_name}": mappable) }
|
||||
|
||||
before { set_arguments(arguments, mappable, mappable_path_arguments) }
|
||||
|
||||
scenario "Should display map on #{mappable_factory_name} show page", :js do
|
||||
arguments.merge!("id": mappable.id)
|
||||
arguments[:id] = mappable.id
|
||||
|
||||
visit send(mappable_show_path, arguments)
|
||||
|
||||
@@ -157,9 +157,9 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
end
|
||||
|
||||
scenario "Should not display map on #{mappable_factory_name} show when marker is not defined", :js do
|
||||
mappable_without_map = create("#{mappable_factory_name}".to_sym)
|
||||
mappable_without_map = create(mappable_factory_name.to_s.to_sym)
|
||||
set_arguments(arguments, mappable_without_map, mappable_path_arguments)
|
||||
arguments.merge!("id": mappable_without_map.id)
|
||||
arguments[:id] = mappable_without_map.id
|
||||
|
||||
visit send(mappable_show_path, arguments)
|
||||
|
||||
@@ -168,7 +168,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
|
||||
scenario "Should not display map on #{mappable_factory_name} show page when feature.map is disable", :js do
|
||||
Setting['feature.map'] = false
|
||||
arguments.merge!("id": mappable.id)
|
||||
arguments[:id] = mappable.id
|
||||
|
||||
visit send(mappable_show_path, arguments)
|
||||
|
||||
@@ -212,9 +212,7 @@ def submit_budget_investment_form
|
||||
end
|
||||
|
||||
def set_arguments(arguments, mappable, mappable_path_arguments)
|
||||
if mappable_path_arguments
|
||||
mappable_path_arguments.each do |argument_name, path_to_value|
|
||||
mappable_path_arguments&.each do |argument_name, path_to_value|
|
||||
arguments.merge!("#{argument_name}": mappable.send(path_to_value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,15 +9,11 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
let!(:imageable) { create(imageable_factory_name) }
|
||||
|
||||
before do
|
||||
if imageable_path_arguments
|
||||
imageable_path_arguments.each do |argument_name, path_to_value|
|
||||
imageable_path_arguments&.each do |argument_name, path_to_value|
|
||||
arguments.merge!("#{argument_name}": imageable.send(path_to_value))
|
||||
end
|
||||
end
|
||||
|
||||
if imageable.respond_to?(:author)
|
||||
imageable.update(author: user)
|
||||
end
|
||||
imageable.update(author: user) if imageable.respond_to?(:author)
|
||||
end
|
||||
|
||||
describe "at #{path}" do
|
||||
@@ -230,7 +226,7 @@ rescue
|
||||
return
|
||||
end
|
||||
|
||||
def imageable_attach_new_file(imageable_factory_name, path, success = true)
|
||||
def imageable_attach_new_file(_imageable_factory_name, path, success = true)
|
||||
click_link "Add image"
|
||||
within "#nested-image" do
|
||||
image = find(".image")
|
||||
|
||||
Reference in New Issue
Block a user