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

@@ -24,6 +24,7 @@ gem 'graphql', '~> 1.6.3'
gem 'groupdate', '~> 3.2.0'
gem 'initialjs-rails', '~> 0.2.0.5'
gem 'invisible_captcha', '~> 0.9.2'
gem 'jquery-fileupload-rails'
gem 'jquery-rails', '~> 4.3.1'
gem 'jquery-ui-rails', '~> 6.0.1'
gem 'kaminari', '~> 1.0.1'
@@ -33,7 +34,6 @@ gem 'omniauth-facebook', '~> 4.0.0'
gem 'omniauth-google-oauth2', '~> 0.4.0'
gem 'omniauth-twitter', '~> 1.4.0'
gem 'paperclip', '~> 5.1.0'
gem 'jquery-fileupload-rails'
gem 'paranoia', '~> 2.3.1'
gem 'pg', '~> 0.21.0'
gem 'pg_search', '~> 2.0.1'

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

View File

@@ -44,13 +44,13 @@ feature 'Admin booths' do
current_poll = create(:poll, :current)
incoming_poll = create(:poll, :incoming)
expired_poll = create(:poll, :expired)
create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll)
create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll)
create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll)
visit admin_root_path
within('#side_menu') do
click_link "Manage shifts"
end

View File

@@ -8,13 +8,13 @@ feature 'Admin shifts' do
end
scenario "Show" do
poll = create(:poll)
poll = create(:poll)
officer = create(:poll_officer)
booth1 = create(:poll_booth)
booth2 = create(:poll_booth)
shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today)
shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today)
shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Date.tomorrow)
visit new_admin_booth_shift_path(booth1)
@@ -36,7 +36,7 @@ feature 'Admin shifts' do
officer = create(:poll_officer)
visit admin_booths_path
within("#booth_#{booth.id}") do
click_link "Manage shifts"
end
@@ -47,7 +47,7 @@ feature 'Admin shifts' do
select I18n.l(poll.starts_at.to_date, format: :long), from: 'shift_date'
click_button "Add shift"
expect(page).to have_content "Shift added"
within("#shifts") do
@@ -63,7 +63,7 @@ feature 'Admin shifts' do
officer = create(:poll_officer)
visit admin_booths_path
within("#booth_#{booth.id}") do
click_link "Manage shifts"
end
@@ -84,7 +84,7 @@ feature 'Admin shifts' do
shift = create(:poll_shift, officer: officer, booth: booth)
visit admin_booths_path
within("#booth_#{booth.id}") do
click_link "Manage shifts"
end

View File

@@ -341,7 +341,7 @@ feature 'Budget Investments' do
scenario 'Can not access the community' do
Setting['feature.community'] = false
investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget_id: budget.id, id: investment.id)
expect(page).not_to have_content "Access the community"

View File

@@ -33,7 +33,7 @@ feature 'Commenting debates' do
expect(page).to have_content second_child.body
expect(page).to have_link "Go back to #{debate.title}", href: debate_path(debate)
expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2)
expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1)
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)

View File

@@ -102,7 +102,7 @@ feature 'Proposals' do
scenario 'Can not access the community' do
Setting['feature.community'] = false
proposal = create(:proposal)
visit proposal_path(proposal)
expect(page).not_to have_content "Access the community"

View File

@@ -41,7 +41,7 @@ describe 'Communities Rake' do
expect(investment.community).to be_present
end
end
end

View File

@@ -25,20 +25,20 @@ describe :booth do
end
describe "#available" do
it "returns booths associated to current or incoming polls" do
booth_for_current_poll = create(:poll_booth)
booth_for_incoming_poll = create(:poll_booth)
booth_for_expired_poll = create(:poll_booth)
current_poll = create(:poll, :current)
incoming_poll = create(:poll, :incoming)
expired_poll = create(:poll, :expired)
create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll)
create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll)
create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll)
expect(Poll::Booth.available).to include(booth_for_current_poll)
expect(Poll::Booth.available).to include(booth_for_incoming_poll)
expect(Poll::Booth.available).to_not include(booth_for_expired_poll)

View File

@@ -43,7 +43,7 @@ describe :shift do
officer_assignments = Poll::OfficerAssignment.all
expect(officer_assignments.count).to eq(2)
oa1 = officer_assignments.first
oa2 = officer_assignments.second
@@ -59,10 +59,10 @@ describe :shift do
end
describe "#persist_data" do
let(:user) { create(:user, username: "Ana", email: "ana@example.com") }
let(:officer) { create(:poll_officer, user: user) }
let(:shift) { create(:poll_shift, officer: officer) }
let(:user) { create(:user, username: "Ana", email: "ana@example.com") }
let(:officer) { create(:poll_officer, user: user) }
let(:shift) { create(:poll_shift, officer: officer) }
it "should maintain officer data after destroying associated user" do
shift.officer.user.destroy
@@ -79,5 +79,5 @@ describe :shift do
end
end
end

View File

@@ -71,5 +71,4 @@ describe Topic do
end
end

View File

@@ -60,7 +60,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
login_as(user)
visit send(documentable_path, arguments)
click_link "Upload document"
click_link "Upload document"
expect(page).to have_selector("h1", text: "Upload document")
end

View File

@@ -11,10 +11,8 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
before do
create(:administrator, user: administrator)
if documentable_path_arguments
documentable_path_arguments.each do |argument_name, path_to_value|
documentable_path_arguments&.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": documentable.send(path_to_value))
end
end
end
@@ -222,7 +220,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
send(fill_resource_method_name) if fill_resource_method_name
documentable.class.max_documents_allowed.times.each do |index|
attach_new_file(documentable_factory_name, index , "spec/fixtures/files/empty.pdf")
attach_new_file(documentable_factory_name, index, "spec/fixtures/files/empty.pdf")
end
click_on submit_button