From 9df54eeadeb25452daea144b8687b6ef533af563 Mon Sep 17 00:00:00 2001 From: Markus Graf Date: Sun, 26 Feb 2017 18:22:28 +0100 Subject: [PATCH] rubocop -a --- app/controllers/application_controller.rb | 2 +- app/controllers/cities_autocomplete_controller.rb | 2 +- lib/mail_chimp_batch_update.rb | 7 ++++--- spec/helpers/application_helper_spec.rb | 2 +- spec/models/supporter_spec.rb | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f5e3894..3c75543 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base # calculate how long a user needed for a form input, ussually we just def input_to_fast? - fail 'session[:form_timestamp] not set' unless session[:form_timestamp] + raise 'session[:form_timestamp] not set' unless session[:form_timestamp] duration = Time.now - session[:form_timestamp].to_time duration < INPUT_TIMEOUT end diff --git a/app/controllers/cities_autocomplete_controller.rb b/app/controllers/cities_autocomplete_controller.rb index faed9a6..5e01fcc 100644 --- a/app/controllers/cities_autocomplete_controller.rb +++ b/app/controllers/cities_autocomplete_controller.rb @@ -4,7 +4,7 @@ class CitiesAutocompleteController < ApplicationController def index @cities = CSV.read Rails.root.join('db', 'plz_ch.csv') query = ActionController::Base.helpers.sanitize(params[:query]) - @cities = @cities.select { |city| city.first =~ /#{query}/i || city.last =~ /#{query}/i } + @cities = @cities.select { |city| city.first =~ /#{query}/i || city.last =~ /#{query}/i } @cities = @cities.map { |city| { plz: city.first, city: city.last } } render json: @cities.uniq diff --git a/lib/mail_chimp_batch_update.rb b/lib/mail_chimp_batch_update.rb index d696f22..ddbf367 100644 --- a/lib/mail_chimp_batch_update.rb +++ b/lib/mail_chimp_batch_update.rb @@ -8,8 +8,8 @@ class MailChimpBatchUpdate subscribers = [] Supporter.each_with_index do |supporter, index| - subscribers.push(subscriber supporter) - if index.modulo(20) == 0 + subscribers.push(subscriber(supporter)) + if index.modulo(20).zero? batch_subscribe(subscribers) subscribers = [] end @@ -32,7 +32,8 @@ class MailChimpBatchUpdate 'MEMBERSHIP' => supporter.li_membership.to_s, 'AGE' => supporter.age_category, 'LANG' => supporter.language, - 'ZIP' => supporter.zip } } + 'ZIP' => supporter.zip + } } end def update_unsubscibed diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ebc5603..982795a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -4,7 +4,7 @@ describe ApplicationHelper do describe '.title' do it 'sets content for :title' do helper.title 'test' - expect(view.content_for :title).to eq 'test' + expect(view.content_for(:title)).to eq 'test' end end end diff --git a/spec/models/supporter_spec.rb b/spec/models/supporter_spec.rb index 8fc39e8..22d84c1 100644 --- a/spec/models/supporter_spec.rb +++ b/spec/models/supporter_spec.rb @@ -14,11 +14,11 @@ describe Supporter do describe '.counter' do it 'counts only from a certain number on' do - allow(Supporter).to receive(:count) { 12 } + allow(Supporter).to receive(:count) { 12 } expect(Supporter.counter).to eq Supporter::COUNTER_START - allow(Supporter).to receive(:count) { Supporter::COUNTER_START + 12 } + allow(Supporter).to receive(:count) { Supporter::COUNTER_START + 12 } expect(Supporter.counter).to eq Supporter::COUNTER_START + 12 end