Rubocop autocorrections

This commit is contained in:
Bertocq
2017-11-13 02:22:00 +01:00
parent 57f8aacdd7
commit cd66ba5d54
9 changed files with 63 additions and 65 deletions

View File

@@ -22,8 +22,10 @@ class Legislation::ProposalsController < Legislation::BaseController
super super
set_legislation_proposal_votes(@process.proposals) set_legislation_proposal_votes(@process.proposals)
@document = Document.new(documentable: @proposal) @document = Document.new(documentable: @proposal)
if request.path != legislation_process_proposal_path(params[:process_id], @proposal)
redirect_to legislation_process_proposal_path(params[:process_id], @proposal), redirect_to legislation_process_proposal_path(params[:process_id], @proposal),
status: :moved_permanently if request.path != legislation_process_proposal_path(params[:process_id], @proposal) status: :moved_permanently
end
end end
def create def create

View File

@@ -29,7 +29,7 @@ module AdminHelper
end end
def menu_profiles? def menu_profiles?
["administrators", "organizations", "officials", "moderators", "valuators", "managers", "users", "activity"].include? controller_name %w[administrators organizations officials moderators valuators managers users activity].include? controller_name
end end
def menu_banners? def menu_banners?

View File

@@ -57,8 +57,7 @@ class Legislation::Proposal < ActiveRecord::Base
tag_list.join(' ') => 'B', tag_list.join(' ') => 'B',
geozone.try(:name) => 'B', geozone.try(:name) => 'B',
summary => 'C', summary => 'C',
description => 'D' description => 'D'}
}
end end
def self.search(terms) def self.search(terms)
@@ -69,7 +68,7 @@ class Legislation::Proposal < ActiveRecord::Base
def self.search_by_code(terms) def self.search_by_code(terms)
matched_code = match_code(terms) matched_code = match_code(terms)
results = where(id: matched_code[1]) if matched_code results = where(id: matched_code[1]) if matched_code
return results if (results.present? && results.first.code == terms) return results if results.present? && results.first.code == terms
end end
def self.match_code(terms) def self.match_code(terms)
@@ -105,9 +104,7 @@ class Legislation::Proposal < ActiveRecord::Base
end end
def register_vote(user, vote_value) def register_vote(user, vote_value)
if votable_by?(user) vote_by(voter: user, vote: vote_value) if votable_by?(user)
vote_by(voter: user, vote: vote_value)
end
end end
def code def code

View File

@@ -37,7 +37,7 @@ class Poll::Question::Answer < ActiveRecord::Base
end end
def most_voted? def most_voted?
self.most_voted most_voted
end end
def total_votes_percentage def total_votes_percentage
@@ -47,8 +47,8 @@ class Poll::Question::Answer < ActiveRecord::Base
def set_most_voted def set_most_voted
answers = question.question_answers answers = question.question_answers
.map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).count } .map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).count }
is_most_voted = !answers.any?{ |a| a > self.total_votes } is_most_voted = answers.none?{ |a| a > total_votes }
self.update(most_voted: is_most_voted) update(most_voted: is_most_voted)
end end
end end

View File

