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
|
||||
|
||||
@@ -49,7 +49,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
|
||||
end
|
||||
|
||||
def shift_params
|
||||
shift_params = params.require(:shift).permit(:booth_id, :officer_id, :task, date:[:vote_collection_date, :recount_scrutiny_date])
|
||||
shift_params = params.require(:shift).permit(:booth_id, :officer_id, :task, date: [:vote_collection_date, :recount_scrutiny_date])
|
||||
shift_params.merge(date: shift_params[:date]["#{shift_params[:task]}_date".to_sym])
|
||||
end
|
||||
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(", ") },
|
||||
@@ -28,7 +27,7 @@ class DirectUploadsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user) )
|
||||
@direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user))
|
||||
@direct_upload.relation.set_attachment_from_cached_attachment
|
||||
|
||||
if @direct_upload.destroy_attachment
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@ module Followable
|
||||
has_many :follows, as: :followable, dependent: :destroy
|
||||
has_many :followers, through: :follows, source: :user
|
||||
|
||||
scope :followed_by_user, -> (user){
|
||||
scope :followed_by_user, ->(user){
|
||||
joins(:follows).where("follows.user_id = ?", user.id)
|
||||
}
|
||||
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? }
|
||||
|
||||
@@ -19,14 +19,14 @@ class DirectUpload
|
||||
if @resource_type.present? && @resource_relation.present? && (@attachment.present? || @cached_attachment.present?)
|
||||
@resource = @resource_type.constantize.find_or_initialize_by(id: @resource_id)
|
||||
|
||||
#Refactor
|
||||
if @resource.respond_to?(:images) &&
|
||||
# Refactor
|
||||
@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
|
||||
|
||||
@@ -394,7 +394,7 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
scenario 'Debates are ordered by recommendations when there is a user logged', :js do
|
||||
proposal = create(:proposal, tag_list: "Sport" )
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
user = create(:user)
|
||||
create(:follow, followable: proposal, user: user)
|
||||
login_as(user)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -27,7 +27,7 @@ feature "Home" do
|
||||
background do
|
||||
Setting['feature.user.recommendations'] = true
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: "Sport" )
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -725,10 +725,10 @@ describe Debate do
|
||||
end
|
||||
|
||||
it "Should return debates ordered by cached_votes_total" do
|
||||
debate1 = create(:debate, cached_votes_total: 1, tag_list: "Sport" )
|
||||
debate2 = create(:debate, cached_votes_total: 5, tag_list: "Sport" )
|
||||
debate3 = create(:debate, cached_votes_total: 10, tag_list: "Sport" )
|
||||
proposal = create(:proposal, tag_list: "Sport" )
|
||||
debate1 = create(:debate, cached_votes_total: 1, tag_list: "Sport")
|
||||
debate2 = create(:debate, cached_votes_total: 5, tag_list: "Sport")
|
||||
debate3 = create(:debate, cached_votes_total: 10, tag_list: "Sport")
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
result = Debate.recommendations(user).sort_by_recommendations
|
||||
@@ -753,7 +753,7 @@ describe Debate do
|
||||
it "Should not return debates when user is the author" do
|
||||
debate1 = create(:debate, author: user, tag_list: "Sport")
|
||||
debate2 = create(:debate, tag_list: "Sport")
|
||||
proposal = create(:proposal, tag_list: "Sport" )
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
result = Debate.recommendations(user)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe MapLocation do
|
||||
|
||||
let(:map_location) { build(:map_location, :proposal_map_location ) }
|
||||
let(:map_location) { build(:map_location, :proposal_map_location) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(map_location).to be_valid
|
||||
|
||||
@@ -903,10 +903,10 @@ describe Proposal do
|
||||
end
|
||||
|
||||
it "Should return proposals ordered by cached_votes_up" do
|
||||
proposal1 = create(:proposal, cached_votes_up: 1, tag_list: "Sport" )
|
||||
proposal2 = create(:proposal, cached_votes_up: 5, tag_list: "Sport" )
|
||||
proposal3 = create(:proposal, cached_votes_up: 10, tag_list: "Sport" )
|
||||
proposal4 = create(:proposal, tag_list: "Sport" )
|
||||
proposal1 = create(:proposal, cached_votes_up: 1, tag_list: "Sport")
|
||||
proposal2 = create(:proposal, cached_votes_up: 5, tag_list: "Sport")
|
||||
proposal3 = create(:proposal, cached_votes_up: 10, tag_list: "Sport")
|
||||
proposal4 = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal4, user: user)
|
||||
|
||||
result = Proposal.recommendations(user).sort_by_recommendations
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -199,8 +199,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
find("#tab-documents-label").click
|
||||
expect(page).to have_content "empty.pdf"
|
||||
|
||||
#Review
|
||||
#Doble check why the file is stored with a name different to empty.pdf
|
||||
# Review
|
||||
# Doble check why the file is stored with a name different to empty.pdf
|
||||
expect(page).to have_css("a[href$='.pdf']")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images=false|
|
||||
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images = false|
|
||||
include ActionView::Helpers
|
||||
include ImagesHelper
|
||||
include ImageablesHelper
|
||||
@@ -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
|
||||
@@ -119,7 +115,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
click_on submit_button
|
||||
|
||||
if has_many_images
|
||||
#Pending. Review soon and test
|
||||
# Pending. Review soon and test
|
||||
else
|
||||
within "#nested-image .image" do
|
||||
expect(page).to have_content("can't be blank", count: 2)
|
||||
@@ -174,7 +170,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
imageable_redirected_to_resource_show_or_navigate_to
|
||||
|
||||
if has_many_images
|
||||
#Pending. Review soon and test
|
||||
# Pending. Review soon and test
|
||||
else
|
||||
expect(page).to have_selector "figure img"
|
||||
expect(page).to have_selector "figure figcaption"
|
||||
@@ -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")
|
||||
|
||||
@@ -163,7 +163,7 @@ module CommonActions
|
||||
expect(page).to have_content 'Document verified with Census'
|
||||
end
|
||||
|
||||
def confirm_phone(user=nil)
|
||||
def confirm_phone(user = nil)
|
||||
user ||= User.last
|
||||
|
||||
fill_in 'sms_phone', with: "611111111"
|
||||
|
||||
Reference in New Issue
Block a user