@@ -26,9 +26,9 @@ class Poll
end end
def total_participants_web_percentage def total_participants_web_percentage
stats_cache('total_participants_web_percentage') { stats_cache('total_participants_web_percentage') do
(total_participants) == 0 ? 0 : total_participants_web * 100 / total_participants total_participants == 0 ? 0 : total_participants_web * 100 / total_participants
} end
end end
def total_participants_booth def total_participants_booth
@@ -36,9 +36,9 @@ class Poll
end end
def total_participants_booth_percentage def total_participants_booth_percentage
stats_cache('total_participants_booth_percentage') { stats_cache('total_participants_booth_percentage') do
(total_participants) == 0 ? 0 : total_participants_booth * 100 / total_participants.to_f total_participants == 0 ? 0 : total_participants_booth * 100 / total_participants.to_f
} end
end end
def total_web_valid def total_web_valid
@@ -46,9 +46,9 @@ class Poll
end end
def valid_percentage_web def valid_percentage_web
stats_cache('valid_percentage_web') { stats_cache('valid_percentage_web') do
(total_valid_votes) == 0 ? 0 : total_web_valid * 100 / total_valid_votes.to_f total_valid_votes == 0 ? 0 : total_web_valid * 100 / total_valid_votes.to_f
} end
end end
def total_web_white def total_web_white
@@ -72,9 +72,9 @@ class Poll
end end
def valid_percentage_booth def valid_percentage_booth
stats_cache('valid_percentage_booth') { stats_cache('valid_percentage_booth') do
(total_valid_votes) == 0 ? 0 : total_booth_valid * 100 / total_valid_votes.to_f total_valid_votes == 0 ? 0 : total_booth_valid * 100 / total_valid_votes.to_f
} end
end end
def total_booth_white def total_booth_white
@@ -82,9 +82,9 @@ class Poll
end end
def white_percentage_booth def white_percentage_booth
stats_cache('white_percentage_booth') { stats_cache('white_percentage_booth') do
(total_white_votes) == 0 ? 0 : total_booth_white * 100 / total_white_votes.to_f total_white_votes == 0 ? 0 : total_booth_white * 100 / total_white_votes.to_f
} end
end end
def total_booth_null def total_booth_null
@@ -92,9 +92,9 @@ class Poll
end end
def null_percentage_booth def null_percentage_booth
stats_cache('null_percentage_booth') { stats_cache('null_percentage_booth') do
(total_null_votes == 0) ? 0 : total_booth_null * 100 / total_null_votes.to_f total_null_votes == 0 ? 0 : total_booth_null * 100 / total_null_votes.to_f
} end
end end
def total_valid_votes def total_valid_votes
@@ -102,9 +102,9 @@ class Poll
end end
def total_valid_percentage def total_valid_percentage
stats_cache('total_valid_percentage'){ stats_cache('total_valid_percentage') do
(total_participants) == 0 ? 0 : total_valid_votes * 100 / total_participants.to_f total_participants == 0 ? 0 : total_valid_votes * 100 / total_participants.to_f
} end
end end
def total_white_votes def total_white_votes
@@ -112,9 +112,9 @@ class Poll
end end
def total_white_percentage def total_white_percentage
stats_cache('total_white_percentage') { stats_cache('total_white_percentage') do
(total_participants) == 0 ? 0 : total_white_votes * 100 / total_participants.to_f total_participants == 0 ? 0 : total_white_votes * 100 / total_participants.to_f
} end
end end
def total_null_votes def total_null_votes
@@ -122,9 +122,9 @@ class Poll
end end
def total_null_percentage def total_null_percentage
stats_cache('total_null_percentage') { stats_cache('total_null_percentage') do
(total_participants) == 0 ? 0 : total_null_votes * 100 / total_participants.to_f total_participants == 0 ? 0 : total_null_votes * 100 / total_participants.to_f
} end
end end
def voters def voters

View File

@@ -102,7 +102,6 @@ class User < ActiveRecord::Base
voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value } voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value }
end end
def spending_proposal_votes(spending_proposals) def spending_proposal_votes(spending_proposals)
voted = votes.for_spending_proposals(spending_proposals) voted = votes.for_spending_proposals(spending_proposals)
voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value } voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value }

View File

@@ -14,11 +14,11 @@ feature "Notifications" do
let(:legislation_question) { create(:legislation_question, process: process, author: administrator) } let(:legislation_question) { create(:legislation_question, process: process, author: administrator) }
let(:legislation_annotation) { create(:legislation_annotation, author: author) } let(:legislation_annotation) { create(:legislation_annotation, author: author) }
let(:topic) { let(:topic) do
proposal = create(:proposal) proposal = create(:proposal)
community = proposal.community community = proposal.community
create(:topic, community: community, author: author) create(:topic, community: community, author: author)
} end
scenario "User commented on my debate", :js do scenario "User commented on my debate", :js do
create(:notification, notifiable: debate, user: author) create(:notification, notifiable: debate, user: author)

View File

@@ -303,8 +303,8 @@ module CommonActions
visit poll_path(poll) visit poll_path(poll)
within("#poll_question_#{question.id}_answers") do within("#poll_question_#{question.id}_answers") do
click_link "#{answer}" click_link answer.to_s
expect(page).to_not have_link("#{answer}") expect(page).to_not have_link(answer.to_s)
end end
end end